Skip to content

[HDRP] Fix errors when switching build targets in editor #5918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma kernel DilateCell

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#pragma kernel VoxelizeProbeVolumeData
#pragma kernel Subdivide

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// #pragma enable_d3d11_debug_symbols

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed anchor position offset property for the Light Anchor component. (case 1362809)
- Fixed minor performance issues in SSGI (case 1367144).
- Fixed scaling issues with dynamic resolution and the CustomPassSampleCameraColor function.
- Fixed compatibility message not displayed correctly when switching platforms.

### Changed
- Use RayTracingAccelerationStructure.CullInstances to filter Renderers and populate the acceleration structure with ray tracing instances for improved CPU performance on the main thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma kernel WorleyNoiseEvaluator
#pragma kernel PerlinNoiseEvaluator

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsUtilities.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

RW_TEXTURE2D_ARRAY(uint, _TargetArray);
RW_TEXTURE2D(uint, _Target);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma kernel LightVolumeGradient
#pragma kernel LightVolumeColors

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

//#pragma enable_d3d11_debug_symbols

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#define BILATERAL_UPSAMPLE_TILE_SIZE 8

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
//#pragma enable_d3d11_debug_symbols

#pragma kernel GTAOMain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#pragma kernel Blur BLUR_KERNEL_NAME=Blur BLUR
#pragma kernel Blur_FullRes BLUR_KERNEL_NAME=Blur_FullRes BLUR FULL_RES

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

TEXTURE2D_X(_AOPackedData);
RW_TEXTURE2D_X(float, _OcclusionTexture);
RW_TEXTURE2D_X(float, _AOPackedBlurred);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel GTAODenoise_CopyHistory

RW_TEXTURE2D_X(float4, _OutputTexture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

// TODO: This pass really could really use some quality improvement.

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel SpatialDenoise

#pragma multi_compile _ TO_TEMPORAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel TemporalDenoise
#pragma multi_compile HALF_RES FULL_RES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

// #pragma enable_d3d11_debug_symbols

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel TraceGlobalIllumination TRACE_GLOBAL_ILLUMINATION=TraceGlobalIllumination GI_TRACE
#pragma kernel TraceGlobalIlluminationHalf TRACE_GLOBAL_ILLUMINATION=TraceGlobalIlluminationHalf GI_TRACE HALF_RES
#pragma kernel ReprojectGlobalIllumination REPROJECT_GLOBAL_ILLUMINATION=ReprojectGlobalIllumination GI_REPROJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

//#pragma enable_d3d11_debug_symbols

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition\Runtime\ShaderLibrary\ShaderVariables.hlsl"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// Depth related kernels
#pragma kernel ConvertObliqueDepth
#pragma kernel DownscaleDepth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma kernel Main
#pragma kernel PreIntegrateAzimuthalScattering

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// This define is required for invoking BSDF.
#define HAS_LIGHTLOOP

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma kernel KMain

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma kernel KMain
#pragma kernel KInitialize

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel KHistogramGen
#define GROUP_SIZE_X 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma kernel FXAA
#pragma multi_compile _ ENABLE_ALPHA

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#pragma multi_compile _ OUTPUT_DEBUG_DATA

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// Because atomics are only on uint and we need a weighted value, we need to convert.
// If we multiply the weight by 2048, we get somewhat ok precision and we support up to
// the equivalent of 1920x1080 image in one bin. (Note, we run this at half res, so equivalent of 4k image)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/MotionBlurCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/PostProcessDefines.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel MotionBlurCS

//#pragma enable_d3d11_debug_symbols
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma kernel KMain

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/PostProcessDefines.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma kernel KMain

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#pragma multi_compile _ INPUT_FROM_FRAME_TEXTURE

// Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset obsol
/// <param name="asset">Source HDRenderPipelineAsset.</param>
public HDRenderPipeline(HDRenderPipelineAsset asset)
{
// We need to call this after the resource initialization as we attempt to use them in checking the supported API.
if (!CheckAPIValidity())
{
m_ValidAPI = false;
return;
}

#if UNITY_EDITOR
m_GlobalSettings = HDRenderPipelineGlobalSettings.Ensure();
#else
Expand Down Expand Up @@ -296,12 +303,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset)
m_GlobalSettings.EnsureShadersCompiled();
#endif

// We need to call this after the resource initialization as we attempt to use them in checking the supported API.
if (!CheckAPIValidity())
{
m_ValidAPI = false;
return;
}
CheckResourcesValidity();

#if ENABLE_VIRTUALTEXTURES
VirtualTexturingSettingsSRP settings = asset.virtualTexturingSettings;
Expand Down Expand Up @@ -575,6 +577,17 @@ bool CheckAPIValidity()
return true;
}

