, m_bias (0.0f, 0.0f, 0.0f, 0.0f)
, m_compression (compression)
{
- computePixelScaleBias(access, m_scale, m_bias);
+ // Simplify combined formats that only use a single channel
+ if (tcu::isCombinedDepthStencilType(m_access.getFormat().type))
+ {
+ if (m_access.getFormat().order == tcu::TextureFormat::D)
+ m_access = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
+ else if (m_access.getFormat().order == tcu::TextureFormat::S)
+ m_access = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
+ }
+
+ // Implicit scale and bias
+ if (m_access.getFormat().order != tcu::TextureFormat::DS)
+ computePixelScaleBias(m_access, m_scale, m_bias);
+ else
+ {
+ // Pack D and S bias and scale to R and G
+ const ConstPixelBufferAccess depthAccess = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
+ const ConstPixelBufferAccess stencilAccess = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
+ tcu::Vec4 depthScale;
+ tcu::Vec4 depthBias;
+ tcu::Vec4 stencilScale;
+ tcu::Vec4 stencilBias;
+
+ computePixelScaleBias(depthAccess, depthScale, depthBias);
+ computePixelScaleBias(stencilAccess, stencilScale, stencilBias);
+
+ m_scale = tcu::Vec4(depthScale.x(), stencilScale.x(), 0.0f, 0.0f);
+ m_bias = tcu::Vec4(depthBias.x(), stencilBias.x(), 0.0f, 0.0f);
+ }
+}
+
+LogImage::LogImage (const std::string& name, const std::string& description, const ConstPixelBufferAccess& access, const Vec4& scale, const Vec4& bias, qpImageCompressionMode compression)
+ : m_name (name)
+ , m_description (description)
+ , m_access (access)
+ , m_scale (scale)
+ , m_bias (bias)
+ , m_compression (compression)
+{
+ // Cannot set scale and bias of combined formats
+ DE_ASSERT(access.getFormat().order != tcu::TextureFormat::DS);
+
+ // Simplify access
+ if (tcu::isCombinedDepthStencilType(access.getFormat().type))
+ {
+ if (access.getFormat().order == tcu::TextureFormat::D)
+ m_access = tcu::getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_DEPTH);
+ if (access.getFormat().order == tcu::TextureFormat::S)
+ m_access = tcu::getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_STENCIL);
+ else
+ {
+ // Cannot log a DS format
+ DE_ASSERT(false);
+ return;
+ }
+ }
+}
+
+void LogImage::write (TestLog& log) const
+{
+ if (m_access.getFormat().order != tcu::TextureFormat::DS)
+ log.writeImage(m_name.c_str(), m_description.c_str(), m_access, m_scale, m_bias, m_compression);
+ else
+ {
+ const ConstPixelBufferAccess depthAccess = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_DEPTH);
+ const ConstPixelBufferAccess stencilAccess = tcu::getEffectiveDepthStencilAccess(m_access, tcu::Sampler::MODE_STENCIL);
+
+ log.startImageSet(m_name.c_str(), m_description.c_str());
+ log.writeImage("Depth", "Depth channel", depthAccess, m_scale.swizzle(0, 0, 0, 0), m_bias.swizzle(0, 0, 0, 0), m_compression);
+ log.writeImage("Stencil", "Stencil channel", stencilAccess, m_scale.swizzle(1, 1, 1, 1), m_bias.swizzle(1, 1, 1, 1), m_compression);
+ log.endImageSet();
+ }
}
// MessageBuilder
int height = access.getHeight();
int depth = access.getDepth();
+ // Writing a combined image does not make sense
+ DE_ASSERT(!tcu::isCombinedDepthStencilType(access.getFormat().type));
+
// Do not bother with preprocessing if images are not stored
if ((qpTestLog_getLogFlags(m_log) & QP_TEST_LOG_EXCLUDE_IMAGES) != 0)
return;
LogImage (const std::string& name, const std::string& description, const ConstPixelBufferAccess& access, qpImageCompressionMode compression = QP_IMAGE_COMPRESSION_MODE_BEST);
- LogImage (const std::string& name, const std::string& description, const ConstPixelBufferAccess& access, const Vec4& scale, const Vec4& bias, qpImageCompressionMode compression = QP_IMAGE_COMPRESSION_MODE_BEST)
- : m_name (name)
- , m_description (description)
- , m_access (access)
- , m_scale (scale)
- , m_bias (bias)
- , m_compression (compression)
- {
- }
+ LogImage (const std::string& name, const std::string& description, const ConstPixelBufferAccess& access, const Vec4& scale, const Vec4& bias, qpImageCompressionMode compression = QP_IMAGE_COMPRESSION_MODE_BEST);
void write (TestLog& log) const;
log.startImageSet(m_name.c_str(), m_description.c_str());
}
-inline void LogImage::write (TestLog& log) const
-{
- log.writeImage(m_name.c_str(), m_description.c_str(), m_access, m_scale, m_bias, m_compression);
-}
-
inline void LogSection::write (TestLog& log) const
{
log.startSection(m_name.c_str(), m_description.c_str());
}
}
+void resolveMultisampleDepthBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src)
+{
+ DE_ASSERT(dst.getWidth() == src.raw().getHeight());
+ DE_ASSERT(dst.getHeight() == src.raw().getDepth());
+
+ const tcu::ConstPixelBufferAccess effectiveSrc = tcu::getEffectiveDepthStencilAccess(src.raw(), tcu::Sampler::MODE_DEPTH);
+ const tcu::PixelBufferAccess effectiveDst = tcu::getEffectiveDepthStencilAccess(dst, tcu::Sampler::MODE_DEPTH);
+
+ if (src.getNumSamples() == 1)
+ {
+ // fast-path for non-multisampled cases
+ tcu::copy(effectiveDst, MultisampleConstPixelBufferAccess::fromMultisampleAccess(effectiveSrc).toSinglesampleAccess());
+ }
+ else
+ {
+ const float numSamplesInv = 1.0f / (float)src.getNumSamples();
+
+ for (int y = 0; y < dst.getHeight(); y++)
+ for (int x = 0; x < dst.getWidth(); x++)
+ {
+ float sum = 0.0f;
+ for (int s = 0; s < src.getNumSamples(); s++)
+ sum += effectiveSrc.getPixDepth(s, x, y);
+
+ effectiveDst.setPixDepth(sum*numSamplesInv, x, y);
+ }
+ }
+}
+
+void resolveMultisampleStencilBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src)
+{
+ DE_ASSERT(dst.getWidth() == src.raw().getHeight());
+ DE_ASSERT(dst.getHeight() == src.raw().getDepth());
+
+ const tcu::ConstPixelBufferAccess effectiveSrc = tcu::getEffectiveDepthStencilAccess(src.raw(), tcu::Sampler::MODE_STENCIL);
+ const tcu::PixelBufferAccess effectiveDst = tcu::getEffectiveDepthStencilAccess(dst, tcu::Sampler::MODE_STENCIL);
+
+ if (src.getNumSamples() == 1)
+ {
+ // fast-path for non-multisampled cases
+ tcu::copy(effectiveDst, MultisampleConstPixelBufferAccess::fromMultisampleAccess(effectiveSrc).toSinglesampleAccess());
+ }
+ else
+ {
+ // Resolve by selecting one
+ for (int y = 0; y < dst.getHeight(); y++)
+ for (int x = 0; x < dst.getWidth(); x++)
+ effectiveDst.setPixStencil(effectiveSrc.getPixStencil(0, x, y), x, y);
+ }
+}
+
+void resolveMultisampleBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src)
+{
+ switch (src.raw().getFormat().order)
+ {
+ case tcu::TextureFormat::D:
+ resolveMultisampleDepthBuffer(dst, src);
+ return;
+
+ case tcu::TextureFormat::S:
+ resolveMultisampleStencilBuffer(dst, src);
+ return;
+
+ case tcu::TextureFormat::DS:
+ resolveMultisampleDepthBuffer(dst, src);
+ resolveMultisampleStencilBuffer(dst, src);
+ return;
+
+ default:
+ resolveMultisampleColorBuffer(dst, src);
+ return;
+ }
+}
+
tcu::Vec4 resolveMultisamplePixel (const MultisampleConstPixelBufferAccess& access, int x, int y)
{
tcu::Vec4 sum;
MultisampleConstPixelBufferAccess getSubregion (const MultisampleConstPixelBufferAccess& access, int x, int y, int width, int height);
void resolveMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src);
+void resolveMultisampleDepthBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src);
+void resolveMultisampleStencilBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src);
+void resolveMultisampleBuffer (const tcu::PixelBufferAccess& dst, const MultisampleConstPixelBufferAccess& src);
tcu::Vec4 resolveMultisamplePixel (const MultisampleConstPixelBufferAccess& access, int x, int y);
void clear (const MultisamplePixelBufferAccess& access, const tcu::Vec4& color);
(subCase.vtx[1].z() == subCase.vtx[2].z());
const float refDepth = subCase.vtx[0].z()*(zf - zn)/2.0f + (zn + zf)/2.0f;
- rr::resolveMultisampleColorBuffer(resolvedColor.getAccess(), rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(interpolated.getAccess()));
- rr::resolveMultisampleColorBuffer(resolvedDepthStencil.getAccess(), rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(depthStencil.getAccess()));
+ rr::resolveMultisampleBuffer(resolvedColor.getAccess(), rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(interpolated.getAccess()));
+ rr::resolveMultisampleBuffer(resolvedDepthStencil.getAccess(), rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(depthStencil.getAccess()));
clear(errorAccess, Vec4(0.0f, 1.0f, 0.0f, 1.0f));
for (int y = 0; y < height; y++)