Açıklama Yok
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.

StpHistory.cs 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. namespace UnityEngine.Rendering.Universal
  2. {
  3. internal sealed class StpHistory : CameraHistoryItem
  4. {
  5. /// <summary>
  6. /// STP uses a custom history texture management system in order to simplify code sharing with other SRPs
  7. /// In URP's case, we potentially need two of these in order to support multi-pass XR rendering
  8. /// </summary>
  9. STP.HistoryContext[] m_historyContexts = new STP.HistoryContext[2];
  10. public override void OnCreate(BufferedRTHandleSystem owner, uint typeId)
  11. {
  12. base.OnCreate(owner, typeId);
  13. for (int eyeIndex = 0; eyeIndex < 2; ++eyeIndex)
  14. {
  15. m_historyContexts[eyeIndex] = new STP.HistoryContext();
  16. }
  17. }
  18. public override void Reset()
  19. {
  20. for (int eyeIndex = 0; eyeIndex < 2; ++eyeIndex)
  21. {
  22. // Clear internal data within the contexts whenever we're reset
  23. m_historyContexts[eyeIndex].Dispose();
  24. }
  25. }
  26. internal STP.HistoryContext GetHistoryContext(int eyeIndex)
  27. {
  28. // STP only supports XR multi-pass with two views
  29. Debug.Assert(eyeIndex < 2);
  30. return m_historyContexts[eyeIndex];
  31. }
  32. // Return true if the internal history data is invalid after the update operation
  33. internal bool Update(UniversalCameraData cameraData)
  34. {
  35. STP.HistoryUpdateInfo info;
  36. info.preUpscaleSize = new Vector2Int(cameraData.cameraTargetDescriptor.width, cameraData.cameraTargetDescriptor.height);
  37. info.postUpscaleSize = new Vector2Int(cameraData.pixelWidth, cameraData.pixelHeight);
  38. info.useHwDrs = false;
  39. info.useTexArray = cameraData.xr.enabled && cameraData.xr.singlePassEnabled;
  40. int eyeIndex = (cameraData.xr.enabled && !cameraData.xr.singlePassEnabled) ? cameraData.xr.multipassId : 0;
  41. bool hasValidHistory = GetHistoryContext(eyeIndex).Update(ref info);
  42. return !hasValidHistory;
  43. }
  44. }
  45. }