st/mesa: Allow ASTC5x5 fallbacks separately from other ASTC LDR formats.
This patch allows us to fake ASTC 5x5 specifically, while leaving the other ASTC LDR formats with native support. I plan to use this in iris, at least for the time being. Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
@@ -226,6 +226,18 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
}
|
||||
|
||||
bool
|
||||
st_astc_format_fallback(const struct st_context *st, mesa_format format)
|
||||
{
|
||||
if (!_mesa_is_format_astc_2d(format))
|
||||
return false;
|
||||
|
||||
if (format == MESA_FORMAT_RGBA_ASTC_5x5 ||
|
||||
format == MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5)
|
||||
return !st->has_astc_5x5_ldr;
|
||||
|
||||
return !st->has_astc_2d_ldr;
|
||||
}
|
||||
|
||||
bool
|
||||
st_compressed_format_fallback(struct st_context *st, mesa_format format)
|
||||
@@ -236,8 +248,8 @@ st_compressed_format_fallback(struct st_context *st, mesa_format format)
|
||||
if (_mesa_is_format_etc2(format))
|
||||
return !st->has_etc2;
|
||||
|
||||
if (_mesa_is_format_astc_2d(format))
|
||||
return !st->has_astc_2d_ldr;
|
||||
if (st_astc_format_fallback(st, format))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -652,6 +652,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
|
||||
st->has_astc_2d_ldr =
|
||||
screen->is_format_supported(screen, PIPE_FORMAT_ASTC_4x4_SRGB,
|
||||
PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW);
|
||||
st->has_astc_5x5_ldr =
|
||||
screen->is_format_supported(screen, PIPE_FORMAT_ASTC_5x5_SRGB,
|
||||
PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW);
|
||||
st->prefer_blit_based_texture_transfer = screen->get_param(screen,
|
||||
PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER);
|
||||
st->force_persample_in_shader =
|
||||
|
||||
@@ -137,6 +137,7 @@ struct st_context
|
||||
boolean has_etc1;
|
||||
boolean has_etc2;
|
||||
boolean has_astc_2d_ldr;
|
||||
boolean has_astc_5x5_ldr;
|
||||
boolean prefer_blit_based_texture_transfer;
|
||||
boolean force_persample_in_shader;
|
||||
boolean has_shareable_shaders;
|
||||
|
||||
@@ -106,7 +106,7 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
|
||||
}
|
||||
}
|
||||
|
||||
if (_mesa_is_format_astc_2d(mesaFormat) && !st->has_astc_2d_ldr) {
|
||||
if (st_astc_format_fallback(st, mesaFormat)) {
|
||||
if (_mesa_is_format_srgb(mesaFormat))
|
||||
return PIPE_FORMAT_R8G8B8A8_SRGB;
|
||||
else
|
||||
|
||||
@@ -322,6 +322,9 @@ st_destroy_bound_texture_handles(struct st_context *st);
|
||||
void
|
||||
st_destroy_bound_image_handles(struct st_context *st);
|
||||
|
||||
bool
|
||||
st_astc_format_fallback(const struct st_context *st, mesa_format format);
|
||||
|
||||
bool
|
||||
st_compressed_format_fallback(struct st_context *st, mesa_format format);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ int main(int argc, char **argv)
|
||||
.has_etc1 = true,
|
||||
.has_etc2 = true,
|
||||
.has_astc_2d_ldr = true,
|
||||
.has_astc_5x5_ldr = true,
|
||||
};
|
||||
struct st_context *st = &local_st;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user