From fee6115b609b8726b50a1f9169d50e8f68170b75 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 11 Nov 2021 13:34:40 +0200 Subject: [PATCH] Recognize push constant blocks when reflecting SPIR-V modules --- source/core/module.h | 3 ++- source/core/program.cpp | 11 ++++++++--- source/core/reflectdata.h | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/source/core/module.h b/source/core/module.h index 1c62f340..5067895d 100644 --- a/source/core/module.h +++ b/source/core/module.h @@ -106,7 +106,8 @@ public: UNIFORM_CONSTANT = 0, INPUT = 1, UNIFORM = 2, - OUTPUT = 3 + OUTPUT = 3, + PUSH_CONSTANT = 9 }; enum BuiltinSemantic diff --git a/source/core/program.cpp b/source/core/program.cpp index 72eb03d8..66fbb7af 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -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; diff --git a/source/core/reflectdata.h b/source/core/reflectdata.h index 2c0d7fe3..2925da14 100644 --- a/source/core/reflectdata.h +++ b/source/core/reflectdata.h @@ -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 uniforms; LayoutHash layout_hash = 0; -- 2.43.0