diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 71678c9c8b6..24bfc468885 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Histogram guided automatic exposure. - Added few exposure debug modes. - Added support for multiple path-traced views at once (e.g., scene and game views). +- Added Virtual Texturing cache settings to control the size of the Streaming Virtual Texturing caches. ### Fixed - Fix when rescale probe all direction below zero (1219246) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index 73ff57b6263..2933603e2c7 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -218,3 +218,10 @@ Use these settings to enable or disable settings relating to lighting in HDRP. | **Grading LUT Size** | The size of the internal and external color grading lookup textures (LUTs). This size is fixed for the Project. You can not mix and match LUT sizes, so decide on a size before you start the color grading process. The default value, **32**, provides a good balance of speed and quality. | | **Grading LUT Format** | Use the drop-down to select the format to encode the color grading LUTs with. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. | | **Buffer Format** | Use the drop-down to select the format of the color buffers that are used in the post-processing passes. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. + +## Virtual Texturing + +| **Property** | **Description** | +| ----------------------- | --------------------------------------------------------------- | +| **CPU Cache Size** | Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to cache texture data. | +| **GPU Cache Size per Format** | Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats. | diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index bf7f0ccc463..a78024c06b3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -23,7 +23,7 @@ public class GeneralSection public static readonly GUIContent materialSectionTitle = EditorGUIUtility.TrTextContent("Material"); public static readonly GUIContent postProcessSectionTitle = EditorGUIUtility.TrTextContent("Post-processing"); public static readonly GUIContent xrTitle = EditorGUIUtility.TrTextContent("XR"); - public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing"); + public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing", "Virtual Texturing Settings. These are only available when Virtual Texturing is enabled in the Player Settings."); public static readonly GUIContent lightLoopSubTitle = EditorGUIUtility.TrTextContent("Lights"); public static readonly GUIContent postProcessQualitySubTitle = EditorGUIUtility.TrTextContent("Post-processing Quality Settings"); public static readonly GUIContent lightingQualitySettings = EditorGUIUtility.TrTextContent("Lighting Quality Settings"); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index e7862542a9d..ad24fb02a96 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -68,6 +68,8 @@ internal enum SelectedFrameSettings internal static SelectedFrameSettings selectedFrameSettings; + internal static VirtualTexturingSettingsUI virtualTexturingSettingsUI = new VirtualTexturingSettingsUI(); + static HDRenderPipelineUI() { Inspector = CED.Group( @@ -99,7 +101,8 @@ static HDRenderPipelineUI() CED.FoldoutGroup(Styles.bloomQualitySettings, Expandable.BloomQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionBloomQualitySettings), CED.FoldoutGroup(Styles.chromaticAberrationQualitySettings, Expandable.ChromaticAberrationQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionChromaticAberrationQualitySettings) ), - CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings) + CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings), + CED.FoldoutGroup(Styles.virtualTexturingTitle, Expandable.VirtualTexturing, k_ExpandedState, Drawer_SectionVTSettings) ); // fix init of selection along what is serialized @@ -569,6 +572,11 @@ static void Drawer_SectionXRSettings(SerializedHDRenderPipelineAsset serialized, EditorGUILayout.PropertyField(serialized.renderPipelineSettings.xrSettings.cameraJitter, Styles.XRCameraJitter); } + static void Drawer_SectionVTSettings(SerializedHDRenderPipelineAsset serialized, Editor owner) + { + virtualTexturingSettingsUI.OnGUI(serialized, owner); + } + static private bool m_ShowDoFLowQualitySection = false; static private bool m_ShowDoFMediumQualitySection = false; static private bool m_ShowDoFHighQualitySection = false; diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs index 1f1572a90e6..e8b64eed36f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs @@ -20,6 +20,7 @@ class SerializedHDRenderPipelineAsset public SerializedFrameSettings defaultFrameSettings; public SerializedFrameSettings defaultBakedOrCustomReflectionFrameSettings; public SerializedFrameSettings defaultRealtimeReflectionFrameSettings; + public SerializedVirtualTexturingSettings virtualTexturingSettings; //RenderPipelineResources not always exist and thus cannot be serialized normally. public bool editorResourceHasMultipleDifferentValues @@ -63,6 +64,8 @@ public SerializedHDRenderPipelineAsset(SerializedObject serializedObject) defaultFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultCameraFrameSettings"), null); //no overrides in HDRPAsset defaultBakedOrCustomReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings"), null); //no overrides in HDRPAsset defaultRealtimeReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultRealtimeReflectionFrameSettings"), null); //no overrides in HDRPAsset + + virtualTexturingSettings = new SerializedVirtualTexturingSettings(serializedObject.FindProperty("virtualTexturingSettings")); } public void Update() diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs new file mode 100644 index 00000000000..3c02a1158d9 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs @@ -0,0 +1,20 @@ +using UnityEditor.Rendering; +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + internal sealed class SerializedVirtualTexturingSettings + { + public SerializedProperty root; + + public SerializedProperty streamingCpuCacheSizeInMegaBytes; + public SerializedProperty streamingGpuCacheSettings; + public SerializedVirtualTexturingSettings(SerializedProperty root) + { + this.root = root; + + streamingCpuCacheSizeInMegaBytes = root.Find((VirtualTexturingSettingsSRP s) => s.streamingCpuCacheSizeInMegaBytes); + streamingGpuCacheSettings = root.Find((VirtualTexturingSettingsSRP s) => s.streamingGpuCacheSettings); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta new file mode 100644 index 00000000000..d2b9c82d69a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2b6b35c2a70589145b2353009c41ecf8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs new file mode 100644 index 00000000000..d9d2f8fb80c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering.VirtualTexturing; + +namespace UnityEditor.Rendering.HighDefinition +{ + internal class VirtualTexturingSettingsUI + { + private ReorderableList m_GPUCacheSizeOverrideListStreaming; + private SerializedProperty m_GPUCacheSizeOverridesPropertyStreaming; + + public SerializedObject serializedObject; + private SerializedHDRenderPipelineAsset serializedRPAsset; + + private const int CPUCacheSizeMinValue = 64; + private const int GPUCacheSizeMinValue = 32; + + public void OnGUI(SerializedHDRenderPipelineAsset serialized, Editor owner) + { + CheckStyles(); + + serializedObject = serialized.serializedObject; + serializedRPAsset = serialized; + + EditorGUILayout.Space(); + +#if !ENABLE_VIRTUALTEXTURES + EditorGUI.BeginDisabledGroup(true); +#endif + + using (var scope = new EditorGUI.ChangeCheckScope()) + { + serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue = Mathf.Max(CPUCacheSizeMinValue, EditorGUILayout.DelayedIntField(s_Styles.cpuCacheSize, serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue)); + + // GPU Cache size settings + if (m_GPUCacheSizeOverrideListStreaming == null || + m_GPUCacheSizeOverridesPropertyStreaming != serialized.virtualTexturingSettings.streamingGpuCacheSettings) + { + m_GPUCacheSizeOverridesPropertyStreaming = serialized.virtualTexturingSettings.streamingGpuCacheSettings; + m_GPUCacheSizeOverrideListStreaming = CreateGPUCacheSizeOverrideList(m_GPUCacheSizeOverridesPropertyStreaming, DrawStreamingOverrideElement); + } + + m_GPUCacheSizeOverrideListStreaming.DoLayoutList(); + } + +#if !ENABLE_VIRTUALTEXTURES + EditorGUI.EndDisabledGroup(); +#endif + + serialized.serializedObject.ApplyModifiedProperties(); + } + + GPUCacheSetting[] GetGPUCacheSizeOverrideArrayFromProperty(SerializedProperty property) + { + List settings = new List(); + for (int i = 0; i < property.arraySize; ++i) + { + SerializedProperty settingProperty = property.GetArrayElementAtIndex(i); + settings.Add(new GPUCacheSetting() + { format = (GraphicsFormat)settingProperty.FindPropertyRelative("format").intValue, sizeInMegaBytes = (uint)settingProperty.FindPropertyRelative("sizeInMegaBytes").intValue }); + } + + return settings.ToArray(); + } + + ReorderableList CreateGPUCacheSizeOverrideList(SerializedProperty property, ReorderableList.ElementCallbackDelegate drawCallback) + { + ReorderableList list = new ReorderableList(property.serializedObject, property); + + list.drawHeaderCallback = + (Rect rect) => + { + GUI.Label(rect, s_Styles.gpuCacheSize); + }; + + list.drawElementCallback = drawCallback; + + list.onAddCallback = (l) => + { + List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); + + // We can't just pass in existing settings as a parameter to CreateGPUCacheSizeOverrideList() because lambdas can't capture ref params. + GPUCacheSetting[] existingSettings = GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings); + RemoveOverriddenFormats(availableFormats, existingSettings); + + int index = property.arraySize; + property.InsertArrayElementAtIndex(index); + var newItemProperty = property.GetArrayElementAtIndex(index); + newItemProperty.FindPropertyRelative("format").intValue = availableFormats.Count > 0 ? (int)availableFormats[0] : 0; + newItemProperty.FindPropertyRelative("sizeInMegaBytes").intValue = 64; + }; + + return list; + } + + void GraphicsFormatToFormatAndChannelTransformString(GraphicsFormat graphicsFormat, out string format, out string channelTransform) + { + string formatString = graphicsFormat.ToString(); + int lastUnderscore = formatString.LastIndexOf('_'); + if (lastUnderscore < 0) + { + format = "None"; + channelTransform = "None"; + return; + } + format = formatString.Substring(0, lastUnderscore); + channelTransform = formatString.Substring(lastUnderscore + 1); + } + GraphicsFormat FormatAndChannelTransformStringToGraphicsFormat(string format, string channelTransform) + { + if (format == "None") return GraphicsFormat.None; + + return (GraphicsFormat)Enum.Parse(typeof(GraphicsFormat), $"{format}_{channelTransform}"); + } + + void RemoveOverriddenFormats(List formats, GPUCacheSetting[] settings) + { + foreach (var existingCacheSizeOverride in settings) + { + formats.Remove(existingCacheSizeOverride.format); + } + } + + void GPUCacheSizeOverridesGUI(Rect rect, int settingIdx, SerializedProperty settingListProperty, GPUCacheSetting[] settingList) + { + var cacheSizeOverrideProperty = settingListProperty.GetArrayElementAtIndex(settingIdx); + var cacheSizeOverride = settingList[settingIdx]; + +#if ENABLE_VIRTUALTEXTURES + List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); + // None is used for a default cache size. + availableFormats.Add(GraphicsFormat.None); + + RemoveOverriddenFormats(availableFormats, settingList); + + // Group formats + Dictionary> formatGroups = new Dictionary>(); + foreach (GraphicsFormat graphicsFormat in availableFormats) + { + GraphicsFormatToFormatAndChannelTransformString(graphicsFormat, out var format, out var channelTransform); + if (!formatGroups.ContainsKey(format)) + { + formatGroups.Add(format, new List()); + } + formatGroups[format].Add(channelTransform); + } +#endif + + GraphicsFormat serializedFormat = (GraphicsFormat) cacheSizeOverrideProperty.FindPropertyRelative("format").intValue; + GraphicsFormatToFormatAndChannelTransformString(serializedFormat, out string formatString, out string channelTransformString); + + + // GUI Drawing + + float settingWidth = rect.width; + + float spacing = Math.Min(5, settingWidth * 0.02f); + + settingWidth -= 2 * spacing; + + float formatLabelWidth = Math.Min(60, settingWidth * 0.25f); + float formatWidth = settingWidth * 0.3f; + float channelTransformWidth = settingWidth * 0.25f; + float sizeLabelWidth = Math.Min(45, settingWidth * 0.2f); + float sizeWidth = settingWidth * 0.15f; + + // Format + rect.width = formatLabelWidth; + rect.position += new Vector2(-15, 0); + EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideFormat); + + rect.position += new Vector2(formatLabelWidth, 0); + rect.width = formatWidth; + if (EditorGUI.DropdownButton(rect, new GUIContent(formatString), FocusType.Keyboard)) + { +#if ENABLE_VIRTUALTEXTURES + GenericMenu menu = new GenericMenu(); + foreach (string possibleFormat in formatGroups.Keys) + { + string localFormat = possibleFormat; + menu.AddItem(new GUIContent(localFormat), formatString == localFormat, () => + { + // Make sure the channelTransform is valid for the format. + List formatGroup = formatGroups[localFormat]; + if (formatGroup.FindIndex((string possibleChannelTransform) => { return possibleChannelTransform == channelTransformString; }) == -1) + { + channelTransformString = formatGroup[0]; + } + + cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)FormatAndChannelTransformStringToGraphicsFormat(localFormat, channelTransformString); + + serializedObject.ApplyModifiedProperties(); + }); + } + + menu.ShowAsContext(); +#endif + } + + // Channel transform + rect.position += new Vector2(formatWidth, 0); + rect.width = channelTransformWidth; + + List possibleChannelTransforms = new List(); + +#if ENABLE_VIRTUALTEXTURES + if (formatGroups.ContainsKey(formatString)) + { + possibleChannelTransforms = formatGroups[formatString]; + } +#endif + + EditorGUI.BeginDisabledGroup(possibleChannelTransforms.Count == 0); + { + if (serializedFormat != GraphicsFormat.None && EditorGUI.DropdownButton(rect, new GUIContent(channelTransformString), FocusType.Keyboard)) + { +#if ENABLE_VIRTUALTEXTURES + GenericMenu menu = new GenericMenu(); + possibleChannelTransforms.Add(channelTransformString); + possibleChannelTransforms.Sort(); + + foreach (string possibleChannelTransform in possibleChannelTransforms) + { + string localChannelTransform = possibleChannelTransform; + menu.AddItem(new GUIContent(localChannelTransform), localChannelTransform == channelTransformString, () => + { + GraphicsFormat format = FormatAndChannelTransformStringToGraphicsFormat(formatString, localChannelTransform); + cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)format; + serializedObject.ApplyModifiedProperties(); + }); + } + + menu.ShowAsContext(); +#endif + } + } + EditorGUI.EndDisabledGroup(); + + // Size + rect.position += new Vector2(channelTransformWidth + spacing, 0); + rect.width = sizeLabelWidth; + + EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideSize); + + rect.position += new Vector2(sizeLabelWidth, 0); + rect.width = sizeWidth; + + cacheSizeOverride.sizeInMegaBytes = (uint) Mathf.Max(GPUCacheSizeMinValue, + EditorGUI.DelayedIntField(rect, (int) cacheSizeOverride.sizeInMegaBytes)); + cacheSizeOverrideProperty.FindPropertyRelative("sizeInMegaBytes").intValue = + (int) cacheSizeOverride.sizeInMegaBytes; + } + + void DrawStreamingOverrideElement(Rect rect, int settingIdx, bool active, bool focused) + { + GPUCacheSizeOverridesGUI(rect, settingIdx, m_GPUCacheSizeOverridesPropertyStreaming, GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings)); + } + + sealed class Styles + { + public readonly GUIContent cpuCacheSize = new GUIContent("CPU Cache Size", "Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to use to cache texture data."); + public readonly GUIContent gpuCacheSize = new GUIContent("GPU Cache Size per Format", "Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats."); + + public readonly GUIContent gpuCacheSizeOverrideFormat = new GUIContent("Format", "Format and channel transform that will be overridden."); + public readonly GUIContent gpuCacheSizeOverrideSize = new GUIContent("Size", "Size (in MB) of the setting."); + } + + static Styles s_Styles; + + // Can't use a static initializer in case we need to create GUIStyle in the Styles class as + // these can only be created with an active GUI rendering context + void CheckStyles() + { + if (s_Styles == null) + s_Styles = new Styles(); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta new file mode 100644 index 00000000000..0df3a0bc55d --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 33b486c1a65371b4391f4e7c4c53f658 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index dc7867b5116..6750807b7e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -7,6 +7,10 @@ using UnityEngine.Experimental.Rendering; using UnityEngine.Experimental.Rendering.RenderGraphModule; +#if ENABLE_VIRTUALTEXTURES +using UnityEngine.Rendering.VirtualTexturing; +#endif + namespace UnityEngine.Rendering.HighDefinition { /// @@ -395,6 +399,24 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau return; } +#if ENABLE_VIRTUALTEXTURES + VirtualTexturingSettingsSRP settings = asset.virtualTexturingSettings; + + if (settings == null) + settings = new VirtualTexturingSettingsSRP(); + + VirtualTexturing.Streaming.SetCPUCacheSize(settings.streamingCpuCacheSizeInMegaBytes); + + GPUCacheSetting[] gpuCacheSettings = new GPUCacheSetting[settings.streamingGpuCacheSettings.Count]; + for (int i = 0; i < settings.streamingGpuCacheSettings.Count; ++i) + { + GPUCacheSettingSRP srpSetting = settings.streamingGpuCacheSettings[i]; + gpuCacheSettings[i] = new GPUCacheSetting() { format = srpSetting.format, sizeInMegaBytes = srpSetting.sizeInMegaBytes }; + } + + VirtualTexturing.Streaming.SetGPUCacheSettings(gpuCacheSettings); +#endif + // Initial state of the RTHandle system. // Tells the system that we will require MSAA or not so that we can avoid wasteful render texture allocation. // TODO: Might want to initialize to at least the window resolution to avoid un-necessary re-alloc in the player diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs index 467348ea653..6c8218c1a3a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs @@ -259,6 +259,9 @@ public override Shader defaultShader [SerializeField] internal List afterPostProcessCustomPostProcesses = new List(); + [SerializeField] + internal VirtualTexturingSettingsSRP virtualTexturingSettings = new VirtualTexturingSettingsSRP(); + #if UNITY_EDITOR /// HDRP default material. public override Material defaultMaterial diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs new file mode 100644 index 00000000000..d9f67985a00 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering.VirtualTexturing; + +namespace UnityEngine.Rendering.HighDefinition +{ + [Serializable] + internal sealed class VirtualTexturingSettingsSRP + { + public int streamingCpuCacheSizeInMegaBytes = 256; + public List streamingGpuCacheSettings = new List() { new GPUCacheSettingSRP() { format = Experimental.Rendering.GraphicsFormat.None, sizeInMegaBytes = 128 } }; + } + + [Serializable] + internal struct GPUCacheSettingSRP + { + /// + /// Format of the cache these settings are applied to. + /// + public GraphicsFormat format; + /// + /// Size in MegaBytes of the cache created with these settings. + /// + public uint sizeInMegaBytes; + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta new file mode 100644 index 00000000000..392dfcfb8b0 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0f8c6d5fdfd2044f8b9c09a8fc27ebc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: