radv: use proper maximum slice for layered view
authorDave Airlie <airlied@redhat.com>
Mon, 9 Jan 2017 07:02:17 +0000 (07:02 +0000)
committerDave Airlie <airlied@redhat.com>
Sat, 28 Jan 2017 00:52:20 +0000 (10:52 +1000)
this fixes deferred shadows with geom shaders enabled.

but I think this fix is fine by itself.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c

index 4aa6af2bbdacd6e346afecb68a9a96b34a8f3c22..a4b12950f2aa35f40bbaf0dc7afa061b4776d701 100644 (file)
@@ -1608,8 +1608,9 @@ radv_initialise_color_surface(struct radv_device *device,
        va += iview->image->dcc_offset;
        cb->cb_dcc_base = va >> 8;
 
+       uint32_t max_slice = iview->type == VK_IMAGE_VIEW_TYPE_3D ? iview->extent.depth : iview->layer_count;
        cb->cb_color_view = S_028C6C_SLICE_START(iview->base_layer) |
-               S_028C6C_SLICE_MAX(iview->base_layer + iview->extent.depth - 1);
+               S_028C6C_SLICE_MAX(iview->base_layer + max_slice - 1);
 
        cb->micro_tile_mode = iview->image->surface.micro_tile_mode;
        pitch_tile_max = level_info->nblk_x / 8 - 1;
@@ -1761,8 +1762,9 @@ radv_initialise_ds_surface(struct radv_device *device,
        z_offs += iview->image->surface.level[level].offset;
        s_offs += iview->image->surface.stencil_level[level].offset;
 
+       uint32_t max_slice = iview->type == VK_IMAGE_VIEW_TYPE_3D ? iview->extent.depth : iview->layer_count;
        ds->db_depth_view = S_028008_SLICE_START(iview->base_layer) |
-               S_028008_SLICE_MAX(iview->base_layer + iview->extent.depth - 1);
+               S_028008_SLICE_MAX(iview->base_layer + max_slice - 1);
        ds->db_depth_info = S_02803C_ADDR5_SWIZZLE_MASK(1);
        ds->db_z_info = S_028040_FORMAT(format) | S_028040_ZRANGE_PRECISION(1);