]> git.tdb.fi Git - libs/gl.git/commitdiff
Recognize push constant blocks when reflecting SPIR-V modules
authorMikko Rasa <tdb@tdb.fi>
Thu, 11 Nov 2021 11:34:40 +0000 (13:34 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 11 Nov 2021 11:34:40 +0000 (13:34 +0200)
source/core/module.h
source/core/program.cpp
source/core/reflectdata.h

index 1c62f340505a254e2fec0d40817c6335e1a49060..5067895de662e2a29676f07f988df3d9e7d1e371 100644 (file)
@@ -106,7 +106,8 @@ public:
                UNIFORM_CONSTANT = 0,
                INPUT = 1,
                UNIFORM = 2,
-               OUTPUT = 3
+               OUTPUT = 3,
+               PUSH_CONSTANT = 9
        };
 
        enum BuiltinSemantic
index 72eb03d8d92dcf233ee20a5fddd3d9127d7f6ab4..66fbb7af61179a7ccb64554f24afb3bb5ac26868 100644 (file)
@@ -57,13 +57,18 @@ void Program::collect_uniforms(const SpirVModule &mod)
 
        for(const SpirVModule::Variable &v: mod.get_variables())
        {
-               if(v.storage==SpirVModule::UNIFORM && v.struct_type)
+               if((v.storage==SpirVModule::UNIFORM || v.storage==SpirVModule::PUSH_CONSTANT) && v.struct_type)
                {
                        reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo());
                        ReflectData::UniformBlockInfo &info = reflect_data.uniform_blocks.back();
                        info.name = v.struct_type->name;
-                       info.bind_point = v.binding;
-                       info.descriptor_set = v.descriptor_set;
+                       if(v.storage==SpirVModule::PUSH_CONSTANT)
+                               info.bind_point = ReflectData::PUSH_CONSTANT;
+                       else
+                       {
+                               info.bind_point = v.binding;
+                               info.descriptor_set = v.descriptor_set;
+                       }
                        info.data_size = v.struct_type->size;
 
                        string prefix;
index 2c0d7fe3e1c0765586726a2dfb4acb7e28616cdc..2925da146b899b1e62ab642b09403400d8f2b761 100644 (file)
@@ -14,6 +14,12 @@ Reflection data for shader programs.
 */
 struct ReflectData
 {
+       enum
+       {
+               DEFAULT_BLOCK = -1,
+               PUSH_CONSTANT = -2
+       };
+
        typedef unsigned LayoutHash;
        struct UniformBlockInfo;
 
@@ -40,7 +46,7 @@ struct ReflectData
                std::string name;
                unsigned data_size = 0;
                int descriptor_set = 0;
-               int bind_point = -1;
+               int bind_point = DEFAULT_BLOCK;
                std::vector<const UniformInfo *> uniforms;
                LayoutHash layout_hash = 0;