You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.9 KiB
84 lines
2.9 KiB
// Each #kernel tells which function to compile; you can have many kernels
|
|
#pragma kernel CS
|
|
|
|
// Create a RenderTexture with enableRandomWrite flag and set it with cs.SetTexture
|
|
// NOTE: the .hlsl files conveniently contain a list of inputs and outputs in their header comments
|
|
//Texture2D<float2> r_exposure; // Expose is not used at the moment, so no need to bind it
|
|
Texture2D<float4> r_rcas_input;
|
|
RWTexture2D<float4> rw_upscaled_output;
|
|
|
|
// Some global defines are needed
|
|
#define FFX_GPU // Compiling for GPU
|
|
#define FFX_HLSL // Compile for plain HLSL
|
|
|
|
//#define FFX_FSR2_OPTION_HDR_COLOR_INPUT // This ought to be supported in the long run
|
|
|
|
#define FSR_RCAS_F // Using 32-bit float mode (not half)
|
|
#define FSR2_BIND_UAV_UPSCALED_OUTPUT // Create an SRV binding for the output we need
|
|
|
|
#include "ffx_core.h" // With the above defines this all compiles cleanly, yay!
|
|
|
|
// This is from ffx_fsr2_callbacks_hlsl.h (bunch of macro use to declare SRVs, may need conversion)
|
|
FfxFloat32 Exposure()
|
|
{
|
|
// return 1.0f;
|
|
#if defined(FSR2_BIND_SRV_EXPOSURE) || defined(FFX_INTERNAL)
|
|
FfxFloat32 exposure = r_exposure[FfxUInt32x2(0, 0)].x;
|
|
#else
|
|
FfxFloat32 exposure = 1.f;
|
|
#endif
|
|
|
|
if (exposure == 0.0f) {
|
|
exposure = 1.0f;
|
|
}
|
|
|
|
return exposure;
|
|
}
|
|
|
|
FfxFloat32 PreExposure()
|
|
{
|
|
//return fPreExposure; // TODO: requires constant buffer bindings, uhhh... (see FSR2_BIND_CB_FSR2)
|
|
return 1.0f;
|
|
}
|
|
|
|
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor)
|
|
{
|
|
#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) || defined(FFX_INTERNAL)
|
|
rw_upscaled_output[iPxPos] = FfxFloat32x4(fColor * PreExposure(), 1.f);
|
|
#endif
|
|
}
|
|
|
|
//#include "ffx_fsr2_common.h" // TODO: still depends on a bunch of CB's from callbacks_hlsl
|
|
|
|
// Below is all converted from ffx_fsr2_rcas_pass.hlsl
|
|
uint4 RCASConfig()
|
|
{
|
|
// These are not your typical config parameters... these are packed floats-as-ints, i.e. complete nonsense values
|
|
return uint4(1061290752, 974141968, 0, 0); // TODO: this needs to be a constant buffer value
|
|
}
|
|
|
|
float4 LoadRCAS_Input(FfxInt32x2 iPxPos)
|
|
{
|
|
return r_rcas_input[iPxPos];
|
|
}
|
|
|
|
#include "ffx_fsr2_rcas.h"
|
|
|
|
#ifndef FFX_FSR2_THREAD_GROUP_WIDTH
|
|
#define FFX_FSR2_THREAD_GROUP_WIDTH 64
|
|
#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH
|
|
#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT
|
|
#define FFX_FSR2_THREAD_GROUP_HEIGHT 1
|
|
#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT
|
|
#ifndef FFX_FSR2_THREAD_GROUP_DEPTH
|
|
#define FFX_FSR2_THREAD_GROUP_DEPTH 1
|
|
#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH
|
|
#ifndef FFX_FSR2_NUM_THREADS
|
|
#define FFX_FSR2_NUM_THREADS [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)]
|
|
#endif // #ifndef FFX_FSR2_NUM_THREADS
|
|
|
|
FFX_FSR2_NUM_THREADS
|
|
void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID)
|
|
{
|
|
RCAS(LocalThreadId, WorkGroupId, Dtid);
|
|
}
|