Mesa (7.11): i915g: Move back to the old method for target format fixup.

Stephane Marchesin marcheu at kemper.freedesktop.org
Fri Jul 8 07:36:50 UTC 2011


Module: Mesa
Branch: 7.11
Commit: b292ef8f88f95087d210d5ac57684dedad5258cd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b292ef8f88f95087d210d5ac57684dedad5258cd

Author: Stéphane Marchesin <marcheu at chromium.org>
Date:   Sun Jul  3 19:43:19 2011 -0700

i915g: Move back to the old method for target format fixup.

Conflicts:

	src/gallium/drivers/i915/i915_state_emit.c

---

 src/gallium/drivers/i915/i915_state.c      |    2 +-
 src/gallium/drivers/i915/i915_state_emit.c |   34 ++++++++++++++++-----------
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 2f1b0f9..76cfd0b 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -243,7 +243,7 @@ i915_create_sampler_state(struct pipe_context *pipe,
 
    /* Shadow:
     */
-   if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) 
+   if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
    {
       cso->state[0] |= (SS2_SHADOW_ENABLE |
                         i915_translate_compare_func(sampler->compare_func));
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 55399a9..cc97dc9 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -349,25 +349,25 @@ static const struct
    uint hw_swizzle;
 } fixup_formats[] = {
    { PIPE_FORMAT_R8G8B8A8_UNORM, 0x21030000 /* BGRA */},
-   { PIPE_FORMAT_L8_UNORM,       0x00000000 /* RRRR */},
-   { PIPE_FORMAT_I8_UNORM,       0x00000000 /* RRRR */},
+   { PIPE_FORMAT_L8_UNORM,       0x00030000 /* RRRA */},
+   { PIPE_FORMAT_I8_UNORM,       0x00030000 /* RRRA */},
    { PIPE_FORMAT_A8_UNORM,       0x33330000 /* AAAA */},
    { PIPE_FORMAT_NONE,           0x00000000},
 };
 
-static boolean need_fixup(struct pipe_surface* p)
+static uint need_target_fixup(struct pipe_surface* p)
 {
    enum pipe_format f;
    /* if we don't have a surface bound yet, we don't need to fixup the shader */
    if (!p)
-      return FALSE;
+      return 0;
 
    f = p->format;
    for(int i=0; fixup_formats[i].format != PIPE_FORMAT_NONE; i++)
       if (fixup_formats[i].format == f)
-         return TRUE;
+         return 1;
 
-   return FALSE;
+   return 0;
 }
 
 static uint fixup_swizzle(enum pipe_format f)
@@ -383,29 +383,35 @@ static void
 validate_program(struct i915_context *i915, unsigned *batch_space)
 {
    struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
+   uint additional_size = need_target_fixup(cbuf_surface);
 
    /* we need more batch space if we want to emulate rgba framebuffers */
-   *batch_space = i915->fs->program_len + (need_fixup(cbuf_surface) ? 3 : 0);
+   *batch_space = i915->fs->program_len + 3 * additional_size;
 }
 
 static void
 emit_program(struct i915_context *i915)
 {
    struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
-   boolean need_format_fixup = need_fixup(cbuf_surface);
+   uint target_fixup = need_target_fixup(cbuf_surface);
    uint i;
 
    /* we should always have, at least, a pass-through program */
    assert(i915->fs->program_len > 0);
-   for (i = 0; i < i915->fs->program_len; i++) {
-         if ((i == 0) && need_format_fixup)
-            OUT_BATCH(i915->fs->program[i] + 3);
-         else
-            OUT_BATCH(i915->fs->program[i]);
+
+   {
+      /* first word has the size, we have to adjust that */
+      uint size = (i915->fs->program[0]);
+      size += target_fixup * 3;
+      OUT_BATCH(size);
    }
 
+   /* output the declarations of the program */
+   for (i=1 ; i < i915->fs->program_len; i++) 
+      OUT_BATCH(i915->fs->program[i]);
+
    /* we emit an additional mov with swizzle to fake RGBA framebuffers */
-   if (need_format_fixup) {
+   if (target_fixup) {
       /* mov out_color, out_color.zyxw */
       OUT_BATCH(A0_MOV |
                 (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) |




More information about the mesa-commit mailing list