Add a new path for querying active attributes from the shader translator, for use with layout qualifier support.
TRAC #23269
Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Jamie Madill
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index b36d456..d117a30 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -161,6 +161,11 @@
return mActiveOutputVariables;
}
+const ActiveShaderVariables &OutputHLSL::getAttributes() const
+{
+ return mActiveAttributes;
+}
+
int OutputHLSL::vectorSize(const TType &type) const
{
int elementSize = type.isMatrix() ? type.getCols() : 1;
@@ -389,6 +394,10 @@
const TString &name = attribute->second->getSymbol();
attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+
+ ShaderVariable shaderVar(glVariableType(type), glVariablePrecision(type), name.c_str(),
+ (unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
+ mActiveAttributes.push_back(shaderVar);
}
if (shaderType == SH_FRAGMENT_SHADER)
diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h
index c22ad4f..6a409b4 100644
--- a/src/compiler/OutputHLSL.h
+++ b/src/compiler/OutputHLSL.h
@@ -35,6 +35,7 @@
const ActiveUniforms &getUniforms();
const ActiveInterfaceBlocks &getInterfaceBlocks() const;
const ActiveShaderVariables &getOutputVariables() const;
+ const ActiveShaderVariables &getAttributes() const;
TString typeString(const TType &type);
TString textureString(const TType &type);
@@ -195,6 +196,7 @@
ActiveUniforms mActiveUniforms;
ActiveInterfaceBlocks mActiveInterfaceBlocks;
ActiveShaderVariables mActiveOutputVariables;
+ ActiveShaderVariables mActiveAttributes;
};
}
diff --git a/src/compiler/ShaderLang.cpp b/src/compiler/ShaderLang.cpp
index 07313dd..efdcb67 100644
--- a/src/compiler/ShaderLang.cpp
+++ b/src/compiler/ShaderLang.cpp
@@ -382,6 +382,9 @@
case SH_ACTIVE_OUTPUT_VARIABLES_ARRAY:
*params = (void*)&translator->getOutputVariables();
break;
+ case SH_ACTIVE_ATTRIBUTES_ARRAY:
+ *params = (void*)&translator->getAttributes();
+ break;
default: UNREACHABLE();
}
}
diff --git a/src/compiler/TranslatorHLSL.cpp b/src/compiler/TranslatorHLSL.cpp
index 6ef91f4..83468d4 100644
--- a/src/compiler/TranslatorHLSL.cpp
+++ b/src/compiler/TranslatorHLSL.cpp
@@ -23,4 +23,5 @@
mActiveUniforms = outputHLSL.getUniforms();
mActiveInterfaceBlocks = outputHLSL.getInterfaceBlocks();
mActiveOutputVariables = outputHLSL.getOutputVariables();
+ mActiveAttributes = outputHLSL.getAttributes();
}
diff --git a/src/compiler/TranslatorHLSL.h b/src/compiler/TranslatorHLSL.h
index c031446..e53e831 100644
--- a/src/compiler/TranslatorHLSL.h
+++ b/src/compiler/TranslatorHLSL.h
@@ -18,6 +18,7 @@
const sh::ActiveUniforms &getUniforms() { return mActiveUniforms; }
const sh::ActiveInterfaceBlocks &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const sh::ActiveShaderVariables &getOutputVariables() { return mActiveOutputVariables; }
+ const sh::ActiveShaderVariables &getAttributes() { return mActiveAttributes; }
protected:
virtual void translate(TIntermNode* root);
@@ -25,6 +26,7 @@
sh::ActiveUniforms mActiveUniforms;
sh::ActiveInterfaceBlocks mActiveInterfaceBlocks;
sh::ActiveShaderVariables mActiveOutputVariables;
+ sh::ActiveShaderVariables mActiveAttributes;
ShShaderOutput mOutputType;
};
diff --git a/src/compiler/Uniform.cpp b/src/compiler/Uniform.cpp
index 602eed5..3cd3599 100644
--- a/src/compiler/Uniform.cpp
+++ b/src/compiler/Uniform.cpp
@@ -11,6 +11,14 @@
namespace sh
{
+ShaderVariable::ShaderVariable()
+ : type(GL_NONE),
+ precision(GL_NONE),
+ arraySize(0),
+ location(-1)
+{
+}
+
ShaderVariable::ShaderVariable(GLenum type, GLenum precision, const char *name, unsigned int arraySize, int location)
: type(type),
precision(precision),
diff --git a/src/compiler/Uniform.h b/src/compiler/Uniform.h
index e43533a..ac0fdfd 100644
--- a/src/compiler/Uniform.h
+++ b/src/compiler/Uniform.h
@@ -19,6 +19,7 @@
struct ShaderVariable
{
+ ShaderVariable();
ShaderVariable(GLenum type, GLenum precision, const char *name, unsigned int arraySize, int location);
GLenum type;