graphics: fix vertex and instance IDs for unpatched indirect draws

This commit is contained in:
nmzik
2026-10-28 04:33:03 +01:00
parent 1be1c6c4f9
commit a833e1b735
10 changed files with 72 additions and 46 deletions
@@ -814,7 +814,7 @@ TranslateResult TranslateProgram(const Decoder::Program& decoded, const CompileO
const auto& cfg = *selected_cfg;
Frontend::EmbeddedFetchPlan embedded_fetch;
if ((options.stage == ShaderType::Vertex || options.stage == ShaderType::Local) &&
options.input_info.vertex->fetch_embedded) {
options.input_info.vertex->has_dynamic_vertex_fetch) {
embedded_fetch = DetectEmbeddedVertexFetch(
decoded, *options.input_info.vertex, options.user_data_base,
static_cast<uint32_t>(options.user_data.size()), options.wave_size);
@@ -1390,11 +1390,12 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph&
entry_ir.SetScalarReg(static_cast<IR::ScalarReg>(3),
entry_ir.BitwiseOr(vertex_count, IR::U32(IR::Value(1u << 28u))));
// Vulkan adds an indirect record's bases to the indices; the hardware passes them
// only in the user SGPRs the packet patches.
// only in the user SGPRs the packet patches. SH_NOP leaves those SGPRs unchanged;
// it does not make the record's bases zero.
const auto& offsets = options.input_info.vertex->indirect_offsets;
const auto index = [&](uint8_t slot, IR::StageInputKind kind,
IR::StageInputKind base_kind) {
if (offsets == ShaderIndirectOffsets {}) {
if (!options.input_info.vertex->indirect_draw) {
return builtin(kind);
}
const auto base = builtin(base_kind);