Home | History | Annotate | Download | only in draw_buffers_indexed
      1 /*-------------------------------------------------------------------------
      2  * OpenGL Conformance Test Suite
      3  * -----------------------------
      4  *
      5  * Copyright (c) 2015-2016 The Khronos Group Inc.
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  */ /*!
     20  * \file
     21  * \brief
     22  */ /*-------------------------------------------------------------------*/
     23 
     24 /*!
     25  * \file  esextcDrawBuffersIndexedSetGet.hpp
     26  * \brief Draw Buffers Indexed tests 3. Set and get
     27  */ /*-------------------------------------------------------------------*/
     28 
     29 #include "esextcDrawBuffersIndexedSetGet.hpp"
     30 #include "tcuTestLog.hpp"
     31 
     32 namespace glcts
     33 {
     34 
     35 /** Constructor
     36  *
     37  *  @param context     Test context
     38  *  @param name        Test case's name
     39  *  @param description Test case's description
     40  **/
     41 DrawBuffersIndexedSetGet::DrawBuffersIndexedSetGet(Context& context, const ExtParameters& extParams, const char* name,
     42 												   const char* description)
     43 	: DrawBuffersIndexedBase(context, extParams, name, description)
     44 {
     45 	/* Left blank on purpose */
     46 }
     47 
     48 tcu::TestNode::IterateResult DrawBuffersIndexedSetGet::iterate()
     49 {
     50 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
     51 
     52 	// Check number of available draw buffers
     53 	glw::GLint maxDrawBuffers = 0;
     54 	gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
     55 	if (maxDrawBuffers < 4)
     56 	{
     57 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Minimum number of draw buffers too low");
     58 		return STOP;
     59 	}
     60 
     61 	BlendMaskStateMachine state(m_context, m_testCtx.getLog(), maxDrawBuffers);
     62 
     63 	state.SetEnable();
     64 	state.SetColorMask(0, 0, 0, 0);
     65 	state.SetBlendEquation(GL_FUNC_SUBTRACT);
     66 	state.SetBlendFunc(GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE);
     67 	if (!state.CheckAll())
     68 	{
     69 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to change blending and color mask state");
     70 		return STOP;
     71 	}
     72 
     73 	state.SetDisablei(1);
     74 	state.SetColorMaski(1, 1, 1, 1, 1);
     75 	state.SetBlendEquationi(1, GL_MIN);
     76 	state.SetBlendFunci(1, GL_ONE_MINUS_DST_COLOR, GL_CONSTANT_ALPHA);
     77 	if (!state.CheckAll())
     78 	{
     79 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to change blending and color mask state");
     80 		return STOP;
     81 	}
     82 
     83 	state.SetBlendEquationSeparatei(2, GL_MAX, GL_FUNC_ADD);
     84 	state.SetBlendFuncSeparatei(2, GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_DST_COLOR);
     85 	if (!state.CheckAll())
     86 	{
     87 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to change blending and color mask state");
     88 		return STOP;
     89 	}
     90 
     91 	state.SetDefaults();
     92 
     93 	// Check for error
     94 	glw::GLenum error_code = gl.getError();
     95 	if (error_code != GL_NO_ERROR)
     96 	{
     97 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Some functions generated error");
     98 		return STOP;
     99 	}
    100 
    101 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
    102 	return STOP;
    103 }
    104 
    105 } // namespace glcts
    106