summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glsl/emit_context.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-06-11 08:50:30 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:38 +0200
commite81c73a8748ccfcde56acfee5630116c3950e479 (patch)
tree617a67d3512b228dbaa40b710700dfb79f7bc7bc /src/shader_recompiler/backend/glsl/emit_context.cpp
parentglsl: Remove Signed Integer variables (diff)
downloadyuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar.gz
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar.bz2
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar.lz
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar.xz
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.tar.zst
yuzu-e81c73a8748ccfcde56acfee5630116c3950e479.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index cbcf0a1eb..ed10eca8a 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -559,53 +559,45 @@ std::string EmitContext::DefineGlobalMemoryFunctions() {
}
void EmitContext::SetupImages(Bindings& bindings) {
- image_buffer_bindings.reserve(info.image_buffer_descriptors.size());
+ image_buffers.reserve(info.image_buffer_descriptors.size());
for (const auto& desc : info.image_buffer_descriptors) {
- image_buffer_bindings.push_back(bindings.image);
- const auto indices{bindings.image + desc.count};
+ image_buffers.push_back({bindings.image, desc.count});
const auto format{ImageFormatString(desc.format)};
- for (u32 index = bindings.image; index < indices; ++index) {
- header += fmt::format("layout(binding={}{}) uniform uimageBuffer img{};",
- bindings.image, format, index);
- }
+ const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
+ header += fmt::format("layout(binding={}{}) uniform uimageBuffer img{}{};", bindings.image,
+ format, bindings.image, array_decorator);
bindings.image += desc.count;
}
- image_bindings.reserve(info.image_descriptors.size());
+ images.reserve(info.image_descriptors.size());
for (const auto& desc : info.image_descriptors) {
- image_bindings.push_back(bindings.image);
+ images.push_back({bindings.image, desc.count});
const auto format{ImageFormatString(desc.format)};
const auto image_type{ImageType(desc.type)};
const auto qualifier{desc.is_written ? "" : "readonly "};
- const auto indices{bindings.image + desc.count};
- for (u32 index = bindings.image; index < indices; ++index) {
- header += fmt::format("layout(binding={}{})uniform {}{} img{};", bindings.image, format,
- qualifier, image_type, index);
- }
+ const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
+ header += fmt::format("layout(binding={}{})uniform {}{} img{}{};", bindings.image, format,
+ qualifier, image_type, bindings.image, array_decorator);
bindings.image += desc.count;
}
}
void EmitContext::SetupTextures(Bindings& bindings) {
- texture_buffer_bindings.reserve(info.texture_buffer_descriptors.size());
+ texture_buffers.reserve(info.texture_buffer_descriptors.size());
for (const auto& desc : info.texture_buffer_descriptors) {
- texture_buffer_bindings.push_back(bindings.texture);
+ texture_buffers.push_back({bindings.texture, desc.count});
const auto sampler_type{SamplerType(TextureType::Buffer, false)};
- const auto indices{bindings.texture + desc.count};
- for (u32 index = bindings.texture; index < indices; ++index) {
- header += fmt::format("layout(binding={}) uniform {} tex{};", bindings.texture,
- sampler_type, index);
- }
+ const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
+ header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
+ sampler_type, bindings.texture, array_decorator);
bindings.texture += desc.count;
}
- texture_bindings.reserve(info.texture_descriptors.size());
+ textures.reserve(info.texture_descriptors.size());
for (const auto& desc : info.texture_descriptors) {
+ textures.push_back({bindings.texture, desc.count});
const auto sampler_type{SamplerType(desc.type, desc.is_depth)};
- texture_bindings.push_back(bindings.texture);
- const auto indices{bindings.texture + desc.count};
- for (u32 index = bindings.texture; index < indices; ++index) {
- header += fmt::format("layout(binding={}) uniform {} tex{};", bindings.texture,
- sampler_type, index);
- }
+ const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
+ header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
+ sampler_type, bindings.texture, array_decorator);
bindings.texture += desc.count;
}
}