Update naming for vertex state

- VertexInputDescriptor -> VertexStateDescriptor
- VertexBufferDescriptor -> VertexBufferLayoutDescriptor
- VertexBufferDescriptor.stride -> .arrayStride
- VertexAttributeDescriptor.offset no longer optional

gpuweb PR: https://github.com/gpuweb/gpuweb/pull/469

Bug: dawn:22
Change-Id: I5431df4ba22cfbdb1bc81e6709e562cd736892a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13100
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Kai Ninomiya
2019-11-07 22:23:29 +00:00
committed by Commit Bot service account
parent c3284fa40e
commit ae1f25fee8
39 changed files with 507 additions and 497 deletions

View File

@@ -46,10 +46,10 @@ class DestroyTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -46,10 +46,10 @@ class DrawIndexedIndirectTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -46,10 +46,10 @@ class DrawIndexedTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -46,10 +46,10 @@ class DrawIndirectTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -46,10 +46,10 @@ class DrawTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -51,11 +51,11 @@ class IndexFormatTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.indexFormat = format;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.indexFormat = format;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor);

View File

@@ -187,10 +187,10 @@ class PrimitiveTopologyTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -77,10 +77,10 @@ class RenderBundleTest : public DawnTest {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor);

View File

@@ -362,10 +362,10 @@ class VertexFormatTest : public DawnTest {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.cVertexInput.bufferCount = 1;
descriptor.cVertexInput.cBuffers[0].stride = strideBytes;
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
descriptor.cVertexInput.cAttributes[0].format = format;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = strideBytes;
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = format;
descriptor.cColorStates[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor);

View File

@@ -21,10 +21,11 @@
using wgpu::InputStepMode;
using wgpu::VertexFormat;
// Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each triangle
// is position in the grid such that X will correspond to the "triangle number" and the Y to the instance number.
// Each test will set up an input state and buffers, and the vertex shader will check that the vertex attributes
// corresponds to predetermined values. On success it outputs green, otherwise red.
// Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each
// triangle is position in the grid such that X will correspond to the "triangle number" and the Y
// to the instance number. Each test will set up an input state and buffers, and the vertex shader
// will check that the vertex attributes corresponds to predetermined values. On success it outputs
// green, otherwise red.
//
// The predetermined values are "K * gl_VertexID + componentIndex" for vertex-indexed buffers, and
// "K * gl_InstanceID + componentIndex" for instance-indexed buffers.
@@ -33,7 +34,7 @@ constexpr static unsigned int kRTSize = 400;
constexpr static unsigned int kRTCellOffset = 50;
constexpr static unsigned int kRTCellSize = 100;
class VertexInputTest : public DawnTest {
class VertexStateTest : public DawnTest {
protected:
void TestSetUp() override {
DawnTest::TestSetUp();
@@ -64,7 +65,7 @@ class VertexInputTest : public DawnTest {
VertexFormat format;
InputStepMode step;
};
wgpu::RenderPipeline MakeTestPipeline(const wgpu::VertexInputDescriptor& vertexInput,
wgpu::RenderPipeline MakeTestPipeline(const wgpu::VertexStateDescriptor& vertexState,
int multiplier,
const std::vector<ShaderTestSpec>& testSpec) {
std::ostringstream vs;
@@ -131,7 +132,7 @@ class VertexInputTest : public DawnTest {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertexInput = &vertexInput;
descriptor.vertexState = &vertexState;
descriptor.cColorStates[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor);
@@ -143,37 +144,37 @@ class VertexInputTest : public DawnTest {
VertexFormat format;
};
struct VertexBufferSpec {
uint64_t stride;
uint64_t arrayStride;
InputStepMode step;
std::vector<VertexAttributeSpec> attributes;
};
utils::ComboVertexInputDescriptor MakeVertexInput(
utils::ComboVertexStateDescriptor MakeVertexState(
const std::vector<VertexBufferSpec>& buffers) {
utils::ComboVertexInputDescriptor vertexInput;
uint32_t bufferCount = 0;
utils::ComboVertexStateDescriptor vertexState;
uint32_t vertexBufferCount = 0;
uint32_t totalNumAttributes = 0;
for (const VertexBufferSpec& buffer : buffers) {
vertexInput.cBuffers[bufferCount].stride = buffer.stride;
vertexInput.cBuffers[bufferCount].stepMode = buffer.step;
vertexState.cVertexBuffers[vertexBufferCount].arrayStride = buffer.arrayStride;
vertexState.cVertexBuffers[vertexBufferCount].stepMode = buffer.step;
vertexInput.cBuffers[bufferCount].attributes =
&vertexInput.cAttributes[totalNumAttributes];
vertexState.cVertexBuffers[vertexBufferCount].attributes =
&vertexState.cAttributes[totalNumAttributes];
for (const VertexAttributeSpec& attribute : buffer.attributes) {
vertexInput.cAttributes[totalNumAttributes].shaderLocation = attribute.location;
vertexInput.cAttributes[totalNumAttributes].offset = attribute.offset;
vertexInput.cAttributes[totalNumAttributes].format = attribute.format;
vertexState.cAttributes[totalNumAttributes].shaderLocation = attribute.location;
vertexState.cAttributes[totalNumAttributes].offset = attribute.offset;
vertexState.cAttributes[totalNumAttributes].format = attribute.format;
totalNumAttributes++;
}
vertexInput.cBuffers[bufferCount].attributeCount =
vertexState.cVertexBuffers[vertexBufferCount].attributeCount =
static_cast<uint32_t>(buffer.attributes.size());
bufferCount++;
vertexBufferCount++;
}
vertexInput.bufferCount = bufferCount;
return vertexInput;
vertexState.vertexBufferCount = vertexBufferCount;
return vertexState;
}
template <typename T>
@@ -232,11 +233,11 @@ class VertexInputTest : public DawnTest {
};
// Test compilation and usage of the fixture :)
TEST_P(VertexInputTest, Basic) {
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
TEST_P(VertexStateTest, Basic) {
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
// clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@@ -249,14 +250,14 @@ TEST_P(VertexInputTest, Basic) {
}
// Test a stride of 0 works
TEST_P(VertexInputTest, ZeroStride) {
TEST_P(VertexStateTest, ZeroStride) {
// This test was failing only on AMD but the OpenGL backend doesn't gather PCI info yet.
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
utils::ComboVertexInputDescriptor vertexInput =
MakeVertexInput({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}});
utils::ComboVertexStateDescriptor vertexState =
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 0, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
0,
@@ -268,36 +269,36 @@ TEST_P(VertexInputTest, ZeroStride) {
}
// Test attributes defaults to (0, 0, 0, 1) if the input state doesn't have all components
TEST_P(VertexInputTest, AttributeExpanding) {
TEST_P(VertexStateTest, AttributeExpanding) {
// This test was failing only on AMD but the OpenGL backend doesn't gather PCI info yet.
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
// R32F case
{
utils::ComboVertexInputDescriptor vertexInput =
MakeVertexInput({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float}}}});
utils::ComboVertexStateDescriptor vertexState =
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 0, {{0, VertexFormat::Float, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
}
// RG32F case
{
utils::ComboVertexInputDescriptor vertexInput =
MakeVertexInput({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float2}}}});
utils::ComboVertexStateDescriptor vertexState =
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float2}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 0, {{0, VertexFormat::Float2, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float2, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
}
// RGB32F case
{
utils::ComboVertexInputDescriptor vertexInput =
MakeVertexInput({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float3}}}});
utils::ComboVertexStateDescriptor vertexState =
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float3}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 0, {{0, VertexFormat::Float3, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float3, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@@ -305,14 +306,14 @@ TEST_P(VertexInputTest, AttributeExpanding) {
}
// Test a stride larger than the attributes
TEST_P(VertexInputTest, StrideLargerThanAttributes) {
TEST_P(VertexStateTest, StrideLargerThanAttributes) {
// This test was failing only on AMD but the OpenGL backend doesn't gather PCI info yet.
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{8 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
// clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@@ -325,13 +326,13 @@ TEST_P(VertexInputTest, StrideLargerThanAttributes) {
}
// Test two attributes at an offset, vertex version
TEST_P(VertexInputTest, TwoAttributesAtAnOffsetVertex) {
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
TEST_P(VertexStateTest, TwoAttributesAtAnOffsetVertex) {
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{8 * sizeof(float),
InputStepMode::Vertex,
{{0, 0, VertexFormat::Float4}, {1, 4 * sizeof(float), VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
// clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@@ -344,13 +345,13 @@ TEST_P(VertexInputTest, TwoAttributesAtAnOffsetVertex) {
}
// Test two attributes at an offset, instance version
TEST_P(VertexInputTest, TwoAttributesAtAnOffsetInstance) {
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
TEST_P(VertexStateTest, TwoAttributesAtAnOffsetInstance) {
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{8 * sizeof(float),
InputStepMode::Instance,
{{0, 0, VertexFormat::Float4}, {1, 4 * sizeof(float), VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
// clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@@ -363,11 +364,11 @@ TEST_P(VertexInputTest, TwoAttributesAtAnOffsetInstance) {
}
// Test a pure-instance input state
TEST_P(VertexInputTest, PureInstance) {
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
TEST_P(VertexStateTest, PureInstance) {
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
// clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@@ -382,8 +383,8 @@ TEST_P(VertexInputTest, PureInstance) {
// Test with mixed everything, vertex vs. instance, different stride and offsets
// different attribute types
TEST_P(VertexInputTest, MixedEverything) {
utils::ComboVertexInputDescriptor vertexInput = MakeVertexInput(
TEST_P(VertexStateTest, MixedEverything) {
utils::ComboVertexStateDescriptor vertexState = MakeVertexState(
{{12 * sizeof(float),
InputStepMode::Vertex,
{{0, 0, VertexFormat::Float}, {1, 6 * sizeof(float), VertexFormat::Float2}}},
@@ -391,7 +392,7 @@ TEST_P(VertexInputTest, MixedEverything) {
InputStepMode::Instance,
{{2, 0, VertexFormat::Float3}, {3, 5 * sizeof(float), VertexFormat::Float4}}}});
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1,
MakeTestPipeline(vertexState, 1,
{{0, VertexFormat::Float, InputStepMode::Vertex},
{1, VertexFormat::Float2, InputStepMode::Vertex},
{2, VertexFormat::Float3, InputStepMode::Instance},
@@ -415,13 +416,13 @@ TEST_P(VertexInputTest, MixedEverything) {
}
// Test input state is unaffected by unused vertex slot
TEST_P(VertexInputTest, UnusedVertexSlot) {
TEST_P(VertexStateTest, UnusedVertexSlot) {
// Instance input state, using slot 1
utils::ComboVertexInputDescriptor instanceVertexInput = MakeVertexInput(
utils::ComboVertexStateDescriptor instanceVertexState = MakeVertexState(
{{0, InputStepMode::Vertex, {}},
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
instanceVertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
instanceVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
// clang-format off
wgpu::Buffer buffer = MakeVertexBuffer<float>({
@@ -454,19 +455,19 @@ TEST_P(VertexInputTest, UnusedVertexSlot) {
// This was a problem with the D3D12 backend where SetVertexBuffer
// was getting the input from the last set pipeline, not the current.
// SetVertexBuffer should be reapplied when the input state changes.
TEST_P(VertexInputTest, MultiplePipelinesMixedVertexInput) {
TEST_P(VertexStateTest, MultiplePipelinesMixedVertexState) {
// Basic input state, using slot 0
utils::ComboVertexInputDescriptor vertexVertexInput = MakeVertexInput(
utils::ComboVertexStateDescriptor vertexVertexState = MakeVertexState(
{{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline vertexPipeline =
MakeTestPipeline(vertexVertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
// Instance input state, using slot 1
utils::ComboVertexInputDescriptor instanceVertexInput = MakeVertexInput(
utils::ComboVertexStateDescriptor instanceVertexState = MakeVertexState(
{{0, InputStepMode::Instance, {}},
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}});
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
instanceVertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
instanceVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
// clang-format off
wgpu::Buffer buffer = MakeVertexBuffer<float>({
@@ -499,28 +500,28 @@ TEST_P(VertexInputTest, MultiplePipelinesMixedVertexInput) {
}
// Checks that using the last vertex buffer doesn't overflow the vertex buffer table in Metal.
TEST_P(VertexInputTest, LastAllowedVertexBuffer) {
TEST_P(VertexStateTest, LastAllowedVertexBuffer) {
constexpr uint32_t kBufferIndex = kMaxVertexBuffers - 1;
utils::ComboVertexInputDescriptor vertexInput;
utils::ComboVertexStateDescriptor vertexState;
// All the other vertex buffers default to no attributes
vertexInput.bufferCount = kMaxVertexBuffers;
vertexInput.cBuffers[kBufferIndex].stride = 4 * sizeof(float);
vertexInput.cBuffers[kBufferIndex].stepMode = InputStepMode::Vertex;
vertexInput.cBuffers[kBufferIndex].attributeCount = 1;
vertexInput.cBuffers[kBufferIndex].attributes = &vertexInput.cAttributes[0];
vertexInput.cAttributes[0].shaderLocation = 0;
vertexInput.cAttributes[0].offset = 0;
vertexInput.cAttributes[0].format = VertexFormat::Float4;
vertexState.vertexBufferCount = kMaxVertexBuffers;
vertexState.cVertexBuffers[kBufferIndex].arrayStride = 4 * sizeof(float);
vertexState.cVertexBuffers[kBufferIndex].stepMode = InputStepMode::Vertex;
vertexState.cVertexBuffers[kBufferIndex].attributeCount = 1;
vertexState.cVertexBuffers[kBufferIndex].attributes = &vertexState.cAttributes[0];
vertexState.cAttributes[0].shaderLocation = 0;
vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].format = VertexFormat::Float4;
wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{kMaxVertexBuffers - 1, &buffer0}});
}
DAWN_INSTANTIATE_TEST(VertexInputTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
DAWN_INSTANTIATE_TEST(VertexStateTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
// TODO for the input state:
// - Add more vertex formats
@@ -530,10 +531,10 @@ DAWN_INSTANTIATE_TEST(VertexInputTest, D3D12Backend, MetalBackend, OpenGLBackend
// - Check for attribute narrowing
// - Check that the input state and the pipeline vertex input types match
class OptionalVertexInputTest : public DawnTest {};
class OptionalVertexStateTest : public DawnTest {};
// Test that vertex input is not required in render pipeline descriptor.
TEST_P(OptionalVertexInputTest, Basic) {
TEST_P(OptionalVertexStateTest, Basic) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
wgpu::ShaderModule vsModule =
@@ -556,7 +557,7 @@ TEST_P(OptionalVertexInputTest, Basic) {
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
descriptor.vertexInput = nullptr;
descriptor.vertexState = nullptr;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
@@ -574,7 +575,7 @@ TEST_P(OptionalVertexInputTest, Basic) {
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 1, 1);
}
DAWN_INSTANTIATE_TEST(OptionalVertexInputTest,
DAWN_INSTANTIATE_TEST(OptionalVertexStateTest,
D3D12Backend,
MetalBackend,
OpenGLBackend,

View File

@@ -346,10 +346,10 @@ void DrawCallPerf::TestSetUp() {
// Setup the base render pipeline descriptor.
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device);
renderPipelineDesc.cVertexInput.bufferCount = 1;
renderPipelineDesc.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
renderPipelineDesc.cVertexInput.cBuffers[0].attributeCount = 1;
renderPipelineDesc.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
renderPipelineDesc.cVertexState.vertexBufferCount = 1;
renderPipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
renderPipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1;
renderPipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState;
renderPipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;

View File

@@ -98,11 +98,11 @@ namespace {
descriptor->layout = pipelineLayout;
descriptor->vertexStage.module = vsModule;
descriptor->cFragmentStage.module = fsModule;
descriptor->cVertexInput.bufferCount = 1;
descriptor->cVertexInput.cBuffers[0].stride = 2 * sizeof(float);
descriptor->cVertexInput.cBuffers[0].attributeCount = 1;
descriptor->cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float2;
descriptor->cVertexInput.cAttributes[0].shaderLocation = 0;
descriptor->cVertexState.vertexBufferCount = 1;
descriptor->cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
descriptor->cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor->cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float2;
descriptor->cVertexState.cAttributes[0].shaderLocation = 0;
}
wgpu::ShaderModule vsModule;

View File

@@ -57,7 +57,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertexInput = nullptr;
descriptor.vertexState = nullptr;
device.CreateRenderPipeline(&descriptor);
}

View File

@@ -70,13 +70,13 @@ class VertexBufferValidationTest : public ValidationTest {
descriptor.cFragmentStage.module = fsModule;
for (unsigned int i = 0; i < bufferCount; ++i) {
descriptor.cVertexInput.cBuffers[i].attributeCount = 1;
descriptor.cVertexInput.cBuffers[i].attributes =
&descriptor.cVertexInput.cAttributes[i];
descriptor.cVertexInput.cAttributes[i].shaderLocation = i;
descriptor.cVertexInput.cAttributes[i].format = wgpu::VertexFormat::Float3;
descriptor.cVertexState.cVertexBuffers[i].attributeCount = 1;
descriptor.cVertexState.cVertexBuffers[i].attributes =
&descriptor.cVertexState.cAttributes[i];
descriptor.cVertexState.cAttributes[i].shaderLocation = i;
descriptor.cVertexState.cAttributes[i].format = wgpu::VertexFormat::Float3;
}
descriptor.cVertexInput.bufferCount = bufferCount;
descriptor.cVertexState.vertexBufferCount = bufferCount;
return device.CreateRenderPipeline(&descriptor);
}

View File

@@ -17,10 +17,10 @@
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/WGPUHelpers.h"
class VertexInputTest : public ValidationTest {
class VertexStateTest : public ValidationTest {
protected:
void CreatePipeline(bool success,
const utils::ComboVertexInputDescriptor& state,
const utils::ComboVertexStateDescriptor& state,
std::string vertexSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(
device, utils::SingleShaderStage::Vertex, vertexSource.c_str());
@@ -36,7 +36,7 @@ class VertexInputTest : public ValidationTest {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertexInput = &state;
descriptor.vertexState = &state;
descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
if (!success) {
@@ -48,8 +48,8 @@ class VertexInputTest : public ValidationTest {
};
// Check an empty vertex input is valid
TEST_F(VertexInputTest, EmptyIsOk) {
utils::ComboVertexInputDescriptor state;
TEST_F(VertexStateTest, EmptyIsOk) {
utils::ComboVertexStateDescriptor state;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -59,13 +59,13 @@ TEST_F(VertexInputTest, EmptyIsOk) {
}
// Check null buffer is valid
TEST_F(VertexInputTest, NullBufferIsOk) {
utils::ComboVertexInputDescriptor state;
TEST_F(VertexStateTest, NullBufferIsOk) {
utils::ComboVertexStateDescriptor state;
// One null buffer (buffer[0]) is OK
state.bufferCount = 1;
state.cBuffers[0].stride = 0;
state.cBuffers[0].attributeCount = 0;
state.cBuffers[0].attributes = nullptr;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 0;
state.cVertexBuffers[0].attributeCount = 0;
state.cVertexBuffers[0].attributes = nullptr;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -74,10 +74,10 @@ TEST_F(VertexInputTest, NullBufferIsOk) {
)");
// One null buffer (buffer[0]) followed by a buffer (buffer[1]) is OK
state.bufferCount = 2;
state.cBuffers[1].stride = 0;
state.cBuffers[1].attributeCount = 1;
state.cBuffers[1].attributes = &state.cAttributes[0];
state.vertexBufferCount = 2;
state.cVertexBuffers[1].arrayStride = 0;
state.cVertexBuffers[1].attributeCount = 1;
state.cVertexBuffers[1].attributes = &state.cAttributes[0];
state.cAttributes[0].shaderLocation = 0;
CreatePipeline(true, state, R"(
#version 450
@@ -87,11 +87,11 @@ TEST_F(VertexInputTest, NullBufferIsOk) {
)");
// Null buffer (buffer[2]) sitting between buffers (buffer[1] and buffer[3]) is OK
state.bufferCount = 4;
state.cBuffers[2].attributeCount = 0;
state.cBuffers[2].attributes = nullptr;
state.cBuffers[3].attributeCount = 1;
state.cBuffers[3].attributes = &state.cAttributes[1];
state.vertexBufferCount = 4;
state.cVertexBuffers[2].attributeCount = 0;
state.cVertexBuffers[2].attributes = nullptr;
state.cVertexBuffers[3].attributeCount = 1;
state.cVertexBuffers[3].attributes = &state.cAttributes[1];
state.cAttributes[1].shaderLocation = 1;
CreatePipeline(true, state, R"(
#version 450
@@ -103,11 +103,11 @@ TEST_F(VertexInputTest, NullBufferIsOk) {
// Check validation that pipeline vertex buffers are backed by attributes in the vertex input
// Check validation that pipeline vertex buffers are backed by attributes in the vertex input
TEST_F(VertexInputTest, PipelineCompatibility) {
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = 2 * sizeof(float);
state.cBuffers[0].attributeCount = 2;
TEST_F(VertexStateTest, PipelineCompatibility) {
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
state.cVertexBuffers[0].attributeCount = 2;
state.cAttributes[0].shaderLocation = 0;
state.cAttributes[1].shaderLocation = 1;
state.cAttributes[1].offset = sizeof(float);
@@ -122,7 +122,7 @@ TEST_F(VertexInputTest, PipelineCompatibility) {
}
)");
// Check it is valid for the pipeline to use a subset of the VertexInput
// Check it is valid for the pipeline to use a subset of the VertexState
CreatePipeline(true, state, R"(
#version 450
layout(location = 0) in vec4 a;
@@ -141,13 +141,13 @@ TEST_F(VertexInputTest, PipelineCompatibility) {
)");
}
// Test that a stride of 0 is valid
TEST_F(VertexInputTest, StrideZero) {
// Test that a arrayStride of 0 is valid
TEST_F(VertexStateTest, StrideZero) {
// Works ok without attributes
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = 0;
state.cBuffers[0].attributeCount = 1;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 0;
state.cVertexBuffers[0].attributeCount = 1;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -165,14 +165,14 @@ TEST_F(VertexInputTest, StrideZero) {
)");
}
// Check validation that vertex attribute offset should be within vertex buffer stride,
// if vertex buffer stride is not zero.
TEST_F(VertexInputTest, SetOffsetOutOfBounds) {
// Control case, setting correct stride and offset
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = 2 * sizeof(float);
state.cBuffers[0].attributeCount = 2;
// Check validation that vertex attribute offset should be within vertex buffer arrayStride,
// if vertex buffer arrayStride is not zero.
TEST_F(VertexStateTest, SetOffsetOutOfBounds) {
// Control case, setting correct arrayStride and offset
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
state.cVertexBuffers[0].attributeCount = 2;
state.cAttributes[0].shaderLocation = 0;
state.cAttributes[1].shaderLocation = 1;
state.cAttributes[1].offset = sizeof(float);
@@ -183,8 +183,8 @@ TEST_F(VertexInputTest, SetOffsetOutOfBounds) {
}
)");
// Test vertex attribute offset exceed vertex buffer stride range
state.cBuffers[0].stride = sizeof(float);
// Test vertex attribute offset exceed vertex buffer arrayStride range
state.cVertexBuffers[0].arrayStride = sizeof(float);
CreatePipeline(false, state, R"(
#version 450
void main() {
@@ -192,8 +192,8 @@ TEST_F(VertexInputTest, SetOffsetOutOfBounds) {
}
)");
// It's OK if stride is zero
state.cBuffers[0].stride = 0;
// It's OK if arrayStride is zero
state.cVertexBuffers[0].arrayStride = 0;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -203,13 +203,13 @@ TEST_F(VertexInputTest, SetOffsetOutOfBounds) {
}
// Check out of bounds condition on total number of vertex buffers
TEST_F(VertexInputTest, SetVertexBuffersNumLimit) {
TEST_F(VertexStateTest, SetVertexBuffersNumLimit) {
// Control case, setting max vertex buffer number
utils::ComboVertexInputDescriptor state;
state.bufferCount = kMaxVertexBuffers;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = kMaxVertexBuffers;
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
state.cBuffers[i].attributeCount = 1;
state.cBuffers[i].attributes = &state.cAttributes[i];
state.cVertexBuffers[i].attributeCount = 1;
state.cVertexBuffers[i].attributes = &state.cAttributes[i];
state.cAttributes[i].shaderLocation = i;
}
CreatePipeline(true, state, R"(
@@ -220,7 +220,7 @@ TEST_F(VertexInputTest, SetVertexBuffersNumLimit) {
)");
// Test vertex buffer number exceed the limit
state.bufferCount = kMaxVertexBuffers + 1;
state.vertexBufferCount = kMaxVertexBuffers + 1;
CreatePipeline(false, state, R"(
#version 450
void main() {
@@ -230,11 +230,11 @@ TEST_F(VertexInputTest, SetVertexBuffersNumLimit) {
}
// Check out of bounds condition on total number of vertex attributes
TEST_F(VertexInputTest, SetVertexAttributesNumLimit) {
TEST_F(VertexStateTest, SetVertexAttributesNumLimit) {
// Control case, setting max vertex attribute number
utils::ComboVertexInputDescriptor state;
state.bufferCount = 2;
state.cBuffers[0].attributeCount = kMaxVertexAttributes;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 2;
state.cVertexBuffers[0].attributeCount = kMaxVertexAttributes;
for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) {
state.cAttributes[i].shaderLocation = i;
}
@@ -246,8 +246,8 @@ TEST_F(VertexInputTest, SetVertexAttributesNumLimit) {
)");
// Test vertex attribute number exceed the limit
state.cBuffers[1].attributeCount = 1;
state.cBuffers[1].attributes = &state.cAttributes[kMaxVertexAttributes - 1];
state.cVertexBuffers[1].attributeCount = 1;
state.cVertexBuffers[1].attributes = &state.cAttributes[kMaxVertexAttributes - 1];
CreatePipeline(false, state, R"(
#version 450
void main() {
@@ -256,13 +256,13 @@ TEST_F(VertexInputTest, SetVertexAttributesNumLimit) {
)");
}
// Check out of bounds condition on input stride
TEST_F(VertexInputTest, SetInputStrideOutOfBounds) {
// Control case, setting max input stride
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = kMaxVertexBufferStride;
state.cBuffers[0].attributeCount = 1;
// Check out of bounds condition on input arrayStride
TEST_F(VertexStateTest, SetInputStrideOutOfBounds) {
// Control case, setting max input arrayStride
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = kMaxVertexBufferStride;
state.cVertexBuffers[0].attributeCount = 1;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -270,8 +270,8 @@ TEST_F(VertexInputTest, SetInputStrideOutOfBounds) {
}
)");
// Test input stride OOB
state.cBuffers[0].stride = kMaxVertexBufferStride + 1;
// Test input arrayStride OOB
state.cVertexBuffers[0].arrayStride = kMaxVertexBufferStride + 1;
CreatePipeline(false, state, R"(
#version 450
void main() {
@@ -280,13 +280,13 @@ TEST_F(VertexInputTest, SetInputStrideOutOfBounds) {
)");
}
// Check multiple of 4 bytes constraint on input stride
TEST_F(VertexInputTest, SetInputStrideNotAligned) {
// Control case, setting input stride 4 bytes.
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = 4;
state.cBuffers[0].attributeCount = 1;
// Check multiple of 4 bytes constraint on input arrayStride
TEST_F(VertexStateTest, SetInputStrideNotAligned) {
// Control case, setting input arrayStride 4 bytes.
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 4;
state.cVertexBuffers[0].attributeCount = 1;
CreatePipeline(true, state, R"(
#version 450
void main() {
@@ -294,8 +294,8 @@ TEST_F(VertexInputTest, SetInputStrideNotAligned) {
}
)");
// Test input stride not multiple of 4 bytes
state.cBuffers[0].stride = 2;
// Test input arrayStride not multiple of 4 bytes
state.cVertexBuffers[0].arrayStride = 2;
CreatePipeline(false, state, R"(
#version 450
void main() {
@@ -305,11 +305,11 @@ TEST_F(VertexInputTest, SetInputStrideNotAligned) {
}
// Test that we cannot set an already set attribute
TEST_F(VertexInputTest, AlreadySetAttribute) {
TEST_F(VertexStateTest, AlreadySetAttribute) {
// Control case, setting attribute 0
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].shaderLocation = 0;
CreatePipeline(true, state, R"(
#version 450
@@ -319,7 +319,7 @@ TEST_F(VertexInputTest, AlreadySetAttribute) {
)");
// Oh no, attribute 0 is set twice
state.cBuffers[0].attributeCount = 2;
state.cVertexBuffers[0].attributeCount = 2;
state.cAttributes[0].shaderLocation = 0;
state.cAttributes[1].shaderLocation = 0;
CreatePipeline(false, state, R"(
@@ -330,12 +330,12 @@ TEST_F(VertexInputTest, AlreadySetAttribute) {
)");
}
// Test that a stride of 0 is valid
TEST_F(VertexInputTest, SetSameShaderLocation) {
// Test that a arrayStride of 0 is valid
TEST_F(VertexStateTest, SetSameShaderLocation) {
// Control case, setting different shader locations in two attributes
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 2;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 2;
state.cAttributes[0].shaderLocation = 0;
state.cAttributes[1].shaderLocation = 1;
state.cAttributes[1].offset = sizeof(float);
@@ -356,11 +356,11 @@ TEST_F(VertexInputTest, SetSameShaderLocation) {
)");
// Test same shader location in two attributes in different buffers
state.bufferCount = 2;
state.cBuffers[0].attributeCount = 1;
state.vertexBufferCount = 2;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].shaderLocation = 0;
state.cBuffers[1].attributeCount = 1;
state.cBuffers[1].attributes = &state.cAttributes[1];
state.cVertexBuffers[1].attributeCount = 1;
state.cVertexBuffers[1].attributes = &state.cAttributes[1];
state.cAttributes[1].shaderLocation = 0;
CreatePipeline(false, state, R"(
#version 450
@@ -371,11 +371,11 @@ TEST_F(VertexInputTest, SetSameShaderLocation) {
}
// Check out of bounds condition on attribute shader location
TEST_F(VertexInputTest, SetAttributeLocationOutOfBounds) {
TEST_F(VertexStateTest, SetAttributeLocationOutOfBounds) {
// Control case, setting last attribute shader location
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].shaderLocation = kMaxVertexAttributes - 1;
CreatePipeline(true, state, R"(
#version 450
@@ -395,11 +395,11 @@ TEST_F(VertexInputTest, SetAttributeLocationOutOfBounds) {
}
// Check attribute offset out of bounds
TEST_F(VertexInputTest, SetAttributeOffsetOutOfBounds) {
TEST_F(VertexStateTest, SetAttributeOffsetOutOfBounds) {
// Control case, setting max attribute offset for FloatR32 vertex format
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = kMaxVertexAttributeEnd - sizeof(wgpu::VertexFormat::Float);
CreatePipeline(true, state, R"(
#version 450
@@ -419,11 +419,11 @@ TEST_F(VertexInputTest, SetAttributeOffsetOutOfBounds) {
}
// Check multiple of 4 bytes constraint on offset
TEST_F(VertexInputTest, SetOffsetNotAligned) {
TEST_F(VertexStateTest, SetOffsetNotAligned) {
// Control case, setting offset 4 bytes.
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1;
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = 4;
CreatePipeline(true, state, R"(
#version 450
@@ -443,10 +443,10 @@ TEST_F(VertexInputTest, SetOffsetNotAligned) {
}
// Check attribute offset overflow
TEST_F(VertexInputTest, SetAttributeOffsetOverflow) {
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1;
TEST_F(VertexStateTest, SetAttributeOffsetOverflow) {
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = std::numeric_limits<uint32_t>::max();
CreatePipeline(false, state, R"(
#version 450
@@ -457,11 +457,11 @@ TEST_F(VertexInputTest, SetAttributeOffsetOverflow) {
}
// Check for some potential underflow in the vertex input validation
TEST_F(VertexInputTest, VertexFormatLargerThanNonZeroStride) {
utils::ComboVertexInputDescriptor state;
state.bufferCount = 1;
state.cBuffers[0].stride = 4;
state.cBuffers[0].attributeCount = 1;
TEST_F(VertexStateTest, VertexFormatLargerThanNonZeroStride) {
utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 4;
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].format = wgpu::VertexFormat::Float4;
CreatePipeline(false, state, R"(
#version 450

View File

@@ -117,11 +117,11 @@ TEST_F(WireArgumentTests, CStringArgument) {
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state
WGPUVertexInputDescriptor vertexInput;
vertexInput.nextInChain = nullptr;
vertexInput.indexFormat = WGPUIndexFormat_Uint32;
vertexInput.bufferCount = 0;
vertexInput.buffers = nullptr;
WGPUVertexStateDescriptor vertexState;
vertexState.nextInChain = nullptr;
vertexState.indexFormat = WGPUIndexFormat_Uint32;
vertexState.vertexBufferCount = 0;
vertexState.vertexBuffers = nullptr;
// Create the rasterization state
WGPURasterizationStateDescriptor rasterizationState;
@@ -179,7 +179,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.vertexState = &vertexState;
pipelineDescriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
pipelineDescriptor.rasterizationState = &rasterizationState;
pipelineDescriptor.depthStencilState = &depthStencilState;

View File

@@ -90,11 +90,11 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state
WGPUVertexInputDescriptor vertexInput;
vertexInput.nextInChain = nullptr;
vertexInput.indexFormat = WGPUIndexFormat_Uint32;
vertexInput.bufferCount = 0;
vertexInput.buffers = nullptr;
WGPUVertexStateDescriptor vertexState;
vertexState.nextInChain = nullptr;
vertexState.indexFormat = WGPUIndexFormat_Uint32;
vertexState.vertexBufferCount = 0;
vertexState.vertexBuffers = nullptr;
// Create the rasterization state
WGPURasterizationStateDescriptor rasterizationState;
@@ -154,7 +154,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.vertexState = &vertexState;
pipelineDescriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
pipelineDescriptor.rasterizationState = &rasterizationState;