Skip to content

Commit 8b5bd0d

Browse files
SuminCho1Evergreen
authored andcommitted
'Shader warning in 'Hidden/HDRP/DebugFullScreen': HLSLcc: Large chunk of constant data detected' after building HDRP project
1 parent ff73256 commit 8b5bd0d

1 file changed

Lines changed: 76 additions & 35 deletions

File tree

Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlsl

Lines changed: 76 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33

44
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl"
55

6+
// Helper to pack 4 characters into one 32-bit uint
7+
// Use (a << 24) for the first char, (b << 16) for the second, etc.
8+
#define PACK_BYTES(a, b, c, d) \
9+
(((uint)(a) << 24) | ((uint)(b) << 16) | ((uint)(c) << 8) | (uint)(d))
10+
11+
// Macro to pack 32 elements into 8 uints
12+
#define PACK_STRING_32( \
13+
c0, c1, c2, c3, \
14+
c4, c5, c6, c7, \
15+
c8, c9, c10, c11, \
16+
c12, c13, c14, c15, \
17+
c16, c17, c18, c19, \
18+
c20, c21, c22, c23, \
19+
c24, c25, c26, c27, \
20+
c28, c29, c30, c31) \
21+
{ \
22+
PACK_BYTES(c0, c1, c2, c3), \
23+
PACK_BYTES(c4, c5, c6, c7), \
24+
PACK_BYTES(c8, c9, c10, c11), \
25+
PACK_BYTES(c12, c13, c14, c15), \
26+
PACK_BYTES(c16, c17, c18, c19), \
27+
PACK_BYTES(c20, c21, c22, c23), \
28+
PACK_BYTES(c24, c25, c26, c27), \
29+
PACK_BYTES(c28, c29, c30, c31) \
30+
}
31+
632
// Indices for Mipmap Debug Legend Strings
733
#define _kNotStreamingIndex 0
834
#define _kStreamingIndex 1
@@ -40,60 +66,75 @@
4066
#define _kRecentlyUpdated 28
4167
#define _kNotRecentlyUpdated 29
4268

