Debian Codegraph @

Sources/nCine/Graphics/RHI/GL/GLEs2HeaderShims.h

raw
1 #pragma once
2
3 // Compile-compatibility shims for building the GL backend against real OpenGL ES 2.0 headers
4 // (`GLES2/gl2.h` + `GLES2/gl2ext.h`), the way a PlayStation Vita (vitaGL) or any strict ES 2.0
5 // target would. Included from CommonHeaders.h only on the strict-ES2 header path, i.e. when
6 // `RHI_GL_PROFILE_ES2` is active AND the build compiles against gl2.h rather than GLES3/gl3.h.
7 // It is NOT included on the vitaGL path (vitaGL declares its own supersets natively), so these
8 // definitions never collide there.
9 //
10 // Every macro below is the canonical Khronos numeric value of an enum that strict ES 2.0 does not
11 // provide but that vitaGL / GLES3 / desktop GL do. They exist ONLY so that code paths which are
12 // statically compiled under the profile yet never executed on it - shared reflection switch tables
13 // (uint-vector / 3D-sampler GL types that ES2 never reports), `static_assert`s that pin the engine's
14 // enum values, dead uniform-buffer / read-draw-framebuffer branches, and unreachable format cases -
15 // keep compiling. None of these values is ever passed to a strict ES 2.0 driver while the profile is
16 // active. Prefer eliminating a reference with `#if` in the referencing code over adding one here;
17 // entries remain only where the reference genuinely has to stay compiled.
18
19 #if !defined(RHI_GL_PROFILE_ES2)
20 # error GLEs2HeaderShims.h must only be included when RHI_GL_PROFILE_ES2 is defined
21 #endif
22
23 // Uniform buffer objects (ES 3.0): the target enum plus the invalid-block-index sentinel and the
24 // glMapBufferRange access bits, referenced by static_asserts (GLDevice), the buffer-target hash map
25 // (GLHashMap) and the reflection block index (GLShaderProgram). No UBO is ever bound on this profile.
26 #if !defined(GL_UNIFORM_BUFFER)
27 # define GL_UNIFORM_BUFFER 0x8A11
28 #endif
29 #if !defined(GL_INVALID_INDEX)
30 # define GL_INVALID_INDEX 0xFFFFFFFFu
31 #endif
32 #if !defined(GL_MAP_INVALIDATE_RANGE_BIT)
33 # define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
34 #endif
35 #if !defined(GL_MAP_INVALIDATE_BUFFER_BIT)
36 # define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
37 #endif
38 #if !defined(GL_MAP_FLUSH_EXPLICIT_BIT)
39 # define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
40 #endif
41 #if !defined(GL_MAP_UNSYNCHRONIZED_BIT)
42 # define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
43 #endif
44
45 // Reflection GL type enums that ES 2.0 never reports (unsigned-integer vectors and 3D samplers are
46 // ES 3.0). They only appear as `case` labels in the GL-type -> engine-type switch tables shared by
47 // every profile (GLAttribute / GLUniform / GLUniformCache / GLShaderProgram).
48 #if !defined(GL_UNSIGNED_INT_VEC2)
49 # define GL_UNSIGNED_INT_VEC2 0x8DC6
50 #endif
51 #if !defined(GL_UNSIGNED_INT_VEC3)
52 # define GL_UNSIGNED_INT_VEC3 0x8DC7
53 #endif
54 #if !defined(GL_UNSIGNED_INT_VEC4)
55 # define GL_UNSIGNED_INT_VEC4 0x8DC8
56 #endif
57 #if !defined(GL_SAMPLER_3D)
58 # define GL_SAMPLER_3D 0x8B5F
59 #endif
60
61 // Separate read/draw framebuffer bind points (ES 3.0). GLFramebuffer::BindHandle remaps every request
62 // to the single ES2 GL_FRAMEBUFFER target, so these only appear in the always-false branches and the
63 // FATAL_ASSERTs that validate the caller-supplied target enum.
64 #if !defined(GL_READ_FRAMEBUFFER)
65 # define GL_READ_FRAMEBUFFER 0x8CA8
66 #endif
67 #if !defined(GL_DRAW_FRAMEBUFFER)
68 # define GL_DRAW_FRAMEBUFFER 0x8CA9
69 #endif
70
71 // Sized floating-point internal formats (ES 3.0 / EXT_color_buffer_(half_)float). Referenced by the
72 // shared format-resolution switch (GLTextureFormat); the ES2 profile only ever resolves the unsized
73 // ES2-core formats in the profile-specific branch above these cases.
74 #if !defined(GL_RGBA16F)
75 # define GL_RGBA16F 0x881A
76 #endif
77 #if !defined(GL_RGBA32F)
78 # define GL_RGBA32F 0x8814
79 #endif
80 #if !defined(GL_RGB16F)
81 # define GL_RGB16F 0x881B
82 #endif
83 #if !defined(GL_RGB32F)
84 # define GL_RGB32F 0x8815
85 #endif
86 #if !defined(GL_DEPTH_COMPONENT32F)
87 # define GL_DEPTH_COMPONENT32F 0x8CAC
88 #endif
89
90 // ETC2 / EAC compressed internal formats and the GL_RED / GL_RG channel enums used by their EAC cases
91 // (all ES 3.0). Unreachable on the ES2 profile (the engine uploads none of these), but present as
92 // `case` labels in the shared compressed-format switch (GLTextureFormat).
93 #if !defined(GL_COMPRESSED_RGBA8_ETC2_EAC)
94 # define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
95 #endif
96 #if !defined(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2)
97 # define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
98 #endif
99 #if !defined(GL_COMPRESSED_RGB8_ETC2)
100 # define GL_COMPRESSED_RGB8_ETC2 0x9274
101 #endif
102 #if !defined(GL_COMPRESSED_RG11_EAC)
103 # define GL_COMPRESSED_RG11_EAC 0x9272
104 #endif
105 #if !defined(GL_COMPRESSED_R11_EAC)
106 # define GL_COMPRESSED_R11_EAC 0x9270
107 #endif
108 #if !defined(GL_RED)
109 # define GL_RED 0x1903
110 #endif
111 #if !defined(GL_RG)
112 # define GL_RG 0x8227
113 #endif
114
115 // Core program-binary format queries (ES 3.0 / ARB_get_program_binary). The ES2 profile uses the OES
116 // spelling; these appear only in the ARB fallback branch of GLRhiCapabilities, never taken on ES2.
117 #if !defined(GL_NUM_PROGRAM_BINARY_FORMATS)
118 # define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
119 #endif
120 #if !defined(GL_PROGRAM_BINARY_FORMATS)
121 # define GL_PROGRAM_BINARY_FORMATS 0x87FF
122 #endif