diff options
author | Brian Paul <brianp@vmware.com> | 2010-04-23 13:13:27 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2010-04-23 13:16:37 -0600 |
commit | 4aa4fe8e2103ee43e77f404ef790125dd4d690e5 (patch) | |
tree | 141c70737375944663586e98d772385aac204203 /src | |
parent | 8283db88414f600e66510de713382c36899d4b03 (diff) |
st/mesa: re-do binding flags in st_ChooseTextureFormat(), again
Try to specify render target bindings flags first. If that fails, try
again with just sampler view binding. Note that we try to create the
texture resource with render target binding flags later when we allocate
the texture. Then, in FBO validation, we check if we can actually render
to the textures. If that fails, we generate GL_FRAMEBUFFER_UNSUPPORTED_EXT.
Changes suggested by Jose.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 2e40659b19..fa6dd2d636 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -651,28 +651,33 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) { enum pipe_format pFormat; - uint usage = PIPE_BIND_SAMPLER_VIEW; + uint bindings; (void) format; (void) type; /* GL textures may wind up being render targets, but we don't know * that in advance. Specify potential render target flags now. - * An alternative would be to destroy and re-create a texture when - * we first start rendering to it. */ - if (!_mesa_is_compressed_format(ctx, internalFormat)) { - if (_mesa_is_depth_format(internalFormat) || - _mesa_is_depthstencil_format(internalFormat)) - usage |= PIPE_BIND_DEPTH_STENCIL; - else - usage |= PIPE_BIND_RENDER_TARGET; - } + if (_mesa_is_depth_format(internalFormat) || + _mesa_is_depthstencil_format(internalFormat)) + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL; + else + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, - PIPE_TEXTURE_2D, usage); - if (pFormat == PIPE_FORMAT_NONE) + PIPE_TEXTURE_2D, bindings); + + if (pFormat == PIPE_FORMAT_NONE) { + /* try choosing format again, this time without render target bindings */ + pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); + } + + if (pFormat == PIPE_FORMAT_NONE) { + /* no luck at all */ return MESA_FORMAT_NONE; + } return st_pipe_format_to_mesa_format(pFormat); } |