nv2a/vk: Ensure pack buffer offsets meet minStorageBufferOffsetAlignment

This commit is contained in:
Matt Borgerson 2024-07-27 14:31:12 -07:00 committed by mborgerson
parent 374eada8ef
commit c881f8641f
3 changed files with 17 additions and 6 deletions

View File

@ -407,7 +407,9 @@ void pgraph_vk_pack_depth_stencil(PGRAPHState *pg, SurfaceBinding *surface,
},
{
.buffer = src,
.offset = depth_size,
.offset = ROUND_UP(
depth_size,
r->device_props.limits.minStorageBufferOffsetAlignment),
.range = stencil_size,
},
{
@ -477,7 +479,9 @@ void pgraph_vk_unpack_depth_stencil(PGRAPHState *pg, SurfaceBinding *surface,
},
{
.buffer = dst,
.offset = depth_size,
.offset = ROUND_UP(
depth_size,
r->device_props.limits.minStorageBufferOffsetAlignment),
.range = stencil_size,
},
{

View File

@ -252,11 +252,14 @@ static void download_surface_to_buffer(NV2AState *d, SurfaceBinding *surface,
}
if (surface->host_fmt.aspect & VK_IMAGE_ASPECT_STENCIL_BIT) {
size_t depth_size = scaled_width * scaled_height * 4;
copy_regions[num_copy_regions++] = (VkBufferImageCopy){
.bufferOffset = scaled_width * scaled_height * 4,
.bufferOffset = ROUND_UP(
depth_size,
r->device_props.limits.minStorageBufferOffsetAlignment),
.imageSubresource.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT,
.imageSubresource.layerCount = 1,
.imageExtent = (VkExtent3D){scaled_width, scaled_height, 1},
.imageExtent = (VkExtent3D){ scaled_width, scaled_height, 1 },
};
}
@ -961,7 +964,9 @@ void pgraph_vk_upload_surface_data(NV2AState *d, SurfaceBinding *surface,
// Already scaled during compute. Adjust copy regions.
regions[0].imageExtent = (VkExtent3D){ scaled_width, scaled_height, 1 };
regions[1].imageExtent = regions[0].imageExtent;
regions[1].bufferOffset = unpacked_depth_image_size;
regions[1].bufferOffset =
ROUND_UP(unpacked_depth_image_size,
r->device_props.limits.minStorageBufferOffsetAlignment);
copy_buffer = unpack_buffer;
}

View File

@ -638,7 +638,9 @@ static void copy_zeta_surface_to_texture(PGRAPHState *pg, SurfaceBinding *surfac
};
if (surface->host_fmt.aspect & VK_IMAGE_ASPECT_STENCIL_BIT) {
stencil_buffer_offset = scaled_width * scaled_height * 4;
stencil_buffer_offset =
ROUND_UP(scaled_width * scaled_height * 4,
r->device_props.limits.minStorageBufferOffsetAlignment);
stencil_buffer_size = scaled_width * scaled_height;
copied_image_size += stencil_buffer_size;