summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp16
1 files changed, 16 insertions, 0 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 5861c4d4c..8223ad862 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
@@ -38,6 +38,15 @@ void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const I
38 u32 num_bits, std::string_view cast = {}, bool component_indexing_bug = false, 38 u32 num_bits, std::string_view cast = {}, bool component_indexing_bug = false,
39 std::string_view bit_offset = {}) { 39 std::string_view bit_offset = {}) {
40 const bool is_immediate{offset.IsImmediate()}; 40 const bool is_immediate{offset.IsImmediate()};
41 if (is_immediate) {
42 const s32 signed_offset{static_cast<s32>(offset.U32())};
43 static constexpr u32 cbuf_size{4096 * 16};
44 if (signed_offset < 0 || offset.U32() > cbuf_size) {
45 // LOG_WARNING(..., "Immediate constant buffer offset is out of bounds");
46 ctx.AddU32("{}=0u;", inst);
47 return;
48 }
49 }
41 const auto offset_var{ctx.var_alloc.Consume(offset)}; 50 const auto offset_var{ctx.var_alloc.Consume(offset)};
42 const auto index{is_immediate ? fmt::format("{}", offset.U32() / 16) 51 const auto index{is_immediate ? fmt::format("{}", offset.U32() / 16)
43 : fmt::format("{}>>4", offset_var)}; 52 : fmt::format("{}>>4", offset_var)};
@@ -124,7 +133,14 @@ void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding
124 const IR::Value& offset) { 133 const IR::Value& offset) {
125 const auto cbuf{fmt::format("{}_cbuf{}", ctx.stage_name, binding.U32())}; 134 const auto cbuf{fmt::format("{}_cbuf{}", ctx.stage_name, binding.U32())};
126 if (offset.IsImmediate()) { 135 if (offset.IsImmediate()) {
136 static constexpr u32 cbuf_size{4096 * 16};
127 const u32 u32_offset{offset.U32()}; 137 const u32 u32_offset{offset.U32()};
138 const s32 signed_offset{static_cast<s32>(offset.U32())};
139 if (signed_offset < 0 || u32_offset > cbuf_size) {
140 // LOG_WARNING(..., "Immediate constant buffer offset is out of bounds");
141 ctx.AddU32x2("{}=uvec2(0u);", inst);
142 return;
143 }
128 if (u32_offset % 2 == 0) { 144 if (u32_offset % 2 == 0) {
129 ctx.AddU32x2("{}=ftou({}[{}].{}{});", inst, cbuf, u32_offset / 16, 145 ctx.AddU32x2("{}=ftou({}[{}].{}{});", inst, cbuf, u32_offset / 16,
130 OffsetSwizzle(u32_offset), OffsetSwizzle(u32_offset + 4)); 146 OffsetSwizzle(u32_offset), OffsetSwizzle(u32_offset + 4));