Make vertex input descriptor optional

Following WebGPU spec change at https://github.com/gpuweb/gpuweb/issues/378,
vertexInput descriptor from GPURenderPipelineDescriptor should not be
required anymore.

BUG=dawn:22

Change-Id: I5d2500a758f44b7a7db2d2c23b359f1012221227
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10640
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
François Beaufort
2019-08-29 15:56:31 +00:00
committed by Commit Bot service account
parent 18b2cb51d7
commit 13c472e196
4 changed files with 85 additions and 12 deletions

View File

@@ -518,3 +518,52 @@ DAWN_INSTANTIATE_TEST(VertexInputTest, D3D12Backend, MetalBackend, OpenGLBackend
// - Add checks for alignement of vertex buffers and attributes if needed
// - Check for attribute narrowing
// - Check that the input state and the pipeline vertex input types match
class OptionalVertexInputTest : public DawnTest {};
// Test that vertex input is not required in render pipeline descriptor.
TEST_P(OptionalVertexInputTest, Basic) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
void main() {
gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);
})");
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = dawn::PrimitiveTopology::PointList;
descriptor.vertexInput = nullptr;
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
{
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.Draw(1, 1, 0, 0);
pass.EndPass();
}
dawn::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 1, 1);
}
DAWN_INSTANTIATE_TEST(OptionalVertexInputTest,
D3D12Backend,
MetalBackend,
OpenGLBackend,
VulkanBackend);

View File

@@ -43,11 +43,31 @@ class RenderPipelineValidationTest : public ValidationTest {
// Test cases where creation should succeed
TEST_F(RenderPipelineValidationTest, CreationSuccess) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline(&descriptor);
}
{
// Vertex input should be optional
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertexInput = nullptr;
device.CreateRenderPipeline(&descriptor);
}
{
// Rasterization state should be optional
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.rasterizationState = nullptr;
device.CreateRenderPipeline(&descriptor);
}
}
// Tests that at least one color state is required.