Skip to content

Commit

Permalink
[dxvk] Fix image view swizzling
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Sep 26, 2024
1 parent 5e5c283 commit 78f5136
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/dxvk/dxvk_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,11 @@ namespace dxvk {
key.mipCount = info.numLevels;
key.layerIndex = info.minLayer;
key.layerCount = info.numLayers;

if (info.usage == VK_IMAGE_USAGE_SAMPLED_BIT) {
key.packedSwizzle =
(uint16_t(info.swizzle.r) << 0) |
(uint16_t(info.swizzle.g) << 4) |
(uint16_t(info.swizzle.b) << 8) |
(uint16_t(info.swizzle.a) << 12);
}
key.packedSwizzle =
(uint16_t(info.swizzle.r) << 0) |
(uint16_t(info.swizzle.g) << 4) |
(uint16_t(info.swizzle.b) << 8) |
(uint16_t(info.swizzle.a) << 12);

std::unique_lock lock(m_viewMutex);

Expand Down Expand Up @@ -298,6 +295,11 @@ namespace dxvk {
return VK_NULL_HANDLE;
}

// We need to expose RT and UAV swizzles to the backend,
// but cannot legally pass them down to Vulkan
if (key.usage != VK_IMAGE_USAGE_SAMPLED_BIT)
key.packedSwizzle = 0u;

return m_image->m_storage->createImageView(key);
}

Expand Down

0 comments on commit 78f5136

Please sign in to comment.