Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
aed76227
Commit
aed76227
authored
3 years ago
by
Mark Oliver Mints
Browse files
Options
Downloads
Patches
Plain Diff
[
#71
] implement function to get pipeline and layout
parent
68834463
No related branches found
No related tags found
1 merge request
!83
Resolve "Refactor Pipeline Config and Manager"
Pipeline
#26997
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/vkcv/ComputePipelineManager.cpp
+31
-8
31 additions, 8 deletions
src/vkcv/ComputePipelineManager.cpp
src/vkcv/ComputePipelineManager.hpp
+23
-8
23 additions, 8 deletions
src/vkcv/ComputePipelineManager.hpp
with
54 additions
and
16 deletions
src/vkcv/ComputePipelineManager.cpp
+
31
−
8
View file @
aed76227
#include
"ComputePipelineManager.hpp"
#include
"vkcv/Logger.hpp"
namespace
vkcv
{
namespace
vkcv
{
ComputePipelineManager
::
ComputePipelineManager
(
vk
::
Device
device
)
noexcept
:
m_Device
{
device
},
...
...
@@ -15,6 +15,31 @@ namespace vkcv {
}
}
vk
::
Pipeline
ComputePipelineManager
::
getVkPipeline
(
const
ComputePipelineHandle
&
handle
)
const
{
const
uint64_t
id
=
handle
.
getId
();
if
(
id
>=
m_Pipelines
.
size
())
{
return
nullptr
;
}
auto
&
pipeline
=
m_Pipelines
[
id
];
return
pipeline
.
m_handle
;
}
vk
::
PipelineLayout
ComputePipelineManager
::
getVkPipelineLayout
(
const
ComputePipelineHandle
&
handle
)
const
{
const
uint64_t
id
=
handle
.
getId
();
if
(
id
>=
m_Pipelines
.
size
())
{
return
nullptr
;
}
auto
&
pipeline
=
m_Pipelines
[
id
];
return
pipeline
.
m_layout
;
}
ComputePipelineHandle
ComputePipelineManager
::
createComputePipeline
(
const
ShaderProgram
&
shaderProgram
,
...
...
@@ -23,7 +48,7 @@ namespace vkcv {
// Temporally handing over the Shader Program instead of a pipeline config
vk
::
ShaderModule
computeModule
{};
if
(
createShaderModule
(
computeModule
,
shaderProgram
,
ShaderStage
::
COMPUTE
)
!=
vk
::
Result
::
eSuccess
)
return
PipelineHandle
();
return
Compute
PipelineHandle
();
vk
::
PipelineShaderStageCreateInfo
pipelineComputeShaderStageInfo
(
{},
...
...
@@ -46,7 +71,7 @@ namespace vkcv {
if
(
m_Device
.
createPipelineLayout
(
&
pipelineLayoutCreateInfo
,
nullptr
,
&
vkPipelineLayout
)
!=
vk
::
Result
::
eSuccess
)
{
m_Device
.
destroy
(
computeModule
);
return
PipelineHandle
();
return
Compute
PipelineHandle
();
}
vk
::
ComputePipelineCreateInfo
computePipelineCreateInfo
{};
...
...
@@ -57,7 +82,7 @@ namespace vkcv {
if
(
m_Device
.
createComputePipelines
(
nullptr
,
1
,
&
computePipelineCreateInfo
,
nullptr
,
&
vkPipeline
)
!=
vk
::
Result
::
eSuccess
)
{
m_Device
.
destroy
(
computeModule
);
return
PipelineHandle
();
return
Compute
PipelineHandle
();
}
m_Device
.
destroy
(
computeModule
);
...
...
@@ -65,10 +90,9 @@ namespace vkcv {
const
uint64_t
id
=
m_Pipelines
.
size
();
m_Pipelines
.
push_back
({
vkPipeline
,
vkPipelineLayout
,
PipelineConfig
()});
return
PipelineHandle
(
id
,
[
&
](
uint64_t
id
)
{
destroyPipelineById
(
id
);
});
return
Compute
PipelineHandle
(
id
,
[
&
](
uint64_t
id
)
{
destroyPipelineById
(
id
);
});
}
void
vkcv
::
ComputePipelineManager
::
destroyPipelineById
(
uint64_t
id
)
{
if
(
id
>=
m_Pipelines
.
size
())
{
return
;
...
...
@@ -93,5 +117,4 @@ namespace vkcv {
vk
::
ShaderModuleCreateInfo
moduleInfo
({},
code
.
size
(),
reinterpret_cast
<
uint32_t
*>
(
code
.
data
()));
return
m_Device
.
createShaderModule
(
&
moduleInfo
,
nullptr
,
&
module
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/vkcv/ComputePipelineManager.hpp
+
23
−
8
View file @
aed76227
#pragma once
#include
<vulkan/vulkan.hpp>
#include
<vector>
#include
"vkcv/Handles.hpp"
#include
"PassManager.hpp"
/**
*
* @authors Mark Mints
* @authors Mark Mints
* @file src/vkcv/ComputePipelineManager.hpp
* @brief Creation and handling of Compute Pipelines
*/
namespace
vkcv
{
#include
<vulkan/vulkan.hpp>
#include
<vector>
#include
"vkcv/Handles.hpp"
namespace
vkcv
{
class
ComputePipelineManager
{
...
...
@@ -26,6 +26,22 @@ namespace vkcv {
ComputePipelineManager
&
operator
=
(
const
ComputePipelineManager
&
other
)
=
delete
;
// copy-assign op
ComputePipelineManager
&
operator
=
(
ComputePipelineManager
&&
other
)
=
delete
;
// move-assign op
/**
* Returns a vk::Pipeline object by handle.
* @param handle Directing to the requested pipeline.
* @return vk::Pipeline.
*/
[[
nodiscard
]]
vk
::
Pipeline
getVkPipeline
(
const
ComputePipelineHandle
&
handle
)
const
;
/**
* Returns a vk::PipelineLayout object by handle.
* @param handle Directing to the requested pipeline.
* @return vk::PipelineLayout.
*/
[[
nodiscard
]]
vk
::
PipelineLayout
getVkPipelineLayout
(
const
ComputePipelineHandle
&
handle
)
const
;
ComputePipelineHandle
createComputePipeline
(
const
ShaderProgram
&
shaderProgram
,
const
std
::
vector
<
vk
::
DescriptorSetLayout
>&
descriptorSetLayouts
);
...
...
@@ -42,7 +58,6 @@ namespace vkcv {
void
destroyPipelineById
(
uint64_t
id
);
// TODO: Move to ComputePipelineManager
vk
::
Result
createShaderModule
(
vk
::
ShaderModule
&
module
,
const
ShaderProgram
&
shaderProgram
,
ShaderStage
stage
);
};
...
...
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