Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/compiler/translator/ExtensionBehavior.cpp
1693 views
1
//
2
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// ExtensionBehavior.cpp: Extension name enumeration and data structures for storing extension
7
// behavior.
8
9
#include "compiler/translator/ExtensionBehavior.h"
10
11
#include "common/debug.h"
12
13
#include <string.h>
14
15
#define LIST_EXTENSIONS(OP) \
16
OP(ANGLE_base_vertex_base_instance) \
17
OP(ANGLE_multi_draw) \
18
OP(ANGLE_texture_multisample) \
19
OP(APPLE_clip_distance) \
20
OP(ARB_texture_rectangle) \
21
OP(ARM_shader_framebuffer_fetch) \
22
OP(EXT_blend_func_extended) \
23
OP(EXT_clip_cull_distance) \
24
OP(EXT_draw_buffers) \
25
OP(EXT_frag_depth) \
26
OP(EXT_geometry_shader) \
27
OP(OES_geometry_shader) \
28
OP(OES_shader_io_blocks) \
29
OP(EXT_shader_io_blocks) \
30
OP(EXT_gpu_shader5) \
31
OP(EXT_primitive_bounding_box) \
32
OP(EXT_shader_framebuffer_fetch) \
33
OP(EXT_shader_framebuffer_fetch_non_coherent) \
34
OP(EXT_shader_non_constant_global_initializers) \
35
OP(EXT_shader_texture_lod) \
36
OP(EXT_shadow_samplers) \
37
OP(EXT_tessellation_shader) \
38
OP(EXT_texture_buffer) \
39
OP(EXT_texture_cube_map_array) \
40
OP(EXT_YUV_target) \
41
OP(NV_EGL_stream_consumer_external) \
42
OP(NV_shader_framebuffer_fetch) \
43
OP(NV_shader_noperspective_interpolation) \
44
OP(OES_EGL_image_external) \
45
OP(OES_EGL_image_external_essl3) \
46
OP(OES_sample_variables) \
47
OP(OES_shader_multisample_interpolation) \
48
OP(OES_shader_image_atomic) \
49
OP(OES_standard_derivatives) \
50
OP(OES_texture_3D) \
51
OP(OES_texture_buffer) \
52
OP(OES_texture_cube_map_array) \
53
OP(OES_texture_storage_multisample_2d_array) \
54
OP(OVR_multiview) \
55
OP(OVR_multiview2) \
56
OP(WEBGL_video_texture)
57
58
namespace sh
59
{
60
61
#define RETURN_EXTENSION_NAME_CASE(ext) \
62
case TExtension::ext: \
63
return "GL_" #ext;
64
65
const char *GetExtensionNameString(TExtension extension)
66
{
67
switch (extension)
68
{
69
LIST_EXTENSIONS(RETURN_EXTENSION_NAME_CASE)
70
default:
71
UNREACHABLE();
72
return "";
73
}
74
}
75
76
#define RETURN_EXTENSION_IF_NAME_MATCHES(ext) \
77
if (strcmp(extWithoutGLPrefix, #ext) == 0) \
78
{ \
79
return TExtension::ext; \
80
}
81
82
TExtension GetExtensionByName(const char *extension)
83
{
84
// If first characters of the extension don't equal "GL_", early out.
85
if (strncmp(extension, "GL_", 3) != 0)
86
{
87
return TExtension::UNDEFINED;
88
}
89
const char *extWithoutGLPrefix = extension + 3;
90
91
LIST_EXTENSIONS(RETURN_EXTENSION_IF_NAME_MATCHES)
92
93
return TExtension::UNDEFINED;
94
}
95
96
const char *GetBehaviorString(TBehavior b)
97
{
98
switch (b)
99
{
100
case EBhRequire:
101
return "require";
102
case EBhEnable:
103
return "enable";
104
case EBhWarn:
105
return "warn";
106
case EBhDisable:
107
return "disable";
108
default:
109
return nullptr;
110
}
111
}
112
113
bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, TExtension extension)
114
{
115
ASSERT(extension != TExtension::UNDEFINED);
116
auto iter = extBehavior.find(extension);
117
return iter != extBehavior.end() &&
118
(iter->second == EBhEnable || iter->second == EBhRequire || iter->second == EBhWarn);
119
}
120
121
} // namespace sh
122
123