+
+void FragmentProcessor::executeDepthBoundsTest (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const float minDepthBound, const float maxDepthBound, const tcu::ConstPixelBufferAccess& depthBuffer)
+{
+ if (depthBuffer.getFormat().type == tcu::TextureFormat::FLOAT || depthBuffer.getFormat().type == tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV)
+ {
+ for (int regSampleNdx = 0; regSampleNdx < SAMPLE_REGISTER_SIZE; ++regSampleNdx)
+ {
+ if (m_sampleRegister[regSampleNdx].isAlive)
+ {
+ const int fragSampleNdx = regSampleNdx % numSamplesPerFragment;
+ const Fragment& frag = inputFragments[fragNdxOffset + regSampleNdx/numSamplesPerFragment];
+ const float depthBufferValue = depthBuffer.getPixDepth(fragSampleNdx, frag.pixelCoord.x(), frag.pixelCoord.y());
+
+ if (!de::inRange(depthBufferValue, minDepthBound, maxDepthBound))
+ m_sampleRegister[regSampleNdx].isAlive = false;
+ }
+ }
+ }
+ else
+ {
+ /* Convert float bounds to target buffer format for comparison */
+
+ deUint32 minDepthBoundUint, maxDepthBoundUint;
+ {
+ deUint32 buffer[2];
+ DE_ASSERT(sizeof(buffer) >= (size_t)depthBuffer.getFormat().getPixelSize());
+
+ tcu::PixelBufferAccess access(depthBuffer.getFormat(), 1, 1, 1, &buffer);
+ access.setPixDepth(minDepthBound, 0, 0, 0);
+ minDepthBoundUint = access.getPixelUint(0, 0, 0).x();
+ }
+ {
+ deUint32 buffer[2];
+
+ tcu::PixelBufferAccess access(depthBuffer.getFormat(), 1, 1, 1, &buffer);
+ access.setPixDepth(maxDepthBound, 0, 0, 0);
+ maxDepthBoundUint = access.getPixelUint(0, 0, 0).x();
+ }
+
+ for (int regSampleNdx = 0; regSampleNdx < SAMPLE_REGISTER_SIZE; ++regSampleNdx)
+ {
+ if (m_sampleRegister[regSampleNdx].isAlive)
+ {
+ const int fragSampleNdx = regSampleNdx % numSamplesPerFragment;
+ const Fragment& frag = inputFragments[fragNdxOffset + regSampleNdx / numSamplesPerFragment];
+ const deUint32 depthBufferValue = depthBuffer.getPixelUint(fragSampleNdx, frag.pixelCoord.x(), frag.pixelCoord.y()).x();
+
+ if (!de::inRange(depthBufferValue, minDepthBoundUint, maxDepthBoundUint))
+ m_sampleRegister[regSampleNdx].isAlive = false;
+ }
+ }
+ }
+}
+