diff options
author | Luca Barbieri <luca@luca-barbieri.com> | 2010-08-26 18:14:57 +0200 |
---|---|---|
committer | Luca Barbieri <luca@luca-barbieri.com> | 2010-09-05 18:11:22 +0200 |
commit | 11d72248257c07a9aab84d6c5a4dbc288bad4d90 (patch) | |
tree | 866ab1f263590fac385a9e1ff044f444453d492b | |
parent | c406514a1fbee6891da4cf9ac3eebe4e4407ec13 (diff) |
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?
-rw-r--r-- | 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 1147b1950e..3d262fda77 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); |