diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs index 8c533e808e9..63e25e34101 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs @@ -435,7 +435,13 @@ public void ProcessRenderer(int i) var materialIndex = rendererData.materialIndex[materialsOffset + matIndex]; var packedMaterialData = rendererData.packedMaterialData[materialIndex]; +#if UNITY_6000_0_76 || UNITY_6000_0_77 || UNITY_6000_0_78 || UNITY_6000_0_79 || UNITY_6000_0_80 || UNITY_6000_1_OR_NEWER || UNITY_6000_2_OR_NEWER || UNITY_6000_3_OR_NEWER + // isIndirectSupported was removed from GPUDrivenPackedMaterialData in 6000.0.76f1 and newer. + // Default to true as workaround for local development; proper fix requires engine API update in Graphics repo. + supportsIndirect &= true; +#else supportsIndirect &= packedMaterialData.isIndirectSupported; +#endif } var rangeKey = new RangeKey diff --git a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl new file mode 100644 index 00000000000..afdfa0b5b8f --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl @@ -0,0 +1,45 @@ +#ifndef _UNIFIEDRAYTRACING_TRACERAYANDQUERYHIT_HLSL_ +#define _UNIFIEDRAYTRACING_TRACERAYANDQUERYHIT_HLSL_ + +#define UNIFIED_RT_PAYLOAD UnifiedRT::Hit +#ifndef UNIFIED_RT_RAYGEN_FUNC +#define UNIFIED_RT_RAYGEN_FUNC RayGenExecute +#endif +#define UNIFIED_RT_CLOSESTHIT_FUNC ClosestHitExecute +#include "Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRay.hlsl" + +void ClosestHitExecute(UnifiedRT::HitContext hitContext, inout UnifiedRT::Hit payload) +{ + payload.instanceID = hitContext.InstanceID(); + payload.primitiveIndex = hitContext.PrimitiveIndex(); + payload.uvBarycentrics = hitContext.UvBarycentrics(); + payload.hitDistance = hitContext.RayTCurrent(); + payload.isFrontFace = hitContext.IsFrontFace(); +} + +namespace UnifiedRT +{ + +Hit TraceRayClosestHit(DispatchInfo dispatchInfo, RayTracingAccelStruct accelStruct, uint instanceMask, Ray ray, uint rayFlags) +{ + Hit payload= (Hit)0; + payload.instanceID = -1; + + TraceRay(dispatchInfo, accelStruct, instanceMask, ray, rayFlags | kRayFlagForceOpaque, payload); + + return payload; +} + +bool TraceRayAnyHit(DispatchInfo dispatchInfo, RayTracingAccelStruct accelStruct, uint instanceMask, Ray ray, uint rayFlags) +{ + Hit payLoadShadow = (Hit)0; + payLoadShadow.instanceID = -1; + + TraceRay(dispatchInfo, accelStruct, instanceMask, ray, rayFlags | kRayFlagForceOpaque | kRayFlagAcceptFirstHitAndEndSearch, payLoadShadow); + + return payLoadShadow.IsValid(); +} + +} // namespace UnifiedRT + +#endif // _UNIFIEDRAYTRACING_TRACERAYANDQUERYHIT_HLSL_ diff --git a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl.meta b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl.meta new file mode 100644 index 00000000000..164358d2686 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/TraceRayAndQueryHit.hlsl.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ff541650e0d7c3146a62582a0bd48d30 diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs index ada35cd9898..690cf91d2db 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs @@ -247,15 +247,25 @@ public void TestStripUnusedPass_XR(Shader shader) helper = new TestHelper(shader, ShaderFeatures.None); helper.data.stripUnusedXRVariants = false; - helper.data.passName = ShaderScriptableStripper.kPassNameXRMotionVectors; - helper.IsFalse(helper.stripper.StripUnusedPass_XRMotionVectors(ref helper.data)); - helper.IsFalse(helper.stripper.StripUnusedPass(ref helper.data)); + helper.data.passName = ShaderScriptableStripper.kPassNameMotionVectors; + TestHelper.s_EnabledKeywords = new System.Collections.Generic.List() { "APPLICATION_SPACE_WARP_MOTION" }; + helper.IsFalse(helper.stripper.StripInvalidVariants_MotionVectors(ref helper.data)); + helper.IsFalse(helper.stripper.StripInvalidVariants(ref helper.data)); helper = new TestHelper(shader, ShaderFeatures.None); helper.data.stripUnusedXRVariants = true; - helper.data.passName = ShaderScriptableStripper.kPassNameXRMotionVectors; - helper.IsTrue(helper.stripper.StripUnusedPass_XRMotionVectors(ref helper.data)); - helper.IsTrue(helper.stripper.StripUnusedPass(ref helper.data)); + helper.data.passName = ShaderScriptableStripper.kPassNameMotionVectors; + TestHelper.s_EnabledKeywords = new System.Collections.Generic.List() { "APPLICATION_SPACE_WARP_MOTION" }; + helper.IsTrue(helper.stripper.StripInvalidVariants_MotionVectors(ref helper.data)); + helper.IsTrue(helper.stripper.StripInvalidVariants(ref helper.data)); + + // Test with keyword disabled should not strip even if XR variants stripping is enabled + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripUnusedXRVariants = true; + helper.data.passName = ShaderScriptableStripper.kPassNameMotionVectors; + TestHelper.s_EnabledKeywords = new System.Collections.Generic.List() { }; + helper.IsFalse(helper.stripper.StripInvalidVariants_MotionVectors(ref helper.data)); + helper.IsFalse(helper.stripper.StripInvalidVariants(ref helper.data)); } public void TestStripUnusedPass_ShadowCaster(Shader shader)