diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 06f033f1..dd780622 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -333,8 +333,8 @@ void EmitContext::DefineOutputs() { void EmitContext::DefinePushDataBlock() { // Create push constants block for instance steps rates - const Id struct_type{ - Name(TypeStruct(U32[1], U32[1], U32[4], U32[4], U32[4], U32[4]), "AuxData")}; + const Id struct_type{Name( + TypeStruct(U32[1], U32[1], U32[4], U32[4], U32[4], U32[4], U32[4], U32[4]), "AuxData")}; Decorate(struct_type, spv::Decoration::Block); MemberName(struct_type, 0, "sr0"); MemberName(struct_type, 1, "sr1"); @@ -342,12 +342,16 @@ void EmitContext::DefinePushDataBlock() { MemberName(struct_type, 3, "buf_offsets1"); MemberName(struct_type, 4, "ud_regs0"); MemberName(struct_type, 5, "ud_regs1"); + MemberName(struct_type, 6, "ud_regs2"); + MemberName(struct_type, 7, "ud_regs3"); MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U); MemberDecorate(struct_type, 1, spv::Decoration::Offset, 4U); MemberDecorate(struct_type, 2, spv::Decoration::Offset, 8U); MemberDecorate(struct_type, 3, spv::Decoration::Offset, 24U); MemberDecorate(struct_type, 4, spv::Decoration::Offset, 40U); MemberDecorate(struct_type, 5, spv::Decoration::Offset, 56U); + MemberDecorate(struct_type, 6, spv::Decoration::Offset, 72U); + MemberDecorate(struct_type, 7, spv::Decoration::Offset, 88U); push_data_block = DefineVar(struct_type, spv::StorageClass::PushConstant); Name(push_data_block, "push_data"); interfaces.push_back(push_data_block); diff --git a/src/shader_recompiler/info.h b/src/shader_recompiler/info.h index 2a9615fc..739214ec 100644 --- a/src/shader_recompiler/info.h +++ b/src/shader_recompiler/info.h @@ -88,18 +88,19 @@ using SamplerResourceList = boost::container::small_vector; struct PushData { static constexpr u32 BufOffsetIndex = 2; static constexpr u32 UdRegsIndex = 4; - static constexpr u32 MaxUdRegs = 8; u32 step0; u32 step1; std::array buf_offsets; - std::array ud_regs; + std::array ud_regs; void AddOffset(u32 binding, u32 offset) { ASSERT(offset < 256 && binding < buf_offsets.size()); buf_offsets[binding] = offset; } }; +static_assert(sizeof(PushData) <= 128, + "PushData size is greater than minimum size guaranteed by Vulkan spec"); /** * Contains general information generated by the shader recompiler for an input program. @@ -216,6 +217,7 @@ struct Info { u32 mask = ud_mask.mask; while (mask) { const u32 index = std::countr_zero(mask); + ASSERT(bnd.user_data < NumUserDataRegs && index < NumUserDataRegs); mask &= ~(1U << index); push.ud_regs[bnd.user_data++] = user_data[index]; }