41 #define RGB_LINECACHE 4
156 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
157 GLSLC(1, u8buf slice_state; );
158 GLSLC(1, u8buf scratch_data; );
159 GLSLC(1, u8buf out_data; );
161 GLSLC(1, ivec4 fmt_lut; );
162 GLSLC(1, ivec2 sar; );
163 GLSLC(1, uvec2 chroma_shift; );
165 GLSLC(1, uint plane_state_size; );
166 GLSLC(1, uint context_count; );
167 GLSLC(1, uint32_t crcref; );
168 GLSLC(1, uint32_t slice_size_max; );
169 GLSLC(1,
int rct_offset; );
171 GLSLC(1, uint8_t extend_lookup[8]; );
172 GLSLC(1, uint8_t bits_per_raw_sample; );
173 GLSLC(1, uint8_t context_model; );
175 GLSLC(1, uint8_t micro_version; );
176 GLSLC(1, uint8_t force_pcm; );
177 GLSLC(1, uint8_t key_frame; );
178 GLSLC(1, uint8_t components; );
180 GLSLC(1, uint8_t codec_planes; );
181 GLSLC(1, uint8_t planar_rgb; );
182 GLSLC(1, uint8_t transparency; );
183 GLSLC(1, uint8_t colorspace; );
184 GLSLC(1, uint8_t pic_mode; );
185 GLSLC(1, uint8_t ec; );
186 GLSLC(1, uint8_t ppi; );
187 GLSLC(1, uint8_t chunks; );
188 GLSLC(1, uint8_t rct_search; );
189 GLSLC(1, uint8_t padding[3]; );
192 VK_SHADER_STAGE_COMPUTE_BIT);
208 AVFrame *enc_in, VkImageView *enc_in_views,
209 FFVkBuffer *slice_data_buf, uint32_t slice_data_size)
221 0, slice_data_size*
f->slice_count,
222 VK_FORMAT_UNDEFINED);
224 enc_in, enc_in_views,
226 VK_IMAGE_LAYOUT_GENERAL,
232 .rct_offset = 1 <<
f->bits_per_raw_sample,
235 .transparency =
f->transparency,
236 .key_frame =
f->key_frame,
238 .version =
f->version,
239 .micro_version =
f->micro_version,
245 memcpy(pd.fmt_lut, (
int [4]) { 2, 1, 0, 3 }, 4*
sizeof(
int));
250 VK_SHADER_STAGE_COMPUTE_BIT,
273 uint32_t plane_state_size;
274 uint32_t slice_state_size;
275 uint32_t slice_data_size;
284 int has_inter = avctx->
gop_size > 1;
285 uint32_t context_count =
f->context_count[
f->context_model];
294 VkImageMemoryBarrier2 img_bar[37];
296 VkBufferMemoryBarrier2 buf_bar[8];
303 f->cur_enc_frame = pict;
312 f->slice_count =
f->max_slice_count;
316 plane_state_size = 8;
320 plane_state_size *= context_count;
321 slice_state_size = plane_state_size*
f->plane_count;
323 slice_data_size = 256;
324 slice_state_size += slice_data_size;
325 slice_state_size =
FFALIGN(slice_state_size, 8);
329 if (!slice_data_ref) {
332 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
333 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
334 NULL, slice_state_size*
f->slice_count,
335 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
347 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
348 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
349 NULL, 2*
f->slice_count*
sizeof(uint64_t),
350 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
351 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
362 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
363 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
364 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
366 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
367 (maxsize < fv->max_heap_size ?
368 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0) |
370 VK_MEMORY_PROPERTY_HOST_CACHED_BIT : 0x0)));
376 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
377 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
382 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
383 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
384 VK_ACCESS_SHADER_READ_BIT,
385 VK_IMAGE_LAYOUT_GENERAL,
386 VK_QUEUE_FAMILY_IGNORED);
398 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
399 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
409 0, slice_data_size*
f->slice_count,
410 VK_FORMAT_UNDEFINED);
414 VK_IMAGE_LAYOUT_GENERAL,
419 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
420 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
421 .srcStageMask = slice_data_buf->
stage,
422 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
423 .srcAccessMask = slice_data_buf->
access,
424 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
425 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
426 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
427 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
428 .buffer = slice_data_buf->
buf,
429 .size = VK_WHOLE_SIZE,
437 slice_data_buf, slice_data_size));
439 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
440 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
441 .srcStageMask = slice_data_buf->
stage,
442 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
443 .srcAccessMask = slice_data_buf->
access,
444 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
445 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
446 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
447 .buffer = slice_data_buf->
buf,
448 .size = slice_data_size*
f->slice_count,
453 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
454 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
455 .pImageMemoryBarriers = img_bar,
456 .imageMemoryBarrierCount = nb_img_bar,
457 .pBufferMemoryBarriers = buf_bar,
458 .bufferMemoryBarrierCount = nb_buf_bar,
462 slice_data_buf->
stage = buf_bar[0].dstStageMask;
463 slice_data_buf->
access = buf_bar[0].dstAccessMask;
471 .out_data = out_data_buf->
address,
472 .bits_per_raw_sample =
f->bits_per_raw_sample,
475 .chroma_shift[0] =
f->chroma_h_shift,
476 .chroma_shift[1] =
f->chroma_v_shift,
477 .plane_state_size = plane_state_size,
478 .context_count = context_count,
480 .rct_offset = 1 <<
f->bits_per_raw_sample,
481 .slice_size_max = out_data_buf->
size /
f->slice_count,
483 .version =
f->version,
484 .micro_version =
f->micro_version,
486 .key_frame =
f->key_frame,
489 .codec_planes =
f->plane_count,
492 .transparency =
f->transparency,
493 .colorspace =
f->colorspace,
506 memcpy(pd.
fmt_lut, (
int [4]) { 2, 1, 0, 3 }, 4*
sizeof(
int));
510 for (
int i = 0;
i <
f->quant_table_count;
i++)
512 (
f->quant_tables[
i][4][127] != 0);
514 VK_SHADER_STAGE_COMPUTE_BIT,
521 vk->CmdClearColorImage(exec->
buf, vkf->
img[0], VK_IMAGE_LAYOUT_GENERAL,
522 &((VkClearColorValue) { 0 }),
523 1, &((VkImageSubresourceRange) {
524 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
531 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
532 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
533 .srcStageMask = slice_data_buf->
stage,
534 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
535 .srcAccessMask = slice_data_buf->
access,
536 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
537 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
538 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
539 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
540 .buffer = slice_data_buf->
buf,
541 .size = slice_data_size*
f->slice_count,
545 if (
f->key_frame ||
f->version > 3) {
551 0, slice_data_size*
f->slice_count,
552 VK_FORMAT_UNDEFINED);
558 .plane_state_size = plane_state_size,
559 .codec_planes =
f->plane_count,
560 .key_frame =
f->key_frame,
562 for (
int i = 0;
i <
f->quant_table_count;
i++)
566 VK_SHADER_STAGE_COMPUTE_BIT,
567 0,
sizeof(pd_reset), &pd_reset);
570 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
571 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
572 .pBufferMemoryBarriers = buf_bar,
573 .bufferMemoryBarrierCount = nb_buf_bar,
575 slice_data_buf->
stage = buf_bar[0].dstStageMask;
576 slice_data_buf->
access = buf_bar[0].dstAccessMask;
584 if (
f->key_frame ||
f->version > 3) {
586 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
587 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
588 .srcStageMask = slice_data_buf->
stage,
589 .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
590 .srcAccessMask = slice_data_buf->
access,
591 .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
592 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
593 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
594 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
595 .buffer = slice_data_buf->
buf,
596 .size = slice_data_buf->
size - slice_data_size*
f->slice_count,
597 .offset = slice_data_size*
f->slice_count,
603 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
604 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
605 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
606 VK_IMAGE_LAYOUT_GENERAL,
607 VK_QUEUE_FAMILY_IGNORED);
611 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
612 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
613 .pImageMemoryBarriers = img_bar,
614 .imageMemoryBarrierCount = nb_img_bar,
615 .pBufferMemoryBarriers = buf_bar,
616 .bufferMemoryBarrierCount = nb_buf_bar,
620 slice_data_buf->
stage = buf_bar[0].dstStageMask;
621 slice_data_buf->
access = buf_bar[0].dstAccessMask;
629 0, slice_data_size*
f->slice_count,
630 VK_FORMAT_UNDEFINED);
634 VK_IMAGE_LAYOUT_GENERAL,
639 0, results_data_buf->
size,
640 VK_FORMAT_UNDEFINED);
645 VK_IMAGE_LAYOUT_GENERAL,
650 VK_SHADER_STAGE_COMPUTE_BIT,
674 VkBufferCopy *buf_regions,
int nb_regions,
688 VkBufferMemoryBarrier2 buf_bar[8];
692 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
709 buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
710 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
711 .srcStageMask = out_data_buf->
stage,
712 .dstStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT,
713 .srcAccessMask = out_data_buf->
access,
714 .dstAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT,
715 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
716 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
717 .buffer = out_data_buf->
buf,
718 .size = VK_WHOLE_SIZE,
721 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
722 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
723 .pBufferMemoryBarriers = buf_bar,
724 .bufferMemoryBarrierCount = nb_buf_bar,
726 out_data_buf->
stage = buf_bar[0].dstStageMask;
727 out_data_buf->
access = buf_bar[0].dstAccessMask;
730 for (
int i = 0;
i < nb_regions;
i++)
731 buf_regions[
i].dstOffset += mapped_buf->virtual_offset;
733 vk->CmdCopyBuffer(exec->
buf,
734 out_data_buf->
buf, mapped_buf->buf,
735 nb_regions, buf_regions);
765 if (!(results_data_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
766 VkMappedMemoryRange invalidate_data = {
767 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
768 .memory = results_data_buf->mem,
770 .size = VK_WHOLE_SIZE,
773 1, &invalidate_data);
778 for (
int i = 0;
i <
f->slice_count;
i++) {
779 sc = &((uint64_t *)results_data_buf->mapped_mem)[
i*2];
781 "src offset = %"PRIu64
"\n",
818 if (!(out_data_buf->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
819 VkMappedMemoryRange invalidate_data = {
820 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
821 .memory = out_data_buf->
mem,
823 .size = VK_WHOLE_SIZE,
826 1, &invalidate_data);
830 for (
int i = 0;
i <
f->slice_count;
i++) {
832 memcpy(
pkt->
data + region->dstOffset,
914 vk_frames = frames_ctx->
hwctx;
915 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
916 vk_frames->
usage = VK_IMAGE_USAGE_STORAGE_BIT |
917 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
918 vk_frames->
img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
997 GLSLF(0, #define
TYPE int%i_t ,smp_bits);
998 GLSLF(0, #define VTYPE2
i%ivec2 ,smp_bits);
999 GLSLF(0, #define VTYPE3
i%ivec3 ,smp_bits);
1018 void *spv_opaque =
NULL;
1021 VK_SHADER_STAGE_COMPUTE_BIT,
1022 (
const char *[]) {
"GL_EXT_buffer_reference",
1023 "GL_EXT_buffer_reference2",
1024 "GL_EXT_null_initializer" }, 3,
1031 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
1032 GLSLC(1, ivec4 fmt_lut; );
1033 GLSLC(1,
int rct_offset; );
1034 GLSLC(1, uint8_t planar_rgb; );
1035 GLSLC(1, uint8_t transparency; );
1036 GLSLC(1, uint8_t key_frame; );
1037 GLSLC(1, uint8_t force_pcm; );
1039 GLSLC(1, uint8_t micro_version; );
1040 GLSLC(1, uint8_t padding[3]; );
1043 VK_SHADER_STAGE_COMPUTE_BIT);
1052 .
name =
"rangecoder_static_buf",
1053 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1054 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1055 .mem_layout =
"scalar",
1056 .buf_content =
"uint8_t zero_one_state[512];",
1059 .name =
"quant_buf",
1060 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1061 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1062 .mem_layout =
"scalar",
1063 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1064 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1073 .
name =
"slice_data_buf",
1074 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1075 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1076 .buf_content =
"SliceContext slice_ctx",
1077 .buf_elems =
f->max_slice_count,
1081 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1086 .mem_quali =
"readonly",
1087 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1117 void *spv_opaque =
NULL;
1120 VK_SHADER_STAGE_COMPUTE_BIT,
1121 (
const char *[]) {
"GL_EXT_buffer_reference",
1122 "GL_EXT_buffer_reference2" }, 2,
1137 .
name =
"rangecoder_static_buf",
1138 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1139 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1140 .mem_layout =
"scalar",
1141 .buf_content =
"uint8_t zero_one_state[512];",
1144 .name =
"quant_buf",
1145 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1146 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1147 .mem_layout =
"scalar",
1148 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1149 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1158 .
name =
"slice_data_buf",
1159 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1160 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1161 .buf_content =
"SliceContext slice_ctx",
1162 .buf_elems =
f->max_slice_count,
1166 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1171 .mem_quali =
"readonly",
1172 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1202 void *spv_opaque =
NULL;
1203 int wg_dim =
FFMIN(fv->
s.
props.properties.limits.maxComputeWorkGroupSize[0], 1024);
1206 VK_SHADER_STAGE_COMPUTE_BIT,
1207 (
const char *[]) {
"GL_EXT_buffer_reference",
1208 "GL_EXT_buffer_reference2" }, 2,
1215 GLSLC(0,
layout(push_constant, scalar) uniform pushConstants { );
1217 GLSLC(1, u8buf slice_state; );
1218 GLSLC(1, uint plane_state_size; );
1219 GLSLC(1, uint8_t codec_planes; );
1220 GLSLC(1, uint8_t key_frame; );
1222 GLSLC(1, uint8_t micro_version; );
1223 GLSLC(1, uint8_t padding[1]; );
1226 VK_SHADER_STAGE_COMPUTE_BIT);
1234 .
name =
"rangecoder_static_buf",
1235 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1236 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1237 .mem_layout =
"scalar",
1238 .buf_content =
"uint8_t zero_one_state[512];",
1241 .name =
"quant_buf",
1242 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1243 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1244 .mem_layout =
"scalar",
1245 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1246 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1255 .
name =
"slice_data_buf",
1256 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1257 .mem_quali =
"readonly",
1258 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1259 .buf_content =
"SliceContext slice_ctx",
1260 .buf_elems =
f->max_slice_count,
1290 void *spv_opaque =
NULL;
1295 VK_SHADER_STAGE_COMPUTE_BIT,
1296 (
const char *[]) {
"GL_EXT_buffer_reference",
1297 "GL_EXT_buffer_reference2" }, 2,
1310 if (use_cached_reader)
1315 .
name =
"rangecoder_static_buf",
1316 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1317 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1318 .mem_layout =
"scalar",
1319 .buf_content =
"uint8_t zero_one_state[512];",
1322 .name =
"quant_buf",
1323 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1324 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1325 .mem_layout =
"scalar",
1326 .buf_content =
"int16_t quant_table[MAX_QUANT_TABLES]"
1327 "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
1330 .name =
"crc_ieee_buf",
1331 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1332 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1333 .mem_layout =
"scalar",
1334 .buf_content =
"uint32_t crc_ieee[256];",
1344 .
name =
"slice_data_buf",
1345 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1346 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1347 .buf_content =
"SliceContext slice_ctx",
1348 .buf_elems =
f->max_slice_count,
1352 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1357 .mem_quali =
"readonly",
1358 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1361 .name =
"results_data_buf",
1362 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1363 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1364 .mem_quali =
"writeonly",
1365 .buf_content =
"uint64_t slice_results[2048];",
1368 .name =
"placeholder",
1376 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1380 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1403 size_t maxsize, max_heap_size, max_host_size;
1426 if (
f->bits_per_raw_sample > (
f->version > 3 ? 16 : 8)) {
1429 "forcing range coder\n");
1434 if (
f->version < 4 && avctx->
gop_size > 1) {
1445 if (
f->version == 4 &&
f->micro_version > 4)
1446 f->micro_version = 3;
1474 f->num_h_slices = w_sl;
1475 f->num_v_slices = h_sl;
1483 if (
f->num_h_slices <= 0 &&
f->num_v_slices <= 0) {
1489 f->num_h_slices = 32;
1490 f->num_v_slices = 32;
1492 }
else if (
f->num_h_slices &&
f->num_v_slices <= 0) {
1494 }
else if (
f->num_v_slices &&
f->num_h_slices <= 0) {
1498 f->num_h_slices =
FFMIN(
f->num_h_slices, avctx->
width);
1503 "by the standard is %i\n",
1509 f->max_slice_count =
f->num_h_slices *
f->num_v_slices;
1514 if (
f->version < 4) {
1515 if (((
f->chroma_h_shift > 0) && (avctx->
width % (64 <<
f->chroma_h_shift))) ||
1516 ((
f->chroma_v_shift > 0) && (avctx->
height % (64 <<
f->chroma_v_shift)))) {
1518 "dimensions is only supported in version 4 (-level 4)\n");
1524 if (
f->version < 4) {
1547 for (
int i = 0;
i < fv->
s.
mprops.memoryHeapCount;
i++) {
1548 if (fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1551 if (!(fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT))
1552 max_host_size =
FFMAX(max_host_size,
1558 if (maxsize > fv->
s.
props_11.maxMemoryAllocationSize) {
1560 "than maximum device allocation (%zu), clipping\n",
1561 maxsize, fv->
s.
props_11.maxMemoryAllocationSize);
1562 maxsize = fv->
s.
props_11.maxMemoryAllocationSize;
1565 if (max_heap_size < maxsize) {
1567 "using host memory (slower)\n",
1571 max_heap_size = max_host_size - (max_host_size >> 1);
1574 max_heap_size = max_heap_size - (max_heap_size >> 3);
1577 av_log(avctx,
AV_LOG_INFO,
"Async buffers: %zuMiB per context, %zuMiB total, depth: %i\n",
1578 maxsize / (1024*1024),
1600 spv = ff_vk_spirv_init();
1639 "pixel format for RCT buffer!\n");
1678 &fv->
setup, 0, 0, 0,
1681 VK_FORMAT_UNDEFINED));
1688 VK_FORMAT_UNDEFINED));
1693 VK_FORMAT_UNDEFINED));
1698 VK_FORMAT_UNDEFINED));
1763 #define OFFSET(x) offsetof(VulkanEncodeFFv1Context, x)
1764 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1767 { .i64 = -1 }, -1, 2,
VE },
1769 { .i64 = 0 }, 0, 1,
VE },
1779 { .i64 = -1 }, -1, 2,
VE , .unit =
"qtable"},
1783 { .i64 =
QTABLE_8BIT }, INT_MIN, INT_MAX,
VE, .unit =
"qtable" },
1793 { .i64 = 0 }, 0, 1,
VE },
1795 {
"rct_search",
"Run a search for RCT parameters (level 4 only)",
OFFSET(optimize_rct),
AV_OPT_TYPE_BOOL,
1796 { .i64 = 1 }, 0, 1,
VE },
1799 { .i64 = 1 }, 1, INT_MAX,
VE },
1822 .
p.
name =
"ffv1_vulkan",
1840 .p.wrapper_name =
"vulkan",