|
|
@ -110,11 +110,13 @@ static uint32_t AllocateFeatureSlot() |
|
|
|
|
|
|
|
|
if (s_FeatureSlots.empty()) |
|
|
if (s_FeatureSlots.empty()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// Create a new feature if there are no free slots
|
|
|
uint32_t featureSlot = (uint32_t)s_Features.size(); |
|
|
uint32_t featureSlot = (uint32_t)s_Features.size(); |
|
|
s_Features.push_back(std::move(FSR3Feature())); |
|
|
s_Features.push_back(std::move(FSR3Feature())); |
|
|
return featureSlot; |
|
|
return featureSlot; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Reallocate an existing free slot
|
|
|
uint32_t featureSlot = s_FeatureSlots.front(); |
|
|
uint32_t featureSlot = s_FeatureSlots.front(); |
|
|
s_FeatureSlots.pop(); |
|
|
s_FeatureSlots.pop(); |
|
|
return featureSlot; |
|
|
return featureSlot; |
|
|
@ -247,13 +249,13 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data) |
|
|
ffx::DispatchDescUpscale dispatchUpscale{}; |
|
|
ffx::DispatchDescUpscale dispatchUpscale{}; |
|
|
dispatchUpscale.commandList = state.commandList; |
|
|
dispatchUpscale.commandList = state.commandList; |
|
|
|
|
|
|
|
|
dispatchUpscale.color = ffxApiGetResourceDX12(feature.textureTable.colorInput, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.depth = ffxApiGetResourceDX12(feature.textureTable.depth, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.motionVectors = ffxApiGetResourceDX12(feature.textureTable.motionVectors, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.exposure = ffxApiGetResourceDX12(feature.textureTable.exposureTexture, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.reactive = ffxApiGetResourceDX12(feature.textureTable.reactiveMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.transparencyAndComposition = ffxApiGetResourceDX12(feature.textureTable.transparencyMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.output = ffxApiGetResourceDX12(feature.textureTable.colorOutput, FFX_API_RESOURCE_STATE_UNORDERED_ACCESS); |
|
|
|
|
|
|
|
|
dispatchUpscale.color = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.colorInput, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.depth = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.depth, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.motionVectors = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.motionVectors, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.exposure = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.exposureTexture, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.reactive = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.reactiveMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.transparencyAndComposition = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.transparencyMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); |
|
|
|
|
|
dispatchUpscale.output = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.colorOutput, FFX_API_RESOURCE_STATE_UNORDERED_ACCESS); |
|
|
|
|
|
|
|
|
dispatchUpscale.jitterOffset.x = params->jitterOffsetX; |
|
|
dispatchUpscale.jitterOffset.x = params->jitterOffsetX; |
|
|
dispatchUpscale.jitterOffset.y = params->jitterOffsetY; |
|
|
dispatchUpscale.jitterOffset.y = params->jitterOffsetY; |
|
|
@ -308,6 +310,14 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data) |
|
|
ffx::CreateContext(feature.upscalingContext, nullptr, createUpscaling, s_BackendDesc); |
|
|
ffx::CreateContext(feature.upscalingContext, nullptr, createUpscaling, s_BackendDesc); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
case BaseEventId + FSR3PluginEvent::eSetTextures: |
|
|
|
|
|
auto* params = (FSR3TextureTable*)data; |
|
|
|
|
|
if (params->featureSlot < 0 || params->featureSlot >= s_Features.size()) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
auto& feature = s_Features[params->featureSlot]; |
|
|
|
|
|
feature.textureTable = *params; |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -343,7 +353,7 @@ static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data) |
|
|
{ |
|
|
{ |
|
|
// We organized the texture table struct to be ordered the same as the texture slot enum
|
|
|
// We organized the texture table struct to be ordered the same as the texture slot enum
|
|
|
// This way we can use the texture slot value simply as a pointer offset into the texture table
|
|
|
// This way we can use the texture slot value simply as a pointer offset into the texture table
|
|
|
*(((ID3D12Resource**)&feature.textureTable) + textureSlot) = s_GraphicsD3D12->TextureFromNativeTexture((UnityTextureID)params->textureID); |
|
|
|
|
|
|
|
|
*(((intptr_t*)&feature.textureTable) + textureSlot) = (intptr_t)s_GraphicsD3D12->TextureFromNativeTexture((UnityTextureID)params->textureID); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|