From f81e3c7e5d6fc0047f7527c662e1080b1926a775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Wed, 1 Nov 2023 00:17:16 -0400 Subject: [PATCH] mesa/st: add compression parameter to st_texture_create MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow allocation of a fixed-rate compressed resource Signed-off-by: Louis-Francis Ratté-Boulianne Reviewed-by: Erik Faye-Lund Part-of: --- src/mesa/state_tracker/st_cb_bitmap.c | 6 ++++-- src/mesa/state_tracker/st_cb_drawpixels.c | 3 ++- src/mesa/state_tracker/st_cb_texture.c | 12 ++++++++---- .../state_tracker/st_texcompress_compute.c | 18 ++++++++++++------ src/mesa/state_tracker/st_texture.c | 7 +++++-- src/mesa/state_tracker/st_texture.h | 3 ++- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 71bbb3b22f7..8585e4969e9 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -141,7 +141,8 @@ st_make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height, */ pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format, 0, width, height, 1, 1, 0, - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!pt) { _mesa_unmap_pbo_source(ctx, unpack); return NULL; @@ -369,7 +370,8 @@ reset_cache(struct st_context *st) BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW, - false); + false, + PIPE_COMPRESSION_FIXED_RATE_NONE); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index cb307c6fcd7..f549354caf9 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -460,7 +460,8 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, struct pipe_resource *pt; pt = st_texture_create(st, st->internal_target, texFormat, 0, - width, height, 1, 1, 0, bind, false); + width, height, 1, 1, 0, bind, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); return pt; } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 907efa3acf6..fde3e6ee45a 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1092,7 +1092,8 @@ guess_and_alloc_texture(struct st_context *st, ptDepth, ptLayers, nr_samples, bindings, - false); + false, + PIPE_COMPRESSION_FIXED_RATE_NONE); stObj->lastLevel = lastLevel; @@ -1189,7 +1190,8 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, ptDepth, ptLayers, 0, bindings, - false); + false, + PIPE_COMPRESSION_FIXED_RATE_NONE); return stImage->pt != NULL; } } @@ -3243,7 +3245,8 @@ st_finalize_texture(struct gl_context *ctx, ptDepth, ptLayers, ptNumSamples, bindings, - false); + false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!tObj->pt) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); @@ -3457,7 +3460,8 @@ st_texture_storage(struct gl_context *ctx, ptDepth, ptLayers, num_samples, bindings, - texObj->IsSparse); + texObj->IsSparse, + PIPE_COMPRESSION_FIXED_RATE_NONE); } if (!texObj->pt) { diff --git a/src/mesa/state_tracker/st_texcompress_compute.c b/src/mesa/state_tracker/st_texcompress_compute.c index 118efc55d7c..158cf995615 100644 --- a/src/mesa/state_tracker/st_texcompress_compute.c +++ b/src/mesa/state_tracker/st_texcompress_compute.c @@ -292,7 +292,8 @@ cs_encode_bc1(struct st_context *st, DIV_ROUND_UP(rgba8_tex->width0, 4), DIV_ROUND_UP(rgba8_tex->height0, 4), 1, 1, 0, PIPE_BIND_SHADER_IMAGE | - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!bc1_tex) goto release_sampler_views; @@ -352,7 +353,8 @@ cs_encode_bc4(struct st_context *st, DIV_ROUND_UP(rgba8_tex->width0, 4), DIV_ROUND_UP(rgba8_tex->height0, 4), 1, 1, 0, PIPE_BIND_SHADER_IMAGE | - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!bc4_tex) goto release_sampler_views; @@ -413,7 +415,8 @@ cs_stitch_64bpb_textures(struct st_context *st, tex_hi->width0, tex_hi->height0, 1, 1, 0, PIPE_BIND_SHADER_IMAGE | - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!stitched_tex) goto release_sampler_views; @@ -478,7 +481,8 @@ sw_decode_astc(struct st_context *st, struct pipe_resource *rgba8_tex = st_texture_create(st, PIPE_TEXTURE_2D, PIPE_FORMAT_R8G8B8A8_UNORM, 0, width_px, height_px, 1, 1, 0, - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!rgba8_tex) return NULL; @@ -572,7 +576,8 @@ get_astc_partition_table_view(struct st_context *st, st_texture_create(st, PIPE_TEXTURE_2D, PIPE_FORMAT_R8_UINT, 0, ptable_box.width, ptable_box.height, 1, 1, 0, - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!res) return NULL; @@ -644,7 +649,8 @@ cs_decode_astc(struct st_context *st, struct pipe_resource *rgba8_tex = st_texture_create(st, PIPE_TEXTURE_2D, PIPE_FORMAT_R8G8B8A8_UNORM, 0, width_px, height_px, 1, 1, 0, - PIPE_BIND_SAMPLER_VIEW, false); + PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); if (!rgba8_tex) goto release_payload_view; diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 98b53d8339e..f11b0c9c3c4 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -63,7 +63,8 @@ st_texture_create(struct st_context *st, GLuint layers, GLuint nr_samples, GLuint bind, - bool sparse) + bool sparse, + uint32_t compression) { struct pipe_resource pt, *newtex; struct pipe_screen *screen = st->screen; @@ -96,6 +97,7 @@ st_texture_create(struct st_context *st, pt.flags = PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY; pt.nr_samples = nr_samples; pt.nr_storage_samples = nr_samples; + pt.compression_rate = compression; if (sparse) pt.flags |= PIPE_RESOURCE_FLAG_SPARSE; @@ -443,7 +445,8 @@ st_create_color_map_texture(struct gl_context *ctx) /* create texture for color map/table */ pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, - texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW, false); + texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW, false, + PIPE_COMPRESSION_FIXED_RATE_NONE); return pt; } diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 673c225a843..5b27bae39e8 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -158,7 +158,8 @@ st_texture_create(struct st_context *st, GLuint layers, GLuint nr_samples, GLuint tex_usage, - bool sparse); + bool sparse, + uint32_t compression); extern void