174 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
175 GLSLC(1, u8buf slice_state; );
176 GLSLC(1, u8buf scratch_data; );
177 GLSLC(1, u8buf out_data; );
178 GLSLC(1, uint64_t slice_size_max; );
180 GLSLC(1, ivec2 sar; );
181 GLSLC(1, uvec2 chroma_shift; );
183 GLSLC(1, uint plane_state_size; );
184 GLSLC(1, uint context_count; );
185 GLSLC(1, uint32_t crcref; );
187 GLSLC(1, uint8_t bits_per_raw_sample; );
188 GLSLC(1, uint8_t context_model; );
190 GLSLC(1, uint8_t micro_version; );
191 GLSLC(1, uint8_t force_pcm; );
192 GLSLC(1, uint8_t key_frame; );
194 GLSLC(1, uint8_t codec_planes; );
195 GLSLC(1, uint8_t transparency; );
196 GLSLC(1, uint8_t colorspace; );
197 GLSLC(1, uint8_t pic_mode; );
198 GLSLC(1, uint8_t ec; );
199 GLSLC(1, uint8_t ppi; );
200 GLSLC(1, uint8_t chunks; );
201 GLSLC(1, uint8_t padding[2]; );
204 VK_SHADER_STAGE_COMPUTE_BIT);
208 AVFrame *enc_in, VkImageView *enc_in_views,
209 AVFrame **intermediate_frame, VkImageView *intermediate_views,
210 VkImageMemoryBarrier2 *img_bar,
int *nb_img_bar,
211 VkBufferMemoryBarrier2 *buf_bar,
int *nb_buf_bar,
212 FFVkBuffer *slice_data_buf, uint32_t slice_data_size)
223 if (!(*intermediate_frame))
227 *intermediate_frame, 0));
230 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
231 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
240 0, slice_data_size*
f->slice_count,
241 VK_FORMAT_UNDEFINED);
243 enc_in, enc_in_views,
245 VK_IMAGE_LAYOUT_GENERAL,
248 *intermediate_frame, intermediate_views,
250 VK_IMAGE_LAYOUT_GENERAL,
254 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
255 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
256 VK_ACCESS_SHADER_WRITE_BIT,
257 VK_IMAGE_LAYOUT_GENERAL,
258 VK_QUEUE_FAMILY_IGNORED);
261 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
262 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
263 .pImageMemoryBarriers = img_bar,
264 .imageMemoryBarrierCount = *nb_img_bar,
265 .pBufferMemoryBarriers = buf_bar,
266 .bufferMemoryBarrierCount = *nb_buf_bar,
270 slice_data_buf->
stage = buf_bar[0].dstStageMask;
271 slice_data_buf->
access = buf_bar[0].dstAccessMask;
278 .offset = 1 <<
f->bits_per_raw_sample,
279 .bits =
f->bits_per_raw_sample,
282 .transparency =
f->transparency,
285 VK_SHADER_STAGE_COMPUTE_BIT,
292 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
293 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
294 VK_ACCESS_SHADER_READ_BIT,
295 VK_IMAGE_LAYOUT_GENERAL,
296 VK_QUEUE_FAMILY_IGNORED);
317 size_t tmp_data_size;
324 uint32_t plane_state_size;
325 uint32_t slice_state_size;
326 uint32_t slice_data_size;
335 int has_inter = avctx->
gop_size > 1;
336 uint32_t context_count =
f->context_count[
f->context_model];
342 VkImageView *enc_in_views = in_views;
344 VkImageMemoryBarrier2 img_bar[37];
346 VkBufferMemoryBarrier2 buf_bar[8];
353 f->cur_enc_frame = pict;
362 f->slice_count =
f->max_slice_count;
368 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
369 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
371 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
377 plane_state_size = 8;
381 plane_state_size *= context_count;
382 slice_state_size = plane_state_size*
f->plane_count;
384 slice_data_size = 256;
385 slice_state_size += slice_data_size;
386 slice_state_size =
FFALIGN(slice_state_size, 8);
390 if (!slice_data_ref) {
393 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
394 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
395 NULL, slice_state_size*
f->slice_count,
396 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
408 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
409 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
410 NULL, 2*
f->slice_count*
sizeof(uint64_t),
411 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
412 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
423 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
424 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
425 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
427 maxsize < fv->max_heap_size ?
428 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
434 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
435 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
440 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
441 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
442 VK_ACCESS_SHADER_READ_BIT,
443 VK_IMAGE_LAYOUT_GENERAL,
444 VK_QUEUE_FAMILY_IGNORED);
450 0, slice_data_size*
f->slice_count,
451 VK_FORMAT_UNDEFINED);
453 enc_in, enc_in_views,
455 VK_IMAGE_LAYOUT_GENERAL,
460 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
461 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
462 .srcStageMask = slice_data_buf->
stage,
463 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
464 .srcAccessMask = slice_data_buf->
access,
465 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
466 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
467 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
468 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
469 .buffer = slice_data_buf->
buf,
470 .size = VK_WHOLE_SIZE,
475 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
476 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
477 .pImageMemoryBarriers = img_bar,
478 .imageMemoryBarrierCount = nb_img_bar,
479 .pBufferMemoryBarriers = buf_bar,
480 .bufferMemoryBarrierCount = nb_buf_bar,
484 slice_data_buf->
stage = buf_bar[0].dstStageMask;
485 slice_data_buf->
access = buf_bar[0].dstAccessMask;
493 .scratch_data = tmp_data_buf->
address,
494 .out_data = out_data_buf->
address,
495 .slice_size_max = out_data_buf->
size /
f->slice_count,
496 .bits_per_raw_sample =
f->bits_per_raw_sample,
499 .chroma_shift[0] =
f->chroma_h_shift,
500 .chroma_shift[1] =
f->chroma_v_shift,
501 .plane_state_size = plane_state_size,
502 .context_count = context_count,
505 .version =
f->version,
506 .micro_version =
f->micro_version,
508 .key_frame =
f->key_frame,
510 .codec_planes =
f->plane_count,
511 .transparency =
f->transparency,
512 .colorspace =
f->colorspace,
520 VK_SHADER_STAGE_COMPUTE_BIT,
525 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
526 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
527 .srcStageMask = slice_data_buf->
stage,
528 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
529 .srcAccessMask = slice_data_buf->
access,
530 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
531 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
532 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
533 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
534 .buffer = slice_data_buf->
buf,
535 .size = slice_data_size*
f->slice_count,
539 if (
f->key_frame ||
f->version > 3) {
545 0, slice_data_size*
f->slice_count,
546 VK_FORMAT_UNDEFINED);
552 .plane_state_size = plane_state_size,
553 .context_count = context_count,
554 .codec_planes =
f->plane_count,
555 .key_frame =
f->key_frame,
558 VK_SHADER_STAGE_COMPUTE_BIT,
559 0,
sizeof(pd_reset), &pd_reset);
562 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
563 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
564 .pBufferMemoryBarriers = buf_bar,
565 .bufferMemoryBarrierCount = nb_buf_bar,
567 slice_data_buf->
stage = buf_bar[0].dstStageMask;
568 slice_data_buf->
access = buf_bar[0].dstAccessMask;
578 enc_in, enc_in_views,
579 &intermediate_frame, intermediate_views,
580 img_bar, &nb_img_bar, buf_bar, &nb_buf_bar,
581 slice_data_buf, slice_data_size));
584 enc_in = intermediate_frame;
585 enc_in_views = intermediate_views;
589 if (
f->key_frame ||
f->version > 3) {
591 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
592 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
593 .srcStageMask = slice_data_buf->
stage,
594 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
595 .srcAccessMask = slice_data_buf->
access,
596 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
597 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
598 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
599 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
600 .buffer = slice_data_buf->
buf,
601 .size = slice_data_buf->
size - slice_data_size*
f->slice_count,
602 .offset = slice_data_size*
f->slice_count,
607 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
608 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
609 .pImageMemoryBarriers = img_bar,
610 .imageMemoryBarrierCount = nb_img_bar,
611 .pBufferMemoryBarriers = buf_bar,
612 .bufferMemoryBarrierCount = nb_buf_bar,
616 slice_data_buf->
stage = buf_bar[0].dstStageMask;
617 slice_data_buf->
access = buf_bar[0].dstAccessMask;
625 0, slice_data_size*
f->slice_count,
626 VK_FORMAT_UNDEFINED);
628 enc_in, enc_in_views,
630 VK_IMAGE_LAYOUT_GENERAL,
635 0, results_data_buf->
size,
636 VK_FORMAT_UNDEFINED);
640 VK_SHADER_STAGE_COMPUTE_BIT,
664 VkBufferCopy *buf_regions,
int nb_regions,
676 VkBufferMemoryBarrier2 buf_bar[8];
689 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
690 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
691 .srcStageMask = out_data_buf->
stage,
692 .dstStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
693 .srcAccessMask = out_data_buf->
access,
694 .dstAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT,
695 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
696 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
697 .buffer = out_data_buf->
buf,
698 .size = VK_WHOLE_SIZE,
701 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
702 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
703 .pBufferMemoryBarriers = buf_bar,
704 .bufferMemoryBarrierCount = nb_buf_bar,
706 out_data_buf->
stage = buf_bar[0].dstStageMask;
707 out_data_buf->
access = buf_bar[0].dstAccessMask;
710 vk->CmdCopyBuffer(exec->
buf,
711 out_data_buf->
buf, pkt_data_buf->buf,
712 nb_regions, buf_regions);
723 if (!(pkt_data_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
724 VkMappedMemoryRange invalidate_data = {
725 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
726 .memory = pkt_data_buf->mem,
728 .size = VK_WHOLE_SIZE,
731 1, &invalidate_data);
758 if (!(results_data_buf->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
759 VkMappedMemoryRange invalidate_data = {
760 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
761 .memory = results_data_buf->
mem,
763 .size = VK_WHOLE_SIZE,
766 1, &invalidate_data);
771 for (
int i = 0;
i <
f->slice_count;
i++) {
772 sc = &((uint64_t *)results_data_buf->
mapped_mem)[
i*2];
774 "src offset = %"PRIu64
"\n",
790 VK_BUFFER_USAGE_TRANSFER_DST_BIT,
792 VK_MEMORY_PROPERTY_HOST_CACHED_BIT |
793 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
888 vk_frames = frames_ctx->
hwctx;
889 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
890 vk_frames->
usage = VK_IMAGE_USAGE_STORAGE_BIT;
891 vk_frames->
img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
966 GLSLF(0, #define
TYPE int%i_t ,smp_bits);
967 GLSLF(0, #define VTYPE2
i%ivec2 ,smp_bits);
968 GLSLF(0, #define VTYPE3
i%ivec3 ,smp_bits);
987 void *spv_opaque =
NULL;
990 VK_SHADER_STAGE_COMPUTE_BIT,
991 (
const char *[]) {
"GL_EXT_buffer_reference",
992 "GL_EXT_buffer_reference2" }, 2,
1002 .
name =
"rangecoder_static_buf",
1003 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1004 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1005 .mem_layout =
"scalar",
1006 .buf_content =
"uint8_t zero_one_state[512];",
1009 .name =
"quant_buf",
1010 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1011 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1012 .mem_layout =
"scalar",
1013 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1014 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1023 .
name =
"slice_data_buf",
1024 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1025 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1026 .buf_content =
"SliceContext slice_ctx[1024];",
1030 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1035 .mem_quali =
"readonly",
1036 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1067 void *spv_opaque =
NULL;
1068 int wg_dim =
FFMIN(fv->
s.
props.properties.limits.maxComputeWorkGroupSize[0], 1024);
1071 VK_SHADER_STAGE_COMPUTE_BIT,
1072 (
const char *[]) {
"GL_EXT_buffer_reference",
1073 "GL_EXT_buffer_reference2" }, 2,
1083 .
name =
"rangecoder_static_buf",
1084 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1085 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1086 .mem_layout =
"scalar",
1087 .buf_content =
"uint8_t zero_one_state[512];",
1090 .name =
"quant_buf",
1091 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1092 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1093 .mem_layout =
"scalar",
1094 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1095 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1104 .
name =
"slice_data_buf",
1105 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1106 .mem_quali =
"readonly",
1107 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1108 .buf_content =
"SliceContext slice_ctx[1024];",
1113 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
1114 GLSLC(1, u8buf slice_state; );
1115 GLSLC(1, uint plane_state_size; );
1116 GLSLC(1, uint context_count; );
1117 GLSLC(1, uint8_t codec_planes; );
1118 GLSLC(1, uint8_t key_frame; );
1119 GLSLC(1, uint8_t padding[3]; );
1122 VK_SHADER_STAGE_COMPUTE_BIT);
1148 void *spv_opaque =
NULL;
1149 int wg_count = sqrt(fv->
s.
props.properties.limits.maxComputeWorkGroupInvocations);
1154 "pixel format for RCT buffer!\n");
1161 VK_SHADER_STAGE_COMPUTE_BIT,
1162 (
const char *[]) {
"GL_EXT_buffer_reference",
1163 "GL_EXT_buffer_reference2" }, 2,
1164 wg_count, wg_count, 1,
1173 .
name =
"rangecoder_static_buf",
1174 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1175 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1176 .mem_layout =
"scalar",
1177 .buf_content =
"uint8_t zero_one_state[512];",
1180 .name =
"quant_buf",
1181 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1182 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1183 .mem_layout =
"scalar",
1184 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1185 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1194 .
name =
"slice_data_buf",
1195 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1196 .mem_quali =
"readonly",
1197 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1198 .buf_content =
"SliceContext slice_ctx[1024];",
1202 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1207 .mem_quali =
"readonly",
1208 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1212 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1217 .mem_quali =
"writeonly",
1218 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1223 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
1226 GLSLC(1, uint8_t planar_rgb; );
1227 GLSLC(1, uint8_t transparency; );
1228 GLSLC(1, uint8_t padding[1]; );
1231 VK_SHADER_STAGE_COMPUTE_BIT);
1262 void *spv_opaque =
NULL;
1265 VK_SHADER_STAGE_COMPUTE_BIT,
1266 (
const char *[]) {
"GL_EXT_buffer_reference",
1267 "GL_EXT_buffer_reference2" }, 2,
1277 .
name =
"rangecoder_static_buf",
1278 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1279 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1280 .mem_layout =
"scalar",
1281 .buf_content =
"uint8_t zero_one_state[512];",
1284 .name =
"quant_buf",
1285 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1286 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1287 .mem_layout =
"scalar",
1288 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1289 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1292 .name =
"crc_ieee_buf",
1293 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1294 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1295 .mem_layout =
"scalar",
1296 .buf_content =
"uint32_t crc_ieee[256];",
1306 .
name =
"slice_data_buf",
1307 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1308 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1309 .buf_content =
"SliceContext slice_ctx[1024];",
1313 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1318 .mem_quali =
"readonly",
1319 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1322 .name =
"results_data_buf",
1323 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1324 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1325 .mem_quali =
"writeonly",
1326 .buf_content =
"uint64_t slice_results[2048];",
1364 uint8_t *buf_mapped;
1365 size_t buf_len = 512*
sizeof(uint8_t);
1370 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
1371 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
1372 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1373 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1377 for (
int i = 1;
i < 256;
i++) {
1386 &fv->
setup, 0, 0, 0,
1389 VK_FORMAT_UNDEFINED));
1394 VK_FORMAT_UNDEFINED));
1405 int16_t *buf_mapped;
1413 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
1414 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
1415 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1416 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1427 VK_FORMAT_UNDEFINED));
1438 uint32_t *buf_mapped;
1439 size_t buf_len = 256*
sizeof(
int32_t);
1444 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
1445 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
1446 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1447 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1457 VK_FORMAT_UNDEFINED));
1466 size_t maxsize, max_heap_size, max_host_size;
1489 if (
f->bits_per_raw_sample > (
f->version > 3 ? 16 : 8)) {
1492 "forcing range coder\n");
1497 if (
f->version < 4 && avctx->
gop_size > 1) {
1533 f->num_h_slices = w_sl;
1534 f->num_v_slices = h_sl;
1542 if (
f->num_h_slices <= 0 &&
f->num_v_slices <= 0) {
1543 f->num_h_slices = 32;
1544 f->num_v_slices = 32;
1545 }
else if (
f->num_h_slices &&
f->num_v_slices <= 0) {
1546 f->num_v_slices = 1024 /
f->num_h_slices;
1547 }
else if (
f->num_v_slices &&
f->num_h_slices <= 0) {
1548 f->num_h_slices = 1024 /
f->num_v_slices;
1551 f->num_h_slices =
FFMIN(
f->num_h_slices, avctx->
width);
1554 if (
f->num_h_slices *
f->num_v_slices > 1024) {
1556 "by the standard is 1024\n",
1557 f->num_h_slices *
f->num_v_slices);
1565 if (
f->version < 4) {
1566 if (((
f->chroma_h_shift > 0) && (avctx->
width % (64 <<
f->chroma_h_shift))) ||
1567 ((
f->chroma_v_shift > 0) && (avctx->
height % (64 <<
f->chroma_v_shift)))) {
1569 "dimensions is only supported in version 4 (-level 4)\n");
1575 if (
f->version < 4) {
1598 for (
int i = 0;
i < fv->
s.
mprops.memoryHeapCount;
i++) {
1599 if (fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1602 if (!(fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT))
1603 max_host_size =
FFMAX(max_host_size,
1609 if (maxsize > fv->
s.
props_11.maxMemoryAllocationSize) {
1611 "than maximum device allocation (%zu), clipping\n",
1612 maxsize, fv->
s.
props_11.maxMemoryAllocationSize);
1613 maxsize = fv->
s.
props_11.maxMemoryAllocationSize;
1616 if (max_heap_size < maxsize) {
1618 "using host memory (slower)\n",
1622 max_heap_size = max_host_size - (max_host_size >> 1);
1625 max_heap_size = max_heap_size - (max_heap_size >> 3);
1633 av_log(avctx,
AV_LOG_INFO,
"Async buffers: %zuMiB per context, %zuMiB total, depth: %i\n",
1634 maxsize / (1024*1024),
1656 spv = ff_vk_spirv_init();
1669 if (!fv->
is_rgb &&
f->bits_per_raw_sample > 8)
1732 f->max_slice_count =
f->num_h_slices *
f->num_v_slices;
1784 #define OFFSET(x) offsetof(VulkanEncodeFFv1Context, x)
1785 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1788 { .i64 = -1 }, -1, 1,
VE },
1790 { .i64 = 0 }, 0, 1,
VE },
1798 { .i64 = -1 }, -1, 2,
VE , .unit =
"qtable"},
1802 { .i64 =
QTABLE_8BIT }, INT_MIN, INT_MAX,
VE, .unit =
"qtable" },
1807 { .i64 = -1 }, -1, 1024,
VE },
1809 { .i64 = -1 }, -1, 1024,
VE },
1812 { .i64 = 0 }, 0, 1,
VE },
1815 { .i64 = 0 }, 0, INT_MAX,
VE },
1838 .
p.
name =
"ffv1_vulkan",
1859 .p.wrapper_name =
"vulkan",