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
This commit is contained in:
parent
c2604615f4
commit
3f04389a18
4 changed files with 57 additions and 2 deletions
|
|
@ -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++) {
|
||||
|
|
@ -319,6 +321,13 @@ public:
|
|||
if (intermediates[stage] != nullptr)
|
||||
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;
|
||||
|
|
@ -329,6 +338,11 @@ public:
|
|||
bool hadError = false;
|
||||
EProfile profile;
|
||||
int version;
|
||||
|
||||
private:
|
||||
TString autoPushConstantBlockName;
|
||||
unsigned int autoPushConstantMaxSize;
|
||||
TLayoutPacking autoPushConstantBlockPacking;
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue