godot/thirdparty/amd-fsr2/ffx_fsr2.cpp

// This file is part of the FidelityFX SDK.
//
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <algorithm>    // for max used inside SPD CPU code.
#include <cmath>        // for fabs, abs, sinf, sqrt, etc.
#include <string.h>     // for memset
#include <cfloat>       // for FLT_EPSILON
#include "ffx_fsr2.h"
#define FFX_CPU
#include "shaders/ffx_core.h"
#include "shaders/ffx_fsr1.h"
#include "shaders/ffx_spd.h"
#include "shaders/ffx_fsr2_callbacks_hlsl.h"

#include "ffx_fsr2_maximum_bias.h"

#ifdef __clang__
#pragma clang diagnostic ignored "-Wunused-variable"
#endif

// -- GODOT start --
#ifndef _countof
#define _countof(array)
#endif

#ifndef _MSC_VER
#include <wchar.h>
#define wcscpy_s
#endif
// -- GODOT end --

// max queued frames for descriptor management
static const uint32_t FSR2_MAX_QUEUED_FRAMES =;

#include "ffx_fsr2_private.h"

// lists to map shader resource bindpoint name to resource identifier
ResourceBinding;

static const ResourceBinding srvResourceBindingTable[] =;

static const ResourceBinding uavResourceBindingTable[] =;

static const ResourceBinding cbResourceBindingTable[] =;

// Broad structure of the root signature.
Fsr2RootSignatureLayout;

FfxRcasConstants;

Fsr2SpdConstants;

Fsr2GenerateReactiveConstants;

Fsr2GenerateReactiveConstants2;

Fsr2SecondaryUnion;

Fsr2ResourceDescription;

FfxConstantBuffer globalFsr2ConstantBuffers[4] =;

// Lanczos
static float lanczos2(float value)
{}

// Calculate halton number for index and base.
static float halton(int32_t index, int32_t base)
{}

static void fsr2DebugCheckDispatch(FfxFsr2Context_Private* context, const FfxFsr2DispatchDescription* params)
{}

static FfxErrorCode patchResourceBindings(FfxPipelineState* inoutPipeline)
{}


static FfxErrorCode createPipelineStates(FfxFsr2Context_Private* context)
{}

static FfxErrorCode generateReactiveMaskInternal(FfxFsr2Context_Private* contextPrivate, const FfxFsr2DispatchDescription* params);

static FfxErrorCode fsr2Create(FfxFsr2Context_Private* context, const FfxFsr2ContextDescription* contextDescription)
{}

static void fsr2SafeReleasePipeline(FfxFsr2Context_Private* context, FfxPipelineState* pipeline)
{}

static void fsr2SafeReleaseResource(FfxFsr2Context_Private* context, FfxResourceInternal resource)
{}

static void fsr2SafeReleaseDevice(FfxFsr2Context_Private* context, FfxDevice* device)
{}

static FfxErrorCode fsr2Release(FfxFsr2Context_Private* context)
{}

static void setupDeviceDepthToViewSpaceDepthParams(FfxFsr2Context_Private* context, const FfxFsr2DispatchDescription* params)
{}

static void scheduleDispatch(FfxFsr2Context_Private* context, const FfxFsr2DispatchDescription* params, const FfxPipelineState* pipeline, uint32_t dispatchX, uint32_t dispatchY)
{}

static FfxErrorCode fsr2Dispatch(FfxFsr2Context_Private* context, const FfxFsr2DispatchDescription* params)
{}

FfxErrorCode ffxFsr2ContextCreate(FfxFsr2Context* context, const FfxFsr2ContextDescription* contextDescription)
{}

FfxErrorCode ffxFsr2ContextDestroy(FfxFsr2Context* context)
{}

FfxErrorCode ffxFsr2ContextDispatch(FfxFsr2Context* context, const FfxFsr2DispatchDescription* dispatchParams)
{}

float ffxFsr2GetUpscaleRatioFromQualityMode(FfxFsr2QualityMode qualityMode)
{}

FfxErrorCode ffxFsr2GetRenderResolutionFromQualityMode(
    uint32_t* renderWidth,
    uint32_t* renderHeight,
    uint32_t displayWidth,
    uint32_t displayHeight,
    FfxFsr2QualityMode qualityMode)
{}

FfxErrorCode ffxFsr2ContextEnqueueRefreshPipelineRequest(FfxFsr2Context* context)
{}

int32_t ffxFsr2GetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth)
{}

FfxErrorCode ffxFsr2GetJitterOffset(float* outX, float* outY, int32_t index, int32_t phaseCount)
{}

FFX_API bool ffxFsr2ResourceIsNull(FfxResource resource)
{}

FfxErrorCode ffxFsr2ContextGenerateReactiveMask(FfxFsr2Context* context, const FfxFsr2GenerateReactiveDescription* params)
{}

static FfxErrorCode generateReactiveMaskInternal(FfxFsr2Context_Private* contextPrivate, const FfxFsr2DispatchDescription* params)
{}