summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp')
-rwxr-xr-xgfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp106
1 files changed, 52 insertions, 54 deletions
diff --git a/gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp b/gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp
index a93411668..f29374f54 100755
--- a/gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp
+++ b/gfx/angle/src/tests/compiler_tests/CollectVariables_test.cpp
@@ -14,21 +14,19 @@
#include "GLSLANG/ShaderLang.h"
#include "compiler/translator/TranslatorGLSL.h"
-using namespace sh;
-
#define EXPECT_GLENUM_EQ(expected, actual) \
- EXPECT_EQ(static_cast<::GLenum>(expected), static_cast<::GLenum>(actual))
+ EXPECT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
class CollectVariablesTest : public testing::Test
{
public:
- CollectVariablesTest(::GLenum shaderType) : mShaderType(shaderType) {}
+ CollectVariablesTest(GLenum shaderType) : mShaderType(shaderType) {}
protected:
void SetUp() override
{
ShBuiltInResources resources;
- InitBuiltInResources(&resources);
+ ShInitBuiltInResources(&resources);
resources.MaxDrawBuffers = 8;
initTranslator(resources);
@@ -47,10 +45,10 @@ class CollectVariablesTest : public testing::Test
const char *shaderStrings[] = { shaderString.c_str() };
ASSERT_TRUE(mTranslator->compile(shaderStrings, 1, SH_VARIABLES));
- const std::vector<Uniform> &uniforms = mTranslator->getUniforms();
+ const std::vector<sh::Uniform> &uniforms = mTranslator->getUniforms();
ASSERT_EQ(1u, uniforms.size());
- const Uniform &uniform = uniforms[0];
+ const sh::Uniform &uniform = uniforms[0];
EXPECT_EQ("gl_DepthRange", uniform.name);
ASSERT_TRUE(uniform.isStruct());
ASSERT_EQ(3u, uniform.fields.size());
@@ -92,7 +90,7 @@ class CollectVariablesTest : public testing::Test
void validateOutputVariableForShader(const std::string &shaderString,
unsigned int varIndex,
const char *varName,
- const OutputVariable **outResult)
+ const sh::OutputVariable **outResult)
{
const char *shaderStrings[] = {shaderString.c_str()};
ASSERT_TRUE(mTranslator->compile(shaderStrings, 1, SH_VARIABLES))
@@ -100,7 +98,7 @@ class CollectVariablesTest : public testing::Test
const auto &outputVariables = mTranslator->getOutputVariables();
ASSERT_LT(varIndex, outputVariables.size());
- const OutputVariable &outputVariable = outputVariables[varIndex];
+ const sh::OutputVariable &outputVariable = outputVariables[varIndex];
EXPECT_EQ(-1, outputVariable.location);
EXPECT_TRUE(outputVariable.staticUse);
EXPECT_EQ(varName, outputVariable.name);
@@ -113,7 +111,7 @@ class CollectVariablesTest : public testing::Test
ASSERT_TRUE(mTranslator->compile(shaderStrings, 1, SH_VARIABLES));
}
- ::GLenum mShaderType;
+ GLenum mShaderType;
std::unique_ptr<TranslatorGLSL> mTranslator;
};
@@ -144,7 +142,7 @@ TEST_F(CollectFragmentVariablesTest, SimpleOutputVar)
const auto &outputVariables = mTranslator->getOutputVariables();
ASSERT_EQ(1u, outputVariables.size());
- const OutputVariable &outputVariable = outputVariables[0];
+ const sh::OutputVariable &outputVariable = outputVariables[0];
EXPECT_EQ(0u, outputVariable.arraySize);
EXPECT_EQ(-1, outputVariable.location);
@@ -169,7 +167,7 @@ TEST_F(CollectFragmentVariablesTest, LocationOutputVar)
const auto &outputVariables = mTranslator->getOutputVariables();
ASSERT_EQ(1u, outputVariables.size());
- const OutputVariable &outputVariable = outputVariables[0];
+ const sh::OutputVariable &outputVariable = outputVariables[0];
EXPECT_EQ(0u, outputVariable.arraySize);
EXPECT_EQ(5, outputVariable.location);
@@ -190,10 +188,10 @@ TEST_F(CollectVertexVariablesTest, LocationAttribute)
compile(shaderString);
- const std::vector<Attribute> &attributes = mTranslator->getAttributes();
+ const std::vector<sh::Attribute> &attributes = mTranslator->getAttributes();
ASSERT_EQ(1u, attributes.size());
- const Attribute &attribute = attributes[0];
+ const sh::Attribute &attribute = attributes[0];
EXPECT_EQ(0u, attribute.arraySize);
EXPECT_EQ(5, attribute.location);
@@ -216,20 +214,20 @@ TEST_F(CollectVertexVariablesTest, SimpleInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_FALSE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_TRUE(interfaceBlock.staticUse);
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_GLENUM_EQ(GL_HIGH_FLOAT, field.precision);
EXPECT_TRUE(field.staticUse);
@@ -252,21 +250,21 @@ TEST_F(CollectVertexVariablesTest, SimpleInstancedInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_FALSE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_EQ("blockInstance", interfaceBlock.instanceName);
EXPECT_TRUE(interfaceBlock.staticUse);
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_GLENUM_EQ(GL_HIGH_FLOAT, field.precision);
EXPECT_TRUE(field.staticUse);
@@ -290,27 +288,27 @@ TEST_F(CollectVertexVariablesTest, StructInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_FALSE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_TRUE(interfaceBlock.staticUse);
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_TRUE(field.isStruct());
EXPECT_TRUE(field.staticUse);
EXPECT_EQ("s", field.name);
EXPECT_FALSE(field.isRowMajorLayout);
- const ShaderVariable &member = field.fields[0];
+ const sh::ShaderVariable &member = field.fields[0];
// NOTE: we don't currently mark struct members as statically used or not
EXPECT_FALSE(member.isStruct());
@@ -333,28 +331,28 @@ TEST_F(CollectVertexVariablesTest, StructInstancedInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_FALSE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_EQ("instanceName", interfaceBlock.instanceName);
EXPECT_TRUE(interfaceBlock.staticUse);
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_TRUE(field.isStruct());
EXPECT_TRUE(field.staticUse);
EXPECT_EQ("s", field.name);
EXPECT_FALSE(field.isRowMajorLayout);
- const ShaderVariable &member = field.fields[0];
+ const sh::ShaderVariable &member = field.fields[0];
// NOTE: we don't currently mark struct members as statically used or not
EXPECT_FALSE(member.isStruct());
@@ -377,27 +375,27 @@ TEST_F(CollectVertexVariablesTest, NestedStructRowMajorInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_TRUE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_TRUE(interfaceBlock.staticUse);
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_TRUE(field.isStruct());
EXPECT_TRUE(field.staticUse);
EXPECT_EQ("s", field.name);
EXPECT_TRUE(field.isRowMajorLayout);
- const ShaderVariable &member = field.fields[0];
+ const sh::ShaderVariable &member = field.fields[0];
// NOTE: we don't currently mark struct members as statically used or not
EXPECT_FALSE(member.isStruct());
@@ -419,10 +417,10 @@ TEST_F(CollectVertexVariablesTest, VaryingInterpolation)
compile(shaderString);
- const std::vector<Varying> &varyings = mTranslator->getVaryings();
+ const std::vector<sh::Varying> &varyings = mTranslator->getVaryings();
ASSERT_EQ(2u, varyings.size());
- const Varying *varying = &varyings[0];
+ const sh::Varying *varying = &varyings[0];
if (varying->name == "gl_Position")
{
@@ -434,7 +432,7 @@ TEST_F(CollectVertexVariablesTest, VaryingInterpolation)
EXPECT_TRUE(varying->staticUse);
EXPECT_GLENUM_EQ(GL_FLOAT, varying->type);
EXPECT_EQ("vary", varying->name);
- EXPECT_EQ(INTERPOLATION_CENTROID, varying->interpolation);
+ EXPECT_EQ(sh::INTERPOLATION_CENTROID, varying->interpolation);
}
// Test for builtin uniform "gl_DepthRange" (Vertex shader)
@@ -471,7 +469,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1FragColor)
" gl_FragColor = vec4(1.0);\n"
"}\n";
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(fragColorShader, 0u, "gl_FragColor", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(0u, outputVariable->arraySize);
@@ -497,7 +495,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1FragData)
resources.MaxDrawBuffers = kMaxDrawBuffers;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(fragDataShader, 0u, "gl_FragData", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(kMaxDrawBuffers, outputVariable->arraySize);
@@ -520,7 +518,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1FragDepthMediump)
resources.EXT_frag_depth = 1;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(fragDepthShader, 0u, "gl_FragDepthEXT", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(0u, outputVariable->arraySize);
@@ -543,7 +541,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1FragDepthHighp)
resources.FragmentPrecisionHigh = 1;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(fragDepthHighShader, 0u, "gl_FragDepthEXT", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(0u, outputVariable->arraySize);
@@ -566,7 +564,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL3FragDepthHighp)
resources.EXT_frag_depth = 1;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(fragDepthHighShader, 0u, "gl_FragDepth", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(0u, outputVariable->arraySize);
@@ -594,7 +592,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1EXTBlendFuncExtendedSecondary
resources.MaxDualSourceDrawBuffers = resources.MaxDrawBuffers;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(secondaryFragColorShader, 0u, "gl_FragColor", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(0u, outputVariable->arraySize);
@@ -632,7 +630,7 @@ TEST_F(CollectFragmentVariablesTest, OutputVarESSL1EXTBlendFuncExtendedSecondary
resources.MaxDualSourceDrawBuffers = resources.MaxDrawBuffers;
initTranslator(resources);
- const OutputVariable *outputVariable = nullptr;
+ const sh::OutputVariable *outputVariable = nullptr;
validateOutputVariableForShader(secondaryFragDataShader, 0u, "gl_FragData", &outputVariable);
ASSERT_NE(outputVariable, nullptr);
EXPECT_EQ(kMaxDrawBuffers, outputVariable->arraySize);
@@ -660,7 +658,7 @@ class CollectHashedVertexVariablesTest : public CollectVertexVariablesTest
{
// Initialize the translate with a hash function
ShBuiltInResources resources;
- sh::InitBuiltInResources(&resources);
+ ShInitBuiltInResources(&resources);
resources.HashFunction = SimpleTestHash;
initTranslator(resources);
}
@@ -679,14 +677,14 @@ TEST_F(CollectHashedVertexVariablesTest, InstancedInterfaceBlock)
compile(shaderString);
- const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
+ const std::vector<sh::InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
- const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
+ const sh::InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ(0u, interfaceBlock.arraySize);
EXPECT_FALSE(interfaceBlock.isRowMajorLayout);
- EXPECT_EQ(BLOCKLAYOUT_SHARED, interfaceBlock.layout);
+ EXPECT_EQ(sh::BLOCKLAYOUT_SHARED, interfaceBlock.layout);
EXPECT_EQ("blockName", interfaceBlock.name);
EXPECT_EQ("blockInstance", interfaceBlock.instanceName);
EXPECT_EQ("webgl_9", interfaceBlock.mappedName);
@@ -694,7 +692,7 @@ TEST_F(CollectHashedVertexVariablesTest, InstancedInterfaceBlock)
ASSERT_EQ(1u, interfaceBlock.fields.size());
- const InterfaceBlockField &field = interfaceBlock.fields[0];
+ const sh::InterfaceBlockField &field = interfaceBlock.fields[0];
EXPECT_GLENUM_EQ(GL_HIGH_FLOAT, field.precision);
EXPECT_TRUE(field.staticUse);
@@ -722,7 +720,7 @@ TEST_F(CollectHashedVertexVariablesTest, StructUniform)
const auto &uniforms = mTranslator->getUniforms();
ASSERT_EQ(1u, uniforms.size());
- const Uniform &uniform = uniforms[0];
+ const sh::Uniform &uniform = uniforms[0];
EXPECT_EQ(0u, uniform.arraySize);
EXPECT_EQ("u", uniform.name);
@@ -731,7 +729,7 @@ TEST_F(CollectHashedVertexVariablesTest, StructUniform)
ASSERT_EQ(1u, uniform.fields.size());
- const ShaderVariable &field = uniform.fields[0];
+ const sh::ShaderVariable &field = uniform.fields[0];
EXPECT_GLENUM_EQ(GL_HIGH_FLOAT, field.precision);
// EXPECT_TRUE(field.staticUse); // we don't yet support struct static use