Mesa (master): r300g: output floats instead of halfs when passed through translate

Marek Olšák mareko at kemper.freedesktop.org
Sat Jun 19 08:21:52 PDT 2010


Module: Mesa
Branch: master
Commit: 4c761843051d7e97be828baad965c13789127dbf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c761843051d7e97be828baad965c13789127dbf

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Jun 19 17:20:40 2010 +0200

r300g: output floats instead of halfs when passed through translate

---

 src/gallium/drivers/r300/r300_render_translate.c |   27 ++++++++++++++++++++-
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_render_translate.c b/src/gallium/drivers/r300/r300_render_translate.c
index ea3c966..0ea11e5 100644
--- a/src/gallium/drivers/r300/r300_render_translate.c
+++ b/src/gallium/drivers/r300/r300_render_translate.c
@@ -49,6 +49,8 @@ void r300_begin_vertex_translate(struct r300_context *r300)
     for (i = 0; i < ve->count; i++) {
         struct pipe_vertex_buffer *vb =
                 &r300->vertex_buffer[ve->velem[i].vertex_buffer_index];
+        enum pipe_format output_format = ve->hw_format[i];
+        unsigned output_format_size = ve->hw_format_size[i];
 
         /* Check for support. */
         if (ve->velem[i].src_format == ve->hw_format[i] &&
@@ -57,6 +59,27 @@ void r300_begin_vertex_translate(struct r300_context *r300)
             continue;
         }
 
+        /* Workaround for translate: output floats instead of halfs. */
+        switch (output_format) {
+            case PIPE_FORMAT_R16_FLOAT:
+                output_format = PIPE_FORMAT_R32_FLOAT;
+                output_format_size = 4;
+                break;
+            case PIPE_FORMAT_R16G16_FLOAT:
+                output_format = PIPE_FORMAT_R32G32_FLOAT;
+                output_format_size = 8;
+                break;
+            case PIPE_FORMAT_R16G16B16_FLOAT:
+                output_format = PIPE_FORMAT_R32G32B32_FLOAT;
+                output_format_size = 12;
+                break;
+            case PIPE_FORMAT_R16G16B16A16_FLOAT:
+                output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+                output_format_size = 16;
+                break;
+            default:;
+        }
+
         /* Add this vertex element. */
         te = &key.element[key.nr_elements];
         /*te->type;
@@ -64,10 +87,10 @@ void r300_begin_vertex_translate(struct r300_context *r300)
         te->input_buffer = ve->velem[i].vertex_buffer_index;
         te->input_format = ve->velem[i].src_format;
         te->input_offset = vb->buffer_offset + ve->velem[i].src_offset;
-        te->output_format = ve->hw_format[i];
+        te->output_format = output_format;
         te->output_offset = key.output_stride;
 
-        key.output_stride += ve->hw_format_size[i];
+        key.output_stride += output_format_size;
         vb_translated[ve->velem[i].vertex_buffer_index] = TRUE;
         tr_elem_index[i] = key.nr_elements;
         key.nr_elements++;



More information about the mesa-commit mailing list