From: Marek Olšák Date: Tue, 13 Feb 2018 03:00:17 +0000 (+0100) Subject: st/mesa: generalize st_etc_fallback -> st_compressed_format_fallback X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=912e0525bed15d8ad63db89fee390eb7fa0b068f;p=mesa.git st/mesa: generalize st_etc_fallback -> st_compressed_format_fallback for ASTC support later Tested-by: Mike Lothian Tested-By: Gert Wollny Tested-by: Dieter Nützel Reviewed-By: Gert Wollny --- diff --git a/src/mesa/state_tracker/st_cb_copyimage.c b/src/mesa/state_tracker/st_cb_copyimage.c index d160c8c8d30..5230b61877f 100644 --- a/src/mesa/state_tracker/st_cb_copyimage.c +++ b/src/mesa/state_tracker/st_cb_copyimage.c @@ -668,8 +668,8 @@ st_CopyImageSubData(struct gl_context *ctx, u_box_2d_zslice(src_x, src_y, src_z, src_width, src_height, &box); - if ((src_image && st_etc_fallback(st, src_image)) || - (dst_image && st_etc_fallback(st, dst_image))) { + if ((src_image && st_compressed_format_fallback(st, src_image->TexFormat)) || + (dst_image && st_compressed_format_fallback(st, dst_image->TexFormat))) { fallback_copy_image(st, dst_image, dst_res, dst_x, dst_y, orig_dst_z, src_image, src_res, src_x, src_y, orig_src_z, src_width, src_height); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 99209abcd62..b345b2c6d8b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -219,10 +219,15 @@ st_FreeTextureImageBuffer(struct gl_context *ctx, } bool -st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage) +st_compressed_format_fallback(struct st_context *st, mesa_format format) { - return (_mesa_is_format_etc2(texImage->TexFormat) && !st->has_etc2) || - (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1); + if (format == MESA_FORMAT_ETC1_RGB8) + return !st->has_etc1; + + if (_mesa_is_format_etc2(format)) + return !st->has_etc2; + + return false; } static void @@ -230,7 +235,7 @@ etc_fallback_allocate(struct st_context *st, struct st_texture_image *stImage) { struct gl_texture_image *texImage = &stImage->base; - if (!st_etc_fallback(st, texImage)) + if (!st_compressed_format_fallback(st, texImage->TexFormat)) return; if (stImage->etc_data) @@ -269,7 +274,7 @@ st_MapTextureImage(struct gl_context *ctx, map = st_texture_image_map(st, stImage, transfer_flags, x, y, slice, w, h, 1, &transfer); if (map) { - if (st_etc_fallback(st, texImage)) { + if (st_compressed_format_fallback(st, texImage->TexFormat)) { /* ETC isn't supported by all gallium drivers, where it's represented * by uncompressed formats. We store the compressed data (as it's * needed for image copies in OES_copy_image), and decompress as @@ -310,8 +315,9 @@ st_UnmapTextureImage(struct gl_context *ctx, struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); - if (st_etc_fallback(st, texImage)) { - /* Decompress the ETC texture to the mapped one. */ + if (st_compressed_format_fallback(st, texImage->TexFormat)) { + /* Decompress the compressed image on upload if the driver doesn't + * support the compressed format. */ unsigned z = slice + stImage->base.Face; struct st_texture_image_transfer *itransfer = &stImage->transfer[z]; struct pipe_transfer *transfer = itransfer->transfer; @@ -1686,10 +1692,8 @@ st_CompressedTexSubImage(struct gl_context *ctx, GLuint dims, if (!_mesa_is_bufferobj(ctx->Unpack.BufferObj)) goto fallback; - if (st_etc_fallback(st, texImage)) { - /* ETC isn't supported and is represented by uncompressed formats. */ + if (st_compressed_format_fallback(st, texImage->TexFormat)) goto fallback; - } if (!dst) { goto fallback; diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index c10a2753104..82a5bc7797c 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -315,7 +315,7 @@ void st_destroy_bound_image_handles(struct st_context *st); bool -st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage); +st_compressed_format_fallback(struct st_context *st, mesa_format format); void st_convert_image(const struct st_context *st, const struct gl_image_unit *u,