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
8b5408f5
Commit
8b5408f5
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#82
] Compute Lens Flare features at lower resolution and upscample
parent
ab38fd00
No related branches found
No related tags found
1 merge request
!70
Resolve "Voxel cone tracing"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/voxelization/src/BloomAndFlares.cpp
+50
-5
50 additions, 5 deletions
projects/voxelization/src/BloomAndFlares.cpp
projects/voxelization/src/BloomAndFlares.hpp
+1
-0
1 addition, 0 deletions
projects/voxelization/src/BloomAndFlares.hpp
with
51 additions
and
5 deletions
projects/voxelization/src/BloomAndFlares.cpp
+
50
−
5
View file @
8b5408f5
...
@@ -16,7 +16,7 @@ BloomAndFlares::BloomAndFlares(
...
@@ -16,7 +16,7 @@ BloomAndFlares::BloomAndFlares(
vkcv
::
SamplerMipmapMode
::
LINEAR
,
vkcv
::
SamplerMipmapMode
::
LINEAR
,
vkcv
::
SamplerAddressMode
::
CLAMP_TO_EDGE
)),
vkcv
::
SamplerAddressMode
::
CLAMP_TO_EDGE
)),
m_Blur
(
p_Core
->
createImage
(
colorBufferFormat
,
width
,
height
,
1
,
true
,
true
,
false
)),
m_Blur
(
p_Core
->
createImage
(
colorBufferFormat
,
width
,
height
,
1
,
true
,
true
,
false
)),
m_LensFeatures
(
p_Core
->
createImage
(
colorBufferFormat
,
width
,
height
,
1
,
fals
e
,
true
,
false
))
m_LensFeatures
(
p_Core
->
createImage
(
colorBufferFormat
,
width
,
height
,
1
,
tru
e
,
true
,
false
))
{
{
vkcv
::
shader
::
GLSLCompiler
compiler
;
vkcv
::
shader
::
GLSLCompiler
compiler
;
...
@@ -49,6 +49,11 @@ BloomAndFlares::BloomAndFlares(
...
@@ -49,6 +49,11 @@ BloomAndFlares::BloomAndFlares(
m_UpsampleDescSets
.
push_back
(
m_UpsampleDescSets
.
push_back
(
p_Core
->
createDescriptorSet
(
usProg
.
getReflectedDescriptors
()[
0
]));
p_Core
->
createDescriptorSet
(
usProg
.
getReflectedDescriptors
()[
0
]));
}
}
for
(
uint32_t
mipLevel
=
0
;
mipLevel
<
m_LensFeatures
.
getMipCount
();
mipLevel
++
)
{
m_UpsampleLensFlareDescSets
.
push_back
(
p_Core
->
createDescriptorSet
(
usProg
.
getReflectedDescriptors
()[
0
]));
}
m_UpsamplePipe
=
p_Core
->
createComputePipeline
(
m_UpsamplePipe
=
p_Core
->
createComputePipeline
(
usProg
,
{
p_Core
->
getDescriptorSet
(
m_UpsampleDescSets
[
0
]).
layout
});
usProg
,
{
p_Core
->
getDescriptorSet
(
m_UpsampleDescSets
[
0
]).
layout
});
...
@@ -197,18 +202,21 @@ void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStr
...
@@ -197,18 +202,21 @@ void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStr
p_Core
->
prepareImageForSampling
(
cmdStream
,
m_Blur
.
getHandle
());
p_Core
->
prepareImageForSampling
(
cmdStream
,
m_Blur
.
getHandle
());
p_Core
->
prepareImageForStorage
(
cmdStream
,
m_LensFeatures
.
getHandle
());
p_Core
->
prepareImageForStorage
(
cmdStream
,
m_LensFeatures
.
getHandle
());
const
uint32_t
targetMip
=
2
;
const
uint32_t
mipLevel
=
std
::
min
(
targetMip
,
m_LensFeatures
.
getMipCount
());
vkcv
::
DescriptorWrites
lensFeatureWrites
;
vkcv
::
DescriptorWrites
lensFeatureWrites
;
lensFeatureWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
m_Blur
.
getHandle
(),
0
)};
lensFeatureWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
m_Blur
.
getHandle
(),
0
)};
lensFeatureWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
m_LinearSampler
)};
lensFeatureWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
m_LinearSampler
)};
lensFeatureWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
2
,
m_LensFeatures
.
getHandle
(),
0
)};
lensFeatureWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
2
,
m_LensFeatures
.
getHandle
(),
mipLevel
)};
p_Core
->
writeDescriptorSet
(
m_LensFlareDescSet
,
lensFeatureWrites
);
p_Core
->
writeDescriptorSet
(
m_LensFlareDescSet
,
lensFeatureWrites
);
auto
dispatchCountX
=
static_cast
<
float
>
(
m_Width
)
/
8.0
f
;
auto
dispatchCountX
=
static_cast
<
float
>
(
m_Width
)
/
8.0
f
;
auto
dispatchCountY
=
static_cast
<
float
>
(
m_Height
)
/
8.0
f
;
auto
dispatchCountY
=
static_cast
<
float
>
(
m_Height
)
/
8.0
f
;
// lens feature generation dispatch
// lens feature generation dispatch
uint32_t
lensFeatureDispatchCount
[
3
]
=
{
uint32_t
lensFeatureDispatchCount
[
3
]
=
{
static_cast
<
uint32_t
>
(
glm
::
ceil
(
dispatchCountX
)),
static_cast
<
uint32_t
>
(
glm
::
ceil
(
dispatchCountX
/
std
::
exp2
(
mipLevel
)
)),
static_cast
<
uint32_t
>
(
glm
::
ceil
(
dispatchCountY
)),
static_cast
<
uint32_t
>
(
glm
::
ceil
(
dispatchCountY
/
std
::
exp2
(
mipLevel
)
)),
1
1
};
};
p_Core
->
recordComputeDispatchToCmdStream
(
p_Core
->
recordComputeDispatchToCmdStream
(
...
@@ -217,6 +225,43 @@ void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStr
...
@@ -217,6 +225,43 @@ void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStr
lensFeatureDispatchCount
,
lensFeatureDispatchCount
,
{
vkcv
::
DescriptorSetUsage
(
0
,
p_Core
->
getDescriptorSet
(
m_LensFlareDescSet
).
vulkanHandle
)},
{
vkcv
::
DescriptorSetUsage
(
0
,
p_Core
->
getDescriptorSet
(
m_LensFlareDescSet
).
vulkanHandle
)},
vkcv
::
PushConstantData
(
nullptr
,
0
));
vkcv
::
PushConstantData
(
nullptr
,
0
));
// upsample dispatch
p_Core
->
prepareImageForStorage
(
cmdStream
,
m_LensFeatures
.
getHandle
());
// upsample dispatch for each mip map
for
(
uint32_t
i
=
mipLevel
;
i
>
0
;
i
--
)
{
// mip descriptor writes
vkcv
::
DescriptorWrites
mipUpsampleWrites
;
mipUpsampleWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
m_LensFeatures
.
getHandle
(),
i
,
true
)
};
mipUpsampleWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
m_LinearSampler
)
};
mipUpsampleWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
2
,
m_LensFeatures
.
getHandle
(),
i
-
1
)
};
p_Core
->
writeDescriptorSet
(
m_UpsampleLensFlareDescSets
[
i
],
mipUpsampleWrites
);
auto
mipDivisor
=
glm
::
pow
(
2.0
f
,
static_cast
<
float
>
(
i
)
-
1.0
f
);
auto
upsampleDispatchX
=
static_cast
<
float
>
(
m_Width
)
/
mipDivisor
;
auto
upsampleDispatchY
=
static_cast
<
float
>
(
m_Height
)
/
mipDivisor
;
upsampleDispatchX
/=
8.0
f
;
upsampleDispatchY
/=
8.0
f
;
const
uint32_t
upsampleDispatchCount
[
3
]
=
{
static_cast
<
uint32_t
>
(
glm
::
ceil
(
upsampleDispatchX
)),
static_cast
<
uint32_t
>
(
glm
::
ceil
(
upsampleDispatchY
)),
1
};
p_Core
->
recordComputeDispatchToCmdStream
(
cmdStream
,
m_UpsamplePipe
,
upsampleDispatchCount
,
{
vkcv
::
DescriptorSetUsage
(
0
,
p_Core
->
getDescriptorSet
(
m_UpsampleLensFlareDescSets
[
i
]).
vulkanHandle
)
},
vkcv
::
PushConstantData
(
nullptr
,
0
)
);
// image barrier between mips
p_Core
->
recordImageMemoryBarrier
(
cmdStream
,
m_LensFeatures
.
getHandle
());
}
}
}
void
BloomAndFlares
::
execCompositePipe
(
const
vkcv
::
CommandStreamHandle
&
cmdStream
,
void
BloomAndFlares
::
execCompositePipe
(
const
vkcv
::
CommandStreamHandle
&
cmdStream
,
...
@@ -268,7 +313,7 @@ void BloomAndFlares::updateImageDimensions(uint32_t width, uint32_t height)
...
@@ -268,7 +313,7 @@ void BloomAndFlares::updateImageDimensions(uint32_t width, uint32_t height)
p_Core
->
getContext
().
getDevice
().
waitIdle
();
p_Core
->
getContext
().
getDevice
().
waitIdle
();
m_Blur
=
p_Core
->
createImage
(
m_ColorBufferFormat
,
m_Width
,
m_Height
,
1
,
true
,
true
,
false
);
m_Blur
=
p_Core
->
createImage
(
m_ColorBufferFormat
,
m_Width
,
m_Height
,
1
,
true
,
true
,
false
);
m_LensFeatures
=
p_Core
->
createImage
(
m_ColorBufferFormat
,
m_Width
,
m_Height
,
1
,
fals
e
,
true
,
false
);
m_LensFeatures
=
p_Core
->
createImage
(
m_ColorBufferFormat
,
m_Width
,
m_Height
,
1
,
tru
e
,
true
,
false
);
}
}
This diff is collapsed.
Click to expand it.
projects/voxelization/src/BloomAndFlares.hpp
+
1
−
0
View file @
8b5408f5
...
@@ -30,6 +30,7 @@ private:
...
@@ -30,6 +30,7 @@ private:
vkcv
::
PipelineHandle
m_UpsamplePipe
;
vkcv
::
PipelineHandle
m_UpsamplePipe
;
std
::
vector
<
vkcv
::
DescriptorSetHandle
>
m_UpsampleDescSets
;
// per mip desc set
std
::
vector
<
vkcv
::
DescriptorSetHandle
>
m_UpsampleDescSets
;
// per mip desc set
std
::
vector
<
vkcv
::
DescriptorSetHandle
>
m_UpsampleLensFlareDescSets
;
// per mip desc set
vkcv
::
PipelineHandle
m_LensFlarePipe
;
vkcv
::
PipelineHandle
m_LensFlarePipe
;
vkcv
::
DescriptorSetHandle
m_LensFlareDescSet
;
vkcv
::
DescriptorSetHandle
m_LensFlareDescSet
;
...
...
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