From: Jeff Bolz Date: Tue, 15 Dec 2015 19:58:19 +0000 (+0000) Subject: Add functions to get depth/stencil format in buffer memory X-Git-Tag: upstream/0.1.0~812^2~434^2~3^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bffa5385346c8425a4bfb6ed270a421e527fce8d;p=platform%2Fupstream%2FVK-GL-CTS.git Add functions to get depth/stencil format in buffer memory --- diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.cpp b/external/vulkancts/framework/vulkan/vkImageUtil.cpp index 7eb7a08..3ae21b9 100644 --- a/external/vulkancts/framework/vulkan/vkImageUtil.cpp +++ b/external/vulkancts/framework/vulkan/vkImageUtil.cpp @@ -889,4 +889,47 @@ tcu::UVec4 mapVkComponentMapping (const vk::VkComponentMapping& mapping) 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 diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.hpp b/external/vulkancts/framework/vulkan/vkImageUtil.hpp index 6084945..c130b57 100644 --- a/external/vulkancts/framework/vulkan/vkImageUtil.hpp +++ b/external/vulkancts/framework/vulkan/vkImageUtil.hpp @@ -53,6 +53,8 @@ bool isCompressedFormat (VkFormat format); tcu::TextureFormat mapVkFormat (VkFormat format); tcu::CompressedTexFormat mapVkCompressedFormat (VkFormat format); +tcu::TextureFormat getDepthCopyFormat (VkFormat combinedFormat); +tcu::TextureFormat getStencilCopyFormat (VkFormat combinedFormat); tcu::Sampler mapVkSampler (const VkSamplerCreateInfo& samplerCreateInfo); tcu::Sampler::CompareMode mapVkSamplerCompareOp (VkCompareOp compareOp); diff --git a/external/vulkancts/modules/vulkan/vktRenderPassTests.cpp b/external/vulkancts/modules/vulkan/vktRenderPassTests.cpp index b72fe1d..f7f1748 100644 --- a/external/vulkancts/modules/vulkan/vktRenderPassTests.cpp +++ b/external/vulkancts/modules/vulkan/vktRenderPassTests.cpp @@ -1186,8 +1186,8 @@ public: 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(); @@ -3250,11 +3250,11 @@ bool logAndVerifyImages (TestLog& log, 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(); @@ -3278,8 +3278,7 @@ bool logAndVerifyImages (TestLog& log, 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());