aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@google.com>2024-03-27 17:08:12 -0400
committerswiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com <swiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-03-28 14:22:32 +0000
commit6912e7d5b75a87d604251cc527063a1ec73c1dea (patch)
tree543d2d7e363d0c9b84f3b50a18c601bafecfaae9
parentf0178b3c40e758ebe7a93fd319f20189c0d0a832 (diff)
downloadswiftshader-6912e7d5b75a87d604251cc527063a1ec73c1dea.tar.gz
Fix alignment bug with depth/stencil resolve attachment
Memory was allocated to cache the depth/stencil resolve attachment info, but this memory needs aligning. Bug: angleproject:7551 Change-Id: I13fa67fe49417b1688cbd36cb3d51ba742b4b05b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/73209 Commit-Queue: Shahbaz Youssefi <syoussefi@google.com> Tested-by: Shahbaz Youssefi <syoussefi@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
-rw-r--r--src/Vulkan/VkRenderPass.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Vulkan/VkRenderPass.cpp b/src/Vulkan/VkRenderPass.cpp
index 135fbdec6..e0feb2abd 100644
--- a/src/Vulkan/VkRenderPass.cpp
+++ b/src/Vulkan/VkRenderPass.cpp
@@ -164,6 +164,12 @@ RenderPass::RenderPass(const VkRenderPassCreateInfo2KHR *pCreateInfo, void *mem)
{
if(subpassDepthStencilResolves == nullptr)
{
+ // Align host memory to 8-bytes
+ const intptr_t memoryAsInt = reinterpret_cast<intptr_t>(hostMemory);
+ const intptr_t alignment = alignof(VkSubpassDescriptionDepthStencilResolve);
+ const intptr_t padding = (alignment - memoryAsInt % alignment) % alignment;
+ hostMemory += padding;
+
subpassDepthStencilResolves = reinterpret_cast<VkSubpassDescriptionDepthStencilResolve *>(hostMemory);
hostMemory += subpassCount * sizeof(VkSubpassDescriptionDepthStencilResolve);
for(uint32_t subpass = 0; subpass < subpassCount; subpass++)
@@ -401,7 +407,9 @@ size_t RenderPass::ComputeRequiredAllocationSize(const VkRenderPassCreateInfo2KH
{
// If any subpass uses DSR, then allocate a VkSubpassDescriptionDepthStencilResolve
// for all subpasses. This allows us to index into our DSR structs using the subpass index.
- requiredMemory += sizeof(VkSubpassDescriptionDepthStencilResolve) * pCreateInfo->subpassCount;
+ //
+ // Add a few bytes for alignment if necessary
+ requiredMemory += sizeof(VkSubpassDescriptionDepthStencilResolve) * pCreateInfo->subpassCount + alignof(VkSubpassDescriptionDepthStencilResolve);
usesDSR = true;
}
// For each subpass that actually uses DSR, allocate a VkAttachmentReference2.