40 VkImageUsageFlagBits usage_req;
45 vk_frames = frames_ctx->
hwctx;
46 vk_dev = device_ctx->
hwctx;
58 if (vk_frames->
tiling == VK_IMAGE_TILING_LINEAR)
71 usage_req = VK_IMAGE_USAGE_SAMPLED_BIT |
72 VK_IMAGE_USAGE_STORAGE_BIT;
76 if (vk_frames->
format[1] == VK_FORMAT_UNDEFINED &&
79 VkFormatProperties3 fprops = {
80 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3,
82 VkFormatProperties2 prop = {
83 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
86 vk->GetPhysicalDeviceFormatProperties2(vk_dev->
phys_dev,
89 if (fprops.optimalTilingFeatures & VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR)
90 usage_req |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
93 if ((vk_frames->
usage & usage_req) != usage_req)
97 for (
int i = 0; sub[
i] != VK_FORMAT_UNDEFINED;
i++) {
98 VkFormatProperties2 prop = {
99 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
101 vk->GetPhysicalDeviceFormatProperties2(vk_dev->
phys_dev, sub[
i],
103 no_storage |= !(prop.formatProperties.optimalTilingFeatures &
104 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
124 "Vulkan filtering requires a device context!\n");
136 vk_frames = frames_ctx->
hwctx;
137 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
138 vk_frames->
usage = VK_IMAGE_USAGE_SAMPLED_BIT |
139 VK_IMAGE_USAGE_STORAGE_BIT |
140 VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
149 vk_dev = device_ctx->
hwctx;
163 s->frames_ref = frames_ref;
164 s->frames = frames_ctx;
166 s->device = device_ctx;
167 s->hwctx = device_ctx->
hwctx;
185 "hardware frames context on the input.\n");
218 s->output_width,
s->output_height,
227 outlink->
w =
s->output_width;
228 outlink->
h =
s->output_height;
244 VkSampler sampler,
void *push_src,
size_t push_size)
250 VkImageMemoryBarrier2 img_bar[37];
258 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
259 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
262 VK_IMAGE_LAYOUT_GENERAL,
266 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
267 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
270 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
278 0, push_size, push_src);
282 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
283 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
284 VK_ACCESS_SHADER_WRITE_BIT,
285 VK_IMAGE_LAYOUT_GENERAL,
286 VK_QUEUE_FAMILY_IGNORED);
289 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
290 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
291 VK_ACCESS_SHADER_READ_BIT,
292 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
293 VK_QUEUE_FAMILY_IGNORED);
295 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
296 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
297 .pImageMemoryBarriers = img_bar,
298 .imageMemoryBarrierCount = nb_img_bar,
301 vk->CmdDispatch(exec->
buf,
315 VkSampler sampler,
void *push_src,
size_t push_size)
322 VkImageMemoryBarrier2 img_bar[37];
330 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
331 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
333 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
334 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
336 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
337 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
344 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
345 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
346 VK_ACCESS_SHADER_READ_BIT,
347 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
348 VK_QUEUE_FAMILY_IGNORED);
350 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
351 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
352 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
353 VK_IMAGE_LAYOUT_GENERAL,
354 VK_QUEUE_FAMILY_IGNORED);
356 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
357 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
358 VK_ACCESS_SHADER_WRITE_BIT,
359 VK_IMAGE_LAYOUT_GENERAL,
360 VK_QUEUE_FAMILY_IGNORED);
362 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
363 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
364 .pImageMemoryBarriers = img_bar,
365 .imageMemoryBarrierCount = nb_img_bar,
368 for (
int i = 0;
i < 2;
i++) {
372 VkImageView *src_views = !
i ? in_views : tmp_views;
373 VkImageView *dst_views = !
i ? tmp_views : out_views;
376 !
i ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
377 VK_IMAGE_LAYOUT_GENERAL,
380 VK_IMAGE_LAYOUT_GENERAL,
387 0, push_size, push_src);
389 vk->CmdDispatch(exec->
buf,
404 VkSampler sampler,
void *push_src,
size_t push_size)
410 VkImageMemoryBarrier2 img_bar[128];
419 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
420 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
422 for (
int i = 0;
i < nb_in;
i++) {
424 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
425 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
431 VK_IMAGE_LAYOUT_GENERAL,
433 for (
int i = 0;
i < nb_in;
i++)
435 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
442 0, push_size, push_src);
446 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
447 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
448 VK_ACCESS_SHADER_WRITE_BIT,
449 VK_IMAGE_LAYOUT_GENERAL,
450 VK_QUEUE_FAMILY_IGNORED);
451 for (
int i = 0;
i < nb_in;
i++)
453 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
454 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
455 VK_ACCESS_SHADER_READ_BIT,
456 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
457 VK_QUEUE_FAMILY_IGNORED);
459 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
460 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
461 .pImageMemoryBarriers = img_bar,
462 .imageMemoryBarrierCount = nb_img_bar,
465 vk->CmdDispatch(exec->
buf,