Commit ba992ab5 by Geoff Lang

Fix HLSL 3 generation of shaders with texture LOD.

BUG=angleproject:2002 Change-Id: If8e6bbaeb5769341f92f05025eafb6a202fec437 Reviewed-on: https://chromium-review.googlesource.com/481680Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 50a8d0e0
......@@ -214,6 +214,7 @@ int GetHLSLCoordCount(const TextureFunctionHLSL::TextureFunction &textureFunctio
switch (textureFunction.method)
{
case TextureFunctionHLSL::TextureFunction::IMPLICIT:
case TextureFunctionHLSL::TextureFunction::GRAD:
return hlslCoords;
case TextureFunctionHLSL::TextureFunction::BIAS:
case TextureFunctionHLSL::TextureFunction::LOD:
......@@ -831,6 +832,9 @@ void OutputTextureSampleFunctionReturnStatement(
case TextureFunctionHLSL::TextureFunction::LOD0BIAS:
out << "lod(" << samplerReference << ", ";
break;
case TextureFunctionHLSL::TextureFunction::GRAD:
out << "grad(" << samplerReference << ", ";
break;
default:
UNREACHABLE();
}
......
......@@ -822,12 +822,14 @@ void GenerateCaps(const FunctionsGL *functions,
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_blend_minmax");
extensions->framebufferBlit = (functions->blitFramebuffer != nullptr);
extensions->framebufferMultisample = caps->maxSamples > 0;
extensions->standardDerivatives = functions->isAtLeastGL(gl::Version(2, 0)) || functions->hasGLExtension("GL_ARB_fragment_shader") ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_standard_derivatives");
extensions->shaderTextureLOD = functions->isAtLeastGL(gl::Version(3, 0)) || functions->hasGLExtension("GL_ARB_shader_texture_lod") ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_shader_texture_lod");
extensions->standardDerivatives = functions->isAtLeastGL(gl::Version(2, 0)) ||
functions->hasGLExtension("GL_ARB_fragment_shader") ||
functions->hasGLESExtension("GL_OES_standard_derivatives");
extensions->shaderTextureLOD = functions->isAtLeastGL(gl::Version(3, 0)) ||
functions->hasGLExtension("GL_ARB_shader_texture_lod") ||
functions->hasGLESExtension("GL_EXT_shader_texture_lod");
extensions->fragDepth = functions->standard == STANDARD_GL_DESKTOP ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_frag_depth");
functions->hasGLESExtension("GL_EXT_frag_depth");
extensions->fboRenderMipmap = functions->isAtLeastGL(gl::Version(3, 0)) || functions->hasGLExtension("GL_EXT_framebuffer_object") ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_fbo_render_mipmap");
extensions->instancedArrays = functions->isAtLeastGL(gl::Version(3, 1)) ||
......
......@@ -1823,6 +1823,28 @@ TEST_P(GLSLTest, VerifyMaxFragmentUniformVectorsExceeded)
CompileGLSLWithUniformsAndSamplers(0, maxUniforms + 1, 0, 0, false);
}
// Test compiling shaders using the GL_EXT_shader_texture_lod extension
TEST_P(GLSLTest, TextureLOD)
{
if (!extensionEnabled("GL_EXT_shader_texture_lod"))
{
std::cout << "Test skipped due to missing GL_EXT_shader_texture_lod." << std::endl;
return;
}
const std::string source =
"#extension GL_EXT_shader_texture_lod : require\n"
"uniform sampler2D u_texture;\n"
"void main() {\n"
" gl_FragColor = texture2DGradEXT(u_texture, vec2(0.0, 0.0), vec2(0.0, 0.0), vec2(0.0, "
"0.0));\n"
"}\n";
GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
ASSERT_NE(0u, shader);
glDeleteShader(shader);
}
// Test that two constructors which have vec4 and mat2 parameters get disambiguated (issue in
// HLSL).
TEST_P(GLSLTest_ES3, AmbiguousConstructorCall2x2)
......
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