diff options
| author | Fernando S <fsahmkow27@gmail.com> | 2022-04-07 12:40:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-07 12:40:59 +0200 |
| commit | 4d5900aaa1776b01ec666a14480018aa86e02e6f (patch) | |
| tree | 6564d65d194725e528fb525dadad3300b58197fa /src/shader_recompiler/backend/glsl/glsl_emit_context.cpp | |
| parent | 172137f1a08cf5a702ca6da6ecba0329b10e0ed7 (diff) | |
| parent | 1ab771c3adb3e886eef9ed33caef2fa5f8c18205 (diff) | |
Merge pull request #8133 from liamwhite/gl-spv-cbuf
shader_recompiler: support const buffer indirect addressing on OpenGL
Diffstat (limited to 'src/shader_recompiler/backend/glsl/glsl_emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/glsl_emit_context.cpp | 19 |
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; |
