Skip to content

Commit

Permalink
FXAA: Add ENABLE_FXAA macro if -fxaa is given.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Feb 11, 2024
1 parent dc1ed9a commit 03d6d11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion include/vkrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ class AsyVkRender
bool interlock=false;
bool GPUindexing=false;
bool GPUcompress=false;
bool fxaa=false;

#if defined(DEBUG)
bool hasDebugMarker=false;
Expand Down Expand Up @@ -737,7 +738,7 @@ class AsyVkRender

#pragma region post-process compute stuff
vk::Extent2D postProcessThreadGroupCount;

vk::UniquePipeline postProcessPipeline;
vk::UniquePipelineLayout postProcessPipelineLayout;
vk::UniqueDescriptorSetLayout postProcessDescSetLayout;
Expand Down
24 changes: 18 additions & 6 deletions src/vkrender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ void AsyVkRender::vkrender(const string& prefix, const picture* pic, const strin
vkinitialize=false;

interlock=settings::getSetting<bool>("GPUinterlock");
fxaa=settings::getSetting<bool>("fxaa");

#ifdef HAVE_VULKAN
Aspect=((double) width)/height;
Expand Down Expand Up @@ -1079,6 +1080,12 @@ void AsyVkRender::pickPhysicalDevice()
std::pair<std::uint32_t, vk::SampleCountFlagBits>
AsyVkRender::getMaxMSAASamples( vk::PhysicalDevice & gpu )
{
// FXAA means we disable MSAA
if (settings::getSetting<bool>("fxaa"))
{
return std::make_pair(1, vk::SampleCountFlagBits::e1);
}

vk::PhysicalDeviceProperties props { };

gpu.getProperties( &props );
Expand Down Expand Up @@ -2016,7 +2023,7 @@ void AsyVkRender::createComputeDescriptorSetLayout()
{ 0, vk::DescriptorType::eStorageImage, 1, vk::ShaderStageFlagBits::eCompute },
{ 1, vk::DescriptorType::eStorageImage, 1, vk::ShaderStageFlagBits::eCompute },
};

postProcessDescSetLayout= device->createDescriptorSetLayoutUnique({
{},
VEC_VIEW(postProcessingLayoutBindings)
Expand Down Expand Up @@ -2094,7 +2101,7 @@ void AsyVkRender::createDescriptorPool()
void AsyVkRender::createComputeDescriptorPool()
{
// gpu indexing

std::array<vk::DescriptorPoolSize, 4> poolSizes;

// countBuffer
Expand Down Expand Up @@ -3006,6 +3013,11 @@ void AsyVkRender::modifyShaderOptions(std::vector<std::string>& options, Pipelin
options.emplace_back("LOCALSIZE " + std::to_string(localSize));
options.emplace_back("BLOCKSIZE " + std::to_string(blockSize));
options.emplace_back("ARRAYSIZE " + std::to_string(maxSize));

if (fxaa)
{
options.emplace_back("ENABLE_FXAA");
}
}

template<typename V>
Expand Down Expand Up @@ -4037,7 +4049,7 @@ void AsyVkRender::copyToSwapchainImg(vk::CommandBuffer& cmdBuffer, uint32_t cons
std::vector const imgCopyData{
vk::ImageCopy(layers, vk::Offset3D(0, 0, 0), layers, vk::Offset3D(0, 0, 0), vk::Extent3D(backbufferExtent, 1))
};

cmdBuffer.copyImage(
prePresentationImages[frameIndex].getImage(),
vk::ImageLayout::eTransferSrcOptimal,
Expand Down Expand Up @@ -4100,7 +4112,7 @@ void AsyVkRender::drawFrame()
beginFrameCommands(getFrameCommandBuffer());
drawBuffers(frameObject, imageIndex);
// current immediate target layout: general

// begin postprocessing
vk::ImageSubresourceRange constexpr isr(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1);
std::vector<vk::ImageMemoryBarrier> const beforePostProcessingBarrier {
Expand Down Expand Up @@ -4142,10 +4154,10 @@ void AsyVkRender::drawFrame()
{},
EMPTY_VIEW, EMPTY_VIEW, VEC_VIEW(preCopyBarriers)
);

copyToSwapchainImg(*frameObject.commandBuffer, imageIndex);
// done copying

std::vector<vk::ImageMemoryBarrier> const prePresentationBarrier {
{vk::AccessFlagBits::eTransferWrite,
{},
Expand Down

0 comments on commit 03d6d11

Please sign in to comment.