Skip to content

Commit

Permalink
Fix: Test PVRTC extension and always use power-of-two dimensions
Browse files Browse the repository at this point in the history
dfgdf
  • Loading branch information
spnda committed Mar 2, 2024
1 parent 1918ab4 commit 8fae4fd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
19 changes: 19 additions & 0 deletions external/vulkancts/framework/vulkan/vkImageUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,25 @@ bool isPvrtcFormat (VkFormat format)
return false;
}

bool isPvrtc1Format (VkFormat format)
{
#ifndef CTS_USES_VULKANSC
switch (format)
{
case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG:
case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG:
return true;
default:
return false;
}
#else
DE_UNREF(format);
#endif
return false;
}

const std::map<VkFormat, std::string> spirvFormats = {
{ VK_FORMAT_R32G32B32A32_SFLOAT, "Rgba32f" },
{ VK_FORMAT_R32G32_SFLOAT, "Rg32f" },
Expand Down
1 change: 1 addition & 0 deletions external/vulkancts/framework/vulkan/vkImageUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ bool isYCbCrFormat (VkFormat format);
bool isYCbCrExtensionFormat (VkFormat format);
bool isYCbCrConversionFormat (VkFormat format);
bool isPvrtcFormat (VkFormat format);
bool isPvrtc1Format (VkFormat format);
PlanarFormatDescription getPlanarFormatDescription (VkFormat format);
int getPlaneCount (VkFormat format);
deUint32 getMipmapCount (VkFormat format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,21 @@ ImageAllocator::ImageAllocator (deRandom& random, deBool dedicated, std::vector<
else
m_colorFormat = (VkFormat)optimalformats[deRandom_getUint32(&random) % optimalformats.size()];

int widthAlignment = (isYCbCr420Format(m_colorFormat) || isYCbCr422Format(m_colorFormat)) ? 2 : 1;
int heightAlignment = isYCbCr420Format(m_colorFormat) ? 2 : 1;
if (isPvrtc1Format(m_colorFormat))
{
m_size = tcu::IVec2(pow(2, deRandom_getUint32(&random) % 4),
pow(2, deRandom_getUint32(&random) % 4));
}
else
{
int widthAlignment = (isYCbCr420Format(m_colorFormat) || isYCbCr422Format(m_colorFormat)) ? 2 : 1;
int heightAlignment = isYCbCr420Format(m_colorFormat) ? 2 : 1;

// Random small size for causing potential alignment issues
m_size = tcu::IVec2((deRandom_getUint32(&random) % 16 + 3) & ~(widthAlignment - 1),
(deRandom_getUint32(&random) % 16 + 3) & ~(heightAlignment - 1));
}

// Random small size for causing potential alignment issues
m_size = tcu::IVec2((deRandom_getUint32(&random) % 16 + 3) & ~(widthAlignment - 1),
(deRandom_getUint32(&random) % 16 + 3) & ~(heightAlignment - 1));
// Pick random memory type from the supported set
m_memoryType = memoryTypes[deRandom_getUint32(&random) % memoryTypes.size()];
}
Expand Down
1 change: 1 addition & 0 deletions external/vulkancts/modules/vulkan/vktTestCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ vector<string> filterExtensions (const vector<VkExtensionProperties>& extensions
"VK_NV_representative_fragment_test",
"VK_NV_shader_atomic_float16_vector",
"VK_MVK_macos_surface",
"VK_IMG_format_pvrtc"
};

const char* exclusions[] =
Expand Down

0 comments on commit 8fae4fd

Please sign in to comment.