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 <dsinclair@chromium.org> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
4a110c2726
commit
d7335fa974
|
@ -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 |
|
||||
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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}));
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)");
|
||||
|
|
|
@ -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::BuiltinDecoration>()) {
|
||||
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));
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -28,7 +28,7 @@ using FirstIndexOffsetTest = TransformTest;
|
|||
|
||||
TEST_F(FirstIndexOffsetTest, Error_AlreadyTransformed) {
|
||||
auto* src = R"(
|
||||
[[builtin(vertex_idx)]] var<in> vert_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> 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<in> vert_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> vert_idx : u32;
|
||||
|
||||
fn test() -> u32 {
|
||||
return vert_idx;
|
||||
|
@ -82,7 +82,7 @@ struct TintFirstIndexOffsetData {
|
|||
tint_first_vertex_index : u32;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), group(2)]] var<uniform> 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<in> inst_idx : u32;
|
||||
[[builtin(instance_index)]] var<in> inst_idx : u32;
|
||||
|
||||
fn test() -> u32 {
|
||||
return inst_idx;
|
||||
|
@ -122,7 +122,7 @@ struct TintFirstIndexOffsetData {
|
|||
tint_first_instance_index : u32;
|
||||
};
|
||||
|
||||
[[builtin(instance_idx)]] var<in> tint_first_index_offset_inst_idx : u32;
|
||||
[[builtin(instance_index)]] var<in> tint_first_index_offset_inst_idx : u32;
|
||||
[[binding(1), group(7)]] var<uniform> 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<in> instance_idx : u32;
|
||||
[[builtin(vertex_idx)]] var<in> vert_idx : u32;
|
||||
[[builtin(instance_index)]] var<in> instance_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> 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<in> tint_first_index_offset_instance_idx : u32;
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[builtin(instance_index)]] var<in> tint_first_index_offset_instance_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), group(2)]] var<uniform> 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<in> vert_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> vert_idx : u32;
|
||||
|
||||
fn func1() -> u32 {
|
||||
return vert_idx;
|
||||
|
@ -211,7 +211,7 @@ struct TintFirstIndexOffsetData {
|
|||
tint_first_vertex_index : u32;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[builtin(vertex_index)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), group(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
|
||||
fn func1() -> u32 {
|
||||
|
|
|
@ -158,7 +158,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() {
|
|||
|
||||
for (auto* d : v->decorations()) {
|
||||
if (auto* builtin = d->As<ast::BuiltinDecoration>()) {
|
||||
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<ast::BuiltinDecoration>(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<ast::BuiltinDecoration>()) {
|
||||
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<ast::BuiltinDecoration>(Source{},
|
||||
ast::Builtin::kInstanceIdx),
|
||||
ast::Builtin::kInstanceIndex),
|
||||
});
|
||||
out->AddGlobalVariable(var);
|
||||
}
|
||||
|
|
|
@ -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<in> with a location decoration to var<private>
|
||||
|
|
|
@ -133,7 +133,7 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
|
@ -172,7 +172,7 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[builtin(instance_idx)]] var<in> _tint_pulling_instance_index : i32;
|
||||
[[builtin(instance_index)]] var<in> _tint_pulling_instance_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
|
@ -211,7 +211,7 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(5)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
|
@ -241,8 +241,8 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
|
|||
auto* src = R"(
|
||||
[[location(0)]] var<in> var_a : f32;
|
||||
[[location(1)]] var<in> var_b : f32;
|
||||
[[builtin(vertex_idx)]] var<in> custom_vertex_index : i32;
|
||||
[[builtin(instance_idx)]] var<in> custom_instance_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> custom_vertex_index : i32;
|
||||
[[builtin(instance_index)]] var<in> custom_instance_index : i32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() -> void {}
|
||||
|
@ -259,8 +259,8 @@ struct TintVertexData {
|
|||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : f32;
|
||||
[[builtin(vertex_idx)]] var<in> custom_vertex_index : i32;
|
||||
[[builtin(instance_idx)]] var<in> custom_instance_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> custom_vertex_index : i32;
|
||||
[[builtin(instance_index)]] var<in> custom_instance_index : i32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() -> void {
|
||||
|
@ -301,7 +301,7 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : array<f32, 4>;
|
||||
|
@ -347,7 +347,7 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(2), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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"}));
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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"}));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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}));
|
||||
|
|
|
@ -19,7 +19,7 @@ const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|||
vec2<f32>(0.5, -0.5));
|
||||
|
||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||
[[builtin(vertex_idx)]] var<in> VertexIndex : i32;
|
||||
[[builtin(vertex_index)]] var<in> VertexIndex : i32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vtx_main() -> void {
|
||||
|
|
Loading…
Reference in New Issue