Commit 1061accf by John Kessenich Committed by GitHub

Merge pull request #562 from TiemoJung/io_map_control_publish

HLSL -> Spir-V: Resource mapping handler
parents 909b8afa c2016a52
......@@ -2,10 +2,6 @@ spv.register.autoassign.rangetest.frag
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_tScene
......
......@@ -1716,7 +1716,7 @@ void TProgram::dumpReflection() { reflection->dump(); }
//
// I/O mapping implementation.
//
bool TProgram::mapIO()
bool TProgram::mapIO(TIoMapResolver* resolver)
{
if (! linked || ioMapper)
return false;
......@@ -1725,7 +1725,7 @@ bool TProgram::mapIO()
for (int s = 0; s < EShLangCount; ++s) {
if (intermediate[s]) {
if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink))
if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink, resolver))
return false;
}
}
......
......@@ -55,7 +55,7 @@ public:
virtual ~TIoMapper() {}
// grow the reflection stage by stage
bool addStage(EShLanguage, TIntermediate&, TInfoSink&);
bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*);
};
} // end namespace glslang
......
......@@ -445,7 +445,36 @@ private:
class TReflection;
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()
// for all shaders, call link().
//
......@@ -485,7 +514,9 @@ public:
void dumpReflection();
// 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:
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