Skip to content

Commit

Permalink
Merge pull request #18088 from hrydgard/vulkan-swizzle-ordering
Browse files Browse the repository at this point in the history
Vulkan: Fix ordering issue in tex loading - decided on color swizzle too early
  • Loading branch information
hrydgard authored Sep 7, 2023
2 parents 9993df5 + f70d233 commit b49e44e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,6 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
entry->vkTex = new VulkanTexture(vulkan, texName);
VulkanTexture *image = entry->vkTex;

const VkComponentMapping *mapping;
switch (actualFmt) {
case VULKAN_4444_FORMAT: mapping = &VULKAN_4444_SWIZZLE; break;
case VULKAN_1555_FORMAT: mapping = &VULKAN_1555_SWIZZLE; break;
case VULKAN_565_FORMAT: mapping = &VULKAN_565_SWIZZLE; break;
default: mapping = &VULKAN_8888_SWIZZLE; break; // no swizzle
}

VkImageLayout imageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;

Expand All @@ -506,6 +498,14 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
actualFmt = VULKAN_8888_FORMAT;
}

const VkComponentMapping *mapping;
switch (actualFmt) {
case VULKAN_4444_FORMAT: mapping = &VULKAN_4444_SWIZZLE; break;
case VULKAN_1555_FORMAT: mapping = &VULKAN_1555_SWIZZLE; break;
case VULKAN_565_FORMAT: mapping = &VULKAN_565_SWIZZLE; break;
default: mapping = &VULKAN_8888_SWIZZLE; break; // no swizzle
}

bool allocSuccess = image->CreateDirect(cmdInit, plan.createW, plan.createH, plan.depth, plan.levelsToCreate, actualFmt, imageLayout, usage, mapping);
if (!allocSuccess && !lowMemoryMode_) {
WARN_LOG_REPORT(G3D, "Texture cache ran out of GPU memory; switching to low memory mode");
Expand Down

0 comments on commit b49e44e

Please sign in to comment.