Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • vulkan2021/vkcv-framework
1 result
Select Git revision
Show changes
Commits on Source (5)
Showing
with 423 additions and 197 deletions
......@@ -41,6 +41,9 @@ set(vkcv_sources
${vkcv_source}/vkcv/BufferManager.hpp
${vkcv_source}/vkcv/BufferManager.cpp
${vkcv_include}/vkcv/ImageConfig.hpp
${vkcv_source}/vkcv/ImageConfig.cpp
${vkcv_include}/vkcv/Image.hpp
${vkcv_source}/vkcv/Image.cpp
......
......@@ -21,6 +21,7 @@
#include "EventFunctionTypes.hpp"
#include "GraphicsPipelineConfig.hpp"
#include "Handles.hpp"
#include "ImageConfig.hpp"
#include "PassConfig.hpp"
#include "PushConstants.hpp"
#include "Result.hpp"
......@@ -318,24 +319,17 @@ namespace vkcv {
SamplerBorderColor borderColor = SamplerBorderColor::INT_ZERO_OPAQUE);
/**
* Creates an #Image with a given format, width, height, depth
* and a lot more optional parameters.
* Creates an #Image with a given format, configuration
* and whether a mipchain should be created.
*
* @param[in] format Image format
* @param[in] width Image width
* @param[in] height Image height
* @param[in] depth Image depth
* @param[in] config Image configuration
* @param[in] createMipChain Flag to create a mip chain
* @param[in] supportStorage Flag whether support storage
* @param[in] supportColorAttachment Flag whether attachment is supported
* @param[in] multisampling Multisampling
* @return Image handle
*/
[[nodiscard]] ImageHandle createImage(vk::Format format, uint32_t width, uint32_t height,
uint32_t depth = 1, bool createMipChain = false,
bool supportStorage = false,
bool supportColorAttachment = false,
Multisampling multisampling = Multisampling::None);
[[nodiscard]] ImageHandle createImage(vk::Format format,
const ImageConfig& config,
bool createMipChain = false);
/**
* @brief Fills the image with given data of a specified size
......@@ -344,8 +338,14 @@ namespace vkcv {
* @param[in] image Image handle
* @param[in] data Image data pointer
* @param[in] size Size of data
*/
void fillImage(const ImageHandle &image, const void* data, size_t size);
* @param[in] firstLayer First image layer
* @param[in] layerCount Image layer count
*/
void fillImage(const ImageHandle &image,
const void* data,
size_t size,
uint32_t firstLayer,
uint32_t layerCount);
/**
* @brief Switches the images layout synchronously if possible.
......
......@@ -10,6 +10,7 @@
#include "BufferTypes.hpp"
#include "Core.hpp"
#include "Handles.hpp"
#include "ImageConfig.hpp"
#include "Multisampling.hpp"
namespace vkcv {
......@@ -111,6 +112,17 @@ namespace vkcv {
* the actual number of copied bytes is min(size, imageDataSize)
*/
void fill(const void* data, size_t size = SIZE_MAX);
/**
* @brief Fills a specific image layer with data of a given
* size in bytes.
*
* @param[in] layer Image layer destination
* @param[in] data Pointer to the source data
* @param[in] size Lower limit of the data size to copy in bytes,
* the actual number of copied bytes is min(size, imageDataSize)
*/
void fillLayer(uint32_t layer, const void* data, size_t size = SIZE_MAX);
/**
* @brief Records mip chain generation to command stream,
......@@ -131,5 +143,10 @@ namespace vkcv {
bool createMipChain = false, bool supportStorage = false,
bool supportColorAttachment = false,
Multisampling multisampling = Multisampling::None);
Image image(Core &core,
vk::Format format,
const ImageConfig &config,
bool createMipChain = false);
} // namespace vkcv
#pragma once
/**
* @authors Tobias Frisch
* @file vkcv/ImageConfig.hpp
* @brief Structure for image configuration.
*/
#include "Multisampling.hpp"
namespace vkcv {
struct ImageConfig {
private:
uint32_t m_width;
uint32_t m_height;
uint32_t m_depth;
bool m_supportStorage;
bool m_supportColorAttachment;
bool m_cubeMapImage;
Multisampling m_msaa;
public:
/**
* Constructor of the image configuration by
* a given resolution.
*
* @param[in] width Image width
* @param[in] height Image height
* @param[in] depth Image depth
*/
ImageConfig(uint32_t width,
uint32_t height,
uint32_t depth = 1);
ImageConfig(const ImageConfig &other) = default;
ImageConfig(ImageConfig&& other) = default;
~ImageConfig() = default;
ImageConfig& operator=(const ImageConfig &other) = default;
ImageConfig& operator=(ImageConfig&& other) = default;
/**
* Return the configured width of the image.
*
* @return Image width
*/
[[nodiscard]]
uint32_t getWidth() const;
/**
* Set configured width of the image.
*
* @param[in] width Image width
*/
void setWidth(uint32_t width);
/**
* Return the configured height of the image.
*
* @return Image height
*/
[[nodiscard]]
uint32_t getHeight() const;
/**
* Set configured height of the image.
*
* @param[in] height Image height
*/
void setHeight(uint32_t height);
/**
* Return the configured depth of the image.
*
* @return Image depth
*/
[[nodiscard]]
uint32_t getDepth() const;
/**
* Set configured depth of the image.
*
* @param[in] depth Image depth
*/
void setDepth(uint32_t depth);
/**
* Return whether the image is configured to
* support storage operations.
*
* @return True, if it supports storage, otherwise false
*/
[[nodiscard]]
bool isSupportingStorage() const;
/**
* Set whether the image is configured to
* support storage operations.
*
* @param[in] supportStorage Support storage
*/
void setSupportingStorage(bool supportStorage);
/**
* Return whether the image is configured to
* support being used as color attachment.
*
* @return True, if it supports color attachment, otherwise false
*/
[[nodiscard]]
bool isSupportingColorAttachment() const;
/**
* Set whether the image is configured to
* support being used as color attachment.
*
* @param[in] supportColorAttachment Support color attachment
*/
void setSupportingColorAttachment(bool supportColorAttachment);
/**
* Return whether the image is configured to
* be a cube map.
*
* @return True, if the image is a cube map, otherwise false
*/
[[nodiscard]]
bool isCubeMapImage() const;
/**
* Set whether the image is configured to
* be a cube map.
*
* @param[in] cubeMapImage Is cube map image
*/
void setCubeMapImage(bool cubeMapImage);
/**
* Return type of multisampling the image
* is configured to use.
*
* @return Multisampling
*/
[[nodiscard]]
Multisampling getMultisampling() const;
/**
* Set the multisampling of the image
* configuration.
*
* @param[in] msaa Multisampling
*/
void setMultisampling(Multisampling msaa);
};
}
......@@ -294,7 +294,7 @@ namespace vkcv::effects {
cmdStream,
m_downsamplePipeline,
dispatch,
{ DescriptorSetUsage(0, mipDescriptorSets[mipLevel]) },
{ useDescriptorSet(0, mipDescriptorSets[mipLevel]) },
PushConstants(0)
);
......@@ -342,7 +342,7 @@ namespace vkcv::effects {
cmdStream,
m_upsamplePipeline,
dispatch,
{ DescriptorSetUsage(0, mipDescriptorSets[mipLevel - 1]) },
{ useDescriptorSet(0, mipDescriptorSets[mipLevel - 1]) },
PushConstants(0)
);
......@@ -388,7 +388,7 @@ namespace vkcv::effects {
cmdStream,
m_lensFlaresPipeline,
dispatch,
{ DescriptorSetUsage(0, m_lensFlaresDescriptorSet) },
{ useDescriptorSet(0, m_lensFlaresDescriptorSet) },
PushConstants(0)
);
}
......@@ -455,7 +455,7 @@ namespace vkcv::effects {
cmdStream,
m_compositePipeline,
dispatch,
{ DescriptorSetUsage(0, m_compositeDescriptorSet) },
{ useDescriptorSet(0, m_compositeDescriptorSet) },
m_advanced? pushConstants : PushConstants(0)
);
}
......@@ -475,15 +475,15 @@ namespace vkcv::effects {
static_cast<float>(m_core.getImageHeight(output)) * 0.5f
));
vkcv::ImageConfig imageConfig (halfWidth, halfHeight);
imageConfig.setSupportingStorage(true);
if ((!m_blurImage) ||
(halfWidth != m_core.getImageWidth(m_blurImage)) ||
(halfHeight != m_core.getImageHeight(m_blurImage))) {
m_blurImage = m_core.createImage(
m_core.getImageFormat(output),
halfWidth,
halfHeight,
1,
true,
imageConfig,
true
);
......@@ -510,10 +510,7 @@ namespace vkcv::effects {
(halfHeight != m_core.getImageHeight(m_flaresImage))) {
m_flaresImage = m_core.createImage(
m_core.getImageFormat(output),
halfWidth,
halfHeight,
1,
true,
imageConfig,
true
);
......
......@@ -274,11 +274,12 @@ namespace vkcv::upscaling {
if ((!m_intermediateImage) ||
(outputWidth != m_core.getImageWidth(m_intermediateImage)) ||
(outputHeight != m_core.getImageHeight(m_intermediateImage))) {
ImageConfig imageConfig (outputWidth, outputHeight);
imageConfig.setSupportingStorage(true);
m_intermediateImage = m_core.createImage(
m_core.getImageFormat(output),
outputWidth, outputHeight,1,
false,
true
imageConfig
);
m_core.prepareImageForStorage(cmdStream, m_intermediateImage);
......@@ -333,7 +334,7 @@ namespace vkcv::upscaling {
cmdStream,
m_easuPipeline,
dispatch,
{DescriptorSetUsage(0, m_easuDescriptorSet, { 0 })},
{ useDescriptorSet(0, m_easuDescriptorSet, { 0 }) },
PushConstants(0)
);
......@@ -353,7 +354,7 @@ namespace vkcv::upscaling {
cmdStream,
m_rcasPipeline,
dispatch,
{DescriptorSetUsage(0,m_rcasDescriptorSet, { 0 })},
{ useDescriptorSet(0,m_rcasDescriptorSet, { 0 }) },
PushConstants(0)
);
......@@ -371,7 +372,7 @@ namespace vkcv::upscaling {
cmdStream,
m_easuPipeline,
dispatch,
{DescriptorSetUsage(0, m_easuDescriptorSet, { 0 })},
{ useDescriptorSet(0, m_easuDescriptorSet, { 0 }) },
PushConstants(0)
);
}
......
......@@ -185,9 +185,7 @@ int main(int argc, const char** argv) {
vkcv::SamplerHandle sampler = vkcv::samplerLinear(core);
vkcv::DescriptorWrites setWrites;
for(uint32_t i = 0; i < 6; i++)
{
for(uint32_t i = 0; i < 6; i++) {
setWrites.writeSampledImage(
1,
texturesArray[i].getHandle(),
......@@ -225,8 +223,7 @@ int main(int argc, const char** argv) {
(swapchainHeight != core.getImageHeight(depthBuffer))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
vkcv::ImageConfig(swapchainWidth, swapchainHeight)
);
}
......
......@@ -331,11 +331,17 @@ int main(int argc, const char **argv) {
std::array<vkcv::ImageHandle, 4> colorBuffers;
for (size_t i = 0; i < colorBuffers.size(); i++) {
vkcv::ImageConfig colorBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
colorBufferConfig.setSupportingStorage(true);
colorBufferConfig.setSupportingColorAttachment(true);
colorBuffers[i] = core.createImage(
colorFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
colorBufferConfig
);
}
......@@ -700,65 +706,60 @@ int main(int argc, const char **argv) {
std::vector<uint32_t> zeroVoxel;
zeroVoxel.resize(voxelWidth * voxelHeight * voxelDepth, 0);
vkcv::ImageConfig voxelImageConfig (
voxelWidth,
voxelHeight,
voxelDepth
);
voxelImageConfig.setSupportingStorage(true);
vkcv::Image voxelRed = vkcv::image(
core,
vk::Format::eR32Uint,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
);
vkcv::Image voxelGreen = vkcv::image(
core,
vk::Format::eR32Uint,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
);
vkcv::Image voxelBlue = vkcv::image(
core,
vk::Format::eR32Uint,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
);
vkcv::Image voxelDensity = vkcv::image(
core,
vk::Format::eR32Uint,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
);
std::array<vkcv::ImageHandle, 2> voxelData {
core.createImage(
vk::Format::eR16G16B16A16Sfloat,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
),
core.createImage(
vk::Format::eR16G16B16A16Sfloat,
voxelWidth,
voxelHeight,
voxelDepth,
false, true
voxelImageConfig
)
};
vkcv::ImageConfig voxelSamplesConfig (
voxelWidth,
voxelHeight
);
voxelImageConfig.setSupportingStorage(true);
vkcv::Image voxelSamples = vkcv::image(
core,
colorFormat,
voxelWidth,
voxelHeight,
1, false, true
voxelSamplesConfig
);
vkcv::SamplerHandle voxelSampler = vkcv::samplerLinear(core, true);
......@@ -934,14 +935,20 @@ int main(int argc, const char **argv) {
continue;
}
for (size_t i = 0; i < colorBuffers.size(); i++) {
if ((core.getImageWidth(colorBuffers[i]) != swapchainWidth) ||
(core.getImageHeight(colorBuffers[i]) != swapchainHeight)) {
colorBuffers[i] = core.createImage(
for (auto& colorBuffer : colorBuffers) {
if ((core.getImageWidth(colorBuffer) != swapchainWidth) ||
(core.getImageHeight(colorBuffer) != swapchainHeight)) {
vkcv::ImageConfig colorBufferConfig (
swapchainWidth,
swapchainHeight
);
colorBufferConfig.setSupportingStorage(true);
colorBufferConfig.setSupportingColorAttachment(true);
colorBuffer = core.createImage(
colorFormat,
swapchainWidth,
swapchainHeight,
1, false, true, true
colorBufferConfig
);
}
}
......
......@@ -117,8 +117,10 @@ int main(int argc, const char** argv) {
(swapchainHeight != core.getImageHeight(depthBuffer))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
}
......
......@@ -103,8 +103,10 @@ int main(int argc, const char** argv) {
(swapchainHeight != core.getImageHeight(depthBuffer))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
}
......
......@@ -150,15 +150,23 @@ int main(int argc, const char** argv) {
vkcv::ImageHandle depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
vkcv::ImageConfig(
swapchainExtent.width,
swapchainExtent.height
)
);
vkcv::ImageConfig colorBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
colorBufferConfig.setSupportingStorage(true);
colorBufferConfig.setSupportingColorAttachment(true);
vkcv::ImageHandle colorBuffer = core.createImage(
colorFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
colorBufferConfig
);
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
......@@ -168,14 +176,22 @@ int main(int argc, const char** argv) {
core.run([&](const vkcv::WindowHandle &windowHandle, double t, double dt,
uint32_t swapchainWidth, uint32_t swapchainHeight) {
if ((swapchainWidth != swapchainExtent.width) || ((swapchainHeight != swapchainExtent.height))) {
depthBuffer = core.createImage(vk::Format::eD32Sfloat, swapchainWidth, swapchainHeight);
if ((swapchainWidth != swapchainExtent.width) ||
((swapchainHeight != swapchainExtent.height))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
colorBufferConfig.setWidth(swapchainWidth);
colorBufferConfig.setHeight(swapchainHeight);
colorBuffer = core.createImage(
colorFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
colorBufferConfig
);
swapchainExtent.width = swapchainWidth;
......
......@@ -301,33 +301,24 @@ bool loadComputePass(vkcv::Core& core, const std::filesystem::path& path, Comput
AppRenderTargets createRenderTargets(vkcv::Core& core, const uint32_t width, const uint32_t height) {
AppRenderTargets targets;
vkcv::ImageConfig depthBufferConfig (width, height);
targets.depthBuffer = core.createImage(
AppConfig::depthBufferFormat,
width,
height,
1,
false
depthBufferConfig
);
vkcv::ImageConfig bufferConfig (width, height);
bufferConfig.setSupportingColorAttachment(true);
targets.colorBuffer = core.createImage(
AppConfig::colorBufferFormat,
width,
height,
1,
false,
false,
true
bufferConfig
);
targets.motionBuffer = core.createImage(
AppConfig::motionBufferFormat,
width,
height,
1,
false,
false,
true
bufferConfig
);
return targets;
......
......@@ -9,51 +9,37 @@ MotionBlurRenderTargets createRenderTargets(const uint32_t width, const uint32_t
// divide and ceil to int
const uint32_t motionMaxWidth = (width + (MotionBlurConfig::maxMotionTileSize - 1)) / MotionBlurConfig::maxMotionTileSize;
const uint32_t motionMaxheight = (height + (MotionBlurConfig::maxMotionTileSize - 1)) / MotionBlurConfig::maxMotionTileSize;
const uint32_t motionMaxHeight = (height + (MotionBlurConfig::maxMotionTileSize - 1)) / MotionBlurConfig::maxMotionTileSize;
vkcv::ImageConfig targetConfig (motionMaxWidth, motionMaxHeight);
targetConfig.setSupportingStorage(true);
targets.motionMax = core.createImage(
MotionBlurConfig::motionVectorTileFormat,
motionMaxWidth,
motionMaxheight,
1,
false,
true
targetConfig
);
targets.motionMaxNeighbourhood = core.createImage(
MotionBlurConfig::motionVectorTileFormat,
motionMaxWidth,
motionMaxheight,
1,
false,
true
targetConfig
);
targets.motionMin = core.createImage(
MotionBlurConfig::motionVectorTileFormat,
motionMaxWidth,
motionMaxheight,
1,
false,
true
targetConfig
);
targets.motionMinNeighbourhood = core.createImage(
MotionBlurConfig::motionVectorTileFormat,
motionMaxWidth,
motionMaxheight,
1,
false,
true
targetConfig
);
vkcv::ImageConfig outputConfig (width, height);
outputConfig.setSupportingStorage(true);
targets.outputColor = core.createImage(
MotionBlurConfig::outputColorFormat,
width,
height,
1,
false,
true
outputConfig
);
return targets;
......
......@@ -528,7 +528,13 @@ int main(int argc, const char** argv) {
if ((!depthBuffer) ||
(swapchainWidth != core.getImageWidth(depthBuffer)) ||
(swapchainHeight != core.getImageHeight(depthBuffer))) {
depthBuffer = core.createImage(vk::Format::eD32Sfloat, swapchainWidth, swapchainHeight);
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
}
cameraManager.update(dt);
......
......@@ -324,8 +324,10 @@ int main(int argc, const char** argv) {
(swapchainHeight != core.getImageHeight(depthBuffer))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
}
......
......@@ -208,11 +208,17 @@ int main(int argc, const char **argv) {
const auto swapchainExtent = core.getSwapchainExtent(window.getSwapchain());
vkcv::ImageConfig colorBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
colorBufferConfig.setSupportingStorage(true);
colorBufferConfig.setSupportingColorAttachment(true);
vkcv::ImageHandle colorBuffer = core.createImage(
colorFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
colorBufferConfig
);
vkcv::effects::BloomAndFlaresEffect bloomAndFlares (core);
......@@ -237,11 +243,12 @@ int main(int argc, const char **argv) {
uint32_t swapchainWidth, uint32_t swapchainHeight) {
if ((core.getImageWidth(colorBuffer) != swapchainWidth) ||
(core.getImageHeight(colorBuffer) != swapchainHeight)) {
colorBufferConfig.setWidth(swapchainWidth);
colorBufferConfig.setHeight(swapchainHeight);
colorBuffer = core.createImage(
colorFormat,
swapchainWidth,
swapchainHeight,
1, false, true, true
colorBufferConfig
);
}
......
......@@ -63,24 +63,23 @@ int main(int argc, const char** argv) {
initialHeight,
true
);
vkcv::ImageConfig imageConfig (
initialWidth,
initialHeight
);
imageConfig.setSupportingStorage(true);
// images
vkcv::ImageHandle outputImage = core.createImage(
vk::Format::eR32G32B32A32Sfloat,
initialWidth,
initialHeight,
1,
false,
true
imageConfig
);
vkcv::ImageHandle meanImage = core.createImage(
vk::Format::eR32G32B32A32Sfloat,
initialWidth,
initialHeight,
1,
false,
true
imageConfig
);
vkcv::shader::GLSLCompiler compiler;
......@@ -248,25 +247,19 @@ int main(int argc, const char** argv) {
core.run([&](const vkcv::WindowHandle &windowHandle, double t, double dt,
uint32_t swapchainWidth, uint32_t swapchainHeight) {
if (swapchainWidth != widthPrevious || swapchainHeight != heightPrevious) {
if ((swapchainWidth != widthPrevious) || (swapchainHeight != heightPrevious)) {
imageConfig.setWidth(swapchainWidth);
imageConfig.setHeight(swapchainHeight);
// resize images
outputImage = core.createImage(
vk::Format::eR32G32B32A32Sfloat,
swapchainWidth,
swapchainHeight,
1,
false,
true
imageConfig
);
meanImage = core.createImage(
vk::Format::eR32G32B32A32Sfloat,
swapchainWidth,
swapchainHeight,
1,
false,
true
imageConfig
);
// update descriptor sets
......
......@@ -101,8 +101,10 @@ int main(int argc, const char** argv) {
((swapchainHeight != core.getImageHeight(depthBuffer)))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
vkcv::ImageConfig(
swapchainWidth,
swapchainHeight
)
);
}
......
......@@ -222,11 +222,17 @@ int main(int argc, const char **argv) {
const auto swapchainExtent = core.getSwapchainExtent(window.getSwapchain());
vkcv::ImageConfig colorBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
colorBufferConfig.setSupportingStorage(true);
colorBufferConfig.setSupportingColorAttachment(true);
vkcv::ImageHandle colorBuffer = core.createImage(
colorFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
colorBufferConfig
);
vkcv::effects::BloomAndFlaresEffect bloomAndFlares (core);
......@@ -245,11 +251,12 @@ int main(int argc, const char **argv) {
uint32_t swapchainWidth, uint32_t swapchainHeight) {
if ((core.getImageWidth(colorBuffer) != swapchainWidth) ||
(core.getImageHeight(colorBuffer) != swapchainHeight)) {
colorBufferConfig.setWidth(swapchainWidth);
colorBufferConfig.setHeight(swapchainHeight);
colorBuffer = core.createImage(
colorFormat,
swapchainWidth,
swapchainHeight,
1, false, true, true
colorBufferConfig
);
}
......
......@@ -387,48 +387,69 @@ int main(int argc, const char** argv) {
skyPipeConfig.setWritingDepth(false);
vkcv::GraphicsPipelineHandle skyPipe = core.createGraphicsPipeline(skyPipeConfig);
vkcv::ImageConfig depthBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
depthBufferConfig.setMultisampling(msaa);
// render targets
vkcv::ImageHandle depthBuffer = core.createImage(
depthBufferFormat,
depthBufferConfig
);
const bool colorBufferRequiresStorage = !usingMsaa;
vkcv::ImageConfig colorBufferConfig (
swapchainExtent.width,
swapchainExtent.height,
1, false, false, false, msaa
swapchainExtent.height
);
colorBufferConfig.setSupportingStorage(colorBufferRequiresStorage);
colorBufferConfig.setSupportingColorAttachment(true);
colorBufferConfig.setMultisampling(msaa);
const bool colorBufferRequiresStorage = !usingMsaa;
vkcv::ImageHandle colorBuffer = core.createImage(
colorBufferFormat,
colorBufferConfig
);
vkcv::ImageConfig resolveBufferConfig (
swapchainExtent.width,
swapchainExtent.height,
1, false, colorBufferRequiresStorage, true, msaa
swapchainExtent.height
);
resolveBufferConfig.setSupportingStorage(true);
resolveBufferConfig.setSupportingColorAttachment(true);
vkcv::ImageHandle resolvedColorBuffer;
if (usingMsaa) {
resolvedColorBuffer = core.createImage(
colorBufferFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true, true
resolveBufferConfig
);
}
else {
} else {
resolvedColorBuffer = colorBuffer;
}
vkcv::ImageConfig swapBufferConfig (
swapchainExtent.width,
swapchainExtent.height
);
swapBufferConfig.setSupportingStorage(true);
vkcv::ImageHandle swapBuffer = core.createImage(
colorBufferFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true
swapBufferConfig
);
vkcv::ImageHandle swapBuffer2 = core.createImage(
colorBufferFormat,
swapchainExtent.width,
swapchainExtent.height,
1, false, true
swapBufferConfig
);
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
......@@ -656,40 +677,48 @@ int main(int argc, const char** argv) {
core.writeDescriptorSet(materialDescriptorSets[i], setWrites);
}
depthBufferConfig.setWidth(fsrWidth);
depthBufferConfig.setHeight(fsrHeight);
depthBuffer = core.createImage(
depthBufferFormat,
fsrWidth, fsrHeight, 1,
false, false, false,
msaa
depthBufferConfig
);
colorBufferConfig.setWidth(fsrWidth);
colorBufferConfig.setHeight(fsrHeight);
colorBuffer = core.createImage(
colorBufferFormat,
fsrWidth, fsrHeight, 1,
false, colorBufferRequiresStorage, true,
msaa
colorBufferConfig
);
if (usingMsaa) {
resolveBufferConfig.setWidth(fsrWidth);
resolveBufferConfig.setHeight(fsrHeight);
resolvedColorBuffer = core.createImage(
colorBufferFormat,
fsrWidth, fsrHeight, 1,
false, true, true
resolveBufferConfig
);
} else {
resolvedColorBuffer = colorBuffer;
}
swapBufferConfig.setWidth(fsrWidth);
swapBufferConfig.setHeight(fsrHeight);
swapBuffer = core.createImage(
colorBufferFormat,
fsrWidth, fsrHeight, 1,
false, true
swapBufferConfig
);
swapBufferConfig.setWidth(swapchainWidth);
swapBufferConfig.setHeight(swapchainHeight);
swapBuffer2 = core.createImage(
colorBufferFormat,
swapchainWidth, swapchainHeight, 1,
false, true
swapBufferConfig
);
}
......@@ -955,8 +984,8 @@ int main(int argc, const char** argv) {
upscaling2.setSharpness(sharpness);
if (ImGui::Button("Reload forward pass")) {
vkcv::ShaderProgram newForwardProgram;
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("assets/shaders/shader.vert"),
[&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
newForwardProgram.addShader(shaderStage, path);
......@@ -973,8 +1002,8 @@ int main(int argc, const char** argv) {
forwardPipeline = newPipeline;
}
}
if (ImGui::Button("Reload tonemapping")) {
vkcv::ShaderProgram newProgram;
compiler.compile(vkcv::ShaderStage::COMPUTE, std::filesystem::path("assets/shaders/tonemapping.comp"),
[&](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
......@@ -990,6 +1019,7 @@ int main(int argc, const char** argv) {
tonemappingPipeline = newPipeline;
}
}
ImGui::End();
}
......