Browse Source

Fixed bugs:

- Assign colorOutput texture to output
- Texture event passes texture IDs after all, so translate those to ID3D12Resource pointers
- Assign texture in End event, perform clear in Begin event. Fixes inputColor texture entry getting cleared.
fsr2
Nico de Poel 1 year ago
parent
commit
dafe81d108
  1. 19
      FSR3UnityPlugin.cpp

19
FSR3UnityPlugin.cpp

@ -242,7 +242,7 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
dispatchUpscale.exposure = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.exposureTexture, 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.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.transparencyAndComposition = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.transparencyMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ);
dispatchUpscale.output = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.colorInput, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); // TODO: shouldn't this be FFX_API_RESOURCE_STATE_UNORDERED_ACCESS?
dispatchUpscale.output = ffxApiGetResourceDX12((ID3D12Resource*)feature.textureTable.colorOutput, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); // TODO: shouldn't this be FFX_API_RESOURCE_STATE_UNORDERED_ACCESS?
dispatchUpscale.jitterOffset.x = params->jitterOffsetX; // TODO: might need to negate these dispatchUpscale.jitterOffset.x = params->jitterOffsetX; // TODO: might need to negate these
dispatchUpscale.jitterOffset.y = params->jitterOffsetY; dispatchUpscale.jitterOffset.y = params->jitterOffsetY;
@ -303,6 +303,9 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data) static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data)
{ {
if (s_GraphicsD3D12 == nullptr)
return;
auto* params = (UnityRenderingExtTextureUpdateParamsV2*)data; auto* params = (UnityRenderingExtTextureUpdateParamsV2*)data;
uint32_t featureSlot = (params->userData >> 16) & 0xFFFF; uint32_t featureSlot = (params->userData >> 16) & 0xFFFF;
@ -313,23 +316,23 @@ static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data)
return; return;
auto& feature = s_Features[featureSlot]; auto& feature = s_Features[featureSlot];
if (clearTextureTable)
{
memset(&feature.textureTable, 0, sizeof(FSR3TextureTable));
}
// User rendering code // User rendering code
switch (eventID) switch (eventID)
{ {
case kUnityRenderingExtEventUpdateTextureBeginV2: case kUnityRenderingExtEventUpdateTextureBeginV2:
{ {
// 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
*(((intptr_t*)&feature.textureTable) + textureSlot) = params->textureID;
if (clearTextureTable)
{
memset(&feature.textureTable, 0, sizeof(FSR3TextureTable));
}
break; break;
} }
case kUnityRenderingExtEventUpdateTextureEndV2: case kUnityRenderingExtEventUpdateTextureEndV2:
{ {
// 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
*(((intptr_t*)&feature.textureTable) + textureSlot) = (intptr_t)s_GraphicsD3D12->TextureFromNativeTexture((UnityTextureID)params->textureID);
break; break;
} }
} }

Loading…
Cancel
Save