Update examples for recent WGSL changes

* Use new entry point IO syntax
* Use `let` instead of `const`
* Remove `-> void` from function headers

Bug: dawn:755
Change-Id: I39b5687a342ea2298c3d2e85517c9b8d9017727e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47500
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-04-13 14:52:44 +00:00
committed by Commit Bot service account
parent f3fe648675
commit 9e0debd91e
6 changed files with 64 additions and 81 deletions

View File

@@ -37,24 +37,21 @@ void init() {
wgpuSwapChainConfigure(swapchain, swapChainFormat, WGPUTextureUsage_RenderAttachment, 640, 480);
const char* vs =
"[[builtin(vertex_index)]] var<in> VertexIndex : u32;\n"
"[[builtin(position)]] var<out> Position : vec4<f32>;\n"
"const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
"let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
" vec2<f32>( 0.0, 0.5),\n"
" vec2<f32>(-0.5, -0.5),\n"
" vec2<f32>( 0.5, -0.5)\n"
");\n"
"[[stage(vertex)]] fn main() {\n"
" Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n"
" return;\n"
"[[stage(vertex)]] fn main(\n"
" [[builtin(vertex_index)]] VertexIndex : u32\n"
") -> [[builtin(position)]] vec4<f32> {\n"
" return vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n"
"}\n";
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
const char* fs =
"[[location(0)]] var<out> fragColor : vec4<f32>;\n"
"[[stage(fragment)]] fn main() {\n"
" fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);\n"
" return;\n"
"[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {\n"
" return vec4<f32>(1.0, 0.0, 0.0, 1.0);\n"
"}\n";
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();