Browse Source

Got UAV bindings in fragment shaders to work in what I think is the correct way

asr-console
Nico de Poel 11 months ago
parent
commit
c4df3d45aa
  1. 10
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
  2. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl
  3. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl

10
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs

@ -177,8 +177,8 @@ namespace ArmASR
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputExposure, dispatchParams.Exposure);
// TODO UAVs in fragment shaders? That seems like it might be a problem...
commandBuffer.SetGlobalTexture(AsrShaderIDs.UavReconstructedPrevNearestDepth, AsrShaderIDs.UavReconstructedPrevNearestDepth);
// UAV binding in fragment shader, index needs to match the register binding in HLSL
commandBuffer.SetRandomWriteTarget(3, AsrShaderIDs.UavReconstructedPrevNearestDepth);
_mrt[0] = AsrShaderIDs.RtDilatedDepth; // fDepth
_mrt[1] = Resources.DilatedMotionVectors[frameIndex]; // fMotionVector
@ -186,6 +186,7 @@ namespace ArmASR
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
BlitFragment(commandBuffer, _mrt);
commandBuffer.ClearRandomWriteTargets();
}
}
@ -276,8 +277,8 @@ namespace ArmASR
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvInternalTemporalReactive, Resources.InternalReactive[frameIndex ^ 1]);
// TODO UAVs in fragment shaders? That seems like it might be a problem...
commandBuffer.SetGlobalTexture(AsrShaderIDs.UavNewLocks, AsrShaderIDs.UavNewLocks);
// UAV binding in fragment shader, index needs to match the register binding in HLSL
commandBuffer.SetRandomWriteTarget(4, AsrShaderIDs.UavNewLocks);
if (ContextDescription.Variant == Asr.Variant.Quality)
{
@ -296,6 +297,7 @@ namespace ArmASR
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
BlitFragment(commandBuffer, _mrt);
commandBuffer.ClearRandomWriteTargets();
}
}

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl

@ -36,7 +36,7 @@
#define FSR2_BIND_SRV_LUMA_HISTORY 10
#define FSR2_BIND_SRV_TEMPORAL_REACTIVE 11
#define FSR2_BIND_UAV_NEW_LOCKS 12
#define FSR2_BIND_UAV_NEW_LOCKS 4
#define FSR2_BIND_CB_FSR2 0

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl

@ -24,7 +24,7 @@
#define FSR2_BIND_SRV_INPUT_COLOR 2
#define FSR2_BIND_SRV_INPUT_EXPOSURE 3
#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 4
#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 3
#define FSR2_BIND_CB_FSR2 0

Loading…
Cancel
Save