Commit 017bda42 by Qin Jiajia Committed by Commit Bot

Fix the ASSERT error

This change adds shader type checking before entering initializeOutputVariables. BUG: angleproject:2821 Change-Id: Ib931031f2fc187f1f2a1821a09664bbe172a5e90 Reviewed-on: https://chromium-review.googlesource.com/1226229 Commit-Queue: Jiajia Qin <jiajia.qin@intel.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 62114aae
...@@ -671,7 +671,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, ...@@ -671,7 +671,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
return false; return false;
} }
} }
if (compileOptions & SH_INIT_OUTPUT_VARIABLES) if ((compileOptions & SH_INIT_OUTPUT_VARIABLES) && (shaderType != GL_COMPUTE_SHADER))
{ {
initializeOutputVariables(root); initializeOutputVariables(root);
} }
......
...@@ -51,7 +51,7 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(const gl::Context *cont ...@@ -51,7 +51,7 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(const gl::Context *cont
ShCompileOptions options = SH_INIT_GL_POSITION; ShCompileOptions options = SH_INIT_GL_POSITION;
bool isWebGL = context->getExtensions().webglCompatibility; bool isWebGL = context->getExtensions().webglCompatibility;
if (isWebGL) if (isWebGL && (mData.getShaderType() != gl::ShaderType::Compute))
{ {
options |= SH_INIT_OUTPUT_VARIABLES; options |= SH_INIT_OUTPUT_VARIABLES;
} }
......
...@@ -38,19 +38,48 @@ class ShCompileTest : public testing::Test ...@@ -38,19 +38,48 @@ class ShCompileTest : public testing::Test
void testCompile(const char **shaderStrings, int stringCount, bool expectation) void testCompile(const char **shaderStrings, int stringCount, bool expectation)
{ {
ShCompileOptions options = SH_OBJECT_CODE; ShCompileOptions options = SH_OBJECT_CODE | SH_VARIABLES | SH_INIT_OUTPUT_VARIABLES;
bool success = sh::Compile(mCompiler, shaderStrings, stringCount, options); bool success = sh::Compile(mCompiler, shaderStrings, stringCount, options);
const std::string &compileLog = sh::GetInfoLog(mCompiler); const std::string &compileLog = sh::GetInfoLog(mCompiler);
EXPECT_EQ(expectation, success) << compileLog; EXPECT_EQ(expectation, success) << compileLog;
} }
private:
ShBuiltInResources mResources; ShBuiltInResources mResources;
public: public:
ShHandle mCompiler; ShHandle mCompiler;
}; };
class ShCompileComputeTest : public ShCompileTest
{
public:
ShCompileComputeTest() {}
protected:
void SetUp() override
{
sh::InitBuiltInResources(&mResources);
mCompiler = sh::ConstructCompiler(GL_COMPUTE_SHADER, SH_WEBGL3_SPEC,
SH_GLSL_COMPATIBILITY_OUTPUT, &mResources);
ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed.";
}
};
// Test calling sh::Compile with compute shader source string.
TEST_F(ShCompileComputeTest, ComputeShaderString)
{
constexpr char kComputeShaderString[] =
R"(#version 310 es
layout(local_size_x=1) in;
void main()
{
})";
const char *shaderStrings[] = {kComputeShaderString};
testCompile(shaderStrings, 1, true);
}
// Test calling sh::Compile with more than one shader source string. // Test calling sh::Compile with more than one shader source string.
TEST_F(ShCompileTest, MultipleShaderStrings) TEST_F(ShCompileTest, MultipleShaderStrings)
{ {
......
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