anv/state: Allow levelCount to be 0
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 17 Dec 2015 01:27:35 +0000 (17:27 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 17 Dec 2015 01:34:57 +0000 (17:34 -0800)
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.

src/vulkan/gen7_state.c
src/vulkan/gen8_state.c

index c6de40d3b9ad3f74dba3e8d9443afe13a9b212a7..cb299a3278bc1a501b59d54127cf27ccffbe723d 100644 (file)
@@ -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);
index fe9f088d9cac6e22cf2c018b7a8b42345d5a1573..199905b60dc62323e97cb3c6fe05daa75b8cee92 100644 (file)
@@ -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);