bool CheckResourcesValidity()
{
if (!(defaultResources?.shaders.defaultPS?.isSupported ?? true))
{
HDUtils.DisplayMessageNotification("Unable to compile Default Material based on Lit.shader. Either there is a compile error in Lit.shader or the current platform / API isn't compatible.");
return false;
}

return true;
}

// Note: If you add new platform in this function, think about adding support when building the player too in HDRPCustomBuildProcessor.cs
bool IsSupportedPlatformAndDevice(out GraphicsDeviceType unsupportedGraphicDevice)
{
Expand All @@ -586,12 +599,6 @@ bool IsSupportedPlatformAndDevice(out GraphicsDeviceType unsupportedGraphicDevic
return false;
}

if (!(defaultResources?.shaders.defaultPS?.isSupported ?? true))
{
HDUtils.DisplayMessageNotification("Unable to compile Default Material based on Lit.shader. Either there is a compile error in Lit.shader or the current platform / API isn't compatible.");
return false;
}

#if UNITY_EDITOR
UnityEditor.BuildTarget activeBuildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
return HDUtils.IsSupportedBuildTargetAndDevice(activeBuildTarget, out unsupportedGraphicDevice);
Expand Down Expand Up @@ -1059,6 +1066,10 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c
#endif
{
#if UNITY_EDITOR
// Build target can change in editor so we need to check if the target is supported
if (!HDUtils.IsSupportedBuildTarget(UnityEditor.EditorUserBuildSettings.activeBuildTarget))
return;

if (!m_ResourcesInitialized)
return;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma multi_compile _ FULL_RESOLUTION_INPUT

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// Common includes
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#pragma multi_compile _ FULL_RESOLUTION_FILTER

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// Common includes
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma kernel KMain
#pragma kernel KMainMSAA

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma kernel FurnaceTest
#pragma kernel FurnaceTestSampled

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

// #pragma enable_d3d11_debug_symbols

// HDRP generic includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#pragma kernel ChooseDirectionTriangleOnly
#pragma kernel SurfaceClosing

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl

#include "Packages/com.unity.visualeffectgraph/Shaders/SDFBaker/SdfUtils.hlsl"

StructuredBuffer<uint> indices;
Expand Down
2 changes: 2 additions & 0 deletions com.unity.visualeffectgraph/Shaders/Sort.compute
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#pragma kernel MergePass MERGE_PASS=MergePass FINAL_PASS=0
#pragma kernel MergeFinalPass MERGE_PASS=MergeFinalPass FINAL_PASS=1

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl

#pragma multi_compile __ VFX_SORT_USE_ELEMENT_COUNT_BUFFER

#include "HLSLSupport.cginc"
Expand Down
2 changes: 2 additions & 0 deletions com.unity.visualeffectgraph/Shaders/UpdateStrips.compute
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma kernel UpdateParticleStrip

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl

#include "HLSLSupport.cginc"

#define NB_THREADS_PER_GROUP 64
Expand Down
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/Shaders/VFXCameraSort.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma kernel CSMain
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl
${VFXGlobalInclude}
${VFXGlobalDeclaration}
${VFXPerPassInclude}
Expand Down
2 changes: 2 additions & 0 deletions com.unity.visualeffectgraph/Shaders/VFXCopyBuffer.compute
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma kernel CSVFXInitDeadListBuffer
#pragma kernel CSVFXZeroInitBuffer

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl

#include "HLSLSupport.cginc"

CBUFFER_START(Uniform)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma kernel CSVFXIndirectArgs

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl

#include "HLSLSupport.cginc"

CBUFFER_START(Uniform)
Expand Down
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/Shaders/VFXInit.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma kernel CSMain
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl
${VFXGlobalInclude}
${VFXGlobalDeclaration}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma kernel CSMain
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl
${VFXGlobalInclude}
${VFXGlobalDeclaration}

Expand Down
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/Shaders/VFXUpdate.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma kernel CSMain
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch opengl
${VFXGlobalInclude}
${VFXGlobalDeclaration}
${VFXInclude("Shaders/VFXParticleCommon.template")}
Expand Down