From 168ef42326dd77501355575a1f5aa7536b63c7b2 Mon Sep 17 00:00:00 2001 From: Jeannot Breton Date: Tue, 20 Jun 2017 16:25:01 -0500 Subject: [PATCH] Set DrawBuffers for each fragment color output Update the DrawBuffers call to properly map the fragment color output to it expected color attachment Affects: KHR-GL45.enhanced_layouts.fragment_data_location_api Components: OpenGL VK-GL-CTS issue: 517 Change-Id: I54678528b59b9732fbe466df1a50707a3a4716ba --- .../modules/gl/gl4cEnhancedLayoutsTests.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp b/external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp index 4686f5b..a9246c1 100644 --- a/external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp +++ b/external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp @@ -19331,16 +19331,18 @@ void FragmentDataLocationAPITest::prepareFramebuffer(Utils::Framebuffer& framebu /* Set up drawbuffers */ const Functions& gl = m_context.getRenderContext().getFunctions(); - // 1. There are only 4 outputs in fragment shader, so only need to do buffer mapping for 4 attachments, - // 2. another issue is each output variable has a location, it is the fragment color index, so the index of - // GL_COLOR_ATTACHMENT in glDrawBuffers() should keep the same with the location, to make test correct, - // we needt to change the above code of glDrawBuffers() as : - GLint buffers_size = 4; - GLenum buffers[] = { GLenum(GL_COLOR_ATTACHMENT0 + m_chichi_location), - GLenum(GL_COLOR_ATTACHMENT0 + m_goku_location), - GLenum(GL_COLOR_ATTACHMENT0 + m_goten_location), - GLenum(GL_COLOR_ATTACHMENT0 + m_gohan_location) }; - gl.drawBuffers(buffers_size, buffers); + // The fragment shader can have more than 4 color outputs, but it only care about 4 (goku, gohan, goten, chichi). + // We will first initialize all draw buffers to NONE and then set the real value for the 4 outputs we care about + GLint maxDrawBuffers = 0; + gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); + + std::vector buffers(maxDrawBuffers, GL_NONE); + buffers[m_chichi_location] = GLenum(GL_COLOR_ATTACHMENT0 + m_chichi_location); + buffers[m_goten_location] = GLenum(GL_COLOR_ATTACHMENT0 + m_goten_location); + buffers[m_goku_location] = GLenum(GL_COLOR_ATTACHMENT0 + m_goku_location); + buffers[m_gohan_location] = GLenum(GL_COLOR_ATTACHMENT0 + m_gohan_location); + + gl.drawBuffers(maxDrawBuffers, buffers.data()); GLU_EXPECT_NO_ERROR(gl.getError(), "DrawBuffers"); } -- 2.7.4