return swizzle;
}
+// Get a format the matches the layout in buffer memory used for a
+// buffer<->image copy on a depth/stencil format.
+tcu::TextureFormat getDepthCopyFormat(VkFormat combinedFormat)
+{
+ switch (combinedFormat) {
+ case VK_FORMAT_D16_UNORM:
+ case VK_FORMAT_X8_D24_UNORM_PACK32:
+ case VK_FORMAT_D32_SFLOAT:
+ return mapVkFormat(combinedFormat);
+
+ case VK_FORMAT_D16_UNORM_S8_UINT:
+ return mapVkFormat(VK_FORMAT_D16_UNORM);
+ case VK_FORMAT_D24_UNORM_S8_UINT:
+ return mapVkFormat(VK_FORMAT_X8_D24_UNORM_PACK32);
+ case VK_FORMAT_D32_SFLOAT_S8_UINT:
+ return mapVkFormat(VK_FORMAT_D32_SFLOAT);
+
+ case VK_FORMAT_S8_UINT:
+ default:
+ DE_FATAL("Unexpected depth/stencil format");
+ return tcu::TextureFormat();
+ }
+}
+
+// Get a format the matches the layout in buffer memory used for a
+// buffer<->image copy on a depth/stencil format.
+tcu::TextureFormat getStencilCopyFormat(VkFormat combinedFormat)
+{
+ switch (combinedFormat) {
+ case VK_FORMAT_D16_UNORM_S8_UINT:
+ case VK_FORMAT_D24_UNORM_S8_UINT:
+ case VK_FORMAT_D32_SFLOAT_S8_UINT:
+ case VK_FORMAT_S8_UINT:
+ return mapVkFormat(VK_FORMAT_S8_UINT);
+ case VK_FORMAT_D16_UNORM:
+ case VK_FORMAT_X8_D24_UNORM_PACK32:
+ case VK_FORMAT_D32_SFLOAT:
+ default:
+ DE_FATAL("Unexpected depth/stencil format");
+ return tcu::TextureFormat();
+ }
+}
+
} // vk
if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
{
- const tcu::TextureFormat depthFormat = tcu::getEffectiveDepthStencilTextureFormat(format, tcu::Sampler::MODE_DEPTH);
- const tcu::TextureFormat stencilFormat = tcu::getEffectiveDepthStencilTextureFormat(format, tcu::Sampler::MODE_STENCIL);
+ const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
+ const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
{
- const tcu::TextureFormat depthFormat = tcu::getEffectiveDepthStencilTextureFormat(format, tcu::Sampler::MODE_DEPTH);
+ const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
const VkDeviceSize depthBufferSize = targetSize.x() * targetSize.y() * depthFormat.getPixelSize();
void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
- const tcu::TextureFormat stencilFormat = tcu::getEffectiveDepthStencilTextureFormat(format, tcu::Sampler::MODE_STENCIL);
+ const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
const VkDeviceSize stencilBufferSize = targetSize.x() * targetSize.y() * stencilFormat.getPixelSize();
void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
VK_CHECK(vk.invalidateMappedMemoryRanges(device, 2u, ranges));
{
- const ConstPixelBufferAccess depthAccess (depthFormat, tcu::IVec3(targetSize.x(), targetSize.y(), 1),
- tcu::IVec3(format.getPixelSize(), format.getPixelSize() * targetSize.x(), 0), depthPtr);
+ const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());