gallium/radeon: Only loop up to last_level for drm<->winsys conversion
authorMichel Dänzer <michel.daenzer@amd.com>
Wed, 2 Nov 2016 09:43:37 +0000 (18:43 +0900)
committerMichel Dänzer <michel@daenzer.net>
Fri, 4 Nov 2016 07:47:43 +0000 (16:47 +0900)
Fixes spurious assertion failure in surf_level_drm_to_winsys when
starting X, due to processing a miplevel which was never initialized.

Fixes: e9c76eeeaa67 ("gallium/radeon: remove radeon_surf_level::pitch_bytes")
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_surface.c

index c6fa475fc4abf023e673ee463545fc316f37a84a..e3eea597ce0ff23583511a35a808b2a7f5e1c440 100644 (file)
@@ -157,7 +157,7 @@ static void surf_winsys_to_drm(struct radeon_surface *surf_drm,
     surf_drm->tile_split = surf_ws->tile_split;
     surf_drm->stencil_tile_split = surf_ws->stencil_tile_split;
 
-    for (i = 0; i < RADEON_SURF_MAX_LEVELS; i++) {
+    for (i = 0; i <= surf_drm->last_level; i++) {
         surf_level_winsys_to_drm(&surf_drm->level[i], &surf_ws->level[i], bpe);
         surf_level_winsys_to_drm(&surf_drm->stencil_level[i],
                                  &surf_ws->stencil_level[i], bpe);
@@ -192,7 +192,7 @@ static void surf_drm_to_winsys(struct radeon_drm_winsys *ws,
 
     surf_ws->macro_tile_index = cik_get_macro_tile_index(surf_ws);
 
-    for (i = 0; i < RADEON_SURF_MAX_LEVELS; i++) {
+    for (i = 0; i <= surf_drm->last_level; i++) {
         surf_level_drm_to_winsys(&surf_ws->level[i], &surf_drm->level[i],
                                  surf_drm->bpe * surf_drm->nsamples);
         surf_level_drm_to_winsys(&surf_ws->stencil_level[i],