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
746db64c
Verified
Commit
746db64c
authored
8 months ago
by
Tobias Frisch
Browse files
Options
Downloads
Patches
Plain Diff
Fix loading layout bindings from shaders
Signed-off-by:
Tobias Frisch
<
tfrisch@uni-koblenz.de
>
parent
036a31e7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
projects/first_mesh/src/main.cpp
+3
-5
3 additions, 5 deletions
projects/first_mesh/src/main.cpp
src/vkcv/DescriptorSetManager.cpp
+42
-13
42 additions, 13 deletions
src/vkcv/DescriptorSetManager.cpp
src/vkcv/ShaderProgram.cpp
+0
-5
0 additions, 5 deletions
src/vkcv/ShaderProgram.cpp
with
45 additions
and
23 deletions
projects/first_mesh/src/main.cpp
+
3
−
5
View file @
746db64c
...
@@ -53,17 +53,15 @@ int main(int argc, const char** argv) {
...
@@ -53,17 +53,15 @@ int main(int argc, const char** argv) {
// recreate copies of the bindings and the handles (to check whether they are properly reused instead of actually recreated)
// recreate copies of the bindings and the handles (to check whether they are properly reused instead of actually recreated)
const
vkcv
::
DescriptorBindings
&
set0Bindings
=
firstMeshProgram
.
getReflectedDescriptors
().
at
(
0
);
const
vkcv
::
DescriptorBindings
&
set0Bindings
=
firstMeshProgram
.
getReflectedDescriptors
().
at
(
0
);
vkcv
::
DescriptorSetLayoutHandle
setLayoutHandle
=
core
.
createDescriptorSetLayout
(
set0Bindings
);
vkcv
::
DescriptorSetLayoutHandle
descriptorSetLayout
=
core
.
createDescriptorSetLayout
(
set0Bindings
);
vkcv
::
DescriptorSetLayoutHandle
setLayoutHandleCopy
=
core
.
createDescriptorSetLayout
(
set0Bindings
);
vkcv
::
DescriptorSetHandle
descriptorSet
=
core
.
createDescriptorSet
(
descriptorSetLayout
);
vkcv
::
DescriptorSetHandle
descriptorSet
=
core
.
createDescriptorSet
(
setLayoutHandle
);
vkcv
::
GraphicsPipelineHandle
firstMeshPipeline
=
core
.
createGraphicsPipeline
(
vkcv
::
GraphicsPipelineHandle
firstMeshPipeline
=
core
.
createGraphicsPipeline
(
vkcv
::
GraphicsPipelineConfig
(
vkcv
::
GraphicsPipelineConfig
(
firstMeshProgram
,
firstMeshProgram
,
firstMeshPass
,
firstMeshPass
,
{
firstMeshLayout
},
{
firstMeshLayout
},
{
s
etLayout
Handle
}
{
descriptorS
etLayout
}
)
)
);
);
...
...
This diff is collapsed.
Click to expand it.
src/vkcv/DescriptorSetManager.cpp
+
42
−
13
View file @
746db64c
...
@@ -22,19 +22,27 @@ namespace vkcv {
...
@@ -22,19 +22,27 @@ namespace vkcv {
*/
*/
m_PoolSizes
.
clear
();
m_PoolSizes
.
clear
();
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eSampler
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eSampler
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eCombinedImageSampler
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eSampledImage
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eSampledImage
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageImage
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eUniformTexelBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageTexelBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eUniformBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eUniformBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageBuffer
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eUniformBufferDynamic
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eUniformBufferDynamic
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageBufferDynamic
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eStorageBufferDynamic
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eInputAttachment
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eInlineUniformBlock
,
1000
);
if
(
core
.
getContext
().
getFeatureManager
().
isExtensionActive
(
VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME
))
{
if
(
core
.
getContext
().
getFeatureManager
().
isExtensionActive
(
VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME
))
{
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eAccelerationStructureKHR
,
1000
);
m_PoolSizes
.
emplace_back
(
vk
::
DescriptorType
::
eAccelerationStructureKHR
,
1000
);
}
}
m_PoolInfo
=
vk
::
DescriptorPoolCreateInfo
(
m_PoolInfo
=
vk
::
DescriptorPoolCreateInfo
(
vk
::
DescriptorPoolCreateFlagBits
::
eFreeDescriptorSet
,
1000
,
vk
::
DescriptorPoolCreateFlagBits
::
eFreeDescriptorSet
,
static_cast
<
uint32_t
>
(
m_PoolSizes
.
size
()),
m_PoolSizes
.
data
()
1000
,
static_cast
<
uint32_t
>
(
m_PoolSizes
.
size
()),
m_PoolSizes
.
data
()
);
);
return
allocateDescriptorPool
();
return
allocateDescriptorPool
();
...
@@ -50,11 +58,16 @@ namespace vkcv {
...
@@ -50,11 +58,16 @@ namespace vkcv {
}
}
void
DescriptorSetManager
::
destroyById
(
uint64_t
id
)
{
void
DescriptorSetManager
::
destroyById
(
uint64_t
id
)
{
const
auto
&
device
=
getCore
().
getContext
().
getDevice
();
auto
&
set
=
getById
(
id
);
auto
&
set
=
getById
(
id
);
if
(
set
.
vulkanHandle
)
{
if
(
set
.
vulkanHandle
)
{
getCore
().
getContext
().
getDevice
().
freeDescriptorSets
(
m_Pools
[
set
.
poolIndex
],
1
,
device
.
freeDescriptorSets
(
&
(
set
.
vulkanHandle
));
m_Pools
[
set
.
poolIndex
],
1
,
&
(
set
.
vulkanHandle
)
);
set
.
vulkanHandle
=
nullptr
;
set
.
vulkanHandle
=
nullptr
;
}
}
...
@@ -62,8 +75,10 @@ namespace vkcv {
...
@@ -62,8 +75,10 @@ namespace vkcv {
}
}
bool
DescriptorSetManager
::
allocateDescriptorPool
()
{
bool
DescriptorSetManager
::
allocateDescriptorPool
()
{
const
auto
&
device
=
getCore
().
getContext
().
getDevice
();
vk
::
DescriptorPool
pool
;
vk
::
DescriptorPool
pool
;
if
(
getCore
().
getContext
().
getD
evice
()
.
createDescriptorPool
(
&
m_PoolInfo
,
nullptr
,
&
pool
)
if
(
d
evice
.
createDescriptorPool
(
&
m_PoolInfo
,
nullptr
,
&
pool
)
!=
vk
::
Result
::
eSuccess
)
{
!=
vk
::
Result
::
eSuccess
)
{
vkcv_log
(
LogLevel
::
WARNING
,
"Failed to allocate descriptor pool"
);
vkcv_log
(
LogLevel
::
WARNING
,
"Failed to allocate descriptor pool"
);
return
false
;
return
false
;
...
@@ -77,11 +92,13 @@ namespace vkcv {
...
@@ -77,11 +92,13 @@ namespace vkcv {
HandleManager
<
DescriptorSetEntry
,
DescriptorSetHandle
>
()
{}
HandleManager
<
DescriptorSetEntry
,
DescriptorSetHandle
>
()
{}
DescriptorSetManager
::~
DescriptorSetManager
()
noexcept
{
DescriptorSetManager
::~
DescriptorSetManager
()
noexcept
{
const
auto
&
device
=
getCore
().
getContext
().
getDevice
();
clear
();
clear
();
for
(
const
auto
&
pool
:
m_Pools
)
{
for
(
const
auto
&
pool
:
m_Pools
)
{
if
(
pool
)
{
if
(
pool
)
{
getCore
().
getContext
().
getD
evice
()
.
destroy
(
pool
);
d
evice
.
destroy
(
pool
);
}
}
}
}
}
}
...
@@ -90,9 +107,15 @@ namespace vkcv {
...
@@ -90,9 +107,15 @@ namespace vkcv {
DescriptorSetManager
::
createDescriptorSet
(
const
DescriptorSetLayoutHandle
&
layout
)
{
DescriptorSetManager
::
createDescriptorSet
(
const
DescriptorSetLayoutHandle
&
layout
)
{
// create and allocate the set based on the layout provided
// create and allocate the set based on the layout provided
const
auto
&
setLayout
=
m_DescriptorSetLayoutManager
->
getDescriptorSetLayout
(
layout
);
const
auto
&
setLayout
=
m_DescriptorSetLayoutManager
->
getDescriptorSetLayout
(
layout
);
const
auto
&
device
=
getCore
().
getContext
().
getDevice
();
vk
::
DescriptorSet
vulkanHandle
;
vk
::
DescriptorSet
vulkanHandle
;
vk
::
DescriptorSetAllocateInfo
allocInfo
(
m_Pools
.
back
(),
1
,
&
setLayout
.
vulkanHandle
);
vk
::
DescriptorSetAllocateInfo
allocInfo
(
m_Pools
.
back
(),
1
,
&
setLayout
.
vulkanHandle
);
uint32_t
sumVariableDescriptorCounts
=
0
;
uint32_t
sumVariableDescriptorCounts
=
0
;
for
(
auto
bindingElem
:
setLayout
.
descriptorBindings
)
{
for
(
auto
bindingElem
:
setLayout
.
descriptorBindings
)
{
...
@@ -109,15 +132,21 @@ namespace vkcv {
...
@@ -109,15 +132,21 @@ namespace vkcv {
allocInfo
.
setPNext
(
&
variableAllocInfo
);
allocInfo
.
setPNext
(
&
variableAllocInfo
);
}
}
auto
result
=
auto
result
=
device
.
allocateDescriptorSets
(
getCore
().
getContext
().
getDevice
().
allocateDescriptorSets
(
&
allocInfo
,
&
vulkanHandle
);
&
allocInfo
,
&
vulkanHandle
);
if
(
result
!=
vk
::
Result
::
eSuccess
)
{
if
(
result
!=
vk
::
Result
::
eSuccess
)
{
// create a new descriptor pool if the previous one ran out of memory
// create a new descriptor pool if the previous one ran out of memory
if
(
result
==
vk
::
Result
::
eErrorOutOfPoolMemory
)
{
if
(
(
result
==
vk
::
Result
::
eErrorOutOfPoolMemory
)
&&
allocateDescriptorPool
()
;
(
allocateDescriptorPool
()
))
{
allocInfo
.
setDescriptorPool
(
m_Pools
.
back
());
allocInfo
.
setDescriptorPool
(
m_Pools
.
back
());
result
=
getCore
().
getContext
().
getDevice
().
allocateDescriptorSets
(
&
allocInfo
,
&
vulkanHandle
);
result
=
device
.
allocateDescriptorSets
(
&
allocInfo
,
&
vulkanHandle
);
}
}
if
(
result
!=
vk
::
Result
::
eSuccess
)
{
if
(
result
!=
vk
::
Result
::
eSuccess
)
{
...
...
This diff is collapsed.
Click to expand it.
src/vkcv/ShaderProgram.cpp
+
0
−
5
View file @
746db64c
...
@@ -123,7 +123,6 @@ namespace vkcv {
...
@@ -123,7 +123,6 @@ namespace vkcv {
bool
variableCount
=
false
;
bool
variableCount
=
false
;
// query whether reflected resources are qualified as one-dimensional array
// query whether reflected resources are qualified as one-dimensional array
if
(
type
.
array_size_literal
[
0
])
{
if
(
type
.
array_size_literal
[
0
])
{
descriptorCount
=
type
.
array
[
0
];
if
(
type
.
array
[
0
]
==
0
)
if
(
type
.
array
[
0
]
==
0
)
variableCount
=
true
;
variableCount
=
true
;
}
}
...
@@ -157,7 +156,6 @@ namespace vkcv {
...
@@ -157,7 +156,6 @@ namespace vkcv {
bool
variableCount
=
false
;
bool
variableCount
=
false
;
// query whether reflected resources are qualified as one-dimensional array
// query whether reflected resources are qualified as one-dimensional array
if
(
type
.
array_size_literal
[
0
])
{
if
(
type
.
array_size_literal
[
0
])
{
descriptorCount
=
type
.
array
[
0
];
if
(
type
.
array
[
0
]
==
0
)
if
(
type
.
array
[
0
]
==
0
)
variableCount
=
true
;
variableCount
=
true
;
}
}
...
@@ -191,7 +189,6 @@ namespace vkcv {
...
@@ -191,7 +189,6 @@ namespace vkcv {
bool
variableCount
=
false
;
bool
variableCount
=
false
;
// query whether reflected resources are qualified as one-dimensional array
// query whether reflected resources are qualified as one-dimensional array
if
(
type
.
array_size_literal
[
0
])
{
if
(
type
.
array_size_literal
[
0
])
{
descriptorCount
=
type
.
array
[
0
];
if
(
type
.
array
[
0
]
==
0
)
if
(
type
.
array
[
0
]
==
0
)
variableCount
=
true
;
variableCount
=
true
;
}
}
...
@@ -224,7 +221,6 @@ namespace vkcv {
...
@@ -224,7 +221,6 @@ namespace vkcv {
bool
variableCount
=
false
;
bool
variableCount
=
false
;
// query whether reflected resources are qualified as one-dimensional array
// query whether reflected resources are qualified as one-dimensional array
if
(
type
.
array_size_literal
[
0
])
{
if
(
type
.
array_size_literal
[
0
])
{
descriptorCount
=
type
.
array
[
0
];
if
(
type
.
array
[
0
]
==
0
)
if
(
type
.
array
[
0
]
==
0
)
variableCount
=
true
;
variableCount
=
true
;
}
}
...
@@ -258,7 +254,6 @@ namespace vkcv {
...
@@ -258,7 +254,6 @@ namespace vkcv {
bool
variableCount
=
false
;
bool
variableCount
=
false
;
// query whether reflected resources are qualified as one-dimensional array
// query whether reflected resources are qualified as one-dimensional array
if
(
type
.
array_size_literal
[
0
])
{
if
(
type
.
array_size_literal
[
0
])
{
descriptorCount
=
type
.
array
[
0
];
if
(
type
.
array
[
0
]
==
0
)
if
(
type
.
array
[
0
]
==
0
)
variableCount
=
true
;
variableCount
=
true
;
}
}
...
...
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