From d7335fa9749554d1743573a9f3d955afead6c514 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 18 Jan 2021 15:51:13 +0000 Subject: [PATCH] Update builtin idx names. This CL upldates the vertex_idx, instance_idx and global_invocation_idx builtins to use the full _index names. The original values still exist until we can update downstream users. Change-Id: Icd02601eeb15704d5463158541c07816d98e5383 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37940 Commit-Queue: dan sinclair Auto-Submit: dan sinclair Reviewed-by: Ben Clayton --- docs/translations.md | 6 ++--- src/ast/builtin.cc | 12 ++++----- src/ast/builtin.h | 6 ++--- src/reader/spirv/enum_converter.cc | 6 ++--- src/reader/spirv/enum_converter_test.cc | 7 ++--- .../spirv/parser_impl_module_var_test.cc | 2 +- src/reader/wgsl/parser_impl.cc | 12 ++++----- .../parser_impl_variable_decoration_test.cc | 27 +++++++++++-------- src/transform/first_index_offset.cc | 12 ++++----- src/transform/first_index_offset.h | 2 +- src/transform/first_index_offset_test.cc | 22 +++++++-------- src/transform/vertex_pulling.cc | 8 +++--- src/transform/vertex_pulling.h | 4 +-- src/transform/vertex_pulling_test.cc | 18 ++++++------- src/writer/hlsl/generator_impl.cc | 6 ++--- src/writer/hlsl/generator_impl_test.cc | 6 ++--- src/writer/msl/generator_impl.cc | 6 ++--- src/writer/msl/generator_impl_test.cc | 6 ++--- src/writer/spirv/builder.cc | 6 ++--- .../spirv/builder_global_variable_test.cc | 6 ++--- test/triangle.wgsl | 2 +- 21 files changed, 94 insertions(+), 88 deletions(-) diff --git a/docs/translations.md b/docs/translations.md index 270a1a41ad..bf6a8eb4f0 100644 --- a/docs/translations.md +++ b/docs/translations.md @@ -28,13 +28,13 @@ decorated with `NonWritable` or each member of the struct can be decorated with | Name | SPIR-V | MSL | HLSL | |------|--------|-----|------| | position | SpvBuiltInPosition |position | SV_Position | -| vertex_idx | SpvBuiltInVertexIndex |vertex_id | SV_VertexID | -| instance_idx | SpvBuiltInInstanceIndex | instance_id| SV_InstanceID | +| vertex_index | SpvBuiltInVertexIndex |vertex_id | SV_VertexID | +| instance_index | SpvBuiltInInstanceIndex | instance_id| SV_InstanceID | | front_facing | SpvBuiltInFrontFacing | front_facing | SV_IsFrontFacing | | frag_coord | SpvBuiltInFragCoord | position | SV_Position | | frag_depth | SpvBuiltInFragDepth | depth(any) | SV_Depth | | local_invocation_id | SpvBuiltInLocalInvocationId | thread_position_in_threadgroup | SV_GroupThreadID | -| local_invocation_idx | SpvBuiltInLocalInvocationIndex | thread_index_in_threadgroup | SV_GroupIndex | +| local_invocation_index | SpvBuiltInLocalInvocationIndex | thread_index_in_threadgroup | SV_GroupIndex | | global_invocation_id | SpvBuiltInGlobalInvocationId | thread_position_in_grid | SV_DispatchThreadID | diff --git a/src/ast/builtin.cc b/src/ast/builtin.cc index 5a7eb63b59..8a8485fca3 100644 --- a/src/ast/builtin.cc +++ b/src/ast/builtin.cc @@ -27,12 +27,12 @@ std::ostream& operator<<(std::ostream& out, Builtin builtin) { out << "position"; break; } - case Builtin::kVertexIdx: { - out << "vertex_idx"; + case Builtin::kVertexIndex: { + out << "vertex_index"; break; } - case Builtin::kInstanceIdx: { - out << "instance_idx"; + case Builtin::kInstanceIndex: { + out << "instance_index"; break; } case Builtin::kFrontFacing: { @@ -51,8 +51,8 @@ std::ostream& operator<<(std::ostream& out, Builtin builtin) { out << "local_invocation_id"; break; } - case Builtin::kLocalInvocationIdx: { - out << "local_invocation_idx"; + case Builtin::kLocalInvocationIndex: { + out << "local_invocation_index"; break; } case Builtin::kGlobalInvocationId: { diff --git a/src/ast/builtin.h b/src/ast/builtin.h index 9b529180ea..e856e2cd31 100644 --- a/src/ast/builtin.h +++ b/src/ast/builtin.h @@ -24,13 +24,13 @@ namespace ast { enum class Builtin { kNone = -1, kPosition, - kVertexIdx, - kInstanceIdx, + kVertexIndex, + kInstanceIndex, kFrontFacing, kFragCoord, kFragDepth, kLocalInvocationId, - kLocalInvocationIdx, + kLocalInvocationIndex, kGlobalInvocationId, // Below are not currently WGSL builtins, but are included in this enum as diff --git a/src/reader/spirv/enum_converter.cc b/src/reader/spirv/enum_converter.cc index c0ea85f3cf..fa7cc1e6e7 100644 --- a/src/reader/spirv/enum_converter.cc +++ b/src/reader/spirv/enum_converter.cc @@ -71,9 +71,9 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) { case SpvBuiltInPosition: return ast::Builtin::kPosition; case SpvBuiltInVertexIndex: - return ast::Builtin::kVertexIdx; + return ast::Builtin::kVertexIndex; case SpvBuiltInInstanceIndex: - return ast::Builtin::kInstanceIdx; + return ast::Builtin::kInstanceIndex; case SpvBuiltInFrontFacing: return ast::Builtin::kFrontFacing; case SpvBuiltInFragCoord: @@ -83,7 +83,7 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) { case SpvBuiltInLocalInvocationId: return ast::Builtin::kLocalInvocationId; case SpvBuiltInLocalInvocationIndex: - return ast::Builtin::kLocalInvocationIdx; + return ast::Builtin::kLocalInvocationIndex; case SpvBuiltInGlobalInvocationId: return ast::Builtin::kGlobalInvocationId; default: diff --git a/src/reader/spirv/enum_converter_test.cc b/src/reader/spirv/enum_converter_test.cc index 280b231c6b..426b94d598 100644 --- a/src/reader/spirv/enum_converter_test.cc +++ b/src/reader/spirv/enum_converter_test.cc @@ -210,15 +210,16 @@ INSTANTIATE_TEST_SUITE_P( SpvBuiltinTest, testing::Values( BuiltinCase{SpvBuiltInPosition, true, ast::Builtin::kPosition}, - BuiltinCase{SpvBuiltInVertexIndex, true, ast::Builtin::kVertexIdx}, - BuiltinCase{SpvBuiltInInstanceIndex, true, ast::Builtin::kInstanceIdx}, + BuiltinCase{SpvBuiltInVertexIndex, true, ast::Builtin::kVertexIndex}, + BuiltinCase{SpvBuiltInInstanceIndex, true, + ast::Builtin::kInstanceIndex}, BuiltinCase{SpvBuiltInFrontFacing, true, ast::Builtin::kFrontFacing}, BuiltinCase{SpvBuiltInFragCoord, true, ast::Builtin::kFragCoord}, BuiltinCase{SpvBuiltInFragDepth, true, ast::Builtin::kFragDepth}, BuiltinCase{SpvBuiltInLocalInvocationId, true, ast::Builtin::kLocalInvocationId}, BuiltinCase{SpvBuiltInLocalInvocationIndex, true, - ast::Builtin::kLocalInvocationIdx}, + ast::Builtin::kLocalInvocationIndex}, BuiltinCase{SpvBuiltInGlobalInvocationId, true, ast::Builtin::kGlobalInvocationId})); diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index f4ce5106b4..0c50d0dc51 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -208,7 +208,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinVertexIndex) { EXPECT_THAT(module_str, HasSubstr(R"( Variable{ Decorations{ - BuiltinDecoration{vertex_idx} + BuiltinDecoration{vertex_index} } x_52 in diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 6900f239ca..b6fe1307ac 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -103,11 +103,11 @@ ast::Builtin ident_to_builtin(const std::string& str) { if (str == "position") { return ast::Builtin::kPosition; } - if (str == "vertex_idx") { - return ast::Builtin::kVertexIdx; + if (str == "vertex_idx" || str == "vertex_index") { + return ast::Builtin::kVertexIndex; } - if (str == "instance_idx") { - return ast::Builtin::kInstanceIdx; + if (str == "instance_idx" || str == "instance_index") { + return ast::Builtin::kInstanceIndex; } if (str == "front_facing") { return ast::Builtin::kFrontFacing; @@ -121,8 +121,8 @@ ast::Builtin ident_to_builtin(const std::string& str) { if (str == "local_invocation_id") { return ast::Builtin::kLocalInvocationId; } - if (str == "local_invocation_idx") { - return ast::Builtin::kLocalInvocationIdx; + if (str == "local_invocation_idx" || str == "local_invocation_index") { + return ast::Builtin::kLocalInvocationIndex; } if (str == "global_invocation_id") { return ast::Builtin::kGlobalInvocationId; diff --git a/src/reader/wgsl/parser_impl_variable_decoration_test.cc b/src/reader/wgsl/parser_impl_variable_decoration_test.cc index aedded4530..9cf65ab04f 100644 --- a/src/reader/wgsl/parser_impl_variable_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decoration_test.cc @@ -112,17 +112,22 @@ TEST_P(BuiltinTest, VariableDecoration_Builtin) { INSTANTIATE_TEST_SUITE_P( ParserImplTest, BuiltinTest, - testing::Values( - BuiltinData{"position", ast::Builtin::kPosition}, - BuiltinData{"vertex_idx", ast::Builtin::kVertexIdx}, - BuiltinData{"instance_idx", ast::Builtin::kInstanceIdx}, - BuiltinData{"front_facing", ast::Builtin::kFrontFacing}, - BuiltinData{"frag_coord", ast::Builtin::kFragCoord}, - BuiltinData{"frag_depth", ast::Builtin::kFragDepth}, - BuiltinData{"local_invocation_id", ast::Builtin::kLocalInvocationId}, - BuiltinData{"local_invocation_idx", ast::Builtin::kLocalInvocationIdx}, - BuiltinData{"global_invocation_id", - ast::Builtin::kGlobalInvocationId})); + testing::Values(BuiltinData{"position", ast::Builtin::kPosition}, + BuiltinData{"vertex_idx", ast::Builtin::kVertexIndex}, + BuiltinData{"vertex_index", ast::Builtin::kVertexIndex}, + BuiltinData{"instance_idx", ast::Builtin::kInstanceIndex}, + BuiltinData{"instance_index", ast::Builtin::kInstanceIndex}, + BuiltinData{"front_facing", ast::Builtin::kFrontFacing}, + BuiltinData{"frag_coord", ast::Builtin::kFragCoord}, + BuiltinData{"frag_depth", ast::Builtin::kFragDepth}, + BuiltinData{"local_invocation_id", + ast::Builtin::kLocalInvocationId}, + BuiltinData{"local_invocation_idx", + ast::Builtin::kLocalInvocationIndex}, + BuiltinData{"local_invocation_index", + ast::Builtin::kLocalInvocationIndex}, + BuiltinData{"global_invocation_id", + ast::Builtin::kGlobalInvocationId})); TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) { auto p = parser("builtin position)"); diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index adc4680fad..7e6bfda473 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -121,8 +121,8 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) { } }; - // Clone the AST, renaming the kVertexIdx and kInstanceIdx builtins, and add - // a CreateFirstIndexOffset() statement to each function that uses one of + // Clone the AST, renaming the kVertexIndex and kInstanceIndex builtins, and + // add a CreateFirstIndexOffset() statement to each function that uses one of // these builtins. Output out; @@ -132,13 +132,13 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) { for (ast::VariableDecoration* dec : var->decorations()) { if (auto* blt_dec = dec->As()) { ast::Builtin blt_type = blt_dec->value(); - if (blt_type == ast::Builtin::kVertexIdx) { + if (blt_type == ast::Builtin::kVertexIndex) { vertex_index_sym = var->symbol(); has_vertex_index_ = true; return clone_variable_with_new_name( ctx, var, kIndexOffsetPrefix + in->SymbolToName(var->symbol())); - } else if (blt_type == ast::Builtin::kInstanceIdx) { + } else if (blt_type == ast::Builtin::kInstanceIndex) { instance_index_sym = var->symbol(); has_instance_index_ = true; return clone_variable_with_new_name( @@ -160,11 +160,11 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) { ast::StatementList statements; for (const auto& data : func->local_referenced_builtin_variables()) { - if (data.second->value() == ast::Builtin::kVertexIdx) { + if (data.second->value() == ast::Builtin::kVertexIndex) { statements.emplace_back(CreateFirstIndexOffset( in->SymbolToName(vertex_index_sym), kFirstVertexName, buffer_var, ctx->mod)); - } else if (data.second->value() == ast::Builtin::kInstanceIdx) { + } else if (data.second->value() == ast::Builtin::kInstanceIndex) { statements.emplace_back(CreateFirstIndexOffset( in->SymbolToName(instance_index_sym), kFirstInstanceName, buffer_var, ctx->mod)); diff --git a/src/transform/first_index_offset.h b/src/transform/first_index_offset.h index 587412b541..7a6e7f8c6a 100644 --- a/src/transform/first_index_offset.h +++ b/src/transform/first_index_offset.h @@ -26,7 +26,7 @@ namespace tint { namespace transform { /// Adds firstVertex/Instance (injected via root constants) to -/// vertex/instance_idx builtins. +/// vertex/instance index builtins. /// /// This transform assumes that Name transform has been run before. /// diff --git a/src/transform/first_index_offset_test.cc b/src/transform/first_index_offset_test.cc index 91726c4024..0ef6417b8c 100644 --- a/src/transform/first_index_offset_test.cc +++ b/src/transform/first_index_offset_test.cc @@ -28,7 +28,7 @@ using FirstIndexOffsetTest = TransformTest; TEST_F(FirstIndexOffsetTest, Error_AlreadyTransformed) { auto* src = R"( -[[builtin(vertex_idx)]] var vert_idx : u32; +[[builtin(vertex_index)]] var vert_idx : u32; fn test() -> u32 { return vert_idx; @@ -63,7 +63,7 @@ TEST_F(FirstIndexOffsetTest, EmptyModule) { TEST_F(FirstIndexOffsetTest, BasicModuleVertexIndex) { auto* src = R"( -[[builtin(vertex_idx)]] var vert_idx : u32; +[[builtin(vertex_index)]] var vert_idx : u32; fn test() -> u32 { return vert_idx; @@ -82,7 +82,7 @@ struct TintFirstIndexOffsetData { tint_first_vertex_index : u32; }; -[[builtin(vertex_idx)]] var tint_first_index_offset_vert_idx : u32; +[[builtin(vertex_index)]] var tint_first_index_offset_vert_idx : u32; [[binding(1), group(2)]] var tint_first_index_data : TintFirstIndexOffsetData; fn test() -> u32 { @@ -103,7 +103,7 @@ fn entry() -> void { TEST_F(FirstIndexOffsetTest, BasicModuleInstanceIndex) { auto* src = R"( -[[builtin(instance_idx)]] var inst_idx : u32; +[[builtin(instance_index)]] var inst_idx : u32; fn test() -> u32 { return inst_idx; @@ -122,7 +122,7 @@ struct TintFirstIndexOffsetData { tint_first_instance_index : u32; }; -[[builtin(instance_idx)]] var tint_first_index_offset_inst_idx : u32; +[[builtin(instance_index)]] var tint_first_index_offset_inst_idx : u32; [[binding(1), group(7)]] var tint_first_index_data : TintFirstIndexOffsetData; fn test() -> u32 { @@ -143,8 +143,8 @@ fn entry() -> void { TEST_F(FirstIndexOffsetTest, BasicModuleBothIndex) { auto* src = R"( -[[builtin(instance_idx)]] var instance_idx : u32; -[[builtin(vertex_idx)]] var vert_idx : u32; +[[builtin(instance_index)]] var instance_idx : u32; +[[builtin(vertex_index)]] var vert_idx : u32; fn test() -> u32 { return instance_idx + vert_idx; @@ -165,8 +165,8 @@ struct TintFirstIndexOffsetData { tint_first_instance_index : u32; }; -[[builtin(instance_idx)]] var tint_first_index_offset_instance_idx : u32; -[[builtin(vertex_idx)]] var tint_first_index_offset_vert_idx : u32; +[[builtin(instance_index)]] var tint_first_index_offset_instance_idx : u32; +[[builtin(vertex_index)]] var tint_first_index_offset_vert_idx : u32; [[binding(1), group(2)]] var tint_first_index_data : TintFirstIndexOffsetData; fn test() -> u32 { @@ -188,7 +188,7 @@ fn entry() -> void { TEST_F(FirstIndexOffsetTest, NestedCalls) { auto* src = R"( -[[builtin(vertex_idx)]] var vert_idx : u32; +[[builtin(vertex_index)]] var vert_idx : u32; fn func1() -> u32 { return vert_idx; @@ -211,7 +211,7 @@ struct TintFirstIndexOffsetData { tint_first_vertex_index : u32; }; -[[builtin(vertex_idx)]] var tint_first_index_offset_vert_idx : u32; +[[builtin(vertex_index)]] var tint_first_index_offset_vert_idx : u32; [[binding(1), group(2)]] var tint_first_index_data : TintFirstIndexOffsetData; fn func1() -> u32 { diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index a06fe5d7bd..3ec0ce34ca 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -158,7 +158,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() { for (auto* d : v->decorations()) { if (auto* builtin = d->As()) { - if (builtin->value() == ast::Builtin::kVertexIdx) { + if (builtin->value() == ast::Builtin::kVertexIndex) { vertex_index_name = in->SymbolToName(v->symbol()); return; } @@ -179,7 +179,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() { ast::VariableDecorationList{ // decorations out->create(Source{}, - ast::Builtin::kVertexIdx), + ast::Builtin::kVertexIndex), }); out->AddGlobalVariable(var); @@ -205,7 +205,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() { for (auto* d : v->decorations()) { if (auto* builtin = d->As()) { - if (builtin->value() == ast::Builtin::kInstanceIdx) { + if (builtin->value() == ast::Builtin::kInstanceIndex) { instance_index_name = in->SymbolToName(v->symbol()); return; } @@ -226,7 +226,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() { ast::VariableDecorationList{ // decorations out->create(Source{}, - ast::Builtin::kInstanceIdx), + ast::Builtin::kInstanceIndex), }); out->AddGlobalVariable(var); } diff --git a/src/transform/vertex_pulling.h b/src/transform/vertex_pulling.h index 2233678120..a09cf0f30c 100644 --- a/src/transform/vertex_pulling.h +++ b/src/transform/vertex_pulling.h @@ -191,10 +191,10 @@ class VertexPulling : public Transform { /// @param index index to append to buffer name std::string GetVertexBufferName(uint32_t index) const; - /// Inserts vertex_idx binding, or finds the existing one + /// Inserts vertex_index binding, or finds the existing one void FindOrInsertVertexIndexIfUsed(); - /// Inserts instance_idx binding, or finds the existing one + /// Inserts instance_index binding, or finds the existing one void FindOrInsertInstanceIndexIfUsed(); /// Converts var with a location decoration to var diff --git a/src/transform/vertex_pulling_test.cc b/src/transform/vertex_pulling_test.cc index 88594ccc33..4317785958 100644 --- a/src/transform/vertex_pulling_test.cc +++ b/src/transform/vertex_pulling_test.cc @@ -133,7 +133,7 @@ struct TintVertexData { _tint_vertex_data : [[stride(4)]] array; }; -[[builtin(vertex_idx)]] var _tint_pulling_vertex_index : i32; +[[builtin(vertex_index)]] var _tint_pulling_vertex_index : i32; [[binding(0), group(4)]] var _tint_pulling_vertex_buffer_0 : TintVertexData; var var_a : f32; @@ -172,7 +172,7 @@ struct TintVertexData { _tint_vertex_data : [[stride(4)]] array; }; -[[builtin(instance_idx)]] var _tint_pulling_instance_index : i32; +[[builtin(instance_index)]] var _tint_pulling_instance_index : i32; [[binding(0), group(4)]] var _tint_pulling_vertex_buffer_0 : TintVertexData; var var_a : f32; @@ -211,7 +211,7 @@ struct TintVertexData { _tint_vertex_data : [[stride(4)]] array; }; -[[builtin(vertex_idx)]] var _tint_pulling_vertex_index : i32; +[[builtin(vertex_index)]] var _tint_pulling_vertex_index : i32; [[binding(0), group(5)]] var _tint_pulling_vertex_buffer_0 : TintVertexData; var var_a : f32; @@ -241,8 +241,8 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { auto* src = R"( [[location(0)]] var var_a : f32; [[location(1)]] var var_b : f32; -[[builtin(vertex_idx)]] var custom_vertex_index : i32; -[[builtin(instance_idx)]] var custom_instance_index : i32; +[[builtin(vertex_index)]] var custom_vertex_index : i32; +[[builtin(instance_index)]] var custom_instance_index : i32; [[stage(vertex)]] fn main() -> void {} @@ -259,8 +259,8 @@ struct TintVertexData { [[binding(1), group(4)]] var _tint_pulling_vertex_buffer_1 : TintVertexData; var var_a : f32; var var_b : f32; -[[builtin(vertex_idx)]] var custom_vertex_index : i32; -[[builtin(instance_idx)]] var custom_instance_index : i32; +[[builtin(vertex_index)]] var custom_vertex_index : i32; +[[builtin(instance_index)]] var custom_instance_index : i32; [[stage(vertex)]] fn main() -> void { @@ -301,7 +301,7 @@ struct TintVertexData { _tint_vertex_data : [[stride(4)]] array; }; -[[builtin(vertex_idx)]] var _tint_pulling_vertex_index : i32; +[[builtin(vertex_index)]] var _tint_pulling_vertex_index : i32; [[binding(0), group(4)]] var _tint_pulling_vertex_buffer_0 : TintVertexData; var var_a : f32; var var_b : array; @@ -347,7 +347,7 @@ struct TintVertexData { _tint_vertex_data : [[stride(4)]] array; }; -[[builtin(vertex_idx)]] var _tint_pulling_vertex_index : i32; +[[builtin(vertex_index)]] var _tint_pulling_vertex_index : i32; [[binding(0), group(4)]] var _tint_pulling_vertex_buffer_0 : TintVertexData; [[binding(1), group(4)]] var _tint_pulling_vertex_buffer_1 : TintVertexData; [[binding(2), group(4)]] var _tint_pulling_vertex_buffer_2 : TintVertexData; diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 06791db227..20fc255809 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1609,9 +1609,9 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { switch (builtin) { case ast::Builtin::kPosition: return "SV_Position"; - case ast::Builtin::kVertexIdx: + case ast::Builtin::kVertexIndex: return "SV_VertexID"; - case ast::Builtin::kInstanceIdx: + case ast::Builtin::kInstanceIndex: return "SV_InstanceID"; case ast::Builtin::kFrontFacing: return "SV_IsFrontFacing"; @@ -1621,7 +1621,7 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "SV_Depth"; case ast::Builtin::kLocalInvocationId: return "SV_GroupThreadID"; - case ast::Builtin::kLocalInvocationIdx: + case ast::Builtin::kLocalInvocationIndex: return "SV_GroupIndex"; case ast::Builtin::kGlobalInvocationId: return "SV_DispatchThreadID"; diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index 2a4f8eda61..44be70a62b 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -77,13 +77,13 @@ INSTANTIATE_TEST_SUITE_P( HlslBuiltinConversionTest, testing::Values( HlslBuiltinData{ast::Builtin::kPosition, "SV_Position"}, - HlslBuiltinData{ast::Builtin::kVertexIdx, "SV_VertexID"}, - HlslBuiltinData{ast::Builtin::kInstanceIdx, "SV_InstanceID"}, + HlslBuiltinData{ast::Builtin::kVertexIndex, "SV_VertexID"}, + HlslBuiltinData{ast::Builtin::kInstanceIndex, "SV_InstanceID"}, HlslBuiltinData{ast::Builtin::kFrontFacing, "SV_IsFrontFacing"}, HlslBuiltinData{ast::Builtin::kFragCoord, "SV_Position"}, HlslBuiltinData{ast::Builtin::kFragDepth, "SV_Depth"}, HlslBuiltinData{ast::Builtin::kLocalInvocationId, "SV_GroupThreadID"}, - HlslBuiltinData{ast::Builtin::kLocalInvocationIdx, "SV_GroupIndex"}, + HlslBuiltinData{ast::Builtin::kLocalInvocationIndex, "SV_GroupIndex"}, HlslBuiltinData{ast::Builtin::kGlobalInvocationId, "SV_DispatchThreadID"})); diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index aa91eefb57..1de2fb9db9 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1396,9 +1396,9 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { switch (builtin) { case ast::Builtin::kPosition: return "position"; - case ast::Builtin::kVertexIdx: + case ast::Builtin::kVertexIndex: return "vertex_id"; - case ast::Builtin::kInstanceIdx: + case ast::Builtin::kInstanceIndex: return "instance_id"; case ast::Builtin::kFrontFacing: return "front_facing"; @@ -1408,7 +1408,7 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "depth(any)"; case ast::Builtin::kLocalInvocationId: return "thread_position_in_threadgroup"; - case ast::Builtin::kLocalInvocationIdx: + case ast::Builtin::kLocalInvocationIndex: return "thread_index_in_threadgroup"; case ast::Builtin::kGlobalInvocationId: return "thread_position_in_grid"; diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 978eba831e..c73e148df7 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -99,14 +99,14 @@ INSTANTIATE_TEST_SUITE_P( MslGeneratorImplTest, MslBuiltinConversionTest, testing::Values(MslBuiltinData{ast::Builtin::kPosition, "position"}, - MslBuiltinData{ast::Builtin::kVertexIdx, "vertex_id"}, - MslBuiltinData{ast::Builtin::kInstanceIdx, "instance_id"}, + MslBuiltinData{ast::Builtin::kVertexIndex, "vertex_id"}, + MslBuiltinData{ast::Builtin::kInstanceIndex, "instance_id"}, MslBuiltinData{ast::Builtin::kFrontFacing, "front_facing"}, MslBuiltinData{ast::Builtin::kFragCoord, "position"}, MslBuiltinData{ast::Builtin::kFragDepth, "depth(any)"}, MslBuiltinData{ast::Builtin::kLocalInvocationId, "thread_position_in_threadgroup"}, - MslBuiltinData{ast::Builtin::kLocalInvocationIdx, + MslBuiltinData{ast::Builtin::kLocalInvocationIndex, "thread_index_in_threadgroup"}, MslBuiltinData{ast::Builtin::kGlobalInvocationId, "thread_position_in_grid"})); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index a37daf1136..cf8e5ac169 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -3132,9 +3132,9 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin) const { switch (builtin) { case ast::Builtin::kPosition: return SpvBuiltInPosition; - case ast::Builtin::kVertexIdx: + case ast::Builtin::kVertexIndex: return SpvBuiltInVertexIndex; - case ast::Builtin::kInstanceIdx: + case ast::Builtin::kInstanceIndex: return SpvBuiltInInstanceIndex; case ast::Builtin::kFrontFacing: return SpvBuiltInFrontFacing; @@ -3144,7 +3144,7 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin) const { return SpvBuiltInFragDepth; case ast::Builtin::kLocalInvocationId: return SpvBuiltInLocalInvocationId; - case ast::Builtin::kLocalInvocationIdx: + case ast::Builtin::kLocalInvocationIndex: return SpvBuiltInLocalInvocationIndex; case ast::Builtin::kGlobalInvocationId: return SpvBuiltInGlobalInvocationId; diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index d05beb2809..55b49ec5a5 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -360,16 +360,16 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{ast::Builtin::kNone, SpvBuiltInMax}, BuiltinData{ast::Builtin::kPosition, SpvBuiltInPosition}, BuiltinData{ - ast::Builtin::kVertexIdx, + ast::Builtin::kVertexIndex, SpvBuiltInVertexIndex, }, - BuiltinData{ast::Builtin::kInstanceIdx, SpvBuiltInInstanceIndex}, + BuiltinData{ast::Builtin::kInstanceIndex, SpvBuiltInInstanceIndex}, BuiltinData{ast::Builtin::kFrontFacing, SpvBuiltInFrontFacing}, BuiltinData{ast::Builtin::kFragCoord, SpvBuiltInFragCoord}, BuiltinData{ast::Builtin::kFragDepth, SpvBuiltInFragDepth}, BuiltinData{ast::Builtin::kLocalInvocationId, SpvBuiltInLocalInvocationId}, - BuiltinData{ast::Builtin::kLocalInvocationIdx, + BuiltinData{ast::Builtin::kLocalInvocationIndex, SpvBuiltInLocalInvocationIndex}, BuiltinData{ast::Builtin::kGlobalInvocationId, SpvBuiltInGlobalInvocationId})); diff --git a/test/triangle.wgsl b/test/triangle.wgsl index 6a29c19c7e..bea1c95ff0 100644 --- a/test/triangle.wgsl +++ b/test/triangle.wgsl @@ -19,7 +19,7 @@ const pos : array, 3> = array, 3>( vec2(0.5, -0.5)); [[builtin(position)]] var Position : vec4; -[[builtin(vertex_idx)]] var VertexIndex : i32; +[[builtin(vertex_index)]] var VertexIndex : i32; [[stage(vertex)]] fn vtx_main() -> void {