Revert "mesa: consider the sample count when choosing a texture format"

This reverts commit 89c94502b6.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16524>
This commit is contained in:
Marek Olšák 2022-05-16 08:16:23 -04:00 committed by Marge Bot
parent 265c9af69e
commit 61d5594064
11 changed files with 29 additions and 62 deletions

View File

@ -997,8 +997,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
* same format-choice logic as for textures.
*/
texformat = st_ChooseTextureFormat(ctx, target, internalformat,
GL_NONE /*format */, GL_NONE /* type */,
0);
GL_NONE /*format */, GL_NONE /* type */);
if (texformat == MESA_FORMAT_NONE || baseformat <= 0)
goto end;

View File

@ -2821,8 +2821,7 @@ mesa_format
_mesa_choose_texture_format(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum target, GLint level,
GLenum internalFormat, GLenum format, GLenum type,
unsigned samples)
GLenum internalFormat, GLenum format, GLenum type)
{
mesa_format f = MESA_FORMAT_NONE;
@ -2842,31 +2841,8 @@ _mesa_choose_texture_format(struct gl_context *ctx,
}
}
if (samples > 0) {
unsigned trySamples = samples;
/* TODO: This somewhat duplicates the logic in st_texture_storage. */
/* Find msaa sample count which is actually supported. For example,
* if the user requests 1x but only 4x or 8x msaa is supported, we'll
* choose 4x here.
*/
if (ctx->Const.MaxSamples > 1 && samples == 1) {
/* don't try num_samples = 1 with drivers that support real msaa */
trySamples = 2;
}
for (; trySamples <= ctx->Const.MaxSamples; trySamples++) {
f = st_ChooseTextureFormat(ctx, target, internalFormat,
format, type, trySamples);
if (f != MESA_FORMAT_NONE)
break;
}
}
if (f == MESA_FORMAT_NONE) {
f = st_ChooseTextureFormat(ctx, target, internalFormat,
format, type, samples);
}
f = st_ChooseTextureFormat(ctx, target, internalFormat,
format, type);
assert(f != MESA_FORMAT_NONE);
return f;
}
@ -3097,7 +3073,7 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims,
}
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, format, type, 0);
internalFormat, format, type);
}
assert(texFormat != MESA_FORMAT_NONE);
@ -4336,7 +4312,7 @@ copyteximage(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texO
assert(texObj);
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, GL_NONE, GL_NONE, 0);
internalFormat, GL_NONE, GL_NONE);
/* First check if reallocating the texture buffer can be avoided.
* Without the realloc the copy can be 20x faster.
@ -6856,7 +6832,7 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
}
texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
internalformat, GL_NONE, GL_NONE, samples);
internalformat, GL_NONE, GL_NONE);
assert(texFormat != MESA_FORMAT_NONE);
dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,

View File

@ -144,8 +144,7 @@ extern mesa_format
_mesa_choose_texture_format(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum target, GLint level,
GLenum internalFormat, GLenum format, GLenum type,
unsigned samples);
GLenum internalFormat, GLenum format, GLenum type);
extern void
_mesa_update_fbo_texture(struct gl_context *ctx,

View File

@ -1018,7 +1018,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
texFormat = st_ChooseTextureFormat(ctx, target,
GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, 0);
GL_UNSIGNED_BYTE);
/* need a loop here just for cube maps */
for (face = 0; face < numFaces; face++) {

View File

@ -455,7 +455,7 @@ texture_storage(struct gl_context *ctx, GLuint dims,
}
texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
internalformat, GL_NONE, GL_NONE, 0);
internalformat, GL_NONE, GL_NONE);
if (!no_error) {
/* check that width, height, depth are legal for the mipmap level */

View File

@ -541,7 +541,7 @@ texture_view(struct gl_context *ctx, struct gl_texture_object *origTexObj,
GLenum faceTarget;
texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
internalformat, GL_NONE, GL_NONE, 0);
internalformat, GL_NONE, GL_NONE);
if (texFormat == MESA_FORMAT_NONE) return;
newViewNumLevels = MIN2(numlevels, origTexObj->Attrib.NumLevels - minlevel);

View File