43-
static const uint kMipmapDebugLegendStrings[][32] =
69+
static const uint kMipmapDebugLegendStrings[][8] =
4470
{
4571
// Status
46-
{13, 'N','o','t',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
47-
{ 9, 'S','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
48-
{31, 'S','t','r','e','a','m','i','n','g',' ','(','m','a','n','u','a','l','l','y',' ','v','i','a',' ','s','c','r','i','p','t',')'},
49-
{18, 'N','o',' ','t','e','x','t','u','r','e',' ','i','n',' ','s','l','o','t','.','.','.','.','.','.','.','.','.','.','.','.','.'},
50-
{ 7, 'W','a','r','n','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
51-
{21, 'U','n','k','n','o','w','n',' ','(','n','o',' ','r','e','n','d','e','r','e','r',')','.','.','.','.','.','.','.','.','.','.'},
52-
{24, 'T','e','x','t','u','r','e','S','t','r','e','a','m','e','r',' ','d','i','s','a','b','l','e','d','.','.','.','.','.','.','.'},
53-
{19, 'N','o',' ','m','i','p','m','a','p',' ','g','e','n','e','r','a','t','e','d','.','.','.','.','.','.','.','.','.','.','.','.'},
54-
{21, 'S','t','r','e','a','m','i','n','g',' ','n','o','t',' ','e','n','a','b','l','e','d','.','.','.','.','.','.','.','.','.','.'},
55-
{19, 'C','a','n','n','o','t',' ','s','t','r','e','a','m',' ','a','s','y','n','c','.','.','.','.','.','.','.','.','.','.','.','.'},
56-
{ 7, 'T','e','r','r','a','i','n','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
57-
58-
{23, 'N','o',' ','t','e','x','t','u','r','e','s',' ','o','n',' ','m','a','t','e','r','i','a','l','.','.','.','.','.','.','.','.'},
59-
{15, 'I','s','s','u','e','s',' ','d','e','t','e','c','t','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
60-
{13, 'A','l','l',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
61-
{29, 'A','l','l',' ','s','t','r','e','a','m','i','n','g',' ','(','s','o','m','e',' ','m','a','n','u','a','l','l','y',')','.','.'},
62-
{21, 'N','o',' ','t','e','x','t','u','r','e','s',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.'},
63-
{14, 'S','o','m','e',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
64-
{30, 'S','o','m','e',' ','s','t','r','e','a','m','i','n','g',' ','(','s','o','m','e',' ','m','a','n','u','a','l','l','y',')','.'},
72+
PACK_STRING_32(13, 'N','o','t',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
73+
PACK_STRING_32( 9, 'S','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
74+
PACK_STRING_32(31, 'S','t','r','e','a','m','i','n','g',' ','(','m','a','n','u','a','l','l','y',' ','v','i','a',' ','s','c','r','i','p','t',')'),
75+
PACK_STRING_32(18, 'N','o',' ','t','e','x','t','u','r','e',' ','i','n',' ','s','l','o','t','.','.','.','.','.','.','.','.','.','.','.','.','.'),
76+
PACK_STRING_32( 7, 'W','a','r','n','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
77+
PACK_STRING_32(21, 'U','n','k','n','o','w','n',' ','(','n','o',' ','r','e','n','d','e','r','e','r',')','.','.','.','.','.','.','.','.','.','.'),
78+
PACK_STRING_32(24, 'T','e','x','t','u','r','e','S','t','r','e','a','m','e','r',' ','d','i','s','a','b','l','e','d','.','.','.','.','.','.','.'),
79+
PACK_STRING_32(19, 'N','o',' ','m','i','p','m','a','p',' ','g','e','n','e','r','a','t','e','d','.','.','.','.','.','.','.','.','.','.','.','.'),
80+
PACK_STRING_32(21, 'S','t','r','e','a','m','i','n','g',' ','n','o','t',' ','e','n','a','b','l','e','d','.','.','.','.','.','.','.','.','.','.'),
81+
PACK_STRING_32(19, 'C','a','n','n','o','t',' ','s','t','r','e','a','m',' ','a','s','y','n','c','.','.','.','.','.','.','.','.','.','.','.','.'),
82+
PACK_STRING_32( 7, 'T','e','r','r','a','i','n','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
83+
84+
PACK_STRING_32(23, 'N','o',' ','t','e','x','t','u','r','e','s',' ','o','n',' ','m','a','t','e','r','i','a','l','.','.','.','.','.','.','.','.'),
85+
PACK_STRING_32(15, 'I','s','s','u','e','s',' ','d','e','t','e','c','t','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
86+
PACK_STRING_32(13, 'A','l','l',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
87+
PACK_STRING_32(29, 'A','l','l',' ','s','t','r','e','a','m','i','n','g',' ','(','s','o','m','e',' ','m','a','n','u','a','l','l','y',')','.','.'),
88+
PACK_STRING_32(21, 'N','o',' ','t','e','x','t','u','r','e','s',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.'),
89+
PACK_STRING_32(14, 'S','o','m','e',' ','s','t','r','e','a','m','i','n','g','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
90+
PACK_STRING_32(30, 'S','o','m','e',' ','s','t','r','e','a','m','i','n','g',' ','(','s','o','m','e',' ','m','a','n','u','a','l','l','y',')','.'),
6591

6692
// MipCount
67-
{16, 'I','n','v','a','l','i','d',' ','m','i','p','C','o','u','n','t','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
68-
{26, 'M','o','r','e',' ','t','h','a','n',' ','1','4',' ','m','i','p','s',' ','u','p','l','o','a','d','e','d','.','.','.','.','.'},
93+
PACK_STRING_32(16, 'I','n','v','a','l','i','d',' ','m','i','p','C','o','u','n','t','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
94+
PACK_STRING_32(26, 'M','o','r','e',' ','t','h','a','n',' ','1','4',' ','m','i','p','s',' ','u','p','l','o','a','d','e','d','.','.','.','.','.'),
6995

7096
// Ratio
71-
{18, 'H','i','g','h',' ','p','i','x','e','l',' ','d','e','n','s','i','t','y','.','.','.','.','.','.','.','.','.','.','.','.','.'},
72-
{17, 'L','o','w',' ','p','i','x','e','l',' ','d','e','n','s','i','t','y','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
97+
PACK_STRING_32(18, 'H','i','g','h',' ','p','i','x','e','l',' ','d','e','n','s','i','t','y','.','.','.','.','.','.','.','.','.','.','.','.','.'),
98+
PACK_STRING_32(17, 'L','o','w',' ','p','i','x','e','l',' ','d','e','n','s','i','t','y','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
7399

74100
// Priorities
75-
{10, 'L','o','w',' ','(','-','1','2','8',')','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
76-
{10, 'H','i','g','h',' ','(','1','2','7',')','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
101+
PACK_STRING_32(10, 'L','o','w',' ','(','-','1','2','8',')','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
102+
PACK_STRING_32(10, 'H','i','g','h',' ','(','1','2','7',')','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
77103

78104
// Performance
79-
{10, 'M','i','p','s',' ','s','a','v','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
80-
{31, 'M','i','p','s',' ','s','a','v','e','d',' ','(','s','o','m','e',' ','c','a','c','h','e','d',' ','o','n',' ','G','P','U',')'},
81-
{30, 'N','o',' ','s','a','v','i','n','g','s',' ','(','a','l','l',' ','m','i','p','s',' ','r','e','q','u','i','r','e','d',')','.'},
82-
{30, 'N','o','t',' ','a','l','l',' ','r','e','q','u','i','r','e','d',' ','m','i','p','s',' ','u','p','l','o','a','d','e','d','.'},
105+
PACK_STRING_32(10, 'M','i','p','s',' ','s','a','v','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
106+
PACK_STRING_32(31, 'M','i','p','s',' ','s','a','v','e','d',' ','(','s','o','m','e',' ','c','a','c','h','e','d',' ','o','n',' ','G','P','U',')'),
107+
PACK_STRING_32(30, 'N','o',' ','s','a','v','i','n','g','s',' ','(','a','l','l',' ','m','i','p','s',' ','r','e','q','u','i','r','e','d',')','.'),
108+
PACK_STRING_32(30, 'N','o','t',' ','a','l','l',' ','r','e','q','u','i','r','e','d',' ','m','i','p','s',' ','u','p','l','o','a','d','e','d','.'),
83109

84110
// RecentlyUpdated
85-
{13, 'J','u','s','t',' ','s','t','r','e','a','m','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
86-
{21, 'N','o','t',' ','r','e','c','e','n','t','l','y',' ','s','t','r','e','a','m','e','d','.','.','.','.','.','.','.','.','.','.'},
111+
PACK_STRING_32(13, 'J','u','s','t',' ','s','t','r','e','a','m','e','d','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'),
112+
PACK_STRING_32(21, 'N','o','t',' ','r','e','c','e','n','t','l','y',' ','s','t','r','e','a','m','e','d','.','.','.','.','.','.','.','.','.','.'),
87113
};
88114

115+
uint GetCharFromPacked(int stringIdx, uint charIdx)
116+
{
117+
// Divide by 4 to find which uint, modulo 4 to find the byte
118+
uint arrayIdx = charIdx * 0.25;
119+
120+
// Shift: 24 for byte 0, 16 for byte 1, 8 for byte 2, 0 for byte 3
121+
uint shift = (3 - (charIdx % 4)) * 8;
122+
123+
return (kMipmapDebugLegendStrings[stringIdx][arrayIdx] >> shift) & 0xFF;
124+
}
125+
89126
void DrawString(int stringIdx, uint2 unormCoord, float3 textColor, uint2 textLocation, bool alignRight, inout float3 outputColor)
90127
{
91-
const uint stringSize = kMipmapDebugLegendStrings[stringIdx][0];
128+
const uint stringSize = GetCharFromPacked(stringIdx, 0);
129+
92130
const int direction = alignRight ? -1 : 1;
93131
uint i = alignRight ? stringSize : 1;
94-
132+
95133
[fastopt] for (; alignRight ? i > 0 : i <= stringSize; i += direction)
96-
DrawCharacter(kMipmapDebugLegendStrings[stringIdx][i], textColor, unormCoord, textLocation, outputColor.rgb, direction);
134+
{
135+
uint character = GetCharFromPacked(stringIdx, i);
136+
DrawCharacter(character, textColor, unormCoord, textLocation, outputColor.rgb, direction);
137+
}
97138
}
98139

99140
void DrawString(int stringIdx, uint2 unormCoord, float3 textColor, uint2 textLocation, inout float3 outputColor)

0 commit comments

Comments
 (0)