wgsl: Replace use of [[attribute]] with @attribute

Bug: tint:1382
Change-Id: I58ad2c88fde1e7c96f2ae8257e6df924b94b61db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-01-25 16:29:04 +00:00
committed by Dawn LUCI CQ
parent facbc82d6c
commit a9ca8cb4ab
101 changed files with 1307 additions and 1312 deletions

View File

@@ -66,14 +66,14 @@ void init() {
scalar : f32;
scalarOffset : f32;
};
[[group(0), binding(0)]] var<uniform> c : Constants;
@group(0) @binding(0) var<uniform> c : Constants;
struct VertexOut {
[[location(0)]] v_color : vec4<f32>;
[[builtin(position)]] Position : vec4<f32>;
@location(0) v_color : vec4<f32>;
@builtin(position) Position : vec4<f32>;
};
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
vec4<f32>( 0.0, 0.1, 0.0, 1.0),
vec4<f32>(-0.1, -0.1, 0.0, 1.0),
@@ -113,8 +113,7 @@ void init() {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main([[location(0)]] v_color : vec4<f32>)
-> [[location(0)]] vec4<f32> {
@stage(fragment) fn main(@location(0) v_color : vec4<f32>) -> @location(0) vec4<f32> {
return v_color;
})");

View File

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

View File

@@ -96,13 +96,13 @@ void initBuffers() {
void initRender() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexIn {
[[location(0)]] a_particlePos : vec2<f32>;
[[location(1)]] a_particleVel : vec2<f32>;
[[location(2)]] a_pos : vec2<f32>;
@location(0) a_particlePos : vec2<f32>;
@location(1) a_particleVel : vec2<f32>;
@location(2) a_pos : vec2<f32>;
};
[[stage(vertex)]]
fn main(input : VertexIn) -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
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>(
(input.a_pos.x * cos(angle)) - (input.a_pos.y * sin(angle)),
@@ -112,8 +112,8 @@ void initRender() {
)");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]]
fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
}
)");
@@ -164,13 +164,13 @@ void initSim() {
struct Particles {
particles : array<Particle>;
};
[[binding(0), group(0)]] var<uniform> params : SimParams;
[[binding(1), group(0)]] var<storage, read> particlesA : Particles;
[[binding(2), group(0)]] var<storage, read_write> particlesB : Particles;
@binding(0), group(0) var<uniform> params : SimParams;
@binding(1), group(0) var<storage, read> particlesA : Particles;
@binding(2), group(0) var<storage, read_write> particlesB : Particles;
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
[[stage(compute), workgroup_size(1)]]
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
@stage(compute) @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
var index : u32 = GlobalInvocationID.x;
if (index >= params.particleCount) {
return;

View File

@@ -97,17 +97,17 @@ void init() {
initTextures();
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main([[location(0)]] pos : vec4<f32>)
-> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main(@location(0) pos : vec4<f32>)
-> @builtin(position) vec4<f32> {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main([[builtin(position)]] FragCoord : vec4<f32>)
-> [[location(0)]] vec4<f32> {
@stage(fragment) fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
return textureSample(myTexture, mySampler, FragCoord.xy / vec2<f32>(640.0, 480.0));
})");

View File

@@ -314,8 +314,8 @@ int main(int argc, const char* argv[]) {
// The hacky pipeline to render a triangle.
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
-> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32)
-> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>(
vec2<f32>( 0.0, 0.5),
vec2<f32>(-0.5, -0.5),
@@ -324,7 +324,7 @@ int main(int argc, const char* argv[]) {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@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].