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
@@ -96,28 +96,26 @@ void initBuffers() {
|
||||
|
||||
void initRender() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[location(0)]] var<in> a_particlePos : vec2<f32>;
|
||||
[[location(1)]] var<in> a_particleVel : vec2<f32>;
|
||||
[[location(2)]] var<in> a_pos : vec2<f32>;
|
||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||
struct VertexIn {
|
||||
[[location(0)]] a_particlePos : vec2<f32>;
|
||||
[[location(1)]] a_particleVel : vec2<f32>;
|
||||
[[location(2)]] a_pos : vec2<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() {
|
||||
var angle : f32 = -atan2(a_particleVel.x, a_particleVel.y);
|
||||
fn main(input : VertexIn) -> [[builtin(position)]] vec4<f32> {
|
||||
var angle : f32 = -atan2(input.a_particleVel.x, input.a_particleVel.y);
|
||||
var pos : vec2<f32> = vec2<f32>(
|
||||
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
|
||||
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
|
||||
Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
|
||||
return;
|
||||
(input.a_pos.x * cos(angle)) - (input.a_pos.y * sin(angle)),
|
||||
(input.a_pos.x * sin(angle)) + (input.a_pos.y * cos(angle)));
|
||||
return vec4<f32>(pos + input.a_particlePos, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[location(0)]] var<out> FragColor : vec4<f32>;
|
||||
[[stage(fragment)]]
|
||||
fn main() {
|
||||
FragColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
return;
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
||||
@@ -170,11 +168,10 @@ void initSim() {
|
||||
[[binding(0), group(0)]] var<uniform> params : SimParams;
|
||||
[[binding(1), group(0)]] var<storage> particlesA : [[access(read)]] Particles;
|
||||
[[binding(2), group(0)]] var<storage> particlesB : [[access(read_write)]] Particles;
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
var index : u32 = GlobalInvocationID.x;
|
||||
if (index >= params.particleCount) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user