Commit f7843da2 by Ian Elliott Committed by Angle LUCI CQ

Create tests for GL_EXT_shader_framebuffer_fetch extension

This CL refactors most of the existing tests for the GL_EXT_shader_framebuffer_fetch_non_coherent extension, sharing shader and test code with new tests for the coherent extension. Bug: b/188095445 Change-Id: I23eac5dae9055f1c8f9eeb9c33429fd1091e68fb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2923323Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent baca10b7
......@@ -65,9 +65,9 @@
5981 PIXEL4ORXL GLES : VulkanExternalImageTest.TextureFormatCompatChromiumFd/* = SKIP
5946 PIXEL4ORXL VULKAN : TransformFeedbackTestES32.PrimitivesWrittenAndGenerated/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchNonCoherentES31.DrawFetchBlitDrawFetch/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchNonCoherentES31.DrawNonFetchDrawFetchWithDifferentAttachments/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchNonCoherentES31.DrawNonFetchDrawFetchWithDifferentPrograms/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchES31.DrawFetchBlitDrawFetch_NonCoherent/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchES31.DrawNonFetchDrawFetchWithDifferentAttachments_NonCoherent/* = SKIP
5947 PIXEL4ORXL VULKAN : FramebufferFetchES31.DrawNonFetchDrawFetchWithDifferentPrograms_NonCoherent/* = SKIP
5981 PIXEL4ORXL VULKAN : BlitFramebufferANGLETest.BlitWithDepthDefaultToUser/* = SKIP
5981 PIXEL4ORXL VULKAN : BlitFramebufferANGLETest.BlitWithDepthUserToDefault/* = SKIP
5981 PIXEL4ORXL VULKAN : ClearTestES3.MaskedClearHeterogeneousAttachments/* = SKIP
......
......@@ -3,8 +3,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ExternalBufferTest:
// Tests the correctness of EXT_shader_framebuffer_fetch_non_coherent extension.
// FramebufferFetchTest:
// Tests the correctness of the EXT_shader_framebuffer_fetch and the
// EXT_shader_framebuffer_fetch_non_coherent extensions.
//
#include "test_utils/ANGLETest.h"
......@@ -13,66 +14,20 @@
namespace angle
{
//
// Shared Vertex Shaders for the tests below
//
// A 1.0 GLSL vertex shader
static constexpr char k100VS[] = R"(#version 100
attribute vec4 a_position;
class FramebufferFetchNonCoherentES31 : public ANGLETest
{
protected:
static constexpr GLuint kMaxColorBuffer = 4u;
static constexpr GLuint kViewportWidth = 16u;
static constexpr GLuint kViewportHeight = 16u;
FramebufferFetchNonCoherentES31()
{
setWindowWidth(16);
setWindowHeight(16);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
void render(GLuint coordLoc, GLboolean isFramebufferFetchProgram)
{
const GLfloat coords[] = {
-1.0f, -1.0f, +1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f,
};
const GLushort indices[] = {
0, 1, 2, 2, 3, 0,
};
glViewport(0, 0, kViewportWidth, kViewportHeight);
GLBuffer coordinatesBuffer;
GLBuffer elementsBuffer;
glBindBuffer(GL_ARRAY_BUFFER, coordinatesBuffer);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)sizeof(coords), coords, GL_STATIC_DRAW);
glEnableVertexAttribArray(coordLoc);
glVertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)sizeof(indices), &indices[0],
GL_STATIC_DRAW);
if (isFramebufferFetchProgram)
{
glFramebufferFetchBarrierEXT();
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
ASSERT_GL_NO_ERROR();
}
};
// Testing EXT_shader_framebuffer_fetch_non_coherent with inout qualifier
TEST_P(FramebufferFetchNonCoherentES31, BasicInout)
void main (void)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
gl_Position = a_position;
})";
constexpr char kVS[] = R"(#version 310 es
// A 3.1 GLSL vertex shader
static constexpr char k310VS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
......@@ -80,61 +35,117 @@ void main (void)
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
//
// Shared simple (i.e. no framebuffer fetch) Fragment Shaders for the tests below
//
// Simple (i.e. no framebuffer fetch) 3.1 GLSL fragment shader that writes to 1 attachment
static constexpr char k310NoFetch1AttachmentFS[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
o_color = u_color;
})";
GLProgram program;
program.makeRaster(kVS, kFS);
glUseProgram(program);
//
// Shared Coherent Fragment Shaders for the tests below
//
// Coherent version of a 1.0 GLSL fragment shader that uses gl_LastFragData
static constexpr char k100CoherentFS[] = R"(#version 100
#extension GL_EXT_shader_framebuffer_fetch : require
mediump vec4 gl_LastFragData[gl_MaxDrawBuffers];
uniform highp vec4 u_color;
ASSERT_GL_NO_ERROR();
void main (void)
{
gl_FragColor = u_color + gl_LastFragData[0];
})";
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> greenColor(kViewportWidth * kViewportHeight, GLColor::green);
GLTexture colorBufferTex;
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
// Coherent version of a 3.1 GLSL fragment shader that writes to 1 attachment
static constexpr char k310Coherent1AttachmentFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch : require
layout(location = 0) inout highp vec4 o_color;
ASSERT_GL_NO_ERROR();
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
float color[4] = {1.0f, 0.0f, 0.0f, 1.0f};
GLint colorLocation = glGetUniformLocation(program, "u_color");
glUniform4fv(colorLocation, 1, color);
// Coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments
static constexpr char k310Coherent4AttachmentFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch : require
layout(location = 0) inout highp vec4 o_color0;
layout(location = 1) inout highp vec4 o_color1;
layout(location = 2) inout highp vec4 o_color2;
layout(location = 3) inout highp vec4 o_color3;
uniform highp vec4 u_color;
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, GL_TRUE);
void main (void)
{
o_color0 += u_color;
o_color1 += u_color;
o_color2 += u_color;
o_color3 += u_color;
})";
ASSERT_GL_NO_ERROR();
// Coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments via an inout
// array
static constexpr char k310Coherent4AttachmentArrayFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch : require
layout(location = 0) inout highp vec4 o_color[4];
uniform highp vec4 u_color;
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
void main (void)
{
o_color[0] += u_color;
o_color[1] += u_color;
o_color[2] += u_color;
o_color[3] += u_color;
})";
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments with the order of
// non-fetch program and fetch program with different attachments (version 1)
static constexpr char k310CoherentDifferent4AttachmentFS1[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch : require
layout(location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(location = 2) inout highp vec4 o_color2;
layout(location = 3) out highp vec4 o_color3;
uniform highp vec4 u_color;
// Testing EXT_shader_framebuffer_fetch_non_coherent with gl_LastFragData
TEST_P(FramebufferFetchNonCoherentES31, BasicLastFragData)
void main (void)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
o_color0 += u_color;
o_color1 = u_color;
o_color2 += u_color;
o_color3 = u_color;
})";
constexpr char kVS[] = R"(#version 100
attribute vec4 a_position;
// Coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments with the order
// of non-fetch program and fetch program with different attachments (version 2)
static constexpr char k310CoherentDifferent4AttachmentFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch : require
layout(location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(location = 2) out highp vec4 o_color2;
layout(location = 3) inout highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
gl_Position = a_position;
o_color0 += u_color;
o_color1 = u_color;
o_color2 = u_color;
o_color3 += u_color;
})";
constexpr char kFS[] = R"(#version 100
//
// Shared Non-Coherent Fragment Shaders for the tests below
//
// Non-coherent version of a 1.0 GLSL fragment shader that uses gl_LastFragData
static constexpr char k100NonCoherentFS[] = R"(#version 100
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent) mediump vec4 gl_LastFragData[gl_MaxDrawBuffers];
uniform highp vec4 u_color;
......@@ -144,73 +155,234 @@ void main (void)
gl_FragColor = u_color + gl_LastFragData[0];
})";
GLProgram program;
program.makeRaster(kVS, kFS);
glUseProgram(program);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> greenColor(kViewportWidth * kViewportHeight, GLColor::green);
GLTexture colorBufferTex;
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
ASSERT_GL_NO_ERROR();
float color[4] = {1.0f, 0.0f, 0.0f, 1.0f};
GLint colorLocation = glGetUniformLocation(program, "u_color");
glUniform4fv(colorLocation, 1, color);
// Non-coherent version of a 3.1 GLSL fragment shader that writes to 1 attachment
static constexpr char k310NonCoherent1AttachmentFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, GL_TRUE);
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
ASSERT_GL_NO_ERROR();
// Non-coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments
static constexpr char k310NonCoherent4AttachmentFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(noncoherent, location = 1) inout highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(noncoherent, location = 3) inout highp vec4 o_color3;
uniform highp vec4 u_color;
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
void main (void)
{
o_color0 += u_color;
o_color1 += u_color;
o_color2 += u_color;
o_color3 += u_color;
})";
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Non-coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments via an inout
// array
static constexpr char k310NonCoherent4AttachmentArrayFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color[4];
uniform highp vec4 u_color;
// Testing EXT_shader_framebuffer_fetch_non_coherent with multiple render target
TEST_P(FramebufferFetchNonCoherentES31, MultipleRenderTarget)
void main (void)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
o_color[0] += u_color;
o_color[1] += u_color;
o_color[2] += u_color;
o_color[3] += u_color;
})";
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
// Non-coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments with the order
// of non-fetch program and fetch program with different attachments (version 1)
static constexpr char k310NonCoherentDifferent4AttachmentFS1[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(location = 3) out highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
gl_Position = a_position;
o_color0 += u_color;
o_color1 = u_color;
o_color2 += u_color;
o_color3 = u_color;
})";
constexpr char kFS[] = R"(#version 310 es
// Non-coherent version of a 3.1 GLSL fragment shader that writes to 4 attachments with the order
// of non-fetch program and fetch program with different attachments (version 2)
static constexpr char k310NonCoherentDifferent4AttachmentFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(noncoherent, location = 1) inout highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(location = 1) out highp vec4 o_color1;
layout(location = 2) out highp vec4 o_color2;
layout(noncoherent, location = 3) inout highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
o_color0 += u_color;
o_color1 += u_color;
o_color2 += u_color;
o_color1 = u_color;
o_color2 = u_color;
o_color3 += u_color;
})";
GLProgram program;
program.makeRaster(kVS, kFS);
glUseProgram(program);
class FramebufferFetchES31 : public ANGLETest
{
protected:
static constexpr GLuint kMaxColorBuffer = 4u;
static constexpr GLuint kViewportWidth = 16u;
static constexpr GLuint kViewportHeight = 16u;
FramebufferFetchES31()
{
setWindowWidth(16);
setWindowHeight(16);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
mCoherentExtension = false;
}
enum WhichExtension
{
COHERENT,
NON_COHERENT,
};
void setWhichExtension(WhichExtension whichExtension)
{
mCoherentExtension = (whichExtension == COHERENT) ? true : false;
}
enum WhichFragmentShader
{
GLSL100,
GLSL310_NO_FETCH_1ATTACHMENT,
GLSL310_1ATTACHMENT,
GLSL310_4ATTACHMENT,
GLSL310_4ATTACHMENT_ARRAY,
GLSL310_4ATTACHMENT_DIFFERENT1,
GLSL310_4ATTACHMENT_DIFFERENT2,
};
const char *getFragmentShader(WhichFragmentShader whichFragmentShader)
{
if (mCoherentExtension)
{
switch (whichFragmentShader)
{
case GLSL100:
return k100CoherentFS;
case GLSL310_NO_FETCH_1ATTACHMENT:
return k310NoFetch1AttachmentFS;
case GLSL310_1ATTACHMENT:
return k310Coherent1AttachmentFS;
case GLSL310_4ATTACHMENT:
return k310Coherent4AttachmentFS;
case GLSL310_4ATTACHMENT_ARRAY:
return k310Coherent4AttachmentArrayFS;
case GLSL310_4ATTACHMENT_DIFFERENT1:
return k310CoherentDifferent4AttachmentFS1;
case GLSL310_4ATTACHMENT_DIFFERENT2:
return k310CoherentDifferent4AttachmentFS2;
}
}
else
{
switch (whichFragmentShader)
{
case GLSL100:
return k100NonCoherentFS;
case GLSL310_NO_FETCH_1ATTACHMENT:
return k310NoFetch1AttachmentFS;
case GLSL310_1ATTACHMENT:
return k310NonCoherent1AttachmentFS;
case GLSL310_4ATTACHMENT:
return k310NonCoherent4AttachmentFS;
case GLSL310_4ATTACHMENT_ARRAY:
return k310NonCoherent4AttachmentArrayFS;
case GLSL310_4ATTACHMENT_DIFFERENT1:
return k310NonCoherentDifferent4AttachmentFS1;
case GLSL310_4ATTACHMENT_DIFFERENT2:
return k310NonCoherentDifferent4AttachmentFS2;
}
}
}
void render(GLuint coordLoc, GLboolean needsFramebufferFetchBarrier)
{
const GLfloat coords[] = {
-1.0f, -1.0f, +1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f,
};
const GLushort indices[] = {
0, 1, 2, 2, 3, 0,
};
glViewport(0, 0, kViewportWidth, kViewportHeight);
GLBuffer coordinatesBuffer;
GLBuffer elementsBuffer;
glBindBuffer(GL_ARRAY_BUFFER, coordinatesBuffer);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)sizeof(coords), coords, GL_STATIC_DRAW);
glEnableVertexAttribArray(coordLoc);
glVertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)sizeof(indices), &indices[0],
GL_STATIC_DRAW);
if (needsFramebufferFetchBarrier)
{
glFramebufferFetchBarrierEXT();
}
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
ASSERT_GL_NO_ERROR();
}
void BasicTest(GLProgram program)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> greenColor(kViewportWidth * kViewportHeight, GLColor::green);
GLTexture colorBufferTex;
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex,
0);
ASSERT_GL_NO_ERROR();
float color[4] = {1.0f, 0.0f, 0.0f, 1.0f};
GLint colorLocation = glGetUniformLocation(program, "u_color");
glUniform4fv(colorLocation, 1, color);
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void MultipleRenderTargetTest(GLProgram program)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> color0(kViewportWidth * kViewportHeight, GLColor::black);
......@@ -247,7 +419,7 @@ void main (void)
glUniform4fv(colorLocation, 1, color);
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, GL_TRUE);
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
......@@ -261,40 +433,10 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::white);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with multiple render target using inout array
TEST_P(FramebufferFetchNonCoherentES31, MultipleRenderTargetWithInoutArray)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color[4];
uniform highp vec4 u_color;
void main (void)
{
o_color[0] += u_color;
o_color[1] += u_color;
o_color[2] += u_color;
o_color[3] += u_color;
})";
GLProgram program;
program.makeRaster(kVS, kFS);
glUseProgram(program);
ASSERT_GL_NO_ERROR();
}
void MultipleRenderTargetArrayTest(GLProgram program)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> color0(kViewportWidth * kViewportHeight, GLColor::black);
......@@ -331,7 +473,7 @@ void main (void)
glUniform4fv(colorLocation, 1, color);
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, GL_TRUE);
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
......@@ -345,37 +487,10 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::white);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with multiple draw
TEST_P(FramebufferFetchNonCoherentES31, MultipleDraw)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
GLProgram program;
program.makeRaster(kVS, kFS);
glUseProgram(program);
ASSERT_GL_NO_ERROR();
}
void MultipleDrawTest(GLProgram program)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> greenColor(kViewportWidth * kViewportHeight, GLColor::green);
......@@ -383,7 +498,8 @@ void main (void)
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex,
0);
ASSERT_GL_NO_ERROR();
......@@ -392,57 +508,23 @@ void main (void)
glUniform4fv(colorLocation, 1, color1);
GLint positionLocation = glGetAttribLocation(program, "a_position");
render(positionLocation, GL_TRUE);
render(positionLocation, !mCoherentExtension);
float color2[4] = {0.0f, 0.0f, 1.0f, 1.0f};
glUniform4fv(colorLocation, 1, color2);
render(positionLocation, GL_TRUE);
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::white);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with the order of non-fetch program and fetch
// program
TEST_P(FramebufferFetchNonCoherentES31, DrawNonFetchDrawFetch)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color = u_color;
})";
constexpr char kFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
}
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(kVS, kFS1);
void DrawNonFetchDrawFetchTest(GLProgram programNonFetch, GLProgram programFetch)
{
glUseProgram(programNonFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebuffer;
......@@ -452,7 +534,8 @@ void main (void)
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex,
0);
ASSERT_GL_NO_ERROR();
......@@ -461,13 +544,13 @@ void main (void)
glUniform4fv(colorLocationNonFetch, 1, colorRed);
GLint positionLocationNonFetch = glGetAttribLocation(programNonFetch, "a_position");
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
programFetch.makeRaster(kVS, kFS2);
glUseProgram(programFetch);
float colorGreen[4] = {0.0f, 1.0f, 0.0f, 1.0f};
......@@ -475,7 +558,9 @@ void main (void)
glUniform4fv(colorLocationFetch, 1, colorGreen);
GLint positionLocationFetch = glGetAttribLocation(programFetch, "a_position");
render(positionLocationFetch, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocationFetch, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
......@@ -483,6 +568,7 @@ void main (void)
glUseProgram(programNonFetch);
glUniform4fv(colorLocationNonFetch, 1, colorRed);
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
......@@ -491,52 +577,20 @@ void main (void)
glUseProgram(programFetch);
glUniform4fv(colorLocationFetch, 1, colorGreen);
render(positionLocationFetch, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocationFetch, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with the order of fetch program and non-fetch
// program
TEST_P(FramebufferFetchNonCoherentES31, DrawFetchDrawNonFetch)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color = u_color;
})";
constexpr char kFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
}
GLProgram programNonFetch, programFetch;
programFetch.makeRaster(kVS, kFS2);
void DrawFetchDrawNonFetchTest(GLProgram programNonFetch, GLProgram programFetch)
{
glUseProgram(programFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebuffer;
......@@ -546,7 +600,8 @@ void main (void)
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex,
0);
ASSERT_GL_NO_ERROR();
......@@ -555,21 +610,21 @@ void main (void)
glUniform4fv(colorLocationFetch, 1, colorRed);
GLint positionLocationFetch = glGetAttribLocation(programFetch, "a_position");
render(positionLocationFetch, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocationFetch, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
programNonFetch.makeRaster(kVS, kFS1);
glUseProgram(programNonFetch);
GLint colorLocationNonFetch = glGetUniformLocation(programNonFetch, "u_color");
glUniform4fv(colorLocationNonFetch, 1, colorRed);
GLint positionLocationNonFetch = glGetAttribLocation(programNonFetch, "a_position");
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
......@@ -577,14 +632,16 @@ void main (void)
float colorGreen[4] = {0.0f, 1.0f, 0.0f, 1.0f};
glUseProgram(programFetch);
glUniform4fv(colorLocationFetch, 1, colorGreen);
render(positionLocationFetch, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocationFetch, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
glUseProgram(programNonFetch);
glUniform4fv(colorLocationNonFetch, 1, colorRed);
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
......@@ -592,51 +649,12 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with the order of non-fetch program and fetch
// program with different attachments
TEST_P(FramebufferFetchNonCoherentES31, DrawNonFetchDrawFetchWithDifferentAttachments)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color = u_color;
})";
constexpr char kFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(location = 3) out highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
o_color0 += u_color;
o_color1 = u_color;
o_color2 += u_color;
o_color3 = u_color;
})";
}
GLProgram programNonFetch, programFetch1;
programNonFetch.makeRaster(kVS, kFS1);
void DrawNonFetchDrawFetchWithDifferentAttachmentsTest(GLProgram programNonFetch,
GLProgram programFetch)
{
glUseProgram(programNonFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebuffer;
......@@ -655,15 +673,13 @@ void main (void)
glUniform4fv(colorLocationNonFetch, 1, colorRed);
GLint positionLocationNonFetch = glGetAttribLocation(programNonFetch, "a_position");
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
programFetch1.makeRaster(kVS, kFS2);
glUseProgram(programFetch1);
glUseProgram(programFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebufferMRT1;
......@@ -692,15 +708,15 @@ void main (void)
colorBufferTex1[i], 0);
}
glDrawBuffers(kMaxColorBuffer, &colorAttachments[0]);
ASSERT_GL_NO_ERROR();
GLint colorLocation = glGetUniformLocation(programFetch1, "u_color");
GLint colorLocation = glGetUniformLocation(programFetch, "u_color");
glUniform4fv(colorLocation, 1, colorRed);
GLint positionLocation = glGetAttribLocation(programFetch1, "a_position");
render(positionLocation, GL_TRUE);
GLint positionLocation = glGetAttribLocation(programFetch, "a_position");
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -734,12 +750,12 @@ void main (void)
colorBufferTex2[i], 0);
}
glDrawBuffers(kMaxColorBuffer, &colorAttachments[0]);
ASSERT_GL_NO_ERROR();
glUniform4fv(colorLocation, 1, colorRed);
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -752,69 +768,14 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with the order of non-fetch program and fetch
// with different programs
TEST_P(FramebufferFetchNonCoherentES31, DrawNonFetchDrawFetchWithDifferentPrograms)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color = u_color;
})";
constexpr char kFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(location = 3) out highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
o_color0 += u_color;
o_color1 = u_color;
o_color2 += u_color;
o_color3 = u_color;
})";
constexpr char kFS3[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(location = 2) out highp vec4 o_color2;
layout(noncoherent, location = 3) inout highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
o_color0 += u_color;
o_color1 = u_color;
o_color2 = u_color;
o_color3 += u_color;
})";
}
GLProgram programNonFetch, programFetch1, programFetch2;
programNonFetch.makeRaster(kVS, kFS1);
void DrawNonFetchDrawFetchWithDifferentProgramsTest(GLProgram programNonFetch,
GLProgram programFetch1,
GLProgram programFetch2)
{
glUseProgram(programNonFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
std::vector<GLColor> greenColor(kViewportWidth * kViewportHeight, GLColor::green);
......@@ -831,15 +792,13 @@ void main (void)
glUniform4fv(colorLocationNonFetch, 1, colorRed);
GLint positionLocationNonFetch = glGetAttribLocation(programNonFetch, "a_position");
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocationNonFetch, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
programFetch1.makeRaster(kVS, kFS2);
glUseProgram(programFetch1);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebufferMRT1;
......@@ -867,15 +826,15 @@ void main (void)
colorBufferTex1[i], 0);
}
glDrawBuffers(kMaxColorBuffer, &colorAttachments[0]);
ASSERT_GL_NO_ERROR();
GLint colorLocation = glGetUniformLocation(programFetch1, "u_color");
glUniform4fv(colorLocation, 1, colorRed);
GLint positionLocation = glGetAttribLocation(programFetch1, "a_position");
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -887,9 +846,7 @@ void main (void)
glReadBuffer(colorAttachments[3]);
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
programFetch2.makeRaster(kVS, kFS3);
glUseProgram(programFetch2);
ASSERT_GL_NO_ERROR();
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
......@@ -899,8 +856,9 @@ void main (void)
glUniform4fv(colorLocation1, 1, colorRed);
GLint positionLocation1 = glGetAttribLocation(programFetch2, "a_position");
render(positionLocation1, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation1, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -913,42 +871,11 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with the order of draw fetch, blit and draw
// fetch
TEST_P(FramebufferFetchNonCoherentES31, DrawFetchBlitDrawFetch)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
constexpr char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color0;
layout(location = 1) out highp vec4 o_color1;
layout(noncoherent, location = 2) inout highp vec4 o_color2;
layout(location = 3) out highp vec4 o_color3;
uniform highp vec4 u_color;
void main (void)
{
o_color0 += u_color;
o_color1 = u_color;
o_color2 += u_color;
o_color3 = u_color;
})";
}
GLProgram programFetch;
programFetch.makeRaster(kVS, kFS1);
void DrawFetchBlitDrawFetchTest(GLProgram programNonFetch, GLProgram programFetch)
{
glUseProgram(programFetch);
ASSERT_GL_NO_ERROR();
GLFramebuffer framebufferMRT1;
......@@ -977,7 +904,6 @@ void main (void)
colorBufferTex1[i], 0);
}
glDrawBuffers(kMaxColorBuffer, &colorAttachments[0]);
ASSERT_GL_NO_ERROR();
float colorRed[4] = {1.0f, 0.0f, 0.0f, 1.0f};
......@@ -985,8 +911,9 @@ void main (void)
glUniform4fv(colorLocation, 1, colorRed);
GLint positionLocation = glGetAttribLocation(programFetch, "a_position");
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -1010,9 +937,8 @@ void main (void)
glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, framebufferColor);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, framebufferMRT1);
glBlitFramebuffer(0, 0, kViewportWidth, kViewportHeight, 0, 0, kViewportWidth, kViewportHeight,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBlitFramebuffer(0, 0, kViewportWidth, kViewportHeight, 0, 0, kViewportWidth,
kViewportHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBindFramebuffer(GL_FRAMEBUFFER, framebufferMRT1);
......@@ -1028,8 +954,9 @@ void main (void)
float colorGreen[4] = {0.0f, 1.0f, 0.0f, 1.0f};
glUniform4fv(colorLocation, 1, colorGreen);
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
glReadBuffer(colorAttachments[0]);
......@@ -1042,41 +969,10 @@ void main (void)
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::green);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Testing EXT_shader_framebuffer_fetch_non_coherent with program pipeline
TEST_P(FramebufferFetchNonCoherentES31, ProgramPipeline)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
const char kVS[] = R"(#version 310 es
in highp vec4 a_position;
void main (void)
{
gl_Position = a_position;
})";
constexpr char kFS1[] = R"(#version 310 es
layout(location = 0) out highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color = u_color;
})";
constexpr char kFS2[] = R"(#version 310 es
#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require
layout(noncoherent, location = 0) inout highp vec4 o_color;
uniform highp vec4 u_color;
void main (void)
{
o_color += u_color;
})";
}
void ProgramPipelineTest(const char *kVS, const char *kFS1, const char *kFS2)
{
GLProgram programVert, programNonFetch, programFetch;
const char *sourceArray[3] = {kVS, kFS1, kFS2};
......@@ -1117,21 +1013,20 @@ void main (void)
glBindTexture(GL_TEXTURE_2D, colorBufferTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kViewportWidth, kViewportHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, greenColor.data());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTex,
0);
ASSERT_GL_NO_ERROR();
glActiveShaderProgram(pipeline1, programNonFetch);
float colorRed[4] = {1.0f, 0.0f, 0.0f, 1.0f};
GLint colorLocationNonFetch = glGetUniformLocation(programNonFetch, "u_color");
glUniform4fv(colorLocationNonFetch, 1, colorRed);
ASSERT_GL_NO_ERROR();
glActiveShaderProgram(pipeline1, programVert);
GLint positionLocation = glGetAttribLocation(programVert, "a_position");
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocation, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
......@@ -1146,8 +1041,9 @@ void main (void)
GLint colorLocationFetch = glGetUniformLocation(programFetch, "u_color");
glUniform4fv(colorLocationFetch, 1, colorGreen);
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
......@@ -1163,8 +1059,8 @@ void main (void)
ASSERT_GL_NO_ERROR();
// Render without regard to glFramebufferFetchBarrierEXT()
render(positionLocation, GL_FALSE);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::red);
......@@ -1177,17 +1073,327 @@ void main (void)
glActiveShaderProgram(pipeline4, programFetch);
colorLocationFetch = glGetUniformLocation(programFetch, "u_color");
glUniform4fv(colorLocationFetch, 1, colorGreen);
render(positionLocation, GL_TRUE);
// Render potentially with a glFramebufferFetchBarrierEXT() depending on the [non-]coherent
// extension being used
render(positionLocation, !mCoherentExtension);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(kViewportWidth / 2, kViewportHeight / 2, GLColor::yellow);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
bool mCoherentExtension;
};
// Test coherent extension with inout qualifier
TEST_P(FramebufferFetchES31, BasicInout_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
BasicTest(program);
}
// Test non-coherent extension with inout qualifier
TEST_P(FramebufferFetchES31, BasicInout_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
BasicTest(program);
}
// Test coherent extension with gl_LastFragData
TEST_P(FramebufferFetchES31, BasicLastFragData_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram program;
program.makeRaster(k100VS, getFragmentShader(GLSL100));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
BasicTest(program);
}
// Test non-coherent extension with gl_LastFragData
TEST_P(FramebufferFetchES31, BasicLastFragData_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram program;
program.makeRaster(k100VS, getFragmentShader(GLSL100));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
BasicTest(program);
}
// Testing coherent extension with multiple render target
TEST_P(FramebufferFetchES31, MultipleRenderTarget_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleRenderTargetTest(program);
}
// Testing non-coherent extension with multiple render target
TEST_P(FramebufferFetchES31, MultipleRenderTarget_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleRenderTargetTest(program);
}
// Testing non-coherent extension with multiple render target using inout array
TEST_P(FramebufferFetchES31, MultipleRenderTargetWithInoutArray_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleRenderTargetTest(program);
}
// Testing coherent extension with multiple render target using inout array
TEST_P(FramebufferFetchES31, MultipleRenderTargetWithInoutArray_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleRenderTargetTest(program);
}
// Test coherent extension with multiple draw
TEST_P(FramebufferFetchES31, MultipleDraw_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleDrawTest(program);
}
// Test non-coherent extension with multiple draw
TEST_P(FramebufferFetchES31, MultipleDraw_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram program;
program.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
glUseProgram(program);
ASSERT_GL_NO_ERROR();
MultipleDrawTest(program);
}
// Testing coherent extension with the order of non-fetch program and fetch program
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetch_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchTest(programNonFetch, programFetch);
}
// Testing non-coherent extension with the order of non-fetch program and fetch program
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetch_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchTest(programNonFetch, programFetch);
}
// Testing coherent extension with the order of fetch program and non-fetch program
TEST_P(FramebufferFetchES31, DrawFetchDrawNonFetch_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
ASSERT_GL_NO_ERROR();
DrawFetchDrawNonFetchTest(programNonFetch, programFetch);
}
// Testing non-coherent extension with the order of fetch program and non-fetch program
TEST_P(FramebufferFetchES31, DrawFetchDrawNonFetch_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_1ATTACHMENT));
ASSERT_GL_NO_ERROR();
DrawFetchDrawNonFetchTest(programNonFetch, programFetch);
}
// Testing coherent extension with the order of non-fetch program and fetch program with
// different attachments
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetchWithDifferentAttachments_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchWithDifferentAttachmentsTest(programNonFetch, programFetch);
}
// Testing non-coherent extension with the order of non-fetch program and fetch program with
// different attachments
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetchWithDifferentAttachments_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchWithDifferentAttachmentsTest(programNonFetch, programFetch);
}
// Testing coherent extension with the order of non-fetch program and fetch with different
// programs
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetchWithDifferentPrograms_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram programNonFetch, programFetch1, programFetch2;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch1.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
programFetch2.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT2));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchWithDifferentProgramsTest(programNonFetch, programFetch1, programFetch2);
}
// Testing non-coherent extension with the order of non-fetch program and fetch with different
// programs
TEST_P(FramebufferFetchES31, DrawNonFetchDrawFetchWithDifferentPrograms_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram programNonFetch, programFetch1, programFetch2;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch1.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
programFetch2.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT2));
ASSERT_GL_NO_ERROR();
DrawNonFetchDrawFetchWithDifferentProgramsTest(programNonFetch, programFetch1, programFetch2);
}
// Testing coherent extension with the order of draw fetch, blit and draw fetch
TEST_P(FramebufferFetchES31, DrawFetchBlitDrawFetch_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
ASSERT_GL_NO_ERROR();
DrawFetchBlitDrawFetchTest(programNonFetch, programFetch);
}
// Testing non-coherent extension with the order of draw fetch, blit and draw fetch
TEST_P(FramebufferFetchES31, DrawFetchBlitDrawFetch_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
GLProgram programNonFetch, programFetch;
programNonFetch.makeRaster(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT));
programFetch.makeRaster(k310VS, getFragmentShader(GLSL310_4ATTACHMENT_DIFFERENT1));
ASSERT_GL_NO_ERROR();
DrawFetchBlitDrawFetchTest(programNonFetch, programFetch);
}
// Testing coherent extension with program pipeline
TEST_P(FramebufferFetchES31, ProgramPipeline_Coherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch"));
setWhichExtension(COHERENT);
ProgramPipelineTest(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT),
getFragmentShader(GLSL310_1ATTACHMENT));
}
// Testing non-coherent extension with program pipeline
TEST_P(FramebufferFetchES31, ProgramPipeline_NonCoherent)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
setWhichExtension(NON_COHERENT);
ProgramPipelineTest(k310VS, getFragmentShader(GLSL310_NO_FETCH_1ATTACHMENT),
getFragmentShader(GLSL310_1ATTACHMENT));
}
// TODO: http://anglebug.com/5792
TEST_P(FramebufferFetchNonCoherentES31, DISABLED_UniformUsageCombinations)
TEST_P(FramebufferFetchES31, DISABLED_UniformUsageCombinations)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
......@@ -1346,7 +1552,7 @@ void main()
// Testing that binding the location value using GLES API is conflicted to the location value of the
// fragment inout.
TEST_P(FramebufferFetchNonCoherentES31, FixedUniformLocation)
TEST_P(FramebufferFetchES31, FixedUniformLocation)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_framebuffer_fetch_non_coherent"));
......@@ -1399,6 +1605,6 @@ void main (void)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FramebufferFetchNonCoherentES31);
ANGLE_INSTANTIATE_TEST_ES31(FramebufferFetchNonCoherentES31);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FramebufferFetchES31);
ANGLE_INSTANTIATE_TEST_ES31(FramebufferFetchES31);
} // namespace angle
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