Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Multi-Layer Reprojection
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Multi-Layer Reprojection
Commits
b35c7883
Commit
b35c7883
authored
4 years ago
by
Lava Block
Browse files
Options
Downloads
Patches
Plain Diff
add one_time_command_buffer
parent
7ddf3f36
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
liblava/base/device.cpp
+38
-0
38 additions, 0 deletions
liblava/base/device.cpp
liblava/base/device.hpp
+3
-0
3 additions, 0 deletions
liblava/base/device.hpp
with
41 additions
and
0 deletions
liblava/base/device.cpp
+
38
−
0
View file @
b35c7883
...
@@ -243,3 +243,41 @@ VkShaderModule lava::create_shader_module(device_ptr device, data const& data) {
...
@@ -243,3 +243,41 @@ VkShaderModule lava::create_shader_module(device_ptr device, data const& data) {
return
result
;
return
result
;
}
}
bool
lava
::
one_time_command_buffer
(
lava
::
device_ptr
device
,
VkCommandPool
pool
,
lava
::
queue
::
ref
queue
,
one_time_command_func
callback
)
{
if
(
!
callback
)
return
false
;
VkCommandBuffer
cmd_buf
=
nullptr
;
if
(
!
device
->
vkAllocateCommandBuffers
(
pool
,
1
,
&
cmd_buf
,
VK_COMMAND_BUFFER_LEVEL_PRIMARY
))
return
false
;
VkCommandBufferBeginInfo
const
begin_info
=
{
.
sType
=
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
,
.
flags
=
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
};
if
(
!
check
(
device
->
call
().
vkBeginCommandBuffer
(
cmd_buf
,
&
begin_info
)))
return
false
;
callback
(
cmd_buf
);
device
->
call
().
vkEndCommandBuffer
(
cmd_buf
);
VkFence
fence
=
VK_NULL_HANDLE
;
VkFenceCreateInfo
const
fence_info
=
{
.
sType
=
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
};
if
(
!
device
->
vkCreateFence
(
&
fence_info
,
&
fence
))
return
false
;
VkSubmitInfo
const
submit_info
=
{
.
sType
=
VK_STRUCTURE_TYPE_SUBMIT_INFO
,
.
commandBufferCount
=
1
,
.
pCommandBuffers
=
&
cmd_buf
};
if
(
!
device
->
vkQueueSubmit
(
queue
.
vk_queue
,
1
,
&
submit_info
,
fence
))
{
device
->
vkDestroyFence
(
fence
);
return
false
;
}
device
->
vkWaitForFences
(
1
,
&
fence
,
VK_TRUE
,
~
0
);
device
->
vkDestroyFence
(
fence
);
device
->
vkFreeCommandBuffers
(
pool
,
1
,
&
cmd_buf
);
return
true
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
liblava/base/device.hpp
+
3
−
0
View file @
b35c7883
...
@@ -175,4 +175,7 @@ namespace lava {
...
@@ -175,4 +175,7 @@ namespace lava {
VkShaderModule
create_shader_module
(
device_ptr
device
,
data
const
&
data
);
VkShaderModule
create_shader_module
(
device_ptr
device
,
data
const
&
data
);
using
one_time_command_func
=
std
::
function
<
void
(
VkCommandBuffer
)
>
;
bool
one_time_command_buffer
(
device_ptr
device
,
VkCommandPool
pool
,
queue
::
ref
queue
,
one_time_command_func
callback
);
}
// namespace lava
}
// namespace lava
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment