aboutsummaryrefslogtreecommitdiff
path: root/glslang/Public/ShaderLang.h
diff options
context:
space:
mode:
Diffstat (limited to 'glslang/Public/ShaderLang.h')
-rw-r--r--glslang/Public/ShaderLang.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
index e5e8b4d7..6793cdd3 100644
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -306,6 +306,7 @@ public:
void setEntryPoint(const char* entryPoint);
void setShiftSamplerBinding(unsigned int base);
void setShiftTextureBinding(unsigned int base);
+ void setShiftImageBinding(unsigned int base);
void setShiftUboBinding(unsigned int base);
void setAutoMapBindings(bool map);
void setFlattenUniformArrays(bool flatten);
@@ -445,7 +446,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().
//
@@ -481,11 +511,14 @@ public:
int getAttributeType(int index) const; // can be used for glGetActiveAttrib()
const TType* getUniformTType(int index) const; // returns a TType*
const TType* getUniformBlockTType(int index) const; // returns a TType*
+ const TType* getAttributeTType(int index) const; // returns a TType*
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);