Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: native FSR 3 sharpening #580

Merged
merged 1 commit into from
Oct 1, 2024
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
2 changes: 1 addition & 1 deletion extern/FidelityFX-SDK
Submodule FidelityFX-SDK updated 39 files
+46 −8 sdk/include/FidelityFX/gpu/ffx_common_types.h
+7 −7 sdk/include/FidelityFX/gpu/ffx_core.h
+19 −19 sdk/include/FidelityFX/gpu/ffx_core_cpu.h
+169 −43 sdk/include/FidelityFX/gpu/ffx_core_glsl.h
+135 −183 sdk/include/FidelityFX/gpu/ffx_core_gpu_common.h
+35 −33 sdk/include/FidelityFX/gpu/ffx_core_gpu_common_half.h
+293 −47 sdk/include/FidelityFX/gpu/ffx_core_hlsl.h
+14 −19 sdk/include/FidelityFX/gpu/ffx_core_portability.h
+28 −28 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1.h
+49 −59 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1_callbacks_glsl.h
+50 −61 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1_callbacks_hlsl.h
+7 −7 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1_easu.h
+7 −7 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1_rcas.h
+7 −7 sdk/include/FidelityFX/gpu/fsr1/ffx_fsr1_resources.h
+8 −8 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_accumulate.h
+9 −11 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_callbacks_glsl.h
+38 −19 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_callbacks_hlsl.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_common.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_compute_luminance_pyramid.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_depth_clip.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_lock.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_postprocess_lock_status.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_rcas.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_reproject.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_resources.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_sample.h
+7 −7 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_tcr_autogen.h
+7 −11 sdk/include/FidelityFX/gpu/fsr2/ffx_fsr2_upsample.h
+7 −8 sdk/include/FidelityFX/gpu/fsr3/ffx_fsr3_callbacks_hlsl.h
+7 −7 sdk/include/FidelityFX/gpu/fsr3/ffx_fsr3_common.h
+10 −24 sdk/include/FidelityFX/gpu/fsr3/ffx_fsr3_resources.h
+1 −1 sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_rcas.h
+14 −14 sdk/include/FidelityFX/host/ffx_fsr1.h
+9 −9 sdk/include/FidelityFX/host/ffx_fsr2.h
+1 −1 sdk/src/backends/dx11/ffx_dx11.cpp
+7 −7 sdk/src/backends/dx12/shaders/fsr1/ffx_fsr1_easu_pass.hlsl
+7 −7 sdk/src/backends/dx12/shaders/fsr1/ffx_fsr1_rcas_pass.hlsl
+0 −3 sdk/src/components/fsr3/ffx_fsr3.cpp
5 changes: 3 additions & 2 deletions src/FidelityFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void FidelityFX::CreateFSRResources()
contextDescription.backBufferFormat = FFX_SURFACE_FORMAT_R8G8B8A8_UNORM;

contextDescription.backendInterfaceUpscaling = fsrInterface;
contextDescription.backendInterfaceFrameInterpolation = fsrInterface;

if (ffxFsr3ContextCreate(&fsrContext, &contextDescription) != FFX_OK)
logger::critical("[FidelityFX] Failed to initialize FSR3 context!");
Expand Down Expand Up @@ -110,13 +109,15 @@ void FidelityFX::Upscale(Texture2D* a_color)
dispatchParameters.cameraNear = cameraNear;

dispatchParameters.enableSharpening = true;
dispatchParameters.sharpness = 0.0f;
dispatchParameters.sharpness = Upscaling::GetSingleton()->settings.sharpness;

dispatchParameters.cameraFovAngleVertical = GetVerticalFOVRad();
dispatchParameters.viewSpaceToMetersFactor = 0.01428222656f;
dispatchParameters.reset = false;
dispatchParameters.preExposure = 1.0f;

dispatchParameters.flags = 0;

FfxErrorCode errorCode = ffxFsr3ContextDispatchUpscale(&fsrContext, &dispatchParameters);
if (errorCode != FFX_OK) {
logger::error("[FidelityFX] Failed to dispatch upscaling!");
Expand Down
42 changes: 22 additions & 20 deletions src/Upscaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,40 +144,42 @@ void Upscaling::Upscale()
else
FidelityFX::GetSingleton()->Upscale(upscalingTempTexture);

context->CopyResource(inputTextureResource, upscalingTempTexture->resource.get());

state->EndPerfEvent();

state->BeginPerfEvent("Sharpening");
if (GetUpscaleMode() != UpscaleMode::kFSR) {
state->BeginPerfEvent("Sharpening");

{
auto dispatchCount = Util::GetScreenDispatchCount(false);
context->CopyResource(inputTextureResource, upscalingTempTexture->resource.get());

{
ID3D11ShaderResourceView* views[1] = { inputTextureSRV };
context->CSSetShaderResources(0, ARRAYSIZE(views), views);
auto dispatchCount = Util::GetScreenDispatchCount(false);

ID3D11UnorderedAccessView* uavs[1] = { upscalingTempTexture->uav.get() };
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
{
ID3D11ShaderResourceView* views[1] = { inputTextureSRV };
context->CSSetShaderResources(0, ARRAYSIZE(views), views);

context->CSSetShader(GetRCASComputeShader(), nullptr, 0);
ID3D11UnorderedAccessView* uavs[1] = { upscalingTempTexture->uav.get() };
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);

context->Dispatch(dispatchCount.x, dispatchCount.y, 1);
}
context->CSSetShader(GetRCASComputeShader(), nullptr, 0);

ID3D11ShaderResourceView* views[1] = { nullptr };
context->CSSetShaderResources(0, ARRAYSIZE(views), views);
context->Dispatch(dispatchCount.x, dispatchCount.y, 1);
}

ID3D11UnorderedAccessView* uavs[1] = { nullptr };
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
ID3D11ShaderResourceView* views[1] = { nullptr };
context->CSSetShaderResources(0, ARRAYSIZE(views), views);

ID3D11ComputeShader* shader = nullptr;
context->CSSetShader(shader, nullptr, 0);
ID3D11UnorderedAccessView* uavs[1] = { nullptr };
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);

ID3D11ComputeShader* shader = nullptr;
context->CSSetShader(shader, nullptr, 0);
}

state->EndPerfEvent();
}

context->CopyResource(outputTextureResource, upscalingTempTexture->resource.get());

state->EndPerfEvent();
}

void Upscaling::CreateUpscalingResources()
Expand Down
Loading