radeonsi/gfx9: fix linear mipmap CPU access
authorMarek Olšák <marek.olsak@amd.com>
Mon, 27 Feb 2017 21:25:43 +0000 (22:25 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 31 Mar 2017 19:41:57 +0000 (21:41 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_surface.c

index 877f5552bd549cdc3ac1363146e0ffaa6672b47c..77e9becda6acf64d34d7fd4be4403eea98ae892e 100644 (file)
@@ -193,8 +193,8 @@ static unsigned r600_texture_get_offset(struct r600_common_screen *rscreen,
                /* Each texture is an array of slices. Each slice is an array
                 * of mipmap levels. */
                return box->z * rtex->surface.u.gfx9.surf_slice_size +
-                      ((rtex->surface.u.gfx9.surf_ymip_offset[level] +
-                        box->y / rtex->surface.blk_h) *
+                      rtex->surface.u.gfx9.offset[level] +
+                      (box->y / rtex->surface.blk_h *
                        rtex->surface.u.gfx9.surf_pitch +
                        box->x / rtex->surface.blk_w) * rtex->surface.bpe;
        } else {
@@ -1623,9 +1623,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
                 * Use the staging texture for uploads if the underlying BO
                 * is busy.
                 */
-               /* TODO: Linear CPU mipmap addressing is broken on GFX9: */
-               if (!rtex->surface.is_linear ||
-                   (rctx->chip_class == GFX9 && level))
+               if (!rtex->surface.is_linear)
                        use_staging_texture = true;
                else if (usage & PIPE_TRANSFER_READ)
                        use_staging_texture =
index 43f74f653e4e35ff6c9a4bd1af68bded43361452..a19ece6634dc957367a6dee0dfb6472d724548ee 100644 (file)
@@ -364,8 +364,8 @@ struct gfx9_surf_layout {
     uint64_t                    surf_slice_size;
     uint16_t                    surf_pitch; /* in blocks */
     uint16_t                    surf_height;
-    /* Y mipmap level offset in blocks. Only valid for LINEAR. */
-    uint16_t                    surf_ymip_offset[RADEON_SURF_MAX_LEVELS];
+    /* Mipmap level offset within the slice in bytes. Only valid for LINEAR. */
+    uint32_t                    offset[RADEON_SURF_MAX_LEVELS];
 
     uint16_t                    dcc_pitch_max;  /* (mip chain pitch - 1) */
 
index 7dfd6d24279ff1c76e00e2c654f02c38bca35559..756608793b5c47f1b8381a891830b1221e70eac7 100644 (file)
@@ -663,7 +663,7 @@ static int gfx9_compute_miptree(struct amdgpu_winsys *ws,
 
    if (in->swizzleMode == ADDR_SW_LINEAR) {
       for (unsigned i = 0; i < in->numMipLevels; i++)
-         surf->u.gfx9.surf_ymip_offset[i] = mip_info[i].mipOffsetYPixel;
+         surf->u.gfx9.offset[i] = mip_info[i].offset;
    }
 
    if (in->flags.depth) {