@ -629,7 +629,7 @@ make_texture(struct st_context *st,
* image to draw.
*/
pipeFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, 0, 0, unpack->SwapBytes);
format, type, unpack->SwapBytes);
if (pipeFormat == PIPE_FORMAT_NONE) {
/* Use the generic approach. */

View File

@ -476,7 +476,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
/* Choose the destination format by finding the best match
* for the format+type combo. */
dst_format = st_choose_matching_format(st, bind, format, type, 0, 0,
dst_format = st_choose_matching_format(st, bind, format, type,
pack->SwapBytes);
if (dst_format == PIPE_FORMAT_NONE) {
goto fallback;

View File

@ -295,7 +295,7 @@ st_pbo_get_dst_format(struct gl_context *ctx, enum pipe_texture_target target,
/* Choose the destination format by finding the best match
* for the format+type combo. */
enum pipe_format dst_format = st_choose_matching_format(st, bind, format, type,
0, 0, ctx->Pack.SwapBytes);
ctx->Pack.SwapBytes);
if (dst_format == PIPE_FORMAT_NONE) {
GLenum dst_glformat;
@ -1033,7 +1033,7 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
/* oops, need to init this image again */
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
texImage->InternalFormat, format,
type, texImage->NumSamples);
type);
_mesa_init_teximage_fields(ctx, texImage,
texImage->Width, texImage->Height,
@ -1624,7 +1624,7 @@ try_pbo_upload(struct gl_context *ctx, GLuint dims,
* support at all because of the remapping we later perform and because
* at least the Radeon driver actually supports some formats for texture
* buffers which it doesn't support for regular textures. */
src_format = st_choose_matching_format(st, 0, format, type, 0, 0,
src_format = st_choose_matching_format(st, 0, format, type,
unpack->SwapBytes);
if (!src_format) {
return false;
@ -2002,7 +2002,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
/* Choose the source format. */
src_format = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, 0, 0, unpack->SwapBytes);
format, type, unpack->SwapBytes);
if (!src_format) {
goto fallback;
}

View File

@ -1138,8 +1138,8 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
*/
if (_mesa_is_enum_format_unsized(internalFormat) && format != 0 &&
_mesa_is_type_unsigned(type)) {
pf = st_choose_matching_format(st, bindings, format, type, sample_count,
storage_sample_count, swap_bytes);
pf = st_choose_matching_format(st, bindings, format, type,
swap_bytes);
if (pf != PIPE_FORMAT_NONE &&
(!bindings || screen->is_format_supported(screen, pf, target, sample_count,
@ -1236,15 +1236,12 @@ st_choose_matching_format_noverify(struct st_context *st,
*/
enum pipe_format
st_choose_matching_format(struct st_context *st, unsigned bind,
GLenum format, GLenum type, unsigned num_samples,
unsigned num_storage_samples, GLboolean swapBytes)
GLenum format, GLenum type, GLboolean swapBytes)
{
struct pipe_screen *screen = st->screen;
enum pipe_format pformat = st_choose_matching_format_noverify(st, format, type, swapBytes);
if (pformat != PIPE_FORMAT_NONE &&
(!bind || screen->is_format_supported(screen, pformat, PIPE_TEXTURE_2D,
num_samples, num_storage_samples,
bind)))
(!bind || screen->is_format_supported(screen, pformat, PIPE_TEXTURE_2D, 0, 0, bind)))
return pformat;
return PIPE_FORMAT_NONE;
@ -1257,7 +1254,7 @@ st_choose_matching_format(struct st_context *st, unsigned bind,
mesa_format
st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
GLint internalFormat,
GLenum format, GLenum type, unsigned samples)
GLenum format, GLenum type)
{
struct st_context *st = st_context(ctx);
enum pipe_format pFormat;
@ -1323,7 +1320,6 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
*/
if (iformat == baseFormat && iformat == basePackFormat) {
pFormat = st_choose_matching_format(st, bindings, format, type,
samples, samples,
ctx->Unpack.SwapBytes);
if (pFormat != PIPE_FORMAT_NONE)
@ -1334,7 +1330,7 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
* target bindings.
*/
pFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, samples, samples,
format, type,
ctx->Unpack.SwapBytes);
if (pFormat != PIPE_FORMAT_NONE)
return st_pipe_format_to_mesa_format(pFormat);
@ -1343,13 +1339,13 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
}
pFormat = st_choose_format(st, internalFormat, format, type,
pTarget, samples, samples, bindings,
pTarget, 0, 0, bindings,
ctx->Unpack.SwapBytes, true);
if (pFormat == PIPE_FORMAT_NONE && !is_renderbuffer) {
/* try choosing format again, this time without render target bindings */
pFormat = st_choose_format(st, internalFormat, format, type,
pTarget, samples, samples, PIPE_BIND_SAMPLER_VIEW,
pTarget, 0, 0, PIPE_BIND_SAMPLER_VIEW,
ctx->Unpack.SwapBytes, true);
}
@ -1483,8 +1479,7 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
break;
}
case GL_TEXTURE_REDUCTION_MODE_ARB: {
mesa_format format = st_ChooseTextureFormat(ctx, target, internalFormat,
GL_NONE, GL_NONE, 0);
mesa_format format = st_ChooseTextureFormat(ctx, target, internalFormat, GL_NONE, GL_NONE);
enum pipe_format pformat = st_mesa_format_to_pipe_format(st, format);
struct pipe_screen *screen = st->screen;
params[0] = pformat != PIPE_FORMAT_NONE &&
@ -1499,8 +1494,7 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
/* this is used only for passing CTS */
if (target == GL_RENDERBUFFER)
target = GL_TEXTURE_2D;
mesa_format format = st_ChooseTextureFormat(ctx, target, internalFormat,
GL_NONE, GL_NONE, 0);
mesa_format format = st_ChooseTextureFormat(ctx, target, internalFormat, GL_NONE, GL_NONE);
enum pipe_format pformat = st_mesa_format_to_pipe_format(st, format);
if (pformat != PIPE_FORMAT_NONE) {

View File

@ -64,13 +64,12 @@ st_choose_matching_format_noverify(struct st_context *st,
extern enum pipe_format
st_choose_matching_format(struct st_context *st, unsigned bind,
GLenum format, GLenum type, unsigned num_samples,
unsigned num_storage_samples, GLboolean swapBytes);
GLenum format, GLenum type, GLboolean swapBytes);
extern mesa_format
st_ChooseTextureFormat(struct gl_context * ctx, GLenum target,
GLint internalFormat,
GLenum format, GLenum type, unsigned samples);
GLenum format, GLenum type);
void
st_QueryInternalFormat(struct gl_context *ctx, GLenum target,