mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
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:
committed by
Commit Bot service account
parent
f3fe648675
commit
9e0debd91e
@@ -313,22 +313,18 @@ int main(int argc, const char* argv[]) {
|
||||
// The hacky pipeline to render a triangle.
|
||||
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
|
||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||
const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
vec2<f32>( 0.5, -0.5)
|
||||
);
|
||||
[[stage(vertex)]] fn main() {
|
||||
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
return;
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
})");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
||||
pipelineDesc.cTargets[0].format = wgpu::TextureFormat::BGRA8Unorm;
|
||||
|
||||
Reference in New Issue
Block a user