Both sampling and possible conversion to RGB are dependent on the
format of the DRI image representing the pixel source. In order to
accomodate this one re-compiles the program upon any changes.

Altering the program key effectively kicks off the re-compilation
as part of brw state uploading.

Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com>
---
 src/mesa/drivers/dri/i965/brw_program.h |    6 ++++++
 src/mesa/drivers/dri/i965/brw_wm.c      |    7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_program.h 
b/src/mesa/drivers/dri/i965/brw_program.h
index 1821775..de1f111 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -40,6 +40,12 @@ struct brw_sampler_prog_key_data {
     */
    uint16_t yuvtex_mask;
    uint16_t yuvtex_swap_mask; /**< UV swaped */
+
+   /**
+    * Format of the sampled texture when it is of the type image
+    * external and needs special sampling/conversion.
+    */
+   const struct intel_image_format *ext_format;
 };
 
 void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 8584e3f..cde1c9b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -363,6 +363,13 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
            if (sampler->WrapR == GL_CLAMP)
               key->gl_clamp_mask[2] |= 1 << s;
         }
+
+         if (unit->_Current->Target == GL_TEXTURE_EXTERNAL_OES) {
+            const struct intel_texture_image *intel_img =
+               (const struct intel_texture_image *)img;
+
+            key->ext_format = intel_img->ext_format;
+         }
       }
    }
 }
-- 
1.7.9.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to