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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
/*
* vigs
*
* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* Stanislav Vorobiov <s.vorobiov@samsung.com>
* Jinhyung Jo <jinhyung.jo@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#ifndef _QEMU_VIGS_GL_BACKEND_H
#define _QEMU_VIGS_GL_BACKEND_H
#include "vigs_types.h"
#include "vigs_backend.h"
#include "vigs_vector.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include "winsys_gl.h"
#define TEXTURE_NUM 5
struct vigs_gl_pool;
struct vigs_gl_backend
{
struct vigs_backend base;
struct winsys_gl_info ws_info;
bool is_gl_2;
bool (*has_current)(struct vigs_gl_backend */*gl_backend*/);
bool (*make_current)(struct vigs_gl_backend */*gl_backend*/,
bool /*enable*/);
bool (*read_pixels_make_current)(struct vigs_gl_backend */*gl_backend*/,
bool /*enable*/);
/*
* Mandatory GL functions and extensions.
* @{
*/
void (GLAPIENTRY *GenTextures)(GLsizei n, GLuint *textures);
void (GLAPIENTRY *DeleteTextures)(GLsizei n, const GLuint *textures);
void (GLAPIENTRY *BindTexture)(GLenum target, GLuint texture);
void (GLAPIENTRY *CullFace)(GLenum mode);
void (GLAPIENTRY *TexParameterf)(GLenum target, GLenum pname, GLfloat param);
void (GLAPIENTRY *TexParameterfv)(GLenum target, GLenum pname, const GLfloat *params);
void (GLAPIENTRY *TexParameteri)(GLenum target, GLenum pname, GLint param);
void (GLAPIENTRY *TexParameteriv)(GLenum target, GLenum pname, const GLint *params);
void (GLAPIENTRY *TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (GLAPIENTRY *TexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void (GLAPIENTRY *Clear)(GLbitfield mask);
void (GLAPIENTRY *ClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (GLAPIENTRY *Disable)(GLenum cap);
void (GLAPIENTRY *Enable)(GLenum cap);
void (GLAPIENTRY *Finish)(void);
void (GLAPIENTRY *Flush)(void);
void (GLAPIENTRY *PixelStorei)(GLenum pname, GLint param);
void (GLAPIENTRY *ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
void (GLAPIENTRY *Viewport)(GLint x, GLint y, GLsizei width, GLsizei height);
void (GLAPIENTRY *GenFramebuffers)(GLsizei n, GLuint *framebuffers);
void (GLAPIENTRY *GenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
void (GLAPIENTRY *DeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
void (GLAPIENTRY *DeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
void (GLAPIENTRY *BindFramebuffer)(GLenum target, GLuint framebuffer);
void (GLAPIENTRY *BindRenderbuffer)(GLenum target, GLuint renderbuffer);
void (GLAPIENTRY *RenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void (GLAPIENTRY *FramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void (GLAPIENTRY *FramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void (GLAPIENTRY *GetIntegerv)(GLenum pname, GLint *params);
const GLubyte *(GLAPIENTRY *GetString)(GLenum name);
void (GLAPIENTRY *DrawArrays)(GLenum mode, GLint first, GLsizei count);
void (GLAPIENTRY *BlendFunc)(GLenum sfactor, GLenum dfactor);
void (GLAPIENTRY *GenBuffers)(GLsizei n, GLuint *buffers);
void (GLAPIENTRY *DeleteBuffers)(GLsizei n, const GLuint *buffers);
void (GLAPIENTRY *BindBuffer)(GLenum target, GLuint buffer);
void (GLAPIENTRY *BufferData)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
void (GLAPIENTRY *BufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
GLvoid *(GLAPIENTRY *MapBuffer)(GLenum target, GLenum access);
GLboolean (GLAPIENTRY *UnmapBuffer)(GLenum target);
GLuint (GLAPIENTRY* CreateProgram)(void);
GLuint (GLAPIENTRY* CreateShader)(GLenum type);
void (GLAPIENTRY* CompileShader)(GLuint shader);
void (GLAPIENTRY* AttachShader)(GLuint program, GLuint shader);
void (GLAPIENTRY* LinkProgram)(GLuint program);
void (GLAPIENTRY* GetProgramiv)(GLuint program, GLenum pname, GLint* params);
void (GLAPIENTRY* GetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
void (GLAPIENTRY* GetShaderiv)(GLuint shader, GLenum pname, GLint* params);
void (GLAPIENTRY* GetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
void (GLAPIENTRY* DetachShader)(GLuint program, GLuint shader);
void (GLAPIENTRY* DeleteProgram)(GLuint program);
void (GLAPIENTRY* DeleteShader)(GLuint shader);
void (GLAPIENTRY* DisableVertexAttribArray)(GLuint index);
void (GLAPIENTRY* EnableVertexAttribArray)(GLuint index);
void (GLAPIENTRY* ShaderSource)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
void (GLAPIENTRY* UseProgram)(GLuint program);
GLint (GLAPIENTRY* GetAttribLocation)(GLuint program, const GLchar* name);
GLint (GLAPIENTRY* GetUniformLocation)(GLuint program, const GLchar* name);
void (GLAPIENTRY* VertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
void (GLAPIENTRY* Uniform4fv)(GLint location, GLsizei count, const GLfloat* value);
void (GLAPIENTRY* UniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
void (GLAPIENTRY* Uniform2fv)(GLint location, GLsizei count, const GLfloat* value);
void (GLAPIENTRY* Uniform1f)(GLint location, GLfloat v0);
void (GLAPIENTRY* Uniform1i)(GLint location, GLint v0);
void (GLAPIENTRY* Uniform2f)(GLint location, GLfloat v0, GLfloat v1);
void (GLAPIENTRY* ActiveTexture)(GLenum texture);
/*
* @}
*/
/*
* Only OpenGL 2.1 + GL_ARB_map_buffer_range or OpenGL 3.1+ core.
*/
GLvoid *(GLAPIENTRY *MapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
/*
* OpenGL 3.1+ core functions and extensions.
* @{
*/
void (GLAPIENTRY* GenVertexArrays)(GLsizei n, GLuint* arrays);
void (GLAPIENTRY* BindVertexArray)(GLuint array);
void (GLAPIENTRY* DeleteVertexArrays)(GLsizei n, const GLuint* arrays);
/*
* @}
*/
struct vigs_gl_pool *tex_pool;
struct vigs_gl_pool *fb_pool;
/*
* General purpose vectors.
* @{
*/
struct vigs_vector v1;
struct vigs_vector v2;
/*
* @}
*/
/*
* Rendering thread related.
* @{
*/
GLuint vao;
GLuint tex_prog_vs_id;
GLuint tex_prog_fs_id;
GLuint tex_prog_id;
GLint tex_prog_proj_loc;
GLint tex_prog_vertCoord_loc;
GLint tex_prog_texCoord_loc;
GLuint color_prog_vs_id;
GLuint color_prog_fs_id;
GLuint color_prog_id;
GLint color_prog_proj_loc;
GLint color_prog_vertCoord_loc;
GLint color_prog_color_loc;
GLuint nv21_prog_vs_id;
GLuint nv21_prog_fs_id;
GLuint nv21_prog_id;
GLint nv21_prog_proj_loc;
GLint nv21_prog_vertCoord_loc;
GLint nv21_prog_texCoord_loc;
GLint nv21_prog_size_loc;
GLint nv21_prog_ytexSize_loc;
GLint nv21_prog_ctexSize_loc;
GLint nv21_prog_ytex_loc;
GLint nv21_prog_ctex_loc;
GLuint yuv420_prog_vs_id;
GLuint yuv420_prog_fs_id;
GLuint yuv420_prog_id;
GLint yuv420_prog_proj_loc;
GLint yuv420_prog_vertCoord_loc;
GLint yuv420_prog_texCoord_loc;
GLint yuv420_prog_size_loc;
GLint yuv420_prog_ytexSize_loc;
GLint yuv420_prog_utexSize_loc;
GLint yuv420_prog_vtexSize_loc;
GLint yuv420_prog_ytex_loc;
GLint yuv420_prog_utex_loc;
GLint yuv420_prog_vtex_loc;
GLuint xbgr_prog_fs_id;
GLuint xbgr_prog_id;
GLint xbgr_prog_proj_loc;
GLint xbgr_prog_vertCoord_loc;
GLint xbgr_prog_texCoord_loc;
GLuint vbo;
uint32_t vbo_size;
GLuint cur_prog_id;
/*
* @}
* Display thread related.
* @{
*/
struct dpy_item {
GLuint tex;
uint32_t width;
uint32_t height;
bool available;
QemuMutex mutex;
} dpy_items[TEXTURE_NUM], *current_dpy;
uint32_t dpy_idx;
GLuint dpy_fb;
/*
* @}
*/
};
bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend);
void vigs_gl_backend_cleanup(struct vigs_gl_backend *gl_backend);
#endif
|