summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-07-07 23:59:03 -0400
committerIlia Mirkin <[email protected]>2016-08-12 20:21:08 -0400
commit7727e6f67c47ab0a36d5646092ee89852523cad8 (patch)
tree37d1eec678d69f17103502954825532bf3b4967b
parent1baae00089c7bf5f31424c1287aa24f8ce5981a3 (diff)
st/mesa: refactor duplicated etc fallback checks
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c15
-rw-r--r--src/mesa/state_tracker/st_texture.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index ab061956f85..86702615607 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -189,6 +189,12 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
stImage->num_transfers = 0;
}
+bool
+st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage)
+{
+ return (_mesa_is_format_etc2(texImage->TexFormat) && !st->has_etc2) ||
+ (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1);
+}
/** called via ctx->Driver.MapTextureImage() */
static void
@@ -215,8 +221,7 @@ st_MapTextureImage(struct gl_context *ctx,
map = st_texture_image_map(st, stImage, pipeMode, x, y, slice, w, h, 1,
&transfer);
if (map) {
- if ((_mesa_is_format_etc2(texImage->TexFormat) && !st->has_etc2) ||
- (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1)) {
+ if (st_etc_fallback(st, texImage)) {
/* ETC isn't supported by gallium and it's represented
* by uncompressed formats. Only write transfers with precompressed
* data are supported by ES3, which makes this really simple.
@@ -258,8 +263,7 @@ st_UnmapTextureImage(struct gl_context *ctx,
struct st_context *st = st_context(ctx);
struct st_texture_image *stImage = st_texture_image(texImage);
- if ((_mesa_is_format_etc2(texImage->TexFormat) && !st->has_etc2) ||
- (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1)) {
+ if (st_etc_fallback(st, texImage)) {
/* Decompress the ETC texture to the mapped one. */
unsigned z = slice + stImage->base.Face;
struct st_texture_image_transfer *itransfer = &stImage->transfer[z];
@@ -1618,8 +1622,7 @@ st_CompressedTexSubImage(struct gl_context *ctx, GLuint dims,
if (!_mesa_is_bufferobj(ctx->Unpack.BufferObj))
goto fallback;
- if ((_mesa_is_format_etc2(texImage->TexFormat) && !st->has_etc2) ||
- (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1)) {
+ if (st_etc_fallback(st, texImage)) {
/* ETC isn't supported and is represented by uncompressed formats. */
goto fallback;
}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index ae9e2b4e9b3..d5e828189ef 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -245,4 +245,7 @@ st_texture_release_all_sampler_views(struct st_context *st,
void
st_texture_free_sampler_views(struct st_texture_object *stObj);
+bool
+st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage);
+
#endif