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:25:21 UTC 2010


Module: Mesa
Branch: floating
Commit: 8c800d98cd6b3d6c0c2cd3b4ed204f35e57f4092
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c800d98cd6b3d6c0c2cd3b4ed204f35e57f4092

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