aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_program.h
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.h
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.h')
-rw-r--r--src/mesa/state_tracker/st_program.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 8e11bf02fa9..ea55d476ff0 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -39,6 +39,7 @@
#include "program/program.h"
#include "pipe/p_state.h"
#include "st_context.h"
+#include "st_texture.h"
#include "st_glsl_to_tgsi.h"
@@ -48,6 +49,40 @@ extern "C" {
#define ST_DOUBLE_ATTRIB_PLACEHOLDER 0xffffffff
+struct st_external_sampler_key
+{
+ GLuint lower_nv12; /**< bitmask of 2 plane YUV samplers */
+ GLuint lower_iyuv; /**< bitmask of 3 plane YUV samplers */
+};
+
+static inline struct st_external_sampler_key
+st_get_external_sampler_key(struct st_context *st, struct gl_program *prog)
+{
+ unsigned mask = prog->ExternalSamplersUsed;
+ struct st_external_sampler_key key;
+
+ memset(&key, 0, sizeof(key));
+
+ while (unlikely(mask)) {
+ unsigned unit = u_bit_scan(&mask);
+ struct st_texture_object *stObj =
+ st_get_texture_object(st->ctx, prog, unit);
+
+ switch (st_get_view_format(stObj)) {
+ case PIPE_FORMAT_NV12:
+ key.lower_nv12 |= (1 << unit);
+ break;
+ case PIPE_FORMAT_IYUV:
+ key.lower_iyuv |= (1 << unit);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return key;
+}
+
/** Fragment program variant key */
struct st_fp_variant_key
{
@@ -72,6 +107,8 @@ struct st_fp_variant_key
/** needed for ATI_fragment_shader */
char texture_targets[MAX_NUM_FRAGMENT_REGISTERS_ATI];
+
+ struct st_external_sampler_key external;
};