Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit d20d5ad

Browse files
committed
Yet another GC fix
1 parent d803468 commit d20d5ad

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

PostProcessing/Runtime/Utils/TextureFormatUtilities.cs

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,65 @@ namespace UnityEngine.Rendering.PostProcessing
88
// Temporary code dump until the texture format refactor goes into trunk...
99
public static class TextureFormatUtilities
1010
{
11-
static Dictionary<TextureFormat, RenderTextureFormat> s_FormatAliasMap;
11+
static Dictionary<int, RenderTextureFormat> s_FormatAliasMap;
1212
static Dictionary<int, bool> s_SupportedRenderTextureFormats;
1313

1414
static TextureFormatUtilities()
1515
{
16-
s_FormatAliasMap = new Dictionary<TextureFormat, RenderTextureFormat>
16+
s_FormatAliasMap = new Dictionary<int, RenderTextureFormat>
1717
{
18-
{ TextureFormat.Alpha8, RenderTextureFormat.ARGB32 },
19-
{ TextureFormat.ARGB4444, RenderTextureFormat.ARGB4444 },
20-
{ TextureFormat.RGB24, RenderTextureFormat.ARGB32 },
21-
{ TextureFormat.RGBA32, RenderTextureFormat.ARGB32 },
22-
{ TextureFormat.ARGB32, RenderTextureFormat.ARGB32 },
23-
{ TextureFormat.RGB565, RenderTextureFormat.RGB565 },
24-
{ TextureFormat.R16, RenderTextureFormat.RHalf },
25-
{ TextureFormat.DXT1, RenderTextureFormat.ARGB32 },
26-
{ TextureFormat.DXT5, RenderTextureFormat.ARGB32 },
27-
{ TextureFormat.RGBA4444, RenderTextureFormat.ARGB4444 },
28-
{ TextureFormat.BGRA32, RenderTextureFormat.ARGB32 },
29-
{ TextureFormat.RHalf, RenderTextureFormat.RHalf },
30-
{ TextureFormat.RGHalf, RenderTextureFormat.RGHalf },
31-
{ TextureFormat.RGBAHalf, RenderTextureFormat.ARGBHalf },
32-
{ TextureFormat.RFloat, RenderTextureFormat.RFloat },
33-
{ TextureFormat.RGFloat, RenderTextureFormat.RGFloat },
34-
{ TextureFormat.RGBAFloat, RenderTextureFormat.ARGBFloat },
35-
{ TextureFormat.RGB9e5Float, RenderTextureFormat.ARGBHalf },
36-
{ TextureFormat.BC4, RenderTextureFormat.R8 },
37-
{ TextureFormat.BC5, RenderTextureFormat.RGHalf },
38-
{ TextureFormat.BC6H, RenderTextureFormat.ARGBHalf },
39-
{ TextureFormat.BC7, RenderTextureFormat.ARGB32 },
18+
{ (int)TextureFormat.Alpha8, RenderTextureFormat.ARGB32 },
19+
{ (int)TextureFormat.ARGB4444, RenderTextureFormat.ARGB4444 },
20+
{ (int)TextureFormat.RGB24, RenderTextureFormat.ARGB32 },
21+
{ (int)TextureFormat.RGBA32, RenderTextureFormat.ARGB32 },
22+
{ (int)TextureFormat.ARGB32, RenderTextureFormat.ARGB32 },
23+
{ (int)TextureFormat.RGB565, RenderTextureFormat.RGB565 },
24+
{ (int)TextureFormat.R16, RenderTextureFormat.RHalf },
25+
{ (int)TextureFormat.DXT1, RenderTextureFormat.ARGB32 },
26+
{ (int)TextureFormat.DXT5, RenderTextureFormat.ARGB32 },
27+
{ (int)TextureFormat.RGBA4444, RenderTextureFormat.ARGB4444 },
28+
{ (int)TextureFormat.BGRA32, RenderTextureFormat.ARGB32 },
29+
{ (int)TextureFormat.RHalf, RenderTextureFormat.RHalf },
30+
{ (int)TextureFormat.RGHalf, RenderTextureFormat.RGHalf },
31+
{ (int)TextureFormat.RGBAHalf, RenderTextureFormat.ARGBHalf },
32+
{ (int)TextureFormat.RFloat, RenderTextureFormat.RFloat },
33+
{ (int)TextureFormat.RGFloat, RenderTextureFormat.RGFloat },
34+
{ (int)TextureFormat.RGBAFloat, RenderTextureFormat.ARGBFloat },
35+
{ (int)TextureFormat.RGB9e5Float, RenderTextureFormat.ARGBHalf },
36+
{ (int)TextureFormat.BC4, RenderTextureFormat.R8 },
37+
{ (int)TextureFormat.BC5, RenderTextureFormat.RGHalf },
38+
{ (int)TextureFormat.BC6H, RenderTextureFormat.ARGBHalf },
39+
{ (int)TextureFormat.BC7, RenderTextureFormat.ARGB32 },
4040
#if !UNITY_IOS && !UNITY_TVOS
41-
{ TextureFormat.DXT1Crunched, RenderTextureFormat.ARGB32 },
42-
{ TextureFormat.DXT5Crunched, RenderTextureFormat.ARGB32 },
41+
{ (int)TextureFormat.DXT1Crunched, RenderTextureFormat.ARGB32 },
42+
{ (int)TextureFormat.DXT5Crunched, RenderTextureFormat.ARGB32 },
4343
#endif
44-
{ TextureFormat.PVRTC_RGB2, RenderTextureFormat.ARGB32 },
45-
{ TextureFormat.PVRTC_RGBA2, RenderTextureFormat.ARGB32 },
46-
{ TextureFormat.PVRTC_RGB4, RenderTextureFormat.ARGB32 },
47-
{ TextureFormat.PVRTC_RGBA4, RenderTextureFormat.ARGB32 },
44+
{ (int)TextureFormat.PVRTC_RGB2, RenderTextureFormat.ARGB32 },
45+
{ (int)TextureFormat.PVRTC_RGBA2, RenderTextureFormat.ARGB32 },
46+
{ (int)TextureFormat.PVRTC_RGB4, RenderTextureFormat.ARGB32 },
47+
{ (int)TextureFormat.PVRTC_RGBA4, RenderTextureFormat.ARGB32 },
4848
#if !UNITY_2018_1_OR_NEWER
49-
{ TextureFormat.ATC_RGB4, RenderTextureFormat.ARGB32 },
50-
{ TextureFormat.ATC_RGBA8, RenderTextureFormat.ARGB32 },
49+
{ (int)TextureFormat.ATC_RGB4, RenderTextureFormat.ARGB32 },
50+
{ (int)TextureFormat.ATC_RGBA8, RenderTextureFormat.ARGB32 },
5151
#endif
52-
{ TextureFormat.ETC_RGB4, RenderTextureFormat.ARGB32 },
53-
{ TextureFormat.ETC2_RGB, RenderTextureFormat.ARGB32 },
54-
{ TextureFormat.ETC2_RGBA1, RenderTextureFormat.ARGB32 },
55-
{ TextureFormat.ETC2_RGBA8, RenderTextureFormat.ARGB32 },
56-
{ TextureFormat.ASTC_RGB_4x4, RenderTextureFormat.ARGB32 },
57-
{ TextureFormat.ASTC_RGB_5x5, RenderTextureFormat.ARGB32 },
58-
{ TextureFormat.ASTC_RGB_6x6, RenderTextureFormat.ARGB32 },
59-
{ TextureFormat.ASTC_RGB_8x8, RenderTextureFormat.ARGB32 },
60-
{ TextureFormat.ASTC_RGB_10x10, RenderTextureFormat.ARGB32 },
61-
{ TextureFormat.ASTC_RGB_12x12, RenderTextureFormat.ARGB32 },
62-
{ TextureFormat.ASTC_RGBA_4x4, RenderTextureFormat.ARGB32 },
63-
{ TextureFormat.ASTC_RGBA_5x5, RenderTextureFormat.ARGB32 },
64-
{ TextureFormat.ASTC_RGBA_6x6, RenderTextureFormat.ARGB32 },
65-
{ TextureFormat.ASTC_RGBA_8x8, RenderTextureFormat.ARGB32 },
66-
{ TextureFormat.ASTC_RGBA_10x10, RenderTextureFormat.ARGB32 },
67-
{ TextureFormat.ASTC_RGBA_12x12, RenderTextureFormat.ARGB32 },
68-
{ TextureFormat.ETC_RGB4_3DS, RenderTextureFormat.ARGB32 },
69-
{ TextureFormat.ETC_RGBA8_3DS, RenderTextureFormat.ARGB32 }
52+
{ (int)TextureFormat.ETC_RGB4, RenderTextureFormat.ARGB32 },
53+
{ (int)TextureFormat.ETC2_RGB, RenderTextureFormat.ARGB32 },
54+
{ (int)TextureFormat.ETC2_RGBA1, RenderTextureFormat.ARGB32 },
55+
{ (int)TextureFormat.ETC2_RGBA8, RenderTextureFormat.ARGB32 },
56+
{ (int)TextureFormat.ASTC_RGB_4x4, RenderTextureFormat.ARGB32 },
57+
{ (int)TextureFormat.ASTC_RGB_5x5, RenderTextureFormat.ARGB32 },
58+
{ (int)TextureFormat.ASTC_RGB_6x6, RenderTextureFormat.ARGB32 },
59+
{ (int)TextureFormat.ASTC_RGB_8x8, RenderTextureFormat.ARGB32 },
60+
{ (int)TextureFormat.ASTC_RGB_10x10, RenderTextureFormat.ARGB32 },
61+
{ (int)TextureFormat.ASTC_RGB_12x12, RenderTextureFormat.ARGB32 },
62+
{ (int)TextureFormat.ASTC_RGBA_4x4, RenderTextureFormat.ARGB32 },
63+
{ (int)TextureFormat.ASTC_RGBA_5x5, RenderTextureFormat.ARGB32 },
64+
{ (int)TextureFormat.ASTC_RGBA_6x6, RenderTextureFormat.ARGB32 },
65+
{ (int)TextureFormat.ASTC_RGBA_8x8, RenderTextureFormat.ARGB32 },
66+
{ (int)TextureFormat.ASTC_RGBA_10x10, RenderTextureFormat.ARGB32 },
67+
{ (int)TextureFormat.ASTC_RGBA_12x12, RenderTextureFormat.ARGB32 },
68+
{ (int)TextureFormat.ETC_RGB4_3DS, RenderTextureFormat.ARGB32 },
69+
{ (int)TextureFormat.ETC_RGBA8_3DS, RenderTextureFormat.ARGB32 }
7070
};
7171

7272
// In 2018.1 SystemInfo.SupportsRenderTextureFormat() generates garbage so we need to
@@ -93,7 +93,7 @@ public static RenderTextureFormat GetUncompressedRenderTextureFormat(Texture tex
9393
var inFormat = ((Texture2D)texture).format;
9494
RenderTextureFormat outFormat;
9595

96-
if (!s_FormatAliasMap.TryGetValue(inFormat, out outFormat))
96+
if (!s_FormatAliasMap.TryGetValue((int)inFormat, out outFormat))
9797
throw new NotSupportedException("Texture format not supported");
9898

9999
return outFormat;

0 commit comments

Comments
 (0)