Commit 68fe74aa by Jamie Madill

Add a compiler query for the translator output type.

This is useful for determining if we are compiling to a D3D9 or D3D11 shader outside of the internal translator classes. BUG=angle:656 Change-Id: Ib1c1d3de569edaa2b65c24c09d05aa4dd229d3e4 Reviewed-on: https://chromium-review.googlesource.com/201564Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5f5320a9
......@@ -37,7 +37,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented every time the API changes.
#define ANGLE_SH_VERSION 124
#define ANGLE_SH_VERSION 125
//
// The names of the following enums have been derived by replacing GL prefix
......@@ -157,7 +157,8 @@ typedef enum {
SH_ACTIVE_OUTPUT_VARIABLES_ARRAY = 0x6007,
SH_ACTIVE_ATTRIBUTES_ARRAY = 0x6008,
SH_ACTIVE_VARYINGS_ARRAY = 0x6009,
SH_RESOURCES_STRING_LENGTH = 0x600A
SH_RESOURCES_STRING_LENGTH = 0x600A,
SH_OUTPUT_TYPE = 0x600B
} ShShaderInfo;
// Compile options.
......@@ -416,6 +417,7 @@ COMPILER_EXPORT int ShCompile(
// null termination character.
// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
// SH_SHADER_VERSION: the version of the shader language
// SH_OUTPUT_TYPE: the currently set language output type
//
// params: Requested parameter
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
......
......@@ -92,9 +92,10 @@ TShHandleBase::~TShHandleBase()
allocator.popAll();
}
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
: shaderType(type),
shaderSpec(spec),
outputType(output),
maxUniformVectors(0),
maxExpressionComplexity(0),
maxCallStackDepth(0),
......
......@@ -54,7 +54,7 @@ protected:
//
class TCompiler : public TShHandleBase {
public:
TCompiler(ShShaderType type, ShShaderSpec spec);
TCompiler(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
virtual ~TCompiler();
virtual TCompiler* getAsCompiler() { return this; }
......@@ -74,6 +74,7 @@ public:
NameMap& getNameMap() { return nameMap; }
TSymbolTable& getSymbolTable() { return symbolTable; }
ShShaderSpec getShaderSpec() const { return shaderSpec; }
ShShaderOutput getOutputType() const { return outputType; }
std::string getBuiltInResourcesString() const { return builtInResourcesString; }
protected:
......@@ -131,6 +132,7 @@ protected:
private:
ShShaderType shaderType;
ShShaderSpec shaderSpec;
ShShaderOutput outputType;
int maxUniformVectors;
int maxExpressionComplexity;
......
......@@ -249,6 +249,9 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
case SH_RESOURCES_STRING_LENGTH:
*params = compiler->getBuiltInResourcesString().length() + 1;
break;
case SH_OUTPUT_TYPE:
*params = compiler->getOutputType();
break;
default: UNREACHABLE();
}
}
......
......@@ -9,7 +9,7 @@
#include "compiler/translator/OutputESSL.h"
TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
: TCompiler(type, spec) {
: TCompiler(type, spec, SH_ESSL_OUTPUT) {
}
void TranslatorESSL::translate(TIntermNode* root) {
......
......@@ -22,7 +22,7 @@ static void writeVersion(ShShaderType type, TIntermNode* root,
}
TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
: TCompiler(type, spec) {
: TCompiler(type, spec, SH_GLSL_OUTPUT) {
}
void TranslatorGLSL::translate(TIntermNode* root) {
......
......@@ -10,14 +10,14 @@
#include "compiler/translator/OutputHLSL.h"
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
: TCompiler(type, spec), mOutputType(output)
: TCompiler(type, spec, output)
{
}
void TranslatorHLSL::translate(TIntermNode *root)
{
TParseContext& parseContext = *GetGlobalParseContext();
sh::OutputHLSL outputHLSL(parseContext, getResources(), mOutputType);
sh::OutputHLSL outputHLSL(parseContext, getResources(), getOutputType());
outputHLSL.output();
......
......@@ -29,7 +29,6 @@ protected:
std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<gl::Attribute> mActiveAttributes;
std::vector<gl::Varying> mActiveVaryings;
ShShaderOutput mOutputType;
};
#endif // COMPILER_TRANSLATORHLSL_H_
......@@ -583,4 +583,21 @@ const std::vector<Attribute> &FragmentShader::getOutputVariables() const
return mActiveOutputVariables;
}
ShShaderOutput Shader::getCompilerOutputType(GLenum shader)
{
void *compiler = NULL;
switch (shader)
{
case GL_VERTEX_SHADER: compiler = mVertexCompiler; break;
case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break;
default: UNREACHABLE(); return SH_HLSL9_OUTPUT;
}
size_t outputType = 0;
ShGetInfo(compiler, SH_OUTPUT_TYPE, &outputType);
return static_cast<ShShaderOutput>(outputType);
}
}
......@@ -22,6 +22,7 @@
#include "common/shadervars.h"
#include "common/angleutils.h"
#include "libGLESv2/angletypes.h"
#include "GLSLANG/ShaderLang.h"
namespace rx
{
......@@ -87,6 +88,7 @@ class Shader
void resetVaryingsRegisterAssignment();
static void releaseCompiler();
static ShShaderOutput getCompilerOutputType(GLenum shader);
bool usesDepthRange() const { return mUsesDepthRange; }
bool usesPointSize() const { return mUsesPointSize; }
......
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