Skip to content

Commit a0e21be

Browse files
author
Antti Tapaninen
committed
metal/ios: lower samplecount for mobile compute limitations, disable MIS since there is no read_write texture support
1 parent 8d98423 commit a0e21be

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/ComputeGgxIblSampleData.compute

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
#include "../../../ShaderLibrary/Common.hlsl"
44
#include "../../../ShaderLibrary/ImageBasedLighting.hlsl"
55

6+
#ifdef SHADER_API_MOBILE
7+
#define MAX_IBL_SAMPLE_CNT 34
8+
#else
69
#define MAX_IBL_SAMPLE_CNT 89
10+
#endif
711

812
RWTexture2D<float4> output; // [MAX_SAMPLE_CNT x UNITY_SPECCUBE_LOD_STEPS]
913

Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/RuntimeFilterIBL.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace UnityEngine.Experimental.Rendering.HDPipeline
77
public class IBLFilterGGX
88
{
99
RenderTexture m_GgxIblSampleData = null;
10-
const int k_GgxIblMaxSampleCount = 89; // Width
10+
int k_GgxIblMaxSampleCount = TextureCache.isMobileBuildTarget ? 34 : 89; // Width
1111
const int k_GgxIblMipCountMinusOne = 6; // Height (UNITY_SPECCUBE_LOD_STEPS)
1212

1313
ComputeShader m_ComputeGgxIblSampleDataCS = null;
@@ -19,11 +19,18 @@ public class IBLFilterGGX
1919

2020
Material m_GgxConvolveMaterial = null; // Convolves a cubemap with GGX
2121

22+
bool m_SupportMIS = !TextureCache.isMobileBuildTarget;
23+
2224
public bool IsInitialized()
2325
{
2426
return m_GgxIblSampleData != null;
2527
}
2628

29+
public bool SupportMIS
30+
{
31+
get { return m_SupportMIS; }
32+
}
33+
2734
public void Initialize(ScriptableRenderContext context)
2835
{
2936
if (!m_ComputeGgxIblSampleDataCS)
@@ -32,7 +39,7 @@ public void Initialize(ScriptableRenderContext context)
3239
m_ComputeGgxIblSampleDataKernel = m_ComputeGgxIblSampleDataCS.FindKernel("ComputeGgxIblSampleData");
3340
}
3441

35-
if (!m_BuildProbabilityTablesCS)
42+
if (!m_BuildProbabilityTablesCS && SupportMIS)
3643
{
3744
m_BuildProbabilityTablesCS = Resources.Load<ComputeShader>("BuildProbabilityTables");
3845
m_ConditionalDensitiesKernel = m_BuildProbabilityTablesCS.FindKernel("ComputeConditionalDensities");

Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private void RenderCubemapGGXConvolution(ScriptableRenderContext renderContext,
358358
renderContext.ExecuteCommandBuffer(cmd);
359359
cmd.Dispose();
360360

361-
if (m_useMIS)
361+
if (m_useMIS && m_iblFilterGgx.SupportMIS)
362362
{
363363
m_iblFilterGgx.FilterCubemapMIS(renderContext, input, target, mipCount, m_SkyboxConditionalCdfRT, m_SkyboxMarginalRowCdfRT, m_CubemapFaceMesh);
364364
}

Assets/ScriptableRenderPipeline/ShaderLibrary/ImageBasedLighting.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,17 @@ uint GetIBLRuntimeFilterSampleCount(uint mipLevel)
306306
{
307307
case 1: sampleCount = 21; break;
308308
case 2: sampleCount = 34; break;
309+
#ifdef SHADER_API_MOBILE
310+
case 3: sampleCount = 34; break;
311+
case 4: sampleCount = 34; break;
312+
case 5: sampleCount = 34; break;
313+
case 6: sampleCount = 34; break; // UNITY_SPECCUBE_LOD_STEPS
314+
#else
309315
case 3: sampleCount = 55; break;
310316
case 4: sampleCount = 89; break;
311317
case 5: sampleCount = 89; break;
312318
case 6: sampleCount = 89; break; // UNITY_SPECCUBE_LOD_STEPS
319+
#endif
313320
}
314321

315322
return sampleCount;

0 commit comments

Comments
 (0)