mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Input State Descriptorization
This change also removes InputState object. BUG=dawn:107 Change-Id: Ia3fd2d348658f5719de0279bfe7bb10a4f183523 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5660 Commit-Queue: Yunchao He <yunchao.he@intel.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
5490e9aca1
commit
889d743baa
@@ -36,9 +36,6 @@ class DestroyBufferTest : public DawnTest {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::InputState inputState =
|
||||
device.CreateInputStateBuilder().SetInput(&input).SetAttribute(&attribute).GetResult();
|
||||
|
||||
dawn::ShaderModule vsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
@@ -60,7 +57,10 @@ class DestroyBufferTest : public DawnTest {
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip;
|
||||
descriptor.indexFormat = dawn::IndexFormat::Uint32;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = 1;
|
||||
descriptor.cInputState.inputs = &input;
|
||||
descriptor.cInputState.numAttributes = 1;
|
||||
descriptor.cInputState.attributes = &attribute;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
@@ -135,4 +135,4 @@ TEST_P(DestroyBufferTest, SubmitDestroySubmit) {
|
||||
EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, 1, 3);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DestroyBufferTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
||||
DAWN_INSTANTIATE_TEST(DestroyBufferTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
||||
|
||||
@@ -37,18 +37,13 @@ class DrawIndexedTest : public DawnTest {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::InputState inputState = device.CreateInputStateBuilder()
|
||||
.SetInput(&input)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
|
||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
dawn::ShaderModule vsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
layout(location = 0) in vec4 pos;
|
||||
void main() {
|
||||
gl_Position = pos;
|
||||
})"
|
||||
);
|
||||
})");
|
||||
|
||||
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
|
||||
#version 450
|
||||
@@ -63,7 +58,10 @@ class DrawIndexedTest : public DawnTest {
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip;
|
||||
descriptor.indexFormat = dawn::IndexFormat::Uint32;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = 1;
|
||||
descriptor.cInputState.inputs = &input;
|
||||
descriptor.cInputState.numAttributes = 1;
|
||||
descriptor.cInputState.attributes = &attribute;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
@@ -37,9 +37,6 @@ class DrawTest : public DawnTest {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::InputState inputState =
|
||||
device.CreateInputStateBuilder().SetInput(&input).SetAttribute(&attribute).GetResult();
|
||||
|
||||
dawn::ShaderModule vsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
@@ -61,7 +58,10 @@ class DrawTest : public DawnTest {
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip;
|
||||
descriptor.indexFormat = dawn::IndexFormat::Uint32;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = 1;
|
||||
descriptor.cInputState.inputs = &input;
|
||||
descriptor.cInputState.numAttributes = 1;
|
||||
descriptor.cInputState.attributes = &attribute;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
@@ -42,11 +42,6 @@ class IndexFormatTest : public DawnTest {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::InputState inputState = device.CreateInputStateBuilder()
|
||||
.SetInput(&input)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
|
||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
layout(location = 0) in vec4 pos;
|
||||
@@ -68,7 +63,10 @@ class IndexFormatTest : public DawnTest {
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip;
|
||||
descriptor.indexFormat = format;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = 1;
|
||||
descriptor.cInputState.inputs = &input;
|
||||
descriptor.cInputState.numAttributes = 1;
|
||||
descriptor.cInputState.attributes = &attribute;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
return device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
@@ -64,7 +64,9 @@ class InputStateTest : public DawnTest {
|
||||
VertexFormat format;
|
||||
InputStepMode step;
|
||||
};
|
||||
dawn::RenderPipeline MakeTestPipeline(const dawn::InputState& inputState, int multiplier, std::vector<ShaderTestSpec> testSpec) {
|
||||
dawn::RenderPipeline MakeTestPipeline(const dawn::InputStateDescriptor& inputState,
|
||||
int multiplier,
|
||||
std::vector<ShaderTestSpec> testSpec) {
|
||||
std::ostringstream vs;
|
||||
vs << "#version 450\n";
|
||||
|
||||
@@ -124,7 +126,7 @@ class InputStateTest : public DawnTest {
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.inputState = &inputState;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
return device.CreateRenderPipeline(&descriptor);
|
||||
@@ -141,28 +143,30 @@ class InputStateTest : public DawnTest {
|
||||
uint32_t offset;
|
||||
VertexFormat format;
|
||||
};
|
||||
dawn::InputState MakeInputState(std::vector<InputSpec> inputs, std::vector<AttributeSpec> attributes) {
|
||||
dawn::InputStateBuilder builder = device.CreateInputStateBuilder();
|
||||
|
||||
dawn::InputStateDescriptor MakeInputState(std::vector<InputSpec> inputs,
|
||||
std::vector<AttributeSpec> attributes) {
|
||||
dawn::InputStateDescriptor inputState;
|
||||
uint32_t numInputs = 0;
|
||||
for (const auto& input : inputs) {
|
||||
dawn::VertexInputDescriptor descriptor;
|
||||
descriptor.inputSlot = input.slot;
|
||||
descriptor.stride = input.stride;
|
||||
descriptor.stepMode = input.step;
|
||||
builder.SetInput(&descriptor);
|
||||
vertexInputs[numInputs].inputSlot = input.slot;
|
||||
vertexInputs[numInputs].stride = input.stride;
|
||||
vertexInputs[numInputs].stepMode = input.step;
|
||||
numInputs++;
|
||||
}
|
||||
|
||||
uint32_t numAttributes = 0;
|
||||
for (const auto& attribute : attributes) {
|
||||
dawn::VertexAttributeDescriptor descriptor;
|
||||
descriptor.shaderLocation = attribute.location;
|
||||
descriptor.inputSlot = attribute.slot;
|
||||
descriptor.offset = attribute.offset;
|
||||
descriptor.format = attribute.format;
|
||||
|
||||
builder.SetAttribute(&descriptor);
|
||||
vertexAttributes[numAttributes].shaderLocation = attribute.location;
|
||||
vertexAttributes[numAttributes].inputSlot = attribute.slot;
|
||||
vertexAttributes[numAttributes].offset = attribute.offset;
|
||||
vertexAttributes[numAttributes].format = attribute.format;
|
||||
numAttributes++;
|
||||
}
|
||||
|
||||
return builder.GetResult();
|
||||
inputState.numInputs = numInputs;
|
||||
inputState.inputs = vertexInputs;
|
||||
inputState.numAttributes = numAttributes;
|
||||
inputState.attributes = vertexAttributes;
|
||||
return inputState;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -214,16 +218,14 @@ class InputStateTest : public DawnTest {
|
||||
}
|
||||
|
||||
utils::BasicRenderPass renderPass;
|
||||
dawn::VertexAttributeDescriptor vertexAttributes[kMaxVertexAttributes];
|
||||
dawn::VertexInputDescriptor vertexInputs[kMaxVertexInputs];
|
||||
};
|
||||
|
||||
// Test compilation and usage of the fixture :)
|
||||
TEST_P(InputStateTest, Basic) {
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 4 * sizeof(float), InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{{0, 4 * sizeof(float), InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -241,12 +243,8 @@ TEST_P(InputStateTest, ZeroStride) {
|
||||
// This test was failing only on AMD but the OpenGL backend doesn't gather PCI info yet.
|
||||
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
|
||||
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 0, InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState =
|
||||
MakeInputState({{0, 0, InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -264,12 +262,8 @@ TEST_P(InputStateTest, AttributeExpanding) {
|
||||
|
||||
// R32F case
|
||||
{
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 0, InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState =
|
||||
MakeInputState({{0, 0, InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
|
||||
{0, VertexFormat::Float, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -281,12 +275,8 @@ TEST_P(InputStateTest, AttributeExpanding) {
|
||||
}
|
||||
// RG32F case
|
||||
{
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 0, InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float2}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState =
|
||||
MakeInputState({{0, 0, InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float2}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
|
||||
{0, VertexFormat::Float2, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -298,12 +288,8 @@ TEST_P(InputStateTest, AttributeExpanding) {
|
||||
}
|
||||
// RGB32F case
|
||||
{
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 0, InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float3}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState =
|
||||
MakeInputState({{0, 0, InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float3}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
|
||||
{0, VertexFormat::Float3, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -320,12 +306,8 @@ TEST_P(InputStateTest, StrideLargerThanAttributes) {
|
||||
// This test was failing only on AMD but the OpenGL backend doesn't gather PCI info yet.
|
||||
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
|
||||
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 8 * sizeof(float), InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{{0, 8 * sizeof(float), InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -340,13 +322,9 @@ TEST_P(InputStateTest, StrideLargerThanAttributes) {
|
||||
|
||||
// Test two attributes at an offset, vertex version
|
||||
TEST_P(InputStateTest, TwoAttributesAtAnOffsetVertex) {
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 8 * sizeof(float), InputStepMode::Vertex}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4},
|
||||
{1, 0, 4 * sizeof(float), VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{{0, 8 * sizeof(float), InputStepMode::Vertex}},
|
||||
{{0, 0, 0, VertexFormat::Float4}, {1, 0, 4 * sizeof(float), VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Vertex}
|
||||
});
|
||||
@@ -361,13 +339,9 @@ TEST_P(InputStateTest, TwoAttributesAtAnOffsetVertex) {
|
||||
|
||||
// Test two attributes at an offset, instance version
|
||||
TEST_P(InputStateTest, TwoAttributesAtAnOffsetInstance) {
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 8 * sizeof(float), InputStepMode::Instance}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4},
|
||||
{1, 0, 4 * sizeof(float), VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{{0, 8 * sizeof(float), InputStepMode::Instance}},
|
||||
{{0, 0, 0, VertexFormat::Float4}, {1, 0, 4 * sizeof(float), VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Instance}
|
||||
});
|
||||
@@ -382,12 +356,8 @@ TEST_P(InputStateTest, TwoAttributesAtAnOffsetInstance) {
|
||||
|
||||
// Test a pure-instance input state
|
||||
TEST_P(InputStateTest, PureInstance) {
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
{0, 4 * sizeof(float), InputStepMode::Instance}
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{{0, 4 * sizeof(float), InputStepMode::Instance}}, {{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float4, InputStepMode::Instance}
|
||||
});
|
||||
@@ -404,16 +374,15 @@ TEST_P(InputStateTest, PureInstance) {
|
||||
// Test with mixed everything, vertex vs. instance, different stride and offsets
|
||||
// different attribute types
|
||||
TEST_P(InputStateTest, MixedEverything) {
|
||||
dawn::InputState inputState = MakeInputState({
|
||||
dawn::InputStateDescriptor inputState = MakeInputState(
|
||||
{
|
||||
{0, 12 * sizeof(float), InputStepMode::Vertex},
|
||||
{1, 10 * sizeof(float), InputStepMode::Instance},
|
||||
}, {
|
||||
{0, 0, 0, VertexFormat::Float},
|
||||
{1, 0, 6 * sizeof(float), VertexFormat::Float2},
|
||||
{2, 1, 0, VertexFormat::Float3},
|
||||
{3, 1, 5 * sizeof(float), VertexFormat::Float4}
|
||||
}
|
||||
);
|
||||
},
|
||||
{{0, 0, 0, VertexFormat::Float},
|
||||
{1, 0, 6 * sizeof(float), VertexFormat::Float2},
|
||||
{2, 1, 0, VertexFormat::Float3},
|
||||
{3, 1, 5 * sizeof(float), VertexFormat::Float4}});
|
||||
dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
|
||||
{0, VertexFormat::Float, InputStepMode::Vertex},
|
||||
{1, VertexFormat::Float2, InputStepMode::Vertex},
|
||||
@@ -439,9 +408,8 @@ TEST_P(InputStateTest, MixedEverything) {
|
||||
// Test input state is unaffected by unused vertex slot
|
||||
TEST_P(InputStateTest, UnusedVertexSlot) {
|
||||
// Instance input state, using slot 1
|
||||
dawn::InputState instanceInputState =
|
||||
MakeInputState({{1, 4 * sizeof(float), InputStepMode::Instance}},
|
||||
{{0, 1, 0, VertexFormat::Float4}});
|
||||
dawn::InputStateDescriptor instanceInputState = MakeInputState(
|
||||
{{1, 4 * sizeof(float), InputStepMode::Instance}}, {{0, 1, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline instancePipeline = MakeTestPipeline(
|
||||
instanceInputState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
|
||||
|
||||
@@ -477,16 +445,14 @@ TEST_P(InputStateTest, UnusedVertexSlot) {
|
||||
// SetVertexBuffers should be reapplied when the input state changes.
|
||||
TEST_P(InputStateTest, MultiplePipelinesMixedInputState) {
|
||||
// Basic input state, using slot 0
|
||||
dawn::InputState vertexInputState =
|
||||
MakeInputState({{0, 4 * sizeof(float), InputStepMode::Vertex}},
|
||||
{{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::InputStateDescriptor vertexInputState = MakeInputState(
|
||||
{{0, 4 * sizeof(float), InputStepMode::Vertex}}, {{0, 0, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline vertexPipeline = MakeTestPipeline(
|
||||
vertexInputState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
|
||||
|
||||
// Instance input state, using slot 1
|
||||
dawn::InputState instanceInputState =
|
||||
MakeInputState({{1, 4 * sizeof(float), InputStepMode::Instance}},
|
||||
{{0, 1, 0, VertexFormat::Float4}});
|
||||
dawn::InputStateDescriptor instanceInputState = MakeInputState(
|
||||
{{1, 4 * sizeof(float), InputStepMode::Instance}}, {{0, 1, 0, VertexFormat::Float4}});
|
||||
dawn::RenderPipeline instancePipeline = MakeTestPipeline(
|
||||
instanceInputState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}});
|
||||
|
||||
|
||||
@@ -165,22 +165,6 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
dawn::VertexAttributeDescriptor attribute;
|
||||
attribute.shaderLocation = 0;
|
||||
attribute.inputSlot = 0;
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::VertexInputDescriptor input;
|
||||
input.inputSlot = 0;
|
||||
input.stride = 4 * sizeof(float);
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
|
||||
inputState = device.CreateInputStateBuilder()
|
||||
.SetAttribute(&attribute)
|
||||
.SetInput(&input)
|
||||
.GetResult();
|
||||
|
||||
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), dawn::BufferUsageBit::Vertex);
|
||||
}
|
||||
|
||||
@@ -197,12 +181,25 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||
|
||||
// Draw the vertices with the given primitive topology and check the pixel values of the test locations
|
||||
void DoTest(dawn::PrimitiveTopology primitiveTopology, const std::vector<LocationSpec> &locationSpecs) {
|
||||
dawn::VertexAttributeDescriptor attribute;
|
||||
attribute.shaderLocation = 0;
|
||||
attribute.inputSlot = 0;
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float4;
|
||||
|
||||
dawn::VertexInputDescriptor input;
|
||||
input.inputSlot = 0;
|
||||
input.stride = 4 * sizeof(float);
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.primitiveTopology = primitiveTopology;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = 1;
|
||||
descriptor.cInputState.inputs = &input;
|
||||
descriptor.cInputState.numAttributes = 1;
|
||||
descriptor.cInputState.attributes = &attribute;
|
||||
descriptor.cColorStates[0]->format = renderPass.colorFormat;
|
||||
|
||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
@@ -234,7 +231,6 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||
utils::BasicRenderPass renderPass;
|
||||
dawn::ShaderModule vsModule;
|
||||
dawn::ShaderModule fsModule;
|
||||
dawn::InputState inputState;
|
||||
dawn::Buffer vertexBuffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,9 +25,13 @@ constexpr static dawn::VertexInputDescriptor kBaseInput = {
|
||||
|
||||
class InputStateTest : public ValidationTest {
|
||||
protected:
|
||||
void CreatePipeline(bool success, const dawn::InputState& inputState, std::string vertexSource) {
|
||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vertexSource.c_str());
|
||||
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
|
||||
void CreatePipeline(bool success,
|
||||
const dawn::InputStateDescriptor* state,
|
||||
std::string vertexSource) {
|
||||
dawn::ShaderModule vsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vertexSource.c_str());
|
||||
dawn::ShaderModule fsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
|
||||
#version 450
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
void main() {
|
||||
@@ -35,26 +39,25 @@ class InputStateTest : public ValidationTest {
|
||||
}
|
||||
)");
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cColorStates[0]->format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
if (state) {
|
||||
descriptor.inputState = state;
|
||||
}
|
||||
descriptor.cColorStates[0]->format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
|
||||
if (!success) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Check an empty input state is valid
|
||||
TEST_F(InputStateTest, EmptyIsOk) {
|
||||
dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.GetResult();
|
||||
|
||||
CreatePipeline(true, state, R"(
|
||||
CreatePipeline(true, nullptr, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
@@ -64,31 +67,30 @@ TEST_F(InputStateTest, EmptyIsOk) {
|
||||
|
||||
// Check validation that pipeline vertex inputs are backed by attributes in the input state
|
||||
TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
dawn::VertexAttributeDescriptor attribute1;
|
||||
attribute1.shaderLocation = 0;
|
||||
attribute1.inputSlot = 0;
|
||||
attribute1.offset = 0;
|
||||
attribute1.format = dawn::VertexFormat::Float;
|
||||
dawn::VertexAttributeDescriptor attribute[2];
|
||||
attribute[0].shaderLocation = 0;
|
||||
attribute[0].inputSlot = 0;
|
||||
attribute[0].offset = 0;
|
||||
attribute[0].format = dawn::VertexFormat::Float;
|
||||
|
||||
dawn::VertexAttributeDescriptor attribute2;
|
||||
attribute2.shaderLocation = 1;
|
||||
attribute2.inputSlot = 0;
|
||||
attribute2.offset = sizeof(float);
|
||||
attribute2.format = dawn::VertexFormat::Float;
|
||||
attribute[1].shaderLocation = 1;
|
||||
attribute[1].inputSlot = 0;
|
||||
attribute[1].offset = sizeof(float);
|
||||
attribute[1].format = dawn::VertexFormat::Float;
|
||||
|
||||
dawn::VertexInputDescriptor input;
|
||||
input.inputSlot = 0;
|
||||
input.stride = 2 * sizeof(float);
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
|
||||
dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&input)
|
||||
.SetAttribute(&attribute1)
|
||||
.SetAttribute(&attribute2)
|
||||
.GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &input;
|
||||
state.numAttributes = 2;
|
||||
state.attributes = attribute;
|
||||
|
||||
// Control case: pipeline with one input per attribute
|
||||
CreatePipeline(true, state, R"(
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
layout(location = 0) in vec4 a;
|
||||
layout(location = 1) in vec4 b;
|
||||
@@ -98,7 +100,7 @@ TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
)");
|
||||
|
||||
// Check it is valid for the pipeline to use a subset of the InputState
|
||||
CreatePipeline(true, state, R"(
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
layout(location = 0) in vec4 a;
|
||||
void main() {
|
||||
@@ -107,7 +109,7 @@ TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
)");
|
||||
|
||||
// Check for an error when the pipeline uses an attribute not in the input state
|
||||
CreatePipeline(false, state, R"(
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
layout(location = 2) in vec4 a;
|
||||
void main() {
|
||||
@@ -119,7 +121,17 @@ TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
// Test that a stride of 0 is valid
|
||||
TEST_F(InputStateTest, StrideZero) {
|
||||
// Works ok without attributes
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder()).SetInput(&kBaseInput).GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 0;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Works ok with attributes at a large-ish offset
|
||||
dawn::VertexAttributeDescriptor attribute;
|
||||
@@ -128,22 +140,42 @@ TEST_F(InputStateTest, StrideZero) {
|
||||
attribute.offset = 128;
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Test that we cannot set an already set input
|
||||
TEST_F(InputStateTest, AlreadySetInput) {
|
||||
// Control case
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder()).SetInput(&kBaseInput).GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 0;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Oh no, input 0 is set twice
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetInput(&kBaseInput)
|
||||
.GetResult();
|
||||
dawn::VertexInputDescriptor vertexInput[2] = {kBaseInput, kBaseInput};
|
||||
state.numInputs = 2;
|
||||
state.inputs = vertexInput;
|
||||
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check out of bounds condition on input slot
|
||||
@@ -154,11 +186,26 @@ TEST_F(InputStateTest, SetInputSlotOutOfBounds) {
|
||||
input.stride = 0;
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder()).SetInput(&input).GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &input;
|
||||
state.numAttributes = 0;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Test input slot OOB
|
||||
input.inputSlot = kMaxVertexInputs;
|
||||
AssertWillBeError(device.CreateInputStateBuilder()).SetInput(&input).GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check out of bounds condition on input stride
|
||||
@@ -168,11 +215,27 @@ TEST_F(InputStateTest, SetInputStrideOutOfBounds) {
|
||||
input.inputSlot = 0;
|
||||
input.stride = kMaxVertexInputStride;
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder()).SetInput(&input).GetResult();
|
||||
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &input;
|
||||
state.numAttributes = 0;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Test input stride OOB
|
||||
input.stride = kMaxVertexInputStride + 1;
|
||||
AssertWillBeError(device.CreateInputStateBuilder()).SetInput(&input).GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Test that we cannot set an already set attribute
|
||||
@@ -184,17 +247,30 @@ TEST_F(InputStateTest, AlreadySetAttribute) {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Oh no, attribute 0 is set twice
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
dawn::VertexAttributeDescriptor vertexAttribute[2] = {attribute, attribute};
|
||||
state.numAttributes = 2;
|
||||
state.attributes = vertexAttribute;
|
||||
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check out of bounds condition on attribute shader location
|
||||
@@ -206,17 +282,27 @@ TEST_F(InputStateTest, SetAttributeLocationOutOfBounds) {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Test attribute location OOB
|
||||
attribute.shaderLocation = kMaxVertexAttributes;
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check attribute offset out of bounds
|
||||
@@ -227,17 +313,28 @@ TEST_F(InputStateTest, SetAttributeOffsetOutOfBounds) {
|
||||
attribute.inputSlot = 0;
|
||||
attribute.offset = kMaxVertexAttributeEnd - sizeof(dawn::VertexFormat::Float);
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Test attribute offset out of bounds
|
||||
attribute.offset = kMaxVertexAttributeEnd - 1;
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check attribute offset overflow
|
||||
@@ -247,10 +344,19 @@ TEST_F(InputStateTest, SetAttributeOffsetOverflow) {
|
||||
attribute.inputSlot = 0;
|
||||
attribute.offset = std::numeric_limits<uint32_t>::max();
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check that all attributes must be backed by an input
|
||||
@@ -262,17 +368,27 @@ TEST_F(InputStateTest, RequireInputForAttribute) {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Attribute 0 uses input 1 which doesn't exist
|
||||
attribute.inputSlot = 1;
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Check OOB checks for an attribute's input
|
||||
@@ -284,15 +400,25 @@ TEST_F(InputStateTest, SetAttributeOOBCheckForInputs) {
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float;
|
||||
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
dawn::InputStateDescriptor state;
|
||||
state.numInputs = 1;
|
||||
state.inputs = &kBaseInput;
|
||||
state.numAttributes = 1;
|
||||
state.attributes = &attribute;
|
||||
|
||||
CreatePipeline(true, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Could crash if we didn't check for OOB
|
||||
attribute.inputSlot = 1000000;
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(&kBaseInput)
|
||||
.SetAttribute(&attribute)
|
||||
.GetResult();
|
||||
CreatePipeline(false, &state, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
@@ -67,8 +67,12 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
return utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
|
||||
}
|
||||
|
||||
dawn::InputState MakeInputState(unsigned int numInputs) {
|
||||
auto builder = device.CreateInputStateBuilder();
|
||||
dawn::RenderPipeline MakeRenderPipeline(const dawn::ShaderModule& vsModule,
|
||||
unsigned int numInputs) {
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
|
||||
dawn::VertexAttributeDescriptor attribute;
|
||||
attribute.offset = 0;
|
||||
attribute.format = dawn::VertexFormat::Float3;
|
||||
@@ -77,22 +81,19 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
input.stride = 0;
|
||||
input.stepMode = dawn::InputStepMode::Vertex;
|
||||
|
||||
dawn::VertexInputDescriptor vertexInputs[kMaxVertexInputs];
|
||||
dawn::VertexAttributeDescriptor vertexAttributes[kMaxVertexAttributes];
|
||||
for (unsigned int i = 0; i < numInputs; ++i) {
|
||||
attribute.shaderLocation = i;
|
||||
attribute.inputSlot = i;
|
||||
input.inputSlot = i;
|
||||
builder.SetAttribute(&attribute);
|
||||
builder.SetInput(&input);
|
||||
vertexInputs[i] = input;
|
||||
vertexAttributes[i] = attribute;
|
||||
}
|
||||
return builder.GetResult();
|
||||
}
|
||||
|
||||
dawn::RenderPipeline MakeRenderPipeline(const dawn::ShaderModule& vsModule, const dawn::InputState& inputState) {
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
descriptor.cVertexStage.module = vsModule;
|
||||
descriptor.cFragmentStage.module = fsModule;
|
||||
descriptor.inputState = inputState;
|
||||
descriptor.cInputState.numInputs = numInputs;
|
||||
descriptor.cInputState.inputs = vertexInputs;
|
||||
descriptor.cInputState.numAttributes = numInputs;
|
||||
descriptor.cInputState.attributes = vertexAttributes;
|
||||
|
||||
return device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
@@ -105,11 +106,8 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
auto vsModule2 = MakeVertexShader(2);
|
||||
auto vsModule1 = MakeVertexShader(1);
|
||||
|
||||
auto inputState2 = MakeInputState(2);
|
||||
auto inputState1 = MakeInputState(1);
|
||||
|
||||
auto pipeline2 = MakeRenderPipeline(vsModule2, inputState2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, inputState1);
|
||||
auto pipeline2 = MakeRenderPipeline(vsModule2, 2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, 1);
|
||||
|
||||
auto vertexBuffers = MakeVertexBuffers<2>();
|
||||
uint32_t offsets[] = { 0, 0 };
|
||||
@@ -143,11 +141,8 @@ TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
auto vsModule2 = MakeVertexShader(2);
|
||||
auto vsModule1 = MakeVertexShader(1);
|
||||
|
||||
auto inputState2 = MakeInputState(2);
|
||||
auto inputState1 = MakeInputState(1);
|
||||
|
||||
auto pipeline2 = MakeRenderPipeline(vsModule2, inputState2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, inputState1);
|
||||
auto pipeline2 = MakeRenderPipeline(vsModule2, 2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, 1);
|
||||
|
||||
auto vertexBuffers = MakeVertexBuffers<2>();
|
||||
uint32_t offsets[] = { 0, 0 };
|
||||
|
||||
@@ -101,15 +101,12 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
||||
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
|
||||
|
||||
// Create the input state
|
||||
DawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
DawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateInputStateBuilder(apiDevice))
|
||||
.WillOnce(Return(apiInputStateBuilder));
|
||||
|
||||
DawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
DawnInputState apiInputState = api.GetNewInputState();
|
||||
EXPECT_CALL(api, InputStateBuilderGetResult(apiInputStateBuilder))
|
||||
.WillOnce(Return(apiInputState));
|
||||
DawnInputStateDescriptor inputState;
|
||||
inputState.nextInChain = nullptr;
|
||||
inputState.numInputs = 0;
|
||||
inputState.inputs = nullptr;
|
||||
inputState.numAttributes = 0;
|
||||
inputState.attributes = nullptr;
|
||||
|
||||
// Create the depth-stencil state
|
||||
DawnStencilStateFaceDescriptor stencilFace;
|
||||
@@ -159,7 +156,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
pipelineDescriptor.layout = layout;
|
||||
pipelineDescriptor.inputState = inputState;
|
||||
pipelineDescriptor.inputState = &inputState;
|
||||
pipelineDescriptor.indexFormat = DAWN_INDEX_FORMAT_UINT32;
|
||||
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
pipelineDescriptor.depthStencilState = &depthStencilState;
|
||||
@@ -172,8 +169,6 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
||||
})))
|
||||
.WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(api, ShaderModuleRelease(apiVsModule));
|
||||
EXPECT_CALL(api, InputStateBuilderRelease(apiInputStateBuilder));
|
||||
EXPECT_CALL(api, InputStateRelease(apiInputState));
|
||||
EXPECT_CALL(api, PipelineLayoutRelease(apiLayout));
|
||||
|
||||
FlushClient();
|
||||
|
||||
@@ -86,15 +86,12 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
||||
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
|
||||
|
||||
// Create the input state
|
||||
DawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
DawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateInputStateBuilder(apiDevice))
|
||||
.WillOnce(Return(apiInputStateBuilder));
|
||||
|
||||
DawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
DawnInputState apiInputState = api.GetNewInputState();
|
||||
EXPECT_CALL(api, InputStateBuilderGetResult(apiInputStateBuilder))
|
||||
.WillOnce(Return(apiInputState));
|
||||
DawnInputStateDescriptor inputState;
|
||||
inputState.nextInChain = nullptr;
|
||||
inputState.numInputs = 0;
|
||||
inputState.inputs = nullptr;
|
||||
inputState.numAttributes = 0;
|
||||
inputState.attributes = nullptr;
|
||||
|
||||
// Create the depth-stencil state
|
||||
DawnStencilStateFaceDescriptor stencilFace;
|
||||
@@ -144,7 +141,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
pipelineDescriptor.layout = layout;
|
||||
pipelineDescriptor.inputState = inputState;
|
||||
pipelineDescriptor.inputState = &inputState;
|
||||
pipelineDescriptor.indexFormat = DAWN_INDEX_FORMAT_UINT32;
|
||||
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
|
||||
@@ -191,8 +188,6 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
||||
.WillOnce(Return(nullptr));
|
||||
|
||||
EXPECT_CALL(api, ShaderModuleRelease(apiVsModule));
|
||||
EXPECT_CALL(api, InputStateBuilderRelease(apiInputStateBuilder));
|
||||
EXPECT_CALL(api, InputStateRelease(apiInputState));
|
||||
EXPECT_CALL(api, PipelineLayoutRelease(apiLayout));
|
||||
|
||||
FlushClient();
|
||||
|
||||
Reference in New Issue
Block a user