Skip to content

Commit

Permalink
Fixed hash function for PS5.
Browse files Browse the repository at this point in the history
Backport https://jira.unity3d.com/browse/UUM-38845

The original artefact that caused the test to be disabled on PS5 did not reproduce anymore. Instead a new bug appeared which is related to the computation of noise values on PS5. The PSSL shader compiler was unhappy to divide by float(0xFFFFFFFF), and failed to generate any noise pattern. The workaround is to replace float(0xFFFFFFFF) by float(0x00FFFFFF), which is the maximal continuous integer value that can be represented as a float (mantissa is 24 bits).

Contrary to other backports for this bug, 010-BRG-Simple does not exist on this branch and is thus not an instability.

Reference image for PS5 HDRP Runtime test 009-SG-FullScreenTarget was incorrect and did not have procedural noise working: new reference image fixes this.
  • Loading branch information
kaychang-unity authored and Evergreen committed Oct 13, 2023
1 parent f6aac47 commit ff70467
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Packages/com.unity.render-pipelines.core/ShaderLibrary/Hashes.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ void Hash_Tchou_2_1_float(float2 i, out float o)
uint r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_1_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_2_1_half(half2 i, out half o)
{
uint r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_1_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_2_3_uint(uint2 q, out uint3 o)
Expand All @@ -45,15 +45,15 @@ void Hash_Tchou_2_3_float(float2 i, out float3 o)
uint3 r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_3_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_2_3_half(half2 i, out half3 o)
{
uint3 r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_3_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_2_2_uint(uint2 v, out uint2 o)
Expand All @@ -73,15 +73,15 @@ void Hash_Tchou_2_2_float(float2 i, out float2 o)
uint2 r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_2_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_2_2_half(half2 i, out half2 o)
{
uint2 r;
uint2 v = (uint2) (int2) round(i);
Hash_Tchou_2_2_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_3_1_uint(uint3 v, out uint o)
Expand All @@ -102,15 +102,15 @@ void Hash_Tchou_3_1_float(float3 i, out float o)
uint r;
uint3 v = (uint3) (int3) round(i);
Hash_Tchou_3_1_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_3_1_half(half3 i, out half o)
{
uint r;
uint3 v = (uint3) (int3) round(i);
Hash_Tchou_3_1_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_3_3_uint(uint3 v, out uint3 o)
Expand All @@ -132,14 +132,14 @@ void Hash_Tchou_3_3_float(float3 i, out float3 o)
{
uint3 r, v = (uint3) (int3) round(i);
Hash_Tchou_3_3_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_Tchou_3_3_half(half3 i, out half3 o)
{
uint3 r, v = (uint3) (int3) round(i);
Hash_Tchou_3_3_uint(v, r);
o = r * (1.0 / float(0xffffffff));
o = (r >> 8) * (1.0 / float(0x00ffffff));
}

void Hash_LegacySine_2_1_float(float2 i, out float o)
Expand Down

0 comments on commit ff70467

Please sign in to comment.