diff options
author | Malcolm Bechard <mbechard@users.noreply.github.com> | 2021-09-22 13:41:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-22 11:41:10 -0600 |
commit | 3f04389a1806c74355236ecd0a2493d701b19d87 (patch) | |
tree | 38e039a2363bc36f3807252198df513c8717266a /glslang/MachineIndependent/iomapper.h | |
parent | c2604615f4820be63d9ea205be9a796bfc309e4b (diff) | |
download | glslang-3f04389a1806c74355236ecd0a2493d701b19d87.tar.gz |
Auto push constant blocks (#2764)
* add ability to upgrade uniform block to push constants assuming it fits within the size limit imposed by the caller
* allow selecting the packing for the auto push constants
* check the size using the potential layout packing of the push constants
Diffstat (limited to 'glslang/MachineIndependent/iomapper.h')
-rw-r--r-- | glslang/MachineIndependent/iomapper.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/glslang/MachineIndependent/iomapper.h b/glslang/MachineIndependent/iomapper.h index 07357c2e..843ea73c 100644 --- a/glslang/MachineIndependent/iomapper.h +++ b/glslang/MachineIndependent/iomapper.h @@ -291,7 +291,7 @@ public: bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; } }; -// I/O mapper for OpenGL +// I/O mapper for GLSL class TGlslIoMapper : public TIoMapper { public: TGlslIoMapper() { @@ -301,6 +301,8 @@ public: memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1)); profile = ENoProfile; version = 0; + autoPushConstantMaxSize = 128; + autoPushConstantBlockPacking = ElpStd430; } virtual ~TGlslIoMapper() { for (size_t stage = 0; stage < EShLangCount; stage++) { @@ -320,6 +322,13 @@ public: intermediates[stage] = nullptr; } } + // If set, the uniform block with the given name will be changed to be backed by + // push_constant if it's size is <= maxSize + void setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) { + autoPushConstantBlockName = name; + autoPushConstantMaxSize = maxSize; + autoPushConstantBlockPacking = packing; + } // grow the reflection stage by stage bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override; bool doMap(TIoMapResolver*, TInfoSink&) override; @@ -329,6 +338,11 @@ public: bool hadError = false; EProfile profile; int version; + +private: + TString autoPushConstantBlockName; + unsigned int autoPushConstantMaxSize; + TLayoutPacking autoPushConstantBlockPacking; }; } // end namespace glslang |