1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #pragma once
17 
18 #include <stdint.h>
19 #include "OpenGLESDispatch/gldefs.h"
20 #include "OpenGLESDispatch/gles_functions.h"
21 #include "KHR/khrplatform.h"
22 
23 #include "OpenGLESDispatch/gles2_extensions_static_translator_namespaced_header.h"
24 #include "OpenGLESDispatch/gles2_only_static_translator_namespaced_header.h"
25 #include "OpenGLESDispatch/gles_common_for_gles2_static_translator_namespaced_header.h"
26 #include "OpenGLESDispatch/gles_extensions_for_gles2_static_translator_namespaced_header.h"
27 #include "OpenGLESDispatch/gles31_only_static_translator_namespaced_header.h"
28 #include "OpenGLESDispatch/gles32_only_static_translator_namespaced_header.h"
29 #include "OpenGLESDispatch/gles3_extensions_static_translator_namespaced_header.h"
30 #include "OpenGLESDispatch/gles3_only_static_translator_namespaced_header.h"
31 
32 namespace gfxstream {
33 namespace gl {
34 
35 // Define function pointer types.
36 #define GLES2_DISPATCH_DEFINE_TYPE(return_type,func_name,signature,callargs) \
37     typedef return_type (KHRONOS_APIENTRY * func_name ## _t) signature;
38 
39 LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DEFINE_TYPE,GLES2_DISPATCH_DEFINE_TYPE)
40 
41 struct GLESv2Dispatch {
42 #define GLES2_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \
43         func_name ## _t func_name;
44     LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DECLARE_POINTER,
45                          GLES2_DISPATCH_DECLARE_POINTER)
46 
47     bool initialized = false;
48 };
49 
50 #undef GLES2_DISPATCH_DECLARE_POINTER
51 #undef GLES2_DISPATCH_DEFINE_TYPE
52 
53 bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table);
54 
55 // Used to initialize the decoder.
56 void* gles2_dispatch_get_proc_func(const char* name, void* userData);
57 // Used to check for unimplemented.
58 void gles2_unimplemented();
59 
60 // Used to query max GLES version support based on what the dispatch mechanism
61 // has found in the GLESv2 library.
62 // First, a enum for tracking the detected GLES version based on dispatch.
63 // We support 2 minimally.
64 enum GLESDispatchMaxVersion {
65     GLES_DISPATCH_MAX_VERSION_2 = 0,
66     GLES_DISPATCH_MAX_VERSION_3_0 = 1,
67     GLES_DISPATCH_MAX_VERSION_3_1 = 2,
68     GLES_DISPATCH_MAX_VERSION_3_2 = 3,
69 };
70 
71 GLESDispatchMaxVersion gles2_dispatch_get_max_version();
72 
73 }  // namespace gl
74 }  // namespace gfxstream