Commit c2016a52 by t.jung

New uniform mapping handling

- add optional callback to handle mapping of uniform variables in linking phase - if no resolver is provided, it uses the internal default resolver with all shifts and auto bind settings Change-Id: Icfe38a9eabe8bfc8f8bb6d8150c06f7ed38bb762
parent 95078855
...@@ -2,10 +2,6 @@ spv.register.autoassign.rangetest.frag ...@@ -2,10 +2,6 @@ spv.register.autoassign.rangetest.frag
Linked fragment stage: Linked fragment stage:
INTERNAL ERROR: mapped binding out of range: g_tScene
INTERNAL ERROR: mapped binding out of range: g_tSamp
INTERNAL ERROR: mapped binding out of range: g_tScene
INTERNAL ERROR: mapped binding out of range: g_tSamp
INTERNAL ERROR: mapped binding out of range: g_tSamp INTERNAL ERROR: mapped binding out of range: g_tSamp
INTERNAL ERROR: mapped binding out of range: g_tScene INTERNAL ERROR: mapped binding out of range: g_tScene
......
...@@ -1716,7 +1716,7 @@ void TProgram::dumpReflection() { reflection->dump(); } ...@@ -1716,7 +1716,7 @@ void TProgram::dumpReflection() { reflection->dump(); }
// //
// I/O mapping implementation. // I/O mapping implementation.
// //
bool TProgram::mapIO() bool TProgram::mapIO(TIoMapResolver* resolver)
{ {
if (! linked || ioMapper) if (! linked || ioMapper)
return false; return false;
...@@ -1725,7 +1725,7 @@ bool TProgram::mapIO() ...@@ -1725,7 +1725,7 @@ bool TProgram::mapIO()
for (int s = 0; s < EShLangCount; ++s) { for (int s = 0; s < EShLangCount; ++s) {
if (intermediate[s]) { if (intermediate[s]) {
if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink)) if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink, resolver))
return false; return false;
} }
} }
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
virtual ~TIoMapper() {} virtual ~TIoMapper() {}
// grow the reflection stage by stage // grow the reflection stage by stage
bool addStage(EShLanguage, TIntermediate&, TInfoSink&); bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*);
}; };
} // end namespace glslang } // end namespace glslang
......
...@@ -445,7 +445,36 @@ private: ...@@ -445,7 +445,36 @@ private:
class TReflection; class TReflection;
class TIoMapper; class TIoMapper;
// Make one TProgram per set of shaders that will get linked together. Add all // Allows to customize the binding layout after linking.
// All used uniform variables will invoke at least validateBinding.
// If validateBinding returned true then the other resolveBinding
// and resolveSet are invoked to resolve the binding and descriptor
// set index respectively.
// Invocations happen in a particular order:
// 1) var with binding and set already defined
// 2) var with binding but no set defined
// 3) var with set but no binding defined
// 4) var with no binding and no set defined
//
// NOTE: that still limit checks are applied to bindings and sets
// and may result in an error.
class TIoMapResolver
{
public:
virtual ~TIoMapResolver() {}
// Should return true if the resulting/current binding would be ok.
// Basic idea is to do aliasing binding checks with this.
virtual bool validateBinding(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return a value >= 0 if the current binding should be overridden.
// Return -1 if the current binding (including no binding) should be kept.
virtual int resolveBinding(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return a value >= 0 if the current set should be overriden.
// Return -1 if the current set (including no set) should be kept.
virtual int resolveSet(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
};
// Make one TProgram per set of shaders that will get linked together. Add all
// the shaders that are to be linked together. After calling shader.parse() // the shaders that are to be linked together. After calling shader.parse()
// for all shaders, call link(). // for all shaders, call link().
// //
...@@ -485,7 +514,9 @@ public: ...@@ -485,7 +514,9 @@ public:
void dumpReflection(); void dumpReflection();
// I/O mapping: apply base offsets and map live unbound variables // I/O mapping: apply base offsets and map live unbound variables
bool mapIO(); // If resolver is not provided it uses the previous approach
// and respects auto assignment and offsets.
bool mapIO(TIoMapResolver* resolver = NULL);
protected: protected:
bool linkStage(EShLanguage, EShMessages); bool linkStage(EShLanguage, EShMessages);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment