mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
asahi: Extract sampler_view_for_surface
We'll reuse this logic for the spilled RT case. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24258>
This commit is contained in:
parent
10fc9e3d59
commit
17e10499b9
1 changed files with 26 additions and 20 deletions
|
|
@ -1097,6 +1097,30 @@ image_view_for_surface(struct pipe_surface *surf)
|
|||
};
|
||||
}
|
||||
|
||||
/* Similarly, to read render targets, surfaces are bound as textures */
|
||||
static struct pipe_sampler_view
|
||||
sampler_view_for_surface(struct pipe_surface *surf)
|
||||
{
|
||||
return (struct pipe_sampler_view){
|
||||
/* To reduce shader variants, we always use a 2D
|
||||
* texture. For reloads of arrays and cube maps, we
|
||||
* map a single layer as a 2D image.
|
||||
*/
|
||||
.target = PIPE_TEXTURE_2D,
|
||||
.swizzle_r = PIPE_SWIZZLE_X,
|
||||
.swizzle_g = PIPE_SWIZZLE_Y,
|
||||
.swizzle_b = PIPE_SWIZZLE_Z,
|
||||
.swizzle_a = PIPE_SWIZZLE_W,
|
||||
.u.tex =
|
||||
{
|
||||
.first_layer = surf->u.tex.first_layer,
|
||||
.last_layer = surf->u.tex.last_layer,
|
||||
.first_level = surf->u.tex.level,
|
||||
.last_level = surf->u.tex.level,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
agx_pack_image_atomic_data(void *packed, struct pipe_image_view *view)
|
||||
{
|
||||
|
|
@ -2273,27 +2297,9 @@ agx_build_meta(struct agx_batch *batch, bool store, bool partial_render)
|
|||
assert(surf != NULL && "cannot load nonexistent attachment");
|
||||
|
||||
struct agx_resource *rsrc = agx_resource(surf->texture);
|
||||
struct pipe_sampler_view sampler_view = sampler_view_for_surface(surf);
|
||||
|
||||
agx_pack_texture(texture.cpu, rsrc, surf->format,
|
||||
&(struct pipe_sampler_view){
|
||||
/* To reduce shader variants, we always use a 2D
|
||||
* texture. For reloads of arrays and cube maps, we
|
||||
* map a single layer as a 2D image.
|
||||
*/
|
||||
.target = PIPE_TEXTURE_2D,
|
||||
.swizzle_r = PIPE_SWIZZLE_X,
|
||||
.swizzle_g = PIPE_SWIZZLE_Y,
|
||||
.swizzle_b = PIPE_SWIZZLE_Z,
|
||||
.swizzle_a = PIPE_SWIZZLE_W,
|
||||
.u.tex =
|
||||
{
|
||||
.first_layer = surf->u.tex.first_layer,
|
||||
.last_layer = surf->u.tex.last_layer,
|
||||
.first_level = surf->u.tex.level,
|
||||
.last_level = surf->u.tex.level,
|
||||
},
|
||||
},
|
||||
true);
|
||||
agx_pack_texture(texture.cpu, rsrc, surf->format, &sampler_view, true);
|
||||
|
||||
agx_usc_pack(&b, TEXTURE, cfg) {
|
||||
cfg.start = rt;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue