Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,16 @@ RWTexture2D<float2> MotionVectorOutput : register(u2);

[numthreads(8, 8, 1)] void main(uint3 dispatchID : SV_DispatchThreadID) {
float2 taaMask = TAAMask[dispatchID.xy];

float reactiveMask = taaMask.x * 0.1 + taaMask.y;
float transparencyCompositionMask = NormalsWaterMask[dispatchID.xy].z;

#if defined(DLSS)
ReactiveMask[dispatchID.xy] = reactiveMask;
TransparencyCompositionMask[dispatchID.xy] = transparencyCompositionMask;
#elif defined(FSR)
ReactiveMask[dispatchID.xy] = reactiveMask;
TransparencyCompositionMask[dispatchID.xy] = transparencyCompositionMask;
#else
ReactiveMask[dispatchID.xy] = reactiveMask + transparencyCompositionMask * 0.1;
#endif
float depth = DepthMask[dispatchID.xy];

#if defined(DLSS) || defined(XESS)
float depth = DepthMask[dispatchID.xy];
// Find longest motion vector in 5x5 neighborhood
float2 motionVector = MotionVectorMask[dispatchID.xy];

// Find longest motion vector in 3x3 neighborhood
float2 longestMotionVector = motionVector;
float maxMotionLengthSq = dot(motionVector, motionVector);
#endif

[unroll]
for (int y = -2; y <= 2; y++) {
Expand All @@ -47,6 +36,9 @@ RWTexture2D<float2> MotionVectorOutput : register(u2);

// Take neighbor if it's longer AND closer
if (neighborDepth < depth){
taaMask.x = min(taaMask.x, TAAMask[samplePos].x);

#if defined(DLSS) || defined(XESS)
float2 neighborMotionVector = MotionVectorMask[samplePos];

// Square motion vector for length
Expand All @@ -56,10 +48,21 @@ RWTexture2D<float2> MotionVectorOutput : register(u2);
maxMotionLengthSq = motionLengthSq;
longestMotionVector = neighborMotionVector;
}
#endif
}
}
}

#if defined(DLSS) || defined(XESS)
MotionVectorOutput[dispatchID.xy] = longestMotionVector;
#endif

#if defined(DLSS) || defined(FSR)
float reactiveMask = taaMask.x * 0.1 + taaMask.y;
ReactiveMask[dispatchID.xy] = reactiveMask;
TransparencyCompositionMask[dispatchID.xy] = transparencyCompositionMask;
#else
float reactiveMask = taaMask.x * 0.01 + taaMask.y;
ReactiveMask[dispatchID.xy] = reactiveMask + transparencyCompositionMask * 0.1;
#endif
Comment thread
doodlum marked this conversation as resolved.
}
5 changes: 2 additions & 3 deletions src/Features/Upscaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ void Upscaling::CreateSharedD3D12Device(IDXGIAdapter* a_dxgiAdapter)

void Upscaling::UpdateSharedResources()
{
logger::info("[Upscaling] Updating shared D3D12 resources");
logger::debug("[Upscaling] Updating shared D3D12 resources");

auto currentMethod = GetUpscaleMethod();

Expand Down Expand Up @@ -1007,7 +1007,6 @@ void Upscaling::UpdateSharedResources()

D3D11_TEXTURE2D_DESC texDesc{};
main.texture->GetDesc(&texDesc);
texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;

// Upscaling-specific resources (FSR/XeSS)
if (needsUpscalingResources) {
Expand Down Expand Up @@ -1079,7 +1078,7 @@ void Upscaling::UpdateSharedResources()
copyDepthToSharedBufferPS = nullptr;
}

logger::info("[Upscaling] Shared resource update complete - Upscaling: {}, FSR: {}, FrameGen: {}",
logger::debug("[Upscaling] Shared resource update complete - Upscaling: {}, FSR: {}, FrameGen: {}",
needsUpscalingResources, needsFSRSpecific, needsFrameGenResources);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Features/Upscaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct Upscaling : Feature
uint frameGenerationForceEnable = 0;
uint streamlineLogLevel = 0; // 0=Off, 1=Default, 2=Verbose
uint enableNISSharpening = 1; // 0=Off, 1=On
float nisSharpness = 0.3f; // 0.0 to 1.0
float nisSharpness = 0.15f; // 0.0 to 1.0
};

Settings settings;
Expand Down
3 changes: 0 additions & 3 deletions src/Features/Upscaling/DX12SwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ void DX12SwapChain::CreateInterop()
texDesc11.Format = swapChainDesc.Format;
texDesc11.SampleDesc.Count = 1;
texDesc11.SampleDesc.Quality = 0;
texDesc11.Usage = D3D11_USAGE_DEFAULT;
texDesc11.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
texDesc11.CPUAccessFlags = 0;
texDesc11.MiscFlags = D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;

swapChainBufferWrapped = new WrappedResource(texDesc11, d3d11Device.get(), upscaling.sharedD3D12Device.get());

Expand Down