panfrost: Index texture by sample
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 30 Jun 2020 20:43:32 +0000 (16:43 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Jul 2020 01:13:39 +0000 (01:13 +0000)
This will allow MSAA to route through.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5782>

src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_resource.h
src/gallium/drivers/panfrost/pan_sfbd.c
src/panfrost/encoder/pan_texture.c
src/panfrost/encoder/pan_texture.h

index 98e67adf4f7a619a9c0fe8be91495e8b868f760c..5514e29a4263011966be7019e5a18ffb3280f7af 100644 (file)
@@ -980,6 +980,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                                 so->base.u.tex.last_level,
                                 so->base.u.tex.first_layer,
                                 so->base.u.tex.last_layer,
+                                texture->nr_samples,
                                 prsrc->cubemap_stride,
                                 panfrost_translate_swizzle_4(composed_swizzle),
                                 prsrc->bo->gpu,
@@ -1006,6 +1007,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                                 so->base.u.tex.last_level,
                                 so->base.u.tex.first_layer,
                                 so->base.u.tex.last_layer,
+                                texture->nr_samples,
                                 prsrc->cubemap_stride,
                                 panfrost_translate_swizzle_4(user_swizzle),
                                 prsrc->bo->gpu,
index 41f21128198fe36624417877d772f43a8e87dea8..274fff45aaa1acf7434ac763a8d3e0326f7c6501 100644 (file)
@@ -211,7 +211,7 @@ panfrost_mfbd_set_cbuf(
         assert(surf->u.tex.last_layer == first_layer);
         int stride = rsrc->slices[level].stride;
 
-        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
+        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer, 0);
 
         rt->format = panfrost_mfbd_format(surf);
 
@@ -274,7 +274,7 @@ panfrost_mfbd_set_zsbuf(
         unsigned first_layer = surf->u.tex.first_layer;
         assert(surf->u.tex.last_layer == first_layer);
 
-        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
+        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer, 0);
 
         if (rsrc->layout == MALI_TEXTURE_AFBC) {
                 /* The only Z/S format we can compress is Z24S8 or variants
@@ -336,7 +336,7 @@ panfrost_mfbd_set_zsbuf(
                         struct panfrost_resource *stencil = rsrc->separate_stencil;
                         struct panfrost_slice stencil_slice = stencil->slices[level];
 
-                        fbx->ds_linear.stencil = panfrost_get_texture_address(stencil, level, first_layer);
+                        fbx->ds_linear.stencil = panfrost_get_texture_address(stencil, level, first_layer, 0);
                         fbx->ds_linear.stencil_stride = stencil_slice.stride;
                 }
 
index d0879ba00c955654d5fe67a8bc823665c2e6c0e0..a8362bee8a91f644f817ecbb33ee146de4c191b0 100644 (file)
@@ -891,10 +891,10 @@ panfrost_generate_mipmap(
 mali_ptr
 panfrost_get_texture_address(
         struct panfrost_resource *rsrc,
-        unsigned level, unsigned face)
+        unsigned level, unsigned face, unsigned sample)
 {
         bool is_3d = rsrc->base.target == PIPE_TEXTURE_3D;
-        return rsrc->bo->gpu + panfrost_texture_offset(rsrc->slices, is_3d, rsrc->cubemap_stride, level, face);
+        return rsrc->bo->gpu + panfrost_texture_offset(rsrc->slices, is_3d, rsrc->cubemap_stride, level, face, sample);
 }
 
 /* Given a resource that has already been allocated, hint that it should use a
index c6226cbe272d47744a3b88401c0ae7f3073216a7..392e988a182025791974346603f04018c79bc78d 100644 (file)
@@ -94,7 +94,7 @@ pan_transfer(struct pipe_transfer *p)
 mali_ptr
 panfrost_get_texture_address(
         struct panfrost_resource *rsrc,
-        unsigned level, unsigned face);
+        unsigned level, unsigned face, unsigned sample);
 
 void panfrost_resource_screen_init(struct pipe_screen *screen);
 
index 7579c4608f9c06b52aea8d20b5dcd7f62c0ac0a2..769fbd79e3f0ea137f5e44192587cf2c0ee50147 100644 (file)
@@ -134,7 +134,7 @@ panfrost_sfbd_set_cbuf(
         assert(surf->u.tex.last_layer == first_layer);
         signed stride = rsrc->slices[level].stride;
 
-        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
+        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer, 0);
 
         fb->format = panfrost_sfbd_format(surf);
 
index d51ff0dff7250c6b24bac357975159ba7438ceb5..54a5398e299482e02e5de26c217caab42f5cbe09 100644 (file)
@@ -197,6 +197,7 @@ panfrost_emit_texture_payload(
         unsigned width, unsigned height,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
+        unsigned nr_samples,
         unsigned cube_stride,
         bool manual_stride,
         mali_ptr base,
@@ -246,6 +247,7 @@ panfrost_new_texture(
         enum mali_texture_layout layout,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
+        unsigned nr_samples,
         unsigned cube_stride,
         unsigned swizzle,
         mali_ptr base,
@@ -293,6 +295,7 @@ panfrost_new_texture(
                 width, height,
                 first_level, last_level,
                 first_layer, last_layer,
+                nr_samples,
                 cube_stride,
                 manual_stride,
                 base,
@@ -309,6 +312,7 @@ panfrost_new_texture_bifrost(
         enum mali_texture_layout layout,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
+        unsigned nr_samples,
         unsigned cube_stride,
         unsigned swizzle,
         mali_ptr base,
@@ -330,6 +334,7 @@ panfrost_new_texture_bifrost(
                 width, height,
                 first_level, last_level,
                 first_layer, last_layer,
+                nr_samples,
                 cube_stride,
                 true, /* Stride explicit on Bifrost */
                 base,
@@ -390,8 +395,8 @@ panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cu
  * the base address of a texture to get the address to that level/face */
 
 unsigned
-panfrost_texture_offset(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level, unsigned face)
+panfrost_texture_offset(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level, unsigned face, unsigned sample)
 {
         unsigned layer_stride = panfrost_get_layer_stride(slices, is_3d, cube_stride, level);
-        return slices[level].offset + (face * layer_stride);
+        return slices[level].offset + (face * layer_stride) + (sample * slices[level].size0);
 }
index f84e0a484a5f5ddf78c2a30e16fc0571371d75ed..e8c68c005bb51f30fe63d14513f89e6129ea1ad7 100644 (file)
@@ -84,6 +84,7 @@ panfrost_new_texture(
         enum mali_texture_layout layout,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
+        unsigned nr_samples,
         unsigned cube_stride,
         unsigned swizzle,
         mali_ptr base,
@@ -99,6 +100,7 @@ panfrost_new_texture_bifrost(
         enum mali_texture_layout layout,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
+        unsigned nr_samples,
         unsigned cube_stride,
         unsigned swizzle,
         mali_ptr base,
@@ -110,7 +112,7 @@ unsigned
 panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level);
 
 unsigned
-panfrost_texture_offset(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level, unsigned face);
+panfrost_texture_offset(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level, unsigned face, unsigned sample);
 
 /* Formats */