Commit 28a97ee1 by Geoff Lang

Generate unique HLSL texture function names for external textures.

Because 2D and external textures have the same HLSL texture type, they were generating texture functions with the same name. This causes conflicts when both 2D and external textures are used in the same shader. BUG=angleproject:1534 BUG=645532 Change-Id: I4b324014b7d9b4851d358730cf4e31fc8461584c Reviewed-on: https://chromium-review.googlesource.com/388551Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent f41a7151
......@@ -1113,32 +1113,8 @@ const char *TextureFunctionHLSL::TextureFunction::getReturnType() const
bool TextureFunctionHLSL::TextureFunction::operator<(const TextureFunction &rhs) const
{
if (sampler < rhs.sampler)
return true;
if (sampler > rhs.sampler)
return false;
if (coords < rhs.coords)
return true;
if (coords > rhs.coords)
return false;
if (!proj && rhs.proj)
return true;
if (proj && !rhs.proj)
return false;
if (!offset && rhs.offset)
return true;
if (offset && !rhs.offset)
return false;
if (method < rhs.method)
return true;
if (method > rhs.method)
return false;
return false;
return std::tie(sampler, coords, proj, offset, method) <
std::tie(rhs.sampler, rhs.coords, rhs.proj, rhs.offset, rhs.method);
}
TString TextureFunctionHLSL::useTextureFunction(const TString &name,
......
......@@ -173,6 +173,8 @@ TString TextureTypeSuffix(const TBasicType type)
return "Cube_int4_";
case EbtUSamplerCube:
return "Cube_uint4_";
case EbtSamplerExternalOES:
return "_External";
default:
// All other types are identified by their group suffix
return TextureGroupSuffix(type);
......
......@@ -2433,6 +2433,29 @@ TEST_P(GLSLTest, FoldedIntDifferenceOutOfBounds)
glDeleteProgram(program);
}
// Test that using a sampler2D and samplerExternalOES in the same shader works (anglebug.com/1534)
TEST_P(GLSLTest, ExternalAnd2DSampler)
{
if (!extensionEnabled("GL_OES_EGL_image_external"))
{
std::cout << "Test skipped because GL_OES_EGL_image_external is not available."
<< std::endl;
return;
}
const std::string fragmentShader =
"precision mediump float;\n"
"uniform samplerExternalOES tex0;\n"
"uniform sampler2D tex1;\n"
"void main(void)\n"
"{\n"
" vec2 uv = vec2(0.0, 0.0);"
" gl_FragColor = texture2D(tex0, uv) + texture2D(tex1, uv);\n"
"}\n";
ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader);
}
// Test that using an invalid constant right-shift produces an error.
TEST_P(GLSLTest_ES3, FoldedInvalidRightShift)
{
......
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