summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_program.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-08-31 17:44:01 -0400
committerRob Clark <[email protected]>2016-09-26 15:29:17 -0400
commitecd6fce2611e88ff8468a354cff8eda39f260a31 (patch)
treef4c281475a9dfb836cf9c9ff1853de0edc850bc6 /src/mesa/state_tracker/st_program.c
parente0ec1c31345aa8f47b5dea16d26be4420bd908ad (diff)
mesa/st: support lowering multi-planar YUV
Support multi-planar YUV for external EGLImage's (currently just in the dma-buf import path) by lowering to multiple texture fetch's for each plane and CSC in shader. There was some discussion of alternative approaches for tracking the additional UV or U/V planes: https://lists.freedesktop.org/archives/mesa-dev/2016-September/127832.html They all seemed worse than pipe_resource::next Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_program.c')
-rw-r--r--src/mesa/state_tracker/st_program.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 2a4edfa7b7a..91887dc27db 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -53,6 +53,7 @@
#include "st_cb_bitmap.h"
#include "st_cb_drawpixels.h"
#include "st_context.h"
+#include "st_tgsi_lower_yuv.h"
#include "st_program.h"
#include "st_mesa_to_tgsi.h"
#include "st_atifs_to_tgsi.h"
@@ -1024,8 +1025,23 @@ st_create_fp_variant(struct st_context *st,
NIR_PASS_V(tgsi.ir.nir, nir_lower_drawpixels, &options);
}
+ if (unlikely(key->external.lower_nv12 || key->external.lower_iyuv)) {
+ nir_lower_tex_options options = {0};
+ options.lower_y_uv_external = key->external.lower_nv12;
+ options.lower_y_u_v_external = key->external.lower_iyuv;
+ NIR_PASS_V(tgsi.ir.nir, nir_lower_tex, &options);
+ }
+
st_finalize_nir(st, &stfp->Base.Base, tgsi.ir.nir);
+ if (unlikely(key->external.lower_nv12 || key->external.lower_iyuv)) {
+ /* This pass needs to happen *after* nir_lower_sampler */
+ NIR_PASS_V(tgsi.ir.nir, st_nir_lower_tex_src_plane,
+ ~stfp->Base.Base.SamplersUsed,
+ key->external.lower_nv12,
+ key->external.lower_iyuv);
+ }
+
variant->driver_shader = pipe->create_fs_state(pipe, &tgsi);
variant->key = *key;
@@ -1122,6 +1138,25 @@ st_create_fp_variant(struct st_context *st,
fprintf(stderr, "mesa: cannot create a shader for glDrawPixels\n");
}
+ if (unlikely(key->external.lower_nv12 || key->external.lower_iyuv)) {
+ const struct tgsi_token *tokens;
+
+ /* samplers inserted would conflict, but this should be unpossible: */
+ assert(!(key->bitmap || key->drawpixels));
+
+ tokens = st_tgsi_lower_yuv(tgsi.tokens,
+ ~stfp->Base.Base.SamplersUsed,
+ key->external.lower_nv12,
+ key->external.lower_iyuv);
+ if (tokens) {
+ if (tgsi.tokens != stfp->tgsi.tokens)
+ tgsi_free_tokens(tgsi.tokens);
+ tgsi.tokens = tokens;
+ } else {
+ fprintf(stderr, "mesa: cannot create a shader for samplerExternalOES\n");
+ }
+ }
+
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump(tgsi.tokens, 0);
debug_printf("\n");