Improve wider platform support

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
TheJackiMonster 2022-09-30 13:14:08 +02:00
parent f8b3d1b2c3
commit d77d3fc94b
No known key found for this signature in database
GPG Key ID: D850A5F772E880F9
3 changed files with 19 additions and 7 deletions

View File

@ -41,6 +41,12 @@ if(CMAKE_GENERATOR_PLATFORM STREQUAL "x64" OR CMAKE_EXE_LINKER_FLAGS STREQUAL "/
set(FSR2_PLATFORM_NAME x64)
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32" OR CMAKE_EXE_LINKER_FLAGS STREQUAL "/machine:X86")
set(FSR2_PLATFORM_NAME x86)
elseif(CMAKE_SYSTEM_PROCESSOR)
set(FSR2_PLATFORM_NAME ${CMAKE_SYSTEM_PROCESSOR})
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(FFX_GCC)
endif()
else()
message(FATAL_ERROR "Unsupported target platform - only supporting x64 and Win32 currently")
endif()

View File

@ -22,6 +22,7 @@
#include <algorithm> // for max used inside SPD CPU code.
#include <cmath> // for fabs, abs, sinf, sqrt, etc.
#include <string.h> // for memset
#include <wchar.h> // for wcscmp, wcscpy
#include <cfloat> // for FLT_EPSILON
#include "ffx_fsr2.h"
#define FFX_CPU
@ -36,6 +37,10 @@
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifndef _countof
#define _countof(array) (sizeof(array) / sizeof(array[0]))
#endif
// max queued frames for descriptor management
static const uint32_t FSR2_MAX_QUEUED_FRAMES = 16;
@ -484,13 +489,13 @@ static void scheduleDispatch(FfxFsr2Context_Private* context, const FfxFsr2Dispa
const uint32_t currentResourceId = pipeline->srvResourceBindings[currentShaderResourceViewIndex].resourceIdentifier;
const FfxResourceInternal currentResource = context->srvResources[currentResourceId];
jobDescriptor.srvs[currentShaderResourceViewIndex] = currentResource;
wcscpy_s(jobDescriptor.srvNames[currentShaderResourceViewIndex], pipeline->srvResourceBindings[currentShaderResourceViewIndex].name);
wcscpy(jobDescriptor.srvNames[currentShaderResourceViewIndex], pipeline->srvResourceBindings[currentShaderResourceViewIndex].name);
}
for (uint32_t currentUnorderedAccessViewIndex = 0; currentUnorderedAccessViewIndex < pipeline->uavCount; ++currentUnorderedAccessViewIndex) {
const uint32_t currentResourceId = pipeline->uavResourceBindings[currentUnorderedAccessViewIndex].resourceIdentifier;
wcscpy_s(jobDescriptor.uavNames[currentUnorderedAccessViewIndex], pipeline->uavResourceBindings[currentUnorderedAccessViewIndex].name);
wcscpy(jobDescriptor.uavNames[currentUnorderedAccessViewIndex], pipeline->uavResourceBindings[currentUnorderedAccessViewIndex].name);
if (currentResourceId >= FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE_MIPMAP_0 && currentResourceId <= FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE_MIPMAP_12)
{
@ -512,7 +517,7 @@ static void scheduleDispatch(FfxFsr2Context_Private* context, const FfxFsr2Dispa
jobDescriptor.pipeline = *pipeline;
for (uint32_t currentRootConstantIndex = 0; currentRootConstantIndex < pipeline->constCount; ++currentRootConstantIndex) {
wcscpy_s( jobDescriptor.cbNames[currentRootConstantIndex], pipeline->cbResourceBindings[currentRootConstantIndex].name);
wcscpy( jobDescriptor.cbNames[currentRootConstantIndex], pipeline->cbResourceBindings[currentRootConstantIndex].name);
jobDescriptor.cbs[currentRootConstantIndex] = globalFsr2ConstantBuffers[pipeline->cbResourceBindings[currentRootConstantIndex].resourceIdentifier];
}
@ -1003,9 +1008,9 @@ FfxErrorCode ffxFsr2ContextGenerateReactiveMask(FfxFsr2Context* context, const F
contextPrivate->contextDescription.callbacks.fpRegisterResource(&contextPrivate->contextDescription.callbacks, &params->colorOpaqueOnly, &jobDescriptor.srvs[0]);
contextPrivate->contextDescription.callbacks.fpRegisterResource(&contextPrivate->contextDescription.callbacks, &params->colorPreUpscale, &jobDescriptor.srvs[1]);
contextPrivate->contextDescription.callbacks.fpRegisterResource(&contextPrivate->contextDescription.callbacks, &params->outReactive, &jobDescriptor.uavs[0]);
wcscpy_s(jobDescriptor.srvNames[0], pipeline->srvResourceBindings[0].name);
wcscpy_s(jobDescriptor.srvNames[1], pipeline->srvResourceBindings[1].name);
wcscpy_s(jobDescriptor.uavNames[0], pipeline->uavResourceBindings[0].name);
wcscpy(jobDescriptor.srvNames[0], pipeline->srvResourceBindings[0].name);
wcscpy(jobDescriptor.srvNames[1], pipeline->srvResourceBindings[1].name);
wcscpy(jobDescriptor.uavNames[0], pipeline->uavResourceBindings[0].name);
jobDescriptor.dimensions[0] = dispatchSrcX;
jobDescriptor.dimensions[1] = dispatchSrcY;
@ -1020,7 +1025,7 @@ FfxErrorCode ffxFsr2ContextGenerateReactiveMask(FfxFsr2Context* context, const F
jobDescriptor.cbs[0].uint32Size = sizeof(constants);
memcpy(&jobDescriptor.cbs[0].data, &constants, sizeof(constants));
wcscpy_s(jobDescriptor.cbNames[0], pipeline->cbResourceBindings[0].name);
wcscpy(jobDescriptor.cbNames[0], pipeline->cbResourceBindings[0].name);
FfxGpuJobDescription dispatchJob = { FFX_GPU_JOB_COMPUTE };
dispatchJob.computeJobDescriptor = jobDescriptor;

View File

@ -22,6 +22,7 @@
#pragma once
#include <stdint.h>
#include <stdlib.h>
#if defined (FFX_GCC)
/// FidelityFX exported functions