Commit 1d02157e by Tim Van Patten Committed by Commit Bot

Only enable shader array size restrictions for HLSL

Shader arrays are currently restricted to 64K entries for all translator back ends. This is being changed to just HLSL, since the other back ends appear to have support for larger sizes. Bug: angleproject:3865 Test: dEQP-GLES31.functional.compute.basic.copy_image_to_ssbo_large Test: dEQP-GLES31.functional.compute.basic.copy_ssbo_to_image_large Test: ComputeShaderTest.VeryLargeArrayInsideFunction/* Change-Id: I9a9d1322e24b3206debdea6a3fd517b4d6869ed9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1821943 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent 588ba833
......@@ -384,7 +384,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
TParseContext parseContext(mSymbolTable, mExtensionBehavior, mShaderType, mShaderSpec,
compileOptions, !IsDesktopGLSpec(mShaderSpec), &mDiagnostics,
getResources());
getResources(), getOutputType());
parseContext.setFragmentPrecisionHighOnESSL1(mResources.FragmentPrecisionHigh == 1);
......
......@@ -169,7 +169,8 @@ TParseContext::TParseContext(TSymbolTable &symt,
ShCompileOptions options,
bool checksPrecErrors,
TDiagnostics *diagnostics,
const ShBuiltInResources &resources)
const ShBuiltInResources &resources,
ShShaderOutput outputType)
: symbolTable(symt),
mDeferredNonEmptyDeclarationErrorCheck(false),
mShaderType(type),
......@@ -217,7 +218,8 @@ TParseContext::TParseContext(TSymbolTable &symt,
mGeometryShaderMaxVertices(-1),
mMaxGeometryShaderInvocations(resources.MaxGeometryShaderInvocations),
mMaxGeometryShaderMaxVertices(resources.MaxGeometryOutputVertices),
mFunctionBodyNewScope(false)
mFunctionBodyNewScope(false),
mOutputType(outputType)
{}
TParseContext::~TParseContext() {}
......@@ -1014,15 +1016,18 @@ unsigned int TParseContext::checkIsValidArraySize(const TSourceLoc &line, TInter
return 1u;
}
// The size of arrays is restricted here to prevent issues further down the
// compiler/translator/driver stack. Shader Model 5 generation hardware is limited to
// 4096 registers so this should be reasonable even for aggressively optimizable code.
const unsigned int sizeLimit = 65536;
if (size > sizeLimit)
if (IsOutputHLSL(getOutputType()))
{
error(line, "array size too large", "");
return 1u;
// The size of arrays is restricted here to prevent issues further down the
// compiler/translator/driver stack. Shader Model 5 generation hardware is limited to
// 4096 registers so this should be reasonable even for aggressively optimizable code.
const unsigned int sizeLimit = 65536;
if (size > sizeLimit)
{
error(line, "array size too large", "");
return 1u;
}
}
return size;
......
......@@ -40,7 +40,8 @@ class TParseContext : angle::NonCopyable
ShCompileOptions options,
bool checksPrecErrors,
TDiagnostics *diagnostics,
const ShBuiltInResources &resources);
const ShBuiltInResources &resources,
ShShaderOutput outputType);
~TParseContext();
bool anyMultiviewExtensionAvailable();
......@@ -459,6 +460,8 @@ class TParseContext : angle::NonCopyable
return mGeometryShaderOutputPrimitiveType;
}
ShShaderOutput getOutputType() const { return mOutputType; }
// TODO(jmadill): make this private
TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
......@@ -655,6 +658,8 @@ class TParseContext : angle::NonCopyable
// Track when we add new scope for func body in ESSL 1.00 spec
bool mFunctionBodyNewScope;
ShShaderOutput mOutputType;
};
int PaParseStrings(size_t count,
......
......@@ -518,6 +518,8 @@
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8.texture_swizzle.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8ui.* = FAIL
3865 D3D11 : dEQP-GLES31.functional.compute.basic.copy_image_to_ssbo_large = FAIL
3865 D3D11 : dEQP-GLES31.functional.compute.basic.copy_ssbo_to_image_large = FAIL
// Failing with dEQP roll
3447 D3D11 : dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers.22 = FAIL
......@@ -545,8 +547,6 @@
1442 D3D11 : dEQP-GLES31.functional.shaders.opaque_type_indexing.* = FAIL
// OpenGL/D3D11/Vulkan Failing Tests
3865 : dEQP-GLES31.functional.compute.basic.copy_image_to_ssbo_large = FAIL
3865 : dEQP-GLES31.functional.compute.basic.copy_ssbo_to_image_large = FAIL
1442 : dEQP-GLES31.functional.shaders.helper_invocation.* = FAIL
1442 : dEQP-GLES31.functional.state_query.integer.program_pipeline_binding_* = FAIL
1442 : dEQP-GLES31.functional.state_query.program.program_separable_get_programiv = FAIL
......
......@@ -3462,6 +3462,57 @@ void main(void)
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}
// Create a 'very large' array inside of a function in a compute shader.
TEST_P(ComputeShaderTest, VeryLargeArrayInsideFunction)
{
constexpr char kComputeShader[] = R"(#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer Output {
int value[1];
} output_data;
void main()
{
int values[1000];
for (int i = 0; i < values.length(); i++)
{
values[i] = 0;
}
int total = 0;
for (int i = 0; i < values.length(); i++)
{
total += i;
values[i] = total;
}
output_data.value[0u] = values[1000-1];
})";
ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShader);
EXPECT_GL_NO_ERROR();
glUseProgram(program);
constexpr unsigned int kBytesPerComponent = sizeof(GLint);
GLBuffer shaderStorageBuffer;
glBindBuffer(GL_SHADER_STORAGE_BUFFER, shaderStorageBuffer);
glBufferData(GL_SHADER_STORAGE_BUFFER, 1 * kBytesPerComponent, nullptr, GL_STATIC_DRAW);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, shaderStorageBuffer);
EXPECT_GL_NO_ERROR();
glDispatchCompute(1, 1, 1);
glFinish();
EXPECT_GL_NO_ERROR();
// read back
const GLint *ptr = reinterpret_cast<const GLint *>(
glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * kBytesPerComponent, GL_MAP_READ_BIT));
EXPECT_EQ(499500, ptr[0]);
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}
ANGLE_INSTANTIATE_TEST(ComputeShaderTest,
ES31_OPENGL(),
ES31_OPENGLES(),
......
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