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:
parent
3f1a93291b
commit
d574be5750
|
@ -94,7 +94,7 @@ Current translation, through SPIR-V, SPIR-V reader, WGSL writer:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@fragment
|
||||||
fn main() -> void {
|
fn main() -> void {
|
||||||
bar_();
|
bar_();
|
||||||
return;
|
return;
|
||||||
|
@ -126,7 +126,7 @@ Proposed translation, through SPIR-V, SPIR-V reader, WGSL writer:
|
||||||
@location(0) frag_color : vec4<f32>;
|
@location(0) frag_color : vec4<f32>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@stage(fragment)
|
@fragment
|
||||||
fn main(
|
fn main(
|
||||||
|
|
||||||
// 'in' variables are entry point parameters
|
// 'in' variables are entry point parameters
|
||||||
|
|
|
@ -64,7 +64,7 @@ ResultOrError<ComputePipelineBase*> GetOrCreateIndirectDispatchValidationPipelin
|
||||||
@group(0) @binding(1) var<storage, read_write> clientParams: IndirectParams;
|
@group(0) @binding(1) var<storage, read_write> clientParams: IndirectParams;
|
||||||
@group(0) @binding(2) var<storage, write> validatedParams: ValidatedParams;
|
@group(0) @binding(2) var<storage, write> validatedParams: ValidatedParams;
|
||||||
|
|
||||||
@stage(compute) @workgroup_size(1, 1, 1)
|
@compute @workgroup_size(1, 1, 1)
|
||||||
fn main() {
|
fn main() {
|
||||||
for (var i = 0u; i < 3u; i = i + 1u) {
|
for (var i = 0u; i < 3u; i = i + 1u) {
|
||||||
var numWorkgroups = clientParams.data[uniformParams.clientOffsetInU32 + i];
|
var numWorkgroups = clientParams.data[uniformParams.clientOffsetInU32 + i];
|
||||||
|
|
|
@ -85,7 +85,7 @@ static const char sCopyTextureForBrowserShader[] = R"(
|
||||||
return sign(v) * (pow(params.A * abs(v) + params.B, params.G) + params.E);
|
return sign(v) * (pow(params.A * abs(v) + params.B, params.G) + params.E);
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(vertex)
|
@vertex
|
||||||
fn vs_main(
|
fn vs_main(
|
||||||
@builtin(vertex_index) VertexIndex : u32
|
@builtin(vertex_index) VertexIndex : u32
|
||||||
) -> VertexOutputs {
|
) -> VertexOutputs {
|
||||||
|
@ -123,7 +123,7 @@ static const char sCopyTextureForBrowserShader[] = R"(
|
||||||
@binding(1) @group(0) var mySampler: sampler;
|
@binding(1) @group(0) var mySampler: sampler;
|
||||||
@binding(2) @group(0) var myTexture: texture_2d<f32>;
|
@binding(2) @group(0) var myTexture: texture_2d<f32>;
|
||||||
|
|
||||||
@stage(fragment)
|
@fragment
|
||||||
fn fs_main(
|
fn fs_main(
|
||||||
@location(0) texcoord : vec2<f32>
|
@location(0) texcoord : vec2<f32>
|
||||||
) -> @location(0) vec4<f32> {
|
) -> @location(0) vec4<f32> {
|
||||||
|
|
|
@ -274,7 +274,7 @@ MaybeError DeviceBase::Initialize(Ref<QueueBase> defaultQueue) {
|
||||||
if (IsToggleEnabled(Toggle::UsePlaceholderFragmentInVertexOnlyPipeline)) {
|
if (IsToggleEnabled(Toggle::UsePlaceholderFragmentInVertexOnlyPipeline)) {
|
||||||
// The empty fragment shader, used as a work around for vertex-only render pipeline
|
// The empty fragment shader, used as a work around for vertex-only render pipeline
|
||||||
constexpr char kEmptyFragmentShader[] = R"(
|
constexpr char kEmptyFragmentShader[] = R"(
|
||||||
@stage(fragment) fn fs_empty_main() {}
|
@fragment fn fs_empty_main() {}
|
||||||
)";
|
)";
|
||||||
ShaderModuleDescriptor descriptor;
|
ShaderModuleDescriptor descriptor;
|
||||||
ShaderModuleWGSLDescriptor wgslDesc;
|
ShaderModuleWGSLDescriptor wgslDesc;
|
||||||
|
|
|
@ -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>) {
|
fn main(@builtin(global_invocation_id) id : vec3<u32>) {
|
||||||
if (id.x >= batch.numDraws) {
|
if (id.x >= batch.numDraws) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -66,7 +66,7 @@ static const char sConvertTimestampsToNanoseconds[] = R"(
|
||||||
|
|
||||||
let sizeofTimestamp : u32 = 8u;
|
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>) {
|
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||||
if (GlobalInvocationID.x >= params.count) { return; }
|
if (GlobalInvocationID.x >= params.count) { return; }
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ void init() {
|
||||||
@builtin(position) Position : vec4<f32>;
|
@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>(
|
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
|
||||||
vec4<f32>( 0.0, 0.1, 0.0, 1.0),
|
vec4<f32>( 0.0, 0.1, 0.0, 1.0),
|
||||||
vec4<f32>(-0.1, -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"(
|
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;
|
return v_color;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ void init() {
|
||||||
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
|
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||||
|
|
||||||
const char* vs = R"(
|
const char* vs = R"(
|
||||||
@stage(vertex) fn main(
|
@vertex fn main(
|
||||||
@builtin(vertex_index) VertexIndex : u32
|
@builtin(vertex_index) VertexIndex : u32
|
||||||
) -> @builtin(position) vec4<f32> {
|
) -> @builtin(position) vec4<f32> {
|
||||||
var pos = array<vec2<f32>, 3>(
|
var pos = array<vec2<f32>, 3>(
|
||||||
|
@ -45,7 +45,7 @@ void init() {
|
||||||
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
|
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
|
||||||
|
|
||||||
const char* fs = R"(
|
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);
|
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
})";
|
})";
|
||||||
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
|
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
|
||||||
|
|
|
@ -102,7 +102,7 @@ void initRender() {
|
||||||
@location(2) a_pos : vec2<f32>;
|
@location(2) a_pos : vec2<f32>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@stage(vertex)
|
@vertex
|
||||||
fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
|
fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
|
||||||
var angle : f32 = -atan2(input.a_particleVel.x, input.a_particleVel.y);
|
var angle : f32 = -atan2(input.a_particleVel.x, input.a_particleVel.y);
|
||||||
var pos : vec2<f32> = vec2<f32>(
|
var pos : vec2<f32> = vec2<f32>(
|
||||||
|
@ -113,7 +113,7 @@ void initRender() {
|
||||||
)");
|
)");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||||
@stage(fragment)
|
@fragment
|
||||||
fn main() -> @location(0) vec4<f32> {
|
fn main() -> @location(0) vec4<f32> {
|
||||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
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;
|
@binding(2) @group(0) var<storage, read_write> particlesB : Particles;
|
||||||
|
|
||||||
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
|
// 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>) {
|
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||||
var index : u32 = GlobalInvocationID.x;
|
var index : u32 = GlobalInvocationID.x;
|
||||||
if (index >= params.particleCount) {
|
if (index >= params.particleCount) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ void init() {
|
||||||
initTextures();
|
initTextures();
|
||||||
|
|
||||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
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> {
|
-> @builtin(position) vec4<f32> {
|
||||||
return pos;
|
return pos;
|
||||||
})");
|
})");
|
||||||
|
@ -104,7 +104,7 @@ void init() {
|
||||||
@group(0) @binding(0) var mySampler: sampler;
|
@group(0) @binding(0) var mySampler: sampler;
|
||||||
@group(0) @binding(1) var myTexture : texture_2d<f32>;
|
@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> {
|
-> @location(0) vec4<f32> {
|
||||||
return textureSample(myTexture, mySampler, FragCoord.xy / vec2<f32>(640.0, 480.0));
|
return textureSample(myTexture, mySampler, FragCoord.xy / vec2<f32>(640.0, 480.0));
|
||||||
})");
|
})");
|
||||||
|
|
|
@ -316,7 +316,7 @@ int main(int argc, const char* argv[]) {
|
||||||
// The hacky pipeline to render a triangle.
|
// The hacky pipeline to render a triangle.
|
||||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
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> {
|
-> @builtin(position) vec4<f32> {
|
||||||
var pos = array<vec2<f32>, 3>(
|
var pos = array<vec2<f32>, 3>(
|
||||||
vec2<f32>( 0.0, 0.5),
|
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);
|
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
})");
|
})");
|
||||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
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);
|
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
})");
|
})");
|
||||||
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
||||||
|
|
|
@ -337,7 +337,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
|
|
||||||
std::ostringstream ostream;
|
std::ostringstream ostream;
|
||||||
ostream << GetImageDeclaration(format, "write", dimension, 0) << "\n";
|
ostream << GetImageDeclaration(format, "write", dimension, 0) << "\n";
|
||||||
ostream << "@stage(" << stage << ")" << workgroupSize << "\n";
|
ostream << "@" << stage << workgroupSize << "\n";
|
||||||
ostream << "fn main() ";
|
ostream << "fn main() ";
|
||||||
if (isFragment) {
|
if (isFragment) {
|
||||||
ostream << "-> @location(0) vec4<f32> ";
|
ostream << "-> @location(0) vec4<f32> ";
|
||||||
|
|
|
@ -203,7 +203,7 @@ type example struct {
|
||||||
func tryCompile(compiler, wd string, e example) error {
|
func tryCompile(compiler, wd string, e example) error {
|
||||||
code := e.code
|
code := e.code
|
||||||
if e.functionScope {
|
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
|
addedStubFunction := false
|
||||||
|
@ -214,7 +214,7 @@ func tryCompile(compiler, wd string, e example) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !addedStubFunction {
|
if !addedStubFunction {
|
||||||
code += "\n@stage(vertex) fn main() {}\n"
|
code += "\n@vertex fn main() {}\n"
|
||||||
addedStubFunction = true
|
addedStubFunction = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue