From cb3f2308afd011b81d9cc1d86e68ce6e94a2ae54 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 19 Jan 2014 10:29:18 -0800 Subject: [PATCH] Fixing shaders that fetch constants. --- src/xenia/gpu/shader.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/xenia/gpu/shader.cc b/src/xenia/gpu/shader.cc index 8522b9eb0..b98c12443 100644 --- a/src/xenia/gpu/shader.cc +++ b/src/xenia/gpu/shader.cc @@ -146,6 +146,29 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) { // num_format_all ? integer : fraction // exp_adjust_all - [-32,31] - (2^exp_adjust_all)*fetch - 0 = default + // Sometimes games have fetches that just produce constants. We can + // ignore those. + uint32_t dst_swiz = vtx->dst_swiz; + bool fetches_any_data = false; + for (int i = 0; i < 4; i++) { + if ((dst_swiz & 0x7) == 4) { + // 0.0 + } else if ((dst_swiz & 0x7) == 5) { + // 1.0 + } else if ((dst_swiz & 0x7) == 6) { + // ? + } else if ((dst_swiz & 0x7) == 7) { + // Previous register value. + } else { + fetches_any_data = true; + break; + } + dst_swiz >>= 3; + } + if (!fetches_any_data) { + return; + } + uint32_t fetch_slot = vtx->const_index * 3 + vtx->const_index_sel; auto& inputs = vtx_buffer_inputs_; vtx_buffer_element_t* el = NULL;