Skip to content

Commit 24e4916

Browse files
committed
Fix two more shader warnings (caused by early outs, which the HLSL compiler hates). These likely crept in with the 10.7.0 upgrade. (#31)
Co-authored-by: pastasfuture <nickb@bonfirestudios.com>
1 parent 905c583 commit 24e4916

2 files changed

Lines changed: 39 additions & 30 deletions

File tree

com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,42 @@ float4 GetStreamingMipColor(uint mipCount, float4 mipInfo)
9999
// w = 0
100100
uint originalTextureMipCount = uint(mipInfo.y);
101101

102+
float4 res = 0.0;
103+
102104
// If material/shader mip info (original mip level) has not been set its not a streamed texture
103105
if (originalTextureMipCount == 0)
104-
return float4(1.0, 1.0, 1.0, 0.0);
105-
106-
uint desiredMipLevel = uint(mipInfo.z);
107-
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel);
108-
if (mipCount == 0)
109-
{
110-
// Magenta if mip count invalid
111-
return float4(1.0, 0.0, 1.0, 1.0);
112-
}
113-
else if (mipCount < mipCountDesired)
114106
{
115-
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired
116-
float ratioToDesired = float(mipCount) / float(mipCountDesired);
117-
return float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired);
118-
}
119-
else if (mipCount >= originalTextureMipCount)
120-
{
121-
// original color when at (or beyond) original mip count
122-
return float4(1.0, 1.0, 1.0, 0.0);
107+
res = float4(1.0, 1.0, 1.0, 0.0);
123108
}
124109
else
125110
{
126-
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original
127-
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount);
128-
return float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal);
111+
uint desiredMipLevel = uint(mipInfo.z);
112+
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel);
113+
if (mipCount == 0)
114+
{
115+
// Magenta if mip count invalid
116+
res = float4(1.0, 0.0, 1.0, 1.0);
117+
}
118+
else if (mipCount < mipCountDesired)
119+
{
120+
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired
121+
float ratioToDesired = float(mipCount) / float(mipCountDesired);
122+
res = float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired);
123+
}
124+
else if (mipCount >= originalTextureMipCount)
125+
{
126+
// original color when at (or beyond) original mip count
127+
res = float4(1.0, 1.0, 1.0, 0.0);
128+
}
129+
else
130+
{
131+
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original
132+
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount);
133+
res = float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal);
134+
}
129135
}
136+
137+
return res;
130138
}
131139

132140
float4 GetSimpleMipCountColor(uint mipCount)

com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,20 @@ void FillMaterialTransmission(uint diffusionProfileIndex, float thickness, inout
233233

234234
uint FindDiffusionProfileIndex(uint diffusionProfileHash)
235235
{
236-
if (diffusionProfileHash == 0)
237-
return 0;
238-
239236
uint diffusionProfileIndex = 0;
240-
uint i = 0;
241237

242-
// Fetch the 4 bit index number by looking for the diffusion profile unique ID:
243-
for (i = 0; i < _DiffusionProfileCount; i++)
238+
if (diffusionProfileHash != 0)
244239
{
245-
if (_DiffusionProfileHashTable[i].x == diffusionProfileHash)
240+
uint i = 0;
241+
242+
// Fetch the 4 bit index number by looking for the diffusion profile unique ID:
243+
for (i = 0; i < _DiffusionProfileCount; i++)
246244
{
247-
diffusionProfileIndex = i;
248-
break;
245+
if (_DiffusionProfileHashTable[i].x == diffusionProfileHash)
246+
{
247+
diffusionProfileIndex = i;
248+
break;
249+
}
249250
}
250251
}
251252

0 commit comments

Comments
 (0)