+#define ST_DOUBLE_ATTRIB_PLACEHOLDER 0xff
+
+struct st_external_sampler_key
+{
+ GLuint lower_nv12; /**< bitmask of 2 plane YUV samplers */
+ GLuint lower_iyuv; /**< bitmask of 3 plane YUV samplers */
+ GLuint lower_xy_uxvx; /**< bitmask of 2 plane YUV samplers */
+ GLuint lower_yx_xuxv; /**< bitmask of 2 plane YUV samplers */
+ GLuint lower_ayuv;
+ GLuint lower_xyuv;
+};
+
+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);
+ enum pipe_format format = st_get_view_format(stObj);
+
+ /* if resource format matches then YUV wasn't lowered */
+ if (format == stObj->pt->format)
+ continue;
+
+ switch (format) {
+ case PIPE_FORMAT_NV12:
+ case PIPE_FORMAT_P010:
+ case PIPE_FORMAT_P016:
+ key.lower_nv12 |= (1 << unit);
+ break;
+ case PIPE_FORMAT_IYUV:
+ key.lower_iyuv |= (1 << unit);
+ break;
+ case PIPE_FORMAT_YUYV:
+ key.lower_yx_xuxv |= (1 << unit);
+ break;
+ case PIPE_FORMAT_UYVY:
+ key.lower_xy_uxvx |= (1 << unit);
+ break;
+ case PIPE_FORMAT_AYUV:
+ key.lower_ayuv |= (1 << unit);
+ break;
+ case PIPE_FORMAT_XYUV:
+ key.lower_xyuv |= (1 << unit);
+ break;
+ default:
+ printf("mesa: st_get_external_sampler_key: unhandled pipe format %u\n",
+ format);
+ break;
+ }
+ }
+
+ return key;
+}