1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

transpose_vulkan: port to imageLoad()

This commit is contained in:
Lynne
2025-02-17 19:01:55 +01:00
parent b02f9157b8
commit 379cfd1855

View File

@@ -35,7 +35,6 @@ typedef struct TransposeVulkanContext {
FFVkExecPool e; FFVkExecPool e;
AVVulkanDeviceQueueFamily *qf; AVVulkanDeviceQueueFamily *qf;
FFVulkanShader shd; FFVulkanShader shd;
VkSampler sampler;
int dir; int dir;
int passthrough; int passthrough;
@@ -69,7 +68,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
} }
RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
RET(ff_vk_shader_init(vkctx, &s->shd, "transpose", RET(ff_vk_shader_init(vkctx, &s->shd, "transpose",
VK_SHADER_STAGE_COMPUTE_BIT, VK_SHADER_STAGE_COMPUTE_BIT,
NULL, 0, NULL, 0,
@@ -79,11 +77,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
desc = (FFVulkanDescriptorSetBinding []) { desc = (FFVulkanDescriptorSetBinding []) {
{ {
.name = "input_images", .name = "input_images",
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
.mem_layout = ff_vk_shader_rep_fmt(s->vkctx.input_format, FF_VK_REP_FLOAT),
.mem_quali = "readonly",
.dimensions = 2, .dimensions = 2,
.elems = planes, .elems = planes,
.stages = VK_SHADER_STAGE_COMPUTE_BIT, .stages = VK_SHADER_STAGE_COMPUTE_BIT,
.samplers = DUP_SAMPLER(s->sampler),
}, },
{ {
.name = "output_images", .name = "output_images",
@@ -107,13 +106,13 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
GLSLF(1, size = imageSize(output_images[%i]); ,i); GLSLF(1, size = imageSize(output_images[%i]); ,i);
GLSLC(1, if (IS_WITHIN(pos, size)) { ); GLSLC(1, if (IS_WITHIN(pos, size)) { );
if (s->dir == TRANSPOSE_CCLOCK) if (s->dir == TRANSPOSE_CCLOCK)
GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i); GLSLF(2, vec4 res = imageLoad(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i);
else if (s->dir == TRANSPOSE_CLOCK_FLIP || s->dir == TRANSPOSE_CLOCK) { else if (s->dir == TRANSPOSE_CLOCK_FLIP || s->dir == TRANSPOSE_CLOCK) {
GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.yx - pos.yx)); ,i); GLSLF(2, vec4 res = imageLoad(input_images[%i], ivec2(size.yx - pos.yx)); ,i);
if (s->dir == TRANSPOSE_CLOCK) if (s->dir == TRANSPOSE_CLOCK)
GLSLC(2, pos = ivec2(pos.x, size.y - pos.y); ); GLSLC(2, pos = ivec2(pos.x, size.y - pos.y); );
} else } else
GLSLF(2, vec4 res = texture(input_images[%i], pos.yx); ,i); GLSLF(2, vec4 res = imageLoad(input_images[%i], pos.yx); ,i);
GLSLF(2, imageStore(output_images[%i], pos, res); ,i); GLSLF(2, imageStore(output_images[%i], pos, res); ,i);
GLSLC(1, } ); GLSLC(1, } );
} }
@@ -157,7 +156,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
RET(init_filter(ctx, in)); RET(init_filter(ctx, in));
RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, out, in, RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, out, in,
s->sampler, NULL, 0)); VK_NULL_HANDLE, NULL, 0));
RET(av_frame_copy_props(out, in)); RET(av_frame_copy_props(out, in));
@@ -182,15 +181,10 @@ static av_cold void transpose_vulkan_uninit(AVFilterContext *avctx)
{ {
TransposeVulkanContext *s = avctx->priv; TransposeVulkanContext *s = avctx->priv;
FFVulkanContext *vkctx = &s->vkctx; FFVulkanContext *vkctx = &s->vkctx;
FFVulkanFunctions *vk = &vkctx->vkfn;
ff_vk_exec_pool_free(vkctx, &s->e); ff_vk_exec_pool_free(vkctx, &s->e);
ff_vk_shader_free(vkctx, &s->shd); ff_vk_shader_free(vkctx, &s->shd);
if (s->sampler)
vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
vkctx->hwctx->alloc);
ff_vk_uninit(&s->vkctx); ff_vk_uninit(&s->vkctx);
s->initialized = 0; s->initialized = 0;