summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-02 17:05:58 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-02 17:05:58 +0000
commitc9661af1a7b9cc643e1adbee0779b0a366bd6189 (patch)
tree1b89bf20574d3847778a59ba2f493c72873d1ce2 /Graphics/GraphicsEngineVulkan
parentUpdated SPIRV-Cross submodule (diff)
downloadDiligentCore-c9661af1a7b9cc643e1adbee0779b0a366bd6189.tar.gz
DiligentCore-c9661af1a7b9cc643e1adbee0779b0a366bd6189.zip
Fixed Vulkan validation error message about incorrect buffer offset alignment for compressed formats
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index 538467d1..5f93f689 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -1219,6 +1219,13 @@ namespace Diligent
const auto& DeviceLimits = m_pDevice.RawPtr<const RenderDeviceVkImpl>()->GetPhysicalDevice().GetProperties().limits;
// Source buffer offset must be multiple of 4 (18.4)
auto BufferOffsetAlignment = std::max(DeviceLimits.optimalBufferCopyOffsetAlignment, VkDeviceSize{4});
+ // If the calling command’s VkImage parameter is a compressed image, bufferOffset must be a multiple of
+ // the compressed texel block size in bytes (18.4)
+ const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
+ if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
+ {
+ BufferOffsetAlignment = std::max(BufferOffsetAlignment, VkDeviceSize{FmtAttribs.ComponentSize});
+ }
auto Allocation = m_UploadHeap.Allocate(CopyInfo.MemorySize, BufferOffsetAlignment);
// The allocation will stay in the upload heap until the end of the frame at which point all upload
// pages will be discarded
@@ -1342,6 +1349,13 @@ namespace Diligent
const auto& DeviceLimits = m_pDevice.RawPtr<RenderDeviceVkImpl>()->GetPhysicalDevice().GetProperties().limits;
// Source buffer offset must be multiple of 4 (18.4)
auto Alignment = std::max(DeviceLimits.optimalBufferCopyOffsetAlignment, VkDeviceSize{4});
+ // If the calling command’s VkImage parameter is a compressed image, bufferOffset must be a multiple of
+ // the compressed texel block size in bytes (18.4)
+ const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
+ if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
+ {
+ Alignment = std::max(Alignment, VkDeviceSize{FmtAttribs.ComponentSize});
+ }
auto Allocation = AllocateDynamicSpace(CopyInfo.MemorySize, static_cast<Uint32>(Alignment));
MappedData.pData = reinterpret_cast<Uint8*>(Allocation.pDynamicMemMgr->GetCPUAddress()) + Allocation.AlignedOffset;