From 78d27e88de6dcc5dca1e13bc82a0caf8e5392f02 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 13 Apr 2021 10:42:44 +0000 Subject: [PATCH] Remove usage of deprecated WGSL IO in perf/unit/whitebox tests Also drive-by fixes some other deprecated constructs (const -> let, and a disabled test having ancient WGSL). Bug: dawn:755 Change-Id: I924dfbcbd0a7d0478f3e9b3766585751a0392499 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47620 Commit-Queue: Corentin Wallez Auto-Submit: Corentin Wallez Reviewed-by: Ben Clayton --- src/tests/perf_tests/DrawCallPerf.cpp | 19 ++--- .../perf_tests/SubresourceTrackingPerf.cpp | 12 ++- .../DrawIndirectValidationTests.cpp | 10 +-- .../validation/IndexBufferValidationTests.cpp | 10 +-- .../validation/QueueSubmitValidationTests.cpp | 10 +-- .../RenderBundleValidationTests.cpp | 4 +- .../RenderPipelineValidationTests.cpp | 78 +++++++------------ .../ShaderModuleValidationTests.cpp | 16 ++-- .../StorageTextureValidationTests.cpp | 38 ++++----- .../VertexBufferValidationTests.cpp | 18 +++-- .../validation/VertexStateValidationTests.cpp | 36 ++++----- .../white_box/D3D12DescriptorHeapTests.cpp | 40 +++++----- src/tests/white_box/D3D12ResidencyTests.cpp | 14 ++-- 13 files changed, 130 insertions(+), 175 deletions(-) diff --git a/src/tests/perf_tests/DrawCallPerf.cpp b/src/tests/perf_tests/DrawCallPerf.cpp index bbff208128..a0456c055d 100644 --- a/src/tests/perf_tests/DrawCallPerf.cpp +++ b/src/tests/perf_tests/DrawCallPerf.cpp @@ -33,10 +33,10 @@ namespace { }; constexpr char kVertexShader[] = R"( - [[location(0)]] var pos : vec4; - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = pos; + [[stage(vertex)]] fn main( + [[location(0)]] pos : vec4 + ) -> [[builtin(position)]] vec4 { + return pos; })"; constexpr char kFragmentShaderA[] = R"( @@ -44,9 +44,8 @@ namespace { color : vec3; }; [[group(0), binding(0)]] var uniforms : Uniforms; - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(uniforms.color * (1.0 / 5000.0), 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(uniforms.color * (1.0 / 5000.0), 1.0); })"; constexpr char kFragmentShaderB[] = R"( @@ -59,10 +58,8 @@ namespace { [[group(0), binding(0)]] var constants : Constants; [[group(1), binding(0)]] var uniforms : Uniforms; - [[location(0)]] var fragColor : vec4; - - [[stage(fragment)]] fn main() { - fragColor = vec4((constants.color + uniforms.color) * (1.0 / 5000.0), 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4((constants.color + uniforms.color) * (1.0 / 5000.0), 1.0); })"; enum class Pipeline { diff --git a/src/tests/perf_tests/SubresourceTrackingPerf.cpp b/src/tests/perf_tests/SubresourceTrackingPerf.cpp index 3a49a1eb3a..2b32621484 100644 --- a/src/tests/perf_tests/SubresourceTrackingPerf.cpp +++ b/src/tests/perf_tests/SubresourceTrackingPerf.cpp @@ -71,17 +71,15 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(1.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(1.0, 0.0, 0.0, 1.0); } )"); pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( - [[location(0)]] var FragColor : vec4; [[group(0), binding(0)]] var materials : texture_2d; - [[stage(fragment)]] fn main() { - const foo : vec2 = textureDimensions(materials); - FragColor = vec4(1.0, 0.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + let foo : vec2 = textureDimensions(materials); + return vec4(1.0, 0.0, 0.0, 1.0); } )"); mPipeline = device.CreateRenderPipeline2(&pipelineDesc); diff --git a/src/tests/unittests/validation/DrawIndirectValidationTests.cpp b/src/tests/unittests/validation/DrawIndirectValidationTests.cpp index 3870f1afe0..edb73a1347 100644 --- a/src/tests/unittests/validation/DrawIndirectValidationTests.cpp +++ b/src/tests/unittests/validation/DrawIndirectValidationTests.cpp @@ -24,15 +24,13 @@ class DrawIndirectValidationTest : public ValidationTest { ValidationTest::SetUp(); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); })"); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4{ + return vec4(0.0, 0.0, 0.0, 0.0); })"); // Set up render pipeline diff --git a/src/tests/unittests/validation/IndexBufferValidationTests.cpp b/src/tests/unittests/validation/IndexBufferValidationTests.cpp index 0320913205..fd23ce5cd0 100644 --- a/src/tests/unittests/validation/IndexBufferValidationTests.cpp +++ b/src/tests/unittests/validation/IndexBufferValidationTests.cpp @@ -23,15 +23,13 @@ class IndexBufferValidationTest : public ValidationTest { wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format, wgpu::PrimitiveTopology primitiveTopology) { wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); })"); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); })"); utils::ComboRenderPipelineDescriptor2 descriptor; diff --git a/src/tests/unittests/validation/QueueSubmitValidationTests.cpp b/src/tests/unittests/validation/QueueSubmitValidationTests.cpp index 184994d4e9..8bf0f4d600 100644 --- a/src/tests/unittests/validation/QueueSubmitValidationTests.cpp +++ b/src/tests/unittests/validation/QueueSubmitValidationTests.cpp @@ -175,15 +175,13 @@ namespace { }; wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); })"); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); })"); utils::ComboRenderPipelineDescriptor2 descriptor; diff --git a/src/tests/unittests/validation/RenderBundleValidationTests.cpp b/src/tests/unittests/validation/RenderBundleValidationTests.cpp index 51e6d8b5f0..cad2341c97 100644 --- a/src/tests/unittests/validation/RenderBundleValidationTests.cpp +++ b/src/tests/unittests/validation/RenderBundleValidationTests.cpp @@ -28,14 +28,12 @@ namespace { ValidationTest::SetUp(); vsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var pos : vec2; - [[block]] struct S { transform : mat2x2; }; [[group(0), binding(0)]] var uniforms : S; - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main([[location(0)]] pos : vec2) { })"); fsModule = utils::CreateShaderModule(device, R"( diff --git a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp index a4cfa43407..54e500c4a8 100644 --- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -27,15 +27,13 @@ class RenderPipelineValidationTest : public ValidationTest { ValidationTest::SetUp(); vsModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); })"); fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); })"); } @@ -191,9 +189,11 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) { std::ostringstream stream; stream << R"( - [[location(0)]] var fragColor : vec4<)" + [[stage(fragment)]] fn main() -> [[location(0)]] vec4<)" + << kScalarTypes[i] << R"(> { + var result : vec4<)" << kScalarTypes[i] << R"(>; - [[stage(fragment)]] fn main() { + return result; })"; descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str()); @@ -484,8 +484,7 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) { data : array; }; [[group(0), binding(0)]] var dst : [[access(read_write)]] Dst; - [[builtin(vertex_index)]] var VertexIndex : u32; - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) { dst.data[VertexIndex] = 0x1234u; })"); @@ -591,16 +590,12 @@ TEST_F(RenderPipelineValidationTest, DepthCompareUndefinedIsError) { // Test that the entryPoint names must be present for the correct stage in the shader module. TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) { wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var position : vec4; - [[stage(vertex)]] fn vertex_main() { - position = vec4(0.0, 0.0, 0.0, 1.0); - return; + [[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); } - [[location(0)]] var color : vec4; - [[stage(fragment)]] fn fragment_main() { - color = vec4(1.0, 0.0, 0.0, 1.0); - return; + [[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4 { + return vec4(1.0, 0.0, 0.0, 1.0); } )"); @@ -641,17 +636,13 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) { // Test that vertex attrib validation is for the correct entryPoint TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) { wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var position : vec4; - [[location(0)]] var attrib0 : vec4; - [[location(1)]] var attrib1 : vec4; - - [[stage(vertex)]] fn vertex0() { - position = attrib0; - return; + [[stage(vertex)]] fn vertex0([[location(0)]] attrib0 : vec4) + -> [[builtin(position)]] vec4 { + return attrib0; } - [[stage(vertex)]] fn vertex1() { - position = attrib1; - return; + [[stage(vertex)]] fn vertex1([[location(1)]] attrib1 : vec4) + -> [[builtin(position)]] vec4 { + return attrib1; } )"); @@ -687,16 +678,11 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) { // Test that fragment output validation is for the correct entryPoint TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) { wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( - [[location(0)]] var colorFloat : vec4; - [[location(0)]] var colorUint : vec4; - - [[stage(fragment)]] fn fragmentFloat() { - colorFloat = vec4(0.0, 0.0, 0.0, 0.0); - return; + [[stage(fragment)]] fn fragmentFloat() -> [[location(0)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); } - [[stage(fragment)]] fn fragmentUint() { - colorUint = vec4(0u, 0u, 0u, 0u); - return; + [[stage(fragment)]] fn fragmentUint() -> [[location(0)]] vec4 { + return vec4(0u, 0u, 0u, 0u); } )"); @@ -730,21 +716,15 @@ TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) { [[block]] struct Uniforms { data : vec4; }; - [[binding 0, set 0]] var var0 : Uniforms; - [[binding 1, set 0]] var var1 : Uniforms; - [[builtin(position)]] var position : vec4; + [[group(0), binding(0)]] var var0 : Uniforms; + [[group(0), binding(1)]] var var1 : Uniforms; - fn vertex0() { - position = var0.data; - return; + [[stage(vertex)]] fn vertex0() -> [[builtin(position)]] vec4 { + return var0.data; } - fn vertex1() { - position = var1.data; - return; + [[stage(vertex)]] fn vertex1() -> [[builtin(position)]] vec4 { + return var1.data; } - - entry_point vertex = vertex0; - entry_point vertex = vertex1; )"); wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( diff --git a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp index 1bc39f6ef5..f3a7a05f1d 100644 --- a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp +++ b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp @@ -60,9 +60,9 @@ TEST_F(ShaderModuleValidationTest, CreationSuccess) { // be compiled. TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachments) { std::ostringstream stream; - stream << "[[location(" << kMaxColorAttachments << R"()]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); + stream << "[[stage(fragment)]] fn main() -> [[location(" << kMaxColorAttachments + << R"()]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); })"; ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str())); } @@ -162,12 +162,10 @@ TEST_F(ShaderModuleValidationTest, CompilationMessages) { // is not the case on the wire. DAWN_SKIP_TEST_IF(UsesWire()); - std::ostringstream stream; - stream << R"([[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); - })"; - wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, stream.str().c_str()); + wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"( + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); + })"); dawn_native::ShaderModuleBase* shaderModuleBase = reinterpret_cast(shaderModule.Get()); diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp index f705049c52..aa96915f73 100644 --- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -24,14 +24,12 @@ class StorageTextureValidationTests : public ValidationTest { ValidationTest::SetUp(); mDefaultVSModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); })"); mDefaultFSModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(1.0, 0.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(1.0, 0.0, 0.0, 1.0); })"); } @@ -122,10 +120,10 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) { { wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d; - [[builtin(vertex_index)]] var VertexIndex : u32; - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = textureLoad(image0, vec2(i32(VertexIndex), 0)); + [[stage(vertex)]] fn main( + [[builtin(vertex_index)]] VertexIndex : u32 + ) -> [[builtin(position)]] vec4 { + return textureLoad(image0, vec2(i32(VertexIndex), 0)); })"); utils::ComboRenderPipelineDescriptor2 descriptor; @@ -139,10 +137,10 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) { { wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d; - [[builtin(frag_coord)]] var FragCoord : vec4; - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = textureLoad(image0, vec2(FragCoord.xy)); + [[stage(fragment)]] fn main( + [[builtin(frag_coord)]] FragCoord : vec4 + ) -> [[location(0)]] vec4 { + return textureLoad(image0, vec2(FragCoord.xy)); })"); utils::ComboRenderPipelineDescriptor2 descriptor; @@ -155,9 +153,8 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) { // Write-only storage textures cannot be declared in a vertex shader. if ((false) /* TODO(https://crbug.com/tint/449) */) { wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( - [[builtin(vertex_index)]] var vertex_index : u32; [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d; - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main([[builtin(vertex_index)]] vertex_index : u32) { textureStore(image0, vec2(i32(vertex_index), 0), vec4(1.0, 0.0, 0.0, 1.0)); })"); @@ -171,9 +168,8 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) { // Write-only storage textures can be declared in a fragment shader. { wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( - [[builtin(frag_coord)]] var frag_coord : vec4; [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d; - [[stage(fragment)]] fn main() { + [[stage(fragment)]] fn main([[builtin(frag_coord)]] frag_coord : vec4) { textureStore(image0, vec2(frag_coord.xy), vec4(1.0, 0.0, 0.0, 1.0)); })"); @@ -192,14 +188,13 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) { { wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d; - [[builtin(local_invocation_id)]] var LocalInvocationID : vec3; [[block]] struct Buf { data : f32; }; [[group(0), binding(1)]] var buf : [[access(read_write)]] Buf; - [[stage(compute)]] fn main() { + [[stage(compute)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3) { buf.data = textureLoad(image0, vec2(LocalInvocationID.xy)).x; })"); @@ -215,9 +210,8 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) { { wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d; - [[builtin(local_invocation_id)]] var LocalInvocationID : vec3; - [[stage(compute)]] fn main() { + [[stage(compute)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3) { textureStore(image0, vec2(LocalInvocationID.xy), vec4(0.0, 0.0, 0.0, 0.0)); })"); diff --git a/src/tests/unittests/validation/VertexBufferValidationTests.cpp b/src/tests/unittests/validation/VertexBufferValidationTests.cpp index cbab0e764b..c7163b6c7c 100644 --- a/src/tests/unittests/validation/VertexBufferValidationTests.cpp +++ b/src/tests/unittests/validation/VertexBufferValidationTests.cpp @@ -26,9 +26,8 @@ class VertexBufferValidationTest : public ValidationTest { ValidationTest::SetUp(); fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(0.0, 1.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(0.0, 1.0, 0.0, 1.0); })"); } @@ -42,13 +41,18 @@ class VertexBufferValidationTest : public ValidationTest { wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) { std::ostringstream vs; + vs << "[[stage(vertex)]] fn main(\n"; for (unsigned int i = 0; i < bufferCount; ++i) { - vs << "[[location(" << i << ")]] var a_position" << i << " : vec3;\n"; + // TODO(cwallez@chromium.org): remove this special handling of 0 once Tint supports + // trailing commas in argument lists. + if (i != 0) { + vs << ", "; + } + vs << "[[location(" << i << ")]] a_position" << i << " : vec3\n"; } - vs << "[[builtin(position)]] var Position : vec4;"; - vs << "[[stage(vertex)]] fn main() {\n"; + vs << ") -> [[builtin(position)]] vec4 {"; - vs << "Position = vec4("; + vs << "return vec4("; for (unsigned int i = 0; i < bufferCount; ++i) { vs << "a_position" << i; if (i != bufferCount - 1) { diff --git a/src/tests/unittests/validation/VertexStateValidationTests.cpp b/src/tests/unittests/validation/VertexStateValidationTests.cpp index 2a4c601ec8..9682b64411 100644 --- a/src/tests/unittests/validation/VertexStateValidationTests.cpp +++ b/src/tests/unittests/validation/VertexStateValidationTests.cpp @@ -24,9 +24,8 @@ class VertexStateTest : public ValidationTest { const char* vertexSource) { wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexSource); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( - [[location(0)]] var fragColor : vec4; - [[stage(fragment)]] fn main() { - fragColor = vec4(1.0, 0.0, 0.0, 1.0); + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return vec4(1.0, 0.0, 0.0, 1.0); } )"); @@ -45,9 +44,8 @@ class VertexStateTest : public ValidationTest { } const char* kDummyVertexShader = R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); } )"; }; @@ -99,29 +97,29 @@ TEST_F(VertexStateTest, PipelineCompatibility) { // Control case: pipeline with one input per attribute CreatePipeline(true, state, R"( - [[location(0)]] var a : vec4; - [[location(1)]] var b : vec4; - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(vertex)]] fn main( + [[location(0)]] a : vec4, + [[location(1)]] b : vec4 + ) -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); } )"); // Check it is valid for the pipeline to use a subset of the VertexState CreatePipeline(true, state, R"( - [[location(0)]] var a : vec4; - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(vertex)]] fn main( + [[location(0)]] a : vec4 + ) -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); } )"); // Check for an error when the pipeline uses an attribute not in the vertex input CreatePipeline(false, state, R"( - [[location(2)]] var a : vec4; - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 0.0); + [[stage(vertex)]] fn main( + [[location(2)]] a : vec4 + ) -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 0.0); } )"); } diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp index e4f6fe62f6..5393e22097 100644 --- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -40,16 +40,16 @@ class D3D12DescriptorHeapTests : public DawnTest { mD3DDevice = reinterpret_cast(device.Get()); mSimpleVSModule = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[builtin(vertex_index)]] var VertexIndex : u32; - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main( + [[builtin(vertex_index)]] VertexIndex : u32 + ) -> [[builtin(position)]] vec4 { const pos : array, 3> = array, 3>( vec2(-1.0, 1.0), vec2( 1.0, 1.0), vec2(-1.0, -1.0) ); - Position = vec4(pos[VertexIndex], 0.0, 1.0); + return vec4(pos[VertexIndex], 0.0, 1.0); })"); mSimpleFSModule = utils::CreateShaderModule(device, R"( @@ -57,10 +57,9 @@ class D3D12DescriptorHeapTests : public DawnTest { color : vec4; }; [[group(0), binding(0)]] var colorBuffer : U; - [[location(0)]] var FragColor : vec4; - [[stage(fragment)]] fn main() { - FragColor = colorBuffer.color; + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return colorBuffer.color; })"); } @@ -177,17 +176,15 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) { // sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over // because the sampler heap allocations are de-duplicated. renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[stage(vertex)]] fn main() { - Position = vec4(0.0, 0.0, 0.0, 1.0); + [[stage(vertex)]] fn main() -> [[builtin(position)]] vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); })"); renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( - [[location(0)]] var FragColor : vec4; [[group(0), binding(0)]] var sampler0 : sampler; - [[stage(fragment)]] fn main() { + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { let referenceSampler : sampler = sampler0; - FragColor = vec4(0.0, 0.0, 0.0, 0.0); + return vec4(0.0, 0.0, 0.0, 0.0); })"); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor); @@ -787,16 +784,16 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) { transform : mat2x2; }; [[group(0), binding(0)]] var buffer0 : U; - [[builtin(position)]] var Position : vec4; - [[builtin(vertex_index)]] var VertexIndex : u32; - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main( + [[builtin(vertex_index)]] VertexIndex : u32 + ) -> [[builtin(position)]] vec4 { const pos : array, 3> = array, 3>( vec2(-1.0, 1.0), vec2( 1.0, 1.0), vec2(-1.0, -1.0) ); - Position = vec4(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0); + return vec4(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0); })"); pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( [[block]] struct U { @@ -806,11 +803,10 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) { [[group(0), binding(2)]] var texture0 : texture_2d; [[group(0), binding(3)]] var buffer0 : U; - [[location(0)]] var FragColor : vec4; - [[builtin(frag_coord)]] var FragCoord : vec4; - - [[stage(fragment)]] fn main() { - FragColor = textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color; + [[stage(fragment)]] fn main( + [[builtin(frag_coord)]] FragCoord : vec4 + ) -> [[location(0)]] vec4 { + return textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color; })"); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); diff --git a/src/tests/white_box/D3D12ResidencyTests.cpp b/src/tests/white_box/D3D12ResidencyTests.cpp index 1b5ce49413..804d93334f 100644 --- a/src/tests/white_box/D3D12ResidencyTests.cpp +++ b/src/tests/white_box/D3D12ResidencyTests.cpp @@ -339,16 +339,15 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { // Fill in a view heap with "view only" bindgroups (1x view per group) by creating a // view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over. renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( - [[builtin(position)]] var Position : vec4; - [[builtin(vertex_index)]] var VertexIndex : u32; - - [[stage(vertex)]] fn main() { + [[stage(vertex)]] fn main( + [[builtin(vertex_index)]] VertexIndex : u32 + ) -> [[builtin(position)]] vec4 { const pos : array, 3> = array, 3>( vec2(-1.0, 1.0), vec2( 1.0, 1.0), vec2(-1.0, -1.0) ); - Position = vec4(pos[VertexIndex], 0.0, 1.0); + return vec4(pos[VertexIndex], 0.0, 1.0); })"); renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( @@ -356,10 +355,9 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { color : vec4; }; [[group(0), binding(0)]] var colorBuffer : U; - [[location(0)]] var FragColor : vec4; - [[stage(fragment)]] fn main() { - FragColor = colorBuffer.color; + [[stage(fragment)]] fn main() -> [[location(0)]] vec4 { + return colorBuffer.color; })"); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);