summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
commitfc61780b35af913801d72086456f493f63197da6 (patch)
treef85891288a7bd988da9f0f15ae64e5c63f00d493 /gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp
parent69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff)
parent50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff)
downloadUXP-fc61780b35af913801d72086456f493f63197da6.tar
UXP-fc61780b35af913801d72086456f493f63197da6.tar.gz
UXP-fc61780b35af913801d72086456f493f63197da6.tar.lz
UXP-fc61780b35af913801d72086456f493f63197da6.tar.xz
UXP-fc61780b35af913801d72086456f493f63197da6.zip
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts: # browser/app/profile/firefox.js # browser/components/preferences/jar.mn
Diffstat (limited to 'gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp')
-rwxr-xr-xgfx/angle/src/tests/gl_tests/UniformBufferTest.cpp242
1 files changed, 46 insertions, 196 deletions
diff --git a/gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp b/gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp
index b3577bf30..0d35df177 100755
--- a/gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp
+++ b/gfx/angle/src/tests/gl_tests/UniformBufferTest.cpp
@@ -5,7 +5,6 @@
//
#include "test_utils/ANGLETest.h"
-#include "test_utils/gl_raii.h"
using namespace angle;
@@ -25,7 +24,7 @@ class UniformBufferTest : public ANGLETest
setConfigAlphaBits(8);
}
- void SetUp() override
+ virtual void SetUp()
{
ANGLETest::SetUp();
@@ -63,7 +62,7 @@ class UniformBufferTest : public ANGLETest
ASSERT_GL_NO_ERROR();
}
- void TearDown() override
+ virtual void TearDown()
{
glDeleteBuffers(1, &mUniformBuffer);
glDeleteProgram(mProgram);
@@ -78,6 +77,13 @@ class UniformBufferTest : public ANGLETest
// Basic UBO functionality.
TEST_P(UniformBufferTest, Simple)
{
+ // TODO(jmadill): Figure out why this fails on Intel.
+ if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ std::cout << "Test skipped on Intel." << std::endl;
+ return;
+ }
+
glClear(GL_COLOR_BUFFER_BIT);
float floatData[4] = {0.5f, 0.75f, 0.25f, 1.0f};
@@ -98,6 +104,13 @@ TEST_P(UniformBufferTest, Simple)
// The second step renders a color from a UBO with a non-zero offset.
TEST_P(UniformBufferTest, UniformBufferRange)
{
+ // TODO(jmadill): Figure out why this fails on Intel.
+ if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ std::cout << "Test skipped on Intel." << std::endl;
+ return;
+ }
+
int px = getWindowWidth() / 2;
int py = getWindowHeight() / 2;
@@ -169,6 +182,13 @@ TEST_P(UniformBufferTest, UniformBufferRange)
// Test uniform block bindings.
TEST_P(UniformBufferTest, UniformBufferBindings)
{
+ // TODO(jmadill): Figure out why this fails on Intel.
+ if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ std::cout << "Test skipped on Intel." << std::endl;
+ return;
+ }
+
int px = getWindowWidth() / 2;
int py = getWindowHeight() / 2;
@@ -225,10 +245,11 @@ TEST_P(UniformBufferTest, UnboundUniformBuffer)
// https://code.google.com/p/angleproject/issues/detail?id=965
TEST_P(UniformBufferTest, UniformBufferManyUpdates)
{
- // TODO(jmadill): Figure out why this fails on Intel OpenGL.
- if (IsIntel() && IsOpenGL())
+ // TODO(jmadill): Figure out why this fails on Intel.
+ if (IsIntel() && (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE ||
+ getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE))
{
- std::cout << "Test skipped on Intel OpenGL." << std::endl;
+ std::cout << "Test skipped on Intel." << std::endl;
return;
}
@@ -265,6 +286,13 @@ TEST_P(UniformBufferTest, UniformBufferManyUpdates)
// Use a large number of buffer ranges (compared to the actual size of the UBO)
TEST_P(UniformBufferTest, ManyUniformBufferRange)
{
+ // TODO(jmadill): Figure out why this fails on Intel.
+ if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ std::cout << "Test skipped on Intel." << std::endl;
+ return;
+ }
+
int px = getWindowWidth() / 2;
int py = getWindowHeight() / 2;
@@ -345,116 +373,12 @@ TEST_P(UniformBufferTest, ActiveUniformNames)
const std::string &vertexShaderSource =
"#version 300 es\n"
"in vec2 position;\n"
- "out vec2 v;\n"
- "uniform blockName1 {\n"
- " float f1;\n"
- "} instanceName1;\n"
- "uniform blockName2 {\n"
- " float f2;\n"
- "} instanceName2[1];\n"
- "void main() {\n"
- " v = vec2(instanceName1.f1, instanceName2[0].f2);\n"
- " gl_Position = vec4(position, 0, 1);\n"
- "}";
-
- const std::string &fragmentShaderSource =
- "#version 300 es\n"
- "precision highp float;\n"
- "in vec2 v;\n"
- "out vec4 color;\n"
- "void main() {\n"
- " color = vec4(v, 0, 1);\n"
- "}";
-
- GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
- ASSERT_NE(0u, program);
-
- GLint activeUniformBlocks;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &activeUniformBlocks);
- ASSERT_EQ(2, activeUniformBlocks);
-
- GLint maxLength;
- GLsizei length;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &maxLength);
- std::vector<GLchar> strBlockNameBuffer(maxLength + 1, 0);
- glGetActiveUniformBlockName(program, 0, maxLength, &length, &strBlockNameBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ("blockName1", std::string(&strBlockNameBuffer[0]));
-
- glGetActiveUniformBlockName(program, 1, maxLength, &length, &strBlockNameBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ("blockName2[0]", std::string(&strBlockNameBuffer[0]));
-
- GLint activeUniforms;
- glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &activeUniforms);
-
- ASSERT_EQ(2, activeUniforms);
-
- GLint size;
- GLenum type;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
- std::vector<GLchar> strUniformNameBuffer(maxLength + 1, 0);
- glGetActiveUniform(program, 0, maxLength, &length, &size, &type, &strUniformNameBuffer[0]);
-
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_GLENUM_EQ(GL_FLOAT, type);
- EXPECT_EQ("blockName1.f1", std::string(&strUniformNameBuffer[0]));
-
- glGetActiveUniform(program, 1, maxLength, &length, &size, &type, &strUniformNameBuffer[0]);
-
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_GLENUM_EQ(GL_FLOAT, type);
- EXPECT_EQ("blockName2.f2", std::string(&strUniformNameBuffer[0]));
-}
-
-// Tests active uniforms and blocks when the layout is std140, shared and packed.
-TEST_P(UniformBufferTest, ActiveUniformNumberAndName)
-{
- // TODO(Jiajia): Figure out why this fails on Intel on Mac.
- // This case can pass on Intel Mac-10.11/10.12. But it fails on Intel Mac-10.10.
- if (IsIntel() && IsOSX())
- {
- std::cout << "Test skipped on Intel on Mac." << std::endl;
- return;
- }
-
- // This case fails on all AMD platforms (Mac, Linux, Win).
- // TODO(zmo): This actually passes on certain AMD cards, but we don't have
- // a way to do device specific handling yet.
- if (IsAMD())
- {
- std::cout << "Test skipped on AMD." << std::endl;
- return;
- }
-
- const std::string &vertexShaderSource =
- "#version 300 es\n"
- "in vec2 position;\n"
"out float v;\n"
- "struct S {\n"
- " highp ivec3 a;\n"
- " mediump ivec2 b[4];\n"
- "};\n"
- "layout(std140) uniform blockName0 {\n"
- " S s0;\n"
- " lowp vec2 v0;\n"
- " S s1[2];\n"
- " highp uint u0;\n"
- "};\n"
- "layout(std140) uniform blockName1 {\n"
- " float f1;\n"
- " bool b1;\n"
- "} instanceName1;\n"
- "layout(shared) uniform blockName2 {\n"
- " float f2;\n"
- "};\n"
- "layout(packed) uniform blockName3 {\n"
- " float f3;\n"
- "};\n"
+ "uniform blockName {\n"
+ " float f;\n"
+ "} instanceName;\n"
"void main() {\n"
- " v = instanceName1.f1;\n"
+ " v = instanceName.f;\n"
" gl_Position = vec4(position, 0, 1);\n"
"}";
@@ -467,99 +391,25 @@ TEST_P(UniformBufferTest, ActiveUniformNumberAndName)
" color = vec4(v, 0, 0, 1);\n"
"}";
- ANGLE_GL_PROGRAM(program, vertexShaderSource, fragmentShaderSource);
+ GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
+ ASSERT_NE(0u, program);
- // Note that the packed |blockName3| might (or might not) be optimized out.
GLint activeUniforms;
- glGetProgramiv(program.get(), GL_ACTIVE_UNIFORMS, &activeUniforms);
- EXPECT_GE(activeUniforms, 11);
+ glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &activeUniforms);
- GLint activeUniformBlocks;
- glGetProgramiv(program.get(), GL_ACTIVE_UNIFORM_BLOCKS, &activeUniformBlocks);
- EXPECT_GE(activeUniformBlocks, 3);
+ ASSERT_EQ(1, activeUniforms);
GLint maxLength, size;
GLenum type;
GLsizei length;
- glGetProgramiv(program.get(), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
std::vector<GLchar> strBuffer(maxLength + 1, 0);
+ glGetActiveUniform(program, 0, maxLength, &length, &size, &type, &strBuffer[0]);
- glGetActiveUniform(program.get(), 0, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("s0.a", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 1, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(4, size);
- EXPECT_EQ("s0.b[0]", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 2, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("v0", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 3, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("s1[0].a", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 4, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(4, size);
- EXPECT_EQ("s1[0].b[0]", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 5, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("s1[1].a", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 6, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(4, size);
- EXPECT_EQ("s1[1].b[0]", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 7, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("u0", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 8, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("blockName1.f1", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 9, maxLength, &length, &size, &type, &strBuffer[0]);
- ASSERT_GL_NO_ERROR();
- EXPECT_EQ(1, size);
- EXPECT_EQ("blockName1.b1", std::string(&strBuffer[0]));
-
- glGetActiveUniform(program.get(), 10, maxLength, &length, &size, &type, &strBuffer[0]);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(1, size);
- EXPECT_EQ("f2", std::string(&strBuffer[0]));
-}
-
-// Test that using a very large buffer to back a small uniform block works OK.
-TEST_P(UniformBufferTest, VeryLarge)
-{
- glClear(GL_COLOR_BUFFER_BIT);
- float floatData[4] = {0.5f, 0.75f, 0.25f, 1.0f};
-
- GLsizei bigSize = 4096 * 64;
- std::vector<GLubyte> zero(bigSize, 0);
-
- glBindBuffer(GL_UNIFORM_BUFFER, mUniformBuffer);
- glBufferData(GL_UNIFORM_BUFFER, bigSize, zero.data(), GL_STATIC_DRAW);
- glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(float) * 4, floatData);
-
- glBindBufferBase(GL_UNIFORM_BUFFER, 0, mUniformBuffer);
-
- glUniformBlockBinding(mProgram, mUniformBufferIndex, 0);
- drawQuad(mProgram, "position", 0.5f);
-
- ASSERT_GL_NO_ERROR();
- EXPECT_PIXEL_NEAR(0, 0, 128, 191, 64, 255, 1);
+ EXPECT_GLENUM_EQ(GL_FLOAT, type);
+ EXPECT_EQ("blockName.f", std::string(&strBuffer[0]));
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.