From b635ce20ea1e5305fe69095f0741916f66f182ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jarkko=20P=C3=B6yry?= Date: Mon, 20 Apr 2015 19:46:36 -0700 Subject: [PATCH] Simplify sglr depth-stencil related code by using tcu and rr utilities. Change-Id: Id1996c65e3f58729cf3aa54da8653e249baa704e --- .../simplereference/sglrReferenceContext.cpp | 149 ++++++++------------- .../referencerenderer/rrFragmentOperations.cpp | 1 + 2 files changed, 55 insertions(+), 95 deletions(-) diff --git a/framework/opengl/simplereference/sglrReferenceContext.cpp b/framework/opengl/simplereference/sglrReferenceContext.cpp index c923e6f..ce0d09b 100644 --- a/framework/opengl/simplereference/sglrReferenceContext.cpp +++ b/framework/opengl/simplereference/sglrReferenceContext.cpp @@ -2981,12 +2981,18 @@ static int getNumStencilBits (const tcu::TextureFormat& format) } } -static inline int maskStencil (int bits, int s) { return s & ((1< row (access.raw().getWidth()*access.raw().getHeight()*pixelSize); - tcu::PixelBufferAccess rowAccess (depthBuf.raw().getFormat(), access.raw().getWidth(), access.raw().getHeight(), 1, &row[0]); - - for (int y = 0; y < rowAccess.getHeight(); y++) - for (int x = 0; x < rowAccess.getWidth(); x++) - rowAccess.setPixel(tcu::Vec4(m_clearDepth), x, y); - - for (int y = 0; y < access.raw().getDepth(); y++) - deMemcpy((deUint8*)access.raw().getDataPtr() + access.raw().getSlicePitch()*y, &row[0], (int)row.size()); - } + rr::MultisamplePixelBufferAccess access = getDepthMultisampleAccess(rr::getSubregion(depthBuf, depthArea.x(), depthArea.y(), depthArea.z(), depthArea.w())); + rr::clearDepth(access, m_clearDepth); } if (hasStencil && (buffers & GL_STENCIL_BUFFER_BIT) != 0) { - rr::MultisamplePixelBufferAccess access = rr::getSubregion(stencilBuf, stencilArea.x(), stencilArea.y(), stencilArea.z(), stencilArea.w()); + rr::MultisamplePixelBufferAccess access = getStencilMultisampleAccess(rr::getSubregion(stencilBuf, stencilArea.x(), stencilArea.y(), stencilArea.z(), stencilArea.w())); int stencilBits = getNumStencilBits(stencilBuf.raw().getFormat()); int stencil = maskStencil(stencilBits, m_clearStencil); - bool isSharedDepthStencil = stencilBuf.raw().getFormat().order != tcu::TextureFormat::S; - if (isSharedDepthStencil || ((m_stencil[rr::FACETYPE_FRONT].writeMask & ((1u< row (access.raw().getWidth()*access.raw().getHeight()*pixelSize); - tcu::PixelBufferAccess rowAccess (stencilBuf.raw().getFormat(), access.raw().getWidth(), access.raw().getHeight(), 1, &row[0]); - - for (int y = 0; y < rowAccess.getHeight(); y++) - for (int x = 0; x < rowAccess.getWidth(); x++) - rowAccess.setPixel(tcu::IVec4(stencil), x, y); - - for (int y = 0; y < access.raw().getDepth(); y++) - deMemcpy((deUint8*)access.raw().getDataPtr() + access.raw().getSlicePitch()*y, &row[0], (int)row.size()); - } + rr::clearStencil(access, stencil); } } @@ -3469,13 +3431,13 @@ void ReferenceContext::clearBufferiv (deUint32 buffer, int drawbuffer, const int if (!isEmpty(area) && m_stencil[rr::FACETYPE_FRONT].writeMask != 0) { - rr::MultisamplePixelBufferAccess access = rr::getSubregion(stencilBuf, area.x(), area.y(), area.z(), area.w()); + rr::MultisamplePixelBufferAccess access = getStencilMultisampleAccess(rr::getSubregion(stencilBuf, area.x(), area.y(), area.z(), area.w())); int stencil = value[0]; for (int y = 0; y < access.raw().getDepth(); y++) for (int x = 0; x < access.raw().getHeight(); x++) for (int s = 0; s < access.getNumSamples(); s++) - writeStencilOnly(access, s, x, y, stencil, m_stencil[rr::FACETYPE_FRONT].writeMask); + writeMaskedStencil(access, s, x, y, stencil, m_stencil[rr::FACETYPE_FRONT].writeMask); } } } @@ -3525,10 +3487,7 @@ void ReferenceContext::clearBufferfv (deUint32 buffer, int drawbuffer, const flo rr::MultisamplePixelBufferAccess access = rr::getSubregion(depthBuf, area.x(), area.y(), area.z(), area.w()); float depth = value[0]; - for (int y = 0; y < access.raw().getDepth(); y++) - for (int x = 0; x < access.raw().getHeight(); x++) - for (int s = 0; s < access.getNumSamples(); s++) - writeDepthOnly(access, s, x, y, depth); + rr::clearDepth(access, depth); } } } diff --git a/framework/referencerenderer/rrFragmentOperations.cpp b/framework/referencerenderer/rrFragmentOperations.cpp index fa8ad92..2994b82 100644 --- a/framework/referencerenderer/rrFragmentOperations.cpp +++ b/framework/referencerenderer/rrFragmentOperations.cpp @@ -745,6 +745,7 @@ void FragmentProcessor::render (const rr::MultisamplePixelBufferAccess& msColor const FragmentOperationState& state) { DE_ASSERT(fragmentFacing < FACETYPE_LAST); + DE_ASSERT(state.numStencilBits < 32); // code bitshifts numStencilBits, avoid undefined behavior const tcu::PixelBufferAccess& colorBuffer = msColorBuffer.raw(); const tcu::PixelBufferAccess& depthBuffer = msDepthBuffer.raw(); -- 2.7.4