Fixed SSAO flickering when TAA is off #744

This commit is contained in:
Robert Beckebans 2023-02-22 09:48:00 +01:00
parent abb3e12d39
commit c1fdd0cffb
6 changed files with 53 additions and 14 deletions

View file

@ -37,10 +37,10 @@ If you have questions concerning this license or the applicable additional terms
#if defined( USE_NVRHI )
#include <nvrhi/nvrhi.h>
#if defined( USE_AMD_ALLOCATOR )
#include <nvrhi/vulkan.h>
#include "vk_mem_alloc.h"
#endif
#if defined( USE_AMD_ALLOCATOR )
#include <nvrhi/vulkan.h>
#include "vk_mem_alloc.h"
#endif
#endif
enum bufferMapType_t
@ -151,7 +151,7 @@ protected:
nvrhi::BufferHandle bufferHandle;
void* buffer;
idStr debugName;
#if defined( USE_AMD_ALLOCATOR )
VkBuffer vkBuffer;
VmaAllocation allocation;

View file

@ -76,35 +76,55 @@ vk::BufferUsageFlags pickBufferUsage( const nvrhi::BufferDesc& desc )
vk::BufferUsageFlagBits::eTransferDst;
if( desc.isVertexBuffer )
{
usageFlags |= vk::BufferUsageFlagBits::eVertexBuffer;
}
if( desc.isIndexBuffer )
{
usageFlags |= vk::BufferUsageFlagBits::eIndexBuffer;
}
if( desc.isDrawIndirectArgs )
{
usageFlags |= vk::BufferUsageFlagBits::eIndirectBuffer;
}
if( desc.isConstantBuffer )
{
usageFlags |= vk::BufferUsageFlagBits::eUniformBuffer;
}
if( desc.structStride != 0 || desc.canHaveUAVs || desc.canHaveRawViews )
{
usageFlags |= vk::BufferUsageFlagBits::eStorageBuffer;
}
if( desc.canHaveTypedViews )
{
usageFlags |= vk::BufferUsageFlagBits::eUniformTexelBuffer;
}
if( desc.canHaveTypedViews && desc.canHaveUAVs )
{
usageFlags |= vk::BufferUsageFlagBits::eStorageTexelBuffer;
}
if( desc.isAccelStructBuildInput )
{
usageFlags |= vk::BufferUsageFlagBits::eAccelerationStructureBuildInputReadOnlyKHR;
}
if( desc.isAccelStructStorage )
{
usageFlags |= vk::BufferUsageFlagBits::eAccelerationStructureStorageKHR;
}
if( deviceManager->IsVulkanDeviceExtensionEnabled( VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME ) )
{
usageFlags |= vk::BufferUsageFlagBits::eShaderDeviceAddress;
}
return usageFlags;
}
#endif

View file

@ -96,10 +96,14 @@ vk::ImageUsageFlags pickImageUsage( const nvrhi::TextureDesc& desc )
}
if( desc.isUAV )
{
usageFlags |= vk::ImageUsageFlagBits::eStorage;
}
if( desc.isShadingRateSurface )
{
usageFlags |= vk::ImageUsageFlagBits::eFragmentShadingRateAttachmentKHR;
}
return usageFlags;
}
@ -113,12 +117,12 @@ idImage::idImage
idImage::idImage( const char* name ) : imgName( name )
{
texture.Reset();
#if defined( USE_AMD_ALLOCATOR )
image = VK_NULL_HANDLE;
allocation = NULL;
#endif
generatorFunction = NULL;
filter = TF_DEFAULT;
repeat = TR_REPEAT;

View file

@ -255,6 +255,7 @@ void SsaoPass::Render(
// TODO required and remove this by fixing the shaders
renderProgManager.BindShader_TextureVertexColor();
renderProgManager.CommitConstantBuffer( commandList, true );
SsaoConstants ssaoConstants = {};

View file

@ -2091,6 +2091,20 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
renderLog.OpenMainBlock( fillGbuffer ? MRB_FILL_GEOMETRY_BUFFER : MRB_AMBIENT_PASS );
renderLog.OpenBlock( fillGbuffer ? "Fill_GeometryBuffer" : "Render_AmbientPass", colorBlue );
// make sure rpWindowCoord is set even without post processing surfaces in the view
int x = viewDef->viewport.x1;
int y = viewDef->viewport.y1;
int w = viewDef->viewport.x2 - viewDef->viewport.x1 + 1;
int h = viewDef->viewport.y2 - viewDef->viewport.y1 + 1;
// window coord to 0.0 to 1.0 conversion
float windowCoordParm[4];
windowCoordParm[0] = 1.0f / w;
windowCoordParm[1] = 1.0f / h;
windowCoordParm[2] = w;
windowCoordParm[3] = h;
renderProgManager.SetUniformValue( RENDERPARM_WINDOWCOORD, windowCoordParm ); // rpWindowCoord
if( fillGbuffer )
{
commandList->clearTextureFloat( globalImages->gbufferNormalsRoughnessImage->GetTextureHandle(), nvrhi::AllSubresources, nvrhi::Color( 0.f ) );

View file

@ -39,14 +39,14 @@
#include <nvrhi/validation.h>
#if defined( USE_AMD_ALLOCATOR )
#define VMA_IMPLEMENTATION
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#include "vk_mem_alloc.h"
#define VMA_IMPLEMENTATION
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#include "vk_mem_alloc.h"
VmaAllocator m_VmaAllocator = nullptr;
VmaAllocator m_VmaAllocator = nullptr;
idCVar r_vmaDeviceLocalMemoryMB( "r_vmaDeviceLocalMemoryMB", "256", CVAR_INTEGER | CVAR_INIT, "Size of VMA allocation block for gpu memory." );
idCVar r_vmaDeviceLocalMemoryMB( "r_vmaDeviceLocalMemoryMB", "256", CVAR_INTEGER | CVAR_INIT, "Size of VMA allocation block for gpu memory." );
#endif
// Define the Vulkan dynamic dispatcher - this needs to occur in exactly one cpp file in the program.