Mesa (floating): mesa/st: use floating point temp texture in st_DrawPixels if necessary
Luca Barbieri
lb at kemper.freedesktop.org
Fri Aug 27 17:26:50 UTC 2010
Module: Mesa
Branch: floating
Commit: dfeb9fb65690fd36845876fa66fd3209f6371725
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfeb9fb65690fd36845876fa66fd3209f6371725
Author: Luca Barbieri <luca at luca-barbieri.com>
Date: Thu Aug 26 18:14:57 2010 +0200
mesa/st: use floating point temp texture in st_DrawPixels if necessary
Otherwise, we lose precision and get the data always clamped.
TODO: should we always try this for floating point input data?
TODO: do the transfer operations benefit from conversion to fixed point
TODO: happening only after them?
---
src/mesa/state_tracker/st_cb_drawpixels.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1147b19..3d262fd 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -326,11 +326,22 @@ make_texture(struct st_context *st,
struct pipe_resource *pt;
enum pipe_format pipeFormat;
GLuint cpp;
- GLenum baseFormat;
+ GLenum baseFormat, internalFormat;
- baseFormat = base_format(format);
+ internalFormat = baseFormat = base_format(format);
+ /* we are going to lose precision and get clamped otherwise
+ * TODO: maybe do this even for floating-point input and non-floating point target
+ */
+ if(internalFormat == GL_RGBA
+ && st->ctx->DrawBuffer && st->ctx->DrawBuffer->Visual.floatMode)
+ {
+ if(type == GL_FLOAT || type == GL_DOUBLE)
+ internalFormat = GL_RGBA32F_ARB;
+ else if(type == GL_HALF_FLOAT_ARB)
+ internalFormat = GL_RGBA16F_ARB;
+ }
- mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type);
+ mformat = st_ChooseTextureFormat(ctx, internalFormat, format, type);
assert(mformat);
pipeFormat = st_mesa_format_to_pipe_format(mformat);
More information about the mesa-commit
mailing list