|
3 | 3 |
|
4 | 4 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl" |
5 | 5 |
|
| 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 | + |
6 | 32 | // Indices for Mipmap Debug Legend Strings |
7 | 33 | #define _kNotStreamingIndex 0 |
8 | 34 | #define _kStreamingIndex 1 |
|
40 | 66 | #define _kRecentlyUpdated 28 |
41 | 67 | #define _kNotRecentlyUpdated 29 |
42 | 68 |
|
43 | | -static const uint kMipmapDebugLegendStrings[][32] = |
| 69 | +static const uint kMipmapDebugLegendStrings[][8] = |
44 | 70 | { |
45 | 71 | // 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',')','.'), |
65 | 91 |
|
66 | 92 | // 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','.','.','.','.','.'), |
69 | 95 |
|
70 | 96 | // 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','.','.','.','.','.','.','.','.','.','.','.','.','.','.'), |
73 | 99 |
|
74 | 100 | // 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',')','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'), |
77 | 103 |
|
78 | 104 | // 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','.'), |
83 | 109 |
|
84 | 110 | // 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','.','.','.','.','.','.','.','.','.','.'), |
87 | 113 | }; |
88 | 114 |
|
| 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 | + |
89 | 126 | void DrawString(int stringIdx, uint2 unormCoord, float3 textColor, uint2 textLocation, bool alignRight, inout float3 outputColor) |
90 | 127 | { |
91 | | - const uint stringSize = kMipmapDebugLegendStrings[stringIdx][0]; |
| 128 | + const uint stringSize = GetCharFromPacked(stringIdx, 0); |
| 129 | + |
92 | 130 | const int direction = alignRight ? -1 : 1; |
93 | 131 | uint i = alignRight ? stringSize : 1; |
94 | | - |
| 132 | + |
95 | 133 | [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 | + } |
97 | 138 | } |
98 | 139 |
|
99 | 140 | void DrawString(int stringIdx, uint2 unormCoord, float3 textColor, uint2 textLocation, inout float3 outputColor) |
|
0 commit comments