Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
6bb718aa
Unverified
Commit
6bb718aa
authored
May 26, 2020
by
Lynne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwcontext_vulkan: use dedicated allocation for buffers when necessary
parent
4dcb50c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
hwcontext_vulkan.c
libavutil/hwcontext_vulkan.c
+28
-3
No files found.
libavutil/hwcontext_vulkan.c
View file @
6bb718aa
...
...
@@ -2663,7 +2663,7 @@ static int create_buf(AVHWDeviceContext *ctx, AVBufferRef **buf, size_t imp_size
{
int
err
;
VkResult
ret
;
VkMemoryRequirements
req
;
int
use_ded_mem
;
AVVulkanDeviceContext
*
hwctx
=
ctx
->
hwctx
;
VulkanDevicePriv
*
p
=
ctx
->
internal
->
priv
;
...
...
@@ -2674,6 +2674,21 @@ static int create_buf(AVHWDeviceContext *ctx, AVBufferRef **buf, size_t imp_size
.
sharingMode
=
VK_SHARING_MODE_EXCLUSIVE
,
};
VkBufferMemoryRequirementsInfo2
req_desc
=
{
.
sType
=
VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2
,
};
VkMemoryDedicatedAllocateInfo
ded_alloc
=
{
.
sType
=
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO
,
.
pNext
=
alloc_pnext
,
};
VkMemoryDedicatedRequirements
ded_req
=
{
.
sType
=
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS
,
};
VkMemoryRequirements2
req
=
{
.
sType
=
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2
,
.
pNext
=
&
ded_req
,
};
ImageBuffer
*
vkbuf
=
av_mallocz
(
sizeof
(
*
vkbuf
));
if
(
!
vkbuf
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -2695,9 +2710,19 @@ static int create_buf(AVHWDeviceContext *ctx, AVBufferRef **buf, size_t imp_size
return
AVERROR_EXTERNAL
;
}
vkGetBufferMemoryRequirements
(
hwctx
->
act_dev
,
vkbuf
->
buf
,
&
req
);
req_desc
.
buffer
=
vkbuf
->
buf
;
vkGetBufferMemoryRequirements2
(
hwctx
->
act_dev
,
&
req_desc
,
&
req
);
/* In case the implementation prefers/requires dedicated allocation */
use_ded_mem
=
ded_req
.
prefersDedicatedAllocation
|
ded_req
.
requiresDedicatedAllocation
;
if
(
use_ded_mem
)
ded_alloc
.
buffer
=
vkbuf
->
buf
;
err
=
alloc_mem
(
ctx
,
&
req
,
flags
,
alloc_pnext
,
&
vkbuf
->
flags
,
&
vkbuf
->
mem
);
err
=
alloc_mem
(
ctx
,
&
req
.
memoryRequirements
,
flags
,
use_ded_mem
?
&
ded_alloc
:
(
void
*
)
ded_alloc
.
pNext
,
&
vkbuf
->
flags
,
&
vkbuf
->
mem
);
if
(
err
)
return
err
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment