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 <robdclark@gmail.com>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user