From 9cda3680c98f4d8e3a38dc781559ca749bb5f06b Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Tue, 15 Jul 2025 03:13:06 +0300 Subject: [PATCH 1/2] Add OpGroupNonUniformBallotFindLSB --- include/sirit/sirit.h | 5 +++++ src/instructions/group.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index a506fe3..2d1f408 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -1270,6 +1270,11 @@ public: /// TBD Id OpSubgroupAllEqualKHR(Id result_type, Id predicate); + // Find the least significant bit set to 1 in Value, considering only the bits in Value required + // to represent all bits of the scope restricted tangle. If none of the considered bits is set to 1, + // the resulting value is undefined. + Id OpGroupNonUniformBallotFindLSB(Id result_type, Id scope, Id value); + // Result is the Value of the invocation identified by the id Id to all active invocations in // the group. Id OpGroupNonUniformBroadcast(Id result_type, Id scope, Id value, Id id); diff --git a/src/instructions/group.cpp b/src/instructions/group.cpp index e7b954d..3d044cf 100644 --- a/src/instructions/group.cpp +++ b/src/instructions/group.cpp @@ -79,4 +79,9 @@ Id Module::OpGroupNonUniformQuadBroadcast(Id result_type, Id scope, Id value, Id return *code << OpId{spv::Op::OpGroupNonUniformQuadBroadcast, result_type} << scope << value << index << EndOp{}; } +Id Module::OpGroupNonUniformBallotFindLSB(Id result_type, Id scope, Id value) { + code->Reserve(5); + return *code << OpId{spv::Op::OpGroupNonUniformBallotFindLSB, result_type} << scope << value << EndOp{}; +} + } // namespace Sirit From 51fcf9720f53395dd4c1f0751737d72362402210 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Tue, 15 Jul 2025 03:13:31 +0300 Subject: [PATCH 2/2] Add SPV_AMD_shader_explicit_vertex_parameter --- include/sirit/sirit.h | 9 +++++++-- src/instructions/extension.cpp | 4 ++++ src/sirit.cpp | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 2d1f408..3d406de 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -1428,8 +1428,8 @@ public: /// 3) store the New Value back through Pointer. Id OpAtomicXor(Id result_type, Id pointer, Id memory, Id semantics, Id value); - // Print a message for vulkan layers to use, e.g. renderdoc - // Usage is like C printf + /// Print a message for vulkan layers to use, e.g. renderdoc + /// Usage is like C printf Id OpDebugPrintf(Id fmt, std::span fmt_args); /// Returns a two-component floating point vector that represents the 2D texture coordinates @@ -1476,11 +1476,15 @@ public: /// Result is the middle of x, y, and z, interpreted as signed integers. Id OpSMid3AMD(Id result_type, Id x, Id y, Id z); + /// Returns the value of the input without any interpolation, i.e. the raw output value of previous shader stage. + Id OpInterpolateAtVertexAMD(Id result_type, Id interpolant, Id vertex_index); + private: Id GetGLSLstd450(); Id GetNonSemanticDebugPrintf(); Id GetAmdGcnShader(); Id GetAmdShaderTrinaryMinMax(); + Id GetAmdExplicitVertexParameter(); std::uint32_t version{}; std::uint32_t bound{}; @@ -1491,6 +1495,7 @@ private: std::optional non_semantic_debug_printf; std::optional amd_gcn_shader; std::optional amd_shader_trinary_minmax; + std::optional amd_explicit_vertex_parameter; spv::AddressingModel addressing_model{spv::AddressingModel::Logical}; spv::MemoryModel memory_model{spv::MemoryModel::GLSL450}; diff --git a/src/instructions/extension.cpp b/src/instructions/extension.cpp index a79aa18..ea26615 100644 --- a/src/instructions/extension.cpp +++ b/src/instructions/extension.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -110,6 +111,8 @@ DEFINE_UNARY(GetAmdGcnShader(), OpCubeFaceCoordAMD, AMD_gcn_shaderCubeFaceCoordA DEFINE_UNARY(GetAmdGcnShader(), OpCubeFaceIndexAMD, AMD_gcn_shaderCubeFaceIndexAMD) DEFINE_NULLARY(GetAmdGcnShader(), OpTimeAMD, AMD_gcn_shaderTimeAMD) +DEFINE_BINARY(GetAmdExplicitVertexParameter(), OpInterpolateAtVertexAMD, AMD_shader_explicit_vertex_parameterInterpolateAtVertexAMD) + DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpFMin3AMD, AMD_shader_trinary_minmaxFMin3AMD) DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpUMin3AMD, AMD_shader_trinary_minmaxUMin3AMD) DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpSMin3AMD, AMD_shader_trinary_minmaxSMin3AMD) @@ -120,4 +123,5 @@ DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpFMid3AMD, AMD_shader_trinary_minma DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpUMid3AMD, AMD_shader_trinary_minmaxUMid3AMD) DEFINE_TRINARY(GetAmdShaderTrinaryMinMax(), OpSMid3AMD, AMD_shader_trinary_minmaxSMid3AMD) + } // namespace Sirit diff --git a/src/sirit.cpp b/src/sirit.cpp index 6bbde44..59bd508 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -175,4 +175,15 @@ Id Module::GetAmdShaderTrinaryMinMax() { return *amd_shader_trinary_minmax; } + +Id Module::GetAmdExplicitVertexParameter() { + const char* extname = "SPV_AMD_shader_explicit_vertex_parameter"; + size_t len = WordsInString(extname); + if (!amd_explicit_vertex_parameter) { + ext_inst_imports->Reserve(3 + len); + amd_explicit_vertex_parameter = *ext_inst_imports << OpId{spv::Op::OpExtInstImport} << extname << EndOp{}; + } + return *amd_explicit_vertex_parameter; +} + } // namespace Sirit