Commit 6575602e by apatrick@chromium.org

Finished off the GLSL compiler's support for parsing shaders using OES_EGL_image_external.

The GLSL to HLSL translator work is not done yet so the extension is disabled in Shader.cpp. Review URL: https://codereview.appspot.com/5530081 git-svn-id: https://angleproject.googlecode.com/svn/trunk@946 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c6489b15
......@@ -77,7 +77,8 @@ typedef enum {
SH_FLOAT_MAT4 = 0x8B5C,
SH_SAMPLER_2D = 0x8B5E,
SH_SAMPLER_CUBE = 0x8B60,
SH_SAMPLER_2D_RECT_ARB = 0x8B63
SH_SAMPLER_2D_RECT_ARB = 0x8B63,
SH_SAMPLER_EXTERNAL_OES = 0x8D66
} ShDataType;
typedef enum {
......
......@@ -301,6 +301,7 @@ void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongV
case SH_FLOAT_MAT4: typeName = "GL_FLOAT_MAT4"; break;
case SH_SAMPLER_2D: typeName = "GL_SAMPLER_2D"; break;
case SH_SAMPLER_CUBE: typeName = "GL_SAMPLER_CUBE"; break;
case SH_SAMPLER_EXTERNAL_OES: typeName = "GL_SAMPLER_EXTERNAL_OES"; break;
default: assert(0);
}
printf("%d: name:%s type:%s size:%d", i, name, typeName, size);
......
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 944
#define BUILD_REVISION 946
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -139,7 +139,7 @@ void OutputHLSL::header()
{
if (mReferencedUniforms.find(name.c_str()) != mReferencedUniforms.end())
{
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type.isArray()) + arrayString(type) + ";\n";
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + ";\n";
}
}
else if (qualifier == EvqVaryingIn || qualifier == EvqInvariantVaryingIn)
......@@ -303,7 +303,7 @@ void OutputHLSL::header()
{
if (mReferencedUniforms.find(name.c_str()) != mReferencedUniforms.end())
{
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type.isArray()) + arrayString(type) + ";\n";
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + ";\n";
}
}
else if (qualifier == EvqAttribute)
......@@ -759,7 +759,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
if (qualifier == EvqUniform)
{
mReferencedUniforms.insert(name.c_str());
out << decorateUniform(name, node->isArray());
out << decorateUniform(name, node->getType());
}
else if (qualifier == EvqAttribute)
{
......@@ -2019,6 +2019,8 @@ TString OutputHLSL::typeString(const TType &type)
return "sampler2D";
case EbtSamplerCube:
return "samplerCUBE";
case EbtSamplerExternalOES:
return "sampler2D";
}
}
......@@ -2370,12 +2372,16 @@ TString OutputHLSL::decorate(const TString &string)
return string;
}
TString OutputHLSL::decorateUniform(const TString &string, bool array)
TString OutputHLSL::decorateUniform(const TString &string, const TType &type)
{
if (array)
if (type.isArray())
{
return "ar_" + string; // Allows identifying arrays of size 1
}
else if (type.getBasicType() == EbtSamplerExternalOES)
{
return "ex_" + string;
}
return decorate(string);
}
......
......@@ -32,7 +32,7 @@ class OutputHLSL : public TIntermTraverser
static TString arrayString(const TType &type);
static TString initializer(const TType &type);
static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes
static TString decorateUniform(const TString &string, bool array);
static TString decorateUniform(const TString &string, const TType &type);
protected:
void header();
......
......@@ -63,6 +63,7 @@ static ShDataType getVariableDataType(const TType& type)
}
case EbtSampler2D: return SH_SAMPLER_2D;
case EbtSamplerCube: return SH_SAMPLER_CUBE;
case EbtSamplerExternalOES: return SH_SAMPLER_EXTERNAL_OES;
case EbtSampler2DRect: return SH_SAMPLER_2D_RECT_ARB;
default: UNREACHABLE();
}
......
......@@ -47,6 +47,7 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso
resources.MaxFragmentUniformVectors = context->getMaximumFragmentUniformVectors();
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
resources.OES_standard_derivatives = 1;
// resources.OES_EGL_image_external = getDisplay()->isD3d9ExDevice() ? 1 : 0; // TODO: commented out until the extension is actually supported.
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
......
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