diff options
| author | 2021-05-29 18:47:17 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | 005eecffcdcac64419d8441b3a724421b9b9816c (patch) | |
| tree | f5879a77d9889b2aecc8a13ff15087d34e10a86d /src | |
| parent | glsl: Implement TXQ and other misc changes (diff) | |
| download | yuzu-005eecffcdcac64419d8441b3a724421b9b9816c.tar.gz yuzu-005eecffcdcac64419d8441b3a724421b9b9816c.tar.xz yuzu-005eecffcdcac64419d8441b3a724421b9b9816c.zip | |
glsl: Fix and implement rest of cbuf access
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index ab7628a5a..03caaacec 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -24,25 +24,61 @@ char OffsetSwizzle(u32 offset) { | |||
| 24 | void EmitGetCbufU8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 24 | void EmitGetCbufU8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 25 | [[maybe_unused]] const IR::Value& binding, | 25 | [[maybe_unused]] const IR::Value& binding, |
| 26 | [[maybe_unused]] const IR::Value& offset) { | 26 | [[maybe_unused]] const IR::Value& offset) { |
| 27 | throw NotImplementedException("GLSL"); | 27 | if (offset.IsImmediate()) { |
| 28 | ctx.AddU32("{}=bitfieldExtract(floatBitsToUint({}_cbuf{}[{}].{}),int({}),8);", inst, | ||
| 29 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), | ||
| 30 | (offset.U32() % 4) * 8); | ||
| 31 | } else { | ||
| 32 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; | ||
| 33 | ctx.AddU32( | ||
| 34 | "{}=bitfieldExtract(floatBitsToUint({}_cbuf{}[{}/16][({}/4)%4]),int(({}%4)*8),8);", | ||
| 35 | inst, ctx.stage_name, binding.U32(), offset_var, offset_var, offset_var); | ||
| 36 | } | ||
| 28 | } | 37 | } |
| 29 | 38 | ||
| 30 | void EmitGetCbufS8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 39 | void EmitGetCbufS8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 31 | [[maybe_unused]] const IR::Value& binding, | 40 | [[maybe_unused]] const IR::Value& binding, |
| 32 | [[maybe_unused]] const IR::Value& offset) { | 41 | [[maybe_unused]] const IR::Value& offset) { |
| 33 | throw NotImplementedException("GLSL"); | 42 | if (offset.IsImmediate()) { |
| 43 | ctx.AddU32("{}=bitfieldExtract(floatBitsToInt({}_cbuf{}[{}].{}),int({}),8);", inst, | ||
| 44 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), | ||
| 45 | (offset.U32() % 4) * 8); | ||
| 46 | } else { | ||
| 47 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; | ||
| 48 | ctx.AddU32( | ||
| 49 | "{}=bitfieldExtract(floatBitsToInt({}_cbuf{}[{}/16][({}/4)%4]),int(({}%4)*8),8);", inst, | ||
| 50 | ctx.stage_name, binding.U32(), offset_var, offset_var, offset_var); | ||
| 51 | } | ||
| 34 | } | 52 | } |
| 35 | 53 | ||
| 36 | void EmitGetCbufU16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 54 | void EmitGetCbufU16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 37 | [[maybe_unused]] const IR::Value& binding, | 55 | [[maybe_unused]] const IR::Value& binding, |
| 38 | [[maybe_unused]] const IR::Value& offset) { | 56 | [[maybe_unused]] const IR::Value& offset) { |
| 39 | throw NotImplementedException("GLSL"); | 57 | if (offset.IsImmediate()) { |
| 58 | ctx.AddU32("{}=bitfieldExtract(floatBitsToUint({}_cbuf{}[{}].{}),int({}),16);", inst, | ||
| 59 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), | ||
| 60 | ((offset.U32() / 2) % 2) * 16); | ||
| 61 | } else { | ||
| 62 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; | ||
| 63 | ctx.AddU32("{}=bitfieldExtract(floatBitsToUint({}_cbuf{}[{}/16][({}/4)%4]),int((({}/" | ||
| 64 | "2)%2)*16),16);", | ||
| 65 | inst, ctx.stage_name, binding.U32(), offset_var, offset_var, offset_var); | ||
| 66 | } | ||
| 40 | } | 67 | } |
| 41 | 68 | ||
| 42 | void EmitGetCbufS16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 69 | void EmitGetCbufS16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 43 | [[maybe_unused]] const IR::Value& binding, | 70 | [[maybe_unused]] const IR::Value& binding, |
| 44 | [[maybe_unused]] const IR::Value& offset) { | 71 | [[maybe_unused]] const IR::Value& offset) { |
| 45 | throw NotImplementedException("GLSL"); | 72 | if (offset.IsImmediate()) { |
| 73 | ctx.AddU32("{}=bitfieldExtract(floatBitsToInt({}_cbuf{}[{}].{}),int({}),16);", inst, | ||
| 74 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), | ||
| 75 | ((offset.U32() / 2) % 2) * 16); | ||
| 76 | } else { | ||
| 77 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; | ||
| 78 | ctx.AddU32( | ||
| 79 | "{}=bitfieldExtract(floatBitsToInt({}_cbuf{}[{}/16][({}/4)%4]),int((({}/2)%2)*16),16);", | ||
| 80 | inst, ctx.stage_name, binding.U32(), offset_var, offset_var, offset_var); | ||
| 81 | } | ||
| 46 | } | 82 | } |
| 47 | 83 | ||
| 48 | void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 84 | void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| @@ -75,12 +111,12 @@ void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding | |||
| 75 | ctx.AddU32x2( | 111 | ctx.AddU32x2( |
| 76 | "{}=uvec2(floatBitsToUint({}_cbuf{}[{}].{}),floatBitsToUint({}_cbuf{}[{}].{}));", inst, | 112 | "{}=uvec2(floatBitsToUint({}_cbuf{}[{}].{}),floatBitsToUint({}_cbuf{}[{}].{}));", inst, |
| 77 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), | 113 | ctx.stage_name, binding.U32(), offset.U32() / 16, OffsetSwizzle(offset.U32()), |
| 78 | ctx.stage_name, binding.U32(), (offset.U32() + 1) / 16, | 114 | ctx.stage_name, binding.U32(), (offset.U32() + 4) / 16, |
| 79 | OffsetSwizzle(offset.U32() + 1)); | 115 | OffsetSwizzle(offset.U32() + 4)); |
| 80 | } else { | 116 | } else { |
| 81 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; | 117 | const auto offset_var{ctx.reg_alloc.Consume(offset)}; |
| 82 | ctx.AddU32x2("{}=uvec2(floatBitsToUint({}_cbuf{}[{}/16][({}/" | 118 | ctx.AddU32x2("{}=uvec2(floatBitsToUint({}_cbuf{}[{}/16][({}/" |
| 83 | "4)%4]),floatBitsToUint({}_cbuf{}[({}+1)/16][(({}+1/4))%4]));", | 119 | "4)%4]),floatBitsToUint({}_cbuf{}[({}+4)/16][(({}+4)/4)%4]));", |
| 84 | inst, ctx.stage_name, binding.U32(), offset_var, offset_var, ctx.stage_name, | 120 | inst, ctx.stage_name, binding.U32(), offset_var, offset_var, ctx.stage_name, |
| 85 | binding.U32(), offset_var, offset_var); | 121 | binding.U32(), offset_var, offset_var); |
| 86 | } | 122 | } |