diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index a506fe3..3d406de 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); @@ -1423,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 @@ -1471,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{}; @@ -1486,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/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 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