freedreno/ir3: use pipe_image_view's cpp
authorRob Clark <robdclark@gmail.com>
Thu, 7 Jun 2018 19:44:28 +0000 (15:44 -0400)
committerRob Clark <robdclark@gmail.com>
Mon, 11 Jun 2018 13:06:03 +0000 (09:06 -0400)
At least for PIPE_BUFFER, we could get the resource used as (for
example) R32F imageBuffer.  So using cpp=1 from the rsc is wrong.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3_shader.c

index 8ed7f5673c81effacb658c59db82a3e6f9a632b9..6ee732f9918ccb924ece9342adab3e8800fdb012 100644 (file)
@@ -660,9 +660,14 @@ emit_image_dims(struct fd_context *ctx, const struct ir3_shader_variant *v,
                        img = &si->si[index];
                        rsc = fd_resource(img->resource);
 
-                       dims[off + 0] = rsc->cpp;
+                       dims[off + 0] = util_format_get_blocksize(img->format);
                        if (img->resource->target != PIPE_BUFFER) {
                                unsigned lvl = img->u.tex.level;
+                               /* note for 2d/cube/etc images, even if re-interpreted
+                                * as a different color format, the pixel size should
+                                * be the same, so use original dimensions for y and z
+                                * stride:
+                                */
                                dims[off + 1] = rsc->slices[lvl].pitch * rsc->cpp;
                                dims[off + 2] = rsc->slices[lvl].size0;
                        }