diff --git a/hw/xbox/nv2a/pgraph/vk/surface-compute.c b/hw/xbox/nv2a/pgraph/vk/surface-compute.c index 8009b993dc..3f5659d8a3 100644 --- a/hw/xbox/nv2a/pgraph/vk/surface-compute.c +++ b/hw/xbox/nv2a/pgraph/vk/surface-compute.c @@ -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, }, { diff --git a/hw/xbox/nv2a/pgraph/vk/surface.c b/hw/xbox/nv2a/pgraph/vk/surface.c index d90995ba01..5351e5602c 100644 --- a/hw/xbox/nv2a/pgraph/vk/surface.c +++ b/hw/xbox/nv2a/pgraph/vk/surface.c @@ -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; } diff --git a/hw/xbox/nv2a/pgraph/vk/texture.c b/hw/xbox/nv2a/pgraph/vk/texture.c index 7cf22f5d71..543b907ebb 100644 --- a/hw/xbox/nv2a/pgraph/vk/texture.c +++ b/hw/xbox/nv2a/pgraph/vk/texture.c @@ -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;