summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNanley Chery <[email protected]>2016-05-09 11:45:07 -0700
committerNanley Chery <[email protected]>2016-05-13 14:08:57 -0700
commit6674d018f7eab899520c1459e569bdea3a6f4874 (patch)
tree3573bcd91ffc9280fecd5088b054b702ff558957
parentff5c3126235804e963abaa94e5ea50d1295cdd5f (diff)
anv/copy: Fix copying Images from Buffers with larger dimensions
This function previously assumed that the Buffer and Image had matching dimensions. However, it is possible to copy from a Buffer with larger dimensions than the Image. Modify the copy function to enable this. v2: Use ternary instead of MAX for setting bufferExtent (Jason Ekstrand) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95292 Signed-off-by: Nanley Chery <[email protected]> Tested-by: Matthew Waters <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/intel/vulkan/anv_meta_copy.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/intel/vulkan/anv_meta_copy.c b/src/intel/vulkan/anv_meta_copy.c
index 982fa7e10c1..372333eb3a9 100644
--- a/src/intel/vulkan/anv_meta_copy.c
+++ b/src/intel/vulkan/anv_meta_copy.c
@@ -128,18 +128,20 @@ meta_copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
const VkOffset3D img_offset_el =
meta_region_offset_el(image, &pRegions[r].imageOffset);
const VkExtent3D bufferExtent = {
- .width = pRegions[r].bufferRowLength,
- .height = pRegions[r].bufferImageHeight,
+ .width = pRegions[r].bufferRowLength ?
+ pRegions[r].bufferRowLength : pRegions[r].imageExtent.width,
+ .height = pRegions[r].bufferImageHeight ?
+ pRegions[r].bufferImageHeight : pRegions[r].imageExtent.height,
};
-
- /* Start creating blit rect */
const VkExtent3D buf_extent_el =
meta_region_extent_el(image, &bufferExtent);
+
+ /* Start creating blit rect */
const VkExtent3D img_extent_el =
meta_region_extent_el(image, &pRegions[r].imageExtent);
struct anv_meta_blit2d_rect rect = {
- .width = MAX2(buf_extent_el.width, img_extent_el.width),
- .height = MAX2(buf_extent_el.height, img_extent_el.height),
+ .width = img_extent_el.width,
+ .height = img_extent_el.height,
};
/* Create blit surfaces */
@@ -153,7 +155,7 @@ meta_copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
.tiling = ISL_TILING_LINEAR,
.base_offset = buffer->offset + pRegions[r].bufferOffset,
.bs = forward ? image->format->isl_layout->bs : img_bsurf.bs,
- .pitch = rect.width * buf_bsurf.bs,
+ .pitch = buf_extent_el.width * buf_bsurf.bs,
};
/* Set direction-dependent variables */
@@ -188,7 +190,8 @@ meta_copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
* increment the offset directly in the image effectively
* re-binding it to different backing memory.
*/
- buf_bsurf.base_offset += rect.width * rect.height * buf_bsurf.bs;
+ buf_bsurf.base_offset += buf_extent_el.width *
+ buf_extent_el.height * buf_bsurf.bs;
if (image->type == VK_IMAGE_TYPE_3D)
slice_3d++;