From: Jason Ekstrand Date: Thu, 17 Dec 2015 01:27:35 +0000 (-0800) Subject: anv/state: Allow levelCount to be 0 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c643e9cea87b4676e648e431d5c39f2880a1454c;p=mesa.git anv/state: Allow levelCount to be 0 This can happen if the client is creating an image view of a textureable surface and they only ever intend to render to that view. --- diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index c6de40d3b9a..cb299a3278b 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -329,7 +329,7 @@ genX(image_view_init)(struct anv_image_view *iview, * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. */ surface_state.SurfaceMinLOD = range->baseMipLevel; - surface_state.MIPCountLOD = range->levelCount - 1; + surface_state.MIPCountLOD = MIN2(range->levelCount, 1) - 1; GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->nonrt_surface_state.map, &surface_state); @@ -369,7 +369,7 @@ genX(image_view_init)(struct anv_image_view *iview, format->surface_format); surface_state.SurfaceMinLOD = range->baseMipLevel; - surface_state.MIPCountLOD = range->levelCount - 1; + surface_state.MIPCountLOD = MIN2(range->levelCount, 1) - 1; GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map, &surface_state); diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index fe9f088d9ca..199905b60dc 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -305,7 +305,7 @@ genX(image_view_init)(struct anv_image_view *iview, * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. */ surface_state.SurfaceMinLOD = range->baseMipLevel; - surface_state.MIPCountLOD = range->levelCount - 1; + surface_state.MIPCountLOD = MIN2(range->levelCount, 1) - 1; GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->nonrt_surface_state.map, &surface_state); @@ -344,7 +344,7 @@ genX(image_view_init)(struct anv_image_view *iview, format_info->surface_format); surface_state.SurfaceMinLOD = range->baseMipLevel; - surface_state.MIPCountLOD = range->levelCount - 1; + surface_state.MIPCountLOD = MIN2(range->levelCount, 1) - 1; GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map, &surface_state);