mesa/st: add compression parameter to st_texture_create

Allow allocation of a fixed-rate compressed resource

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27109>
This commit is contained in:
Louis-Francis Ratté-Boulianne
2023-11-01 00:17:16 -04:00
committed by Marge Bot
parent bc134ade0b
commit f81e3c7e5d
6 changed files with 33 additions and 16 deletions

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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