From 1cb737dd0d3af3f1001466feb566e0d54f623a15 Mon Sep 17 00:00:00 2001 From: Amy Liu Date: Tue, 14 Jan 2020 16:34:30 +0800 Subject: [PATCH] Initialize gl_PointSize if the test draws points From GLSL specification: "If gl_PointSize is not written to, its value is undefined in subsequent pipe stages" Affects: dEQP-GLES3.functional.primitive_restart.basic.points.* dEQP-GLES3.functional.fragment_ops.scissor.partial_points Components: AOSP VK-GL-CTS issue: 2161 Change-Id: I3016287f7e55331522d6a7a8d562d8b57ab27e43 (cherry picked from commit 434240bf67d226947a3ccb73b10ea8e685f7aaaf) --- .../gles3/functional/es3fPrimitiveRestartTests.cpp | 33 +++++++++---- modules/glshared/glsScissorTests.cpp | 57 +++++++++++++++++++--- 2 files changed, 73 insertions(+), 17 deletions(-) diff --git a/modules/gles3/functional/es3fPrimitiveRestartTests.cpp b/modules/gles3/functional/es3fPrimitiveRestartTests.cpp index d926aec..d82ca34 100644 --- a/modules/gles3/functional/es3fPrimitiveRestartTests.cpp +++ b/modules/gles3/functional/es3fPrimitiveRestartTests.cpp @@ -215,15 +215,30 @@ void* PrimitiveRestartCase::getIndexPtr (int indexNdx) void PrimitiveRestartCase::init (void) { // Create shader program. - - static const char* vertShaderSource = - "#version 300 es\n" - "in highp vec4 a_position;\n" - "\n" - "void main()\n" - "{\n" - " gl_Position = a_position;\n" - "}\n"; + std::string vertShaderSource; + if (m_primType == PRIMITIVE_POINTS) + { + vertShaderSource = + "#version 300 es\n" + "in highp vec4 a_position;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = a_position;\n" + " gl_PointSize = 1.0f;\n" + "}\n"; + } + else + { + vertShaderSource = + "#version 300 es\n" + "in highp vec4 a_position;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = a_position;\n" + "}\n"; + } static const char* fragShaderSource = "#version 300 es\n" diff --git a/modules/glshared/glsScissorTests.cpp b/modules/glshared/glsScissorTests.cpp index 96cbeea..e11e7a3 100644 --- a/modules/glshared/glsScissorTests.cpp +++ b/modules/glshared/glsScissorTests.cpp @@ -124,13 +124,27 @@ void clearEdges (const tcu::PixelBufferAccess& access, const T& color, const IVe } } -glu::ProgramSources genShaders(glu::GLSLVersion version) +glu::ProgramSources genShaders(glu::GLSLVersion version, bool isPoint) { - const string vtxSource = "${VERSION}\n" - "${IN} highp vec4 a_position;\n" - "void main(){\n" - " gl_Position = a_position;\n" - "}\n"; + string vtxSource; + + if (isPoint) + { + vtxSource = "${VERSION}\n" + "${IN} highp vec4 a_position;\n" + "void main(){\n" + " gl_Position = a_position;\n" + " gl_PointSize = 1.0;\n" + "}\n"; + } + else + { + vtxSource = "${VERSION}\n" + "${IN} highp vec4 a_position;\n" + "void main(){\n" + " gl_Position = a_position;\n" + "}\n"; + } const string frgSource = "${VERSION}\n" "${OUT_DECL}" @@ -177,6 +191,9 @@ public: protected: virtual void render (GLuint program, const IVec4& viewport) const = 0; + // Initialize gl_PointSize to 1.0f when drawing points, or the point size is undefined according to spec. + virtual bool isPoint (void) const = 0; + glu::RenderContext& m_renderCtx; const Vec4 m_scissorArea; }; @@ -199,7 +216,7 @@ ScissorCase::IterateResult ScissorCase::iterate (void) 1u << de::max(0, 8 - renderFormat.greenBits), 1u << de::max(0, 8 - renderFormat.blueBits), 1u << de::max(0, 8 - renderFormat.alphaBits)).asFloat(); - const glu::ShaderProgram shader (m_renderCtx, genShaders(glu::getContextTypeGLSLVersion(m_renderCtx.getType()))); + const glu::ShaderProgram shader (m_renderCtx, genShaders(glu::getContextTypeGLSLVersion(m_renderCtx.getType()), isPoint())); const RandomViewport viewport (m_renderCtx.getRenderTarget(), 256, 256, deStringHash(getName())); const IVec4 relScissorArea (int(m_scissorArea.x() * (float)viewport.width), @@ -297,6 +314,7 @@ public: protected: virtual void render (GLuint program, const IVec4& viewport) const; + virtual bool isPoint (void) const; private: const Vec4 m_renderArea; @@ -319,6 +337,11 @@ ScissorPrimitiveCase::ScissorPrimitiveCase (tcu::TestContext& testCtx, { } +bool ScissorPrimitiveCase::isPoint (void) const +{ + return (m_primitiveType == POINT); +} + void ScissorPrimitiveCase::render (GLuint program, const IVec4&) const { const glw::Functions& gl = m_renderCtx.getFunctions(); @@ -410,6 +433,7 @@ public: protected: virtual void render (GLuint program, const IVec4& viewport) const; + virtual bool isPoint (void) const; private: const deUint32 m_clearMode; //!< Combination of the flags accepted by glClear @@ -434,6 +458,11 @@ void ScissorClearCase::init (void) throw tcu::NotSupportedError("Cannot clear stencil; no stencil buffer present", "", __FILE__, __LINE__); } +bool ScissorClearCase::isPoint (void) const +{ + return false; +} + void ScissorClearCase::render (GLuint program, const IVec4&) const { const glw::Functions& gl = m_renderCtx.getFunctions(); @@ -485,6 +514,7 @@ protected: enum {SIZE = 64}; virtual void render (GLuint program, const IVec4& viewport) const; + virtual bool isPoint (void) const; FramebufferP m_fbo; }; @@ -520,6 +550,11 @@ void FramebufferBlitCase::deinit (void) m_fbo.clear(); } +bool FramebufferBlitCase::isPoint (void) const +{ + return false; +} + void FramebufferBlitCase::render(GLuint program, const IVec4& viewport) const { const glw::Functions& gl = m_renderCtx.getFunctions(); @@ -578,6 +613,7 @@ private: static BufferFmtDesc getBufferFormat (ClearType type); virtual void render (GLuint program) const; + virtual bool isPoint (void) const; glu::RenderContext& m_renderCtx; const ClearType m_clearType; @@ -609,7 +645,7 @@ FramebufferClearCase::IterateResult FramebufferClearCase::iterate (void) { TestLog& log = m_testCtx.getLog(); const glw::Functions& gl = m_renderCtx.getFunctions(); - const glu::ShaderProgram shader (m_renderCtx, genShaders(glu::getContextTypeGLSLVersion(m_renderCtx.getType()))); + const glu::ShaderProgram shader (m_renderCtx, genShaders(glu::getContextTypeGLSLVersion(m_renderCtx.getType()), isPoint())); const glu::Framebuffer fbo (gl); const glu::Renderbuffer colorbuf (gl); @@ -834,6 +870,11 @@ void FramebufferClearCase::render (GLuint program) const } } +bool FramebufferClearCase::isPoint (void) const +{ + return false; +} + } // Anonymous namespace ScissorTestInternal -- 2.7.4