Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -152,7 +152,7 @@ int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size, · 151 unmodified lines | ||
| 152 | 152 | { |
| 153 | 153 | int err; |
| 154 | 154 | VkResult ret; |
| 155 | − VkMemoryRequirements req; | |
| 155 | + int use_ded_mem; | |
| 156 | 156 | VulkanFilterContext *s = avctx->priv; |
| 157 | 157 | |
| 158 | 158 | VkBufferCreateInfo buf_spawn = { |
| @@ -164,6 +164,21 @@ int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size, · 5 unmodified lines | ||
| 164 | 164 | but should be ok */ |
| 165 | 165 | }; |
| 166 | 166 | |
| 167 | + VkBufferMemoryRequirementsInfo2 req_desc = { | |
| 168 | + .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2, | |
| 169 | + }; | |
| 170 | + VkMemoryDedicatedAllocateInfo ded_alloc = { | |
| 171 | + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, | |
| 172 | + .pNext = NULL, | |
| 173 | + }; | |
| 174 | + VkMemoryDedicatedRequirements ded_req = { | |
| 175 | + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS, | |
| 176 | + }; | |
| 177 | + VkMemoryRequirements2 req = { | |
| 178 | + .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, | |
| 179 | + .pNext = &ded_req, | |
| 180 | + }; | |
| 181 | + | |
| 167 | 182 | ret = vkCreateBuffer(s->hwctx->act_dev, &buf_spawn, NULL, &buf->buf); |
| 168 | 183 | if (ret != VK_SUCCESS) { |
| 169 | 184 | av_log(avctx, AV_LOG_ERROR, "Failed to create buffer: %s\n", |
| @@ -171,9 +186,19 @@ int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size, · 1 unmodified line | ||
| 171 | 186 | return AVERROR_EXTERNAL; |
| 172 | 187 | } |
| 173 | 188 | |
| 174 | − vkGetBufferMemoryRequirements(s->hwctx->act_dev, buf->buf, &req); | |
| 189 | + req_desc.buffer = buf->buf; | |
| 190 | + | |
| 191 | + vkGetBufferMemoryRequirements2(s->hwctx->act_dev, &req_desc, &req); | |
| 192 | + | |
| 193 | + /* In case the implementation prefers/requires dedicated allocation */ | |
| 194 | + use_ded_mem = ded_req.prefersDedicatedAllocation | | |
| 195 | + ded_req.requiresDedicatedAllocation; | |
| 196 | + if (use_ded_mem) | |
| 197 | + ded_alloc.buffer = buf->buf; | |
| 175 | 198 | |
| 176 | − err = vk_alloc_mem(avctx, &req, flags, NULL, &buf->flags, &buf->mem); | |
| 199 | + err = vk_alloc_mem(avctx, &req.memoryRequirements, flags, | |
| 200 | + use_ded_mem ? &ded_alloc : (void *)ded_alloc.pNext, | |
| 201 | + &buf->flags, &buf->mem); | |
| 177 | 202 | if (err) |
| 178 | 203 | return err; |
| 179 | 204 | |