Convert @stage to short form

This CL converts remaining @stage instances in the dawn tree to use
the equivalent shorter variant.

Bug: tint:1503
Change-Id: I74594cd68544fbd692f77d4646991d9c27e218f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92484
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-06-07 15:57:35 +00:00 committed by Dawn LUCI CQ
parent 3f1a93291b
commit d574be5750
13 changed files with 22 additions and 22 deletions

View File

@ -94,7 +94,7 @@ Current translation, through SPIR-V, SPIR-V reader, WGSL writer:
return;
}
@stage(fragment)
@fragment
fn main() -> void {
bar_();
return;
@ -126,7 +126,7 @@ Proposed translation, through SPIR-V, SPIR-V reader, WGSL writer:
@location(0) frag_color : vec4<f32>;
};
@stage(fragment)
@fragment
fn main(
// 'in' variables are entry point parameters

View File

@ -64,7 +64,7 @@ ResultOrError<ComputePipelineBase*> GetOrCreateIndirectDispatchValidationPipelin
@group(0) @binding(1) var<storage, read_write> clientParams: IndirectParams;
@group(0) @binding(2) var<storage, write> validatedParams: ValidatedParams;
@stage(compute) @workgroup_size(1, 1, 1)
@compute @workgroup_size(1, 1, 1)
fn main() {
for (var i = 0u; i < 3u; i = i + 1u) {
var numWorkgroups = clientParams.data[uniformParams.clientOffsetInU32 + i];

View File

@ -85,7 +85,7 @@ static const char sCopyTextureForBrowserShader[] = R"(
return sign(v) * (pow(params.A * abs(v) + params.B, params.G) + params.E);
}
@stage(vertex)
@vertex
fn vs_main(
@builtin(vertex_index) VertexIndex : u32
) -> VertexOutputs {
@ -123,7 +123,7 @@ static const char sCopyTextureForBrowserShader[] = R"(
@binding(1) @group(0) var mySampler: sampler;
@binding(2) @group(0) var myTexture: texture_2d<f32>;
@stage(fragment)
@fragment
fn fs_main(
@location(0) texcoord : vec2<f32>
) -> @location(0) vec4<f32> {

View File

@ -274,7 +274,7 @@ MaybeError DeviceBase::Initialize(Ref<QueueBase> defaultQueue) {
if (IsToggleEnabled(Toggle::UsePlaceholderFragmentInVertexOnlyPipeline)) {
// The empty fragment shader, used as a work around for vertex-only render pipeline
constexpr char kEmptyFragmentShader[] = R"(
@stage(fragment) fn fs_empty_main() {}
@fragment fn fs_empty_main() {}
)";
ShaderModuleDescriptor descriptor;
ShaderModuleWGSLDescriptor wgslDesc;

View File

@ -130,7 +130,7 @@ static const char sRenderValidationShaderSource[] = R"(
}
}
@stage(compute) @workgroup_size(64, 1, 1)
@compute @workgroup_size(64, 1, 1)
fn main(@builtin(global_invocation_id) id : vec3<u32>) {
if (id.x >= batch.numDraws) {
return;

View File

@ -66,7 +66,7 @@ static const char sConvertTimestampsToNanoseconds[] = R"(
let sizeofTimestamp : u32 = 8u;
@stage(compute) @workgroup_size(8, 1, 1)
@compute @workgroup_size(8, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
if (GlobalInvocationID.x >= params.count) { return; }

View File

@ -72,7 +72,7 @@ void init() {
@builtin(position) Position : vec4<f32>;
};
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
@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),
@ -112,7 +112,7 @@ void init() {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main(@location(0) v_color : vec4<f32>) -> @location(0) vec4<f32> {
@fragment fn main(@location(0) v_color : vec4<f32>) -> @location(0) vec4<f32> {
return v_color;
})");

View File

@ -32,7 +32,7 @@ void init() {
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
const char* vs = R"(
@stage(vertex) fn main(
@vertex fn main(
@builtin(vertex_index) VertexIndex : u32
) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>(
@ -45,7 +45,7 @@ void init() {
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
const char* fs = R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> {
@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

@ -102,7 +102,7 @@ void initRender() {
@location(2) a_pos : vec2<f32>;
};
@stage(vertex)
@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>(
@ -113,7 +113,7 @@ void initRender() {
)");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment)
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
}
@ -170,7 +170,7 @@ void initSim() {
@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)
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
var index : u32 = GlobalInvocationID.x;
if (index >= params.particleCount) {

View File

@ -95,7 +95,7 @@ void init() {
initTextures();
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main(@location(0) pos : vec4<f32>)
@vertex fn main(@location(0) pos : vec4<f32>)
-> @builtin(position) vec4<f32> {
return pos;
})");
@ -104,7 +104,7 @@ void init() {
@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>)
@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

@ -316,7 +316,7 @@ 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)
@vertex fn main(@builtin(vertex_index) VertexIndex : u32)
-> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>(
vec2<f32>( 0.0, 0.5),
@ -326,7 +326,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> {
@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].

View File

@ -337,7 +337,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
std::ostringstream ostream;
ostream << GetImageDeclaration(format, "write", dimension, 0) << "\n";
ostream << "@stage(" << stage << ")" << workgroupSize << "\n";
ostream << "@" << stage << workgroupSize << "\n";
ostream << "fn main() ";
if (isFragment) {
ostream << "-> @location(0) vec4<f32> ";

View File

@ -203,7 +203,7 @@ type example struct {
func tryCompile(compiler, wd string, e example) error {
code := e.code
if e.functionScope {
code = "\n@stage(vertex) fn main() -> @builtin(position) vec4<f32> {\n" + code + " return vec4<f32>();}\n"
code = "\n@vertex fn main() -> @builtin(position) vec4<f32> {\n" + code + " return vec4<f32>();}\n"
}
addedStubFunction := false
@ -214,7 +214,7 @@ func tryCompile(compiler, wd string, e example) error {
}
if !addedStubFunction {
code += "\n@stage(vertex) fn main() {}\n"
code += "\n@vertex fn main() {}\n"
addedStubFunction = true
continue
}