-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvk2gl.c
179 lines (159 loc) · 5.71 KB
/
vk2gl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab textwidth=70: */
/*
* Copyright 2024 Mark Callow.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
* @file vk2gl.h
* @~English
*
* @brief Test compilation of GL format mappings.
*
* Note that this requires a @c vulkan_core.h with a VkFormat that includes
* the ASTC 3D formats which are not currently in the standard
* @c vulkan_core.h. A suitable file can be found at
*
* https://github.com/KhronosGroup/dfdutils/blob/main/vulkan/vulkan_core.h
*
* Once these formats are included in the standard @c vulkan_core.h
* the above file will be removed.
*
* Tokens used in the case statements and results can be found in
* @c vulkan_core.h version 267+ (except ASTC 3D tokens),
* a @c glcorearb.h circa early 2024 (glcorearb.h has no version
* number) or defined below.
*/
#include "vulkan/vulkan_core.h"
#include "GL/glcorearb.h"
// These are only in glext.h.
#if !defined( GL_COMPRESSED_SRGB_S3TC_DXT1_EXT )
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
#endif
#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT )
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
#endif
#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT )
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
#endif
#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT )
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
#endif
// These are only in GLES headers not in glcorearb.h or glext.h.
//
// ETC
//
#if !defined( GL_ETC1_RGB8_OES )
#define GL_ETC1_RGB8_OES 0x8D64
#endif
//
// PVRTC
//
#if !defined( GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG )
#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
#endif
#if !defined( GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG )
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
#endif
#if !defined( GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT )
#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
#endif
#if !defined( GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG )
#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
#endif
//
// ASTC
//
#if !defined( GL_COMPRESSED_RGBA_ASTC_3x3x3_OES )
#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
#endif
#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES )
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
#endif
/**
* @brief Return the glInternalFormat equivalent to the vkFormat.
*
* @param[in] vkFormat VkFormat enumerator value to look up.
*
* @return a GLenum with the equivalent internal format value.
* GL_INVALID_VALUE if none found.
*/
GLenum vkFormat2glInternalFormat( VkFormat vkFormat )
{
switch ( vkFormat )
{
#include "vkFormat2glInternalFormat.inl"
default: return GL_INVALID_VALUE;
}
}
/**
* @brief Return the glFormat equivalent to the vkFormat.
*
* Only non-block compressed vkFormats have an equivalent glFormat as
* only the glInternalformat is needed for loading compressed
* textures. GL_INVALID_VALUE is returned for block-compressed formats.
*
* It is not possible to tell from the vkFormat token value when the
* format is block compressed. If operating in the context of a KTX
* file the embedded DFD's @c colorModel can be used to distinguish.
*
* @param[in] vkFormat VkFormat enumerator value to look up.
*
* @return a GLenum with the equivalent format value. GL_INVALID_VALUE
* if none found.
*/
GLenum vkFormat2glFormat( VkFormat vkFormat )
{
switch ( vkFormat )
{
#include "vkFormat2glFormat.inl"
default: return GL_INVALID_VALUE;
}
}
/**
* @brief Return the glType equivalent to the vkFormat.
*
* Only non-block compressed vkFormats have an equivalent glType as
* only the glInternalformat is needed for loading compressed
* textures. @see vkFormat2glFormat for more details.
*
* @param[in] vkFormat VkFormat enumerator value to look up.
*
* @return a GLenum with the equivalent format value. GL_INVALID_VALUE
* if none found.
*/
GLenum vkFormat2glType( VkFormat vkFormat )
{
switch ( vkFormat )
{
#include "vkFormat2glType.inl"
default: return GL_INVALID_VALUE;
}
}