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 struct wined3d_swapchain_gl
;
36 struct wined3d_texture_gl
;
38 #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 /* not in the gl spec */
40 /* OpenGL extensions. */
41 enum wined3d_gl_extension
48 APPLE_FLUSH_BUFFER_RANGE
,
54 ARB_BLEND_FUNC_EXTENDED
,
56 ARB_CLEAR_BUFFER_OBJECT
,
59 ARB_COLOR_BUFFER_FLOAT
,
61 ARB_CONSERVATIVE_DEPTH
,
66 ARB_DEPTH_BUFFER_FLOAT
,
69 ARB_DERIVATIVE_CONTROL
,
71 ARB_DRAW_BUFFERS_BLEND
,
72 ARB_DRAW_ELEMENTS_BASE_VERTEX
,
75 ARB_ES2_COMPATIBILITY
,
76 ARB_ES3_COMPATIBILITY
,
77 ARB_EXPLICIT_ATTRIB_LOCATION
,
78 ARB_FRAGMENT_COORD_CONVENTIONS
,
79 ARB_FRAGMENT_LAYER_VIEWPORT
,
82 ARB_FRAMEBUFFER_NO_ATTACHMENTS
,
83 ARB_FRAMEBUFFER_OBJECT
,
88 ARB_HALF_FLOAT_VERTEX
,
90 ARB_INTERNALFORMAT_QUERY
,
91 ARB_INTERNALFORMAT_QUERY2
,
92 ARB_MAP_BUFFER_ALIGNMENT
,
97 ARB_PIPELINE_STATISTICS_QUERY
,
98 ARB_PIXEL_BUFFER_OBJECT
,
101 ARB_POLYGON_OFFSET_CLAMP
,
102 ARB_PROVOKING_VERTEX
,
103 ARB_QUERY_BUFFER_OBJECT
,
106 ARB_SEAMLESS_CUBE_MAP
,
107 ARB_SHADER_ATOMIC_COUNTERS
,
108 ARB_SHADER_VIEWPORT_LAYER_ARRAY
,
109 ARB_SHADER_BIT_ENCODING
,
110 ARB_SHADER_IMAGE_LOAD_STORE
,
111 ARB_SHADER_IMAGE_SIZE
,
112 ARB_SHADER_STORAGE_BUFFER_OBJECT
,
113 ARB_SHADER_TEXTURE_IMAGE_SAMPLES
,
114 ARB_SHADER_TEXTURE_LOD
,
115 ARB_SHADING_LANGUAGE_100
,
116 ARB_SHADING_LANGUAGE_420PACK
,
117 ARB_SHADING_LANGUAGE_PACKING
,
119 ARB_STENCIL_TEXTURING
,
121 ARB_TESSELLATION_SHADER
,
122 ARB_TEXTURE_BORDER_CLAMP
,
123 ARB_TEXTURE_BUFFER_OBJECT
,
124 ARB_TEXTURE_BUFFER_RANGE
,
125 ARB_TEXTURE_COMPRESSION
,
126 ARB_TEXTURE_COMPRESSION_BPTC
,
127 ARB_TEXTURE_COMPRESSION_RGTC
,
128 ARB_TEXTURE_CUBE_MAP
,
129 ARB_TEXTURE_CUBE_MAP_ARRAY
,
130 ARB_TEXTURE_ENV_COMBINE
,
131 ARB_TEXTURE_ENV_DOT3
,
132 ARB_TEXTURE_FILTER_ANISOTROPIC
,
135 ARB_TEXTURE_MIRRORED_REPEAT
,
136 ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
,
137 ARB_TEXTURE_MULTISAMPLE
,
138 ARB_TEXTURE_NON_POWER_OF_TWO
,
139 ARB_TEXTURE_QUERY_LEVELS
,
140 ARB_TEXTURE_RECTANGLE
,
142 ARB_TEXTURE_RGB10_A2UI
,
144 ARB_TEXTURE_STORAGE_MULTISAMPLE
,
148 ARB_TRANSFORM_FEEDBACK2
,
149 ARB_TRANSFORM_FEEDBACK3
,
150 ARB_UNIFORM_BUFFER_OBJECT
,
151 ARB_VERTEX_ARRAY_BGRA
,
152 ARB_VERTEX_BUFFER_OBJECT
,
155 ARB_VERTEX_TYPE_10F_11F_11F_REV
,
156 ARB_VERTEX_TYPE_2_10_10_10_REV
,
161 ATI_SEPARATE_STENCIL
,
162 ATI_TEXTURE_COMPRESSION_3DC
,
163 ATI_TEXTURE_ENV_COMBINE3
,
164 ATI_TEXTURE_MIRROR_ONCE
,
167 EXT_BLEND_EQUATION_SEPARATE
,
168 EXT_BLEND_FUNC_SEPARATE
,
171 EXT_DEPTH_BOUNDS_TEST
,
174 EXT_FRAMEBUFFER_BLIT
,
175 EXT_FRAMEBUFFER_MULTISAMPLE
,
176 EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
,
177 EXT_FRAMEBUFFER_OBJECT
,
178 EXT_GPU_PROGRAM_PARAMETERS
,
181 EXT_PACKED_DEPTH_STENCIL
,
183 EXT_POINT_PARAMETERS
,
184 EXT_PROVOKING_VERTEX
,
186 EXT_STENCIL_TWO_SIDE
,
190 EXT_TEXTURE_COMPRESSION_RGTC
,
191 EXT_TEXTURE_COMPRESSION_S3TC
,
192 EXT_TEXTURE_ENV_COMBINE
,
193 EXT_TEXTURE_ENV_DOT3
,
195 EXT_TEXTURE_LOD_BIAS
,
196 EXT_TEXTURE_MIRROR_CLAMP
,
197 EXT_TEXTURE_SHADOW_LOD
,
198 EXT_TEXTURE_SHARED_EXPONENT
,
201 EXT_TEXTURE_SRGB_DECODE
,
206 NV_FRAGMENT_PROGRAM2
,
207 NV_FRAGMENT_PROGRAM_OPTION
,
209 NV_LIGHT_MAX_EXPONENT
,
211 NV_REGISTER_COMBINERS
,
212 NV_REGISTER_COMBINERS2
,
213 NV_TEXGEN_REFLECTION
,
214 NV_TEXTURE_ENV_COMBINE4
,
218 NV_VERTEX_PROGRAM1_1
,
220 NV_VERTEX_PROGRAM2_OPTION
,
224 WGL_ARB_PIXEL_FORMAT
,
225 WGL_EXT_SWAP_CONTROL
,
226 WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
,
227 WGL_WINE_QUERY_RENDERER
,
228 /* Internally used */
229 WINED3D_GL_BLEND_EQUATION
,
230 WINED3D_GL_LEGACY_CONTEXT
,
231 WINED3D_GL_NORMALIZED_TEXRECT
,
232 WINED3D_GL_PRIMITIVE_QUERY
,
233 WINED3D_GL_VERSION_2_0
,
234 WINED3D_GL_VERSION_3_2
,
237 WINED3D_GL_EXT_COUNT
,
240 struct wined3d_fbo_ops
242 GLboolean (WINE_GLAPI
*glIsRenderbuffer
)(GLuint renderbuffer
);
243 void (WINE_GLAPI
*glBindRenderbuffer
)(GLenum target
, GLuint renderbuffer
);
244 void (WINE_GLAPI
*glDeleteRenderbuffers
)(GLsizei n
, const GLuint
*renderbuffers
);
245 void (WINE_GLAPI
*glGenRenderbuffers
)(GLsizei n
, GLuint
*renderbuffers
);
246 void (WINE_GLAPI
*glRenderbufferStorage
)(GLenum target
, GLenum internalformat
,
247 GLsizei width
, GLsizei height
);
248 void (WINE_GLAPI
*glRenderbufferStorageMultisample
)(GLenum target
, GLsizei samples
,
249 GLenum internalformat
, GLsizei width
, GLsizei height
);
250 void (WINE_GLAPI
*glGetRenderbufferParameteriv
)(GLenum target
, GLenum pname
, GLint
*params
);
251 GLboolean (WINE_GLAPI
*glIsFramebuffer
)(GLuint framebuffer
);
252 void (WINE_GLAPI
*glBindFramebuffer
)(GLenum target
, GLuint framebuffer
);
253 void (WINE_GLAPI
*glDeleteFramebuffers
)(GLsizei n
, const GLuint
*framebuffers
);
254 void (WINE_GLAPI
*glGenFramebuffers
)(GLsizei n
, GLuint
*framebuffers
);
255 GLenum (WINE_GLAPI
*glCheckFramebufferStatus
)(GLenum target
);
256 void (WINE_GLAPI
*glFramebufferTexture
)(GLenum target
, GLenum attachment
,
257 GLuint texture
, GLint level
);
258 void (WINE_GLAPI
*glFramebufferTexture1D
)(GLenum target
, GLenum attachment
,
259 GLenum textarget
, GLuint texture
, GLint level
);
260 void (WINE_GLAPI
*glFramebufferTexture2D
)(GLenum target
, GLenum attachment
,
261 GLenum textarget
, GLuint texture
, GLint level
);
262 void (WINE_GLAPI
*glFramebufferTexture3D
)(GLenum target
, GLenum attachment
,
263 GLenum textarget
, GLuint texture
, GLint level
, GLint layer
);
264 void (WINE_GLAPI
*glFramebufferTextureLayer
)(GLenum target
, GLenum attachment
,
265 GLuint texture
, GLint level
, GLint layer
);
266 void (WINE_GLAPI
*glFramebufferRenderbuffer
)(GLenum target
, GLenum attachment
,
267 GLenum renderbuffertarget
, GLuint renderbuffer
);
268 void (WINE_GLAPI
*glGetFramebufferAttachmentParameteriv
)(GLenum target
, GLenum attachment
,
269 GLenum pname
, GLint
*params
);
270 void (WINE_GLAPI
*glBlitFramebuffer
)(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
271 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
, GLbitfield mask
, GLenum filter
);
272 void (WINE_GLAPI
*glGenerateMipmap
)(GLenum target
);
275 struct wined3d_gl_limits
277 unsigned int buffers
;
279 unsigned int textures
;
280 unsigned int texture_coords
;
281 unsigned int uniform_blocks
[WINED3D_SHADER_TYPE_COUNT
];
282 unsigned int samplers
[WINED3D_SHADER_TYPE_COUNT
];
283 unsigned int graphics_samplers
;
284 unsigned int combined_samplers
;
285 unsigned int general_combiners
;
286 unsigned int user_clip_distances
;
287 unsigned int texture_size
;
288 unsigned int texture3d_size
;
289 unsigned int anisotropy
;
291 unsigned int samples
;
292 unsigned int vertex_attribs
;
294 unsigned int texture_buffer_offset_alignment
;
296 unsigned int framebuffer_width
;
297 unsigned int framebuffer_height
;
298 unsigned int viewport_subpixel_bits
;
300 unsigned int glsl_varyings
;
301 unsigned int glsl_vs_float_constants
;
302 unsigned int glsl_ps_float_constants
;
304 unsigned int arb_vs_float_constants
;
305 unsigned int arb_vs_native_constants
;
306 unsigned int arb_vs_instructions
;
307 unsigned int arb_vs_temps
;
308 unsigned int arb_ps_float_constants
;
309 unsigned int arb_ps_local_constants
;
310 unsigned int arb_ps_native_constants
;
311 unsigned int arb_ps_instructions
;
312 unsigned int arb_ps_temps
;
315 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits
*gl_limits
,
316 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
);
317 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits
*gl_limits
,
318 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
);
320 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
321 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
322 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
323 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
324 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
325 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
326 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
327 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
328 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
329 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
331 typedef void (WINE_GLAPI
*wined3d_ffp_attrib_func
)(const void *data
);
332 typedef void (WINE_GLAPI
*wined3d_ffp_texcoord_func
)(GLenum unit
, const void *data
);
333 typedef void (WINE_GLAPI
*wined3d_generic_attrib_func
)(GLuint idx
, const void *data
);
335 struct wined3d_ffp_attrib_ops
337 wined3d_ffp_attrib_func position
[WINED3D_FFP_EMIT_COUNT
];
338 wined3d_ffp_attrib_func diffuse
[WINED3D_FFP_EMIT_COUNT
];
339 wined3d_ffp_attrib_func specular
[WINED3D_FFP_EMIT_COUNT
];
340 wined3d_ffp_attrib_func normal
[WINED3D_FFP_EMIT_COUNT
];
341 wined3d_ffp_texcoord_func texcoord
[WINED3D_FFP_EMIT_COUNT
];
342 wined3d_generic_attrib_func generic
[WINED3D_FFP_EMIT_COUNT
];
345 struct wined3d_gl_info
347 unsigned int selected_gl_version
;
348 unsigned int glsl_version
;
349 struct wined3d_gl_limits limits
;
350 unsigned int reserved_glsl_constants
, reserved_arb_constants
;
352 BOOL supported
[WINED3D_GL_EXT_COUNT
];
353 GLint wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
+ 1];
354 float filling_convention_offset
;
356 HGLRC (WINAPI
*p_wglCreateContextAttribsARB
)(HDC dc
, HGLRC share
, const GLint
*attribs
);
357 struct wined3d_ffp_attrib_ops ffp_attrib_ops
;
358 struct opengl_funcs gl_ops
;
359 struct wined3d_fbo_ops fbo_ops
;
361 void (WINE_GLAPI
*p_glDisableWINE
)(GLenum cap
);
362 void (WINE_GLAPI
*p_glEnableWINE
)(GLenum cap
);
365 void install_gl_compat_wrapper(struct wined3d_gl_info
*gl_info
, enum wined3d_gl_extension ext
);
366 void print_glsl_info_log(const struct wined3d_gl_info
*gl_info
, GLuint id
, BOOL program
);
367 void shader_glsl_validate_link(const struct wined3d_gl_info
*gl_info
, GLuint program
);
368 GLenum
wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info
*gl_info
, uint32_t bind_flags
);
369 void wined3d_check_gl_call(const struct wined3d_gl_info
*gl_info
,
370 const char *file
, unsigned int line
, const char *name
);
374 GLenum mip
[WINED3D_TEXF_LINEAR
+ 1];
377 extern const struct min_lookup minMipLookup
[WINED3D_TEXF_LINEAR
+ 1];
378 extern const GLenum magLookup
[WINED3D_TEXF_LINEAR
+ 1];
380 static inline GLenum
wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter
)
382 return magLookup
[mag_filter
];
385 static inline GLenum
wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter
,
386 enum wined3d_texture_filter_type mip_filter
)
388 return minMipLookup
[min_filter
].mip
[mip_filter
];
391 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
);
393 const char *debug_fboattachment(GLenum attachment
);
394 const char *debug_fbostatus(GLenum status
);
395 const char *debug_glerror(GLenum error
);
397 static inline bool wined3d_fence_supported(const struct wined3d_gl_info
*gl_info
)
399 return gl_info
->supported
[ARB_SYNC
] || gl_info
->supported
[NV_FENCE
] || gl_info
->supported
[APPLE_FENCE
];
402 /* Checking of API calls */
403 /* --------------------- */
404 #ifndef WINE_NO_DEBUG_MSGS
405 #define checkGLcall(A) \
408 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
409 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
410 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
413 #define checkGLcall(A) do {} while(0)
422 struct wined3d_allocator_block
*memory
;
429 uint64_t command_fence_id
;
432 static inline struct wined3d_bo_gl
*wined3d_bo_gl(struct wined3d_bo
*bo
)
434 return CONTAINING_RECORD(bo
, struct wined3d_bo_gl
, b
);
437 static inline GLuint
wined3d_bo_gl_id(struct wined3d_bo
*bo
)
439 return bo
? wined3d_bo_gl(bo
)->id
: 0;
442 union wined3d_gl_fence_object
448 enum wined3d_fence_result
451 WINED3D_FENCE_WAITING
,
452 WINED3D_FENCE_NOT_STARTED
,
453 WINED3D_FENCE_WRONG_THREAD
,
460 union wined3d_gl_fence_object object
;
461 struct wined3d_context_gl
*context_gl
;
464 HRESULT
wined3d_fence_create(struct wined3d_device
*device
, struct wined3d_fence
**fence
);
465 void wined3d_fence_destroy(struct wined3d_fence
*fence
);
466 void wined3d_fence_issue(struct wined3d_fence
*fence
, struct wined3d_device
*device
);
467 enum wined3d_fence_result
wined3d_fence_wait(const struct wined3d_fence
*fence
, struct wined3d_device
*device
);
468 enum wined3d_fence_result
wined3d_fence_test(const struct wined3d_fence
*fence
,
469 struct wined3d_device
*device
, uint32_t flags
);
471 HRESULT
wined3d_query_gl_create(struct wined3d_device
*device
, enum wined3d_query_type type
, void *parent
,
472 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
473 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl
*context_gl
, struct wined3d_query
*query
);
475 struct wined3d_event_query
477 struct wined3d_query query
;
479 struct wined3d_fence fence
;
483 struct wined3d_occlusion_query
485 struct wined3d_query query
;
489 struct wined3d_context_gl
*context_gl
;
494 struct wined3d_timestamp_query
496 struct wined3d_query query
;
500 struct wined3d_context_gl
*context_gl
;
504 union wined3d_gl_so_statistics_query
514 struct wined3d_so_statistics_query
516 struct wined3d_query query
;
519 union wined3d_gl_so_statistics_query u
;
520 struct wined3d_context_gl
*context_gl
;
521 unsigned int stream_idx
;
522 struct wined3d_query_data_so_statistics statistics
;
526 union wined3d_gl_pipeline_statistics_query
533 GLuint vertex_shader
;
534 GLuint tess_control_shader
;
535 GLuint tess_eval_shader
;
536 GLuint geometry_shader
;
537 GLuint geometry_primitives
;
538 GLuint fragment_shader
;
539 GLuint compute_shader
;
540 GLuint clipping_input
;
541 GLuint clipping_output
;
545 struct wined3d_pipeline_statistics_query
547 struct wined3d_query query
;
550 union wined3d_gl_pipeline_statistics_query u
;
551 struct wined3d_context_gl
*context_gl
;
552 struct wined3d_query_data_pipeline_statistics statistics
;
556 struct wined3d_gl_view
562 struct wined3d_rendertarget_info
564 struct wined3d_gl_view gl_view
;
565 struct wined3d_resource
*resource
;
566 unsigned int sub_resource_idx
;
567 unsigned int layer_count
;
570 struct wined3d_command_fence_gl
573 struct wined3d_fence
*fence
;
576 #define MAX_GL_FRAGMENT_SAMPLERS 32
578 struct wined3d_fbo_resource
585 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
586 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
587 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
595 struct wined3d_fbo_entry_key
597 uint32_t rb_namespace
;
598 struct wined3d_fbo_resource objects
[WINED3D_MAX_RENDER_TARGETS
+ 1];
602 struct wined3d_context_gl
604 struct wined3d_context c
;
606 const struct wined3d_gl_info
*gl_info
;
608 DWORD tid
; /* Thread ID which owns this context at the moment. */
610 uint32_t dc_is_private
: 1;
611 uint32_t dc_has_format
: 1; /* Only meaningful for private DCs. */
612 uint32_t fog_enabled
: 1;
613 uint32_t diffuse_attrib_to_1
: 1;
614 uint32_t rebind_fbo
: 1;
615 uint32_t untracked_material_count
: 2; /* Max value 2 */
616 uint32_t needs_set
: 1;
617 uint32_t internal_format_set
: 1;
619 uint32_t padding
: 22;
621 uint32_t default_attrib_value_set
;
623 GLenum tracking_parm
; /* Which source is tracking current colour. */
624 GLenum untracked_materials
[2];
626 unsigned int active_texture
;
628 GLenum
*texture_type
;
630 /* The WGL context. */
643 unsigned int fbo_entry_count
;
644 struct list fbo_list
;
645 struct list fbo_destroy_list
;
646 struct fbo_entry
*current_fbo
;
647 GLuint fbo_read_binding
;
648 GLuint fbo_draw_binding
;
649 struct wined3d_rendertarget_info blit_targets
[WINED3D_MAX_RENDER_TARGETS
];
650 uint32_t draw_buffers_mask
; /* Enabled draw buffers, 31 max. */
653 struct list occlusion_queries
;
655 struct list timestamp_queries
;
656 struct list so_statistics_queries
;
657 struct list pipeline_statistics_queries
;
659 GLuint
*free_occlusion_queries
;
660 SIZE_T free_occlusion_query_size
;
661 unsigned int free_occlusion_query_count
;
663 union wined3d_gl_fence_object
*free_fences
;
664 SIZE_T free_fence_size
;
665 unsigned int free_fence_count
;
667 GLuint
*free_timestamp_queries
;
668 SIZE_T free_timestamp_query_size
;
669 unsigned int free_timestamp_query_count
;
671 union wined3d_gl_so_statistics_query
*free_so_statistics_queries
;
672 SIZE_T free_so_statistics_query_size
;
673 unsigned int free_so_statistics_query_count
;
675 union wined3d_gl_pipeline_statistics_query
*free_pipeline_statistics_queries
;
676 SIZE_T free_pipeline_statistics_query_size
;
677 unsigned int free_pipeline_statistics_query_count
;
681 unsigned int tex_unit_map
[WINED3D_MAX_COMBINED_SAMPLERS
];
682 unsigned int rev_tex_unit_map
[MAX_GL_FRAGMENT_SAMPLERS
+ WINED3D_MAX_VERTEX_SAMPLERS
];
684 /* Extension emulation. */
686 GLfloat fog_coord_value
;
687 GLfloat colour
[4], fog_start
, fog_end
, fog_colour
[4];
689 GLuint dummy_arbfp_prog
;
693 struct wined3d_command_fence_gl
*fences
;
699 static inline struct wined3d_context_gl
*wined3d_context_gl(struct wined3d_context
*context
)
701 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
704 static inline const struct wined3d_context_gl
*wined3d_context_gl_const(const struct wined3d_context
*context
)
706 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
709 HGLRC
context_create_wgl_attribs(const struct wined3d_gl_info
*gl_info
, HDC hdc
, HGLRC share_ctx
);
710 DWORD
context_get_tls_idx(void);
711 void context_gl_apply_texture_draw_state(struct wined3d_context_gl
*context_gl
,
712 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
, unsigned int location
);
713 void context_gl_resource_released(struct wined3d_device
*device
, GLuint name
, BOOL rb_namespace
);
715 struct wined3d_context
*wined3d_context_gl_acquire(const struct wined3d_device
*device
,
716 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
717 void wined3d_context_gl_active_texture(struct wined3d_context_gl
*context_gl
,
718 const struct wined3d_gl_info
*gl_info
, unsigned int unit
);
719 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl
*context_gl
, struct wined3d_fence
*fence
);
720 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl
*context_gl
,
721 struct wined3d_occlusion_query
*query
);
722 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl
*context_gl
,
723 struct wined3d_pipeline_statistics_query
*query
);
724 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl
*context_gl
,
725 struct wined3d_so_statistics_query
*query
);
726 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl
*context_gl
,
727 struct wined3d_timestamp_query
*query
);
728 GLuint
wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl
*context_gl
,
729 unsigned int pool
, size_t size
);
730 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_device
*device
);
731 BOOL
wined3d_context_gl_apply_clear_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
,
732 unsigned int rt_count
, const struct wined3d_fb_state
*fb
);
733 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl
*context_gl
, GLenum target
,
734 struct wined3d_resource
*rt
, unsigned int rt_sub_resource_idx
,
735 struct wined3d_resource
*ds
, unsigned int ds_sub_resource_idx
, uint32_t location
);
736 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl
*context_gl
,
737 const struct wined3d_device
*device
);
738 void wined3d_context_gl_bind_bo(struct wined3d_context_gl
*context_gl
, GLenum binding
, GLuint name
);
739 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl
*context_gl
);
740 void wined3d_context_gl_bind_texture(struct wined3d_context_gl
*context_gl
, GLenum target
, GLuint name
);
741 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl
*context_gl
, GLenum target
);
742 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl
*context_gl
,
743 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
744 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
);
745 void wined3d_context_gl_destroy(struct wined3d_context_gl
*context_gl
);
746 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo
);
747 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl
*context_gl
, struct wined3d_texture_gl
*texture_gl
,
748 unsigned int sub_resource_idx
, const RECT
*src_rect
, const RECT
*dst_rect
,
749 enum wined3d_texture_filter_type filter
);
750 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl
*context_gl
,
751 struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
752 const RECT
*src_rect
, const RECT
*dst_rect
, enum wined3d_texture_filter_type filter
);
753 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl
*context_gl
, uint32_t mask
);
754 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl
*context_gl
);
755 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl
*context_gl
,
756 const struct wined3d_const_bo_address
*data
, size_t size
);
757 void wined3d_context_gl_free_fence(struct wined3d_fence
*fence
);
758 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query
*query
);
759 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query
*query
);
760 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query
*query
);
761 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query
*query
);
762 struct wined3d_context_gl
*wined3d_context_gl_get_current(void);
763 GLenum
wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl
*context_gl
);
764 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl
*context_gl
,
765 const struct wined3d_shader_version
*shader_version
, unsigned int *base
, unsigned int *count
);
766 HRESULT
wined3d_context_gl_init(struct wined3d_context_gl
*context_gl
, struct wined3d_swapchain_gl
*swapchain_gl
);
767 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl
*context_gl
,
768 const struct wined3d_stream_info
*si
, GLuint
*current_bo
, const struct wined3d_state
*state
);
769 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl
*context_gl
,
770 const struct wined3d_bo_address
*data
, size_t size
, uint32_t flags
);
771 struct wined3d_context_gl
*wined3d_context_gl_reacquire(struct wined3d_context_gl
*context_gl
);
772 void wined3d_context_gl_release(struct wined3d_context_gl
*context_gl
);
773 BOOL
wined3d_context_gl_set_current(struct wined3d_context_gl
*context_gl
);
774 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl
*context_gl
);
775 void wined3d_context_gl_texture_update(struct wined3d_context_gl
*context_gl
,
776 const struct wined3d_texture_gl
*texture_gl
);
777 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl
*context_gl
);
778 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl
*context_gl
, const struct wined3d_bo_address
*data
,
779 unsigned int range_count
, const struct wined3d_range
*ranges
);
780 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
);
781 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl
*context_gl
, uint64_t id
);
783 void wined3d_arbfp_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_device
*device
);
784 void wined3d_fbo_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
785 void wined3d_ffp_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
786 struct wined3d_blitter
*wined3d_glsl_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_device
*device
);
787 void wined3d_raw_blitter_create(struct wined3d_blitter
**next
, const struct wined3d_gl_info
*gl_info
);
789 struct wined3d_caps_gl_ctx
795 HGLRC restore_gl_ctx
;
797 const struct wined3d_gl_info
*gl_info
;
799 GLuint test_program_id
;
801 const struct wined3d_gpu_description
*gpu_description
;
805 BOOL
wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
*ctx
);
806 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx
*ctx
, float offset
);
808 struct wined3d_adapter_gl
810 struct wined3d_adapter a
;
812 struct wined3d_gl_info gl_info
;
814 struct wined3d_pixel_format
*pixel_formats
;
815 unsigned int pixel_format_count
;
818 static inline struct wined3d_adapter_gl
*wined3d_adapter_gl(struct wined3d_adapter
*adapter
)
820 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
823 static inline const struct wined3d_adapter_gl
*wined3d_adapter_gl_const(const struct wined3d_adapter
*adapter
)
825 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
828 BOOL
wined3d_adapter_gl_init_format_info(struct wined3d_adapter
*adapter
, struct wined3d_caps_gl_ctx
*ctx
);
830 struct wined3d_allocator_chunk_gl
832 struct wined3d_allocator_chunk c
;
833 unsigned int memory_type
;
837 static inline struct wined3d_allocator_chunk_gl
*wined3d_allocator_chunk_gl(struct wined3d_allocator_chunk
*chunk
)
839 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_gl
, c
);
842 struct wined3d_dummy_textures
849 GLuint tex_cube_array
;
854 GLuint tex_2d_ms_array
;
857 struct wined3d_device_gl
859 struct wined3d_device d
;
861 /* Textures for when no other textures are bound. */
862 struct wined3d_dummy_textures dummy_textures
;
864 CRITICAL_SECTION allocator_cs
;
865 struct wined3d_allocator allocator
;
866 uint64_t completed_fence_id
;
867 uint64_t current_fence_id
;
868 uint64_t retired_bo_size
;
870 struct wined3d_retired_block_gl
872 struct wined3d_allocator_block
*block
;
875 SIZE_T retired_blocks_size
;
876 SIZE_T retired_block_count
;
882 static inline struct wined3d_device_gl
*wined3d_device_gl(struct wined3d_device
*device
)
884 return CONTAINING_RECORD(device
, struct wined3d_device_gl
, d
);
887 static inline struct wined3d_device_gl
*wined3d_device_gl_from_allocator(struct wined3d_allocator
*allocator
)
889 return CONTAINING_RECORD(allocator
, struct wined3d_device_gl
, allocator
);
892 static inline void wined3d_device_gl_allocator_lock(struct wined3d_device_gl
*device_gl
)
894 EnterCriticalSection(&device_gl
->allocator_cs
);
897 static inline void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl
*device_gl
)
899 LeaveCriticalSection(&device_gl
->allocator_cs
);
902 static inline void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
904 wined3d_device_gl_allocator_lock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
907 static inline void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
909 wined3d_device_gl_allocator_unlock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
912 bool wined3d_device_gl_create_bo(struct wined3d_device_gl
*device_gl
,
913 struct wined3d_context_gl
*context_gl
, GLsizeiptr size
, GLenum binding
,
914 GLenum usage
, bool coherent
, GLbitfield flags
, struct wined3d_bo_gl
*bo
);
915 void wined3d_device_gl_create_primary_opengl_context_cs(void *object
);
916 void wined3d_device_gl_delete_opengl_contexts_cs(void *object
);
917 HDC
wined3d_device_gl_get_backup_dc(struct wined3d_device_gl
*device_gl
);
918 GLbitfield
wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx
);
920 GLbitfield
wined3d_resource_gl_map_flags(const struct wined3d_bo_gl
*bo
, DWORD d3d_flags
);
921 GLenum
wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags
);
922 GLbitfield
wined3d_resource_gl_storage_flags(const struct wined3d_resource
*resource
);
926 struct wined3d_sampler_desc sampler_desc
;
927 unsigned int base_level
;
931 struct wined3d_renderbuffer_entry
935 unsigned int width
, height
;
938 struct wined3d_texture_gl
940 struct wined3d_texture t
;
942 struct gl_texture texture_rgb
, texture_srgb
;
946 GLuint rb_multisample
;
949 struct list renderbuffers
;
950 const struct wined3d_renderbuffer_entry
*current_renderbuffer
;
953 static inline struct wined3d_texture_gl
*wined3d_texture_gl(struct wined3d_texture
*texture
)
955 return CONTAINING_RECORD(texture
, struct wined3d_texture_gl
, t
);
958 static inline struct gl_texture
*wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl
*texture_gl
, bool srgb
)
960 return srgb
? &texture_gl
->texture_srgb
: &texture_gl
->texture_rgb
;
963 static inline GLenum
wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl
*texture_gl
,
964 unsigned int sub_resource_idx
)
966 static const GLenum cube_targets
[] =
968 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
969 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
970 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
971 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
972 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
973 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
,
976 if (texture_gl
->t
.resource
.usage
& WINED3DUSAGE_LEGACY_CUBEMAP
)
977 return cube_targets
[sub_resource_idx
/ texture_gl
->t
.level_count
];
978 return texture_gl
->target
;
981 static inline bool wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl
*texture_gl
,
984 if (location
== WINED3D_LOCATION_RB_MULTISAMPLE
)
986 if (location
!= WINED3D_LOCATION_TEXTURE_RGB
&& location
!= WINED3D_LOCATION_TEXTURE_SRGB
)
988 return texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE
|| texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
;
991 struct wined3d_blt_info
994 struct wined3d_vec3 texcoords
[4];
997 void texture2d_get_blt_info(const struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
998 const RECT
*rect
, struct wined3d_blt_info
*info
);
999 void texture2d_load_fb_texture(struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
1000 BOOL srgb
, struct wined3d_context
*context
);
1001 void texture2d_read_from_framebuffer(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
1002 struct wined3d_context
*context
, DWORD src_location
, DWORD dst_location
);
1004 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle
[4], struct color_fixup_desc fixup
);
1005 GLenum
wined3d_texture_get_gl_buffer(const struct wined3d_texture
*texture
);
1007 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl
*texture_gl
,
1008 const struct wined3d_sampler_desc
*sampler_desc
, const struct wined3d_context_gl
*context_gl
);
1009 void wined3d_texture_gl_bind(struct wined3d_texture_gl
*texture_gl
, struct wined3d_context_gl
*context_gl
, BOOL srgb
);
1010 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl
*texture_gl
,
1011 struct wined3d_context_gl
*context_gl
, BOOL srgb
);
1012 HRESULT
wined3d_texture_gl_init(struct wined3d_texture_gl
*texture_gl
, struct wined3d_device
*device
,
1013 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
1014 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1015 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl
*texture_gl
,
1016 struct wined3d_context_gl
*context_gl
, BOOL srgb
);
1017 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl
*texture_gl
,
1018 struct wined3d_context_gl
*context_gl
, unsigned int level
, const struct wined3d_rendertarget_info
*rt
);
1020 struct wined3d_sampler_gl
1022 struct wined3d_sampler s
;
1027 static inline struct wined3d_sampler_gl
*wined3d_sampler_gl(struct wined3d_sampler
*sampler
)
1029 return CONTAINING_RECORD(sampler
, struct wined3d_sampler_gl
, s
);
1032 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl
*sampler_gl
, unsigned int unit
,
1033 struct wined3d_texture_gl
*texture_gl
, const struct wined3d_context_gl
*context_gl
);
1034 void wined3d_sampler_gl_init(struct wined3d_sampler_gl
*sampler_gl
, struct wined3d_device
*device
,
1035 const struct wined3d_sampler_desc
*desc
, void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1037 struct wined3d_buffer_gl
1039 struct wined3d_buffer b
;
1042 static inline struct wined3d_buffer_gl
*wined3d_buffer_gl(struct wined3d_buffer
*buffer
)
1044 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
1047 static inline const struct wined3d_buffer_gl
*wined3d_buffer_gl_const(const struct wined3d_buffer
*buffer
)
1049 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
1052 HRESULT
wined3d_buffer_gl_init(struct wined3d_buffer_gl
*buffer_gl
, struct wined3d_device
*device
,
1053 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
1054 void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1056 struct wined3d_rendertarget_view_gl
1058 struct wined3d_rendertarget_view v
;
1059 struct wined3d_gl_view gl_view
;
1062 static inline struct wined3d_rendertarget_view_gl
*wined3d_rendertarget_view_gl(
1063 struct wined3d_rendertarget_view
*view
)
1065 return CONTAINING_RECORD(view
, struct wined3d_rendertarget_view_gl
, v
);
1068 HRESULT
wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl
*view_gl
,
1069 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
1070 void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1072 struct wined3d_shader_resource_view_gl
1074 struct wined3d_shader_resource_view v
;
1075 struct wined3d_bo_user bo_user
;
1076 struct wined3d_gl_view gl_view
;
1079 static inline struct wined3d_shader_resource_view_gl
*wined3d_shader_resource_view_gl(
1080 struct wined3d_shader_resource_view
*view
)
1082 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_gl
, v
);
1085 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
*view_gl
, unsigned int unit
,
1086 struct wined3d_sampler_gl
*sampler_gl
, struct wined3d_context_gl
*context_gl
);
1087 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl
*srv_gl
,
1088 struct wined3d_context_gl
*context_gl
);
1089 HRESULT
wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl
*view_gl
,
1090 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
1091 void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1092 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl
*srv_gl
,
1093 struct wined3d_context_gl
*context_gl
);
1095 struct wined3d_unordered_access_view_gl
1097 struct wined3d_unordered_access_view v
;
1098 struct wined3d_bo_user bo_user
;
1099 struct wined3d_gl_view gl_view
;
1100 struct wined3d_bo_gl counter_bo
;
1103 static inline struct wined3d_unordered_access_view_gl
*wined3d_unordered_access_view_gl(
1104 struct wined3d_unordered_access_view
*view
)
1106 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_gl
, v
);
1109 void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view_gl
*view_gl
,
1110 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_gl
*context_gl
, bool fp
);
1111 HRESULT
wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl
*view_gl
,
1112 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
1113 void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1114 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl
*uav_gl
,
1115 struct wined3d_context_gl
*context_gl
);
1117 struct wined3d_swapchain_gl
1119 struct wined3d_swapchain s
;
1122 static inline struct wined3d_swapchain_gl
*wined3d_swapchain_gl(struct wined3d_swapchain
*swapchain
)
1124 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_gl
, s
);
1127 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl
*swapchain_gl
);
1128 struct wined3d_context_gl
*wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl
*swapchain_gl
);
1129 HRESULT
wined3d_swapchain_gl_init(struct wined3d_swapchain_gl
*swapchain_gl
, struct wined3d_device
*device
,
1130 const struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain_state_parent
*state_parent
,
1131 void *parent
, const struct wined3d_parent_ops
*parent_ops
);
1133 #endif /* __WINE_WINED3D_GL */