From cf65c56fb46b75e3c9819218165d9b97acf25c4a Mon Sep 17 00:00:00 2001 From: Alexander Galazin Date: Wed, 5 Apr 2017 09:30:06 +0200 Subject: [PATCH] Fix shader bugs in OOB tests 1. Check that the required number of vertex shader storage blocks is supported, throw NotSupported otherwise. 2. Use an array instead of a vector in local_array tests. 3. Try harder to defeat compiler optimizations on arrays, i.e. initialize it with different values. Components: AOSP Affects: dEQP-EGL.functional.robustness.reset_context.shaders.out_of_bounds_non_robust.*.shader_storage_block.vertex* dEQP-EGL.functional.robustness.reset_context.shaders.out_of_bounds_non_robust.*.local_array.* Google bug: 36891454 Change-Id: I2aeb2d454295993126d4048759e5981421d5c0db --- modules/egl/teglRobustnessTests.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/egl/teglRobustnessTests.cpp b/modules/egl/teglRobustnessTests.cpp index 269b866..97b3cdd 100644 --- a/modules/egl/teglRobustnessTests.cpp +++ b/modules/egl/teglRobustnessTests.cpp @@ -39,6 +39,7 @@ #include "glwEnums.hpp" #include "deSTLUtil.hpp" +#include "deStringUtil.hpp" #include "deThread.hpp" #include "deSharedPtr.hpp" @@ -1229,9 +1230,9 @@ glu::ProgramSources ShadersOOB::genNonComputeSource (void) { const char* const readWriteStatement = (m_isRead) ? " color.x = color_out[u_index];\n" - : " color[u_index] = color_out.x;\n"; + : " color[u_index] = color_out[0];\n"; - shaderBody << " highp vec4 color_out = vec4(1.0f);\n" + shaderBody << " highp float color_out[4] = float[4](0.25f, 0.5f, 0.75f, 1.0f);\n" << readWriteStatement; } else @@ -1240,12 +1241,12 @@ glu::ProgramSources ShadersOOB::genNonComputeSource (void) shaderDecl << "layout(std140, binding = 0) " << ((m_isUBO) ? "uniform" : "buffer") << " Block\n" << "{\n" - << " highp vec4 color_out;\n" + << " highp float color_out[4];\n" << "} " << resName << "[" << s_numBindings << "];\n"; const std::string readWriteStatement = (m_isRead) ? " color.x = " + resName + "[0].color_out[u_index];\n" - : " color[u_index] = " + resName + "[0].color_out.x;\n"; + : " color[u_index] = " + resName + "[0].color_out[0];\n"; shaderBody << readWriteStatement; } @@ -1302,6 +1303,17 @@ glu::ProgramSources ShadersOOB::genSources (void) void ShadersOOB::setup (void) { + if (!m_isUBO && !m_isLocalArray && (m_shaderType == SHADERTYPE_VERT || m_shaderType == SHADERTYPE_VERT_AND_FRAG)) + { + // Check implementation limits for vertex shader SSBO + int vertexShaderStorageBlockSupported = -1; + + GLU_CHECK_GLW_CALL(m_gl, getIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &vertexShaderStorageBlockSupported)); + + if (vertexShaderStorageBlockSupported < (int)m_buffers.size()) + TCU_THROW(NotSupportedError, ("Test requires GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS >= " + de::toString((int)m_buffers.size()) + ", got " + de::toString(vertexShaderStorageBlockSupported)).c_str()); + } + glu::ShaderProgram program(m_gl, genSources()); m_log << program; -- 2.7.4