diff --git a/.gitignore b/.gitignore index e48280767..438fbb9f0 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ TAGS .VERSION* # IRQL fork .vscode/c_cpp_properties.json +.vscode/settings.json diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c index c9df7d304..6ca177527 100644 --- a/src/gen6_mfd.c +++ b/src/gen6_mfd.c @@ -1964,3 +1964,89 @@ gen6_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) return (struct hw_context *)gen6_mfd_context; } + +void gen6_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->entrypoint) + { + case VAEntrypointVLD: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } + + case VAEntrypointVideoProc: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YUY2; + (*i)++; + + /** + * Previously the driver claimed to support RGBA on SNB, + * this however isn't true since the conversion shader does + * NOT support the alpha channel. + * + * This also applies to BGRA and ARGB which would mean that + * we need to use a workaround shader to make it possible + * to use these formats. + */ + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBX; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_ARGB; + (*i)++; + + FALLTHROUGH; + } + + case VAEntrypointEncSlice: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV12; + (*i)++; + + break; + } + + default: + { + i965_log_debug(ctx, "gen6_get_hw_formats: Ignoring unknown entrypoint %#010x\n", obj_config->entrypoint); + break; + } + } +} \ No newline at end of file diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c index fa8fa8415..d3d03509d 100644 --- a/src/gen7_mfd.c +++ b/src/gen7_mfd.c @@ -3239,3 +3239,184 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) gen7_mfd_context->driver_context = ctx; return (struct hw_context *)gen7_mfd_context; } + +static inline void gen7_get_hw_dec_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->profile) + { + case VAProfileJPEGBaseline: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC3; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC1; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_Y800; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_411P; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_422H; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_422V; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_444P; + (*i)++; + + break; + } + + default: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } + } +} + +static inline void gen7_get_hw_enc_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC3; + (*i)++; +} + +static inline void gen7_get_hw_vpp_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBX; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRX; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_ARGB; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YUY2; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_UYVY; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV16; + (*i)++; +} + +void gen7_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->entrypoint) + { + case VAEntrypointVLD: + { + gen7_get_hw_dec_formats(ctx, obj_config, data, i, attribs); + break; + } + + case VAEntrypointVideoProc: + { + gen7_get_hw_vpp_formats(ctx, obj_config, data, i, attribs); + + /** + * We also support the encoding formats + * in the VPP for IVB and HSW. + */ + FALLTHROUGH; + } + + case VAEntrypointEncSlice: + { + gen7_get_hw_enc_formats(ctx, obj_config, data, i, attribs); + break; + } + + default: + { + i965_log_debug(ctx, "gen7_get_hw_formats: Ignoring unknown entrypoint %#010x\n", obj_config->entrypoint); + break; + } + } +} \ No newline at end of file diff --git a/src/gen8_mfd.c b/src/gen8_mfd.c index da1ae6cb0..341c1f17c 100644 --- a/src/gen8_mfd.c +++ b/src/gen8_mfd.c @@ -3701,3 +3701,299 @@ gen8_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) gen7_mfd_context->driver_context = ctx; return (struct hw_context *)gen7_mfd_context; } + +static inline void gen8_get_hw_dec_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->profile) + { + case VAProfileJPEGBaseline: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC3; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC1; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_Y800; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_411P; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_422H; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_422V; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_444P; + (*i)++; + + break; + } + + case VAProfileHEVCMain10: + case VAProfileVP9Profile2: + { + if (!data->codec_info->has_vpp_p010) + break; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_P010; + (*i)++; + + FALLTHROUGH; + } + + default: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } + } +} + +static inline void gen8_get_hw_enc_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->profile) + { + case VAProfileHEVCMain10: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_P010; + (*i)++; + + break; + } + + case VAProfileJPEGBaseline: + { + if (obj_config->entrypoint == VAEntrypointEncPicture) + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YUY2; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_UYVY; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV16; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_Y800; + (*i)++; + } + + FALLTHROUGH; + } + + default: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC3; + (*i)++; + } + } +} + +static inline void gen8_get_hw_vpp_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_IMC3; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBX; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRX; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_ARGB; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YUY2; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_UYVY; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_YV16; + (*i)++; + + /** + * KBL/GLK or newer. + */ + if (data->codec_info->has_vpp_p010) + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_P010; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I010; + (*i)++; + } +} + +void gen8_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->entrypoint) + { + case VAEntrypointVLD: + { + gen8_get_hw_dec_formats(ctx, obj_config, data, i, attribs); + break; + } + + case VAEntrypointEncSlice: + case VAEntrypointEncSliceLP: + case VAEntrypointEncPicture: + case VAEntrypointFEI: + { + gen8_get_hw_enc_formats(ctx, obj_config, data, i, attribs); + break; + } + + case VAEntrypointVideoProc: + { + gen8_get_hw_vpp_formats(ctx, obj_config, data, i, attribs); + break; + } + + case VAEntrypointStats: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } + + default: + { + i965_log_debug(ctx, "gen8_get_hw_formats: Ignoring unknown entrypoint %#010x\n", obj_config->entrypoint); + break; + } + } +} \ No newline at end of file diff --git a/src/i965_device_info.c b/src/i965_device_info.c index e0c6e9d73..87db3b3b6 100644 --- a/src/i965_device_info.c +++ b/src/i965_device_info.c @@ -60,6 +60,10 @@ extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *); extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *); + +extern void g4x_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs); + extern bool genx_render_init(VADriverContextP); static struct hw_codec_info g4x_hw_codec_info = { @@ -68,6 +72,7 @@ static struct hw_codec_info g4x_hw_codec_info = { .proc_hw_context_init = NULL, .render_init = genx_render_init, .post_processing_context_init = NULL, + .get_hw_formats = g4x_get_hw_formats, .max_width = 2048, .max_height = 2048, @@ -90,12 +95,16 @@ static struct hw_codec_info g4x_hw_codec_info = { extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *); extern void i965_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *); +extern void ironlake_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs); + static struct hw_codec_info ilk_hw_codec_info = { .dec_hw_context_init = ironlake_dec_hw_context_init, .enc_hw_context_init = NULL, .proc_hw_context_init = i965_proc_context_init, .render_init = genx_render_init, .post_processing_context_init = i965_post_processing_context_init, + .get_hw_formats = ironlake_get_hw_formats, .max_width = 2048, .max_height = 2048, @@ -119,9 +128,12 @@ static struct hw_codec_info ilk_hw_codec_info = { }; static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info); +static void gen6_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs); extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *); extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *); + static struct hw_codec_info snb_hw_codec_info = { .dec_hw_context_init = gen6_dec_hw_context_init, .enc_hw_context_init = gen6_enc_hw_context_init, @@ -129,6 +141,7 @@ static struct hw_codec_info snb_hw_codec_info = { .render_init = genx_render_init, .post_processing_context_init = i965_post_processing_context_init, .preinit_hw_codec = gen6_hw_codec_preinit, + .get_hw_formats = gen6_get_hw_formats, .max_width = 2048, .max_height = 2048, @@ -166,6 +179,8 @@ static struct hw_codec_info snb_hw_codec_info = { }; static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info); +static void gen7_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs); extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *); extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *); @@ -176,6 +191,7 @@ static struct hw_codec_info ivb_hw_codec_info = { .render_init = genx_render_init, .post_processing_context_init = i965_post_processing_context_init, .preinit_hw_codec = gen7_hw_codec_preinit, + .get_hw_formats = gen7_get_hw_formats, .max_width = 4096, .max_height = 4096, @@ -229,6 +245,7 @@ static struct hw_codec_info hsw_hw_codec_info = { .render_init = genx_render_init, .post_processing_context_init = i965_post_processing_context_init, .preinit_hw_codec = hsw_hw_codec_preinit, + .get_hw_formats = gen7_get_hw_formats, .max_width = 4096, .max_height = 4096, @@ -278,12 +295,17 @@ static struct hw_codec_info hsw_hw_codec_info = { extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *); extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *); extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *); + +static void gen8_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs); + static struct hw_codec_info bdw_hw_codec_info = { .dec_hw_context_init = gen8_dec_hw_context_init, .enc_hw_context_init = gen8_enc_hw_context_init, .proc_hw_context_init = gen75_proc_context_init, .render_init = gen8_render_init, .post_processing_context_init = gen8_post_processing_context_init, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, .max_height = 4096, @@ -332,12 +354,14 @@ static struct hw_codec_info bdw_hw_codec_info = { }; extern struct hw_context *gen9_dec_hw_context_init(VADriverContextP, struct object_config *); + static struct hw_codec_info chv_hw_codec_info = { .dec_hw_context_init = gen9_dec_hw_context_init, .enc_hw_context_init = gen8_enc_hw_context_init, .proc_hw_context_init = gen75_proc_context_init, .render_init = gen8_render_init, .post_processing_context_init = gen8_post_processing_context_init, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, .max_height = 4096, @@ -402,6 +426,7 @@ static struct hw_codec_info skl_hw_codec_info = { .post_processing_context_init = gen9_post_processing_context_init, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, /* default. See max_resolution */ .max_height = 4096, /* default. See max_resolution */ @@ -466,6 +491,7 @@ static struct hw_codec_info bxt_hw_codec_info = { .post_processing_context_init = gen9_post_processing_context_init, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, /* default. See max_resolution */ .max_height = 4096, /* default. See max_resolution */ @@ -533,6 +559,7 @@ static struct hw_codec_info kbl_hw_codec_info = { .post_processing_context_init = gen9_post_processing_context_init, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, /* default. See max_resolution */ .max_height = 4096, /* default. See max_resolution */ @@ -606,7 +633,7 @@ static struct hw_codec_info glk_hw_codec_info = { .proc_hw_context_init = gen75_proc_context_init, .render_init = gen9_render_init, .post_processing_context_init = gen9_post_processing_context_init, - + .get_hw_formats = gen8_get_hw_formats, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, @@ -684,6 +711,7 @@ static struct hw_codec_info cfl_hw_codec_info = { .post_processing_context_init = gen9_post_processing_context_init, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, /* default. See max_resolution */ .max_height = 4096, /* default. See max_resolution */ @@ -759,6 +787,7 @@ static struct hw_codec_info cnl_hw_codec_info = { .post_processing_context_init = gen9_post_processing_context_init, .max_resolution = gen9_max_resolution, .preinit_hw_codec = gen9_hw_codec_preinit, + .get_hw_formats = gen8_get_hw_formats, .max_width = 4096, /* default. See max_resolution */ .max_height = 4096, /* default. See max_resolution */ diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index 9f95df372..182fd9295 100644 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -6393,91 +6393,15 @@ i965_GetSurfaceAttributes( return vaStatus; } -static int i965_PopulateVideoProcFormats(struct i965_driver_data *i965, int i, VASurfaceAttrib *attribs) -{ - /* RGBx formats */ - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_RGBA; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_RGBX; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_BGRA; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_BGRX; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_ARGB; - i++; - - /* YUY2 (supported by all H/W) */ - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YUY2; - i++; - - /* 10-bit formats */ - - if (HAS_VPP_P010(i965)) - { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_P010; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I010; - i++; - } - - /* YUV422 (Ivybridge and newer) */ - - if (i965->intel.device_info->gen >= 7) - { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_UYVY; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YV16; - i++; - } - - return i; -} - static VAStatus i965_QuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, VASurfaceAttrib *attrib_list, unsigned int *num_attribs) { + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + VAStatus vaStatus = VA_STATUS_SUCCESS; struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_config *obj_config; @@ -6507,317 +6431,20 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx, if (attribs == NULL) return VA_STATUS_ERROR_ALLOCATION_FAILED; - if (IS_G4X(i965->intel.device_info)) { - if (obj_config->profile == VAProfileMPEG2Simple || - obj_config->profile == VAProfileMPEG2Main) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - } - } else if (IS_IRONLAKE(i965->intel.device_info)) { - switch (obj_config->profile) { - case VAProfileMPEG2Simple: - case VAProfileMPEG2Main: - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - - break; - - case VAProfileH264ConstrainedBaseline: - case VAProfileH264Main: - case VAProfileH264High: - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - break; - - case VAProfileNone: - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - - break; - - default: - break; - } - } else if (IS_GEN6(i965->intel.device_info)) { - if (obj_config->entrypoint == VAEntrypointVLD) { /* decode */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - } else if (obj_config->entrypoint == VAEntrypointEncSlice || /* encode */ - obj_config->entrypoint == VAEntrypointVideoProc) { /* vpp */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YV12; - i++; - - if (obj_config->entrypoint == VAEntrypointVideoProc) - { - i = i965_PopulateVideoProcFormats(i965, i, attribs); - } - } - } else if (IS_GEN7(i965->intel.device_info)) { - if (obj_config->entrypoint == VAEntrypointVLD) { /* decode */ - if (obj_config->profile == VAProfileJPEGBaseline) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC3; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC1; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_Y800; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_411P; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_422H; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_422V; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_444P; - i++; - } else if (obj_config->profile == VAProfileHEVCMain10) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_P010; - i++; - } else { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - } - } else if (obj_config->entrypoint == VAEntrypointEncSlice || /* encode */ - obj_config->entrypoint == VAEntrypointVideoProc) { /* vpp */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC3; - i++; - - if (obj_config->entrypoint == VAEntrypointVideoProc) - { - i = i965_PopulateVideoProcFormats(i965, i, attribs); - } - } - } else if (IS_GEN8(i965->intel.device_info) || - IS_GEN9(i965->intel.device_info) || - IS_GEN10(i965->intel.device_info)) { - if (obj_config->entrypoint == VAEntrypointVLD) { /* decode */ - if (obj_config->profile == VAProfileJPEGBaseline) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC3; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC1; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_Y800; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_411P; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_422H; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_422V; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_444P; - i++; - } else { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - if ((obj_config->profile == VAProfileHEVCMain10) || - (obj_config->profile == VAProfileVP9Profile2)) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_P010; - i++; - } - } - } else if (obj_config->entrypoint == VAEntrypointEncSlice || /* encode */ - obj_config->entrypoint == VAEntrypointVideoProc || - obj_config->entrypoint == VAEntrypointEncSliceLP || - obj_config->entrypoint == VAEntrypointEncPicture || - obj_config->entrypoint == VAEntrypointFEI) { - - if (obj_config->profile == VAProfileHEVCMain10) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_P010; - i++; - } else { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_I420; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YV12; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_IMC3; - i++; - } - - if (obj_config->entrypoint == VAEntrypointVideoProc) - { - i = i965_PopulateVideoProcFormats(i965, i, attribs); - } - - /* Additional support for jpeg encoder */ - if (obj_config->profile == VAProfileJPEGBaseline - && obj_config->entrypoint == VAEntrypointEncPicture) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YUY2; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_UYVY; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_YV16; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_Y800; - i++; - } - } else if (obj_config->entrypoint == VAEntrypointStats) { - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; - } + if (!i965->codec_info->get_hw_formats) + { + i965_log_error(ctx, "i965_QuerySurfaceAttributes: get_hw_formats() is unavailable!\n"); + return VA_STATUS_ERROR_UNKNOWN; } + /** + * We no longer have one massive function to query the formats. + * + * This has the benefit of being tider, at the cost of some additional + * code overhead. + */ + i965->codec_info->get_hw_formats(ctx, obj_config, i965, &i, attribs); + attribs[i].type = VASurfaceAttribMemoryType; attribs[i].value.type = VAGenericValueTypeInteger; attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h index 1a4ea6448..a79501de6 100644 --- a/src/i965_drv_video.h +++ b/src/i965_drv_video.h @@ -457,6 +457,7 @@ struct hw_codec_info { bool (*render_init)(VADriverContextP); void (*post_processing_context_init)(VADriverContextP, void *, struct intel_batchbuffer *); void (*preinit_hw_codec)(VADriverContextP, struct hw_codec_info *); + void (*get_hw_formats)(VADriverContextP, struct object_config *, struct i965_driver_data *, int *, VASurfaceAttrib *); /** * Allows HW info to support per-codec max resolution. If this functor is diff --git a/src/i965_media.c b/src/i965_media.c index 30ba3a9a7..28cb18754 100644 --- a/src/i965_media.c +++ b/src/i965_media.c @@ -363,6 +363,51 @@ g4x_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) return (struct hw_context *)media_context; } +void g4x_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->profile) + { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + { + assert(obj_config->entrypoint == VAEntrypointVLD); + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + break; + } + +#if defined(I965_H264_ENABLE_CTG) + case VAProfileH264ConstrainedBaseline: + case VAProfileH264Main: + case VAProfileH264High: + { + assert(obj_config->entrypoint == VAEntrypointVLD); + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } +#endif + + default: + { + i965_log_debug(ctx, "g4x_get_hw_formats: Ignoring unknown entrypoint %#010x (profile %#010x)\n", + obj_config->entrypoint, obj_config->profile); + break;; + } + } +} + struct hw_context * ironlake_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) { @@ -396,3 +441,94 @@ ironlake_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_con return (struct hw_context *)media_context; } + +void ironlake_get_hw_formats(VADriverContextP ctx, struct object_config *obj_config, + struct i965_driver_data* data, int *i, VASurfaceAttrib *attribs) +{ + switch (obj_config->profile) + { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + { + assert(obj_config->entrypoint == VAEntrypointVLD); + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + break; + } + + case VAProfileH264ConstrainedBaseline: + case VAProfileH264Main: + case VAProfileH264High: + { + assert(obj_config->entrypoint == VAEntrypointVLD); + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + break; + } + + case VAProfileNone: + { + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_NV12; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_I420; + (*i)++; + + /** + * The VAAPI driver previously didn't claim support for RGBX, + * even though we do have the shaders for processing it, + * make it possible. + * + * Even if it's untested. + */ + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_RGBX; + (*i)++; + + /** + * BGRA and ARGB isn't supported natively via VPP on ILK, + * we need to use a workaround shader to make it possible. + */ + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_BGRA; + (*i)++; + + attribs[*i].type = VASurfaceAttribPixelFormat; + attribs[*i].value.type = VAGenericValueTypeInteger; + attribs[*i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[*i].value.value.i = VA_FOURCC_ARGB; + (*i)++; + + break; + } + + default: + { + i965_log_debug(ctx, "ironlake_get_hw_formats: Ignoring unknown entrypoint %#010x (profile %#010x)\n", + obj_config->entrypoint, obj_config->profile); + break; + } + } +} \ No newline at end of file diff --git a/src/intel_compiler.h b/src/intel_compiler.h index e1c3bd2a8..32a496d2a 100644 --- a/src/intel_compiler.h +++ b/src/intel_compiler.h @@ -23,4 +23,29 @@ # define DLL_EXPORT #endif +/** + * FALLTHROUGH macro + */ +#if defined(__has_cpp_attribute) && defined(__clang__) +/* We do not do the same trick as __has_attribute because parsing + * clang::fallthrough in the preprocessor fails in GCC. */ +# define HAS_CLANG_FALLTHROUGH __has_cpp_attribute(clang::fallthrough) +#else +# define HAS_CLANG_FALLTHROUGH 0 +#endif + +#if (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L)) +/* Standard C++17/C23 attribute */ +#define FALLTHROUGH [[fallthrough]] +#elif HAS_CLANG_FALLTHROUGH +/* Clang++ specific */ +#define FALLTHROUGH [[clang::fallthrough]] +#elif __has_attribute(fallthrough) +/* Non-standard but supported by at least gcc and clang */ +#define FALLTHROUGH __attribute__((fallthrough)) +#else +#define FALLTHROUGH do { } while(0) +#endif + #endif /* _INTEL_COMPILER_H_ */