2 * Direct3D wine OpenGL include file
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2004 Jason Edmeades
7 * Copyright 2007 Roderick Colenbrander
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #ifndef __WINE_WINED3D_GL_H
25 #define __WINE_WINED3D_GL_H
27 #define WINE_GLAPI __stdcall
33 #include "wine/wgl_driver.h"
35 #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 /* not in the gl spec */
37 /* OpenGL extensions. */
38 enum wined3d_gl_extension
45 APPLE_FLUSH_BUFFER_RANGE
,
51 ARB_BLEND_FUNC_EXTENDED
,
53 ARB_CLEAR_BUFFER_OBJECT
,
56 ARB_COLOR_BUFFER_FLOAT
,
58 ARB_CONSERVATIVE_DEPTH
,
63 ARB_DEPTH_BUFFER_FLOAT
,
66 ARB_DERIVATIVE_CONTROL
,
68 ARB_DRAW_BUFFERS_BLEND
,
69 ARB_DRAW_ELEMENTS_BASE_VERTEX
,
72 ARB_ES2_COMPATIBILITY
,
73 ARB_ES3_COMPATIBILITY
,
74 ARB_EXPLICIT_ATTRIB_LOCATION
,
75 ARB_FRAGMENT_COORD_CONVENTIONS
,
76 ARB_FRAGMENT_LAYER_VIEWPORT
,
79 ARB_FRAMEBUFFER_NO_ATTACHMENTS
,
80 ARB_FRAMEBUFFER_OBJECT
,
85 ARB_HALF_FLOAT_VERTEX
,
87 ARB_INTERNALFORMAT_QUERY
,
88 ARB_INTERNALFORMAT_QUERY2
,
89 ARB_MAP_BUFFER_ALIGNMENT
,
94 ARB_PIPELINE_STATISTICS_QUERY
,
95 ARB_PIXEL_BUFFER_OBJECT
,
98 ARB_POLYGON_OFFSET_CLAMP
,
100 ARB_QUERY_BUFFER_OBJECT
,
103 ARB_SEAMLESS_CUBE_MAP
,
104 ARB_SHADER_ATOMIC_COUNTERS
,
105 ARB_SHADER_VIEWPORT_LAYER_ARRAY
,
106 ARB_SHADER_BIT_ENCODING
,
107 ARB_SHADER_IMAGE_LOAD_STORE
,
108 ARB_SHADER_IMAGE_SIZE
,
109 ARB_SHADER_STORAGE_BUFFER_OBJECT
,
110 ARB_SHADER_TEXTURE_IMAGE_SAMPLES
,
111 ARB_SHADER_TEXTURE_LOD
,
112 ARB_SHADING_LANGUAGE_100
,
113 ARB_SHADING_LANGUAGE_420PACK
,
114 ARB_SHADING_LANGUAGE_PACKING
,
116 ARB_STENCIL_TEXTURING
,
118 ARB_TESSELLATION_SHADER
,
119 ARB_TEXTURE_BORDER_CLAMP
,
120 ARB_TEXTURE_BUFFER_OBJECT
,
121 ARB_TEXTURE_BUFFER_RANGE
,
122 ARB_TEXTURE_COMPRESSION
,
123 ARB_TEXTURE_COMPRESSION_BPTC
,
124 ARB_TEXTURE_COMPRESSION_RGTC
,
125 ARB_TEXTURE_CUBE_MAP
,
126 ARB_TEXTURE_CUBE_MAP_ARRAY
,
127 ARB_TEXTURE_ENV_COMBINE
,
128 ARB_TEXTURE_ENV_DOT3
,
129 ARB_TEXTURE_FILTER_ANISOTROPIC
,
132 ARB_TEXTURE_MIRRORED_REPEAT
,
133 ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
,
134 ARB_TEXTURE_MULTISAMPLE
,
135 ARB_TEXTURE_NON_POWER_OF_TWO
,
136 ARB_TEXTURE_QUERY_LEVELS
,
137 ARB_TEXTURE_RECTANGLE
,
139 ARB_TEXTURE_RGB10_A2UI
,
141 ARB_TEXTURE_STORAGE_MULTISAMPLE
,
145 ARB_TRANSFORM_FEEDBACK2
,
146 ARB_TRANSFORM_FEEDBACK3
,
147 ARB_UNIFORM_BUFFER_OBJECT
,
148 ARB_VERTEX_ARRAY_BGRA
,
149 ARB_VERTEX_BUFFER_OBJECT
,
152 ARB_VERTEX_TYPE_10F_11F_11F_REV
,
153 ARB_VERTEX_TYPE_2_10_10_10_REV
,
158 ATI_SEPARATE_STENCIL
,
159 ATI_TEXTURE_COMPRESSION_3DC
,
160 ATI_TEXTURE_ENV_COMBINE3
,
161 ATI_TEXTURE_MIRROR_ONCE
,
164 EXT_BLEND_EQUATION_SEPARATE
,
165 EXT_BLEND_FUNC_SEPARATE
,
168 EXT_DEPTH_BOUNDS_TEST
,
171 EXT_FRAMEBUFFER_BLIT
,
172 EXT_FRAMEBUFFER_MULTISAMPLE
,
173 EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
,
174 EXT_FRAMEBUFFER_OBJECT
,
175 EXT_GPU_PROGRAM_PARAMETERS
,
178 EXT_PACKED_DEPTH_STENCIL
,
180 EXT_POINT_PARAMETERS
,
181 EXT_PROVOKING_VERTEX
,
183 EXT_STENCIL_TWO_SIDE
,
187 EXT_TEXTURE_COMPRESSION_RGTC
,
188 EXT_TEXTURE_COMPRESSION_S3TC
,
189 EXT_TEXTURE_ENV_COMBINE
,
190 EXT_TEXTURE_ENV_DOT3
,
192 EXT_TEXTURE_LOD_BIAS
,
193 EXT_TEXTURE_MIRROR_CLAMP
,
194 EXT_TEXTURE_SHADOW_LOD
,
195 EXT_TEXTURE_SHARED_EXPONENT
,
198 EXT_TEXTURE_SRGB_DECODE
,
203 NV_FRAGMENT_PROGRAM2
,
204 NV_FRAGMENT_PROGRAM_OPTION
,
206 NV_LIGHT_MAX_EXPONENT
,
208 NV_REGISTER_COMBINERS
,
209 NV_REGISTER_COMBINERS2
,
210 NV_TEXGEN_REFLECTION
,
211 NV_TEXTURE_ENV_COMBINE4
,
215 NV_VERTEX_PROGRAM1_1
,
217 NV_VERTEX_PROGRAM2_OPTION
,
221 WGL_ARB_PIXEL_FORMAT
,
222 WGL_EXT_SWAP_CONTROL
,
223 WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
,
224 WGL_WINE_QUERY_RENDERER
,
225 /* Internally used */
226 WINED3D_GL_BLEND_EQUATION
,
227 WINED3D_GL_LEGACY_CONTEXT
,
228 WINED3D_GL_NORMALIZED_TEXRECT
,
229 WINED3D_GL_PRIMITIVE_QUERY
,
230 WINED3D_GL_VERSION_2_0
,
231 WINED3D_GL_VERSION_3_2
,
234 WINED3D_GL_EXT_COUNT
,
237 struct wined3d_fbo_ops
239 GLboolean (WINE_GLAPI
*glIsRenderbuffer
)(GLuint renderbuffer
);
240 void (WINE_GLAPI
*glBindRenderbuffer
)(GLenum target
, GLuint renderbuffer
);
241 void (WINE_GLAPI
*glDeleteRenderbuffers
)(GLsizei n
, const GLuint
*renderbuffers
);
242 void (WINE_GLAPI
*glGenRenderbuffers
)(GLsizei n
, GLuint
*renderbuffers
);
243 void (WINE_GLAPI
*glRenderbufferStorage
)(GLenum target
, GLenum internalformat
,
244 GLsizei width
, GLsizei height
);
245 void (WINE_GLAPI
*glRenderbufferStorageMultisample
)(GLenum target
, GLsizei samples
,
246 GLenum internalformat
, GLsizei width
, GLsizei height
);
247 void (WINE_GLAPI
*glGetRenderbufferParameteriv
)(GLenum target
, GLenum pname
, GLint
*params
);
248 GLboolean (WINE_GLAPI
*glIsFramebuffer
)(GLuint framebuffer
);
249 void (WINE_GLAPI
*glBindFramebuffer
)(GLenum target
, GLuint framebuffer
);
250 void (WINE_GLAPI
*glDeleteFramebuffers
)(GLsizei n
, const GLuint
*framebuffers
);
251 void (WINE_GLAPI
*glGenFramebuffers
)(GLsizei n
, GLuint
*framebuffers
);
252 GLenum (WINE_GLAPI
*glCheckFramebufferStatus
)(GLenum target
);
253 void (WINE_GLAPI
*glFramebufferTexture
)(GLenum target
, GLenum attachment
,
254 GLuint texture
, GLint level
);
255 void (WINE_GLAPI
*glFramebufferTexture1D
)(GLenum target
, GLenum attachment
,
256 GLenum textarget
, GLuint texture
, GLint level
);
257 void (WINE_GLAPI
*glFramebufferTexture2D
)(GLenum target
, GLenum attachment
,
258 GLenum textarget
, GLuint texture
, GLint level
);
259 void (WINE_GLAPI
*glFramebufferTexture3D
)(GLenum target
, GLenum attachment
,
260 GLenum textarget
, GLuint texture
, GLint level
, GLint layer
);
261 void (WINE_GLAPI
*glFramebufferTextureLayer
)(GLenum target
, GLenum attachment
,
262 GLuint texture
, GLint level
, GLint layer
);
263 void (WINE_GLAPI
*glFramebufferRenderbuffer
)(GLenum target
, GLenum attachment
,
264 GLenum renderbuffertarget
, GLuint renderbuffer
);
265 void (WINE_GLAPI
*glGetFramebufferAttachmentParameteriv
)(GLenum target
, GLenum attachment
,
266 GLenum pname
, GLint
*params
);
267 void (WINE_GLAPI
*glBlitFramebuffer
)(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
268 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
, GLbitfield mask
, GLenum filter
);
269 void (WINE_GLAPI
*glGenerateMipmap
)(GLenum target
);
272 struct wined3d_gl_limits
274 unsigned int buffers
;
276 unsigned int textures
;
277 unsigned int texture_coords
;
278 unsigned int uniform_blocks
[WINED3D_SHADER_TYPE_COUNT
];
279 unsigned int samplers
[WINED3D_SHADER_TYPE_COUNT
];
280 unsigned int graphics_samplers
;
281 unsigned int combined_samplers
;
282 unsigned int general_combiners
;
283 unsigned int user_clip_distances
;
284 unsigned int texture_size
;
285 unsigned int texture3d_size
;
286 unsigned int anisotropy
;
288 unsigned int samples
;
289 unsigned int vertex_attribs
;
291 unsigned int texture_buffer_offset_alignment
;
293 unsigned int framebuffer_width
;
294 unsigned int framebuffer_height
;
295 unsigned int viewport_subpixel_bits
;
297 unsigned int glsl_varyings
;
298 unsigned int glsl_vs_float_constants
;
299 unsigned int glsl_ps_float_constants
;
301 unsigned int arb_vs_float_constants
;
302 unsigned int arb_vs_native_constants
;
303 unsigned int arb_vs_instructions
;
304 unsigned int arb_vs_temps
;
305 unsigned int arb_ps_float_constants
;
306 unsigned int arb_ps_local_constants
;
307 unsigned int arb_ps_native_constants
;
308 unsigned int arb_ps_instructions
;
309 unsigned int arb_ps_temps
;
312 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits
*gl_limits
,
313 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
);
314 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits
*gl_limits
,
315 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
);
317 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
318 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
319 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
320 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
321 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
322 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
323 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
324 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
325 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
326 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
328 typedef void (WINE_GLAPI
*wined3d_ffp_attrib_func
)(const void *data
);
329 typedef void (WINE_GLAPI
*wined3d_ffp_texcoord_func
)(GLenum unit
, const void *data
);
330 typedef void (WINE_GLAPI
*wined3d_generic_attrib_func
)(GLuint idx
, const void *data
);
332 struct wined3d_ffp_attrib_ops
334 wined3d_ffp_attrib_func position
[WINED3D_FFP_EMIT_COUNT
];
335 wined3d_ffp_attrib_func diffuse
[WINED3D_FFP_EMIT_COUNT
];
336 wined3d_ffp_attrib_func specular
[WINED3D_FFP_EMIT_COUNT
];
337 wined3d_ffp_attrib_func normal
[WINED3D_FFP_EMIT_COUNT
];
338 wined3d_ffp_texcoord_func texcoord
[WINED3D_FFP_EMIT_COUNT
];
339 wined3d_generic_attrib_func generic
[WINED3D_FFP_EMIT_COUNT
];
342 struct wined3d_gl_info
344 unsigned int selected_gl_version
;
345 unsigned int glsl_version
;
346 struct wined3d_gl_limits limits
;
347 unsigned int reserved_glsl_constants
, reserved_arb_constants
;
349 BOOL supported
[WINED3D_GL_EXT_COUNT
];
350 GLint wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
+ 1];
351 float filling_convention_offset
;
353 HGLRC (WINAPI
*p_wglCreateContextAttribsARB
)(HDC dc
, HGLRC share
, const GLint
*attribs
);
354 struct wined3d_ffp_attrib_ops ffp_attrib_ops
;
355 struct opengl_funcs gl_ops
;
356 struct wined3d_fbo_ops fbo_ops
;
358 void (WINE_GLAPI
*p_glDisableWINE
)(GLenum cap
);
359 void (WINE_GLAPI
*p_glEnableWINE
)(GLenum cap
);
362 void install_gl_compat_wrapper(struct wined3d_gl_info
*gl_info
, enum wined3d_gl_extension ext
);
363 void print_glsl_info_log(const struct wined3d_gl_info
*gl_info
, GLuint id
, BOOL program
);
364 void shader_glsl_validate_link(const struct wined3d_gl_info
*gl_info
, GLuint program
);
365 GLenum
wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info
*gl_info
, uint32_t bind_flags
);
366 void wined3d_check_gl_call(const struct wined3d_gl_info
*gl_info
,
367 const char *file
, unsigned int line
, const char *name
);
371 GLenum mip
[WINED3D_TEXF_LINEAR
+ 1];
374 extern const struct min_lookup minMipLookup
[WINED3D_TEXF_LINEAR
+ 1];
375 extern const GLenum magLookup
[WINED3D_TEXF_LINEAR
+ 1];
377 static inline GLenum
wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter
)
379 return magLookup
[mag_filter
];
382 static inline GLenum
wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter
,
383 enum wined3d_texture_filter_type mip_filter
)
385 return minMipLookup
[min_filter
].mip
[mip_filter
];
388 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
);
390 const char *debug_fboattachment(GLenum attachment
);
391 const char *debug_fbostatus(GLenum status
);
392 const char *debug_glerror(GLenum error
);
394 static inline bool wined3d_fence_supported(const struct wined3d_gl_info
*gl_info
)
396 return gl_info
->supported
[ARB_SYNC
] || gl_info
->supported
[NV_FENCE
] || gl_info
->supported
[APPLE_FENCE
];
399 /* Checking of API calls */
400 /* --------------------- */
401 #ifndef WINE_NO_DEBUG_MSGS
402 #define checkGLcall(A) \
405 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
406 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
407 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
410 #define checkGLcall(A) do {} while(0)
419 struct wined3d_allocator_block
*memory
;
426 uint64_t command_fence_id
;
429 static inline struct wined3d_bo_gl
*wined3d_bo_gl(struct wined3d_bo
*bo
)
431 return CONTAINING_RECORD(bo
, struct wined3d_bo_gl
, b
);
434 static inline GLuint
wined3d_bo_gl_id(struct wined3d_bo
*bo
)
436 return bo
? wined3d_bo_gl(bo
)->id
: 0;
439 union wined3d_gl_fence_object
445 enum wined3d_fence_result
448 WINED3D_FENCE_WAITING
,
449 WINED3D_FENCE_NOT_STARTED
,
450 WINED3D_FENCE_WRONG_THREAD
,
457 union wined3d_gl_fence_object object
;
458 struct wined3d_context_gl
*context_gl
;
461 HRESULT
wined3d_fence_create(struct wined3d_device
*device
, struct wined3d_fence
**fence
);
462 void wined3d_fence_destroy(struct wined3d_fence
*fence
);
463 void wined3d_fence_issue(struct wined3d_fence
*fence
, struct wined3d_device
*device
);
464 enum wined3d_fence_result
wined3d_fence_wait(const struct wined3d_fence
*fence
, struct wined3d_device
*device
);
465 enum wined3d_fence_result
wined3d_fence_test(const struct wined3d_fence
*fence
,
466 struct wined3d_device
*device
, uint32_t flags
);
468 HRESULT
wined3d_query_gl_create(struct wined3d_device
*device
, enum wined3d_query_type type
, void *parent
,
469 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
470 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl
*context_gl
, struct wined3d_query
*query
);
472 struct wined3d_event_query
474 struct wined3d_query query
;
476 struct wined3d_fence fence
;
480 struct wined3d_occlusion_query
482 struct wined3d_query query
;
486 struct wined3d_context_gl
*context_gl
;
491 struct wined3d_timestamp_query
493 struct wined3d_query query
;
497 struct wined3d_context_gl
*context_gl
;
501 union wined3d_gl_so_statistics_query
511 struct wined3d_so_statistics_query
513 struct wined3d_query query
;
516 union wined3d_gl_so_statistics_query u
;
517 struct wined3d_context_gl
*context_gl
;
518 unsigned int stream_idx
;
519 struct wined3d_query_data_so_statistics statistics
;
523 union wined3d_gl_pipeline_statistics_query
530 GLuint vertex_shader
;
531 GLuint tess_control_shader
;
532 GLuint tess_eval_shader
;
533 GLuint geometry_shader
;
534 GLuint geometry_primitives
;
535 GLuint fragment_shader
;
536 GLuint compute_shader
;
537 GLuint clipping_input
;
538 GLuint clipping_output
;
542 struct wined3d_pipeline_statistics_query
544 struct wined3d_query query
;
547 union wined3d_gl_pipeline_statistics_query u
;
548 struct wined3d_context_gl
*context_gl
;
549 struct wined3d_query_data_pipeline_statistics statistics
;
553 struct wined3d_gl_view
559 struct wined3d_rendertarget_info
561 struct wined3d_gl_view gl_view
;
562 struct wined3d_resource
*resource
;
563 unsigned int sub_resource_idx
;
564 unsigned int layer_count
;
567 struct wined3d_command_fence_gl
570 struct wined3d_fence
*fence
;
573 #define MAX_GL_FRAGMENT_SAMPLERS 32
575 struct wined3d_context_gl
577 struct wined3d_context c
;
579 const struct wined3d_gl_info
*gl_info
;
581 DWORD tid
; /* Thread ID which owns this context at the moment. */
583 uint32_t dc_is_private
: 1;
584 uint32_t dc_has_format
: 1; /* Only meaningful for private DCs. */
585 uint32_t fog_enabled
: 1;
586 uint32_t diffuse_attrib_to_1
: 1;
587 uint32_t rebind_fbo
: 1;
588 uint32_t untracked_material_count
: 2; /* Max value 2 */
589 uint32_t needs_set
: 1;
590 uint32_t internal_format_set
: 1;
592 uint32_t padding
: 22;
594 uint32_t default_attrib_value_set
;
596 GLenum tracking_parm
; /* Which source is tracking current colour. */
597 GLenum untracked_materials
[2];
599 unsigned int active_texture
;
601 GLenum
*texture_type
;
603 /* The WGL context. */
616 unsigned int fbo_entry_count
;
617 struct list fbo_list
;
618 struct list fbo_destroy_list
;
619 struct fbo_entry
*current_fbo
;
620 GLuint fbo_read_binding
;
621 GLuint fbo_draw_binding
;
622 struct wined3d_rendertarget_info blit_targets
[WINED3D_MAX_RENDER_TARGETS
];
623 uint32_t draw_buffers_mask
; /* Enabled draw buffers, 31 max. */
626 struct list occlusion_queries
;
628 struct list timestamp_queries
;
629 struct list so_statistics_queries
;
630 struct list pipeline_statistics_queries
;
632 GLuint
*free_occlusion_queries
;
633 SIZE_T free_occlusion_query_size
;
634 unsigned int free_occlusion_query_count
;
636 union wined3d_gl_fence_object
*free_fences
;
637 SIZE_T free_fence_size
;
638 unsigned int free_fence_count
;
640 GLuint
*free_timestamp_queries
;
641 SIZE_T free_timestamp_query_size
;
642 unsigned int free_timestamp_query_count
;
644 union wined3d_gl_so_statistics_query
*free_so_statistics_queries
;
645 SIZE_T free_so_statistics_query_size
;
646 unsigned int free_so_statistics_query_count
;
648 union wined3d_gl_pipeline_statistics_query
*free_pipeline_statistics_queries
;
649 SIZE_T free_pipeline_statistics_query_size
;
650 unsigned int free_pipeline_statistics_query_count
;
654 unsigned int tex_unit_map
[WINED3D_MAX_COMBINED_SAMPLERS
];
655 unsigned int rev_tex_unit_map
[MAX_GL_FRAGMENT_SAMPLERS
+ WINED3D_MAX_VERTEX_SAMPLERS
];
657 /* Extension emulation. */
659 GLfloat fog_coord_value
;
660 GLfloat colour
[4], fog_start
, fog_end
, fog_colour
[4];
662 GLuint dummy_arbfp_prog
;
666 struct wined3d_command_fence_gl
*fences
;
672 static inline struct wined3d_context_gl
*wined3d_context_gl(struct wined3d_context
*context
)
674 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
677 static inline const struct wined3d_context_gl
*wined3d_context_gl_const(const struct wined3d_context
*context
)
679 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
682 HGLRC
context_create_wgl_attribs(const struct wined3d_gl_info
*gl_info
, HDC hdc
, HGLRC share_ctx
);
683 DWORD
context_get_tls_idx(void);
684 void context_gl_apply_texture_draw_state(struct wined3d_context_gl
*context_gl
,
685 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
, unsigned int location
);
686 void context_gl_resource_released(struct wined3d_device
*device
, GLuint name
, BOOL rb_namespace
);
688 struct wined3d_context
*wined3d_context_gl_acquire(const struct wined3d_device
*device
,
689 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
690 void wined3d_context_gl_active_texture(struct wined3d_context_gl
*context_gl
,
691 const struct wined3d_gl_info
*gl_info
, unsigned int unit
);
692 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl
*context_gl
, struct wined3d_fence
*fence
);
693 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl
*context_gl
,
694 struct wined3d_occlusion_query
*query
);
695 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl
*context_gl
,
696 struct wined3d_pipeline_statistics_query
*query
);
697 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl
*context_gl
,
698 struct wined3d_so_statistics_query
*query
);
699 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl
*context_gl
,
700 struct wined3d_timestamp_query
*query
);
701 GLuint
wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl
*context_gl
,
702 unsigned int pool
, size_t size
);
703 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_device
*device
);
704 BOOL
wined3d_context_gl_apply_clear_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
,
705 unsigned int rt_count
, const struct wined3d_fb_state
*fb
);
706 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl
*context_gl
, GLenum target
,
707 struct wined3d_resource
*rt
, unsigned int rt_sub_resource_idx
,
708 struct wined3d_resource
*ds
, unsigned int ds_sub_resource_idx
, uint32_t location
);
709 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl
*context_gl
,
710 const struct wined3d_device
*device
);
711 void wined3d_context_gl_bind_bo(struct wined3d_context_gl
*context_gl
, GLenum binding
, GLuint name
);
712 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl
*context_gl
);
713 void wined3d_context_gl_bind_texture(struct wined3d_context_gl
*context_gl
, GLenum target
, GLuint name
);
714 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl
*context_gl
, GLenum target
);
715 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl
*context_gl
,
716 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
717 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
);
718 void wined3d_context_gl_destroy(struct wined3d_context_gl
*context_gl
);
719 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo
);
720 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl
*context_gl
, struct wined3d_texture_gl
*texture_gl
,
721 unsigned int sub_resource_idx
, const RECT
*src_rect
, const RECT
*dst_rect
,
722 enum wined3d_texture_filter_type filter
);
723 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl
*context_gl
,
724 struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
725 const RECT
*src_rect
, const RECT
*dst_rect
, enum wined3d_texture_filter_type filter
);
726 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl
*context_gl
, uint32_t mask
);
727 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl
*context_gl
);
728 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl
*context_gl
,
729 const struct wined3d_const_bo_address
*data
, size_t size
);
730 void wined3d_context_gl_free_fence(struct wined3d_fence
*fence
);
731 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query
*query
);
732 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query
*query
);
733 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query
*query
);
734 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query
*query
);
735 struct wined3d_context_gl
*wined3d_context_gl_get_current(void);
736 GLenum
wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl
*context_gl
);
737 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl
*context_gl
,
738 const struct wined3d_shader_version
*shader_version
, unsigned int *base
, unsigned int *count
);
739 HRESULT
wined3d_context_gl_init(struct wined3d_context_gl
*context_gl
, struct wined3d_swapchain_gl
*swapchain_gl
);
740 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl
*context_gl
,
741 const struct wined3d_stream_info
*si
, GLuint
*current_bo
, const struct wined3d_state
*state
);
742 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl
*context_gl
,
743 const struct wined3d_bo_address
*data
, size_t size
, uint32_t flags
);
744 struct wined3d_context_gl
*wined3d_context_gl_reacquire(struct wined3d_context_gl
*context_gl
);
745 void wined3d_context_gl_release(struct wined3d_context_gl
*context_gl
);
746 BOOL
wined3d_context_gl_set_current(struct wined3d_context_gl
*context_gl
);
747 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl
*context_gl
);
748 void wined3d_context_gl_texture_update(struct wined3d_context_gl
*context_gl
,
749 const struct wined3d_texture_gl
*texture_gl
);
750 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl
*context_gl
);
751 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl
*context_gl
, const struct wined3d_bo_address
*data
,
752 unsigned int range_count
, const struct wined3d_range
*ranges
);
753 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
);
754 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl
*context_gl
, uint64_t id
);
756 void wined3d_arbfp_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_device
*device
);
757 void wined3d_fbo_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
758 void wined3d_ffp_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
759 struct wined3d_blitter
*wined3d_glsl_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_device
*device
);
760 void wined3d_raw_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
762 struct wined3d_caps_gl_ctx
768 HGLRC restore_gl_ctx
;
770 const struct wined3d_gl_info
*gl_info
;
772 GLuint test_program_id
;
774 const struct wined3d_gpu_description
*gpu_description
;
778 BOOL
wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
*ctx
);
779 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx
*ctx
, float offset
);
781 struct wined3d_adapter_gl
783 struct wined3d_adapter a
;
785 struct wined3d_gl_info gl_info
;
787 struct wined3d_pixel_format
*pixel_formats
;
788 unsigned int pixel_format_count
;
791 static inline struct wined3d_adapter_gl
*wined3d_adapter_gl(struct wined3d_adapter
*adapter
)
793 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
796 static inline const struct wined3d_adapter_gl
*wined3d_adapter_gl_const(const struct wined3d_adapter
*adapter
)
798 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
801 BOOL
wined3d_adapter_gl_init_format_info(struct wined3d_adapter
*adapter
, struct wined3d_caps_gl_ctx
*ctx
);
803 struct wined3d_allocator_chunk_gl
805 struct wined3d_allocator_chunk c
;
806 unsigned int memory_type
;
810 static inline struct wined3d_allocator_chunk_gl
*wined3d_allocator_chunk_gl(struct wined3d_allocator_chunk
*chunk
)
812 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_gl
, c
);
815 struct wined3d_dummy_textures
822 GLuint tex_cube_array
;
827 GLuint tex_2d_ms_array
;
830 struct wined3d_device_gl
832 struct wined3d_device d
;
834 /* Textures for when no other textures are bound. */
835 struct wined3d_dummy_textures dummy_textures
;
837 CRITICAL_SECTION allocator_cs
;
838 struct wined3d_allocator allocator
;
839 uint64_t completed_fence_id
;
840 uint64_t current_fence_id
;
841 uint64_t retired_bo_size
;
843 struct wined3d_retired_block_gl
845 struct wined3d_allocator_block
*block
;
848 SIZE_T retired_blocks_size
;
849 SIZE_T retired_block_count
;
855 static inline struct wined3d_device_gl
*wined3d_device_gl(struct wined3d_device
*device
)
857 return CONTAINING_RECORD(device
, struct wined3d_device_gl
, d
);
860 static inline struct wined3d_device_gl
*wined3d_device_gl_from_allocator(struct wined3d_allocator
*allocator
)
862 return CONTAINING_RECORD(allocator
, struct wined3d_device_gl
, allocator
);
865 static inline void wined3d_device_gl_allocator_lock(struct wined3d_device_gl
*device_gl
)
867 EnterCriticalSection(&device_gl
->allocator_cs
);
870 static inline void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl
*device_gl
)
872 LeaveCriticalSection(&device_gl
->allocator_cs
);
875 static inline void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
877 wined3d_device_gl_allocator_lock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
880 static inline void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
882 wined3d_device_gl_allocator_unlock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
885 bool wined3d_device_gl_create_bo(struct wined3d_device_gl
*device_gl
,
886 struct wined3d_context_gl
*context_gl
, GLsizeiptr size
, GLenum binding
,
887 GLenum usage
, bool coherent
, GLbitfield flags
, struct wined3d_bo_gl
*bo
);
888 void wined3d_device_gl_create_primary_opengl_context_cs(void *object
);
889 void wined3d_device_gl_delete_opengl_contexts_cs(void *object
);
890 HDC
wined3d_device_gl_get_backup_dc(struct wined3d_device_gl
*device_gl
);
891 GLbitfield
wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx
);
893 #endif /* __WINE_WINED3D_GL */