Add sRGB write decode negative case
authorJohn Richardson <john.richardson@mobica.com>
Thu, 30 Mar 2017 14:11:43 +0000 (15:11 +0100)
committerMika Isojärvi <misojarvi@google.com>
Thu, 6 Jul 2017 18:06:29 +0000 (11:06 -0700)
Test to check drivers that don't expose EXT_sRGB_write control return
GL_INVALID_ENUM for related gl calls.

New Tests:
- dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_unsupported_enum

Change-Id: I605f70894ead6e5dd317a340d061dcec9a6180c8

android/cts/master/gles31-master.txt
modules/gles31/functional/es31fFboSRGBWriteControlTests.cpp

index aeebbe3..0c5d89b 100644 (file)
@@ -17899,6 +17899,7 @@ dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_enabled_col_attac
 dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_enabled_blend
 dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_enabled_render_target_ignore
 dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_enabled_copy_to_linear
+dEQP-GLES31.functional.fbo.srgb_write_control.framebuffer_srgb_unsupported_enum
 dEQP-GLES31.functional.program_interface_query.buffer_limited_query.resource_name_query
 dEQP-GLES31.functional.program_interface_query.buffer_limited_query.resource_query
 dEQP-GLES31.functional.program_interface_query.uniform.resource_list.default_block.var
index bd913ec..57f39d2 100644 (file)
@@ -35,6 +35,7 @@
 #include "gluPixelTransfer.hpp"
 #include "glsTextureTestUtil.hpp"
 #include "tcuVectorUtil.hpp"
+#include "gluStrUtil.hpp"
 
 namespace deqp
 {
@@ -1771,6 +1772,106 @@ bool FboSRGBCopyToLinearCase::verifyResult (void)
                return false;
 }
 
+class FboSRGBUnsupportedEnumCase : public TestCase
+{
+public:
+                                       FboSRGBUnsupportedEnumCase      (Context& context, const char* const name, const char* const description);
+                                       ~FboSRGBUnsupportedEnumCase     (void);
+
+       void                    init                                            (void);
+       void                    deinit                                          (void);
+       bool                    isInvalidEnum                           (std::string functionName);
+       IterateResult   iterate                                         (void);
+};
+
+FboSRGBUnsupportedEnumCase::FboSRGBUnsupportedEnumCase (Context& context, const char* const name, const char* const description)
+       : TestCase                                              (context, name, description)
+{
+}
+
+FboSRGBUnsupportedEnumCase::~FboSRGBUnsupportedEnumCase (void)
+{
+       FboSRGBUnsupportedEnumCase::deinit();
+}
+
+void FboSRGBUnsupportedEnumCase::init (void)
+{
+       // extension requirements for test
+       if (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2)) || m_context.getContextInfo().isExtensionSupported("GL_EXT_sRGB_write_control"))
+               TCU_THROW(NotSupportedError, "Test requires extension GL_EXT_sRGB_write_control to be unsupported and a context version less than 3.2");
+}
+
+void FboSRGBUnsupportedEnumCase::deinit (void)
+{
+}
+
+bool FboSRGBUnsupportedEnumCase::isInvalidEnum (std::string functionName)
+{
+       const glw::Functions&   gl                      = m_context.getRenderContext().getFunctions();
+       tcu::TestLog&                   log                     = m_context.getTestContext().getLog();
+       bool                                    isOk            = true;
+       glw::GLenum                             error           = GL_NO_ERROR;
+
+       log << tcu::TestLog::Message << "Checking call to " << functionName << tcu::TestLog::EndMessage;
+
+       std::ostringstream              message;
+       gl.getError();
+
+       if (error != GL_INVALID_ENUM)
+       {
+               message << functionName << " returned wrong value [" << glu::getErrorStr(error) << ", expected " << glu::getErrorStr(GL_INVALID_ENUM) << "]";
+               log << tcu::TestLog::Message << message.str() << tcu::TestLog::EndMessage;
+               isOk = false;
+       }
+
+       return isOk;
+}
+
+FboSRGBUnsupportedEnumCase::IterateResult FboSRGBUnsupportedEnumCase::iterate (void)
+{
+       // TEST INFO:
+       // API tests that check calls using enum GL_FRAMEBUFFER_SRGB return GL_INVALID_ENUM  when GL_EXT_sRGB_write_control is not supported
+
+       const glw::Functions&   gl                      = m_context.getRenderContext().getFunctions();
+       bool                                    allPass         = true;
+       glw::GLboolean                  bEnabled        = GL_FALSE;
+       glw::GLfloat                    fEnabled        = 0;
+       glw::GLint                              iEnabled        = 0;
+       glw::GLint64                    lEnabled        = 0;
+
+       m_context.getTestContext().getLog() << tcu::TestLog::Message
+                                                                               << "Check calls using enum GL_FRAMEBUFFER_SRGB return GL_INVALID_ENUM  when GL_EXT_sRGB_write_control is not supported\n\n"
+                                                                               << tcu::TestLog::EndMessage;
+
+       gl.enable(GL_FRAMEBUFFER_SRGB);
+       allPass &= isInvalidEnum("glEnable()");
+
+       gl.disable(GL_FRAMEBUFFER_SRGB);
+       allPass &= isInvalidEnum("glDisable()");
+
+       gl.isEnabled(GL_FRAMEBUFFER_SRGB);
+       allPass &= isInvalidEnum("glIsEnabled()");
+
+       gl.getBooleanv(GL_FRAMEBUFFER_SRGB, &bEnabled);
+       allPass &= isInvalidEnum("glGetBooleanv()");
+
+       gl.getFloatv(GL_FRAMEBUFFER_SRGB, &fEnabled);
+       allPass &= isInvalidEnum("glGetFloatv()");
+
+       gl.getIntegerv(GL_FRAMEBUFFER_SRGB, &iEnabled);
+       allPass &= isInvalidEnum("glGetIntegerv()");
+
+       gl.getInteger64v(GL_FRAMEBUFFER_SRGB, &lEnabled);
+       allPass &= isInvalidEnum("glGetInteger64v()");
+
+       if (allPass)
+               m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
+       else
+               m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
+
+       return STOP;
+}
+
 } // anonymous
 
 FboSRGBWriteControlTests::FboSRGBWriteControlTests     (Context& context)
@@ -1789,6 +1890,9 @@ void FboSRGBWriteControlTests::init (void)
        this->addChild(new FboSRGBToggleBlendCase                       (m_context, "framebuffer_srgb_enabled_blend",                                   "toggle framebuffer srgb settings with blend disabled"));
        this->addChild(new FboSRGBRenderTargetIgnoreCase        (m_context, "framebuffer_srgb_enabled_render_target_ignore",    "enable framebuffer srgb, non-srgb render target should ignore"));
        this->addChild(new FboSRGBCopyToLinearCase                      (m_context, "framebuffer_srgb_enabled_copy_to_linear",                  "no conversion when blittering between framebuffer srgb and linear"));
+
+       // negative
+       this->addChild(new FboSRGBUnsupportedEnumCase           (m_context, "framebuffer_srgb_unsupported_enum",                                "check error codes for query functions when extension is not supported"));
 }
 
 }