Port VertexBufferValidationTests to WGSL

Bug: dawn:572
Change-Id: I5e626b4e8784cd87f2e29c0cb232f21447958865
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33934
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-11-26 13:24:36 +00:00 committed by Commit Bot service account
parent 21c1e5f623
commit de56b07e61
1 changed files with 10 additions and 12 deletions

View File

@ -25,11 +25,10 @@ class VertexBufferValidationTest : public ValidationTest {
void SetUp() override { void SetUp() override {
ValidationTest::SetUp(); ValidationTest::SetUp();
fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
#version 450 [[location(0)]] var<out> fragColor : vec4<f32>;
layout(location = 0) out vec4 fragColor; [[stage(fragment)]] fn main() -> void {
void main() { fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})"); })");
} }
@ -43,13 +42,13 @@ class VertexBufferValidationTest : public ValidationTest {
wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) { wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) {
std::ostringstream vs; std::ostringstream vs;
vs << "#version 450\n";
for (unsigned int i = 0; i < bufferCount; ++i) { for (unsigned int i = 0; i < bufferCount; ++i) {
vs << "layout(location = " << i << ") in vec3 a_position" << i << ";\n"; vs << "[[location(" << i << ")]] var<in> a_position" << i << " : vec3<f32>;\n";
} }
vs << "void main() {\n"; vs << "[[builtin(position)]] var<out> Position : vec4<f32>;";
vs << "[[stage(vertex)]] fn main() -> void {\n";
vs << "gl_Position = vec4("; vs << "Position = vec4<f32>(";
for (unsigned int i = 0; i < bufferCount; ++i) { for (unsigned int i = 0; i < bufferCount; ++i) {
vs << "a_position" << i; vs << "a_position" << i;
if (i != bufferCount - 1) { if (i != bufferCount - 1) {
@ -60,8 +59,7 @@ class VertexBufferValidationTest : public ValidationTest {
vs << "}\n"; vs << "}\n";
return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, return utils::CreateShaderModuleFromWGSL(device, vs.str().c_str());
vs.str().c_str());
} }
wgpu::RenderPipeline MakeRenderPipeline(const wgpu::ShaderModule& vsModule, wgpu::RenderPipeline MakeRenderPipeline(const wgpu::ShaderModule& vsModule,