diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2024-03-07 15:33:54 -0500 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-03-12 14:22:17 +0000 |
commit | 0f66589c2a461524f324655ffc62503f259cb79b (patch) | |
tree | 5e98b1d4ed3eae94092f5164633fc16a97a537ac /src/mesa | |
parent | d7def3ccdf4ac7f436dcd27342851179b68bee42 (diff) |
mesa: force rendertarget usage on required-renderable formats
the existing guesswork during format selection for teximage is
accurate most of the time, but it's not accurate all of the time.
GL/ES each have a set of sized formats that are required to be
color renderable, and so any time one of these is allocated as a
texture, it MUST have the rendertarget usage bit attached so that
it can later be bound as a framebuffer attachment
an alternative might be to relax this and then try to do migration
to a different format/buffer later if necessary, but that's hard and
probably not actually as useful
cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28055>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 7a6f68db2c6..36846cd6b7a 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1333,6 +1333,21 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, is_renderbuffer = true; } else { pTarget = gl_target_to_pipe(target); + if (internalFormat == format) { + if (internalFormat == GL_RGBA) { + /* with GL_RGBA, these are effectively aliases to required formats */ + switch (type) { + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_INT_8_8_8_8: + is_renderbuffer = true; + break; + default: break; + } + } else if (internalFormat == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { + is_renderbuffer = true; + } + } } if (target == GL_TEXTURE_1D || target == GL_TEXTURE_1D_ARRAY) { @@ -1351,7 +1366,9 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, bindings = PIPE_BIND_SAMPLER_VIEW; if (_mesa_is_depth_or_stencil_format(internalFormat)) bindings |= PIPE_BIND_DEPTH_STENCIL; - else if (is_renderbuffer || internalFormat == 3 || internalFormat == 4 || + else if (is_renderbuffer) + bindings |= PIPE_BIND_RENDER_TARGET; + else if (internalFormat == 3 || internalFormat == 4 || internalFormat == GL_RGB || internalFormat == GL_RGBA || internalFormat == GL_RGBA2 || internalFormat == GL_RGB4 || internalFormat == GL_RGBA4 || |