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;
75 if (vk_frames->
format[1] == VK_FORMAT_UNDEFINED &&
78 VkFormatProperties3 fprops = {
79 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3,
81 VkFormatProperties2 prop = {
82 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
85 vk->GetPhysicalDeviceFormatProperties2(vk_dev->
phys_dev,
88 if (fprops.optimalTilingFeatures & VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR)
89 usage_req |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
92 if ((vk_frames->
usage & usage_req) != usage_req)
96 for (
int i = 0; sub[
i] != VK_FORMAT_UNDEFINED;
i++) {
97 VkFormatProperties2 prop = {
98 .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
100 vk->GetPhysicalDeviceFormatProperties2(vk_dev->
phys_dev, sub[
i],
102 no_storage |= !(prop.formatProperties.optimalTilingFeatures &
103 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
121 "Vulkan filtering requires a device context!\n");
140 vk_dev = device_ctx->
hwctx;
152 "the %s extension is supported!\n",
153 VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
164 s->frames_ref = frames_ref;
165 s->frames = frames_ctx;
167 s->device = device_ctx;
168 s->hwctx = device_ctx->
hwctx;
186 "hardware frames context on the input.\n");
219 s->output_width,
s->output_height,
228 outlink->
w =
s->output_width;
229 outlink->
h =
s->output_height;
245 VkSampler sampler,
void *push_src,
size_t push_size)
251 VkImageMemoryBarrier2 img_bar[37];
262 0, push_size, push_src);
266 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
267 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
270 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
273 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
274 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
275 VK_ACCESS_SHADER_READ_BIT,
276 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
277 VK_QUEUE_FAMILY_IGNORED);
281 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
282 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
285 VK_IMAGE_LAYOUT_GENERAL,
288 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
289 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
290 VK_ACCESS_SHADER_WRITE_BIT,
291 VK_IMAGE_LAYOUT_GENERAL,
292 VK_QUEUE_FAMILY_IGNORED);
294 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
295 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
296 .pImageMemoryBarriers = img_bar,
297 .imageMemoryBarrierCount = nb_img_bar,
300 vk->CmdDispatch(exec->
buf,
314 VkSampler sampler,
void *push_src,
size_t push_size)
321 VkImageMemoryBarrier2 img_bar[37];
329 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
330 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
332 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
333 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
335 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
336 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
343 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
344 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
345 VK_ACCESS_SHADER_READ_BIT,
346 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
347 VK_QUEUE_FAMILY_IGNORED);
349 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
350 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
351 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
352 VK_IMAGE_LAYOUT_GENERAL,
353 VK_QUEUE_FAMILY_IGNORED);
355 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
356 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
357 VK_ACCESS_SHADER_WRITE_BIT,
358 VK_IMAGE_LAYOUT_GENERAL,
359 VK_QUEUE_FAMILY_IGNORED);
361 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
362 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
363 .pImageMemoryBarriers = img_bar,
364 .imageMemoryBarrierCount = nb_img_bar,
367 for (
int i = 0;
i < 2;
i++) {
371 VkImageView *src_views = !
i ? in_views : tmp_views;
372 VkImageView *dst_views = !
i ? tmp_views : out_views;
378 0, push_size, push_src);
381 !
i ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
382 VK_IMAGE_LAYOUT_GENERAL,
385 VK_IMAGE_LAYOUT_GENERAL,
388 vk->CmdDispatch(exec->
buf,
403 VkSampler sampler,
void *push_src,
size_t push_size)
409 VkImageMemoryBarrier2 img_bar[128];
417 for (
int i = 0;
i < nb_in;
i++) {
419 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
420 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
424 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
425 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
426 VK_ACCESS_SHADER_READ_BIT,
427 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
428 VK_QUEUE_FAMILY_IGNORED);
433 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
434 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
437 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
438 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
439 VK_ACCESS_SHADER_WRITE_BIT,
440 VK_IMAGE_LAYOUT_GENERAL,
441 VK_QUEUE_FAMILY_IGNORED);
443 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
444 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
445 .pImageMemoryBarriers = img_bar,
446 .imageMemoryBarrierCount = nb_img_bar,
453 0, push_size, push_src);
455 for (
int i = 0;
i < nb_in;
i++)
457 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
461 VK_IMAGE_LAYOUT_GENERAL,
464 vk->CmdDispatch(exec->
buf,