summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_format.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-04-22 14:34:22 -0600
committerBrian Paul <brianp@vmware.com>2010-04-22 14:37:50 -0600
commite9bcad4c33c8c39356ee37445768c0e4a6b3f9a2 (patch)
treeced7ae6af7d4e1b86a8dbf1edc6f8836c62e1749 /src/mesa/state_tracker/st_format.c
parent9f74fa111b422b57a3c8bc0a1cd8c65ecc996aa8 (diff)
st/mesa: fix binding flags in st_ChooseTextureFormat()
See comment for more info.
Diffstat (limited to 'src/mesa/state_tracker/st_format.c')
-rw-r--r--src/mesa/state_tracker/st_format.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 875b65c5b5..3e767507ee 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -36,6 +36,7 @@
#include "main/context.h"
#include "main/texstore.h"
#include "main/enums.h"
+#include "main/image.h"
#include "main/macros.h"
#include "pipe/p_context.h"
@@ -672,12 +673,24 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type)
{
enum pipe_format pFormat;
+ uint usage = PIPE_BIND_SAMPLER_VIEW;
(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_depth_format(internalFormat) ||
+ _mesa_is_depthstencil_format(internalFormat))
+ usage |= PIPE_BIND_DEPTH_STENCIL;
+ else
+ usage |= PIPE_BIND_RENDER_TARGET;
+
pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
- PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+ PIPE_TEXTURE_2D, usage);
if (pFormat == PIPE_FORMAT_NONE)
return MESA_FORMAT_NONE;