diff options
Diffstat (limited to '')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index b5c08d611..7e8f37563 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |||
| @@ -13,9 +13,6 @@ namespace Shader::Backend::GLASM { | |||
| 13 | namespace { | 13 | namespace { |
| 14 | void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset, | 14 | void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset, |
| 15 | std::string_view size) { | 15 | std::string_view size) { |
| 16 | if (!binding.IsImmediate()) { | ||
| 17 | throw NotImplementedException("Indirect constant buffer loading"); | ||
| 18 | } | ||
| 19 | const Register ret{ctx.reg_alloc.Define(inst)}; | 16 | const Register ret{ctx.reg_alloc.Define(inst)}; |
| 20 | if (offset.type == Type::U32) { | 17 | if (offset.type == Type::U32) { |
| 21 | // Avoid reading arrays out of bounds, matching hardware's behavior | 18 | // Avoid reading arrays out of bounds, matching hardware's behavior |
| @@ -24,7 +21,27 @@ void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU | |||
| 24 | return; | 21 | return; |
| 25 | } | 22 | } |
| 26 | } | 23 | } |
| 27 | ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset); | 24 | |
| 25 | if (binding.IsImmediate()) { | ||
| 26 | ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset); | ||
| 27 | return; | ||
| 28 | } | ||
| 29 | |||
| 30 | const ScalarU32 idx{ctx.reg_alloc.Consume(binding)}; | ||
| 31 | for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) { | ||
| 32 | ctx.Add("SEQ.S.CC RC.x,{},{};" | ||
| 33 | "IF NE.x;" | ||
| 34 | "LDC.{} {},c{}[{}];", | ||
| 35 | idx, i, size, ret, i, offset); | ||
| 36 | |||
| 37 | if (i != Info::MAX_INDIRECT_CBUFS - 1) { | ||
| 38 | ctx.Add("ELSE;"); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) { | ||
| 43 | ctx.Add("ENDIF;"); | ||
| 44 | } | ||
| 28 | } | 45 | } |
| 29 | 46 | ||
| 30 | bool IsInputArray(Stage stage) { | 47 | bool IsInputArray(Stage stage) { |