diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c index 93ec5cafb9..7021f27572 100644 --- a/libavcodec/ffv1enc_vulkan.c +++ b/libavcodec/ffv1enc_vulkan.c @@ -96,9 +96,10 @@ extern const char *ff_source_ffv1_enc_rgb_comp; typedef struct FFv1VkRCTParameters { int offset; + uint8_t bits; uint8_t planar_rgb; uint8_t transparency; - uint8_t padding[2]; + uint8_t padding[1]; } FFv1VkRCTParameters; typedef struct FFv1VkResetParameters { @@ -247,6 +248,7 @@ static int run_rct(AVCodecContext *avctx, FFVkExecContext *exec, ff_vk_exec_bind_shader(&fv->s, exec, &fv->rct); pd = (FFv1VkRCTParameters) { .offset = 1 << f->bits_per_raw_sample, + .bits = f->bits_per_raw_sample, .planar_rgb = ff_vk_mt_is_np_rgb(src_hwfc->sw_format) && (ff_vk_count_images((AVVkFrame *)enc_in->data[0]) > 1), .transparency = f->transparency, @@ -1070,9 +1072,10 @@ static int init_rct_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) GLSLC(0, layout(push_constant, scalar) uniform pushConstants { ); GLSLC(1, int offset; ); + GLSLC(1, uint8_t bits; ); GLSLC(1, uint8_t planar_rgb; ); GLSLC(1, uint8_t transparency; ); - GLSLC(1, uint8_t padding[2]; ); + GLSLC(1, uint8_t padding[1]; ); GLSLC(0, }; ); ff_vk_shader_add_push_const(shd, 0, sizeof(FFv1VkRCTParameters), VK_SHADER_STAGE_COMPUTE_BIT); diff --git a/libavcodec/vulkan/ffv1_enc_rct.comp b/libavcodec/vulkan/ffv1_enc_rct.comp index ad4cbf805f..28f40cda7e 100644 --- a/libavcodec/vulkan/ffv1_enc_rct.comp +++ b/libavcodec/vulkan/ffv1_enc_rct.comp @@ -30,9 +30,9 @@ ivec4 load_components(ivec2 pos) pix[i] = int(imageLoad(src[i], pos)[0]); /* Swizzle out the difference */ - if (transparency > 0) - return pix.brga; - return pix.bgra; + if (bits > 8 && bits < 16) + return pix.bgra; + return pix.brga; } void bypass_sample(ivec2 pos) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 1de98b1a9c..7f5a74dd38 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -329,10 +329,15 @@ static const struct FFVkFormatEntry { { VK_FORMAT_R32G32B32A32_UINT, AV_PIX_FMT_RGBA128, VK_IMAGE_ASPECT_COLOR_BIT, 1, 1, 1, { VK_FORMAT_R32G32B32A32_UINT } }, /* Planar RGB */ + { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP10, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP12, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP14, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP16, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { VK_FORMAT_R32_SFLOAT, AV_PIX_FMT_GBRPF32, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT } }, + + /* Planar RGB + Alpha */ { VK_FORMAT_R8_UNORM, AV_PIX_FMT_GBRAP, VK_IMAGE_ASPECT_COLOR_BIT, 4, 4, 4, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM } }, - { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP10, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, { VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRAP16, VK_IMAGE_ASPECT_COLOR_BIT, 4, 4, 4, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, - { VK_FORMAT_R32_SFLOAT, AV_PIX_FMT_GBRPF32, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT } }, { VK_FORMAT_R32_SFLOAT, AV_PIX_FMT_GBRAPF32, VK_IMAGE_ASPECT_COLOR_BIT, 4, 4, 4, { VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT } }, /* Two-plane 420 YUV at 8, 10, 12 and 16 bits */ diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index ba21fef3dd..790f2e5aa4 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1330,7 +1330,8 @@ int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt) pix_fmt == AV_PIX_FMT_RGBA64 || pix_fmt == AV_PIX_FMT_RGB565 || pix_fmt == AV_PIX_FMT_BGR565 || pix_fmt == AV_PIX_FMT_BGR0 || pix_fmt == AV_PIX_FMT_0BGR || pix_fmt == AV_PIX_FMT_RGB0 || - pix_fmt == AV_PIX_FMT_GBRP10 || + pix_fmt == AV_PIX_FMT_GBRP10 || pix_fmt == AV_PIX_FMT_GBRP12 || + pix_fmt == AV_PIX_FMT_GBRP14 || pix_fmt == AV_PIX_FMT_GBRP16 || pix_fmt == AV_PIX_FMT_GBRAP || pix_fmt == AV_PIX_FMT_GBRAP16 || pix_fmt == AV_PIX_FMT_GBRPF32 || pix_fmt == AV_PIX_FMT_GBRAPF32 || pix_fmt == AV_PIX_FMT_X2RGB10 || pix_fmt == AV_PIX_FMT_X2BGR10 || @@ -1428,6 +1429,9 @@ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, case AV_PIX_FMT_GRAY16: case AV_PIX_FMT_GBRAP16: case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV420P16: