Cogs.Core
FormatsGLES30.cpp
1#include "Foundation/Logging/Logger.h"
2
3#include "FormatsGLES30.h"
4#include "CapabilitiesGLES30.h"
5#include "../SamplerState.h"
6
7namespace {
8 static Cogs::Logging::Log logger = Cogs::Logging::getLogger("FormatsGLES30");
9
10 Cogs::OpenGLES30::DataFormatInfo DataFormats_[] = {
11 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Unknown = 0,
12
13 // Unsigned normalized byte formats
14 { GL_R8, GL_RED, GL_UNSIGNED_BYTE, 1, 1, 1, 0, 1, 1, 0, 1, 1 }, // R8_UNORM,
15 { GL_RG8, GL_RG, GL_UNSIGNED_BYTE, 1, 1, 1, 0, 1, 1, 0, 2, 1 }, // R8G8_UNORM,
16 { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 1, 1, 1, 0, 1, 1, 0, 3, 1 }, // R8G8B8_UNORM,
17 { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1, 1, 0, 1, 1, 0, 4, 1 }, // R8G8B8A8_UNORM,
18
19 // Unsigned 16 bit normalized integer formats
20 { GL_NONE, GL_NONE, GL_UNSIGNED_SHORT, 0, 0, 0, 0, 1, 1, 0, 1, 1 }, // R16_UNORM,
21 { GL_NONE, GL_NONE, GL_UNSIGNED_SHORT, 0, 0, 0, 0, 1, 1, 0, 2, 1 }, // R16G16_UNORM,
22 { GL_NONE, GL_NONE, GL_UNSIGNED_SHORT, 0, 0, 0, 0, 1, 1, 0, 3, 1 }, // R16G16B16_UNORM,
23 { GL_NONE, GL_NONE, GL_UNSIGNED_SHORT, 0, 0, 0, 0, 1, 1, 0, 4, 1 }, // R16G16B16A16_UNORM,
24
25 // Signed normalized byte formats
26 { GL_R8_SNORM, GL_RED, GL_BYTE, 1, 0, 1, 0, 1, 1, 0, 1, 1 }, // R8_SNORM,
27 { GL_RG8_SNORM, GL_RG, GL_BYTE, 1, 0, 1, 0, 1, 1, 0, 2, 1 }, // R8G8_SNORM,
28 { GL_RGB8_SNORM, GL_RGB, GL_BYTE, 1, 0, 1, 0, 1, 1, 0, 3, 1 }, // R8G8B8_SNORM,
29 { GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, 1, 0, 1, 0, 1, 1, 0, 4, 1 }, // R8G8B8A8_SNORM,
30
31 // Signed 16 bit normalized integer formats
32 { GL_NONE, GL_NONE, GL_SHORT, 0, 0, 0, 0, 1, 1, 0, 1, 1 }, // R16_SNORM,
33 { GL_NONE, GL_NONE, GL_SHORT, 0, 0, 0, 0, 1, 1, 0, 2, 1 }, // R16G16_SNORM,
34 { GL_NONE, GL_NONE, GL_SHORT, 0, 0, 0, 0, 1, 1, 0, 3, 1 }, // R16G16B16_SNORM,
35 { GL_NONE, GL_NONE, GL_SHORT, 0, 0, 0, 0, 1, 1, 0, 4, 1 }, // R16G16B16A16_SNORM,
36
37 // Unsigned byte formats
38 { GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R8_UINT,
39 { GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R8G8_UINT,
40 { GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R8G8B8_UINT,
41 { GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R8G8B8A8_UINT,
42
43 // Unsigned 16 bit integer formats
44 { GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R16_UINT,
45 { GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R16G16_UINT,
46 { GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R16G16B16_UINT,
47 { GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R16G16B16A16_UINT,
48
49 // Unsigned 32 bit integer formats
50 { GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R32_UINT,
51 { GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R32G32_UINT,
52 { GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R32G32B32_UINT,
53 { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R32G32B32A32_UINT,
54
55 // Signed byte formats
56 { GL_R8I, GL_RED_INTEGER, GL_BYTE, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R8_SINT,
57 { GL_RG8I, GL_RG_INTEGER, GL_BYTE, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R8G8_SINT,
58 { GL_RGB8I, GL_RGB_INTEGER, GL_BYTE, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R8G8B8_SINT,
59 { GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R8G8B8A8_SINT,
60
61 // Signed 16 bit integer formats
62 { GL_R16I, GL_RED_INTEGER, GL_SHORT, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R16_SINT,
63 { GL_RG16I, GL_RG_INTEGER, GL_SHORT, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R16G16_SINT,
64 { GL_RGB16I, GL_RGB_INTEGER, GL_SHORT, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R16G16B16_SINT,
65 { GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R16G16B16A16_SINT,
66
67 // Signed 32 bit integer formats
68 { GL_R32I, GL_RED_INTEGER, GL_INT, 1, 1, 0, 0, 1, 0, 1, 1, 1 }, // R32_SINT,
69 { GL_RG32I, GL_RG_INTEGER, GL_INT, 1, 1, 0, 0, 1, 0, 1, 2, 1 }, // R32G32_SINT,
70 { GL_RGB32I, GL_RGB_INTEGER, GL_INT, 1, 0, 0, 0, 1, 0, 1, 3, 1 }, // R32G32B32_SINT,
71 { GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, 1, 1, 0, 0, 1, 0, 1, 4, 1 }, // R32G32B32A32_SINT,
72
73 // 16 bit floating point formats
74 { GL_R16F, GL_RED, GL_HALF_FLOAT, 1, 0, 1, 0, 1, 0, 0, 1, 1 }, // R16_FLOAT,
75 { GL_RG16F, GL_RG, GL_HALF_FLOAT, 1, 0, 1, 0, 1, 0, 0, 2, 1 }, // R16G16_FLOAT,
76 { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, 1, 0, 1, 0, 1, 0, 0, 3, 1 }, // R16G16B16_FLOAT,
77 { GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 1, 0, 1, 0, 1, 0, 0, 4, 1 }, // R16G16B16A16_FLOAT,
78
79 // 32 bit floating point formats
80 { GL_R32F, GL_RED, GL_FLOAT, 1, 0, 0, 0, 1, 0, 0, 1, 1 }, // R32_FLOAT,
81 { GL_RG32F, GL_RG, GL_FLOAT, 1, 0, 0, 0, 1, 0, 0, 2, 1 }, // R32G32_FLOAT,
82 { GL_RGB32F, GL_RGB, GL_FLOAT, 1, 0, 0, 0, 1, 0, 0, 3, 1 }, // R32G32B32_FLOAT,
83 { GL_RGBA32F, GL_RGBA, GL_FLOAT, 1, 0, 0, 0, 1, 0, 0, 4, 1 }, // R32G32B32A32_FLOAT,
84
85 // Depth buffer formats
86 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // D16_UNORM,
87 { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // D24_UNORM,
88 { GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // D24S8_UNORM,
89 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // D32_FLOAT,
90 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // R32_TYPELESS,
91 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 0, 0, 0, 0, 0, 0, 0, 0}, // R16_TYPELESS,
92
93 // 8 bit typeless formats
94 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // R8T,
95 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // R8G8T,
96 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // R8G8B8T,
97 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // R8G8B8A8T,
98
99 // Reverse component order formats.
100 { GL_RGB8, GL_NONE, GL_UNSIGNED_BYTE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // B8G8R8,
101 { GL_RGB8, GL_NONE, GL_UNSIGNED_BYTE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // B8G8R8A8,
102
103 // Alpha formats
104 { GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // A8_UNORM,
105
106 // Compressed formats
107 { GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC1_TYPELESS,
108 { GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC1_UNORM,
109 { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC1_UNORM_SRGB,
110 { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC2_TYPELESS,
111 { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC2_UNORM,
112 { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC2_UNORM_SRGB,
113 { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC3_TYPELESS,
114 { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC3_UNORM,
115 { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC3_UNORM_SRGB,
116 { GL_COMPRESSED_RED_RGTC1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC4_TYPELESS,
117 { GL_COMPRESSED_RED_RGTC1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC4_UNORM,
118 { GL_COMPRESSED_SIGNED_RED_RGTC1_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC4_SNORM,
119 { GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC5_TYPELESS,
120 { GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC5_UNORM,
121 { GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC5_SNORM,
122
123
124 //BPTC
125 { GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC6H_SIGNED_FLOAT_RGB, FORMAT_RGBA_BP_UNORM_BLOCK16
126 { GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC6H_UNSIGNED_FLOAT_RGB, FORMAT_RGBA_BP_UNORM_BLOCK16
127 { GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC7_UNORM_RGBA, FORMAT_RGBA_BP_UNORM_BLOCK16
128 { GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // BC7_UNORM_SRGBA, FORMAT_RGBA_BP_UNORM_BLOCK16
129
130 //PVRTC
131 { GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // PVRTC_2BPPV1_UNORM_RGB
132 { GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // PVRTC_4BPPV1_UNORM_RGB
133 { GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // PVRTC_2BPPV1_UNORM_RGBA
134 { GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // PVRTC_4BPPV1_UNORM_RGBA
135
136 // ETC
137 { GL_COMPRESSED_R11_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
138 { GL_COMPRESSED_SIGNED_R11_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
139 { GL_COMPRESSED_RG11_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
140 { GL_COMPRESSED_SIGNED_RG11_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
141
142 { GL_COMPRESSED_RGB8_ETC2, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
143 { GL_COMPRESSED_SRGB8_ETC2, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
144
145 { GL_COMPRESSED_RGBA8_ETC2_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // ETC2_BLOCK16_UNORM_RGBA, FORMAT_RGBA_BP_UNORM_BLOCK16
146 { GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // ETC2_BLOCK16_UNORM_SRGBA, FORMAT_SRGBA_BP_UNORM_BLOCK16
147
148 // ASTC
149 { GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
150 { GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
151 { GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
152 { GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
153 { GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
154 { GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
155 { GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
156 { GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
157 { GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
158 { GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
159 { GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
160 { GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
161 { GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
162 { GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
163 // ASTC SRGBA
164 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
165 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
166 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
167 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
168 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
169 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
170 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
171 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
172 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
173 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
174 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
175 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
176 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
177 { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, GL_NONE, GL_NONE, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
178
179 // SRGB formats
180 { GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, 1, 0, 1, 0, 0, 0, 0, 0, 0 }, // R8G8B8A8_UNORM_SRGB,
181 { GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, // R8G8B8A8_UNORM_SRGB,
182
183 // 10 bit formats
184 { GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // R10G10B10A2_TYPELESS,
185 { GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 1, 1, 1, 0, 1, 1, 0, 4, 1 }, // R10G10B10A2_UNORM,
186 { GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, 1, 0, 1, 0, 1, 0, 1, 4, 1 }, // R10G10B10A2_UINT,
187 { GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV,1, 0, 1, 0, 0, 0, 0, 3, 1 }, // R11G11B10_FLOAT
188 { GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, 1, 1, 0, 0, 0, 0, 3, 1 }, // R5G6B5_UNORM
189 { GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 1, 1, 1, 0, 0, 0, 0, 4, 1 }, // R5G5B5A1_UNORM
190 { GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 1, 1, 1, 0, 0, 0, 0, 4, 1 }, // R4G4B4A4_UNORM
191 { GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, 1, 0, 1, 0, 0, 0, 0, 4, 1 }, // R9G9B9E5_FLOAT
192 // Matrix format for instancing
193 { GL_NONE, GL_NONE, GL_FLOAT, 0, 0, 0, 0, 1, 0, 0, 4, 4 } // MAT4X4_FLOAT,
194 };
195 static_assert(sizeof(DataFormats_) == sizeof(DataFormats_[0]) * size_t(Cogs::TextureFormat::TextureFormat_Size));
196}
197
198const Cogs::OpenGLES30::DataFormatInfo* Cogs::OpenGLES30::DataFormats = DataFormats_;
199
200void Cogs::OpenGLES30::enableExtensionFormats(CapabilitiesGLES30* caps)
201{
202 if (caps->getDeviceCapabilities().TextureCompressionS3TC)
203 {
204 DataFormats_[size_t(TextureFormat::BC1_TYPELESS)].isTextureFormat = 1;
205 DataFormats_[size_t(TextureFormat::BC1_UNORM)].isTextureFormat = 1;
206 DataFormats_[size_t(TextureFormat::BC1_UNORM_SRGB)].isTextureFormat = 1;
207 DataFormats_[size_t(TextureFormat::BC2_TYPELESS)].isTextureFormat = 1;
208 DataFormats_[size_t(TextureFormat::BC2_UNORM)].isTextureFormat = 1;
209 DataFormats_[size_t(TextureFormat::BC2_UNORM_SRGB)].isTextureFormat = 1;
210 DataFormats_[size_t(TextureFormat::BC3_TYPELESS)].isTextureFormat = 1;
211 DataFormats_[size_t(TextureFormat::BC3_UNORM)].isTextureFormat = 1;
212 DataFormats_[size_t(TextureFormat::BC3_UNORM_SRGB)].isTextureFormat = 1;
213 LOG_DEBUG(logger, "Enabled S3TC compressed texture formats");
214 }
215
216 if (caps->getDeviceCapabilities().TextureCompressionRGTC)
217 {
218 DataFormats_[size_t(TextureFormat::BC4_TYPELESS)].isTextureFormat = 1;
219 DataFormats_[size_t(TextureFormat::BC4_UNORM)].isTextureFormat = 1;
220 DataFormats_[size_t(TextureFormat::BC4_SNORM)].isTextureFormat = 1;
221 DataFormats_[size_t(TextureFormat::BC5_TYPELESS)].isTextureFormat = 1;
222 DataFormats_[size_t(TextureFormat::BC5_UNORM)].isTextureFormat = 1;
223 DataFormats_[size_t(TextureFormat::BC5_SNORM)].isTextureFormat = 1;
224 LOG_DEBUG(logger, "Enabled BC4/BC5 compressed texture formats");
225 }
226
227 if (caps->getDeviceCapabilities().TextureCompressionBPTC)
228 {
229 DataFormats_[size_t(TextureFormat::BC6H_SIGNED_FLOAT_RGB)].isTextureFormat = 1;
230 DataFormats_[size_t(TextureFormat::BC6H_UNSIGNED_FLOAT_RGB)].isTextureFormat = 1;
231 DataFormats_[size_t(TextureFormat::BC7_UNORM_RGBA)].isTextureFormat = 1;
232 DataFormats_[size_t(TextureFormat::BC7_UNORM_SRGBA)].isTextureFormat = 1;
233 LOG_DEBUG(logger, "Enabled BC7 compressed texture formats");
234 }
235 else {
236 LOG_DEBUG(logger, "Unsupported BC7 compressed texture formats not enabled");
237 }
238
239 if (caps->getDeviceCapabilities().TextureCompressionETC)
240 {
241 DataFormats_[size_t(TextureFormat::EAC_BLOCK8_UNSIGNED_FLOAT_R)].isTextureFormat = 1;
242 DataFormats_[size_t(TextureFormat::EAC_BLOCK8_SIGNED_FLOAT_R)].isTextureFormat = 1;
243 DataFormats_[size_t(TextureFormat::EAC_BLOCK16_UNSIGNED_FLOAT_RG)].isTextureFormat = 1;
244 DataFormats_[size_t(TextureFormat::EAC_BLOCK16_SIGNED_FLOAT_RG)].isTextureFormat = 1;
245
246 DataFormats_[size_t(TextureFormat::ETC2_BLOCK8_UNORM_RGB)].isTextureFormat = 1;
247 DataFormats_[size_t(TextureFormat::ETC2_BLOCK8_UNORM_SRGB)].isTextureFormat = 1;
248 DataFormats_[size_t(TextureFormat::ETC2_BLOCK16_UNORM_RGBA)].isTextureFormat = 1;
249 DataFormats_[size_t(TextureFormat::ETC2_BLOCK16_UNORM_SRGBA)].isTextureFormat = 1;
250 LOG_DEBUG(logger, "Enabled ETC compressed texture formats");
251 }
252 else {
253 LOG_DEBUG(logger, "Unsupported ETC compressed texture formats not enabled");
254 }
255
256 if (caps->getDeviceCapabilities().TextureCompressionPVRTC)
257 {
258 DataFormats_[size_t(TextureFormat::PVRTC1_2BPP_UNORM_RGB)].isTextureFormat = 1;
259 DataFormats_[size_t(TextureFormat::PVRTC1_4BPP_UNORM_RGB)].isTextureFormat = 1;
260 DataFormats_[size_t(TextureFormat::PVRTC1_2BPP_UNORM_RGBA)].isTextureFormat = 1;
261 DataFormats_[size_t(TextureFormat::PVRTC1_4BPP_UNORM_RGBA)].isTextureFormat = 1;
262 LOG_DEBUG(logger, "Enabled PVRTC compressed texture formats");
263 }
264 else {
265 LOG_DEBUG(logger, "Unsupported PVRTC compressed texture formats not enabled");
266 }
267
268 if (caps->getDeviceCapabilities().TextureCompressionASTC) {
269 DataFormats_[size_t(TextureFormat::ASTC_4x4_UNORM_RGBA)].isTextureFormat = 1;
270 DataFormats_[size_t(TextureFormat::ASTC_5x4_UNORM_RGBA)].isTextureFormat = 1;
271 DataFormats_[size_t(TextureFormat::ASTC_5x5_UNORM_RGBA)].isTextureFormat = 1;
272 DataFormats_[size_t(TextureFormat::ASTC_6x5_UNORM_RGBA)].isTextureFormat = 1;
273 DataFormats_[size_t(TextureFormat::ASTC_6x6_UNORM_RGBA)].isTextureFormat = 1;
274 DataFormats_[size_t(TextureFormat::ASTC_8x5_UNORM_RGBA)].isTextureFormat = 1;
275 DataFormats_[size_t(TextureFormat::ASTC_8x6_UNORM_RGBA)].isTextureFormat = 1;
276 DataFormats_[size_t(TextureFormat::ASTC_8x8_UNORM_RGBA)].isTextureFormat = 1;
277 DataFormats_[size_t(TextureFormat::ASTC_10x5_UNORM_RGBA)].isTextureFormat = 1;
278 DataFormats_[size_t(TextureFormat::ASTC_10x6_UNORM_RGBA)].isTextureFormat = 1;
279 DataFormats_[size_t(TextureFormat::ASTC_10x8_UNORM_RGBA)].isTextureFormat = 1;
280 DataFormats_[size_t(TextureFormat::ASTC_10x10_UNORM_RGBA)].isTextureFormat = 1;
281 DataFormats_[size_t(TextureFormat::ASTC_12x10_UNORM_RGBA)].isTextureFormat = 1;
282 DataFormats_[size_t(TextureFormat::ASTC_12x12_UNORM_RGBA)].isTextureFormat = 1;
283
284 DataFormats_[size_t(TextureFormat::ASTC_4x4_UNORM_SRGBA)].isTextureFormat = 1;
285 DataFormats_[size_t(TextureFormat::ASTC_5x4_UNORM_SRGBA)].isTextureFormat = 1;
286 DataFormats_[size_t(TextureFormat::ASTC_5x5_UNORM_SRGBA)].isTextureFormat = 1;
287 DataFormats_[size_t(TextureFormat::ASTC_6x5_UNORM_SRGBA)].isTextureFormat = 1;
288 DataFormats_[size_t(TextureFormat::ASTC_6x6_UNORM_SRGBA)].isTextureFormat = 1;
289 DataFormats_[size_t(TextureFormat::ASTC_8x5_UNORM_SRGBA)].isTextureFormat = 1;
290 DataFormats_[size_t(TextureFormat::ASTC_8x6_UNORM_SRGBA)].isTextureFormat = 1;
291 DataFormats_[size_t(TextureFormat::ASTC_8x8_UNORM_SRGBA)].isTextureFormat = 1;
292 DataFormats_[size_t(TextureFormat::ASTC_10x5_UNORM_SRGBA)].isTextureFormat = 1;
293 DataFormats_[size_t(TextureFormat::ASTC_10x6_UNORM_SRGBA)].isTextureFormat = 1;
294 DataFormats_[size_t(TextureFormat::ASTC_10x8_UNORM_SRGBA)].isTextureFormat = 1;
295 DataFormats_[size_t(TextureFormat::ASTC_10x10_UNORM_SRGBA)].isTextureFormat = 1;
296 DataFormats_[size_t(TextureFormat::ASTC_12x10_UNORM_SRGBA)].isTextureFormat = 1;
297 DataFormats_[size_t(TextureFormat::ASTC_12x12_UNORM_SRGBA)].isTextureFormat = 1;
298 LOG_DEBUG(logger, "Enabled ASTC compressed texture formats");
299 }
300 else {
301 LOG_DEBUG(logger, "Unsupported ASTC compressed texture formats not enabled");
302 }
303
304
305 if (caps->isSupported("GL_EXT_color_buffer_float")) {
306 DataFormats_[size_t(TextureFormat::R32G32B32A32_FLOAT)].isDrawable = 1;
307 DataFormats_[size_t(TextureFormat::R32G32_FLOAT)].isDrawable = 1;
308 DataFormats_[size_t(TextureFormat::R32_FLOAT)].isDrawable = 1;
309
310 DataFormats_[size_t(TextureFormat::R16G16B16A16_FLOAT)].isDrawable = 1;
311 DataFormats_[size_t(TextureFormat::R16G16_FLOAT)].isDrawable = 1;
312 DataFormats_[size_t(TextureFormat::R16_FLOAT)].isDrawable = 1;
313
314 DataFormats_[size_t(TextureFormat::R11G11B10_FLOAT)].isDrawable = 1;
315 LOG_DEBUG(logger, "Enabled float32 and float16 render targets");
316 }
317 if (caps->isSupported("GL_EXT_color_buffer_float")) {
318 DataFormats_[size_t(TextureFormat::R16G16B16A16_FLOAT)].isDrawable = 1;
319 DataFormats_[size_t(TextureFormat::R16G16B16_FLOAT)].isDrawable = 1;
320 DataFormats_[size_t(TextureFormat::R16G16_FLOAT)].isDrawable = 1;
321 DataFormats_[size_t(TextureFormat::R16_FLOAT)].isDrawable = 1;
322 LOG_DEBUG(logger, "Enabled float16 render targets");
323 }
324
325 if (caps->isSupported("GL_OES_texture_float_linear")) {
326 DataFormats_[size_t(TextureFormat::R32G32B32A32_FLOAT)].isTextureFilterable = 1;
327 DataFormats_[size_t(TextureFormat::R32G32B32_FLOAT)].isTextureFilterable = 1;
328 DataFormats_[size_t(TextureFormat::R32G32_FLOAT)].isTextureFilterable = 1;
329 DataFormats_[size_t(TextureFormat::R32_FLOAT)].isTextureFilterable = 1;
330 LOG_DEBUG(logger, "Enabled float32 texture filtering");
331 }
332
333}
334
335
336
337const GLenum Cogs::OpenGLES30::PrimitiveFormats[] = {
338 GL_TRIANGLES, // TriangleList = 0,
339 GL_TRIANGLE_STRIP, // TriangleStrip,
340 GL_LINES, // LineList,
341 GL_LINE_STRIP, // LineStrip,
342 GL_POINTS, // PointList,
343 GL_INVALID_ENUM, // TriangleListAdjacency,
344 GL_INVALID_ENUM, // TriangleStripAdjacency,
345 GL_INVALID_ENUM, // LineListAdjacency,
346 GL_INVALID_ENUM, // LineStripAdjacency,
347 GL_INVALID_ENUM, // ControlPoint1PatchList,
348 GL_INVALID_ENUM, // ControlPoint2PatchList,
349 GL_INVALID_ENUM, // ControlPoint3PatchList,
350 GL_INVALID_ENUM, // ControlPoint4PatchList,
351
352};
353static_assert(sizeof(Cogs::OpenGLES30::PrimitiveFormats) == sizeof(Cogs::OpenGLES30::PrimitiveFormats[0]) * size_t(Cogs::PrimitiveType::PrimitiveType_Size));
354
355const GLenum Cogs::OpenGLES30::MinFilterModes[] = {
356 GL_NEAREST,
357 GL_LINEAR,
358 GL_NEAREST,
359 GL_LINEAR,
360};
361static_assert(sizeof(Cogs::OpenGLES30::MinFilterModes) == sizeof(Cogs::OpenGLES30::MinFilterModes[0]) * size_t(Cogs::SamplerState::FilterMode_Size));
362
363const GLenum Cogs::OpenGLES30::MipMinFilterModes[] = {
364 GL_NEAREST_MIPMAP_LINEAR,
365 GL_LINEAR_MIPMAP_LINEAR,
366 GL_NEAREST_MIPMAP_LINEAR,
367 GL_LINEAR_MIPMAP_LINEAR,
368};
369static_assert(sizeof(Cogs::OpenGLES30::MipMinFilterModes) == sizeof(Cogs::OpenGLES30::MipMinFilterModes[0]) * size_t(Cogs::SamplerState::FilterMode_Size));
370
371const GLenum Cogs::OpenGLES30::MagFilterModes[] = {
372 GL_NEAREST,
373 GL_LINEAR,
374 GL_NEAREST,
375 GL_LINEAR,
376};
377static_assert(sizeof(Cogs::OpenGLES30::MagFilterModes) == sizeof(Cogs::OpenGLES30::MagFilterModes[0]) * size_t(Cogs::SamplerState::FilterMode_Size));
378
379const GLenum Cogs::OpenGLES30::AddressModes[] = {
380 GL_CLAMP_TO_EDGE,
381 GL_REPEAT,
382 GL_MIRRORED_REPEAT,
383 GL_CLAMP_TO_EDGE
384};
385static_assert(sizeof(Cogs::OpenGLES30::AddressModes) == sizeof(Cogs::OpenGLES30::AddressModes[0]) * size_t(Cogs::SamplerState::AddressMode_Size));
Log implementation class.
Definition: LogManager.h:140
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:181