]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a separate limit for storage texture binding range
authorMikko Rasa <tdb@tdb.fi>
Fri, 15 Apr 2022 19:44:25 +0000 (22:44 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 15 Apr 2022 19:48:06 +0000 (22:48 +0300)
source/backends/opengl/device_backend.cpp
source/backends/vulkan/device_backend.cpp
source/glsl/features.cpp
source/glsl/features.h
source/glsl/finalize.cpp

index 7819c98fe68e6d92f095a9edfc3ea2919e0cf48a..db711e5101bae9036eb2edc82fb645e2ed3e3813 100644 (file)
@@ -3,6 +3,7 @@
 #include <msp/gl/extensions/arb_explicit_uniform_location.h>
 #include <msp/gl/extensions/arb_gpu_shader5.h>
 #include <msp/gl/extensions/arb_separate_shader_objects.h>
+#include <msp/gl/extensions/arb_shader_image_load_store.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/ext_framebuffer_multisample.h>
@@ -62,6 +63,8 @@ void OpenGLDevice::fill_info()
                glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast<int *>(&lim.max_vertex_attributes));
                glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast<int *>(&lim.max_texture_bindings));
        }
+       if(ARB_shader_image_load_store)
+               glGetIntegerv(GL_MAX_IMAGE_UNITS, reinterpret_cast<int *>(&lim.max_storage_texture_bindings));
        if(EXT_framebuffer_object)
                glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast<int *>(&lim.max_color_attachments));
        if(EXT_framebuffer_multisample)
@@ -87,6 +90,7 @@ void OpenGLDevice::fill_info()
        feat.ext_texture_array = EXT_texture_array;
        feat.uniform_binding_range = lim.max_uniform_bindings;
        feat.texture_binding_range = lim.max_texture_bindings;
+       feat.storage_texture_binding_range = lim.max_storage_texture_bindings;
 
        state.bound_tex_targets.resize(lim.max_texture_bindings);
        state.bound_uniform_blocks.resize(lim.max_uniform_bindings);
index 9a8b930d713f6d100f3351a0a91040232c3f19f7..8e3f2ab621a9acc55823d2f0c2ea22b4331a082a 100644 (file)
@@ -56,6 +56,7 @@ void VulkanDevice::fill_info()
        limits.max_clip_planes = props.limits.maxClipDistances;
        limits.max_vertex_attributes = props.limits.maxVertexInputAttributes;
        limits.max_texture_bindings = props.limits.maxDescriptorSetSampledImages;
+       limits.max_storage_texture_bindings = props.limits.maxDescriptorSetStorageImages;
        limits.max_color_attachments = props.limits.maxColorAttachments;
        unsigned samples = props.limits.framebufferColorSampleCounts&props.limits.framebufferDepthSampleCounts&props.limits.framebufferStencilSampleCounts;
        if(samples&VK_SAMPLE_COUNT_64_BIT)
index 9382ce6605c3289dc6342d3670f6db813a56d431..d66226e327fee4a384b7d2eabb60cf0a21a98c02 100644 (file)
@@ -34,6 +34,7 @@ Features Features::from_api_version(GraphicsApi api, const Version &ver)
                        ver>=Version(3, 3) ? 36 : 24);
                features.texture_binding_range = (ver>=Version(4, 3) ? 96 : ver>=Version(4, 0) ? 80 :
                        ver>=Version(3, 2) ? 48 : ver>=Version(1, 4) ? 32 : 16);
+               features.storage_texture_binding_range = 8;
                break;
        case OPENGL_ES:
                if(ver.major==2)
@@ -52,11 +53,13 @@ Features Features::from_api_version(GraphicsApi api, const Version &ver)
                features.uniform_binding_range = (ver>=Version(3, 2) ? 72 : ver>=Version(3, 1) ? 36 : 24);
                features.texture_binding_range = (ver>=Version(3, 2) ? 96 : ver>=Version(3, 1) ? 48 :
                        ver>=Version(3, 0) ? 32 : 8);
+               features.storage_texture_binding_range = 4;
                break;
        case VULKAN:
                features.glsl_version = Version(4, 60);
                features.uniform_binding_range = 72;
                features.texture_binding_range = 96;
+               features.storage_texture_binding_range = 24;
                break;
        default:
                throw invalid_argument("Features::from_api_version");
index e0d7dd77ceb3982ec6ed60bb543b26799cd9604e..28cefd0b411661af1a0c6f88b96918a5bc6e0ad0 100644 (file)
@@ -22,6 +22,7 @@ struct Features
        unsigned constant_id_range = 0x80000000U;
        unsigned uniform_binding_range = 24;
        unsigned texture_binding_range = 16;
+       unsigned storage_texture_binding_range = 8;
 
        static Features from_api_version(GraphicsApi, const Version &);
        static Features latest(GraphicsApi);
index 94052432296e2dc1dc629e68ad4618b595f4d63d..3b0909ac2a90949733577e0e3a22dc0383cca445 100644 (file)
@@ -75,7 +75,12 @@ void LocationAllocator::apply(Module &module, const Features &f, bool a)
        for(VariableDeclaration *b: unbound_blocks)
                bind_uniform(b->layout, b->block_declaration->block_name, features.uniform_binding_range);
        for(VariableDeclaration *t: unbound_textures)
-               bind_uniform(t->layout, t->name, features.texture_binding_range);
+       {
+               const TypeDeclaration *base_type = get_ultimate_base_type(t->type_declaration);
+               unsigned range = (static_cast<const ImageTypeDeclaration *>(base_type)->sampled ?
+                       features.texture_binding_range : features.storage_texture_binding_range);
+               bind_uniform(t->layout, t->name, range);
+       }
 }
 
 void LocationAllocator::apply(Stage &stage)