Commit 24180607 by Corentin Wallez Committed by Commit Bot

Allow rectangle textures to be sample with texture() in ESSL3

This makes them consistent with the other texture types. Also adds a test for using texture(sampler2DRect, ...). BUG=chromium:757974 BUG=angleproject:1650 Change-Id: Ie966da928ae0c83850da1e530e72c0d501909394 Reviewed-on: https://chromium-review.googlesource.com/946675 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 7618eaf9
...@@ -94,8 +94,8 @@ ImmutableString TOutputGLSL::translateTextureFunction(const ImmutableString &nam ...@@ -94,8 +94,8 @@ ImmutableString TOutputGLSL::translateTextureFunction(const ImmutableString &nam
nullptr}; nullptr};
static const char *legacyToCoreRename[] = { static const char *legacyToCoreRename[] = {
"texture2D", "texture", "texture2DProj", "textureProj", "texture2DLod", "textureLod", "texture2D", "texture", "texture2DProj", "textureProj", "texture2DLod", "textureLod",
"texture2DProjLod", "textureProjLod", "texture2DRect", "texture", "textureCube", "texture", "texture2DProjLod", "textureProjLod", "texture2DRect", "texture", "texture2DRectProj",
"textureCubeLod", "textureLod", "textureProj", "textureCube", "texture", "textureCubeLod", "textureLod",
// Extensions // Extensions
"texture2DLodEXT", "textureLod", "texture2DProjLodEXT", "textureProjLod", "texture2DLodEXT", "textureLod", "texture2DProjLodEXT", "textureProjLod",
"textureCubeLodEXT", "textureLod", "texture2DGradEXT", "textureGrad", "textureCubeLodEXT", "textureLod", "texture2DGradEXT", "textureGrad",
......
...@@ -287,6 +287,13 @@ GROUP BEGIN ARB_texture_rectangle ...@@ -287,6 +287,13 @@ GROUP BEGIN ARB_texture_rectangle
vec4 texture2DRect(sampler2DRect, vec2); vec4 texture2DRect(sampler2DRect, vec2);
vec4 texture2DRectProj(sampler2DRect, vec3); vec4 texture2DRectProj(sampler2DRect, vec3);
vec4 texture2DRectProj(sampler2DRect, vec4); vec4 texture2DRectProj(sampler2DRect, vec4);
DEFAULT METADATA {"level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "ARB_texture_rectangle"}
// We don't have a rectangle texture extension for OpenGL ES however based on the behavior of
// rectangle texture in desktop OpenGL, they should be sampled with a "texture" overload in
// GLSL version that have such an overload. This is the case for ESSL3 and above.
vec4 texture(sampler2DRect, vec2);
vec4 textureProj(sampler2DRect, vec3);
vec4 textureProj(sampler2DRect, vec4);
GROUP END ARB_texture_rectangle GROUP END ARB_texture_rectangle
// The *Grad* variants are new to both vertex and fragment shaders; the fragment // The *Grad* variants are new to both vertex and fragment shaders; the fragment
......
...@@ -281,8 +281,8 @@ TEST_P(TextureRectangleTest, FramebufferTexture2DLevel) ...@@ -281,8 +281,8 @@ TEST_P(TextureRectangleTest, FramebufferTexture2DLevel)
ASSERT_GL_ERROR(GL_INVALID_VALUE); ASSERT_GL_ERROR(GL_INVALID_VALUE);
} }
// Test sampling from a rectangle texture // Test sampling from a rectangle texture using texture2DRect in ESSL1
TEST_P(TextureRectangleTest, SamplingFromRectangle) TEST_P(TextureRectangleTest, SamplingFromRectangleESSL1)
{ {
ANGLE_SKIP_TEST_IF(!checkExtensionSupported()); ANGLE_SKIP_TEST_IF(!checkExtensionSupported());
...@@ -321,6 +321,49 @@ TEST_P(TextureRectangleTest, SamplingFromRectangle) ...@@ -321,6 +321,49 @@ TEST_P(TextureRectangleTest, SamplingFromRectangle)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test sampling from a rectangle texture using the texture overload in ESSL3
TEST_P(TextureRectangleTestES3, SamplingFromRectangleESSL3)
{
ANGLE_SKIP_TEST_IF(!checkExtensionSupported());
GLTexture tex;
glBindTexture(GL_TEXTURE_RECTANGLE_ANGLE, tex);
glTexImage2D(GL_TEXTURE_RECTANGLE_ANGLE, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
&GLColor::green);
const std::string vs =
"#version 300 es\n"
"in vec4 position;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(position.xy, 0.0, 1.0);\n"
"}\n";
const std::string fs =
"#version 300 es\n"
"#extension GL_ARB_texture_rectangle : require\n"
"precision mediump float;\n"
"uniform sampler2DRect tex;\n"
"out vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = texture(tex, vec2(0, 0));\n"
"}\n";
ANGLE_GL_PROGRAM(program, vs, fs);
glUseProgram(program);
GLint location = glGetUniformLocation(program, "tex");
ASSERT_NE(-1, location);
glUniform1i(location, 0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
drawQuad(program, "position", 0.5f, 1.0f, false);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
ASSERT_GL_NO_ERROR();
}
// Test attaching a rectangle texture and rendering to it. // Test attaching a rectangle texture and rendering to it.
TEST_P(TextureRectangleTest, RenderToRectangle) TEST_P(TextureRectangleTest, RenderToRectangle)
{ {
......
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