summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-04-01 23:08:40 +0200
committerLiam <byteslice@airmail.cc>2022-04-01 23:08:40 +0200
commit7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f (patch)
treea443cd005e62a7563fd9c8c7c9a199668774a769 /src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
parentshader_recompiler: support const buffer indirect addressing on OpenGL SPIR-V (diff)
downloadyuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar.gz
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar.bz2
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar.lz
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar.xz
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.tar.zst
yuzu-7d5a38ea6cb692cdeb5565b36b283d1a34d5d27f.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glsl/glsl_emit_context.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
index e816a93ec..17266f40d 100644
--- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
@@ -359,6 +359,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
header += "layout(location=0) uniform vec4 scaling;";
}
DefineConstantBuffers(bindings);
+ DefineConstantBufferIndirect();
DefineStorageBuffers(bindings);
SetupImages(bindings);
SetupTextures(bindings);
@@ -436,6 +437,24 @@ void EmitContext::DefineConstantBuffers(Bindings& bindings) {
}
}
+void EmitContext::DefineConstantBufferIndirect() {
+ if (!info.uses_cbuf_indirect) {
+ return;
+ }
+
+ header += profile.has_gl_cbuf_ftou_bug ? "uvec4 " : "vec4 ";
+ header += "GetCbufIndirect(uint binding, uint offset){"
+ "switch(binding){"
+ "default:";
+
+ for (const auto& desc : info.constant_buffer_descriptors) {
+ header +=
+ fmt::format("case {}:return {}_cbuf{}[offset];", desc.index, stage_name, desc.index);
+ }
+
+ header += "}}";
+}
+
void EmitContext::DefineStorageBuffers(Bindings& bindings) {
if (info.storage_buffers_descriptors.empty()) {
return;