28 .r = VK_COMPONENT_SWIZZLE_IDENTITY,
29 .g = VK_COMPONENT_SWIZZLE_IDENTITY,
30 .b = VK_COMPONENT_SWIZZLE_IDENTITY,
31 .a = VK_COMPONENT_SWIZZLE_IDENTITY,
37 #define CASE(VAL) case VAL: return #VAL
45 CASE(VK_ERROR_OUT_OF_HOST_MEMORY);
46 CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY);
47 CASE(VK_ERROR_INITIALIZATION_FAILED);
48 CASE(VK_ERROR_DEVICE_LOST);
49 CASE(VK_ERROR_MEMORY_MAP_FAILED);
50 CASE(VK_ERROR_LAYER_NOT_PRESENT);
51 CASE(VK_ERROR_EXTENSION_NOT_PRESENT);
52 CASE(VK_ERROR_FEATURE_NOT_PRESENT);
53 CASE(VK_ERROR_INCOMPATIBLE_DRIVER);
54 CASE(VK_ERROR_TOO_MANY_OBJECTS);
55 CASE(VK_ERROR_FORMAT_NOT_SUPPORTED);
56 CASE(VK_ERROR_FRAGMENTED_POOL);
57 CASE(VK_ERROR_UNKNOWN);
58 CASE(VK_ERROR_OUT_OF_POOL_MEMORY);
59 CASE(VK_ERROR_INVALID_EXTERNAL_HANDLE);
60 CASE(VK_ERROR_FRAGMENTATION);
61 CASE(VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS);
62 CASE(VK_PIPELINE_COMPILE_REQUIRED);
63 CASE(VK_ERROR_SURFACE_LOST_KHR);
64 CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR);
65 CASE(VK_SUBOPTIMAL_KHR);
66 CASE(VK_ERROR_OUT_OF_DATE_KHR);
67 CASE(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR);
68 CASE(VK_ERROR_VALIDATION_FAILED_EXT);
69 CASE(VK_ERROR_INVALID_SHADER_NV);
70 CASE(VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR);
71 CASE(VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR);
72 CASE(VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR);
73 CASE(VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR);
74 CASE(VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR);
75 CASE(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
76 CASE(VK_ERROR_NOT_PERMITTED_KHR);
77 CASE(VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT);
78 CASE(VK_THREAD_IDLE_KHR);
79 CASE(VK_THREAD_DONE_KHR);
80 CASE(VK_OPERATION_DEFERRED_KHR);
81 CASE(VK_OPERATION_NOT_DEFERRED_KHR);
82 default:
return "Unknown error";
90 for (
int i = 0;
i <
s->hwctx->nb_qf;
i++) {
93 for (
int j = 0; j <
s->nb_qfs; j++) {
94 if (
s->qfs[j] ==
s->hwctx->qf[
i].idx) {
102 s->qfs[
s->nb_qfs++] =
s->hwctx->qf[
i].idx;
110 s->hprops = (VkPhysicalDeviceExternalMemoryHostPropertiesEXT) {
111 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT,
113 s->optical_flow_props = (VkPhysicalDeviceOpticalFlowPropertiesNV) {
114 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV,
117 s->coop_matrix_props = (VkPhysicalDeviceCooperativeMatrixPropertiesKHR) {
118 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR,
119 .pNext = &
s->optical_flow_props,
121 s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) {
122 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES,
123 .pNext = &
s->coop_matrix_props,
125 s->desc_buf_props = (VkPhysicalDeviceDescriptorBufferPropertiesEXT) {
126 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT,
127 .pNext = &
s->subgroup_props,
129 s->driver_props = (VkPhysicalDeviceDriverProperties) {
130 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES,
131 .pNext = &
s->desc_buf_props,
133 s->props = (VkPhysicalDeviceProperties2) {
134 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
135 .pNext = &
s->driver_props,
138 s->atomic_float_feats = (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT) {
139 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT,
141 s->feats_12 = (VkPhysicalDeviceVulkan12Features) {
142 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
143 .pNext = &
s->atomic_float_feats,
145 s->feats = (VkPhysicalDeviceFeatures2) {
146 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
147 .pNext = &
s->feats_12,
150 vk->GetPhysicalDeviceProperties2(
s->hwctx->phys_dev, &
s->props);
151 vk->GetPhysicalDeviceMemoryProperties(
s->hwctx->phys_dev, &
s->mprops);
152 vk->GetPhysicalDeviceFeatures2(
s->hwctx->phys_dev, &
s->feats);
159 vk->GetPhysicalDeviceQueueFamilyProperties2(
s->hwctx->phys_dev, &
s->tot_nb_qfs,
NULL);
161 s->qf_props =
av_calloc(
s->tot_nb_qfs,
sizeof(*
s->qf_props));
165 s->query_props =
av_calloc(
s->tot_nb_qfs,
sizeof(*
s->query_props));
171 s->video_props =
av_calloc(
s->tot_nb_qfs,
sizeof(*
s->video_props));
172 if (!
s->video_props) {
178 for (uint32_t
i = 0;
i <
s->tot_nb_qfs;
i++) {
179 s->query_props[
i] = (VkQueueFamilyQueryResultStatusPropertiesKHR) {
180 .sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR,
182 s->video_props[
i] = (VkQueueFamilyVideoPropertiesKHR) {
183 .sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR,
184 .pNext = &
s->query_props[
i],
186 s->qf_props[
i] = (VkQueueFamilyProperties2) {
187 .sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2,
188 .pNext = &
s->video_props[
i],
192 vk->GetPhysicalDeviceQueueFamilyProperties2(
s->hwctx->phys_dev, &
s->tot_nb_qfs,
s->qf_props);
195 vk->GetPhysicalDeviceCooperativeMatrixPropertiesKHR(
s->hwctx->phys_dev,
196 &
s->coop_mat_props_nb,
NULL);
198 if (
s->coop_mat_props_nb) {
200 sizeof(VkCooperativeMatrixPropertiesKHR));
201 for (
int i = 0;
i <
s->coop_mat_props_nb;
i++) {
202 s->coop_mat_props[
i] = (VkCooperativeMatrixPropertiesKHR) {
203 .sType = VK_STRUCTURE_TYPE_COOPERATIVE_MATRIX_PROPERTIES_KHR,
207 vk->GetPhysicalDeviceCooperativeMatrixPropertiesKHR(
s->hwctx->phys_dev,
208 &
s->coop_mat_props_nb,
218 for (
int i = 0;
i <
s->hwctx->nb_qf;
i++) {
219 if (
s->hwctx->qf[
i].flags & dev_family) {
220 *nb =
s->hwctx->qf[
i].num;
221 return s->hwctx->qf[
i].idx;
229 VkQueueFlagBits dev_family)
246 vk->WaitForFences(
s->hwctx->act_dev, 1, &e->
fence, VK_TRUE, UINT64_MAX);
247 vk->DestroyFence(
s->hwctx->act_dev, e->
fence,
s->hwctx->alloc);
279 vk->DestroyDescriptorPool(
s->hwctx->act_dev, sd->
desc_pool,
288 vk->FreeCommandBuffers(
s->hwctx->act_dev, pool->
cmd_buf_pool,
291 vk->DestroyCommandPool(
s->hwctx->act_dev, pool->
cmd_buf_pool,
s->hwctx->alloc);
293 vk->DestroyQueryPool(
s->hwctx->act_dev, pool->
query_pool,
s->hwctx->alloc);
302 int nb_queries, VkQueryType query_type,
int query_64bit,
303 const void *query_create_pnext)
310 VkCommandBufferAllocateInfo cbuf_create;
312 const VkQueryPoolVideoEncodeFeedbackCreateInfoKHR *ef =
NULL;
314 if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) {
316 VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR);
323 .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
324 .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
325 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
330 if (
ret != VK_SUCCESS) {
345 cbuf_create = (VkCommandBufferAllocateInfo) {
346 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
347 .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
349 .commandBufferCount = nb_contexts,
351 ret = vk->AllocateCommandBuffers(
s->hwctx->act_dev, &cbuf_create,
353 if (
ret != VK_SUCCESS) {
362 VkQueryPoolCreateInfo query_pool_info = {
363 .sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,
364 .pNext = query_create_pnext,
365 .queryType = query_type,
366 .queryCount = nb_queries*nb_contexts,
368 ret = vk->CreateQueryPool(
s->hwctx->act_dev, &query_pool_info,
370 if (
ret != VK_SUCCESS) {
383 if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) {
384 int nb_results =
av_popcount(ef->encodeFeedbackFlags);
387 }
else if (query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR) {
414 VkFenceCreateInfo fence_create = {
415 .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
416 .flags = VK_FENCE_CREATE_SIGNALED_BIT,
425 ret = vk->CreateFence(
s->hwctx->act_dev, &fence_create,
s->hwctx->alloc,
427 if (
ret != VK_SUCCESS) {
458 void **
data, VkQueryResultFlagBits
flags)
462 VkQueryResultFlags qf =
flags & ~(VK_QUERY_RESULT_64_BIT |
463 VK_QUERY_RESULT_WITH_STATUS_BIT_KHR);
467 return VK_INCOMPLETE;
471 VK_QUERY_RESULT_64_BIT : 0x0;
473 VK_QUERY_RESULT_WITH_STATUS_BIT_KHR : 0x0;
478 return vk->GetQueryPoolResults(
s->hwctx->act_dev, pool->
query_pool,
492 if (vk->GetFenceStatus(
s->hwctx->act_dev, e->
fence) == VK_SUCCESS)
503 vk->WaitForFences(
s->hwctx->act_dev, 1, &e->
fence, VK_TRUE, UINT64_MAX);
514 VkCommandBufferBeginInfo cmd_start = {
515 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
516 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
520 vk->WaitForFences(
s->hwctx->act_dev, 1, &e->
fence, VK_TRUE, UINT64_MAX);
524 vk->ResetFences(
s->hwctx->act_dev, 1, &e->
fence);
530 ret = vk->BeginCommandBuffer(e->
buf, &cmd_start);
531 if (
ret != VK_SUCCESS) {
556 vkfc->unlock_frame(hwfc, vkf);
582 for (
int i = 0;
i < nb_deps;
i++) {
594 #define ARR_REALLOC(str, arr, alloc_s, cnt) \
596 arr = av_fast_realloc(str->arr, alloc_s, (cnt + 1)*sizeof(*arr)); \
598 ff_vk_exec_discard_deps(s, e); \
599 return AVERROR(ENOMEM); \
616 vk->DestroySemaphore(
s->hwctx->act_dev, ts->
sem[
i],
s->hwctx->alloc);
622 VkSemaphore *sem,
int nb,
623 VkPipelineStageFlagBits2 stage,
635 for (
int i = 0;
i < nb;
i++) {
636 VkSemaphoreSubmitInfo *sem_sig;
640 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
649 buf_size =
sizeof(*ts) +
sizeof(VkSemaphore)*nb;
656 memcpy(ts->sem, sem, nb*
sizeof(*sem));
672 for (
int i = 0;
i < nb;
i++) {
677 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
686 for (
int i = 0;
i < nb;
i++)
687 vk->DestroySemaphore(
s->hwctx->act_dev, sem[
i],
s->hwctx->alloc);
693 VkPipelineStageFlagBits2 wait_stage,
694 VkPipelineStageFlagBits2 signal_stage)
696 uint8_t *frame_locked;
697 uint8_t *frame_update;
699 VkImageLayout *layout_dst;
700 uint32_t *queue_family_dst;
701 VkAccessFlagBits *access_dst;
727 vkfc->lock_frame(hwfc, vkf);
732 for (
int i = 0;
i < nb_images;
i++) {
734 VkSemaphoreSubmitInfo *sem_sig;
735 uint64_t **sem_sig_val_dst;
742 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
743 .semaphore = vkf->sem[
i],
744 .value = vkf->sem_value[
i],
745 .stageMask = wait_stage,
749 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
750 .semaphore = vkf->sem[
i],
751 .value = vkf->sem_value[
i] + 1,
752 .stageMask = signal_stage,
763 VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar)
782 VkSemaphore *
dst, uint64_t *dst_val,
785 uint64_t **sem_sig_val_dst;
811 VkCommandBufferSubmitInfo cmd_buf_info = (VkCommandBufferSubmitInfo) {
812 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO,
813 .commandBuffer = e->
buf,
815 VkSubmitInfo2 submit_info = (VkSubmitInfo2) {
816 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO_2,
817 .pCommandBufferInfos = &cmd_buf_info,
818 .commandBufferInfoCount = 1,
821 .pSignalSemaphoreInfos = e->
sem_sig,
825 ret = vk->EndCommandBuffer(e->
buf);
826 if (
ret != VK_SUCCESS) {
833 s->hwctx->lock_queue(
s->device, e->
qf, e->
qi);
835 s->hwctx->unlock_queue(
s->device, e->
qf, e->
qi);
837 if (
ret != VK_SUCCESS) {
857 for (
int i = 0;
i < nb_images;
i++) {
863 vkfc->unlock_frame(hwfc, vkf);
874 VkMemoryPropertyFlagBits req_flags,
void *alloc_extension,
875 VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem)
881 VkMemoryAllocateInfo alloc_info = {
882 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
883 .pNext = alloc_extension,
886 alloc_info.allocationSize = req->size;
890 for (
int i = 0;
i <
s->mprops.memoryTypeCount;
i++) {
892 if (!(req->memoryTypeBits & (1 <<
i)))
896 if ((req_flags != UINT32_MAX) &&
897 ((
s->mprops.memoryTypes[
i].propertyFlags & req_flags) != req_flags))
911 alloc_info.memoryTypeIndex =
index;
913 ret = vk->AllocateMemory(
s->hwctx->act_dev, &alloc_info,
914 s->hwctx->alloc, mem);
915 if (
ret != VK_SUCCESS)
919 *mem_flags |=
s->mprops.memoryTypes[
index].propertyFlags;
925 void *pNext,
void *alloc_pNext,
926 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags)
933 VkBufferCreateInfo buf_spawn = {
934 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
937 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
938 .size =
flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT ?
939 FFALIGN(
size,
s->props.properties.limits.minMemoryMapAlignment) :
943 VkMemoryAllocateFlagsInfo alloc_flags = {
944 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO,
945 .flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT,
947 VkBufferMemoryRequirementsInfo2 req_desc = {
948 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
950 VkMemoryDedicatedAllocateInfo ded_alloc = {
951 .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
952 .pNext = alloc_pNext,
954 VkMemoryDedicatedRequirements ded_req = {
955 .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS,
957 VkMemoryRequirements2 req = {
958 .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
963 "usage: 0x%x, flags: 0x%x\n",
966 ret = vk->CreateBuffer(
s->hwctx->act_dev, &buf_spawn,
s->hwctx->alloc, &buf->
buf);
967 if (
ret != VK_SUCCESS) {
973 req_desc.buffer = buf->
buf;
975 vk->GetBufferMemoryRequirements2(
s->hwctx->act_dev, &req_desc, &req);
978 use_ded_mem = ded_req.prefersDedicatedAllocation |
979 ded_req.requiresDedicatedAllocation;
981 ded_alloc.buffer = buf->
buf;
982 ded_alloc.pNext = alloc_pNext;
983 alloc_pNext = &ded_alloc;
986 if (
usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) {
987 alloc_flags.pNext = alloc_pNext;
988 alloc_pNext = &alloc_flags;
996 ret = vk->BindBufferMemory(
s->hwctx->act_dev, buf->
buf, buf->
mem, 0);
997 if (
ret != VK_SUCCESS) {
1003 if (
usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) {
1004 VkBufferDeviceAddressInfo address_info = {
1005 .sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
1008 buf->
address = vk->GetBufferDeviceAddress(
s->hwctx->act_dev, &address_info);
1025 void *pNext,
void *alloc_pNext,
1026 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags)
1052 int nb_buffers,
int invalidate)
1056 VkMappedMemoryRange inval_list[64];
1057 int inval_count = 0;
1059 for (
int i = 0;
i < nb_buffers;
i++) {
1061 ret = vk->MapMemory(
s->hwctx->act_dev, buf[
i]->
mem, 0,
1062 VK_WHOLE_SIZE, 0, &
dst);
1063 if (
ret != VK_SUCCESS) {
1074 for (
int i = 0;
i < nb_buffers;
i++) {
1075 const VkMappedMemoryRange ival_buf = {
1076 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
1077 .memory = buf[
i]->
mem,
1078 .size = VK_WHOLE_SIZE,
1080 if (buf[
i]->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
1082 inval_list[inval_count++] = ival_buf;
1086 ret = vk->InvalidateMappedMemoryRanges(
s->hwctx->act_dev, inval_count,
1088 if (
ret != VK_SUCCESS) {
1104 VkMappedMemoryRange flush_list[64];
1105 int flush_count = 0;
1108 for (
int i = 0;
i < nb_buffers;
i++) {
1109 const VkMappedMemoryRange flush_buf = {
1110 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
1111 .memory = buf[
i]->
mem,
1112 .size = VK_WHOLE_SIZE,
1114 if (buf[
i]->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
1116 flush_list[flush_count++] = flush_buf;
1121 ret = vk->FlushMappedMemoryRanges(
s->hwctx->act_dev, flush_count,
1123 if (
ret != VK_SUCCESS) {
1130 for (
int i = 0;
i < nb_buffers;
i++) {
1131 vk->UnmapMemory(
s->hwctx->act_dev, buf[
i]->
mem);
1142 if (!buf || !
s->hwctx)
1147 if (buf->
buf != VK_NULL_HANDLE)
1148 vk->DestroyBuffer(
s->hwctx->act_dev, buf->
buf,
s->hwctx->alloc);
1149 if (buf->
mem != VK_NULL_HANDLE)
1150 vk->FreeMemory(
s->hwctx->act_dev, buf->
mem,
s->hwctx->alloc);
1176 void *create_pNext,
size_t size,
1177 VkMemoryPropertyFlagBits mem_props)
1195 data->stage = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT;
1196 data->access = VK_ACCESS_2_NONE;
1212 if (mem_props & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
1224 VkShaderStageFlagBits stage)
1226 VkPushConstantRange *pc;
1235 memset(pc, 0,
sizeof(*pc));
1237 pc->stageFlags = stage;
1245 int unnorm_coords, VkFilter
filt)
1250 VkSamplerCreateInfo sampler_info = {
1251 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
1253 .minFilter = sampler_info.magFilter,
1254 .mipmapMode = unnorm_coords ? VK_SAMPLER_MIPMAP_MODE_NEAREST :
1255 VK_SAMPLER_MIPMAP_MODE_LINEAR,
1256 .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
1257 .addressModeV = sampler_info.addressModeU,
1258 .addressModeW = sampler_info.addressModeU,
1259 .anisotropyEnable = VK_FALSE,
1260 .compareOp = VK_COMPARE_OP_NEVER,
1261 .borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
1262 .unnormalizedCoordinates = unnorm_coords,
1265 ret = vk->CreateSampler(
s->hwctx->act_dev, &sampler_info,
1266 s->hwctx->alloc, sampler);
1267 if (
ret != VK_SUCCESS) {
1306 const char *rep_tab[] = {
1312 return rep_tab[rep_fmt];
1318 const char *rep_tab[] = {
1324 return rep_tab[rep_fmt];
1332 const char *rep_tab[] = {
1338 return rep_tab[rep_fmt];
1342 const char *rep_tab[] = {
1348 return rep_tab[rep_fmt];
1352 const char *rep_tab[] = {
1358 return rep_tab[rep_fmt];
1365 const char *rep_tab[] = {
1371 return rep_tab[rep_fmt];
1384 const char *rep_tab[] = {
1390 return rep_tab[rep_fmt];
1395 const char *rep_tab[] = {
1401 return rep_tab[rep_fmt];
1406 const char *rep_tab[] = {
1412 return rep_tab[rep_fmt];
1417 const char *rep_tab[] = {
1423 return rep_tab[rep_fmt];
1431 const char *rep_tab[] = {
1437 return rep_tab[rep_fmt];
1456 vk->DestroyImageView(
s->hwctx->act_dev, iv->
views[
i],
s->hwctx->alloc);
1463 #define REPS_FMT(fmt) \
1464 [FF_VK_REP_NATIVE] = fmt ## _UINT, \
1465 [FF_VK_REP_FLOAT] = fmt ## _UNORM, \
1466 [FF_VK_REP_INT] = fmt ## _SINT, \
1467 [FF_VK_REP_UINT] = fmt ## _UINT,
1469 #define REPS_FMT_PACK(fmt, num) \
1470 [FF_VK_REP_NATIVE] = fmt ## _UINT_PACK ## num, \
1471 [FF_VK_REP_FLOAT] = fmt ## _UNORM_PACK ## num, \
1472 [FF_VK_REP_INT] = fmt ## _SINT_PACK ## num, \
1473 [FF_VK_REP_UINT] = fmt ## _UINT_PACK ## num,
1479 VK_FORMAT_B5G6R5_UNORM_PACK16,
1480 VK_FORMAT_B5G6R5_UNORM_PACK16,
1481 VK_FORMAT_UNDEFINED,
1482 VK_FORMAT_UNDEFINED,
1485 VK_FORMAT_R5G6B5_UNORM_PACK16,
1486 VK_FORMAT_R5G6B5_UNORM_PACK16,
1487 VK_FORMAT_UNDEFINED,
1488 VK_FORMAT_UNDEFINED,
1499 {
REPS_FMT(VK_FORMAT_R16G16B16A16) },
1501 VK_FORMAT_R32_SFLOAT,
1502 VK_FORMAT_R32_SFLOAT,
1503 VK_FORMAT_UNDEFINED,
1504 VK_FORMAT_UNDEFINED,
1507 VK_FORMAT_R32G32B32_SFLOAT,
1508 VK_FORMAT_R32G32B32_SFLOAT,
1509 VK_FORMAT_UNDEFINED,
1510 VK_FORMAT_UNDEFINED,
1513 VK_FORMAT_R32G32B32A32_SFLOAT,
1514 VK_FORMAT_R32G32B32A32_SFLOAT,
1515 VK_FORMAT_UNDEFINED,
1516 VK_FORMAT_UNDEFINED,
1519 VK_FORMAT_R32G32B32_UINT,
1520 VK_FORMAT_UNDEFINED,
1521 VK_FORMAT_R32G32B32_SINT,
1522 VK_FORMAT_R32G32B32_UINT,
1525 VK_FORMAT_R32G32B32A32_UINT,
1526 VK_FORMAT_UNDEFINED,
1527 VK_FORMAT_R32G32B32A32_SINT,
1528 VK_FORMAT_R32G32B32A32_UINT,
1531 #undef REPS_FMT_PACK
1534 if (fmt == VK_FORMAT_UNDEFINED)
1535 return VK_FORMAT_UNDEFINED;
1542 return fmts_map[
i][rep_fmt];
1545 return VK_FORMAT_UNDEFINED;
1564 const size_t buf_size =
sizeof(*iv) + nb_planes*
sizeof(VkImageView);
1569 for (
int i = 0;
i < nb_planes;
i++) {
1570 VkImageAspectFlags plane_aspect[] = { VK_IMAGE_ASPECT_COLOR_BIT,
1571 VK_IMAGE_ASPECT_PLANE_0_BIT,
1572 VK_IMAGE_ASPECT_PLANE_1_BIT,
1573 VK_IMAGE_ASPECT_PLANE_2_BIT, };
1575 VkImageViewUsageCreateInfo view_usage_info = {
1576 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
1577 .usage = vkfc->usage &
1578 (~(VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR |
1579 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR)),
1581 VkImageViewCreateInfo view_create_info = {
1582 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1583 .pNext = &view_usage_info,
1584 .image = vkf->
img[
FFMIN(
i, nb_images - 1)],
1585 .viewType = VK_IMAGE_VIEW_TYPE_2D,
1588 .subresourceRange = {
1589 .aspectMask = plane_aspect[(nb_planes != nb_images) +
1590 i*(nb_planes != nb_images)],
1595 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
1597 "of format %i and mode %i\n",
1598 rep_fmts[
i], rep_fmt);
1603 ret = vk->CreateImageView(
s->hwctx->act_dev, &view_create_info,
1604 s->hwctx->alloc, &iv->views[
i]);
1605 if (
ret != VK_SUCCESS) {
1626 memcpy(views, iv->views, nb_planes*
sizeof(*views));
1631 for (
int i = 0;
i < iv->nb_views;
i++)
1632 vk->DestroyImageView(
s->hwctx->act_dev, iv->views[
i],
s->hwctx->alloc);
1638 AVFrame *pic, VkImageMemoryBarrier2 *bar,
int *nb_bar,
1639 VkPipelineStageFlags src_stage,
1640 VkPipelineStageFlags dst_stage,
1641 VkAccessFlagBits new_access,
1642 VkImageLayout new_layout,
1655 for (
int i = 0;
i < nb_images;
i++) {
1656 bar[*nb_bar] = (VkImageMemoryBarrier2) {
1657 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
1659 .srcStageMask = src_stage,
1660 .dstStageMask = dst_stage,
1662 .dstAccessMask = new_access,
1664 .newLayout = new_layout,
1666 .dstQueueFamilyIndex = new_qf,
1667 .image = vkf->
img[
i],
1668 .subresourceRange = (VkImageSubresourceRange) {
1669 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1681 VkPipelineStageFlags stage,
1682 const char *extensions[],
int nb_extensions,
1683 int lg_x,
int lg_y,
int lg_z,
1684 uint32_t required_subgroup_size)
1694 switch (shd->
stage) {
1695 case VK_SHADER_STAGE_ANY_HIT_BIT_KHR:
1696 case VK_SHADER_STAGE_CALLABLE_BIT_KHR:
1697 case VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR:
1698 case VK_SHADER_STAGE_INTERSECTION_BIT_KHR:
1699 case VK_SHADER_STAGE_MISS_BIT_KHR:
1700 case VK_SHADER_STAGE_RAYGEN_BIT_KHR:
1701 shd->
bind_point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR;
1703 case VK_SHADER_STAGE_COMPUTE_BIT:
1704 shd->
bind_point = VK_PIPELINE_BIND_POINT_COMPUTE;
1707 shd->
bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS;
1711 if (required_subgroup_size) {
1712 shd->
subgroup_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO;
1713 shd->
subgroup_info.requiredSubgroupSize = required_subgroup_size;
1717 (stage == VK_SHADER_STAGE_TASK_BIT_EXT ||
1718 stage == VK_SHADER_STAGE_MESH_BIT_EXT) ?
1720 (shd->
bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) ?
1722 (shd->
bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) ?
1723 "Compute" :
"Graphics",
1729 GLSLC(0, #define IS_WITHIN(v1, v2) ((v1.x < v2.x) && (v1.y < v2.y)) );
1731 GLSLC(0, #extension GL_EXT_scalar_block_layout : require );
1732 GLSLC(0, #extension GL_EXT_shader_explicit_arithmetic_types : require );
1733 GLSLC(0, #extension GL_EXT_control_flow_attributes : require );
1736 GLSLC(0, #extension GL_EXT_debug_printf : require );
1740 if (stage == VK_SHADER_STAGE_TASK_BIT_EXT ||
1741 stage == VK_SHADER_STAGE_MESH_BIT_EXT)
1742 GLSLC(0, #extension GL_EXT_mesh_shader : require );
1744 for (
int i = 0;
i < nb_extensions;
i++)
1745 GLSLF(0, #extension %
s : %
s ,extensions[
i],
"require");
1748 GLSLF(0,
layout (local_size_x = %
i, local_size_y = %
i, local_size_z = %
i) in;
1758 const char *p = shd->
src.str;
1759 const char *start = p;
1760 const size_t len = strlen(p);
1765 for (
int i = 0;
i <
len;
i++) {
1781 VkPipelineLayoutCreateInfo pipeline_layout_info;
1784 pipeline_layout_info = (VkPipelineLayoutCreateInfo) {
1785 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
1792 ret = vk->CreatePipelineLayout(
s->hwctx->act_dev, &pipeline_layout_info,
1794 if (
ret != VK_SUCCESS) {
1804 VkShaderModule *
mod,
1805 uint8_t *spirv,
size_t spirv_len)
1810 VkShaderModuleCreateInfo shader_module_info = {
1811 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
1814 .pCode = (
void *)spirv,
1815 .codeSize = spirv_len,
1818 ret = vk->CreateShaderModule(
s->hwctx->act_dev, &shader_module_info,
1819 s->hwctx->alloc,
mod);
1820 if (
ret != VK_SUCCESS) {
1830 VkShaderModule
mod,
const char *entrypoint)
1835 VkComputePipelineCreateInfo pipeline_create_info = {
1836 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
1838 VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT : 0x0,
1840 .stage = (VkPipelineShaderStageCreateInfo) {
1841 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
1844 .pName = entrypoint,
1846 VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT : 0x0,
1847 .stage = shd->
stage,
1852 ret = vk->CreateComputePipelines(
s->hwctx->act_dev, VK_NULL_HANDLE, 1,
1853 &pipeline_create_info,
1855 if (
ret != VK_SUCCESS) {
1865 uint8_t *spirv,
size_t spirv_len,
1866 const char *entrypoint)
1870 size_t shader_size = 0;
1872 VkShaderCreateInfoEXT shader_obj_create = {
1873 .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT,
1875 VK_SHADER_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT : 0x0,
1876 .stage = shd->
stage,
1878 .codeType = VK_SHADER_CODE_TYPE_SPIRV_EXT,
1880 .codeSize = spirv_len,
1881 .pName = entrypoint,
1886 .pSpecializationInfo =
NULL,
1889 ret = vk->CreateShadersEXT(
s->hwctx->act_dev, 1, &shader_obj_create,
1890 s->hwctx->alloc, &shd->
object);
1891 if (
ret != VK_SUCCESS) {
1897 if (vk->GetShaderBinaryDataEXT(
s->hwctx->act_dev, shd->
object,
1898 &shader_size,
NULL) == VK_SUCCESS)
1900 shd->
name, shader_size, spirv_len);
1916 int has_singular = 0;
1930 VkDescriptorSetLayoutCreateInfo desc_layout_create = {
1931 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
1932 .bindingCount =
set->nb_bindings,
1933 .pBindings =
set->binding,
1935 VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT :
1937 VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR :
1941 ret = vk->CreateDescriptorSetLayout(
s->hwctx->act_dev,
1942 &desc_layout_create,
1945 if (
ret != VK_SUCCESS) {
1952 vk->GetDescriptorSetLayoutSizeEXT(
s->hwctx->act_dev, shd->
desc_layout[
i],
1956 s->desc_buf_props.descriptorBufferOffsetAlignment);
1958 for (
int j = 0; j <
set->nb_bindings; j++)
1959 vk->GetDescriptorSetLayoutBindingOffsetEXT(
s->hwctx->act_dev,
1962 &
set->binding_offset[j]);
1970 uint8_t *spirv,
size_t spirv_len,
1971 const char *entrypoint)
2005 case VK_PIPELINE_BIND_POINT_COMPUTE:
2015 vk->DestroyShaderModule(
s->hwctx->act_dev,
mod,
s->hwctx->alloc);
2031 [VK_DESCRIPTOR_TYPE_SAMPLER] = {
sizeof(VkDescriptorImageInfo),
"sampler", 1, 0, 0, 0, },
2032 [VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE] = {
sizeof(VkDescriptorImageInfo),
"texture", 1, 0, 1, 0, },
2033 [VK_DESCRIPTOR_TYPE_STORAGE_IMAGE] = {
sizeof(VkDescriptorImageInfo),
"image", 1, 1, 1, 0, },
2034 [VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT] = {
sizeof(VkDescriptorImageInfo),
"subpassInput", 1, 0, 0, 0, },
2035 [VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] = {
sizeof(VkDescriptorImageInfo),
"sampler", 1, 0, 1, 0, },
2036 [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER] = {
sizeof(VkDescriptorBufferInfo),
NULL, 1, 0, 0, 1, },
2037 [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] = {
sizeof(VkDescriptorBufferInfo),
"buffer", 0, 1, 0, 1, },
2038 [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] = {
sizeof(VkDescriptorBufferInfo),
NULL, 1, 0, 0, 1, },
2039 [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] = {
sizeof(VkDescriptorBufferInfo),
"buffer", 0, 1, 0, 1, },
2040 [VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER] = {
sizeof(VkBufferView),
"samplerBuffer", 1, 0, 0, 0, },
2041 [VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER] = {
sizeof(VkBufferView),
"imageBuffer", 1, 0, 0, 0, },
2046 int singular,
int print_to_shader_only)
2048 int has_sampler = 0;
2051 if (print_to_shader_only)
2063 memset(
set, 0,
sizeof(*
set));
2070 if (!
set->binding_offset) {
2075 for (
int i = 0;
i < nb;
i++) {
2076 set->binding[
i].binding =
i;
2077 set->binding[
i].descriptorType =
desc[
i].type;
2079 set->binding[
i].stageFlags =
desc[
i].stages;
2080 set->binding[
i].pImmutableSamplers =
desc[
i].samplers;
2082 if (
desc[
i].
type == VK_DESCRIPTOR_TYPE_SAMPLER ||
2083 desc[
i].
type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
2087 set->usage = VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT |
2088 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
2090 set->usage |= VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT;
2093 for (
int i = 0;
i < nb;
i++) {
2095 VkDescriptorPoolSize *desc_pool_size;
2101 sizeof(*desc_pool_size),
2103 if (!desc_pool_size)
2108 memset(&desc_pool_size[j], 0,
sizeof(VkDescriptorPoolSize));
2115 set->singular = singular;
2116 set->nb_bindings = nb;
2121 for (
int i = 0;
i < nb;
i++) {
2125 if (
desc[
i].mem_layout)
2137 if (
desc[
i].
type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
2138 if (
desc[
i].mem_layout) {
2139 int len = strlen(
desc[
i].mem_layout);
2140 if (
desc[
i].mem_layout[
len - 1] ==
'i' &&
2141 desc[
i].mem_layout[
len - 2] ==
'u') {
2143 }
else if (
desc[
i].mem_layout[
len - 1] ==
'i') {
2158 else if (
desc[
i].elems > 0)
2186 memset(sd, 0,
sizeof(*sd));
2206 set->aligned_size*nb,
2208 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
2209 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
2210 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
2218 sd->
desc_bind[
i] = (VkDescriptorBufferBindingInfoEXT) {
2219 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT,
2220 .usage =
set->usage,
2227 VkDescriptorSetLayout *tmp_layouts;
2228 VkDescriptorSetAllocateInfo set_alloc_info;
2229 VkDescriptorPoolCreateInfo pool_create_info;
2234 pool_create_info = (VkDescriptorPoolCreateInfo) {
2235 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2242 ret = vk->CreateDescriptorPool(
s->hwctx->act_dev, &pool_create_info,
2244 if (
ret != VK_SUCCESS) {
2250 tmp_layouts =
av_malloc_array(pool_create_info.maxSets,
sizeof(*tmp_layouts));
2259 set_alloc_info = (VkDescriptorSetAllocateInfo) {
2260 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2262 .pSetLayouts = tmp_layouts,
2263 .descriptorSetCount = pool_create_info.maxSets,
2267 sizeof(*tmp_layouts));
2272 ret = vk->AllocateDescriptorSets(
s->hwctx->act_dev, &set_alloc_info,
2275 if (
ret != VK_SUCCESS) {
2297 int bind_idx,
int array_idx,
2298 VkDescriptorGetInfoEXT *desc_get_info,
2309 array_idx*desc_size;
2311 vk->GetDescriptorEXT(
s->hwctx->act_dev, desc_get_info, desc_size,
desc);
2316 VkWriteDescriptorSet *write_info)
2325 vk->UpdateDescriptorSets(
s->hwctx->act_dev, 1, write_info, 0,
NULL);
2329 vk->CmdPushDescriptorSetKHR(e->
buf,
2336 vk->UpdateDescriptorSets(
s->hwctx->act_dev, 1, write_info, 0,
NULL);
2343 VkImageView view, VkImageLayout
layout,
2349 VkDescriptorGetInfoEXT desc_get_info = {
2350 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT,
2351 .type = desc_set->
binding[bind].descriptorType,
2353 VkDescriptorImageInfo desc_img_info = {
2360 switch (desc_get_info.type) {
2361 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2362 desc_get_info.
data.pSampledImage = &desc_img_info;
2363 desc_size =
s->desc_buf_props.sampledImageDescriptorSize;
2365 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
2366 desc_get_info.data.pStorageImage = &desc_img_info;
2367 desc_size =
s->desc_buf_props.storageImageDescriptorSize;
2369 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2370 desc_get_info.data.pInputAttachmentImage = &desc_img_info;
2371 desc_size =
s->desc_buf_props.inputAttachmentDescriptorSize;
2373 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2374 desc_get_info.data.pCombinedImageSampler = &desc_img_info;
2375 desc_size =
s->desc_buf_props.combinedImageSamplerDescriptorSize;
2379 set, bind, desc_get_info.type);
2385 &desc_get_info, desc_size);
2387 VkDescriptorImageInfo desc_pool_write_info_img = {
2392 VkWriteDescriptorSet desc_pool_write_info = {
2393 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2395 .descriptorCount = 1,
2396 .dstArrayElement = offs,
2397 .descriptorType = desc_set->
binding[bind].descriptorType,
2398 .pImageInfo = &desc_pool_write_info_img,
2408 int set,
int bind,
int elem,
2415 VkDescriptorGetInfoEXT desc_get_info = {
2416 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT,
2417 .type = desc_set->
binding[bind].descriptorType,
2419 VkDescriptorAddressInfoEXT desc_buf_info = {
2420 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT,
2427 switch (desc_get_info.type) {
2428 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2429 desc_get_info.data.pUniformBuffer = &desc_buf_info;
2430 desc_size =
s->desc_buf_props.uniformBufferDescriptorSize;
2432 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2433 desc_get_info.data.pStorageBuffer = &desc_buf_info;
2434 desc_size =
s->desc_buf_props.storageBufferDescriptorSize;
2436 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2437 desc_get_info.data.pUniformTexelBuffer = &desc_buf_info;
2438 desc_size =
s->desc_buf_props.uniformTexelBufferDescriptorSize;
2440 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2441 desc_get_info.data.pStorageTexelBuffer = &desc_buf_info;
2442 desc_size =
s->desc_buf_props.storageTexelBufferDescriptorSize;
2446 set, bind, desc_get_info.type);
2453 VkDescriptorBufferInfo desc_pool_write_info_buf = {
2458 VkWriteDescriptorSet desc_pool_write_info = {
2459 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2461 .descriptorCount = 1,
2462 .dstArrayElement = elem,
2463 .descriptorType = desc_set->
binding[bind].descriptorType,
2464 .pBufferInfo = &desc_pool_write_info_buf,
2474 VkImageView *views,
int set,
int binding,
2475 VkImageLayout
layout, VkSampler sampler)
2480 for (
int i = 0;
i < nb_planes;
i++)
2487 VkShaderStageFlagBits stage,
2503 VkShaderStageFlagBits stages = shd->
stage;
2504 vk->CmdBindShadersEXT(e->
buf, 1, &stages, &shd->
object);
2536 if (shd->shader.module)
2537 vk->DestroyShaderModule(
s->hwctx->act_dev, shd->shader.module,
2542 vk->DestroyShaderEXT(
s->hwctx->act_dev, shd->
object,
s->hwctx->alloc);
2544 vk->DestroyPipeline(
s->hwctx->act_dev, shd->
pipeline,
s->hwctx->alloc);
2557 vk->DestroyDescriptorSetLayout(
s->hwctx->act_dev, shd->
desc_layout[
i],
2584 static const AVClass vulkan_context_class = {
2590 memset(
s, 0,
sizeof(*
s));
2591 s->log_parent = log_parent;
2592 s->class = &vulkan_context_class;
2600 s->hwfc =
s->frames->hwctx;
2602 device_ref =
s->frames->device_ref;
2606 if (!
s->device_ref) {
2612 s->hwctx =
s->device->hwctx;
2615 s->hwctx->nb_enabled_dev_extensions);
2617 s->hwctx->nb_enabled_inst_extensions);