ReactOS 0.4.17-dev-923-g4c9a150
context_gl.c File Reference
#include "wined3d_private.h"
#include "wined3d_gl.h"
Include dependency graph for context_gl.c:

Go to the source code of this file.

Macros

#define WINED3D_MAX_FBO_ENTRIES   64
 
#define WINED3D_ALL_LAYERS   (~0u)
 

Typedefs

typedef void() context_fbo_entry_func_t(struct wined3d_context_gl *context_gl, struct fbo_entry *entry)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_sync)
 
static GLenum gl_primitive_type_from_d3d (enum wined3d_primitive_type primitive_type)
 
static void wined3d_context_gl_bind_fbo (struct wined3d_context_gl *context_gl, GLenum target, GLuint fbo)
 
static void context_clean_fbo_attachments (const struct wined3d_gl_info *gl_info, GLenum target)
 
static void wined3d_context_gl_destroy_fbo (struct wined3d_context_gl *context_gl, GLuint fbo)
 
static void context_attach_depth_stencil_rb (const struct wined3d_gl_info *gl_info, GLenum fbo_target, uint32_t flags, GLuint rb)
 
static void wined3d_context_gl_attach_gl_texture_fbo (struct wined3d_context_gl *context_gl, GLenum fbo_target, GLenum attachment, const struct wined3d_fbo_resource *resource)
 
static void wined3d_context_gl_attach_depth_stencil_fbo (struct wined3d_context_gl *context_gl, GLenum fbo_target, const struct wined3d_fbo_resource *resource, BOOL rb_namespace, uint32_t flags)
 
static void wined3d_context_gl_attach_surface_fbo (struct wined3d_context_gl *context_gl, GLenum fbo_target, unsigned int idx, const struct wined3d_fbo_resource *resource, BOOL rb_namespace)
 
static void context_dump_fbo_attachment (const struct wined3d_gl_info *gl_info, GLenum target, GLenum attachment)
 
void wined3d_context_gl_check_fbo_status (const struct wined3d_context_gl *context_gl, GLenum target)
 
static DWORD context_generate_rt_mask (GLenum buffer)
 
static DWORD context_generate_rt_mask_from_resource (struct wined3d_resource *resource)
 
static void wined3d_context_gl_set_draw_buffer (struct wined3d_context_gl *context_gl, GLenum buffer)
 
static void wined3d_context_gl_set_fbo_key_for_render_target (const struct wined3d_context_gl *context_gl, struct wined3d_fbo_entry_key *key, unsigned int idx, const struct wined3d_rendertarget_info *render_target, DWORD location)
 
static void wined3d_context_gl_generate_fbo_key (const struct wined3d_context_gl *context_gl, struct wined3d_fbo_entry_key *key, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
static struct fbo_entry * wined3d_context_gl_create_fbo_entry (const struct wined3d_context_gl *context_gl, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
static void wined3d_context_gl_reuse_fbo_entry (struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location, struct fbo_entry *entry)
 
static void wined3d_context_gl_destroy_fbo_entry (struct wined3d_context_gl *context_gl, struct fbo_entry *entry)
 
static struct fbo_entry * wined3d_context_gl_find_fbo_entry (struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
static void wined3d_context_gl_apply_fbo_entry (struct wined3d_context_gl *context_gl, GLenum target, struct fbo_entry *entry)
 
static void wined3d_context_gl_apply_fbo_state (struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
void wined3d_context_gl_apply_fbo_state_explicit (struct wined3d_context_gl *context_gl, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, uint32_t location)
 
void wined3d_context_gl_alloc_occlusion_query (struct wined3d_context_gl *context_gl, struct wined3d_occlusion_query *query)
 
void wined3d_context_gl_free_occlusion_query (struct wined3d_occlusion_query *query)
 
void wined3d_context_gl_alloc_fence (struct wined3d_context_gl *context_gl, struct wined3d_fence *fence)
 
void wined3d_context_gl_free_fence (struct wined3d_fence *fence)
 
void wined3d_context_gl_alloc_timestamp_query (struct wined3d_context_gl *context_gl, struct wined3d_timestamp_query *query)
 
void wined3d_context_gl_free_timestamp_query (struct wined3d_timestamp_query *query)
 
void wined3d_context_gl_alloc_so_statistics_query (struct wined3d_context_gl *context_gl, struct wined3d_so_statistics_query *query)
 
void wined3d_context_gl_free_so_statistics_query (struct wined3d_so_statistics_query *query)
 
void wined3d_context_gl_alloc_pipeline_statistics_query (struct wined3d_context_gl *context_gl, struct wined3d_pipeline_statistics_query *query)
 
void wined3d_context_gl_free_pipeline_statistics_query (struct wined3d_pipeline_statistics_query *query)
 
static void wined3d_context_gl_enum_fbo_entries (const struct wined3d_device *device, GLuint name, BOOL rb_namespace, context_fbo_entry_func_t *callback)
 
static void wined3d_context_gl_queue_fbo_entry_destruction (struct wined3d_context_gl *context_gl, struct fbo_entry *entry)
 
void context_gl_resource_released (struct wined3d_device *device, GLuint name, BOOL rb_namespace)
 
void wined3d_context_gl_texture_update (struct wined3d_context_gl *context_gl, const struct wined3d_texture_gl *texture_gl)
 
static BOOL wined3d_context_gl_restore_pixel_format (struct wined3d_context_gl *context_gl)
 
static BOOL wined3d_context_gl_set_pixel_format (struct wined3d_context_gl *context_gl)
 
static BOOL wined3d_context_gl_set_gl_context (struct wined3d_context_gl *context_gl)
 
static void context_restore_gl_context (const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx)
 
static void wined3d_context_gl_update_window (struct wined3d_context_gl *context_gl)
 
static void wined3d_context_gl_cleanup (struct wined3d_context_gl *context_gl)
 
DWORD context_get_tls_idx (void)
 
void context_set_tls_idx (DWORD idx)
 
struct wined3d_context_gl * wined3d_context_gl_get_current (void)
 
BOOL wined3d_context_gl_set_current (struct wined3d_context_gl *context_gl)
 
void wined3d_context_gl_release (struct wined3d_context_gl *context_gl)
 
static void wined3d_context_gl_enter (struct wined3d_context_gl *context_gl)
 
static int context_choose_pixel_format (const struct wined3d_device *device, HDC hdc, const struct wined3d_format *color_format, const struct wined3d_format *ds_format, bool aux_buffers, bool swap_effect_copy)
 
void wined3d_context_gl_bind_dummy_textures (const struct wined3d_context_gl *context_gl)
 
void wined3d_check_gl_call (const struct wined3d_gl_info *gl_info, const char *file, unsigned int line, const char *name)
 
static BOOL context_debug_output_enabled (const struct wined3d_gl_info *gl_info)
 
static void WINE_GLAPI wined3d_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, void *ctx)
 
HGLRC context_create_wgl_attribs (const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx)
 
static BOOL wined3d_context_gl_create_wgl_ctx (struct wined3d_context_gl *context_gl, struct wined3d_swapchain_gl *swapchain_gl, BOOL *new_drawable)
 
HRESULT wined3d_context_gl_init (struct wined3d_context_gl *context_gl, struct wined3d_swapchain_gl *swapchain_gl)
 
void wined3d_context_gl_destroy (struct wined3d_context_gl *context_gl)
 
const unsigned int * wined3d_context_gl_get_tex_unit_mapping (const struct wined3d_context_gl *context_gl, const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count)
 
static void wined3d_context_gl_get_rt_size (const struct wined3d_context_gl *context_gl, SIZE *size)
 
void wined3d_context_gl_enable_clip_distances (struct wined3d_context_gl *context_gl, uint32_t enable_mask)
 
static BOOL is_rt_mask_onscreen (DWORD rt_mask)
 
static GLenum draw_buffer_from_rt_mask (DWORD rt_mask)
 
static void wined3d_context_gl_apply_draw_buffers (struct wined3d_context_gl *context_gl, uint32_t rt_mask)
 
void wined3d_context_gl_active_texture (struct wined3d_context_gl *context_gl, const struct wined3d_gl_info *gl_info, unsigned int unit)
 
void wined3d_context_gl_bind_bo (struct wined3d_context_gl *context_gl, GLenum binding, GLuint name)
 
void wined3d_context_gl_bind_texture (struct wined3d_context_gl *context_gl, GLenum target, GLuint name)
 
static void wined3d_context_gl_poll_fences (struct wined3d_context_gl *context_gl)
 
static void wined3d_device_gl_free_memory (struct wined3d_device_gl *device_gl, struct wined3d_allocator_block *block)
 
static void wined3d_context_gl_cleanup_resources (struct wined3d_context_gl *context_gl)
 
void wined3d_context_gl_wait_command_fence (struct wined3d_context_gl *context_gl, uint64_t id)
 
void wined3d_context_gl_submit_command_fence (struct wined3d_context_gl *context_gl)
 
static void wined3d_context_gl_destroy_allocator_block (struct wined3d_context_gl *context_gl, struct wined3d_allocator_block *block, uint64_t fence_id)
 
GLuint wined3d_context_gl_allocate_vram_chunk_buffer (struct wined3d_context_gl *context_gl, unsigned int pool, size_t size)
 
static void * wined3d_allocator_chunk_gl_map (struct wined3d_allocator_chunk_gl *chunk_gl, struct wined3d_context_gl *context_gl)
 
static void wined3d_allocator_chunk_gl_unmap (struct wined3d_allocator_chunk_gl *chunk_gl, struct wined3d_context_gl *context_gl)
 
static void * wined3d_bo_gl_map (struct wined3d_bo_gl *bo, struct wined3d_context_gl *context_gl, uint32_t flags)
 
static void wined3d_bo_gl_unmap (struct wined3d_bo_gl *bo, struct wined3d_context_gl *context_gl)
 
void * wined3d_context_gl_map_bo_address (struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, size_t size, uint32_t flags)
 
static void flush_bo_ranges (struct wined3d_context_gl *context_gl, const struct wined3d_const_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
 
void wined3d_context_gl_unmap_bo_address (struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
 
void wined3d_context_gl_flush_bo_address (struct wined3d_context_gl *context_gl, const struct wined3d_const_bo_address *data, size_t size)
 
void wined3d_context_gl_copy_bo_address (struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags)
 
void wined3d_context_gl_destroy_bo (struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo)
 
GLenum wined3d_context_gl_get_offscreen_gl_buffer (const struct wined3d_context_gl *context_gl)
 
static uint32_t wined3d_context_gl_generate_rt_mask_no_fbo (const struct wined3d_context_gl *context_gl, struct wined3d_resource *rt)
 
void wined3d_context_gl_apply_blit_state (struct wined3d_context_gl *context_gl, const struct wined3d_device *device)
 
static BOOL have_framebuffer_attachment (unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
 
BOOL wined3d_context_gl_apply_clear_state (struct wined3d_context_gl *context_gl, const struct wined3d_state *state, unsigned int rt_count, const struct wined3d_fb_state *fb)
 
static uint32_t find_draw_buffers_mask (const struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
void context_gl_apply_texture_draw_state (struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx, unsigned int location)
 
void context_state_fb (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void wined3d_context_gl_map_stage (struct wined3d_context_gl *context_gl, unsigned int stage, unsigned int unit)
 
static void context_invalidate_texture_stage (struct wined3d_context *context, DWORD stage)
 
static bool use_ffp_ps (const struct wined3d_state *state)
 
static void context_update_fixed_function_usage_map (struct wined3d_context *context, const struct wined3d_state *state)
 
static void wined3d_context_gl_map_fixed_function_samplers (struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
static void wined3d_context_gl_map_psamplers (struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
static BOOL wined3d_context_gl_unit_free_for_vs (const struct wined3d_context_gl *context_gl, const struct wined3d_shader_resource_info *ps_resource_info, unsigned int unit)
 
static void wined3d_context_gl_map_vsamplers (struct wined3d_context_gl *context_gl, BOOL ps, const struct wined3d_state *state)
 
static void wined3d_context_gl_update_tex_unit_map (struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
void context_state_drawbuf (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void wined3d_context_gl_bind_shader_resources (struct wined3d_context_gl *context_gl, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
 
static void wined3d_context_gl_bind_unordered_access_views (struct wined3d_context_gl *context_gl, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
 
static bool is_resource_rtv_bound (const struct wined3d_state *state, const struct wined3d_resource *resource)
 
static void context_gl_load_shader_resources (struct wined3d_context_gl *context_gl, const struct wined3d_state *state, unsigned int shader_mask)
 
static void context_gl_load_unordered_access_resources (struct wined3d_context_gl *context_gl, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
 
static void context_gl_load_stream_output_buffers (struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
static BOOL context_apply_draw_state (struct wined3d_context *context, const struct wined3d_device *device, const struct wined3d_state *state, BOOL indexed)
 
static void wined3d_context_gl_apply_compute_state (struct wined3d_context_gl *context_gl, const struct wined3d_device *device, const struct wined3d_state *state)
 
void wined3d_context_gl_end_transform_feedback (struct wined3d_context_gl *context_gl)
 
static void wined3d_context_gl_pause_transform_feedback (struct wined3d_context_gl *context_gl, BOOL force)
 
static void wined3d_context_gl_setup_target (struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
static void wined3d_context_gl_activate (struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
struct wined3d_context * wined3d_context_gl_acquire (const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
struct wined3d_context_gl * wined3d_context_gl_reacquire (struct wined3d_context_gl *context_gl)
 
void dispatch_compute (struct wined3d_device *device, const struct wined3d_state *state, const struct wined3d_dispatch_parameters *parameters)
 
static void wined3d_context_gl_draw_primitive_arrays (struct wined3d_context_gl *context_gl, const struct wined3d_state *state, const void *idx_data, unsigned int idx_size, int base_vertex_idx, unsigned int start_idx, unsigned int count, unsigned int start_instance, unsigned int instance_count)
 
static void wined3d_context_gl_draw_indirect (struct wined3d_context_gl *context_gl, const struct wined3d_state *state, const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size)
 
static GLenum gl_tfb_primitive_type_from_d3d (enum wined3d_primitive_type primitive_type)
 
void draw_primitive (struct wined3d_device *device, const struct wined3d_state *state, const struct wined3d_draw_parameters *parameters)
 
static const void * get_vertex_attrib_pointer (const struct wined3d_stream_info_element *element, const struct wined3d_state *state)
 
static void wined3d_context_gl_unload_numbered_array (struct wined3d_context_gl *context_gl, unsigned int i)
 
static void wined3d_context_gl_unload_numbered_arrays (struct wined3d_context_gl *context_gl)
 
static void wined3d_context_gl_load_numbered_arrays (struct wined3d_context_gl *context_gl, const struct wined3d_stream_info *stream_info, const struct wined3d_state *state)
 
void wined3d_context_gl_update_stream_sources (struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
 
static void apply_texture_blit_state (const struct wined3d_gl_info *gl_info, struct gl_texture *texture, GLenum target, unsigned int level, enum wined3d_texture_filter_type filter)
 
void wined3d_context_gl_draw_shaded_quad (struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
 

Variables

static DWORD wined3d_context_tls_idx
 

Macro Definition Documentation

◆ WINED3D_ALL_LAYERS

#define WINED3D_ALL_LAYERS   (~0u)

Definition at line 35 of file context_gl.c.

◆ WINED3D_MAX_FBO_ENTRIES

#define WINED3D_MAX_FBO_ENTRIES   64

Definition at line 34 of file context_gl.c.

Typedef Documentation

◆ context_fbo_entry_func_t

typedef void() context_fbo_entry_func_t(struct wined3d_context_gl *context_gl, struct fbo_entry *entry)

Definition at line 1102 of file context_gl.c.

Function Documentation

◆ apply_texture_blit_state()

static void apply_texture_blit_state ( const struct wined3d_gl_info *  gl_info,
struct gl_texture *  texture,
GLenum  target,
unsigned int  level,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 5101 of file context_gl.c.

5103{
5104 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(filter));
5105 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
5107 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
5108 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
5109 if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
5110 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
5111 gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, level);
5112
5113 /* We changed the filtering settings on the texture. Make sure they get
5114 * reset on subsequent draws. */
5115 texture->sampler_desc.mag_filter = WINED3D_TEXF_POINT;
5116 texture->sampler_desc.min_filter = WINED3D_TEXF_POINT;
5117 texture->sampler_desc.mip_filter = WINED3D_TEXF_NONE;
5118 texture->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP;
5119 texture->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP;
5120 texture->sampler_desc.srgb_decode = FALSE;
5121 texture->sampler_desc.mip_base_level = level;
5122}
#define FALSE
Definition: types.h:117
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
GLint level
Definition: gl.h:1546
#define GL_TEXTURE_BASE_LEVEL
Definition: gl.h:1503
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
Definition: filter.c:165
Definition: tools.h:99
BOOL supported[WINED3D_GL_EXT_COUNT]
Definition: wined3d_gl.h:347
struct opengl_funcs gl_ops
Definition: wined3d_gl.h:353
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
@ WINED3D_TADDRESS_CLAMP
Definition: wined3d.h:660
@ EXT_TEXTURE_SRGB_DECODE
Definition: wined3d_gl.h:203
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
Definition: wined3d_gl.h:377
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
Definition: wined3d_gl.h:382

Referenced by wined3d_context_gl_draw_shaded_quad().

◆ context_apply_draw_state()

static BOOL context_apply_draw_state ( struct wined3d_context *  context,
const struct wined3d_device *  device,
const struct wined3d_state *  state,
BOOL  indexed 
)
static

Definition at line 4039 of file context_gl.c.

4041{
4042 const struct wined3d_state_entry *state_table = context->state_table;
4043 struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
4044 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4045 const struct wined3d_fb_state *fb = &state->fb;
4046 unsigned int i, base;
4047 uint32_t map;
4048
4049 context->uses_fbo_attached_resources = 0;
4050
4051 if (!have_framebuffer_attachment(gl_info->limits.buffers, fb->render_targets, fb->depth_stencil))
4052 {
4054 {
4055 FIXME("OpenGL implementation does not support framebuffers with no attachments.\n");
4056 return FALSE;
4057 }
4058 }
4059
4060 /* Preload resources before FBO setup. Texture preload in particular may
4061 * result in changes to the current FBO, due to using e.g. FBO blits for
4062 * updating a resource location. */
4066 state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
4068 /* TODO: Right now the dependency on the vertex shader is necessary
4069 * since wined3d_stream_info_from_declaration() depends on the reg_maps of
4070 * the current VS but maybe it's possible to relax the coupling in some
4071 * situations at least. */
4074 {
4076 }
4077
4078 map = context->stream_info.use_map;
4079 while (map)
4080 {
4081 const struct wined3d_stream_info_element *e;
4082 struct wined3d_buffer *buffer;
4083
4084 e = &context->stream_info.elements[wined3d_bit_scan(&map)];
4085 buffer = state->streams[e->stream_idx].buffer;
4086
4087 if (!buffer->bo_user.valid)
4089 else
4091 }
4092 /* Loading the buffers above may have invalidated the stream info. */
4095
4096 map = context->stream_info.use_map;
4097 while (map)
4098 {
4099 const struct wined3d_stream_info_element *e;
4100 struct wined3d_buffer *buffer;
4101
4102 e = &context->stream_info.elements[wined3d_bit_scan(&map)];
4103 buffer = state->streams[e->stream_idx].buffer;
4104
4106 }
4107
4108 if (indexed && state->index_buffer)
4109 {
4110 struct wined3d_buffer *buffer = state->index_buffer;
4111
4112 if (context->stream_info.all_vbo)
4113 {
4115 if (!buffer->bo_user.valid)
4118 }
4119 else
4120 {
4122 }
4123 }
4124
4125 for (i = 0, base = 0; i < ARRAY_SIZE(context->dirty_graphics_states); ++i)
4126 {
4127 uint32_t dirty_mask = context->dirty_graphics_states[i];
4128
4129 while (dirty_mask)
4130 {
4131 unsigned int state_id = base + wined3d_bit_scan(&dirty_mask);
4132
4133 state_table[state_id].apply(context, state, state_id);
4134 }
4135 base += sizeof(dirty_mask) * CHAR_BIT;
4136 }
4137
4138 memset(context->dirty_graphics_states, 0, sizeof(context->dirty_graphics_states));
4139
4140 if (context->update_shader_resource_bindings)
4141 {
4142 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
4144 context->update_shader_resource_bindings = 0;
4145 if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4146 context->update_compute_shader_resource_bindings = 1;
4147 }
4148
4149 if (context->update_unordered_access_view_bindings)
4150 {
4153 state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
4154 context->update_unordered_access_view_bindings = 0;
4155 context->update_compute_unordered_access_view_bindings = 1;
4156 }
4157
4159
4160 device->shader_backend->shader_apply_draw_state(device->shader_priv, context, state);
4161 context->shader_update_mask &= 1u << WINED3D_SHADER_TYPE_COMPUTE;
4162 context->constant_update_mask = 0;
4163
4164 context->last_was_blit = FALSE;
4165 context->last_was_ffp_blit = FALSE;
4166
4167 return TRUE;
4168}
static int state
Definition: maze.c:121
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
Definition: _map.h:48
static void context_gl_load_unordered_access_resources(struct wined3d_context_gl *context_gl, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context_gl.c:3975
static void wined3d_context_gl_bind_unordered_access_views(struct wined3d_context_gl *context_gl, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context_gl.c:3819
static void context_gl_load_stream_output_buffers(struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
Definition: context_gl.c:4017
static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
Definition: context_gl.c:3232
static void wined3d_context_gl_update_tex_unit_map(struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
Definition: context_gl.c:3694
static void wined3d_context_gl_bind_shader_resources(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
Definition: context_gl.c:3738
void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target)
Definition: context_gl.c:419
static void context_gl_load_shader_resources(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, unsigned int shader_mask)
Definition: context_gl.c:3891
#define TRUE
Definition: types.h:120
UINT32 uint32_t
Definition: types.h:75
static const struct @282 state_table[]
void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state)
Definition: buffer.c:484
void * wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:362
void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:258
void device_invalidate_state(const struct wined3d_device *device, unsigned int state_id)
Definition: device.c:5565
#define CHAR_BIT
Definition: cabinet.h:45
GLuint buffer
Definition: glext.h:5915
#define GL_FRAMEBUFFER
Definition: glext.h:1732
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define e
Definition: ke_i.h:82
#define memset(x, y, z)
Definition: compat.h:39
Definition: http.c:7252
Definition: devices.h:37
const struct wined3d_gl_info * gl_info
Definition: wined3d_gl.h:603
struct wined3d_rendertarget_view * depth_stencil
struct wined3d_rendertarget_view * render_targets[WINED3D_MAX_RENDER_TARGETS]
struct wined3d_gl_limits limits
Definition: wined3d_gl.h:344
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982
@ WINED3D_PIPELINE_GRAPHICS
Definition: wined3d.h:855
@ WINED3D_SHADER_TYPE_PIXEL
Definition: wined3d.h:841
@ WINED3D_SHADER_TYPE_GRAPHICS_COUNT
Definition: wined3d.h:846
@ WINED3D_SHADER_TYPE_COMPUTE
Definition: wined3d.h:848
@ WINED3D_SHADER_TYPE_VERTEX
Definition: wined3d.h:842
@ ARB_FRAMEBUFFER_NO_ATTACHMENTS
Definition: wined3d_gl.h:83
static void wined3d_context_gl_reference_buffer(struct wined3d_context_gl *context_gl, struct wined3d_buffer *buffer)
Definition: wined3d_gl.h:919
static bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context *context, unsigned int state_id)
static bool isStateDirty(const struct wined3d_context *context, unsigned int state_id)
#define STATE_SHADER(a)
#define STATE_STREAMSRC
#define STATE_INDEXBUFFER
#define STATE_VDECL

Referenced by draw_primitive().

◆ context_attach_depth_stencil_rb()

static void context_attach_depth_stencil_rb ( const struct wined3d_gl_info *  gl_info,
GLenum  fbo_target,
uint32_t  flags,
GLuint  rb 
)
static

Definition at line 155 of file context_gl.c.

157{
159 {
160 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
161 checkGLcall("glFramebufferRenderbuffer()");
162 }
163
165 {
166 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
167 checkGLcall("glFramebufferRenderbuffer()");
168 }
169}
#define GL_RENDERBUFFER
Definition: glext.h:1733
GLbitfield flags
Definition: glext.h:7161
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
struct wined3d_fbo_ops fbo_ops
Definition: wined3d_gl.h:354
#define WINED3D_FBO_ENTRY_FLAG_STENCIL
Definition: wined3d_gl.h:584
#define WINED3D_FBO_ENTRY_FLAG_DEPTH
Definition: wined3d_gl.h:583
#define checkGLcall(A)
Definition: wined3d_gl.h:402

Referenced by wined3d_context_gl_attach_depth_stencil_fbo().

◆ context_choose_pixel_format()

static int context_choose_pixel_format ( const struct wined3d_device *  device,
HDC  hdc,
const struct wined3d_format *  color_format,
const struct wined3d_format *  ds_format,
bool  aux_buffers,
bool  swap_effect_copy 
)
static

Definition at line 1691 of file context_gl.c.

1694{
1695 unsigned int cfg_count = wined3d_adapter_gl(device->adapter)->pixel_format_count;
1696 unsigned int current_value;
1698 int iPixelFormat = 0;
1699 unsigned int i;
1700
1701 TRACE("device %p, dc %p, color_format %s, ds_format %s, aux_buffers %#x, swap_effect_copy %#x.\n",
1702 device, hdc, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id),
1703 aux_buffers, swap_effect_copy);
1704
1705 current_value = 0;
1706 for (i = 0; i < cfg_count; ++i)
1707 {
1708 const struct wined3d_pixel_format *cfg = &wined3d_adapter_gl(device->adapter)->pixel_formats[i];
1709 unsigned int value;
1710
1711 /* For now only accept RGBA formats. Perhaps some day we will
1712 * allow floating point formats for pbuffers. */
1713 if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
1714 continue;
1715 /* In window mode we need a window drawable format and double buffering. */
1716 if (!(cfg->windowDrawable && cfg->doubleBuffer))
1717 continue;
1718 if (cfg->redSize < color_format->red_size)
1719 continue;
1720 if (cfg->greenSize < color_format->green_size)
1721 continue;
1722 if (cfg->blueSize < color_format->blue_size)
1723 continue;
1724 if (cfg->alphaSize < color_format->alpha_size)
1725 continue;
1726 if (cfg->depthSize < ds_format->depth_size)
1727 continue;
1728 if (ds_format->stencil_size && cfg->stencilSize != ds_format->stencil_size)
1729 continue;
1730 /* Check multisampling support. */
1731 if (cfg->numSamples)
1732 continue;
1733
1734 value = 1;
1735 if (swap_effect_copy && cfg->swap_method == WGL_SWAP_COPY_ARB)
1736 value += 1;
1737 /* We try to locate a format which matches our requirements exactly. In case of
1738 * depth it is no problem to emulate 16-bit using e.g. 24-bit, so accept that. */
1739 if (cfg->depthSize == ds_format->depth_size)
1740 value += 2;
1741 if (cfg->stencilSize == ds_format->stencil_size)
1742 value += 4;
1743 if (cfg->alphaSize == color_format->alpha_size)
1744 value += 8;
1745 /* We like to have aux buffers in backbuffer mode */
1746 if (aux_buffers && cfg->auxBuffers)
1747 value += 16;
1748 if (cfg->redSize == color_format->red_size
1749 && cfg->greenSize == color_format->green_size
1750 && cfg->blueSize == color_format->blue_size)
1751 value += 32;
1752
1753 if (value > current_value)
1754 {
1756 current_value = value;
1757 }
1758 }
1759
1760 if (!iPixelFormat)
1761 {
1762 ERR("Trying to locate a compatible pixel format because an exact match failed.\n");
1763
1764 memset(&pfd, 0, sizeof(pfd));
1765 pfd.nSize = sizeof(pfd);
1766 pfd.nVersion = 1;
1767 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/
1769 pfd.cAlphaBits = color_format->alpha_size;
1770 pfd.cColorBits = color_format->red_size + color_format->green_size
1771 + color_format->blue_size + color_format->alpha_size;
1772 pfd.cDepthBits = ds_format->depth_size;
1773 pfd.cStencilBits = ds_format->stencil_size;
1775
1777 {
1778 /* Something is very wrong as ChoosePixelFormat() barely fails. */
1779 ERR("Can't find a suitable pixel format.\n");
1780 return 0;
1781 }
1782 }
1783
1784 TRACE("Found iPixelFormat=%d for ColorFormat=%s, DepthStencilFormat=%s.\n",
1785 iPixelFormat, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id));
1786 return iPixelFormat;
1787}
#define ERR(fmt,...)
Definition: precomp.h:57
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
HDC hdc
Definition: main.c:9
#define TRACE(s)
Definition: solgame.cpp:4
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
struct wined3d_pixel_format * pixel_formats
Definition: wined3d_gl.h:802
unsigned int pixel_format_count
Definition: wined3d_gl.h:803
enum wined3d_format_id id
Definition: pdh_main.c:64
#define WGL_TYPE_RGBA_ARB
Definition: wgl.h:5231
#define WGL_SWAP_COPY_ARB
Definition: wgl.h:5200
_In_ LONG iPixelFormat
Definition: winddi.h:3488
int WINAPI ChoosePixelFormat(_In_ HDC hdc, _In_ const PIXELFORMATDESCRIPTOR *ppfd)
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:306
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:303
#define PFD_MAIN_PLANE
Definition: wingdi.h:298
#define PFD_TYPE_RGBA
Definition: wingdi.h:296
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:301

Referenced by wined3d_context_gl_create_wgl_ctx().

◆ context_clean_fbo_attachments()

static void context_clean_fbo_attachments ( const struct wined3d_gl_info *  gl_info,
GLenum  target 
)
static

Definition at line 126 of file context_gl.c.

127{
128 unsigned int i;
129
130 for (i = 0; i < gl_info->limits.buffers; ++i)
131 {
132 gl_info->fbo_ops.glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, 0, 0);
133 checkGLcall("glFramebufferTexture2D()");
134 }
135 gl_info->fbo_ops.glFramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
136 checkGLcall("glFramebufferTexture2D()");
137
138 gl_info->fbo_ops.glFramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
139 checkGLcall("glFramebufferTexture2D()");
140}
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714

Referenced by wined3d_context_gl_destroy_fbo(), and wined3d_context_gl_reuse_fbo_entry().

◆ context_create_wgl_attribs()

HGLRC context_create_wgl_attribs ( const struct wined3d_gl_info *  gl_info,
HDC  hdc,
HGLRC  share_ctx 
)

Definition at line 1881 of file context_gl.c.

1882{
1883 HGLRC ctx;
1884 unsigned int ctx_attrib_idx = 0;
1885 GLint ctx_attribs[7], ctx_flags = 0;
1886
1887 if (context_debug_output_enabled(gl_info))
1888 ctx_flags = WGL_CONTEXT_DEBUG_BIT_ARB;
1889 ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
1890 ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version >> 16;
1891 ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MINOR_VERSION_ARB;
1892 ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version & 0xffff;
1893 if (ctx_flags)
1894 {
1895 ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_FLAGS_ARB;
1896 ctx_attribs[ctx_attrib_idx++] = ctx_flags;
1897 }
1898 ctx_attribs[ctx_attrib_idx] = 0;
1899
1900 if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
1901 {
1902 if (gl_info->selected_gl_version >= MAKEDWORD_VERSION(3, 2))
1903 {
1904 if (ctx_flags)
1905 {
1907 ctx_attribs[ctx_attrib_idx - 1] = ctx_flags;
1908 }
1909 else
1910 {
1912 ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_FLAGS_ARB;
1913 ctx_attribs[ctx_attrib_idx++] = ctx_flags;
1914 ctx_attribs[ctx_attrib_idx] = 0;
1915 }
1916 if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
1917 WARN("Failed to create a WGL context with wglCreateContextAttribsARB, last error %#lx.\n",
1918 GetLastError());
1919 }
1920 }
1921 return ctx;
1922}
#define WARN(fmt,...)
Definition: precomp.h:61
static BOOL context_debug_output_enabled(const struct wined3d_gl_info *gl_info)
Definition: context_gl.c:1850
int GLint
Definition: gl.h:156
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
unsigned int selected_gl_version
Definition: wined3d_gl.h:342
#define WGL_CONTEXT_MINOR_VERSION_ARB
Definition: wgl.h:5140
#define WGL_CONTEXT_MAJOR_VERSION_ARB
Definition: wgl.h:5139
#define WGL_CONTEXT_DEBUG_BIT_ARB
Definition: wgl.h:5134
#define WGL_CONTEXT_FLAGS_ARB
Definition: wgl.h:5136
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
Definition: wgl.h:5137
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MAKEDWORD_VERSION(maj, min)

Referenced by wined3d_caps_gl_ctx_create_attribs(), and wined3d_context_gl_create_wgl_ctx().

◆ context_debug_output_enabled()

static BOOL context_debug_output_enabled ( const struct wined3d_gl_info *  gl_info)
static

Definition at line 1850 of file context_gl.c.

1851{
1852 return gl_info->supported[ARB_DEBUG_OUTPUT]
1853 && (ERR_ON(d3d) || FIXME_ON(d3d) || WARN_ON(d3d_perf));
1854}
#define WARN_ON(c)
Definition: module.h:257
#define FIXME_ON(ch)
Definition: debug.h:418
#define ERR_ON(ch)
Definition: debug.h:423
@ ARB_DEBUG_OUTPUT
Definition: wined3d_gl.h:65

Referenced by context_create_wgl_attribs(), and wined3d_context_gl_init().

◆ context_dump_fbo_attachment()

static void context_dump_fbo_attachment ( const struct wined3d_gl_info *  gl_info,
GLenum  target,
GLenum  attachment 
)
static

Definition at line 283 of file context_gl.c.

285{
286 static const struct
287 {
290 const char *str;
291 enum wined3d_gl_extension extension;
292 }
293 texture_type[] =
294 {
302 };
303
304 GLint type, name, samples, width, height, old_texture, level, face, fmt, tex_target;
305 const char *tex_type_str = NULL;
306 unsigned int i;
307
308 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
310 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
312
313 if (type == GL_RENDERBUFFER)
314 {
315 gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, name);
316 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
317 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
318 if (gl_info->limits.samples > 1)
319 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
320 else
321 samples = 1;
322 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT, &fmt);
323 FIXME(" %s: renderbuffer %d, %dx%d, %d samples, format %#x.\n",
325 }
326 else if (type == GL_TEXTURE)
327 {
328 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
330 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
332
333 if (gl_info->gl_ops.ext.p_glGetTextureParameteriv)
334 {
335 GL_EXTCALL(glGetTextureParameteriv(name, GL_TEXTURE_TARGET, &tex_target));
336
337 for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
338 {
339 if (texture_type[i].target == tex_target)
340 {
341 tex_type_str = texture_type[i].str;
342 break;
343 }
344 }
345 if (i == ARRAY_SIZE(texture_type))
346 tex_type_str = wine_dbg_sprintf("%#x", tex_target);
347 }
348 else if (face)
349 {
350 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &old_texture);
351 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, name);
352
353 tex_target = GL_TEXTURE_CUBE_MAP;
354 tex_type_str = "cube";
355 }
356 else
357 {
358 for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
359 {
360 if (!gl_info->supported[texture_type[i].extension])
361 continue;
362
363 gl_info->gl_ops.gl.p_glGetIntegerv(texture_type[i].binding, &old_texture);
364 while (gl_info->gl_ops.gl.p_glGetError());
365
366 gl_info->gl_ops.gl.p_glBindTexture(texture_type[i].target, name);
367 if (!gl_info->gl_ops.gl.p_glGetError())
368 {
369 tex_target = texture_type[i].target;
370 tex_type_str = texture_type[i].str;
371 break;
372 }
373 gl_info->gl_ops.gl.p_glBindTexture(texture_type[i].target, old_texture);
374 }
375
376 if (!tex_type_str)
377 {
378 FIXME("Cannot find type of texture %d.\n", name);
379 return;
380 }
381 }
382
383 if (gl_info->gl_ops.ext.p_glGetTextureParameteriv)
384 {
385 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_INTERNAL_FORMAT, &fmt));
386 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_WIDTH, &width));
387 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_HEIGHT, &height));
388 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_SAMPLES, &samples));
389 }
390 else
391 {
392 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
393 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_WIDTH, &width);
394 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_HEIGHT, &height);
396 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_SAMPLES, &samples);
397 else
398 samples = 1;
399
400 gl_info->gl_ops.gl.p_glBindTexture(tex_target, old_texture);
401 }
402
403 FIXME(" %s: %s texture %d, %dx%d, %d samples, format %#x.\n",
405 }
406 else if (type == GL_NONE)
407 {
408 FIXME(" %s: NONE.\n", debug_fboattachment(attachment));
409 }
410 else
411 {
412 ERR(" %s: Unknown attachment %#x.\n", debug_fboattachment(attachment), type);
413 }
414
415 checkGLcall("dump FBO attachment");
416}
#define NULL
Definition: types.h:112
WORD face[3]
Definition: mesh.c:4854
const char * debug_fboattachment(GLenum attachment)
Definition: utils.c:5394
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
#define GL_NONE
Definition: gl.h:465
#define GL_TEXTURE_WIDTH
Definition: gl.h:657
#define GL_TEXTURE
Definition: gl.h:247
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_HEIGHT
Definition: gl.h:658
#define GL_TEXTURE_INTERNAL_FORMAT
Definition: gl.h:732
#define GL_TEXTURE_BINDING_CUBE_MAP
Definition: gl.h:1789
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_TEXTURE_BINDING_2D
Definition: gl.h:731
#define GL_TEXTURE_BINDING_1D
Definition: gl.h:730
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
Definition: glext.h:1704
#define GL_RENDERBUFFER_SAMPLES
Definition: glext.h:1701
#define GL_TEXTURE_BINDING_1D_ARRAY
Definition: glext.h:537
GLsizei samples
Definition: glext.h:7006
#define GL_RENDERBUFFER_WIDTH
Definition: glext.h:1734
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
Definition: glext.h:1703
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define GL_RENDERBUFFER_HEIGHT
Definition: glext.h:1735
#define GL_TEXTURE_BINDING_2D_ARRAY
Definition: glext.h:538
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_SAMPLES
Definition: glext.h:1945
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
Definition: glext.h:1705
#define GL_RENDERBUFFER_INTERNAL_FORMAT
Definition: glext.h:1736
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE
Definition: glext.h:1943
GLenum attachment
Definition: glext.h:6295
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
Definition: glext.h:1702
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1944
static RPC_BINDING_HANDLE binding
Definition: server.c:166
const WCHAR * str
Definition: dsound.c:943
Definition: name.c:39
#define GL_TEXTURE_TARGET
Definition: wgl.h:4517
wined3d_gl_extension
Definition: wined3d_gl.h:42
@ ARB_TEXTURE_CUBE_MAP
Definition: wined3d_gl.h:130
@ WINED3D_GL_EXT_NONE
Definition: wined3d_gl.h:43
@ ARB_TEXTURE_MULTISAMPLE
Definition: wined3d_gl.h:139
@ EXT_TEXTURE_ARRAY
Definition: wined3d_gl.h:191
#define GL_EXTCALL(f)
Definition: wined3d_gl.h:360

Referenced by wined3d_context_gl_check_fbo_status().

◆ context_generate_rt_mask()

static DWORD context_generate_rt_mask ( GLenum  buffer)
inlinestatic

Definition at line 452 of file context_gl.c.

453{
454 /* Should take care of all the GL_FRONT/GL_BACK/GL_AUXi/GL_NONE... cases */
455 return buffer ? (1u << 31) | buffer : 0;
456}

Referenced by wined3d_context_gl_create_fbo_entry(), wined3d_context_gl_generate_rt_mask_no_fbo(), wined3d_context_gl_init(), and wined3d_context_gl_set_draw_buffer().

◆ context_generate_rt_mask_from_resource()

static DWORD context_generate_rt_mask_from_resource ( struct wined3d_resource *  resource)
inlinestatic

Definition at line 458 of file context_gl.c.

459{
461 {
462 FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
463 return 0;
464 }
465
467}
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:113
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4992
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)

Referenced by context_gl_apply_texture_draw_state(), wined3d_context_gl_apply_clear_state(), and wined3d_context_gl_generate_rt_mask_no_fbo().

◆ context_get_tls_idx()

DWORD context_get_tls_idx ( void  )

Definition at line 1556 of file context_gl.c.

1557{
1559}
static DWORD wined3d_context_tls_idx
Definition: context_gl.c:37

Referenced by wined3d_context_gl_destroy(), and wined3d_dll_destroy().

◆ context_gl_apply_texture_draw_state()

void context_gl_apply_texture_draw_state ( struct wined3d_context_gl *  context_gl,
struct wined3d_texture *  texture,
unsigned int  sub_resource_idx,
unsigned int  location 
)

Definition at line 3384 of file context_gl.c.

3386{
3387 const struct wined3d_format *format = texture->resource.format;
3388 struct wined3d_context *context = &context_gl->c;
3389 uint32_t rt_mask, *cur_mask;
3390
3391 TRACE("context_gl %p, texture %p, sub_resource_idx %u, location %s.\n",
3393
3394 if (format->depth_size || format->stencil_size)
3396 0, &texture->resource, sub_resource_idx, location);
3397 else
3400
3402 {
3403 if (texture->resource.format->id == WINED3DFMT_NULL || format->depth_size || format->stencil_size)
3404 rt_mask = 0;
3405 else
3406 rt_mask = 1;
3407 }
3408 else
3409 {
3410 rt_mask = context_generate_rt_mask_from_resource(&texture->resource);
3411 }
3412
3413 cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask;
3414 if (rt_mask != *cur_mask)
3415 {
3416 wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask);
3417 *cur_mask = rt_mask;
3418 }
3419
3421
3423}
static void wined3d_context_gl_apply_draw_buffers(struct wined3d_context_gl *context_gl, uint32_t rt_mask)
Definition: context_gl.c:2447
void wined3d_context_gl_apply_fbo_state_explicit(struct wined3d_context_gl *context_gl, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, uint32_t location)
Definition: context_gl.c:852
static DWORD context_generate_rt_mask_from_resource(struct wined3d_resource *resource)
Definition: context_gl.c:458
void context_invalidate_state(struct wined3d_context *context, unsigned int state_id)
Definition: context.c:76
const char * wined3d_debug_location(uint32_t location)
Definition: utils.c:6588
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
struct fbo_entry * current_fbo
Definition: wined3d_gl.h:641
struct wined3d_context c
Definition: wined3d_gl.h:601
uint32_t draw_buffers_mask
Definition: wined3d_gl.h:645
unsigned int sub_resource_idx
@ WINED3DFMT_NULL
Definition: wined3d.h:276
#define WINED3D_LOCATION_DRAWABLE
#define STATE_FRAMEBUFFER

Referenced by glsl_blitter_blit(), texture2d_blt_fbo(), texture2d_depth_blt_fbo(), and wined3d_texture_gl_clear().

◆ context_gl_load_shader_resources()

static void context_gl_load_shader_resources ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state,
unsigned int  shader_mask 
)
static

Definition at line 3891 of file context_gl.c.

3893{
3895 struct wined3d_shader_resource_view_gl *srv_gl;
3897 struct wined3d_sampler *sampler;
3898 struct wined3d_shader *shader;
3899 struct wined3d_buffer *buffer;
3900 unsigned int i, j;
3901
3902 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3903 {
3904 if (!(shader_mask & (1u << i)))
3905 continue;
3906
3907 if (!(shader = state->shader[i]))
3908 {
3910 {
3911 uint32_t ffu_map = context_gl->c.fixed_function_usage_map;
3912
3913 while (ffu_map)
3914 {
3915 i = wined3d_bit_scan(&ffu_map);
3916
3917 view = state->shader_resource_view[WINED3D_SHADER_TYPE_PIXEL][i];
3919
3920 if (view)
3922 &context_gl->c, sampler->desc.srgb_decode);
3923 }
3924 }
3925
3926 continue;
3927 }
3928
3929 for (j = 0; j < WINED3D_MAX_CBS; ++j)
3930 {
3931 if (!state->cb[i][j].buffer)
3932 continue;
3933
3934 buffer = state->cb[i][j].buffer;
3935 wined3d_buffer_load(buffer, &context_gl->c, state);
3937 if (!buffer->bo_user.valid)
3938 device_invalidate_state(context_gl->c.device, STATE_CONSTANT_BUFFER(i));
3939 }
3940
3941 for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
3942 {
3943 entry = &shader->reg_maps.sampler_map.entries[j];
3944
3945 if (!(view = state->shader_resource_view[i][entry->resource_idx]))
3946 continue;
3947
3948 if (is_resource_rtv_bound(state, view->resource))
3949 context_gl->c.uses_fbo_attached_resources = 1;
3950
3951 if (view->resource->type == WINED3D_RTYPE_BUFFER)
3952 {
3953 buffer = buffer_from_resource(view->resource);
3954 wined3d_buffer_load(buffer, &context_gl->c, state);
3956
3958 if (!srv_gl->bo_user.valid)
3959 wined3d_shader_resource_view_gl_update(srv_gl, context_gl);
3960 }
3961 else
3962 {
3963 BOOL srgb = TRUE;
3964
3965 if (entry->sampler_idx != WINED3D_SAMPLER_DEFAULT
3966 && (sampler = state->sampler[i][entry->sampler_idx]))
3967 srgb = sampler->desc.srgb_decode;
3968
3969 wined3d_texture_load(texture_from_resource(view->resource), &context_gl->c, srgb);
3970 }
3971 }
3972 }
3973}
static bool is_resource_rtv_bound(const struct wined3d_state *state, const struct wined3d_resource *resource)
Definition: context_gl.c:3872
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1657
void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl *srv_gl, struct wined3d_context_gl *context_gl)
Definition: view.c:1023
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint sampler
Definition: glext.h:7283
GLuint shader
Definition: glext.h:6030
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
uint32_t entry
Definition: isohybrid.c:63
enum view_type type
struct wined3d_bo_user bo_user
Definition: wined3d_gl.h:1082
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:718
@ WINED3D_SHADER_TYPE_COUNT
Definition: wined3d.h:849
#define STATE_CONSTANT_BUFFER(a)
#define WINED3D_MAX_CBS
#define WINED3D_SAMPLER_DEFAULT
static struct wined3d_buffer * buffer_from_resource(struct wined3d_resource *resource)

Referenced by context_apply_draw_state(), and wined3d_context_gl_apply_compute_state().

◆ context_gl_load_stream_output_buffers()

static void context_gl_load_stream_output_buffers ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)
static

Definition at line 4017 of file context_gl.c.

4019{
4020 struct wined3d_buffer *buffer;
4021 unsigned int i;
4022
4023 for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
4024 {
4025 if (!(buffer = state->stream_output[i].buffer))
4026 continue;
4027
4029
4030 wined3d_buffer_load(buffer, &context_gl->c, state);
4033 if (!buffer->bo_user.valid)
4034 device_invalidate_state(context_gl->c.device, STATE_STREAM_OUTPUT);
4035 }
4036}
void wined3d_buffer_acquire_bo_for_write(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:750
void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, uint32_t location)
Definition: buffer.c:131
#define STATE_STREAM_OUTPUT
#define WINED3D_LOCATION_BUFFER

Referenced by context_apply_draw_state().

◆ context_gl_load_unordered_access_resources()

static void context_gl_load_unordered_access_resources ( struct wined3d_context_gl *  context_gl,
const struct wined3d_shader *  shader,
struct wined3d_unordered_access_view *const *  views 
)
static

Definition at line 3975 of file context_gl.c.

3977{
3978 struct wined3d_unordered_access_view_gl *uav_gl;
3980 struct wined3d_texture *texture;
3981 struct wined3d_buffer *buffer;
3982 unsigned int i;
3983
3984 context_gl->c.uses_uavs = 0;
3985
3986 if (!shader)
3987 return;
3988
3989 for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
3990 {
3991 if (!(view = views[i]))
3992 continue;
3993
3994 if (view->resource->type == WINED3D_RTYPE_BUFFER)
3995 {
3996 buffer = buffer_from_resource(view->resource);
4001
4003 if (!uav_gl->bo_user.valid)
4004 wined3d_unordered_access_view_gl_update(uav_gl, context_gl);
4005 }
4006 else
4007 {
4008 texture = texture_from_resource(view->resource);
4009 wined3d_texture_load(texture, &context_gl->c, FALSE);
4011 }
4012
4013 context_gl->c.uses_uavs = 1;
4014 }
4015}
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, uint32_t location)
Definition: buffer.c:269
void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view, uint32_t location)
Definition: view.c:1564
void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl *uav_gl, struct wined3d_context_gl *context_gl)
Definition: view.c:1753
struct wined3d_bo_user bo_user
Definition: wined3d_gl.h:1105
#define MAX_UNORDERED_ACCESS_VIEWS
#define WINED3D_LOCATION_TEXTURE_RGB

Referenced by context_apply_draw_state(), and wined3d_context_gl_apply_compute_state().

◆ context_gl_resource_released()

void context_gl_resource_released ( struct wined3d_device *  device,
GLuint  name,
BOOL  rb_namespace 
)

Definition at line 1137 of file context_gl.c.

1138{
1141}
static void wined3d_context_gl_enum_fbo_entries(const struct wined3d_device *device, GLuint name, BOOL rb_namespace, context_fbo_entry_func_t *callback)
Definition: context_gl.c:1104
static void wined3d_context_gl_queue_fbo_entry_destruction(struct wined3d_context_gl *context_gl, struct fbo_entry *entry)
Definition: context_gl.c:1130

Referenced by gltexture_delete(), wined3d_texture_gl_unload_location(), and wined3d_view_gl_destroy_object().

◆ context_invalidate_texture_stage()

static void context_invalidate_texture_stage ( struct wined3d_context *  context,
DWORD  stage 
)
static

Definition at line 3487 of file context_gl.c.

3488{
3489 DWORD i;
3490
3491 for (i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
3493}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINED3D_HIGHEST_TEXTURE_STATE
Definition: wined3d.h:614
#define STATE_TEXTURESTAGE(stage, num)

Referenced by wined3d_context_gl_map_fixed_function_samplers(), and wined3d_context_gl_map_psamplers().

◆ context_restore_gl_context()

static void context_restore_gl_context ( const struct wined3d_gl_info *  gl_info,
HDC  dc,
HGLRC  gl_ctx 
)
static

Definition at line 1323 of file context_gl.c.

1324{
1325 if (!wglMakeCurrent(dc, gl_ctx))
1326 {
1327 ERR("Failed to restore GL context %p on device context %p, last error %#lx.\n",
1328 gl_ctx, dc, GetLastError());
1330 }
1331}
BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1571
HDC dc
Definition: cylfrac.c:34
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
Definition: wgl.c:652

Referenced by wined3d_context_gl_cleanup(), and wined3d_context_gl_release().

◆ context_set_tls_idx()

void context_set_tls_idx ( DWORD  idx)

Definition at line 1561 of file context_gl.c.

1562{
1564}
unsigned int idx
Definition: utils.c:40

Referenced by wined3d_dll_init().

◆ context_state_drawbuf()

void context_state_drawbuf ( struct wined3d_context *  context,
const struct wined3d_state *  state,
DWORD  state_id 
)

Definition at line 3722 of file context_gl.c.

3723{
3724 struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
3725 uint32_t rt_mask, *cur_mask;
3726
3728
3729 cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask;
3730 rt_mask = find_draw_buffers_mask(context_gl, state);
3731 if (rt_mask != *cur_mask)
3732 {
3733 wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask);
3734 *cur_mask = rt_mask;
3735 }
3736}
static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
Definition: context_gl.c:3360

◆ context_state_fb()

void context_state_fb ( struct wined3d_context *  context,
const struct wined3d_state *  state,
DWORD  state_id 
)

Definition at line 3426 of file context_gl.c.

3427{
3428 struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
3429 uint32_t rt_mask = find_draw_buffers_mask(context_gl, state);
3430 const struct wined3d_rendertarget_view_gl *view_gl;
3431 struct wined3d_rendertarget_info ds_info = {{0}};
3432 const struct wined3d_fb_state *fb = &state->fb;
3433 DWORD color_location = 0;
3434 uint32_t *cur_mask;
3435
3436 memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets));
3437 for (unsigned int i = 0; i < context_gl->gl_info->limits.buffers; ++i)
3438 {
3439 if (!fb->render_targets[i])
3440 continue;
3441
3443 context_gl->blit_targets[i].gl_view = view_gl->gl_view;
3444 context_gl->blit_targets[i].resource = view_gl->v.resource;
3445 context_gl->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx;
3446 context_gl->blit_targets[i].layer_count = view_gl->v.layer_count;
3447
3448 if (!color_location)
3449 color_location = view_gl->v.resource->draw_binding;
3450 }
3451
3452 if (fb->depth_stencil)
3453 {
3455 ds_info.gl_view = view_gl->gl_view;
3456 ds_info.resource = view_gl->v.resource;
3457 ds_info.sub_resource_idx = view_gl->v.sub_resource_idx;
3458 ds_info.layer_count = view_gl->v.layer_count;
3459 }
3460
3461 wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info,
3462 color_location, fb->depth_stencil ? fb->depth_stencil->resource->draw_binding : 0);
3463
3464 cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask;
3465 if (rt_mask != *cur_mask)
3466 {
3467 wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask);
3468 *cur_mask = rt_mask;
3469 }
3470}
static void wined3d_context_gl_apply_fbo_state(struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context_gl.c:821
struct wined3d_rendertarget_info blit_targets[WINED3D_MAX_RENDER_TARGETS]
Definition: wined3d_gl.h:644
unsigned int layer_count
Definition: wined3d_gl.h:564
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:561
unsigned int sub_resource_idx
Definition: wined3d_gl.h:563
struct wined3d_resource * resource
Definition: wined3d_gl.h:562
struct wined3d_rendertarget_view v
Definition: wined3d_gl.h:1065
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:1066

◆ context_update_fixed_function_usage_map()

static void context_update_fixed_function_usage_map ( struct wined3d_context *  context,
const struct wined3d_state *  state 
)
static

Definition at line 3506 of file context_gl.c.

3508{
3509 UINT i = 0, start, end;
3510
3511 context->fixed_function_usage_map = 0;
3512
3513 if (use_ffp_ps(state))
3514 {
3515 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
3516 {
3517 enum wined3d_texture_op color_op = state->texture_states[i][WINED3D_TSS_COLOR_OP];
3518 enum wined3d_texture_op alpha_op = state->texture_states[i][WINED3D_TSS_ALPHA_OP];
3519 DWORD color_arg1 = state->texture_states[i][WINED3D_TSS_COLOR_ARG1] & WINED3DTA_SELECTMASK;
3520 DWORD color_arg2 = state->texture_states[i][WINED3D_TSS_COLOR_ARG2] & WINED3DTA_SELECTMASK;
3521 DWORD color_arg3 = state->texture_states[i][WINED3D_TSS_COLOR_ARG0] & WINED3DTA_SELECTMASK;
3522 DWORD alpha_arg1 = state->texture_states[i][WINED3D_TSS_ALPHA_ARG1] & WINED3DTA_SELECTMASK;
3523 DWORD alpha_arg2 = state->texture_states[i][WINED3D_TSS_ALPHA_ARG2] & WINED3DTA_SELECTMASK;
3524 DWORD alpha_arg3 = state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] & WINED3DTA_SELECTMASK;
3525
3526 /* Not used, and disable higher stages. */
3527 if (color_op == WINED3D_TOP_DISABLE)
3528 break;
3529
3530 if (((color_arg1 == WINED3DTA_TEXTURE) && color_op != WINED3D_TOP_SELECT_ARG2)
3531 || ((color_arg2 == WINED3DTA_TEXTURE) && color_op != WINED3D_TOP_SELECT_ARG1)
3532 || ((color_arg3 == WINED3DTA_TEXTURE)
3533 && (color_op == WINED3D_TOP_MULTIPLY_ADD || color_op == WINED3D_TOP_LERP))
3534 || ((alpha_arg1 == WINED3DTA_TEXTURE) && alpha_op != WINED3D_TOP_SELECT_ARG2)
3535 || ((alpha_arg2 == WINED3DTA_TEXTURE) && alpha_op != WINED3D_TOP_SELECT_ARG1)
3536 || ((alpha_arg3 == WINED3DTA_TEXTURE)
3537 && (alpha_op == WINED3D_TOP_MULTIPLY_ADD || alpha_op == WINED3D_TOP_LERP)))
3538 context->fixed_function_usage_map |= (1u << i);
3539
3540 if ((color_op == WINED3D_TOP_BUMPENVMAP || color_op == WINED3D_TOP_BUMPENVMAP_LUMINANCE)
3541 && i < WINED3D_MAX_FFP_TEXTURES - 1)
3542 context->fixed_function_usage_map |= (1u << (i + 1));
3543 }
3544 }
3545
3546 if (i < context->lowest_disabled_stage)
3547 {
3548 start = i;
3549 end = context->lowest_disabled_stage;
3550 }
3551 else
3552 {
3553 start = context->lowest_disabled_stage;
3554 end = i;
3555 }
3556
3557 context->lowest_disabled_stage = i;
3558 for (i = start + 1; i < end; ++i)
3559 {
3561 }
3562}
static bool use_ffp_ps(const struct wined3d_state *state)
Definition: context_gl.c:3495
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
unsigned int UINT
Definition: sysinfo.c:13
#define WINED3DTA_SELECTMASK
Definition: wined3d.h:880
@ WINED3D_TSS_COLOR_ARG2
Definition: wined3d.h:596
@ WINED3D_TSS_ALPHA_OP
Definition: wined3d.h:597
@ WINED3D_TSS_COLOR_OP
Definition: wined3d.h:594
@ WINED3D_TSS_ALPHA_ARG2
Definition: wined3d.h:599
@ WINED3D_TSS_ALPHA_ARG0
Definition: wined3d.h:609
@ WINED3D_TSS_COLOR_ARG0
Definition: wined3d.h:608
@ WINED3D_TSS_COLOR_ARG1
Definition: wined3d.h:595
@ WINED3D_TSS_ALPHA_ARG1
Definition: wined3d.h:598
wined3d_texture_op
Definition: wined3d.h:627
@ WINED3D_TOP_SELECT_ARG1
Definition: wined3d.h:629
@ WINED3D_TOP_DISABLE
Definition: wined3d.h:628
@ WINED3D_TOP_MULTIPLY_ADD
Definition: wined3d.h:652
@ WINED3D_TOP_BUMPENVMAP_LUMINANCE
Definition: wined3d.h:650
@ WINED3D_TOP_BUMPENVMAP
Definition: wined3d.h:649
@ WINED3D_TOP_SELECT_ARG2
Definition: wined3d.h:630
@ WINED3D_TOP_LERP
Definition: wined3d.h:653
#define WINED3D_MAX_FFP_TEXTURES
Definition: wined3d.h:1597
#define WINED3DTA_TEXTURE
Definition: wined3d.h:883

Referenced by wined3d_context_gl_update_tex_unit_map().

◆ dispatch_compute()

void dispatch_compute ( struct wined3d_device *  device,
const struct wined3d_state *  state,
const struct wined3d_dispatch_parameters *  parameters 
)

Definition at line 4402 of file context_gl.c.

4404{
4405 const struct wined3d_gl_info *gl_info;
4406 struct wined3d_context_gl *context_gl;
4407
4408 context_gl = wined3d_context_gl(context_acquire(device, NULL, 0));
4409 if (!context_gl->valid)
4410 {
4411 context_release(&context_gl->c);
4412 WARN("Invalid context, skipping dispatch.\n");
4413 return;
4414 }
4415 gl_info = context_gl->gl_info;
4416
4417 if (!gl_info->supported[ARB_COMPUTE_SHADER])
4418 {
4419 context_release(&context_gl->c);
4420 FIXME("OpenGL implementation does not support compute shaders.\n");
4421 return;
4422 }
4423
4424 if (parameters->indirect)
4425 wined3d_buffer_load(parameters->u.indirect.buffer, &context_gl->c, state);
4426
4428
4429 if (parameters->indirect)
4430 {
4431 const struct wined3d_indirect_dispatch_parameters *indirect = &parameters->u.indirect;
4432 struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(indirect->buffer->buffer_object);
4433
4434 GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, bo_gl->id));
4435 GL_EXTCALL(glDispatchComputeIndirect(bo_gl->b.buffer_offset + (GLintptr)indirect->offset));
4436 GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0));
4437 wined3d_context_gl_reference_bo(context_gl, bo_gl);
4438 }
4439 else
4440 {
4441 const struct wined3d_direct_dispatch_parameters *direct = &parameters->u.direct;
4442 GL_EXTCALL(glDispatchCompute(direct->group_count_x, direct->group_count_y, direct->group_count_z));
4443 }
4444 checkGLcall("dispatch compute");
4445
4446 GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS));
4447 checkGLcall("glMemoryBarrier");
4448
4449 context_release(&context_gl->c);
4450}
static void wined3d_context_gl_apply_compute_state(struct wined3d_context_gl *context_gl, const struct wined3d_device *device, const struct wined3d_state *state)
Definition: context_gl.c:4170
ptrdiff_t GLintptr
Definition: glext.h:5498
#define GL_ALL_BARRIER_BITS
Definition: glext.h:2341
static BYTE parameters[]
Definition: asn.c:558
struct wined3d_bo b
Definition: wined3d_gl.h:415
#define GL_DISPATCH_INDIRECT_BUFFER
Definition: wgl.h:1033
@ ARB_COMPUTE_SHADER
Definition: wined3d_gl.h:60
static void wined3d_context_gl_reference_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo_gl)
Definition: wined3d_gl.h:912
static void context_release(struct wined3d_context *context)
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)

◆ draw_buffer_from_rt_mask()

static GLenum draw_buffer_from_rt_mask ( DWORD  rt_mask)
inlinestatic

Definition at line 2441 of file context_gl.c.

2442{
2443 return rt_mask & ~(1u << 31);
2444}

Referenced by wined3d_context_gl_apply_draw_buffers().

◆ draw_primitive()

void draw_primitive ( struct wined3d_device *  device,
const struct wined3d_state *  state,
const struct wined3d_draw_parameters *  parameters 
)

Definition at line 4648 of file context_gl.c.

4650{
4651 const struct wined3d_fb_state *fb = &state->fb;
4652 const struct wined3d_stream_info *stream_info;
4653 struct wined3d_rendertarget_view *dsv, *rtv;
4654 const struct wined3d_gl_info *gl_info;
4655 struct wined3d_context_gl *context_gl;
4656 struct wined3d_context *context;
4657 bool rasterizer_discard = false;
4658 unsigned int i, idx_size = 0;
4659 const void *idx_data = NULL;
4660
4661 TRACE("device %p, state %p, parameters %p.\n", device, state, parameters);
4662
4663 if (!parameters->indirect && !parameters->u.direct.index_count)
4664 return;
4665
4666 if (!parameters->indirect)
4667 TRACE("base_vertex_idx %d, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n",
4668 parameters->u.direct.base_vertex_idx, parameters->u.direct.start_idx,
4669 parameters->u.direct.index_count, parameters->u.direct.start_instance,
4670 parameters->u.direct.instance_count);
4671
4672 if (!(rtv = fb->render_targets[0]))
4673 rtv = fb->depth_stencil;
4674
4675 if (rtv && rtv->resource->type == WINED3D_RTYPE_BUFFER)
4676 {
4677 FIXME("Buffer render targets not implemented.\n");
4678 return;
4679 }
4680
4681 if (rtv)
4683 else
4685 context_gl = wined3d_context_gl(context);
4686 if (!context_gl->valid)
4687 {
4689 WARN("Invalid context, skipping draw.\n");
4690 return;
4691 }
4692 gl_info = context_gl->gl_info;
4693
4696
4697 for (i = 0; i < gl_info->limits.buffers; ++i)
4698 {
4699 if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL)
4700 continue;
4701
4702 if (wined3d_blend_state_get_writemask(state->blend_state, i))
4703 {
4706 }
4707 else
4708 {
4710 }
4711 }
4712
4713 if ((dsv = fb->depth_stencil))
4714 {
4715 /* We don't currently take the Z-compare function into account,
4716 * but we could skip loading the depthstencil for D3DCMP_NEVER and
4717 * D3DCMP_ALWAYS as well.
4718 * Also note that we never copy the stencil data. */
4719 uint32_t location = dsv->resource->draw_binding;
4720
4723 else
4725 }
4726
4727 if (parameters->indirect)
4728 wined3d_buffer_load(parameters->u.indirect.buffer, context, state);
4729
4731 {
4733 WARN("Unable to apply draw state, skipping draw.\n");
4734 return;
4735 }
4736
4737 if (dsv && (!state->depth_stencil_state || state->depth_stencil_state->writes_ds))
4738 {
4739 uint32_t location = dsv->resource->draw_binding;
4740
4743 }
4744
4745 stream_info = &context->stream_info;
4746
4747 if (parameters->indexed)
4748 {
4749 struct wined3d_buffer *index_buffer = state->index_buffer;
4750 struct wined3d_bo *bo = index_buffer->buffer_object;
4751
4752 if (!bo || !stream_info->all_vbo)
4753 idx_data = index_buffer->resource.heap_memory;
4754 else
4755 idx_data = (void *)bo->buffer_offset;
4756 idx_data = (const BYTE *)idx_data + state->index_offset;
4757
4758 if (state->index_format == WINED3DFMT_R16_UINT)
4759 idx_size = 2;
4760 else
4761 idx_size = 4;
4762 }
4763
4765 {
4767
4769 {
4771 checkGLcall("enable rasterizer discard");
4772 rasterizer_discard = true;
4773 }
4774
4775 if (context->transform_feedback_paused)
4776 {
4777 GL_EXTCALL(glResumeTransformFeedback());
4778 checkGLcall("glResumeTransformFeedback");
4779 context->transform_feedback_paused = 0;
4780 }
4781 else if (!context->transform_feedback_active)
4782 {
4783 enum wined3d_primitive_type primitive_type = shader->u.gs.output_type
4784 ? shader->u.gs.output_type : state->primitive_type;
4785 GLenum mode = gl_tfb_primitive_type_from_d3d(primitive_type);
4786 GL_EXTCALL(glBeginTransformFeedback(mode));
4787 checkGLcall("glBeginTransformFeedback");
4788 context->transform_feedback_active = 1;
4789 }
4790 }
4791
4792 if (state->primitive_type == WINED3D_PT_PATCH)
4793 {
4794 GL_EXTCALL(glPatchParameteri(GL_PATCH_VERTICES, state->patch_vertex_count));
4795 checkGLcall("glPatchParameteri");
4796 }
4797
4798 if (context->uses_fbo_attached_resources)
4799 {
4800 static unsigned int fixme_once;
4801
4802 if (gl_info->supported[ARB_TEXTURE_BARRIER])
4803 {
4804 GL_EXTCALL(glTextureBarrier());
4805 }
4806 else if (gl_info->supported[NV_TEXTURE_BARRIER])
4807 {
4808 GL_EXTCALL(glTextureBarrierNV());
4809 }
4810 else
4811 {
4812 if (!fixme_once++)
4813 FIXME("Sampling attached render targets is not supported.\n");
4814
4815 WARN("Sampling attached render targets is not supported, skipping draw.\n");
4817 return;
4818 }
4819 checkGLcall("glTextureBarrier");
4820 }
4821
4822 if (parameters->indirect)
4823 {
4824 wined3d_context_gl_draw_indirect(context_gl, state, &parameters->u.indirect, idx_size);
4825 }
4826 else
4827 {
4828 wined3d_context_gl_draw_primitive_arrays(context_gl, state, idx_data, idx_size,
4829 parameters->u.direct.base_vertex_idx, parameters->u.direct.start_idx,
4830 parameters->u.direct.index_count, parameters->u.direct.start_instance,
4831 parameters->u.direct.instance_count);
4832 }
4833
4834 if (context->uses_uavs)
4835 {
4836 GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS));
4837 checkGLcall("glMemoryBarrier");
4838 }
4839
4840 if (rasterizer_discard)
4841 {
4843 checkGLcall("disable rasterizer discard");
4844 }
4845
4847
4848 TRACE("Draw completed.\n");
4849}
static void wined3d_context_gl_draw_primitive_arrays(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, const void *idx_data, unsigned int idx_size, int base_vertex_idx, unsigned int start_idx, unsigned int count, unsigned int start_instance, unsigned int instance_count)
Definition: context_gl.c:4453
static void wined3d_context_gl_draw_indirect(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size)
Definition: context_gl.c:4586
static GLenum gl_tfb_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type)
Definition: context_gl.c:4621
static void wined3d_context_gl_pause_transform_feedback(struct wined3d_context_gl *context_gl, BOOL force)
Definition: context_gl.c:4241
static BOOL context_apply_draw_state(struct wined3d_context *context, const struct wined3d_device *device, const struct wined3d_state *state, BOOL indexed)
Definition: context_gl.c:4039
struct wined3d_texture *__cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
Definition: texture.c:3343
void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view, struct wined3d_context *context, uint32_t location)
Definition: view.c:469
void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view, struct wined3d_context *context, uint32_t location)
Definition: view.c:489
void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view, uint32_t location)
Definition: view.c:495
void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view, uint32_t location)
Definition: view.c:514
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_RASTERIZER_DISCARD
Definition: glext.h:552
GLenum mode
Definition: glext.h:6217
#define GL_PATCH_VERTICES
Definition: glext.h:2091
static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
size_t buffer_offset
struct wined3d_bo * buffer_object
struct wined3d_resource resource
struct wined3d_resource * resource
const struct wined3d_format * format
wined3d_primitive_type
Definition: wined3d.h:74
@ WINED3D_PT_PATCH
Definition: wined3d.h:86
@ WINED3DFMT_R16_UINT
Definition: wined3d.h:214
@ WINED3D_SHADER_TYPE_GEOMETRY
Definition: wined3d.h:843
@ ARB_TEXTURE_BARRIER
Definition: wined3d_gl.h:159
@ NV_TEXTURE_BARRIER
Definition: wined3d_gl.h:224
static BOOL use_transform_feedback(const struct wined3d_state *state)
static bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state)
static BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
static unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state *state, unsigned int index)
unsigned char BYTE
Definition: xxhash.c:193

◆ find_draw_buffers_mask()

static uint32_t find_draw_buffers_mask ( const struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)
static

Definition at line 3360 of file context_gl.c.

3361{
3362 struct wined3d_rendertarget_view * const *rts = state->fb.render_targets;
3364 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3365 unsigned int rt_mask, mask;
3366 unsigned int i;
3367
3368 rt_mask = ps ? ps->reg_maps.rt_mask : 1;
3369 rt_mask &= wined3d_mask_from_size(gl_info->limits.buffers);
3370 if (state->blend_state && state->blend_state->dual_source)
3371 rt_mask = 1;
3372
3373 mask = rt_mask;
3374 while (mask)
3375 {
3377 if (!rts[i] || rts[i]->format->id == WINED3DFMT_NULL)
3378 rt_mask &= ~(1u << i);
3379 }
3380
3381 return rt_mask;
3382}
GLenum GLint GLuint mask
Definition: glext.h:6028
struct wined3d_pixel_shader ps
struct wined3d_shader_reg_maps reg_maps
static uint32_t wined3d_mask_from_size(unsigned int size)

Referenced by context_state_drawbuf(), and context_state_fb().

◆ flush_bo_ranges()

static void flush_bo_ranges ( struct wined3d_context_gl *  context_gl,
const struct wined3d_const_bo_address *  data,
unsigned int  range_count,
const struct wined3d_range *  ranges 
)
static

Definition at line 2950 of file context_gl.c.

2952{
2953 const struct wined3d_gl_info *gl_info;
2954 struct wined3d_bo_gl *bo;
2955 unsigned int i;
2956
2957 if (!data->buffer_object || data->buffer_object->coherent)
2958 return;
2959 bo = wined3d_bo_gl(data->buffer_object);
2960
2961 gl_info = context_gl->gl_info;
2962 wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
2963
2964 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
2965 {
2966 /* The offset passed to glFlushMappedBufferRange() is relative to the
2967 * mapped range, but we map the whole buffer anyway. */
2968 for (i = 0; i < range_count; ++i)
2969 {
2970 GL_EXTCALL(glFlushMappedBufferRange(bo->binding,
2971 bo->b.buffer_offset + (uintptr_t)data->addr + ranges[i].offset, ranges[i].size));
2972 }
2973 }
2974 else if (gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
2975 {
2976 for (i = 0; i < range_count; ++i)
2977 {
2978 GL_EXTCALL(glFlushMappedBufferRangeAPPLE(bo->binding,
2979 bo->b.buffer_offset + (uintptr_t)data->addr + ranges[i].offset, ranges[i].size));
2980 checkGLcall("glFlushMappedBufferRangeAPPLE");
2981 }
2982 }
2983
2984 wined3d_context_gl_bind_bo(context_gl, bo->binding, 0);
2985 checkGLcall("Flush buffer object");
2986}
void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name)
Definition: context_gl.c:2497
unsigned int uintptr_t
Definition: corecrt.h:185
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum binding
Definition: wined3d_gl.h:422
@ APPLE_FLUSH_BUFFER_RANGE
Definition: wined3d_gl.h:48
@ ARB_MAP_BUFFER_RANGE
Definition: wined3d_gl.h:94

Referenced by wined3d_context_gl_flush_bo_address(), and wined3d_context_gl_unmap_bo_address().

◆ get_vertex_attrib_pointer()

static const void * get_vertex_attrib_pointer ( const struct wined3d_stream_info_element *  element,
const struct wined3d_state *  state 
)
static

Definition at line 4851 of file context_gl.c.

4853{
4854 const uint8_t *offset = element->data.addr + state->load_base_vertex_index * element->stride;
4855
4856 if (element->data.buffer_object)
4857 offset += element->data.buffer_object->buffer_offset;
4858 return offset;
4859}
unsigned char uint8_t
Definition: stdint.h:33
GLintptr offset
Definition: glext.h:5920

Referenced by wined3d_context_gl_load_numbered_arrays().

◆ gl_primitive_type_from_d3d()

static GLenum gl_primitive_type_from_d3d ( enum wined3d_primitive_type  primitive_type)
static

Definition at line 41 of file context_gl.c.

42{
43 switch (primitive_type)
44 {
46 return GL_POINTS;
47
49 return GL_LINES;
50
52 return GL_LINE_STRIP;
53
55 return GL_TRIANGLES;
56
58 return GL_TRIANGLE_STRIP;
59
61 return GL_TRIANGLE_FAN;
62
65
68
71
74
76 return GL_PATCHES;
77
78 default:
79 FIXME("Unhandled primitive type %s.\n", debug_d3dprimitivetype(primitive_type));
81 return ~0u;
82 }
83}
const char * debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type)
Definition: utils.c:5009
#define GL_TRIANGLE_FAN
Definition: gl.h:196
#define GL_LINE_STRIP
Definition: gl.h:193
#define GL_LINES
Definition: gl.h:191
#define GL_TRIANGLES
Definition: gl.h:194
#define GL_POINTS
Definition: gl.h:190
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
#define GL_TRIANGLE_STRIP_ADJACENCY_ARB
Definition: glext.h:1765
#define GL_LINE_STRIP_ADJACENCY_ARB
Definition: glext.h:1763
#define GL_LINES_ADJACENCY_ARB
Definition: glext.h:1762
#define GL_TRIANGLES_ADJACENCY_ARB
Definition: glext.h:1764
#define GL_PATCHES
Definition: glext.h:2090
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
@ WINED3D_PT_LINESTRIP_ADJ
Definition: wined3d.h:83
@ WINED3D_PT_LINELIST
Definition: wined3d.h:77
@ WINED3D_PT_UNDEFINED
Definition: wined3d.h:75
@ WINED3D_PT_POINTLIST
Definition: wined3d.h:76
@ WINED3D_PT_TRIANGLELIST_ADJ
Definition: wined3d.h:84
@ WINED3D_PT_LINELIST_ADJ
Definition: wined3d.h:82
@ WINED3D_PT_TRIANGLESTRIP_ADJ
Definition: wined3d.h:85
@ WINED3D_PT_TRIANGLESTRIP
Definition: wined3d.h:80
@ WINED3D_PT_LINESTRIP
Definition: wined3d.h:78
@ WINED3D_PT_TRIANGLELIST
Definition: wined3d.h:79
@ WINED3D_PT_TRIANGLEFAN
Definition: wined3d.h:81

Referenced by gl_tfb_primitive_type_from_d3d(), wined3d_context_gl_draw_indirect(), and wined3d_context_gl_draw_primitive_arrays().

◆ gl_tfb_primitive_type_from_d3d()

static GLenum gl_tfb_primitive_type_from_d3d ( enum wined3d_primitive_type  primitive_type)
static

Definition at line 4621 of file context_gl.c.

4622{
4623 GLenum gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
4624 switch (gl_primitive_type)
4625 {
4626 case GL_POINTS:
4627 return GL_POINTS;
4628
4629 case GL_LINE_STRIP:
4631 case GL_LINES_ADJACENCY:
4632 case GL_LINES:
4633 return GL_LINES;
4634
4635 case GL_TRIANGLE_FAN:
4636 case GL_TRIANGLE_STRIP:
4639 case GL_TRIANGLES:
4640 return GL_TRIANGLES;
4641
4642 default:
4643 return gl_primitive_type;
4644 }
4645}
static GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type)
Definition: context_gl.c:41
#define GL_LINES_ADJACENCY
Definition: glext.h:812
#define GL_TRIANGLE_STRIP_ADJACENCY
Definition: glext.h:815
#define GL_TRIANGLES_ADJACENCY
Definition: glext.h:814
#define GL_LINE_STRIP_ADJACENCY
Definition: glext.h:813

Referenced by draw_primitive().

◆ have_framebuffer_attachment()

static BOOL have_framebuffer_attachment ( unsigned int  rt_count,
struct wined3d_rendertarget_view *const *  rts,
const struct wined3d_rendertarget_view *  ds 
)
static

Definition at line 3232 of file context_gl.c.

3234{
3235 unsigned int i;
3236
3237 if (ds)
3238 return TRUE;
3239
3240 for (i = 0; i < rt_count; ++i)
3241 {
3242 if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3243 return TRUE;
3244 }
3245
3246 return FALSE;
3247}
#define ds
Definition: i386-dis.c:443

Referenced by context_apply_draw_state(), and wined3d_context_gl_apply_clear_state().

◆ is_resource_rtv_bound()

static bool is_resource_rtv_bound ( const struct wined3d_state *  state,
const struct wined3d_resource *  resource 
)
static

Definition at line 3872 of file context_gl.c.

3873{
3874 unsigned int i;
3875
3876 if (state->fb.depth_stencil && state->fb.depth_stencil->resource == resource)
3877 return true;
3878
3879 if (!resource->rtv_bind_count_device)
3880 return false;
3881
3882 for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
3883 {
3884 if (state->fb.render_targets[i] && state->fb.render_targets[i]->resource == resource)
3885 return true;
3886 }
3887
3888 return false;
3889}

Referenced by context_gl_load_shader_resources().

◆ is_rt_mask_onscreen()

static BOOL is_rt_mask_onscreen ( DWORD  rt_mask)
inlinestatic

Definition at line 2436 of file context_gl.c.

2437{
2438 return rt_mask & (1u << 31);
2439}

Referenced by wined3d_context_gl_apply_draw_buffers().

◆ use_ffp_ps()

static bool use_ffp_ps ( const struct wined3d_state *  state)
static

Definition at line 3495 of file context_gl.c.

3496{
3498
3499 if (!use_vs(state))
3500 return true;
3501 if (vs && vs->reg_maps.shader_version.major >= 4)
3502 return false;
3503 return true;
3504}
static vector_t * vs
Definition: server.c:146
static BOOL use_vs(const struct wined3d_state *state)

Referenced by context_update_fixed_function_usage_map().

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/2]

WINE_DECLARE_DEBUG_CHANNEL ( d3d_perf  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/2]

WINE_DECLARE_DEBUG_CHANNEL ( d3d_sync  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_allocator_chunk_gl_map()

static void * wined3d_allocator_chunk_gl_map ( struct wined3d_allocator_chunk_gl *  chunk_gl,
struct wined3d_context_gl *  context_gl 
)
static

Definition at line 2736 of file context_gl.c.

2738{
2739 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2740 void *map_ptr;
2741
2742 TRACE("chunk %p, gl_buffer %u, map_ptr %p.\n", chunk_gl, chunk_gl->gl_buffer, chunk_gl->c.map_ptr);
2743
2745
2746 if (!chunk_gl->c.map_ptr)
2747 {
2748 unsigned int flags = wined3d_device_gl_get_memory_type_flags(chunk_gl->memory_type) & ~GL_CLIENT_STORAGE_BIT;
2749
2751 if (!(flags & GL_MAP_READ_BIT))
2753 if (flags & GL_MAP_WRITE_BIT)
2756 chunk_gl->c.map_ptr = GL_EXTCALL(glMapBufferRange(GL_PIXEL_UNPACK_BUFFER,
2758 if (!chunk_gl->c.map_ptr)
2759 {
2761 ERR("Failed to map chunk memory.\n");
2762 return NULL;
2763 }
2764
2765 adapter_adjust_mapped_memory(context_gl->c.device->adapter, WINED3D_ALLOCATOR_CHUNK_SIZE);
2766 }
2767
2768 ++chunk_gl->c.map_count;
2769 map_ptr = chunk_gl->c.map_ptr;
2770
2772
2773 return map_ptr;
2774}
GLbitfield wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx)
Definition: device.c:1274
#define GL_MAP_READ_BIT
Definition: glext.h:1793
#define GL_MAP_FLUSH_EXPLICIT_BIT
Definition: glext.h:1797
#define GL_MAP_UNSYNCHRONIZED_BIT
Definition: glext.h:1798
#define GL_MAP_WRITE_BIT
Definition: glext.h:1794
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
struct wined3d_allocator_chunk c
Definition: wined3d_gl.h:820
#define GL_MAP_COHERENT_BIT
Definition: wgl.h:2142
#define GL_MAP_PERSISTENT_BIT
Definition: wgl.h:2147
ssize_t adapter_adjust_mapped_memory(struct wined3d_adapter *adapter, ssize_t size)
Definition: directx.c:167
static void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl *chunk_gl)
Definition: wined3d_gl.h:895
static void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl *chunk_gl)
Definition: wined3d_gl.h:890
#define WINED3D_ALLOCATOR_CHUNK_SIZE

Referenced by wined3d_bo_gl_map().

◆ wined3d_allocator_chunk_gl_unmap()

static void wined3d_allocator_chunk_gl_unmap ( struct wined3d_allocator_chunk_gl *  chunk_gl,
struct wined3d_context_gl *  context_gl 
)
static

Definition at line 2776 of file context_gl.c.

2778{
2779 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2780
2781 TRACE("chunk_gl %p, context_gl %p.\n", chunk_gl, context_gl);
2782
2784
2785 if (!--chunk_gl->c.map_count)
2786 {
2788 GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
2789 chunk_gl->c.map_ptr = NULL;
2790
2791 adapter_adjust_mapped_memory(context_gl->c.device->adapter, -WINED3D_ALLOCATOR_CHUNK_SIZE);
2792 }
2793
2795}

Referenced by wined3d_bo_gl_unmap(), and wined3d_context_gl_destroy_bo().

◆ wined3d_bo_gl_map()

static void * wined3d_bo_gl_map ( struct wined3d_bo_gl *  bo,
struct wined3d_context_gl *  context_gl,
uint32_t  flags 
)
static

Definition at line 2797 of file context_gl.c.

2798{
2799 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2800 const struct wined3d_gl_info *gl_info;
2801 struct wined3d_bo_user *bo_user;
2802 struct wined3d_bo_gl tmp;
2803
2805 goto map;
2806
2808 {
2809 if (wined3d_device_gl_create_bo(device_gl, context_gl, bo->size,
2810 bo->binding, bo->usage, bo->b.coherent, bo->flags, &tmp))
2811 {
2812 LIST_FOR_EACH_ENTRY(bo_user, &bo->b.users, struct wined3d_bo_user, entry)
2813 bo_user->valid = false;
2814 list_init(&bo->b.users);
2815
2816 wined3d_context_gl_destroy_bo(context_gl, bo);
2817 *bo = tmp;
2818 list_init(&bo->b.users);
2819
2820 goto map;
2821 }
2822
2823 ERR("Failed to create new buffer object.\n");
2824 }
2825
2826 if (context_gl->c.d3d_info->fences)
2827 {
2828 if (bo->command_fence_id == device_gl->current_fence_id)
2831 }
2832
2833map:
2834 if (bo->b.map_ptr)
2835 return bo->b.map_ptr;
2836
2837 if (bo->memory)
2838 {
2839 struct wined3d_allocator_chunk_gl *chunk_gl = wined3d_allocator_chunk_gl(bo->memory->chunk);
2840
2841 if (!(bo->b.map_ptr = wined3d_allocator_chunk_gl_map(chunk_gl, context_gl)))
2842 ERR("Failed to map chunk.\n");
2843 return bo->b.map_ptr;
2844 }
2845
2846 gl_info = context_gl->gl_info;
2847 wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
2848
2849 if (gl_info->supported[ARB_BUFFER_STORAGE])
2850 {
2852
2853 /* When mapping the bo persistently, we need to use the access flags
2854 * used to create the bo, instead of the access flags passed to the
2855 * map call. Otherwise, if for example the initial map call that
2856 * caused the bo to be persistently mapped was a read-only map,
2857 * subsequent write access to the bo would be undefined.
2858 *
2859 * Note that we use GL_MAP_PERSISTENT_BIT for non-persistent maps here
2860 * as well, in order to allow draws to succeed while referenced buffer
2861 * resources are mapped. On the other hand, we don't want to use the
2862 * access flags used to create the bo for non-persistent maps, because
2863 * that may imply dropping GL_MAP_UNSYNCHRONIZED_BIT. */
2864 gl_flags = bo->flags & ~GL_CLIENT_STORAGE_BIT;
2865 if (!(gl_flags & GL_MAP_READ_BIT))
2870
2871 bo->b.map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, gl_flags));
2872 }
2873 else if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
2874 {
2875 bo->b.map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, wined3d_resource_gl_map_flags(bo, flags)));
2876 }
2877 else
2878 {
2879 bo->b.map_ptr = GL_EXTCALL(glMapBuffer(bo->binding, wined3d_resource_gl_legacy_map_flags(flags)));
2880 }
2881
2882 if (bo->b.map_ptr)
2883 adapter_adjust_mapped_memory(device_gl->d.adapter, bo->size);
2884
2885 wined3d_context_gl_bind_bo(context_gl, bo->binding, 0);
2886 checkGLcall("Map buffer object");
2887
2888 return bo->b.map_ptr;
2889}
static void list_init(struct list_entry *head)
Definition: list.h:51
void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo)
Definition: context_gl.c:3097
void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2653
void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id)
Definition: context_gl.c:2629
static void * wined3d_allocator_chunk_gl_map(struct wined3d_allocator_chunk_gl *chunk_gl, struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2736
bool wined3d_device_gl_create_bo(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo)
Definition: device.c:1335
GLbitfield wined3d_resource_gl_map_flags(const struct wined3d_bo_gl *bo, DWORD d3d_flags)
Definition: resource.c:373
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags)
Definition: resource.c:391
unsigned int GLbitfield
Definition: gl.h:152
LOCAL struct ga_flags * gl_flags
Definition: mkisofs.c:999
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
struct wined3d_allocator_block * memory
Definition: wined3d_gl.h:419
uint64_t command_fence_id
Definition: wined3d_gl.h:426
GLsizeiptr size
Definition: wined3d_gl.h:421
GLbitfield flags
Definition: wined3d_gl.h:425
GLenum usage
Definition: wined3d_gl.h:423
struct wined3d_device d
Definition: wined3d_gl.h:847
uint64_t completed_fence_id
Definition: wined3d_gl.h:854
uint64_t current_fence_id
Definition: wined3d_gl.h:855
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:953
#define WINED3D_MAP_NOOVERWRITE
Definition: wined3d.h:952
@ ARB_BUFFER_STORAGE
Definition: wined3d_gl.h:55

Referenced by wined3d_context_gl_map_bo_address().

◆ wined3d_bo_gl_unmap()

static void wined3d_bo_gl_unmap ( struct wined3d_bo_gl *  bo,
struct wined3d_context_gl *  context_gl 
)
static

Definition at line 2891 of file context_gl.c.

2892{
2893 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2894
2895 if (context_gl->c.d3d_info->persistent_map
2896 && context_gl->c.device->adapter->mapped_size <= MAX_PERSISTENT_MAPPED_BYTES)
2897 {
2898 TRACE("Not unmapping BO %p.\n", bo);
2899 return;
2900 }
2901
2902 wined3d_device_bo_map_lock(context_gl->c.device);
2903 /* The mapping is still in use by the client (viz. for an accelerated
2904 * NOOVERWRITE map). The client will trigger another unmap request when the
2905 * d3d application requests to unmap the BO. */
2906 if (bo->b.client_map_count)
2907 {
2908 wined3d_device_bo_map_unlock(context_gl->c.device);
2909 assert(context_gl->c.d3d_info->persistent_map);
2910 TRACE("BO %p is still in use by a client thread; not unmapping.\n", bo);
2911 return;
2912 }
2913 bo->b.map_ptr = NULL;
2914 wined3d_device_bo_map_unlock(context_gl->c.device);
2915
2916 if (bo->memory)
2917 {
2918 struct wined3d_allocator_chunk_gl *chunk_gl = wined3d_allocator_chunk_gl(bo->memory->chunk);
2919
2920 wined3d_allocator_chunk_gl_unmap(chunk_gl, context_gl);
2921 return;
2922 }
2923
2924 wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
2925 GL_EXTCALL(glUnmapBuffer(bo->binding));
2926 wined3d_context_gl_bind_bo(context_gl, bo->binding, 0);
2927 checkGLcall("Unmap buffer object");
2928
2929 adapter_adjust_mapped_memory(context_gl->c.device->adapter, -bo->size);
2930}
static void wined3d_allocator_chunk_gl_unmap(struct wined3d_allocator_chunk_gl *chunk_gl, struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2776
#define assert(_expr)
Definition: assert.h:32
static void wined3d_device_bo_map_lock(struct wined3d_device *device)
static void wined3d_device_bo_map_unlock(struct wined3d_device *device)
#define MAX_PERSISTENT_MAPPED_BYTES

Referenced by wined3d_context_gl_unmap_bo_address().

◆ wined3d_check_gl_call()

void wined3d_check_gl_call ( const struct wined3d_gl_info *  gl_info,
const char *  file,
unsigned int  line,
const char *  name 
)

Definition at line 1831 of file context_gl.c.

1833{
1834 GLint err;
1835
1836 if (gl_info->supported[ARB_DEBUG_OUTPUT] || (err = gl_info->gl_ops.gl.p_glGetError()) == GL_NO_ERROR)
1837 {
1838 TRACE("%s call ok %s / %u.\n", name, file, line);
1839 return;
1840 }
1841
1842 do
1843 {
1844 ERR(">>>>>>> %s (%#x) from %s @ %s / %u.\n",
1846 err = gl_info->gl_ops.gl.p_glGetError();
1847 } while (err != GL_NO_ERROR);
1848}
const char * debug_glerror(GLenum error)
Definition: utils.c:5445
#define GL_NO_ERROR
Definition: gl.h:693
#define err(...)
Definition: fci.c:123
Definition: parser.c:49

◆ wined3d_context_gl_acquire()

struct wined3d_context * wined3d_context_gl_acquire ( const struct wined3d_device *  device,
struct wined3d_texture *  texture,
unsigned int  sub_resource_idx 
)

Definition at line 4319 of file context_gl.c.

4321{
4322 struct wined3d_context_gl *current_context = wined3d_context_gl_get_current();
4323 struct wined3d_context_gl *context_gl;
4324
4325 TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
4326
4327 if (current_context && current_context->c.destroyed)
4328 current_context = NULL;
4329
4330 if (!texture)
4331 {
4332 if (current_context
4333 && current_context->c.device == device)
4334 {
4335 texture = current_context->c.current_rt.texture;
4336 sub_resource_idx = current_context->c.current_rt.sub_resource_idx;
4337 }
4338 else
4339 {
4340 struct wined3d_swapchain *swapchain = device->swapchains[0];
4341
4342 if (swapchain->back_buffers)
4343 texture = swapchain->back_buffers[0];
4344 else
4345 texture = swapchain->front_buffer;
4346 sub_resource_idx = 0;
4347 }
4348 }
4349
4350 if (current_context && current_context->c.current_rt.texture == texture)
4351 {
4352 context_gl = current_context;
4353 }
4354 else if (!wined3d_resource_is_offscreen(&texture->resource))
4355 {
4356 TRACE("Rendering onscreen.\n");
4357
4358 if (!(context_gl = wined3d_swapchain_gl_get_context(wined3d_swapchain_gl(texture->swapchain))))
4359 return NULL;
4360 }
4361 else
4362 {
4363 TRACE("Rendering offscreen.\n");
4364
4365 /* Stay with the current context if possible. Otherwise use the
4366 * context for the primary swapchain. */
4367 if (current_context && current_context->c.device == device)
4368 context_gl = current_context;
4369 else if (!(context_gl = wined3d_swapchain_gl_get_context(wined3d_swapchain_gl(device->swapchains[0]))))
4370 return NULL;
4371 }
4372
4373 wined3d_context_gl_activate(context_gl, texture, sub_resource_idx);
4374
4375 return &context_gl->c;
4376}
static void wined3d_context_gl_activate(struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context_gl.c:4293
struct wined3d_context_gl * wined3d_context_gl_get_current(void)
Definition: context_gl.c:1566
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:406
struct wined3d_texture ** back_buffers
struct wined3d_texture * front_buffer
struct wined3d_context_gl * wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl)
Definition: swapchain.c:1798

Referenced by adapter_gl_acquire_context().

◆ wined3d_context_gl_activate()

static void wined3d_context_gl_activate ( struct wined3d_context_gl *  context_gl,
struct wined3d_texture *  texture,
unsigned int  sub_resource_idx 
)
static

Definition at line 4293 of file context_gl.c.

4295{
4296 wined3d_context_gl_enter(context_gl);
4297 if (texture && texture->swapchain && texture->swapchain != context_gl->c.swapchain)
4298 {
4299 TRACE("Switching context_gl %p from swapchain %p to swapchain %p.\n",
4300 context_gl, context_gl->c.swapchain, texture->swapchain);
4301 context_gl->c.swapchain = texture->swapchain;
4302 }
4304 wined3d_context_gl_setup_target(context_gl, texture, sub_resource_idx);
4305 if (!context_gl->valid)
4306 return;
4307
4308 if (context_gl != wined3d_context_gl_get_current())
4309 {
4310 if (!wined3d_context_gl_set_current(context_gl))
4311 ERR("Failed to activate the new context.\n");
4312 }
4313 else if (context_gl->needs_set)
4314 {
4316 }
4317}
static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1261
static void wined3d_context_gl_enter(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1663
static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context_gl.c:4262
static void wined3d_context_gl_update_window(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1333
uint32_t needs_set
Definition: wined3d_gl.h:611

Referenced by wined3d_context_gl_acquire(), and wined3d_context_gl_reacquire().

◆ wined3d_context_gl_active_texture()

void wined3d_context_gl_active_texture ( struct wined3d_context_gl *  context_gl,
const struct wined3d_gl_info *  gl_info,
unsigned int  unit 
)

Definition at line 2489 of file context_gl.c.

2491{
2493 checkGLcall("glActiveTexture");
2494 context_gl->active_texture = unit;
2495}
#define GL_TEXTURE0
Definition: gl.h:1750
GLAPI void GLAPIENTRY glActiveTexture(GLenum texture)
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392
unsigned int active_texture
Definition: wined3d_gl.h:621

Referenced by glsl_blitter_upload_palette(), wined3d_context_gl_apply_blit_state(), wined3d_context_gl_bind_shader_resources(), wined3d_context_gl_init(), wined3d_device_gl_create_dummy_textures(), and wined3d_shader_resource_view_gl_bind().

◆ wined3d_context_gl_alloc_fence()

void wined3d_context_gl_alloc_fence ( struct wined3d_context_gl *  context_gl,
struct wined3d_fence *  fence 
)

Definition at line 925 of file context_gl.c.

926{
927 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
928
929 if (context_gl->free_fence_count)
930 {
931 fence->object = context_gl->free_fences[--context_gl->free_fence_count];
932 }
933 else
934 {
935 if (gl_info->supported[ARB_SYNC])
936 {
937 /* Using ARB_sync, not much to do here. */
938 fence->object.sync = NULL;
939 TRACE("Allocated sync object in context %p.\n", context_gl);
940 }
941 else if (gl_info->supported[APPLE_FENCE])
942 {
943 GL_EXTCALL(glGenFencesAPPLE(1, &fence->object.id));
944 checkGLcall("glGenFencesAPPLE");
945
946 TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
947 }
948 else if(gl_info->supported[NV_FENCE])
949 {
950 GL_EXTCALL(glGenFencesNV(1, &fence->object.id));
951 checkGLcall("glGenFencesNV");
952
953 TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
954 }
955 else
956 {
957 WARN("Fences not supported, not allocating fence.\n");
958 fence->object.id = 0;
959 }
960 }
961
962 fence->context_gl = context_gl;
963 list_add_head(&context_gl->fences, &fence->entry);
964}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
union wined3d_gl_fence_object * free_fences
Definition: wined3d_gl.h:658
struct list fences
Definition: wined3d_gl.h:649
unsigned int free_fence_count
Definition: wined3d_gl.h:660
union wined3d_gl_fence_object object
Definition: wined3d_gl.h:457
struct list entry
Definition: wined3d_gl.h:456
struct wined3d_context_gl * context_gl
Definition: wined3d_gl.h:458
@ APPLE_FENCE
Definition: wined3d_gl.h:46
@ ARB_SYNC
Definition: wined3d_gl.h:122
@ NV_FENCE
Definition: wined3d_gl.h:205

Referenced by wined3d_fence_issue().

◆ wined3d_context_gl_alloc_occlusion_query()

void wined3d_context_gl_alloc_occlusion_query ( struct wined3d_context_gl *  context_gl,
struct wined3d_occlusion_query *  query 
)

Definition at line 877 of file context_gl.c.

879{
880 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
881
882 if (context_gl->free_occlusion_query_count)
883 {
884 query->id = context_gl->free_occlusion_queries[--context_gl->free_occlusion_query_count];
885 }
886 else
887 {
888 if (gl_info->supported[ARB_OCCLUSION_QUERY])
889 {
890 GL_EXTCALL(glGenQueries(1, &query->id));
891 checkGLcall("glGenQueries");
892
893 TRACE("Allocated occlusion query %u in context %p.\n", query->id, context_gl);
894 }
895 else
896 {
897 WARN("Occlusion queries not supported, not allocating query id.\n");
898 query->id = 0;
899 }
900 }
901
902 query->context_gl = context_gl;
903 list_add_head(&context_gl->occlusion_queries, &query->entry);
904}
struct list occlusion_queries
Definition: wined3d_gl.h:648
unsigned int free_occlusion_query_count
Definition: wined3d_gl.h:656
GLuint * free_occlusion_queries
Definition: wined3d_gl.h:654
@ ARB_OCCLUSION_QUERY
Definition: wined3d_gl.h:97

Referenced by wined3d_occlusion_query_ops_issue().

◆ wined3d_context_gl_alloc_pipeline_statistics_query()

void wined3d_context_gl_alloc_pipeline_statistics_query ( struct wined3d_context_gl *  context_gl,
struct wined3d_pipeline_statistics_query *  query 
)

Definition at line 1065 of file context_gl.c.

1067{
1068 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1069
1071 {
1073 }
1074 else
1075 {
1076 GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
1077 checkGLcall("glGenQueries");
1078 }
1079
1080 query->context_gl = context_gl;
1081 list_add_head(&context_gl->pipeline_statistics_queries, &query->entry);
1082}
union wined3d_gl_pipeline_statistics_query * free_pipeline_statistics_queries
Definition: wined3d_gl.h:670
struct list pipeline_statistics_queries
Definition: wined3d_gl.h:652
unsigned int free_pipeline_statistics_query_count
Definition: wined3d_gl.h:672

Referenced by wined3d_pipeline_query_ops_issue().

◆ wined3d_context_gl_alloc_so_statistics_query()

void wined3d_context_gl_alloc_so_statistics_query ( struct wined3d_context_gl *  context_gl,
struct wined3d_so_statistics_query *  query 
)

Definition at line 1024 of file context_gl.c.

1026{
1027 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1028
1029 if (context_gl->free_so_statistics_query_count)
1030 {
1031 query->u = context_gl->free_so_statistics_queries[--context_gl->free_so_statistics_query_count];
1032 }
1033 else
1034 {
1035 GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
1036 checkGLcall("glGenQueries");
1037
1038 TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
1039 query->u.id[0], query->u.id[1], context_gl);
1040 }
1041
1042 query->context_gl = context_gl;
1043 list_add_head(&context_gl->so_statistics_queries, &query->entry);
1044}
unsigned int free_so_statistics_query_count
Definition: wined3d_gl.h:668
struct list so_statistics_queries
Definition: wined3d_gl.h:651
union wined3d_gl_so_statistics_query * free_so_statistics_queries
Definition: wined3d_gl.h:666

Referenced by wined3d_so_statistics_query_ops_issue().

◆ wined3d_context_gl_alloc_timestamp_query()

void wined3d_context_gl_alloc_timestamp_query ( struct wined3d_context_gl *  context_gl,
struct wined3d_timestamp_query *  query 
)

Definition at line 985 of file context_gl.c.

987{
988 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
989
990 if (context_gl->free_timestamp_query_count)
991 {
992 query->id = context_gl->free_timestamp_queries[--context_gl->free_timestamp_query_count];
993 }
994 else
995 {
996 GL_EXTCALL(glGenQueries(1, &query->id));
997 checkGLcall("glGenQueries");
998
999 TRACE("Allocated timestamp query %u in context %p.\n", query->id, context_gl);
1000 }
1001
1002 query->context_gl = context_gl;
1003 list_add_head(&context_gl->timestamp_queries, &query->entry);
1004}
GLuint * free_timestamp_queries
Definition: wined3d_gl.h:662
unsigned int free_timestamp_query_count
Definition: wined3d_gl.h:664
struct list timestamp_queries
Definition: wined3d_gl.h:650

Referenced by wined3d_timestamp_query_ops_issue().

◆ wined3d_context_gl_allocate_vram_chunk_buffer()

GLuint wined3d_context_gl_allocate_vram_chunk_buffer ( struct wined3d_context_gl *  context_gl,
unsigned int  pool,
size_t  size 
)

Definition at line 2707 of file context_gl.c.

2709{
2710 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2712 GLuint id = 0;
2713
2714 TRACE("context_gl %p, pool %u, size %Iu.\n", context_gl, pool, size);
2715
2716 GL_EXTCALL(glGenBuffers(1, &id));
2717 if (!id)
2718 {
2719 checkGLcall("buffer object creation");
2720 return 0;
2721 }
2723
2727 GL_EXTCALL(glBufferStorage(GL_PIXEL_UNPACK_BUFFER, size, NULL, flags));
2728
2729 checkGLcall("buffer object creation");
2730
2731 TRACE("Created buffer object %u.\n", id);
2732
2733 return id;
2734}
unsigned int GLuint
Definition: gl.h:159
GLsizeiptr size
Definition: glext.h:5919
GLuint id
Definition: glext.h:5910
#define GL_DYNAMIC_STORAGE_BIT
Definition: wgl.h:1199

Referenced by wined3d_allocator_gl_create_chunk(), wined3d_device_gl_allocate_memory(), and wined3d_device_gl_create_bo().

◆ wined3d_context_gl_apply_blit_state()

void wined3d_context_gl_apply_blit_state ( struct wined3d_context_gl *  context_gl,
const struct wined3d_device *  device 
)

Definition at line 3156 of file context_gl.c.

3157{
3158 struct wined3d_context *context = &context_gl->c;
3159 const struct wined3d_gl_info *gl_info;
3160 SIZE rt_size;
3161
3162 TRACE("Setting up context %p for blitting.\n", context);
3163
3164 gl_info = context_gl->gl_info;
3165
3166 wined3d_context_gl_get_rt_size(context_gl, &rt_size);
3167
3168 if (context->last_was_blit)
3169 {
3170 if (context_gl->blit_size.cx != rt_size.cx || context_gl->blit_size.cy != rt_size.cy)
3171 {
3172 gl_info->gl_ops.gl.p_glViewport(0, 0, rt_size.cx, rt_size.cy);
3173 context->viewport_count = WINED3D_MAX_VIEWPORTS;
3174 context_gl->blit_size = rt_size;
3175 /* No need to dirtify here, the states are still dirtified because
3176 * they weren't applied since the last context_apply_blit_state()
3177 * call. */
3178 }
3179 checkGLcall("blit state application");
3180 TRACE("Context is already set up for blitting, nothing to do.\n");
3181 return;
3182 }
3183 context->last_was_blit = TRUE;
3184
3185 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
3186 GL_EXTCALL(glBindSampler(0, 0));
3187 wined3d_context_gl_active_texture(context_gl, gl_info, 0);
3188
3191
3193 {
3194 gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
3196 }
3197 gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
3198 gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3200 gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE);
3201 gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
3203 gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST);
3204 gl_info->gl_ops.gl.p_glDisable(GL_STENCIL_TEST);
3206 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
3207 {
3208 gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
3210 }
3211
3212 context->last_was_rhw = TRUE;
3213 context_invalidate_state(context, STATE_VDECL); /* because of last_was_rhw = TRUE */
3214
3217
3218 /* FIXME: Make draw_textured_quad() able to work with a upper left origin. */
3219 if (gl_info->supported[ARB_CLIP_CONTROL])
3221 gl_info->gl_ops.gl.p_glViewport(0, 0, rt_size.cx, rt_size.cy);
3222 context->viewport_count = WINED3D_MAX_VIEWPORTS;
3224
3225 device->shader_backend->shader_disable(device->shader_priv, context);
3226
3227 context_gl->blit_size = rt_size;
3228
3229 checkGLcall("blit state application");
3230}
void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t enable_mask)
Definition: context_gl.c:2408
static void wined3d_context_gl_get_rt_size(const struct wined3d_context_gl *context_gl, SIZE *size)
Definition: context_gl.c:2387
void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context_gl.c:2489
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:66
#define GL_TRUE
Definition: gl.h:174
#define GL_DEPTH_TEST
Definition: gl.h:301
#define GL_STENCIL_TEST
Definition: gl.h:449
#define GL_ALPHA_TEST
Definition: gl.h:366
#define GL_CULL_FACE
Definition: gl.h:276
#define GL_BLEND
Definition: gl.h:371
#define GL_SCISSOR_TEST
Definition: gl.h:589
#define GL_FRAMEBUFFER_SRGB
Definition: glext.h:1758
#define GL_LOWER_LEFT
Definition: glext.h:461
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
#define GL_NEGATIVE_ONE_TO_ONE
Definition: wgl.h:2715
@ WINED3D_RS_SRGBWRITEENABLE
Definition: wined3d.h:400
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:346
@ WINED3D_RS_ALPHATESTENABLE
Definition: wined3d.h:301
#define WINED3D_MAX_VIEWPORTS
Definition: wined3d.h:1590
@ ARB_SAMPLER_OBJECTS
Definition: wined3d_gl.h:106
@ ARB_FRAMEBUFFER_SRGB
Definition: wined3d_gl.h:85
@ WINED3D_GL_LEGACY_CONTEXT
Definition: wined3d_gl.h:232
@ ARB_CLIP_CONTROL
Definition: wined3d_gl.h:58
#define STATE_DEPTH_STENCIL
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
#define STATE_COMPUTE_SHADER_RESOURCE_BINDING
#define STATE_RASTERIZER
#define STATE_VIEWPORT
#define STATE_RENDER(a)
#define STATE_BLEND

Referenced by glsl_blitter_blit().

◆ wined3d_context_gl_apply_clear_state()

BOOL wined3d_context_gl_apply_clear_state ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state,
unsigned int  rt_count,
const struct wined3d_fb_state *  fb 
)

Definition at line 3250 of file context_gl.c.

3252{
3253 struct wined3d_rendertarget_view * const *rts = fb->render_targets;
3254 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3255 struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
3256 uint32_t rt_mask = 0, *cur_mask;
3257 unsigned int i;
3258
3259 if (isStateDirty(&context_gl->c, STATE_FRAMEBUFFER) || fb != &state->fb
3260 || rt_count != gl_info->limits.buffers)
3261 {
3262 struct wined3d_rendertarget_info ds_info = {{0}};
3263
3264 if (!have_framebuffer_attachment(rt_count, rts, dsv))
3265 {
3266 WARN("Invalid render target config, need at least one attachment.\n");
3267 return FALSE;
3268 }
3269
3270 if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))
3271 {
3272 memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets));
3273 for (i = 0; i < rt_count; ++i)
3274 {
3275 if (rts[i])
3276 {
3278 context_gl->blit_targets[i].gl_view = rtv_gl->gl_view;
3279 context_gl->blit_targets[i].resource = rtv_gl->v.resource;
3280 context_gl->blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx;
3281 context_gl->blit_targets[i].layer_count = rtv_gl->v.layer_count;
3282 }
3283 if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3284 rt_mask |= (1u << i);
3285 }
3286
3287 if (dsv)
3288 {
3290 ds_info.gl_view = dsv_gl->gl_view;
3291 ds_info.resource = dsv_gl->v.resource;
3292 ds_info.sub_resource_idx = dsv_gl->v.sub_resource_idx;
3293 ds_info.layer_count = dsv_gl->v.layer_count;
3294 }
3295
3296 wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info,
3297 rt_count ? rts[0]->resource->draw_binding : 0, dsv ? dsv->resource->draw_binding : 0);
3298 }
3299 else
3300 {
3304 }
3305
3306 /* If the framebuffer is not the device's fb the device's fb has to be reapplied
3307 * next draw. Otherwise we could mark the framebuffer state clean here, once the
3308 * state management allows this */
3310 }
3311 else if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))
3312 {
3313 for (i = 0; i < rt_count; ++i)
3314 {
3315 if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3316 rt_mask |= (1u << i);
3317 }
3318 }
3319 else
3320 {
3321 rt_mask = wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, rt_count ? rts[0]->resource : NULL);
3322 }
3323
3324 cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask;
3325
3326 if (rt_mask != *cur_mask)
3327 {
3328 wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask);
3329 *cur_mask = rt_mask;
3331 }
3332
3334
3335 context_gl->c.last_was_blit = FALSE;
3336 context_gl->c.last_was_ffp_blit = FALSE;
3337
3338 /* Blending and clearing should be orthogonal, but tests on the nvidia
3339 * driver show that disabling blending when clearing improves the clearing
3340 * performance incredibly. */
3341 gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
3342 gl_info->gl_ops.gl.p_glEnable(GL_SCISSOR_TEST);
3343 if (rt_count && gl_info->supported[ARB_FRAMEBUFFER_SRGB])
3344 {
3345 if (needs_srgb_write(context_gl->c.d3d_info, state, fb))
3346 gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB);
3347 else
3348 gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
3350 }
3351 checkGLcall("setting up state for clear");
3352
3353 context_invalidate_state(&context_gl->c, STATE_BLEND);
3356
3357 return TRUE;
3358}
static uint32_t wined3d_context_gl_generate_rt_mask_no_fbo(const struct wined3d_context_gl *context_gl, struct wined3d_resource *rt)
Definition: context_gl.c:3144
#define STATE_SCISSORRECT
static BOOL needs_srgb_write(const struct wined3d_d3d_info *d3d_info, const struct wined3d_state *state, const struct wined3d_fb_state *fb)

Referenced by ffp_blitter_clear_rendertargets().

◆ wined3d_context_gl_apply_compute_state()

static void wined3d_context_gl_apply_compute_state ( struct wined3d_context_gl *  context_gl,
const struct wined3d_device *  device,
const struct wined3d_state *  state 
)
static

Definition at line 4170 of file context_gl.c.

4172{
4173 const struct wined3d_state_entry *state_table = context_gl->c.state_table;
4174 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4175 unsigned int state_id, i;
4176
4179 state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4180
4181 for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context_gl->c.dirty_compute_states); ++i)
4182 {
4183 unsigned int dirty_mask = context_gl->c.dirty_compute_states[i];
4184
4185 while (dirty_mask)
4186 {
4187 unsigned int current_state_id = state_id + wined3d_bit_scan(&dirty_mask);
4188 state_table[current_state_id].apply(&context_gl->c, state, current_state_id);
4189 }
4190 state_id += sizeof(*context_gl->c.dirty_compute_states) * CHAR_BIT;
4191 }
4192 memset(context_gl->c.dirty_compute_states, 0, sizeof(*context_gl->c.dirty_compute_states));
4193
4194 device->shader_backend->shader_apply_compute_state(device->shader_priv, &context_gl->c, state);
4195
4196 if (context_gl->c.update_compute_shader_resource_bindings)
4197 {
4199 context_gl->c.update_compute_shader_resource_bindings = 0;
4200 if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4201 context_gl->c.update_shader_resource_bindings = 1;
4202 }
4203
4204 if (context_gl->c.update_compute_unordered_access_view_bindings)
4205 {
4208 state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4209 context_gl->c.update_compute_unordered_access_view_bindings = 0;
4210 context_gl->c.update_unordered_access_view_bindings = 1;
4211 }
4212
4213 /* Updates to currently bound render targets aren't necessarily coherent
4214 * between the graphics and compute pipelines. Unbind any currently bound
4215 * FBO here to ensure preceding updates to its attachments by the graphics
4216 * pipeline are visible to the compute pipeline.
4217 *
4218 * Without this, the bloom effect in Nier:Automata is too bright on the
4219 * Mesa radeonsi driver, and presumably on other Mesa based drivers. */
4222
4223 context_gl->c.last_was_blit = FALSE;
4224 context_gl->c.last_was_ffp_blit = FALSE;
4225 context_gl->c.shader_update_mask &= ~(1u << WINED3D_SHADER_TYPE_COMPUTE);
4226}
static void wined3d_context_gl_bind_fbo(struct wined3d_context_gl *context_gl, GLenum target, GLuint fbo)
Definition: context_gl.c:88
@ WINED3D_PIPELINE_COMPUTE
Definition: wined3d.h:856
#define STATE_COMPUTE_OFFSET

Referenced by dispatch_compute().

◆ wined3d_context_gl_apply_draw_buffers()

static void wined3d_context_gl_apply_draw_buffers ( struct wined3d_context_gl *  context_gl,
uint32_t  rt_mask 
)
static

Definition at line 2447 of file context_gl.c.

2448{
2449 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2450 GLenum draw_buffers[WINED3D_MAX_RENDER_TARGETS];
2451
2452 if (!rt_mask)
2453 {
2454 gl_info->gl_ops.gl.p_glDrawBuffer(GL_NONE);
2455 }
2456 else if (is_rt_mask_onscreen(rt_mask))
2457 {
2458 gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffer_from_rt_mask(rt_mask));
2459 }
2460 else
2461 {
2462 unsigned int i = 0;
2463
2464 while (rt_mask)
2465 {
2466 if (rt_mask & 1)
2467 draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
2468 else
2469 draw_buffers[i] = GL_NONE;
2470
2471 rt_mask >>= 1;
2472 ++i;
2473 }
2474
2475 if (gl_info->supported[ARB_DRAW_BUFFERS])
2476 {
2477 GL_EXTCALL(glDrawBuffers(i, draw_buffers));
2478 }
2479 else
2480 {
2481 gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]);
2482 }
2483 }
2484
2485 checkGLcall("apply draw buffers");
2486}
static GLenum draw_buffer_from_rt_mask(DWORD rt_mask)
Definition: context_gl.c:2441
static BOOL is_rt_mask_onscreen(DWORD rt_mask)
Definition: context_gl.c:2436
#define WINED3D_MAX_RENDER_TARGETS
Definition: wined3d.h:1606
@ ARB_DRAW_BUFFERS
Definition: wined3d_gl.h:70

Referenced by context_gl_apply_texture_draw_state(), context_state_drawbuf(), context_state_fb(), and wined3d_context_gl_apply_clear_state().

◆ wined3d_context_gl_apply_fbo_entry()

static void wined3d_context_gl_apply_fbo_entry ( struct wined3d_context_gl *  context_gl,
GLenum  target,
struct fbo_entry *  entry 
)
static

Definition at line 768 of file context_gl.c.

770{
771 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
772 GLuint read_binding, draw_binding;
773 unsigned int i;
774
776 {
777 wined3d_context_gl_bind_fbo(context_gl, target, entry->id);
778 return;
779 }
780
781 read_binding = context_gl->fbo_read_binding;
782 draw_binding = context_gl->fbo_draw_binding;
784
786 {
787 GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
788 GL_FRAMEBUFFER_DEFAULT_WIDTH, gl_info->limits.framebuffer_width));
789 GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
790 GL_FRAMEBUFFER_DEFAULT_HEIGHT, gl_info->limits.framebuffer_height));
791 GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_LAYERS, 1));
792 GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1));
793 }
794
795 /* Apply render targets */
796 for (i = 0; i < gl_info->limits.buffers; ++i)
797 {
799 &entry->key.objects[i + 1], entry->key.rb_namespace & (1 << (i + 1)));
800 }
801
803 &entry->key.objects[0], entry->key.rb_namespace & 0x1, entry->flags);
804
805 /* Set valid read and draw buffer bindings to satisfy pedantic pre-ES2_compatibility
806 * GL contexts requirements. */
807 gl_info->gl_ops.gl.p_glReadBuffer(GL_NONE);
809 if (target != GL_FRAMEBUFFER)
810 {
812 wined3d_context_gl_bind_fbo(context_gl, GL_DRAW_FRAMEBUFFER, draw_binding);
813 else
814 wined3d_context_gl_bind_fbo(context_gl, GL_READ_FRAMEBUFFER, read_binding);
815 }
816
818}
static void wined3d_context_gl_attach_depth_stencil_fbo(struct wined3d_context_gl *context_gl, GLenum fbo_target, const struct wined3d_fbo_resource *resource, BOOL rb_namespace, uint32_t flags)
Definition: context_gl.c:217
static void wined3d_context_gl_attach_surface_fbo(struct wined3d_context_gl *context_gl, GLenum fbo_target, unsigned int idx, const struct wined3d_fbo_resource *resource, BOOL rb_namespace)
Definition: context_gl.c:257
static void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer)
Definition: context_gl.c:470
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
GLuint fbo_read_binding
Definition: wined3d_gl.h:642
GLuint fbo_draw_binding
Definition: wined3d_gl.h:643
#define GL_FRAMEBUFFER_DEFAULT_HEIGHT
Definition: wgl.h:1495
#define GL_FRAMEBUFFER_DEFAULT_LAYERS
Definition: wgl.h:1496
#define GL_FRAMEBUFFER_DEFAULT_SAMPLES
Definition: wgl.h:1497
#define GL_FRAMEBUFFER_DEFAULT_WIDTH
Definition: wgl.h:1498
#define WINED3D_FBO_ENTRY_FLAG_ATTACHED
Definition: wined3d_gl.h:582

Referenced by wined3d_context_gl_apply_fbo_state().

◆ wined3d_context_gl_apply_fbo_state()

static void wined3d_context_gl_apply_fbo_state ( struct wined3d_context_gl *  context_gl,
GLenum  target,
const struct wined3d_rendertarget_info *  render_targets,
const struct wined3d_rendertarget_info *  depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 821 of file context_gl.c.

824{
825 struct fbo_entry *entry, *entry2;
826
827 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_destroy_list, struct fbo_entry, entry)
828 {
830 }
831
832 if (context_gl->rebind_fbo)
833 {
835 context_gl->rebind_fbo = FALSE;
836 }
837
838 if (color_location == WINED3D_LOCATION_DRAWABLE)
839 {
840 context_gl->current_fbo = NULL;
841 wined3d_context_gl_bind_fbo(context_gl, target, 0);
842 }
843 else
844 {
845 context_gl->current_fbo = wined3d_context_gl_find_fbo_entry(context_gl,
846 target, render_targets, depth_stencil, color_location, ds_location);
847 wined3d_context_gl_apply_fbo_entry(context_gl, target, context_gl->current_fbo);
848 }
849}
static void wined3d_context_gl_apply_fbo_entry(struct wined3d_context_gl *context_gl, GLenum target, struct fbo_entry *entry)
Definition: context_gl.c:768
static void wined3d_context_gl_destroy_fbo_entry(struct wined3d_context_gl *context_gl, struct fbo_entry *entry)
Definition: context_gl.c:622
static struct fbo_entry * wined3d_context_gl_find_fbo_entry(struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context_gl.c:635
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:766
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
Definition: wined3d_gl.h:587
struct list fbo_destroy_list
Definition: wined3d_gl.h:640
uint32_t rebind_fbo
Definition: wined3d_gl.h:610

Referenced by context_state_fb(), wined3d_context_gl_apply_clear_state(), and wined3d_context_gl_apply_fbo_state_explicit().

◆ wined3d_context_gl_apply_fbo_state_explicit()

void wined3d_context_gl_apply_fbo_state_explicit ( struct wined3d_context_gl *  context_gl,
GLenum  target,
struct wined3d_resource *  rt,
unsigned int  rt_sub_resource_idx,
struct wined3d_resource *  ds,
unsigned int  ds_sub_resource_idx,
uint32_t  location 
)

Definition at line 852 of file context_gl.c.

855{
856 struct wined3d_rendertarget_info ds_info = {{0}};
857
858 memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets));
859 if (rt)
860 {
861 context_gl->blit_targets[0].resource = rt;
862 context_gl->blit_targets[0].sub_resource_idx = rt_sub_resource_idx;
863 context_gl->blit_targets[0].layer_count = 1;
864 }
865
866 if (ds)
867 {
868 ds_info.resource = ds;
869 ds_info.sub_resource_idx = ds_sub_resource_idx;
870 ds_info.layer_count = 1;
871 }
872
873 wined3d_context_gl_apply_fbo_state(context_gl, target, context_gl->blit_targets, &ds_info, location, location);
874}

Referenced by context_gl_apply_texture_draw_state(), texture2d_blt_fbo(), texture2d_depth_blt_fbo(), and texture2d_read_from_framebuffer().

◆ wined3d_context_gl_attach_depth_stencil_fbo()

static void wined3d_context_gl_attach_depth_stencil_fbo ( struct wined3d_context_gl *  context_gl,
GLenum  fbo_target,
const struct wined3d_fbo_resource *  resource,
BOOL  rb_namespace,
uint32_t  flags 
)
static

Definition at line 217 of file context_gl.c.

220{
221 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
222
223 if (resource->object)
224 {
225 TRACE("Attach depth stencil %u.\n", resource->object);
226
227 if (rb_namespace)
228 {
229 context_attach_depth_stencil_rb(gl_info, fbo_target,
230 flags, resource->object);
231 }
232 else
233 {
236
239 }
240
243
246 }
247 else
248 {
249 TRACE("Attach depth stencil 0.\n");
250
253 }
254}
static void context_attach_depth_stencil_rb(const struct wined3d_gl_info *gl_info, GLenum fbo_target, uint32_t flags, GLuint rb)
Definition: context_gl.c:155
static void wined3d_context_gl_attach_gl_texture_fbo(struct wined3d_context_gl *context_gl, GLenum fbo_target, GLenum attachment, const struct wined3d_fbo_resource *resource)
Definition: context_gl.c:171

Referenced by wined3d_context_gl_apply_fbo_entry().

◆ wined3d_context_gl_attach_gl_texture_fbo()

static void wined3d_context_gl_attach_gl_texture_fbo ( struct wined3d_context_gl *  context_gl,
GLenum  fbo_target,
GLenum  attachment,
const struct wined3d_fbo_resource *  resource 
)
static

Definition at line 171 of file context_gl.c.

173{
174 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
175
176 if (!resource)
177 {
178 gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, GL_TEXTURE_2D, 0, 0);
179 }
180 else if (resource->layer == WINED3D_ALL_LAYERS)
181 {
182 if (!gl_info->fbo_ops.glFramebufferTexture)
183 {
184 FIXME("OpenGL implementation doesn't support glFramebufferTexture().\n");
185 return;
186 }
187
188 gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment,
189 resource->object, resource->level);
190 }
191 else if (resource->target == GL_TEXTURE_1D_ARRAY || resource->target == GL_TEXTURE_2D_ARRAY
192 || resource->target == GL_TEXTURE_3D)
193 {
194 if (!gl_info->fbo_ops.glFramebufferTextureLayer)
195 {
196 FIXME("OpenGL implementation doesn't support glFramebufferTextureLayer().\n");
197 return;
198 }
199
200 gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment,
201 resource->object, resource->level, resource->layer);
202 }
203 else if (resource->target == GL_TEXTURE_1D)
204 {
205 gl_info->fbo_ops.glFramebufferTexture1D(fbo_target, attachment,
206 resource->target, resource->object, resource->level);
207 }
208 else
209 {
210 gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment,
211 resource->target, resource->object, resource->level);
212 }
213 checkGLcall("attach texture to fbo");
214}
#define WINED3D_ALL_LAYERS
Definition: context_gl.c:35
#define GL_TEXTURE_3D
Definition: gl.h:1515

Referenced by wined3d_context_gl_attach_depth_stencil_fbo(), and wined3d_context_gl_attach_surface_fbo().

◆ wined3d_context_gl_attach_surface_fbo()

static void wined3d_context_gl_attach_surface_fbo ( struct wined3d_context_gl *  context_gl,
GLenum  fbo_target,
unsigned int  idx,
const struct wined3d_fbo_resource *  resource,
BOOL  rb_namespace 
)
static

Definition at line 257 of file context_gl.c.

259{
260 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
261
262 TRACE("Attach GL object %u to %u.\n", resource->object, idx);
263
264 if (resource->object)
265 {
266 if (rb_namespace)
267 {
268 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
269 GL_RENDERBUFFER, resource->object);
270 checkGLcall("glFramebufferRenderbuffer()");
271 }
272 else
273 {
275 }
276 }
277 else
278 {
280 }
281}

Referenced by wined3d_context_gl_apply_fbo_entry().

◆ wined3d_context_gl_bind_bo()

◆ wined3d_context_gl_bind_dummy_textures()

void wined3d_context_gl_bind_dummy_textures ( const struct wined3d_context_gl *  context_gl)

Definition at line 1790 of file context_gl.c.

1791{
1792 const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context_gl->c.device)->dummy_textures;
1793 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1794 unsigned int i;
1795
1796 for (i = 0; i < gl_info->limits.combined_samplers; ++i)
1797 {
1799
1800 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
1801 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
1802
1803 if (gl_info->supported[EXT_TEXTURE3D])
1804 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
1805
1806 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
1807 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
1808
1810 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
1811
1812 if (gl_info->supported[EXT_TEXTURE_ARRAY])
1813 {
1814 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
1815 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
1816 }
1817
1819 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
1820
1821 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
1822 {
1823 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
1824 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
1825 }
1826 }
1827
1828 checkGLcall("bind dummy textures");
1829}
const GLuint * textures
Definition: glext.h:8098
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
struct wined3d_dummy_textures dummy_textures
Definition: wined3d_gl.h:850
@ ARB_TEXTURE_BUFFER_OBJECT
Definition: wined3d_gl.h:125
@ EXT_TEXTURE3D
Definition: wined3d_gl.h:190
@ ARB_TEXTURE_CUBE_MAP_ARRAY
Definition: wined3d_gl.h:131

Referenced by wined3d_context_gl_init(), and wined3d_device_gl_create_dummy_textures().

◆ wined3d_context_gl_bind_fbo()

static void wined3d_context_gl_bind_fbo ( struct wined3d_context_gl *  context_gl,
GLenum  target,
GLuint  fbo 
)
static

Definition at line 88 of file context_gl.c.

89{
90 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
91
92 TRACE("context_gl %p, target %#x, fbo %u.\n", context_gl, target, fbo);
93
94 switch (target)
95 {
97 if (context_gl->fbo_read_binding == fbo)
98 return;
99 context_gl->fbo_read_binding = fbo;
100 break;
101
103 if (context_gl->fbo_draw_binding == fbo)
104 return;
105 context_gl->fbo_draw_binding = fbo;
106 break;
107
108 case GL_FRAMEBUFFER:
109 if (context_gl->fbo_read_binding == fbo
110 && context_gl->fbo_draw_binding == fbo)
111 return;
112 context_gl->fbo_read_binding = fbo;
113 context_gl->fbo_draw_binding = fbo;
114 break;
115
116 default:
117 FIXME("Unhandled target %#x.\n", target);
118 break;
119 }
120
121 gl_info->fbo_ops.glBindFramebuffer(target, fbo);
122 checkGLcall("glBindFramebuffer()");
123}

Referenced by wined3d_context_gl_apply_compute_state(), wined3d_context_gl_apply_fbo_entry(), wined3d_context_gl_apply_fbo_state(), wined3d_context_gl_destroy_fbo(), and wined3d_context_gl_reuse_fbo_entry().

◆ wined3d_context_gl_bind_shader_resources()

static void wined3d_context_gl_bind_shader_resources ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state,
enum wined3d_shader_type  shader_type 
)
static

Definition at line 3738 of file context_gl.c.

3740{
3741 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3742 unsigned int bind_idx, shader_sampler_count, base, count, i;
3743 const struct wined3d_device *device = context_gl->c.device;
3746 const struct wined3d_shader *shader;
3747 const unsigned int *tex_unit_map;
3748 struct wined3d_sampler *sampler;
3749
3750 if (!(shader = state->shader[shader_type]))
3751 {
3753 {
3754 uint32_t ffu_map = context_gl->c.fixed_function_usage_map;
3755
3756 while (ffu_map)
3757 {
3758 i = wined3d_bit_scan(&ffu_map);
3759 bind_idx = context_gl->tex_unit_map[i];
3760
3761 view = state->shader_resource_view[WINED3D_SHADER_TYPE_PIXEL][i];
3763
3764 if (view)
3765 {
3767 bind_idx, wined3d_sampler_gl(sampler), context_gl);
3768 }
3769 else
3770 {
3771 WARN("No resource view bound at index %u.\n", i);
3772 wined3d_context_gl_active_texture(context_gl, gl_info, bind_idx);
3774 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
3775 GL_EXTCALL(glBindSampler(bind_idx, 0));
3776 }
3777 }
3778 }
3779
3780 return;
3781 }
3782
3783 tex_unit_map = wined3d_context_gl_get_tex_unit_mapping(context_gl,
3784 &shader->reg_maps.shader_version, &base, &count);
3785
3786 shader_sampler_count = shader->reg_maps.sampler_map.count;
3787 if (shader_sampler_count > count)
3788 FIXME("Shader %p needs %u samplers, but only %u are supported.\n",
3789 shader, shader_sampler_count, count);
3790 count = min(shader_sampler_count, count);
3791
3792 for (i = 0; i < count; ++i)
3793 {
3794 entry = &shader->reg_maps.sampler_map.entries[i];
3795 bind_idx = base + entry->bind_idx;
3796 if (tex_unit_map)
3797 bind_idx = tex_unit_map[bind_idx];
3798
3799 if ((view = state->shader_resource_view[shader_type][entry->resource_idx]))
3800 {
3801 if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
3802 sampler = device->default_sampler;
3803 else if (!(sampler = state->sampler[shader_type][entry->sampler_idx]))
3804 sampler = device->null_sampler;
3806 bind_idx, wined3d_sampler_gl(sampler), context_gl);
3807 }
3808 else
3809 {
3810 WARN("No resource view bound at index %u, %u.\n", shader_type, entry->resource_idx);
3811 wined3d_context_gl_active_texture(context_gl, gl_info, bind_idx);
3813 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
3814 GL_EXTCALL(glBindSampler(bind_idx, 0));
3815 }
3816 }
3817}
const unsigned int * wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl, const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count)
Definition: context_gl.c:2350
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name)
Definition: context_gl.c:2507
void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit, struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl)
Definition: view.c:1274
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define min(a, b)
Definition: monoChain.cc:55
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS]
Definition: wined3d_gl.h:676

Referenced by context_apply_draw_state(), and wined3d_context_gl_apply_compute_state().

◆ wined3d_context_gl_bind_texture()

void wined3d_context_gl_bind_texture ( struct wined3d_context_gl *  context_gl,
GLenum  target,
GLuint  name 
)

Definition at line 2507 of file context_gl.c.

2508{
2509 const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context_gl->c.device)->dummy_textures;
2510 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2511 GLenum old_texture_type;
2512 unsigned int unit;
2513
2514 if (name)
2515 gl_info->gl_ops.gl.p_glBindTexture(target, name);
2516 else
2517 target = GL_NONE;
2518
2519 unit = context_gl->active_texture;
2520 old_texture_type = context_gl->texture_type[unit];
2521 if (old_texture_type != target)
2522 {
2523 switch (old_texture_type)
2524 {
2525 case GL_NONE:
2526 /* nothing to do */
2527 break;
2528 case GL_TEXTURE_1D:
2529 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
2530 break;
2532 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
2533 break;
2534 case GL_TEXTURE_2D:
2535 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
2536 break;
2538 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
2539 break;
2541 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
2542 break;
2544 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
2545 break;
2546 case GL_TEXTURE_3D:
2547 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
2548 break;
2549 case GL_TEXTURE_BUFFER:
2550 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
2551 break;
2553 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
2554 break;
2556 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
2557 break;
2558 default:
2559 ERR("Unexpected texture target %#x.\n", old_texture_type);
2560 }
2561
2562 context_gl->texture_type[unit] = target;
2563 }
2564
2565 checkGLcall("bind texture");
2566}
GLenum * texture_type
Definition: wined3d_gl.h:623

Referenced by create_buffer_texture(), create_texture_view(), shader_resource_view_gl_bind_and_dirtify(), wined3d_context_gl_bind_shader_resources(), wined3d_context_gl_draw_shaded_quad(), wined3d_shader_resource_view_gl_bind(), and wined3d_texture_gl_bind().

◆ wined3d_context_gl_bind_unordered_access_views()

static void wined3d_context_gl_bind_unordered_access_views ( struct wined3d_context_gl *  context_gl,
const struct wined3d_shader *  shader,
struct wined3d_unordered_access_view *const *  views 
)
static

Definition at line 3819 of file context_gl.c.

3821{
3822 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3823 struct wined3d_unordered_access_view_gl *view_gl;
3824 const struct wined3d_format_gl *format_gl;
3825 GLuint texture_name;
3826 unsigned int i;
3827 GLint level;
3828
3829 if (!shader)
3830 return;
3831
3832 for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
3833 {
3834 if (!views[i])
3835 {
3836 if (shader->reg_maps.uav_resource_info[i].type)
3837 WARN("No unordered access view bound at index %u.\n", i);
3838 GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3839 continue;
3840 }
3841
3842 view_gl = wined3d_unordered_access_view_gl(views[i]);
3843 if (view_gl->gl_view.name)
3844 {
3845 texture_name = view_gl->gl_view.name;
3846 level = 0;
3847 }
3848 else if (view_gl->v.resource->type != WINED3D_RTYPE_BUFFER)
3849 {
3850 struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(texture_from_resource(view_gl->v.resource));
3851 texture_name = wined3d_texture_gl_get_texture_name(texture_gl, &context_gl->c, FALSE);
3852 level = view_gl->v.desc.u.texture.level_idx;
3853 }
3854 else
3855 {
3856 FIXME("Unsupported buffer unordered access view.\n");
3857 GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3858 continue;
3859 }
3860
3861 format_gl = wined3d_format_gl(view_gl->v.format);
3862 GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE,
3863 format_gl->internal));
3864
3865 if (view_gl->counter_bo.id)
3866 GL_EXTCALL(glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, i, view_gl->counter_bo.id,
3867 view_gl->counter_bo.b.buffer_offset, view_gl->counter_bo.size));
3868 }
3869 checkGLcall("Bind unordered access views");
3870}
#define GL_FALSE
Definition: gl.h:173
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glext.h:2297
#define GL_R8
Definition: glext.h:1819
#define GL_READ_WRITE
Definition: glext.h:343
struct wined3d_bo_gl counter_bo
Definition: wined3d_gl.h:1107
struct wined3d_unordered_access_view v
Definition: wined3d_gl.h:1104
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:1106
static GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl, const struct wined3d_context *context, bool srgb)
Definition: wined3d_gl.h:982

Referenced by context_apply_draw_state(), and wined3d_context_gl_apply_compute_state().

◆ wined3d_context_gl_check_fbo_status()

void wined3d_context_gl_check_fbo_status ( const struct wined3d_context_gl *  context_gl,
GLenum  target 
)

Definition at line 419 of file context_gl.c.

420{
421 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
423
424 if (!FIXME_ON(d3d))
425 return;
426
427 status = gl_info->fbo_ops.glCheckFramebufferStatus(target);
429 {
430 TRACE("FBO complete.\n");
431 }
432 else
433 {
434 unsigned int i;
435
436 FIXME("FBO status %s (%#x).\n", debug_fbostatus(status), status);
437
438 if (!context_gl->current_fbo)
439 {
440 ERR("FBO 0 is incomplete, driver bug?\n");
441 return;
442 }
443
446
447 for (i = 0; i < gl_info->limits.buffers; ++i)
449 }
450}
static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, GLenum target, GLenum attachment)
Definition: context_gl.c:283
const char * debug_fbostatus(GLenum status)
Definition: utils.c:5423
#define GL_FRAMEBUFFER_COMPLETE
Definition: glext.h:1707
Definition: ps.c:97

Referenced by context_apply_draw_state(), context_gl_apply_texture_draw_state(), texture2d_blt_fbo(), texture2d_depth_blt_fbo(), texture2d_read_from_framebuffer(), and wined3d_context_gl_apply_clear_state().

◆ wined3d_context_gl_cleanup()

static void wined3d_context_gl_cleanup ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1361 of file context_gl.c.

1362{
1363 struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
1364 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1365 struct wined3d_so_statistics_query *so_statistics_query;
1366 struct wined3d_timestamp_query *timestamp_query;
1367 struct wined3d_occlusion_query *occlusion_query;
1369 struct fbo_entry *entry, *entry2;
1370 struct wined3d_fence *fence;
1371 HGLRC restore_ctx;
1373 unsigned int i;
1374
1375 TRACE("context_gl %p.\n", context_gl);
1376
1377 restore_ctx = wglGetCurrentContext();
1379
1380 if (context_gl->valid && context_gl->gl_ctx != restore_ctx)
1381 {
1382 /* Attempting to restore a GL context corresponding to a wined3d
1383 * context is not particularly useful. Worse, when we're called from
1384 * wined3d_context_gl_destroy(), we subsequently clear the "current
1385 * D3D context" TLS value, which would cause
1386 * wined3d_context_gl_enter() to consider the GL context a non-D3D
1387 * context. */
1388 if ((current = wined3d_context_gl_get_current()) && current->gl_ctx == restore_ctx)
1389 restore_ctx = NULL;
1391 }
1392 else
1393 {
1394 restore_ctx = NULL;
1395 }
1396
1397 if (context_gl->valid)
1398 {
1399 /* If we're here because we're switching away from a previously
1400 * destroyed context, acquiring a context in order to submit a fence
1401 * is problematic. In particular, we'd end up back here again in the
1402 * process of switching to the newly acquired context.
1403 *
1404 * If fences aren't supported there should be nothing to wait for
1405 * anyway, so just do nothing in that case. */
1406 if (context_gl->c.destroyed)
1407 {
1408 gl_info->gl_ops.gl.p_glFinish();
1409 }
1410 else if (context_gl->c.d3d_info->fences)
1411 {
1415 }
1416
1417 if (context_gl->dummy_arbfp_prog)
1418 GL_EXTCALL(glDeleteProgramsARB(1, &context_gl->dummy_arbfp_prog));
1419
1420 if (context_gl->blit_vbo)
1421 GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
1422
1423 for (i = 0; i < context_gl->free_pipeline_statistics_query_count; ++i)
1424 {
1426 GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
1427 }
1428
1429 for (i = 0; i < context_gl->free_so_statistics_query_count; ++i)
1430 {
1432 GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
1433 }
1434
1435 if (context_gl->free_timestamp_query_count)
1436 GL_EXTCALL(glDeleteQueries(context_gl->free_timestamp_query_count, context_gl->free_timestamp_queries));
1437
1438 if (gl_info->supported[ARB_SYNC])
1439 {
1440 for (i = 0; i < context_gl->free_fence_count; ++i)
1441 {
1442 GL_EXTCALL(glDeleteSync(context_gl->free_fences[i].sync));
1443 }
1444 }
1445 else if (gl_info->supported[APPLE_FENCE])
1446 {
1447 for (i = 0; i < context_gl->free_fence_count; ++i)
1448 {
1449 GL_EXTCALL(glDeleteFencesAPPLE(1, &context_gl->free_fences[i].id));
1450 }
1451 }
1452 else if (gl_info->supported[NV_FENCE])
1453 {
1454 for (i = 0; i < context_gl->free_fence_count; ++i)
1455 {
1456 GL_EXTCALL(glDeleteFencesNV(1, &context_gl->free_fences[i].id));
1457 }
1458 }
1459
1460 if (context_gl->free_occlusion_query_count)
1461 GL_EXTCALL(glDeleteQueries(context_gl->free_occlusion_query_count, context_gl->free_occlusion_queries));
1462
1463 checkGLcall("context cleanup");
1464 }
1465 free(context_gl->submitted.fences);
1467 free(context_gl->free_so_statistics_queries);
1468 free(context_gl->free_timestamp_queries);
1469 free(context_gl->free_fences);
1470 free(context_gl->free_occlusion_queries);
1471
1472 LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context_gl->pipeline_statistics_queries,
1474 {
1475 if (context_gl->valid)
1476 GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
1477 pipeline_statistics_query->context_gl = NULL;
1478 }
1479
1480 LIST_FOR_EACH_ENTRY(so_statistics_query, &context_gl->so_statistics_queries,
1482 {
1483 if (context_gl->valid)
1484 GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
1485 so_statistics_query->context_gl = NULL;
1486 }
1487
1488 LIST_FOR_EACH_ENTRY(timestamp_query, &context_gl->timestamp_queries, struct wined3d_timestamp_query, entry)
1489 {
1490 if (context_gl->valid)
1491 GL_EXTCALL(glDeleteQueries(1, &timestamp_query->id));
1492 timestamp_query->context_gl = NULL;
1493 }
1494
1495 LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
1496 {
1497 if (context_gl->valid)
1498 {
1499 if (gl_info->supported[ARB_SYNC])
1500 {
1501 if (fence->object.sync)
1502 GL_EXTCALL(glDeleteSync(fence->object.sync));
1503 }
1504 else if (gl_info->supported[APPLE_FENCE])
1505 {
1506 GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
1507 }
1508 else if (gl_info->supported[NV_FENCE])
1509 {
1510 GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
1511 }
1512 }
1513 fence->context_gl = NULL;
1514 }
1515
1516 LIST_FOR_EACH_ENTRY(occlusion_query, &context_gl->occlusion_queries, struct wined3d_occlusion_query, entry)
1517 {
1518 if (context_gl->valid)
1519 GL_EXTCALL(glDeleteQueries(1, &occlusion_query->id));
1520 occlusion_query->context_gl = NULL;
1521 }
1522
1523 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_destroy_list, struct fbo_entry, entry)
1524 {
1525 if (!context_gl->valid)
1526 entry->id = 0;
1528 }
1529
1530 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_list, struct fbo_entry, entry)
1531 {
1532 if (!context_gl->valid)
1533 entry->id = 0;
1535 }
1536
1537 free(context_gl->texture_type);
1538
1540 if (restore_ctx)
1541 context_restore_gl_context(gl_info, restore_dc, restore_ctx);
1543 ERR("Failed to disable GL context.\n");
1544
1545 wined3d_release_dc(context_gl->window, context_gl->dc);
1546
1547 if (!wglDeleteContext(context_gl->gl_ctx))
1548 {
1549 unsigned int err = GetLastError();
1550 ERR("Failed to delete GL context %p, last error %#x.\n", context_gl->gl_ctx, err);
1551 }
1552
1553 wined3d_context_cleanup(&context_gl->c);
1554}
static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx)
Definition: context_gl.c:1323
static BOOL wined3d_context_gl_restore_pixel_format(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1165
#define free
Definition: debug_ros.c:5
void wined3d_context_cleanup(struct wined3d_context *context)
Definition: context.c:48
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6658
static void restore_dc(GpGraphics *graphics, HDC hdc, INT state)
Definition: graphics.c:354
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
struct task_struct * current
Definition: linux.c:32
static HDC
Definition: imagelist.c:88
struct list fbo_list
Definition: wined3d_gl.h:639
struct wined3d_context_gl::@345 submitted
struct wined3d_context_gl * context_gl
Definition: wined3d_gl.h:486
union wined3d_gl_pipeline_statistics_query u
Definition: wined3d_gl.h:547
struct wined3d_context_gl * context_gl
Definition: wined3d_gl.h:548
struct wined3d_context_gl * context_gl
Definition: wined3d_gl.h:517
union wined3d_gl_so_statistics_query u
Definition: wined3d_gl.h:516
struct wined3d_context_gl * context_gl
Definition: wined3d_gl.h:497
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:516
HDC WINAPI wglGetCurrentDC(void)
Definition: wgl.c:581
HGLRC WINAPI wglGetCurrentContext(void)
Definition: wgl.c:576

Referenced by wined3d_context_gl_destroy(), and wined3d_context_gl_set_current().

◆ wined3d_context_gl_cleanup_resources()

static void wined3d_context_gl_cleanup_resources ( struct wined3d_context_gl *  context_gl)
static

Definition at line 2600 of file context_gl.c.

2601{
2602 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2603 struct wined3d_retired_block_gl *r, *blocks;
2604 SIZE_T count, i = 0;
2605 uint64_t id;
2606
2608 id = device_gl->completed_fence_id;
2609
2610 blocks = device_gl->retired_blocks;
2611 count = device_gl->retired_block_count;
2612 while (i < count)
2613 {
2614 r = &blocks[i];
2615
2616 if (r->fence_id > id)
2617 {
2618 ++i;
2619 continue;
2620 }
2621
2622 wined3d_device_gl_free_memory(device_gl, r->block);
2623 if (i != --count)
2624 *r = blocks[count];
2625 }
2626 device_gl->retired_block_count = count;
2627}
static void wined3d_device_gl_free_memory(struct wined3d_device_gl *device_gl, struct wined3d_allocator_block *block)
Definition: context_gl.c:2592
static void wined3d_context_gl_poll_fences(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2568
UINT64 uint64_t
Definition: types.h:77
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static int blocks
Definition: mkdosfs.c:527
SIZE_T retired_block_count
Definition: wined3d_gl.h:864
struct wined3d_device_gl::wined3d_retired_block_gl * retired_blocks
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by wined3d_context_gl_submit_command_fence(), and wined3d_context_gl_wait_command_fence().

◆ wined3d_context_gl_copy_bo_address()

void wined3d_context_gl_copy_bo_address ( struct wined3d_context_gl *  context_gl,
const struct wined3d_bo_address *  dst,
const struct wined3d_bo_address *  src,
unsigned int  range_count,
const struct wined3d_range *  ranges,
uint32_t  map_flags 
)

Definition at line 3016 of file context_gl.c.

3019{
3020 const struct wined3d_gl_info *gl_info;
3021 struct wined3d_bo_gl *src_bo, *dst_bo;
3022 BYTE *dst_ptr, *src_ptr;
3023 unsigned int i;
3024
3025 gl_info = context_gl->gl_info;
3026 src_bo = src->buffer_object ? wined3d_bo_gl(src->buffer_object) : NULL;
3027 dst_bo = dst->buffer_object ? wined3d_bo_gl(dst->buffer_object) : NULL;
3028
3029 if (dst_bo && src_bo)
3030 {
3031 if (gl_info->supported[ARB_COPY_BUFFER])
3032 {
3033 GL_EXTCALL(glBindBuffer(GL_COPY_READ_BUFFER, src_bo->id));
3034 GL_EXTCALL(glBindBuffer(GL_COPY_WRITE_BUFFER, dst_bo->id));
3035
3036 for (i = 0; i < range_count; ++i)
3038 src_bo->b.buffer_offset + (GLintptr)src->addr + ranges[i].offset,
3039 dst_bo->b.buffer_offset + (GLintptr)dst->addr + ranges[i].offset, ranges[i].size));
3040 checkGLcall("direct buffer copy");
3041
3042 wined3d_context_gl_reference_bo(context_gl, src_bo);
3043 wined3d_context_gl_reference_bo(context_gl, dst_bo);
3044 }
3045 else
3046 {
3047 src_ptr = wined3d_context_gl_map_bo_address(context_gl, src,
3048 src_bo->size - (uintptr_t)src->addr, WINED3D_MAP_READ);
3049 dst_ptr = wined3d_context_gl_map_bo_address(context_gl, dst,
3050 dst_bo->size - (uintptr_t)dst->addr, map_flags);
3051
3052 for (i = 0; i < range_count; ++i)
3053 memcpy(dst_ptr + ranges[i].offset, src_ptr + ranges[i].offset, ranges[i].size);
3054
3055 wined3d_context_gl_unmap_bo_address(context_gl, dst, range_count, ranges);
3057 }
3058 }
3059 else if (!dst_bo && src_bo)
3060 {
3061 wined3d_context_gl_bind_bo(context_gl, src_bo->binding, src_bo->id);
3062 for (i = 0; i < range_count; ++i)
3063 GL_EXTCALL(glGetBufferSubData(src_bo->binding,
3064 src_bo->b.buffer_offset + (GLintptr)src->addr + ranges[i].offset,
3065 ranges[i].size, dst->addr + ranges[i].offset));
3066 checkGLcall("buffer download");
3067
3068 wined3d_context_gl_reference_bo(context_gl, src_bo);
3069 }
3070 else if (dst_bo && !src_bo)
3071 {
3072 if ((map_flags & WINED3D_MAP_DISCARD) && (dst_bo->flags & GL_MAP_WRITE_BIT))
3073 {
3074 dst_ptr = wined3d_context_gl_map_bo_address(context_gl, dst, dst_bo->size, map_flags);
3075 memcpy(dst_ptr, src->addr, dst_bo->size);
3076 wined3d_context_gl_unmap_bo_address(context_gl, dst, range_count, ranges);
3077 }
3078 else
3079 {
3080 wined3d_context_gl_bind_bo(context_gl, dst_bo->binding, dst_bo->id);
3081 for (i = 0; i < range_count; ++i)
3082 GL_EXTCALL(glBufferSubData(dst_bo->binding,
3083 dst_bo->b.buffer_offset + (GLintptr)dst->addr + ranges[i].offset,
3084 ranges[i].size, src->addr + ranges[i].offset));
3085 checkGLcall("buffer upload");
3086
3087 wined3d_context_gl_reference_bo(context_gl, dst_bo);
3088 }
3089 }
3090 else
3091 {
3092 for (i = 0; i < range_count; ++i)
3093 memcpy(dst->addr + ranges[i].offset, src->addr + ranges[i].offset, ranges[i].size);
3094 }
3095}
void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
Definition: context_gl.c:2988
void * wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, size_t size, uint32_t flags)
Definition: context_gl.c:2932
#define GL_COPY_WRITE_BUFFER
Definition: glext.h:1889
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define GL_COPY_READ_BUFFER
Definition: glext.h:1887
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WINED3D_MAP_READ
Definition: wined3d.h:957
@ ARB_COPY_BUFFER
Definition: wined3d_gl.h:62

Referenced by adapter_gl_copy_bo_address().

◆ wined3d_context_gl_create_fbo_entry()

static struct fbo_entry * wined3d_context_gl_create_fbo_entry ( const struct wined3d_context_gl *  context_gl,
const struct wined3d_rendertarget_info *  render_targets,
const struct wined3d_rendertarget_info *  depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 573 of file context_gl.c.

576{
577 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
578 struct fbo_entry *entry;
579
580 entry = malloc(sizeof(*entry));
582 render_targets, depth_stencil, color_location, ds_location);
583 entry->flags = 0;
584 if (depth_stencil->resource)
585 {
586 if (depth_stencil->resource->format->depth_size)
588 if (depth_stencil->resource->format->stencil_size)
590 }
592 gl_info->fbo_ops.glGenFramebuffers(1, &entry->id);
593 checkGLcall("glGenFramebuffers()");
594 TRACE("Created FBO %u.\n", entry->id);
595
596 return entry;
597}
static DWORD context_generate_rt_mask(GLenum buffer)
Definition: context_gl.c:452
static void wined3d_context_gl_generate_fbo_key(const struct wined3d_context_gl *context_gl, struct wined3d_fbo_entry_key *key, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context_gl.c:557
#define malloc
Definition: debug_ros.c:4

Referenced by wined3d_context_gl_find_fbo_entry().

◆ wined3d_context_gl_create_wgl_ctx()

static BOOL wined3d_context_gl_create_wgl_ctx ( struct wined3d_context_gl *  context_gl,
struct wined3d_swapchain_gl *  swapchain_gl,
BOOL *  new_drawable 
)
static

Definition at line 1924 of file context_gl.c.

1926{
1927 enum wined3d_swap_effect swap_effect = swapchain_gl->s.state.desc.swap_effect;
1928 const struct wined3d_format *colour_format, *ds_format;
1929 struct wined3d_context *context = &context_gl->c;
1930 const struct wined3d_gl_info *gl_info;
1931 struct wined3d_resource *target;
1932 struct wined3d_adapter *adapter;
1933 unsigned int target_bind_flags;
1934 struct wined3d_device *device;
1935 bool swap_effect_copy;
1936 HGLRC ctx, share_ctx;
1937
1938 device = context->device;
1939 adapter = device->adapter;
1940 gl_info = &wined3d_adapter_gl(adapter)->gl_info;
1941
1942 target = &context->current_rt.texture->resource;
1943 target_bind_flags = target->bind_flags;
1944
1945 swap_effect_copy = swap_effect == WINED3D_SWAP_EFFECT_COPY || swap_effect == WINED3D_SWAP_EFFECT_COPY_VSYNC;
1946
1947 *new_drawable = !GetPixelFormat(context_gl->dc);
1948
1949 /* When using FBOs for off-screen rendering, we only use the drawable for
1950 * presentation blits, and don't do any rendering to it. That means we
1951 * don't need depth or stencil buffers, and can mostly ignore the render
1952 * target format. This wouldn't necessarily be quite correct for 10bpc
1953 * display modes, but we don't currently support those.
1954 * Using the same format regardless of the colour/depth/stencil targets
1955 * makes it much less likely that different wined3d instances will set
1956 * conflicting pixel formats. */
1957 colour_format = wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, target_bind_flags);
1960 context_gl->dc, colour_format, ds_format, false, swap_effect_copy);
1961
1962 if (!context_gl->pixel_format)
1963 {
1964 ERR("Failed to choose pixel format.\n");
1965 return FALSE;
1966 }
1967
1968 wined3d_context_gl_enter(context_gl);
1969
1970 if (!wined3d_context_gl_set_pixel_format(context_gl))
1971 {
1973
1974 if (context_gl->dc_is_private)
1975 {
1976 ERR("Failed to set pixel format %d on device context %p.\n", context_gl->pixel_format, context_gl->dc);
1977
1978 return FALSE;
1979 }
1980
1981 WARN("Failed to set pixel format %d on device context %p, trying backup DC.\n",
1982 context_gl->pixel_format, context_gl->dc);
1983
1984 wined3d_release_dc(context_gl->window, context_gl->dc);
1986 {
1987 ERR("Failed to retrieve the backup device context.\n");
1988 return FALSE;
1989 }
1990 context_gl->dc_is_private = TRUE;
1991
1992 return wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl, new_drawable);
1993 }
1994
1995 share_ctx = device->context_count ? wined3d_context_gl(device->contexts[0])->gl_ctx : NULL;
1996 if (gl_info->p_wglCreateContextAttribsARB)
1997 {
1998 if (!(ctx = context_create_wgl_attribs(gl_info, context_gl->dc, share_ctx)))
1999 {
2000 ERR("Failed to create a WGL context.\n");
2002 return FALSE;
2003 }
2004 }
2005 else
2006 {
2007 if (!(ctx = wglCreateContext(context_gl->dc)))
2008 {
2009 ERR("Failed to create a WGL context.\n");
2011 return FALSE;
2012 }
2013
2014 if (share_ctx && !wglShareLists(share_ctx, ctx))
2015 {
2016 ERR("wglShareLists(%p, %p) failed, last error %#lx.\n", share_ctx, ctx, GetLastError());
2018 if (!wglDeleteContext(ctx))
2019 ERR("wglDeleteContext(%p) failed, last error %#lx.\n", ctx, GetLastError());
2020 return FALSE;
2021 }
2022 }
2023
2024 context_gl->dc_has_format = TRUE;
2025 context_gl->needs_set = 1;
2026 context_gl->valid = 1;
2027 context_gl->gl_ctx = ctx;
2028
2029 return TRUE;
2030}
static int context_choose_pixel_format(const struct wined3d_device *device, HDC hdc, const struct wined3d_format *color_format, const struct wined3d_format *ds_format, bool aux_buffers, bool swap_effect_copy)
Definition: context_gl.c:1691
static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1197
static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context_gl, struct wined3d_swapchain_gl *swapchain_gl, BOOL *new_drawable)
Definition: context_gl.c:1924
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx)
Definition: context_gl.c:1881
HDC wined3d_device_gl_get_backup_dc(struct wined3d_device_gl *device_gl)
Definition: device.c:5313
const struct wined3d_format * wined3d_get_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id, unsigned int bind_flags)
Definition: utils.c:4428
return adapter
struct wined3d_gl_info gl_info
Definition: wined3d_gl.h:800
uint32_t dc_is_private
Definition: wined3d_gl.h:607
uint32_t dc_has_format
Definition: wined3d_gl.h:608
struct wined3d_swapchain s
Definition: wined3d_gl.h:1126
HGLRC WINAPI wglCreateContext(HDC hdc)
Definition: wgl.c:383
BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst)
Definition: wgl.c:874
wined3d_swap_effect
Definition: wined3d.h:533
@ WINED3D_SWAP_EFFECT_COPY
Definition: wined3d.h:538
@ WINED3D_SWAP_EFFECT_COPY_VSYNC
Definition: wined3d.h:539
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:244
@ WINED3DFMT_UNKNOWN
Definition: wined3d.h:127
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
int WINAPI GetPixelFormat(_In_ HDC)

Referenced by wined3d_context_gl_create_wgl_ctx(), and wined3d_context_gl_init().

◆ wined3d_context_gl_destroy()

void wined3d_context_gl_destroy ( struct wined3d_context_gl *  context_gl)

Definition at line 2308 of file context_gl.c.

2309{
2310 struct wined3d_device *device = context_gl->c.device;
2311
2312 TRACE("Destroying context %p.\n", context_gl);
2313
2315
2316 /* We delay destroying a context when it is active. The context_release()
2317 * function invokes wined3d_context_gl_destroy() again while leaving the
2318 * last level. */
2319 if (context_gl->level)
2320 {
2321 TRACE("Delaying destruction of context %p.\n", context_gl);
2322 context_gl->c.destroy_delayed = 1;
2323 /* FIXME: Get rid of a pointer to swapchain from wined3d_context. */
2324 context_gl->c.swapchain = NULL;
2325 context_gl->c.device = NULL;
2326 return;
2327 }
2328
2329 device_context_remove(device, &context_gl->c);
2330
2331 if (context_gl->c.current && context_gl->tid != GetCurrentThreadId())
2332 {
2333 struct wined3d_gl_info *gl_info;
2334
2335 /* Make a copy of gl_info for wined3d_context_gl_cleanup() use, the
2336 * one in wined3d_adapter may go away in the meantime. */
2337 gl_info = malloc(sizeof(*gl_info));
2338 *gl_info = *context_gl->gl_info;
2339 context_gl->gl_info = gl_info;
2340 context_gl->c.destroyed = 1;
2341
2342 return;
2343 }
2344
2345 wined3d_context_gl_cleanup(context_gl);
2347 free(context_gl);
2348}
static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1361
DWORD context_get_tls_idx(void)
Definition: context_gl.c:1556
void device_context_remove(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:118
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1334
unsigned int level
Definition: wined3d_gl.h:626
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
static void wined3d_from_cs(const struct wined3d_cs *cs)

Referenced by wined3d_context_gl_release(), wined3d_device_gl_create_primary_opengl_context_cs(), wined3d_device_gl_delete_opengl_contexts_cs(), and wined3d_swapchain_gl_create_context().

◆ wined3d_context_gl_destroy_allocator_block()

static void wined3d_context_gl_destroy_allocator_block ( struct wined3d_context_gl *  context_gl,
struct wined3d_allocator_block *  block,
uint64_t  fence_id 
)
static

Definition at line 2680 of file context_gl.c.

2682{
2683 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2684 struct wined3d_retired_block_gl *r;
2685
2686 if (device_gl->completed_fence_id >= fence_id)
2687 {
2689 TRACE("Freed block %p.\n", block);
2690 return;
2691 }
2692
2693 if (!wined3d_array_reserve((void **)&device_gl->retired_blocks,
2694 &device_gl->retired_blocks_size, device_gl->retired_block_count + 1,
2695 sizeof(*device_gl->retired_blocks)))
2696 {
2697 ERR("Leaking block %p.\n", block);
2698 return;
2699 }
2700
2701 r = &device_gl->retired_blocks[device_gl->retired_block_count++];
2702 r->block = block;
2703 r->fence_id = fence_id;
2704}
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: utils.c:6740
SIZE_T retired_blocks_size
Definition: wined3d_gl.h:863
static unsigned int block
Definition: xmlmemory.c:101

Referenced by wined3d_context_gl_destroy_bo().

◆ wined3d_context_gl_destroy_bo()

void wined3d_context_gl_destroy_bo ( struct wined3d_context_gl *  context_gl,
struct wined3d_bo_gl *  bo 
)

Definition at line 3097 of file context_gl.c.

3098{
3099 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
3100 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3101
3102 TRACE("context_gl %p, bo %p.\n", context_gl, bo);
3103
3104 assert(list_empty(&bo->b.users));
3105
3106 if (bo->memory)
3107 {
3108 unsigned int order = bo->memory->order;
3109
3110 if (bo->b.map_ptr)
3113
3114 if (bo->command_fence_id == device_gl->current_fence_id)
3115 {
3119 }
3120
3121 bo->id = 0;
3122 return;
3123 }
3124
3125 if (bo->b.map_ptr)
3126 {
3127 wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
3128 GL_EXTCALL(glUnmapBuffer(bo->binding));
3129 adapter_adjust_mapped_memory(context_gl->c.device->adapter, -bo->size);
3130 }
3131
3132 TRACE("Destroying GL buffer %u.\n", bo->id);
3133
3134 GL_EXTCALL(glDeleteBuffers(1, &bo->id));
3135 checkGLcall("buffer object destruction");
3136 bo->id = 0;
3137}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void wined3d_context_gl_destroy_allocator_block(struct wined3d_context_gl *context_gl, struct wined3d_allocator_block *block, uint64_t fence_id)
Definition: context_gl.c:2680
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
uint64_t retired_bo_size
Definition: wined3d_gl.h:856
#define WINED3D_RETIRED_BO_SIZE_THRESHOLD

Referenced by adapter_gl_destroy_bo(), wined3d_bo_gl_map(), wined3d_buffer_gl_destroy_buffer_object(), wined3d_texture_remove_buffer_object(), and wined3d_view_gl_destroy_object().

◆ wined3d_context_gl_destroy_fbo()

static void wined3d_context_gl_destroy_fbo ( struct wined3d_context_gl *  context_gl,
GLuint  fbo 
)
static

Definition at line 143 of file context_gl.c.

144{
145 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
146
150
151 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
152 checkGLcall("glDeleteFramebuffers()");
153}
static void context_clean_fbo_attachments(const struct wined3d_gl_info *gl_info, GLenum target)
Definition: context_gl.c:126

Referenced by wined3d_context_gl_destroy_fbo_entry().

◆ wined3d_context_gl_destroy_fbo_entry()

static void wined3d_context_gl_destroy_fbo_entry ( struct wined3d_context_gl *  context_gl,
struct fbo_entry *  entry 
)
static

Definition at line 622 of file context_gl.c.

623{
624 if (entry->id)
625 {
626 TRACE("Destroy FBO %u.\n", entry->id);
627 wined3d_context_gl_destroy_fbo(context_gl, entry->id);
628 }
629 --context_gl->fbo_entry_count;
630 list_remove(&entry->entry);
631 free(entry);
632}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void wined3d_context_gl_destroy_fbo(struct wined3d_context_gl *context_gl, GLuint fbo)
Definition: context_gl.c:143
unsigned int fbo_entry_count
Definition: wined3d_gl.h:638

Referenced by wined3d_context_gl_apply_fbo_state(), and wined3d_context_gl_cleanup().

◆ wined3d_context_gl_draw_indirect()

static void wined3d_context_gl_draw_indirect ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state,
const struct wined3d_indirect_draw_parameters *  parameters,
unsigned int  idx_size 
)
static

Definition at line 4586 of file context_gl.c.

4588{
4589 struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(parameters->buffer->buffer_object);
4590 GLenum gl_primitive_type = gl_primitive_type_from_d3d(state->primitive_type);
4591 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4592 const void *offset;
4593
4594 if (!gl_info->supported[ARB_DRAW_INDIRECT])
4595 {
4596 FIXME("OpenGL implementation does not support indirect draws.\n");
4597 return;
4598 }
4599
4600 GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, bo_gl->id));
4601
4602 offset = (const uint8_t *)bo_gl->b.buffer_offset + parameters->offset;
4603 if (idx_size)
4604 {
4605 GLenum idx_type = idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
4606 if (state->index_offset)
4607 FIXME("Ignoring index offset %u.\n", state->index_offset);
4608 GL_EXTCALL(glDrawElementsIndirect(gl_primitive_type, idx_type, offset));
4609 }
4610 else
4611 {
4612 GL_EXTCALL(glDrawArraysIndirect(gl_primitive_type, offset));
4613 }
4614
4615 GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0));
4616 wined3d_context_gl_reference_bo(context_gl, bo_gl);
4617
4618 checkGLcall("draw indirect");
4619}
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define GL_DRAW_INDIRECT_BUFFER
Definition: glext.h:2046
if(dx< 0)
Definition: linetemp.h:194
@ ARB_DRAW_INDIRECT
Definition: wined3d_gl.h:73

Referenced by draw_primitive().

◆ wined3d_context_gl_draw_primitive_arrays()

static void wined3d_context_gl_draw_primitive_arrays ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state,
const void *  idx_data,
unsigned int  idx_size,
int  base_vertex_idx,
unsigned int  start_idx,
unsigned int  count,
unsigned int  start_instance,
unsigned int  instance_count 
)
static

Definition at line 4453 of file context_gl.c.

4456{
4457 GLenum idx_type = idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
4458 const struct wined3d_stream_info *si = &context_gl->c.stream_info;
4459 GLenum mode = gl_primitive_type_from_d3d(state->primitive_type);
4460 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4461 unsigned int instanced_elements[ARRAY_SIZE(si->elements)];
4462 const struct wined3d_ffp_attrib_ops *ops;
4463 unsigned int instanced_element_count = 0;
4464 const void *indices;
4465 unsigned int i, j;
4466
4467 ops = &gl_info->ffp_attrib_ops;
4468
4469 indices = (const char *)idx_data + idx_size * start_idx;
4470
4471 if (!instance_count)
4472 {
4473 if (!idx_size)
4474 {
4475 gl_info->gl_ops.gl.p_glDrawArrays(mode, start_idx, count);
4476 checkGLcall("glDrawArrays");
4477 return;
4478 }
4479
4481 {
4482 GL_EXTCALL(glDrawElementsBaseVertex(mode, count, idx_type, indices, base_vertex_idx));
4483 checkGLcall("glDrawElementsBaseVertex");
4484 return;
4485 }
4486
4487 gl_info->gl_ops.gl.p_glDrawElements(mode, count, idx_type, indices);
4488 checkGLcall("glDrawElements");
4489 return;
4490 }
4491
4492 if (start_instance && !(gl_info->supported[ARB_BASE_INSTANCE] && gl_info->supported[ARB_INSTANCED_ARRAYS]))
4493 FIXME("Start instance (%u) not supported.\n", start_instance);
4494
4495 if (gl_info->supported[ARB_INSTANCED_ARRAYS])
4496 {
4497 if (!idx_size)
4498 {
4499 if (gl_info->supported[ARB_BASE_INSTANCE])
4500 {
4501 GL_EXTCALL(glDrawArraysInstancedBaseInstance(mode, start_idx, count, instance_count, start_instance));
4502 checkGLcall("glDrawArraysInstancedBaseInstance");
4503 return;
4504 }
4505
4506 GL_EXTCALL(glDrawArraysInstanced(mode, start_idx, count, instance_count));
4507 checkGLcall("glDrawArraysInstanced");
4508 return;
4509 }
4510
4511 if (gl_info->supported[ARB_BASE_INSTANCE])
4512 {
4513 GL_EXTCALL(glDrawElementsInstancedBaseVertexBaseInstance(mode, count, idx_type,
4514 indices, instance_count, base_vertex_idx, start_instance));
4515 checkGLcall("glDrawElementsInstancedBaseVertexBaseInstance");
4516 return;
4517 }
4519 {
4520 GL_EXTCALL(glDrawElementsInstancedBaseVertex(mode, count, idx_type,
4521 indices, instance_count, base_vertex_idx));
4522 checkGLcall("glDrawElementsInstancedBaseVertex");
4523 return;
4524 }
4525
4526 GL_EXTCALL(glDrawElementsInstanced(mode, count, idx_type, indices, instance_count));
4527 checkGLcall("glDrawElementsInstanced");
4528 return;
4529 }
4530
4531 /* Instancing emulation by mixing immediate mode and arrays. */
4532
4533 /* This is a nasty thing. MSDN says no hardware supports this and
4534 * applications have to use software vertex processing. We don't support
4535 * this for now.
4536 *
4537 * Shouldn't be too hard to support with OpenGL, in theory just call
4538 * glDrawArrays() instead of drawElements(). But the stream frequency value
4539 * has a different meaning in that situation. */
4540 if (!idx_size)
4541 {
4542 FIXME("Non-indexed instanced drawing is not supported.\n");
4543 return;
4544 }
4545
4546 for (i = 0; i < ARRAY_SIZE(si->elements); ++i)
4547 {
4548 if (!(si->use_map & (1u << i)))
4549 continue;
4550
4551 if (state->streams[si->elements[i].stream_idx].flags & WINED3DSTREAMSOURCE_INSTANCEDATA)
4552 instanced_elements[instanced_element_count++] = i;
4553 }
4554
4555 for (i = 0; i < instance_count; ++i)
4556 {
4557 /* Specify the instanced attributes using immediate mode calls. */
4558 for (j = 0; j < instanced_element_count; ++j)
4559 {
4561 unsigned int element_idx;
4562 const BYTE *ptr;
4563
4564 element_idx = instanced_elements[j];
4565 element = &si->elements[element_idx];
4566 ptr = element->data.addr + element->stride * i;
4567 if (element->data.buffer_object)
4568 ptr += (ULONG_PTR)wined3d_buffer_load_sysmem(state->streams[element->stream_idx].buffer,
4569 &context_gl->c);
4570 ops->generic[element->format->emit_idx](element_idx, ptr);
4571 }
4572
4574 {
4575 GL_EXTCALL(glDrawElementsBaseVertex(mode, count, idx_type, indices, base_vertex_idx));
4576 checkGLcall("glDrawElementsBaseVertex");
4577 }
4578 else
4579 {
4580 gl_info->gl_ops.gl.p_glDrawElements(mode, count, idx_type, indices);
4581 checkGLcall("glDrawElements");
4582 }
4583 }
4584}
#define ULONG_PTR
Definition: config.h:101
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
static SYSTEM_INFO si
Definition: virtual.c:39
wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT]
Definition: wined3d_gl.h:337
struct wined3d_ffp_attrib_ops ffp_attrib_ops
Definition: wined3d_gl.h:352
#define WINED3DSTREAMSOURCE_INSTANCEDATA
Definition: wined3d.h:1015
@ ARB_DRAW_ELEMENTS_BASE_VERTEX
Definition: wined3d_gl.h:72
@ ARB_BASE_INSTANCE
Definition: wined3d_gl.h:53
@ ARB_INSTANCED_ARRAYS
Definition: wined3d_gl.h:90

Referenced by draw_primitive().

◆ wined3d_context_gl_draw_shaded_quad()

void wined3d_context_gl_draw_shaded_quad ( struct wined3d_context_gl *  context_gl,
struct wined3d_texture_gl *  texture_gl,
unsigned int  sub_resource_idx,
const RECT *  src_rect,
const RECT *  dst_rect,
enum wined3d_texture_filter_type  filter 
)

Definition at line 5125 of file context_gl.c.

5128{
5129 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
5130 struct wined3d_blt_info info;
5131 unsigned int level, w, h, i;
5132 SIZE dst_size;
5133 struct blit_vertex
5134 {
5135 float x, y;
5136 struct wined3d_vec3 texcoord;
5137 }
5138 quad[4];
5139
5140 texture2d_get_blt_info(texture_gl, sub_resource_idx, src_rect, &info);
5141
5142 level = sub_resource_idx % texture_gl->t.level_count;
5143 wined3d_context_gl_bind_texture(context_gl, info.bind_target, texture_gl->texture_rgb.name);
5144 apply_texture_blit_state(gl_info, &texture_gl->texture_rgb, info.bind_target, level, filter);
5145 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, level);
5146
5148
5149 wined3d_context_gl_get_rt_size(context_gl, &dst_size);
5150 w = dst_size.cx;
5151 h = dst_size.cy;
5152
5153 quad[0].x = dst_rect->left * 2.0f / w - 1.0f;
5154 quad[0].y = dst_rect->top * 2.0f / h - 1.0f;
5155 quad[0].texcoord = info.texcoords[0];
5156
5157 quad[1].x = dst_rect->right * 2.0f / w - 1.0f;
5158 quad[1].y = dst_rect->top * 2.0f / h - 1.0f;
5159 quad[1].texcoord = info.texcoords[1];
5160
5161 quad[2].x = dst_rect->left * 2.0f / w - 1.0f;
5162 quad[2].y = dst_rect->bottom * 2.0f / h - 1.0f;
5163 quad[2].texcoord = info.texcoords[2];
5164
5165 quad[3].x = dst_rect->right * 2.0f / w - 1.0f;
5166 quad[3].y = dst_rect->bottom * 2.0f / h - 1.0f;
5167 quad[3].texcoord = info.texcoords[3];
5168
5169 /* Draw a quad. */
5170 if (gl_info->supported[ARB_VERTEX_BUFFER_OBJECT])
5171 {
5172 if (!context_gl->blit_vbo)
5173 GL_EXTCALL(glGenBuffers(1, &context_gl->blit_vbo));
5174 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, context_gl->blit_vbo));
5175
5177
5178 GL_EXTCALL(glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW));
5179 GL_EXTCALL(glVertexAttribPointer(0, 2, GL_FLOAT, FALSE, sizeof(*quad), NULL));
5180 GL_EXTCALL(glVertexAttribPointer(1, 3, GL_FLOAT, FALSE, sizeof(*quad),
5181 (void *)FIELD_OFFSET(struct blit_vertex, texcoord)));
5182
5183 GL_EXTCALL(glEnableVertexAttribArray(0));
5184 GL_EXTCALL(glEnableVertexAttribArray(1));
5185
5186 gl_info->gl_ops.gl.p_glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
5187
5188 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
5189 GL_EXTCALL(glDisableVertexAttribArray(1));
5190 GL_EXTCALL(glDisableVertexAttribArray(0));
5191 }
5192 else
5193 {
5194 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
5195
5196 for (i = 0; i < ARRAY_SIZE(quad); ++i)
5197 {
5198 GL_EXTCALL(glVertexAttrib3fv(1, &quad[i].texcoord.x));
5199 GL_EXTCALL(glVertexAttrib2fv(0, &quad[i].x));
5200 }
5201
5202 gl_info->gl_ops.gl.p_glEnd();
5203 }
5204 checkGLcall("draw");
5205
5206 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1);
5207 wined3d_context_gl_bind_texture(context_gl, info.bind_target, 0);
5208}
static void wined3d_context_gl_unload_numbered_arrays(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:4873
static void apply_texture_blit_state(const struct wined3d_gl_info *gl_info, struct gl_texture *texture, GLenum target, unsigned int level, enum wined3d_texture_filter_type filter)
Definition: context_gl.c:5101
void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *rect, struct wined3d_blt_info *info)
Definition: texture.c:173
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GL_TEXTURE_MAX_LEVEL
Definition: gl.h:1504
#define GL_FLOAT
Definition: gl.h:183
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_ARRAY_BUFFER
Definition: glext.h:336
#define GL_STREAM_DRAW
Definition: glext.h:347
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
Definition: quads.c:63
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
struct wined3d_texture t
Definition: wined3d_gl.h:941
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
@ ARB_VERTEX_BUFFER_OBJECT
Definition: wined3d_gl.h:153

Referenced by glsl_blitter_blit().

◆ wined3d_context_gl_enable_clip_distances()

void wined3d_context_gl_enable_clip_distances ( struct wined3d_context_gl *  context_gl,
uint32_t  enable_mask 
)

Definition at line 2408 of file context_gl.c.

2409{
2410 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2411 unsigned int clip_distance_count, i;
2412 uint32_t disable_mask, current_mask;
2413
2414 clip_distance_count = gl_info->limits.user_clip_distances;
2415 disable_mask = ~enable_mask;
2416 enable_mask &= wined3d_mask_from_size(clip_distance_count);
2417 disable_mask &= wined3d_mask_from_size(clip_distance_count);
2418 current_mask = context_gl->c.clip_distance_mask;
2419 context_gl->c.clip_distance_mask = enable_mask;
2420
2421 enable_mask &= ~current_mask;
2422 while (enable_mask)
2423 {
2424 i = wined3d_bit_scan(&enable_mask);
2425 gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i);
2426 }
2427 disable_mask &= current_mask;
2428 while (disable_mask)
2429 {
2430 i = wined3d_bit_scan(&disable_mask);
2431 gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i);
2432 }
2433 checkGLcall("toggle clip distances");
2434}
#define GL_CLIP_DISTANCE0
Definition: glext.h:506

Referenced by shader_glsl_update_graphics_program(), state_clipping(), and wined3d_context_gl_apply_blit_state().

◆ wined3d_context_gl_end_transform_feedback()

void wined3d_context_gl_end_transform_feedback ( struct wined3d_context_gl *  context_gl)

Definition at line 4228 of file context_gl.c.

4229{
4230 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4231
4232 if (context_gl->c.transform_feedback_active)
4233 {
4234 GL_EXTCALL(glEndTransformFeedback());
4235 checkGLcall("glEndTransformFeedback");
4236 context_gl->c.transform_feedback_active = 0;
4237 context_gl->c.transform_feedback_paused = 0;
4238 }
4239}

Referenced by state_so(), wined3d_buffer_gl_destroy_buffer_object(), and wined3d_context_gl_pause_transform_feedback().

◆ wined3d_context_gl_enter()

static void wined3d_context_gl_enter ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1663 of file context_gl.c.

1664{
1665 TRACE("Entering context %p, level %u.\n", context_gl, context_gl->level + 1);
1666
1667 if (!context_gl->level++)
1668 {
1669 const struct wined3d_context_gl *current_context = wined3d_context_gl_get_current();
1670 HGLRC current_gl = wglGetCurrentContext();
1671
1672 if (current_gl && (!current_context || current_context->gl_ctx != current_gl))
1673 {
1674 TRACE("Another GL context (%p on device context %p) is already current.\n",
1675 current_gl, wglGetCurrentDC());
1676 context_gl->restore_ctx = current_gl;
1677 context_gl->restore_dc = wglGetCurrentDC();
1678 context_gl->needs_set = 1;
1679 }
1680 else if (!context_gl->needs_set && !(context_gl->dc_is_private && context_gl->dc_has_format))
1681 {
1682 int current = context_gl->gl_info->gl_ops.wgl.p_wglGetPixelFormat(context_gl->dc);
1683
1684 if ((current && current != context_gl->pixel_format) || (!current && !context_gl->internal_format_set))
1685 context_gl->needs_set = 1;
1686 }
1687 }
1688}
uint32_t internal_format_set
Definition: wined3d_gl.h:612

Referenced by wined3d_context_gl_activate(), and wined3d_context_gl_create_wgl_ctx().

◆ wined3d_context_gl_enum_fbo_entries()

static void wined3d_context_gl_enum_fbo_entries ( const struct wined3d_device *  device,
GLuint  name,
BOOL  rb_namespace,
context_fbo_entry_func_t *  callback 
)
static

Definition at line 1104 of file context_gl.c.

1106{
1107 unsigned int i, j;
1108
1109 for (i = 0; i < device->context_count; ++i)
1110 {
1111 struct wined3d_context_gl *context_gl = wined3d_context_gl(device->contexts[i]);
1112 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1113 struct fbo_entry *entry, *entry2;
1114
1115 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_list, struct fbo_entry, entry)
1116 {
1117 for (j = 0; j < gl_info->limits.buffers + 1; ++j)
1118 {
1119 if (entry->key.objects[j].object == name
1120 && !(entry->key.rb_namespace & (1 << j)) == !rb_namespace)
1121 {
1122 callback(context_gl, entry);
1123 break;
1124 }
1125 }
1126 }
1127 }
1128}
static IPrintDialogCallback callback
Definition: printdlg.c:325

Referenced by context_gl_resource_released().

◆ wined3d_context_gl_find_fbo_entry()

static struct fbo_entry * wined3d_context_gl_find_fbo_entry ( struct wined3d_context_gl *  context_gl,
GLenum  target,
const struct wined3d_rendertarget_info *  render_targets,
const struct wined3d_rendertarget_info *  depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 635 of file context_gl.c.

638{
639 static const struct wined3d_rendertarget_info ds_null = {{0}};
640 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
641 struct wined3d_texture *rt_texture, *ds_texture;
642 struct wined3d_fbo_entry_key fbo_key;
643 unsigned int i, ds_level, rt_level;
644 struct fbo_entry *entry;
645
646 if (depth_stencil->resource && depth_stencil->resource->type != WINED3D_RTYPE_BUFFER
647 && render_targets[0].resource && render_targets[0].resource->type != WINED3D_RTYPE_BUFFER
648 && render_targets[0].resource->format->id != WINED3DFMT_NULL)
649 {
650 rt_texture = wined3d_texture_from_resource(render_targets[0].resource);
651 rt_level = render_targets[0].sub_resource_idx % rt_texture->level_count;
652 ds_texture = wined3d_texture_from_resource(depth_stencil->resource);
653 ds_level = depth_stencil->sub_resource_idx % ds_texture->level_count;
654
655 if (wined3d_texture_get_level_width(ds_texture, ds_level)
656 < wined3d_texture_get_level_width(rt_texture, rt_level)
657 || wined3d_texture_get_level_height(ds_texture, ds_level)
658 < wined3d_texture_get_level_height(rt_texture, rt_level))
659 {
660 WARN("Depth stencil is smaller than the primary color buffer, disabling.\n");
661 depth_stencil = &ds_null;
662 }
663 else if (ds_texture->resource.multisample_type != rt_texture->resource.multisample_type
664 || (ds_texture->resource.multisample_type
665 && ds_texture->resource.multisample_quality != rt_texture->resource.multisample_quality))
666 {
667 WARN("Color multisample type %u and quality %u, depth stencil has %u and %u, disabling ds buffer.\n",
668 rt_texture->resource.multisample_type, rt_texture->resource.multisample_quality,
669 ds_texture->resource.multisample_type, ds_texture->resource.multisample_quality);
670 depth_stencil = &ds_null;
671 }
672 else if (depth_stencil->resource->type == WINED3D_RTYPE_TEXTURE_2D)
673 {
675 context_gl, ds_level, &render_targets[0]);
676 }
677 }
678
679 wined3d_context_gl_generate_fbo_key(context_gl, &fbo_key,
680 render_targets, depth_stencil, color_location, ds_location);
681
682 if (TRACE_ON(d3d))
683 {
685 unsigned int width, height;
686 const char *resource_type;
687
688 TRACE("Dumping FBO attachments:\n");
689 for (i = 0; i < gl_info->limits.buffers; ++i)
690 {
691 if ((resource = render_targets[i].resource))
692 {
693 if (resource->type == WINED3D_RTYPE_BUFFER)
694 {
696 height = 1;
697 resource_type = "buffer";
698 }
699 else
700 {
702 rt_level = render_targets[i].sub_resource_idx % rt_texture->level_count;
703 width = wined3d_texture_get_level_width(rt_texture, rt_level);
704 height = wined3d_texture_get_level_height(rt_texture, rt_level);
705 resource_type = "texture";
706 }
707
708 TRACE(" Color attachment %u: %p, %u format %s, %s %u, %ux%u, %u samples.\n",
709 i, resource, render_targets[i].sub_resource_idx, debug_d3dformat(resource->format->id),
710 fbo_key.rb_namespace & (1 << (i + 1)) ? "renderbuffer" : resource_type,
711 fbo_key.objects[i + 1].object, width, height, resource->multisample_type);
712 }
713 }
714 if ((resource = depth_stencil->resource))
715 {
716 if (resource->type == WINED3D_RTYPE_BUFFER)
717 {
719 height = 1;
720 resource_type = "buffer";
721 }
722 else
723 {
725 ds_level = depth_stencil->sub_resource_idx % ds_texture->level_count;
726 width = wined3d_texture_get_level_width(ds_texture, ds_level);
727 height = wined3d_texture_get_level_height(ds_texture, ds_level);
728 resource_type = "texture";
729 }
730
731 TRACE(" Depth attachment: %p, %u format %s, %s %u, %ux%u, %u samples.\n",
732 resource, depth_stencil->sub_resource_idx, debug_d3dformat(resource->format->id),
733 fbo_key.rb_namespace & (1 << 0) ? "renderbuffer" : resource_type,
734 fbo_key.objects[0].object, width, height, resource->multisample_type);
735 }
736 }
737
738 LIST_FOR_EACH_ENTRY(entry, &context_gl->fbo_list, struct fbo_entry, entry)
739 {
740 if (memcmp(&fbo_key, &entry->key, sizeof(fbo_key)))
741 continue;
742
743 list_remove(&entry->entry);
744 list_add_head(&context_gl->fbo_list, &entry->entry);
745 return entry;
746 }
747
749 {
751 render_targets, depth_stencil, color_location, ds_location);
752 list_add_head(&context_gl->fbo_list, &entry->entry);
753 ++context_gl->fbo_entry_count;
754 }
755 else
756 {
757 entry = LIST_ENTRY(list_tail(&context_gl->fbo_list), struct fbo_entry, entry);
758 wined3d_context_gl_reuse_fbo_entry(context_gl, target, render_targets,
759 depth_stencil, color_location, ds_location, entry);
760 list_remove(&entry->entry);
761 list_add_head(&context_gl->fbo_list, &entry->entry);
762 }
763
764 return entry;
765}
static void wined3d_context_gl_reuse_fbo_entry(struct wined3d_context_gl *context_gl, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location, struct fbo_entry *entry)
Definition: context_gl.c:600
static struct fbo_entry * wined3d_context_gl_create_fbo_entry(const struct wined3d_context_gl *context_gl, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context_gl.c:573
#define WINED3D_MAX_FBO_ENTRIES
Definition: context_gl.c:34
void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, unsigned int level, const struct wined3d_rendertarget_info *rt)
Definition: texture.c:1788
#define TRACE_ON(x)
Definition: compat.h:75
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define resource
Definition: kernel32.h:9
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:139
size_t size
Definition: utils.c:170
struct wined3d_resource resource
unsigned int level_count
#define LIST_ENTRY(type)
Definition: queue.h:175
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by wined3d_context_gl_apply_fbo_state().

◆ wined3d_context_gl_flush_bo_address()

void wined3d_context_gl_flush_bo_address ( struct wined3d_context_gl *  context_gl,
const struct wined3d_const_bo_address *  data,
size_t  size 
)

Definition at line 3003 of file context_gl.c.

3005{
3006 struct wined3d_range range;
3007
3008 TRACE("context_gl %p, data %s, size %Iu.\n", context_gl, debug_const_bo_address(data), size);
3009
3010 range.offset = (uintptr_t)data->addr;
3011 range.size = size;
3012
3013 flush_bo_ranges(context_gl, data, 1, &range);
3014}
static void flush_bo_ranges(struct wined3d_context_gl *context_gl, const struct wined3d_const_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
Definition: context_gl.c:2950
range
Definition: d3dx9_private.h:58
const char * debug_const_bo_address(const struct wined3d_const_bo_address *address)
Definition: utils.c:4593

Referenced by adapter_gl_flush_bo_address().

◆ wined3d_context_gl_free_fence()

void wined3d_context_gl_free_fence ( struct wined3d_fence *  fence)

Definition at line 966 of file context_gl.c.

967{
968 struct wined3d_context_gl *context_gl = fence->context_gl;
969
970 list_remove(&fence->entry);
971 fence->context_gl = NULL;
972
973 if (!wined3d_array_reserve((void **)&context_gl->free_fences,
974 &context_gl->free_fence_size, context_gl->free_fence_count + 1,
975 sizeof(*context_gl->free_fences)))
976 {
977 ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context_gl);
978 return;
979 }
980
981 context_gl->free_fences[context_gl->free_fence_count++] = fence->object;
982}
SIZE_T free_fence_size
Definition: wined3d_gl.h:659

Referenced by wined3d_fence_free(), and wined3d_fence_issue().

◆ wined3d_context_gl_free_occlusion_query()

void wined3d_context_gl_free_occlusion_query ( struct wined3d_occlusion_query *  query)

Definition at line 906 of file context_gl.c.

907{
908 struct wined3d_context_gl *context_gl = query->context_gl;
909
910 list_remove(&query->entry);
911 query->context_gl = NULL;
912
913 if (!wined3d_array_reserve((void **)&context_gl->free_occlusion_queries,
914 &context_gl->free_occlusion_query_size, context_gl->free_occlusion_query_count + 1,
915 sizeof(*context_gl->free_occlusion_queries)))
916 {
917 ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context_gl);
918 return;
919 }
920
921 context_gl->free_occlusion_queries[context_gl->free_occlusion_query_count++] = query->id;
922}
SIZE_T free_occlusion_query_size
Definition: wined3d_gl.h:655

Referenced by wined3d_occlusion_query_ops_destroy(), and wined3d_occlusion_query_ops_issue().

◆ wined3d_context_gl_free_pipeline_statistics_query()

void wined3d_context_gl_free_pipeline_statistics_query ( struct wined3d_pipeline_statistics_query *  query)

Definition at line 1084 of file context_gl.c.

1085{
1086 struct wined3d_context_gl *context_gl = query->context_gl;
1087
1088 list_remove(&query->entry);
1089 query->context_gl = NULL;
1090
1093 sizeof(*context_gl->free_pipeline_statistics_queries)))
1094 {
1095 ERR("Failed to grow free list, leaking GL queries in context %p.\n", context_gl);
1096 return;
1097 }
1098
1100}
SIZE_T free_pipeline_statistics_query_size
Definition: wined3d_gl.h:671

Referenced by wined3d_pipeline_query_ops_destroy(), and wined3d_pipeline_query_ops_issue().

◆ wined3d_context_gl_free_so_statistics_query()

void wined3d_context_gl_free_so_statistics_query ( struct wined3d_so_statistics_query *  query)

Definition at line 1046 of file context_gl.c.

1047{
1048 struct wined3d_context_gl *context_gl = query->context_gl;
1049
1050 list_remove(&query->entry);
1051 query->context_gl = NULL;
1052
1053 if (!wined3d_array_reserve((void **)&context_gl->free_so_statistics_queries,
1055 sizeof(*context_gl->free_so_statistics_queries)))
1056 {
1057 ERR("Failed to grow free list, leaking GL queries %u, %u in context %p.\n",
1058 query->u.id[0], query->u.id[1], context_gl);
1059 return;
1060 }
1061
1062 context_gl->free_so_statistics_queries[context_gl->free_so_statistics_query_count++] = query->u;
1063}
SIZE_T free_so_statistics_query_size
Definition: wined3d_gl.h:667

Referenced by wined3d_so_statistics_query_ops_destroy(), and wined3d_so_statistics_query_ops_issue().

◆ wined3d_context_gl_free_timestamp_query()

void wined3d_context_gl_free_timestamp_query ( struct wined3d_timestamp_query *  query)

Definition at line 1006 of file context_gl.c.

1007{
1008 struct wined3d_context_gl *context_gl = query->context_gl;
1009
1010 list_remove(&query->entry);
1011 query->context_gl = NULL;
1012
1013 if (!wined3d_array_reserve((void **)&context_gl->free_timestamp_queries,
1014 &context_gl->free_timestamp_query_size, context_gl->free_timestamp_query_count + 1,
1015 sizeof(*context_gl->free_timestamp_queries)))
1016 {
1017 ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context_gl);
1018 return;
1019 }
1020
1021 context_gl->free_timestamp_queries[context_gl->free_timestamp_query_count++] = query->id;
1022}
SIZE_T free_timestamp_query_size
Definition: wined3d_gl.h:663

Referenced by wined3d_timestamp_query_ops_destroy(), and wined3d_timestamp_query_ops_issue().

◆ wined3d_context_gl_generate_fbo_key()

static void wined3d_context_gl_generate_fbo_key ( const struct wined3d_context_gl *  context_gl,
struct wined3d_fbo_entry_key *  key,
const struct wined3d_rendertarget_info *  render_targets,
const struct wined3d_rendertarget_info *  depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 557 of file context_gl.c.

560{
561 unsigned int buffers = context_gl->gl_info->limits.buffers;
562 unsigned int i;
563
564 key->rb_namespace = 0;
566
567 for (i = 0; i < buffers; ++i)
568 wined3d_context_gl_set_fbo_key_for_render_target(context_gl, key, i + 1, &render_targets[i], color_location);
569
570 memset(&key->objects[buffers + 1], 0, (ARRAY_SIZE(key->objects) - buffers - 1) * sizeof(*key->objects));
571}
static void wined3d_context_gl_set_fbo_key_for_render_target(const struct wined3d_context_gl *context_gl, struct wined3d_fbo_entry_key *key, unsigned int idx, const struct wined3d_rendertarget_info *render_target, DWORD location)
Definition: context_gl.c:487
const GLuint * buffers
Definition: glext.h:5916
Definition: copy.c:22

Referenced by wined3d_context_gl_create_fbo_entry(), wined3d_context_gl_find_fbo_entry(), and wined3d_context_gl_reuse_fbo_entry().

◆ wined3d_context_gl_generate_rt_mask_no_fbo()

static uint32_t wined3d_context_gl_generate_rt_mask_no_fbo ( const struct wined3d_context_gl *  context_gl,
struct wined3d_resource *  rt 
)
static

Definition at line 3144 of file context_gl.c.

3146{
3147 if (!rt || rt->format->id == WINED3DFMT_NULL)
3148 return 0;
3149 else if (rt->type != WINED3D_RTYPE_BUFFER && texture_from_resource(rt)->swapchain)
3151 else
3153}
GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl)
Definition: context_gl.c:3139
enum wined3d_resource_type type
const struct wined3d_format * format

Referenced by wined3d_context_gl_apply_clear_state().

◆ wined3d_context_gl_get_current()

◆ wined3d_context_gl_get_offscreen_gl_buffer()

GLenum wined3d_context_gl_get_offscreen_gl_buffer ( const struct wined3d_context_gl *  context_gl)

Definition at line 3139 of file context_gl.c.

3140{
3141 return GL_COLOR_ATTACHMENT0;
3142}

Referenced by texture2d_read_from_framebuffer(), and wined3d_context_gl_generate_rt_mask_no_fbo().

◆ wined3d_context_gl_get_rt_size()

static void wined3d_context_gl_get_rt_size ( const struct wined3d_context_gl *  context_gl,
SIZE *  size 
)
static

Definition at line 2387 of file context_gl.c.

2388{
2389 const struct wined3d_texture *rt = context_gl->c.current_rt.texture;
2390 unsigned int level;
2391
2392 if (rt->swapchain)
2393 {
2394 RECT window_size;
2395
2396 GetClientRect(context_gl->window, &window_size);
2397 size->cx = window_size.right - window_size.left;
2398 size->cy = window_size.bottom - window_size.top;
2399
2400 return;
2401 }
2402
2403 level = context_gl->c.current_rt.sub_resource_idx % rt->level_count;
2406}
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: dcommon.idl:28
struct wined3d_swapchain * swapchain

Referenced by wined3d_context_gl_apply_blit_state(), and wined3d_context_gl_draw_shaded_quad().

◆ wined3d_context_gl_get_tex_unit_mapping()

const unsigned int * wined3d_context_gl_get_tex_unit_mapping ( const struct wined3d_context_gl *  context_gl,
const struct wined3d_shader_version *  shader_version,
unsigned int *  base,
unsigned int *  count 
)

Definition at line 2350 of file context_gl.c.

2352{
2353 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
2354
2355 if (!shader_version)
2356 {
2357 *base = 0;
2359 return context_gl->tex_unit_map;
2360 }
2361
2362 if (shader_version->major >= 4)
2363 {
2364 wined3d_gl_limits_get_texture_unit_range(&gl_info->limits, shader_version->type, base, count);
2365 return NULL;
2366 }
2367
2368 switch (shader_version->type)
2369 {
2371 *base = 0;
2373 break;
2377 break;
2378 default:
2379 ERR("Unhandled shader type %#x.\n", shader_version->type);
2380 *base = 0;
2381 *count = 0;
2382 }
2383
2384 return context_gl->tex_unit_map;
2385}
void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits, enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count)
Definition: utils.c:6712
enum wined3d_shader_type type
#define WINED3D_MAX_FRAGMENT_SAMPLERS
Definition: wined3d.h:1598
#define WINED3D_MAX_VERTEX_SAMPLERS
Definition: wined3d.h:1599

Referenced by create_combined_resource_sampler_bindings(), shader_glsl_load_samplers(), shader_glsl_map_tex_unit(), and wined3d_context_gl_bind_shader_resources().

◆ wined3d_context_gl_init()

HRESULT wined3d_context_gl_init ( struct wined3d_context_gl *  context_gl,
struct wined3d_swapchain_gl *  swapchain_gl 
)

Definition at line 2032 of file context_gl.c.

2033{
2034 struct wined3d_context *context = &context_gl->c;
2035 const struct wined3d_d3d_info *d3d_info;
2036 const struct wined3d_gl_info *gl_info;
2037 struct wined3d_device *device;
2038 BOOL new_drawable;
2039 unsigned int i;
2040
2041 TRACE("context_gl %p, swapchain %p.\n", context_gl, swapchain_gl);
2042
2043 wined3d_context_init(&context_gl->c, &swapchain_gl->s);
2044
2045 device = context->device;
2046 gl_info = &wined3d_adapter_gl(device->adapter)->gl_info;
2047 context_gl->gl_info = gl_info;
2048 d3d_info = context->d3d_info;
2049
2050 context_gl->tid = GetCurrentThreadId();
2051 context_gl->window = context->swapchain->win_handle;
2052 if (context_gl->window == GetDesktopWindow())
2053 {
2054 TRACE("Swapchain is created on the desktop window, trying backup device context.\n");
2055 context_gl->dc = NULL;
2056 }
2057 else if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
2058 WARN("Failed to retrieve device context, trying swapchain backup.\n");
2059
2060 if (!context_gl->dc)
2061 {
2063 {
2064 ERR("Failed to retrieve a device context.\n");
2065 return E_FAIL;
2066 }
2067 context_gl->dc_is_private = TRUE;
2068 }
2069
2070 list_init(&context_gl->fbo_list);
2071 list_init(&context_gl->fbo_destroy_list);
2072
2073 list_init(&context_gl->occlusion_queries);
2074 list_init(&context_gl->fences);
2075 list_init(&context_gl->timestamp_queries);
2076 list_init(&context_gl->so_statistics_queries);
2078
2079 for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
2080 context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
2081 for (i = 0; i < ARRAY_SIZE(context_gl->rev_tex_unit_map); ++i)
2083 if (gl_info->limits.graphics_samplers >= WINED3D_MAX_COMBINED_SAMPLERS)
2084 {
2085 /* Initialize the texture unit mapping to a 1:1 mapping. */
2086 unsigned int base, count;
2087
2090 {
2091 ERR("Unexpected texture unit base index %u.\n", base);
2092 goto fail;
2093 }
2094 for (i = 0; i < min(count, WINED3D_MAX_FRAGMENT_SAMPLERS); ++i)
2095 {
2096 context_gl->tex_unit_map[i] = base + i;
2097 context_gl->rev_tex_unit_map[base + i] = i;
2098 }
2099
2102 {
2103 ERR("Unexpected texture unit base index %u.\n", base);
2104 goto fail;
2105 }
2106 for (i = 0; i < min(count, WINED3D_MAX_VERTEX_SAMPLERS); ++i)
2107 {
2110 }
2111 }
2112
2113 if (!(context_gl->texture_type = calloc(gl_info->limits.combined_samplers,
2114 sizeof(*context_gl->texture_type))))
2115 goto fail;
2116
2117 if (!wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl, &new_drawable))
2118 goto fail;
2119
2120 /* Set up the context defaults. */
2121
2123
2124 if (!wined3d_context_gl_set_current(context_gl))
2125 {
2126 ERR("Cannot activate context to set up defaults.\n");
2128 if (!wglDeleteContext(context_gl->gl_ctx))
2129 ERR("wglDeleteContext(%p) failed, last error %#lx.\n", context_gl->gl_ctx, GetLastError());
2130 goto fail;
2131 }
2132
2133 if (context_debug_output_enabled(gl_info))
2134 {
2135 GL_EXTCALL(glDebugMessageCallback(wined3d_debug_callback, context));
2136 if (TRACE_ON(d3d_sync))
2137 gl_info->gl_ops.gl.p_glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
2138 GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_FALSE));
2139 if (ERR_ON(d3d))
2140 {
2141 GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_ERROR,
2142 GL_DONT_CARE, 0, NULL, GL_TRUE));
2143 }
2144 if (FIXME_ON(d3d))
2145 {
2147 GL_DONT_CARE, 0, NULL, GL_TRUE));
2149 GL_DONT_CARE, 0, NULL, GL_TRUE));
2150 GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PORTABILITY,
2151 GL_DONT_CARE, 0, NULL, GL_TRUE));
2152 }
2153 if (WARN_ON(d3d_perf))
2154 {
2155 GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE,
2156 GL_DONT_CARE, 0, NULL, GL_TRUE));
2157 }
2158 }
2159
2161 gl_info->gl_ops.gl.p_glGetIntegerv(GL_AUX_BUFFERS, &context_gl->aux_buffers);
2162
2163 TRACE("Setting up the screen\n");
2164
2166 {
2167 gl_info->gl_ops.gl.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
2168 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
2169
2170 gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2171 checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
2172
2174 checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
2175 }
2176 else
2177 {
2178 GLuint vao;
2179
2180 GL_EXTCALL(glGenVertexArrays(1, &vao));
2181 GL_EXTCALL(glBindVertexArray(vao));
2182 checkGLcall("creating VAO");
2183 }
2184
2185 gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);
2186 checkGLcall("glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);");
2187 gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2188 checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, 1);");
2189
2190 if (gl_info->supported[NV_TEXTURE_SHADER2])
2191 {
2192 /* Set up the previous texture input for all shader units. This applies to bump mapping, and in d3d
2193 * the previous texture where to source the offset from is always unit - 1.
2194 */
2195 for (i = 1; i < gl_info->limits.ffp_textures; ++i)
2196 {
2197 wined3d_context_gl_active_texture(context_gl, gl_info, i);
2198 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV,
2200 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...");
2201 }
2202 }
2203 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2204 {
2205 /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are
2206 * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but
2207 * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline,
2208 * because the ARBFP extension is enabled by the ARBFP pipeline at context creation, but no program
2209 * is ever assigned.
2210 *
2211 * So make sure a program is assigned to each context. The first real ARBFP use will set a different
2212 * program and the dummy program is destroyed when the context is destroyed.
2213 */
2214 static const char dummy_program[] =
2215 "!!ARBfp1.0\n"
2216 "MOV result.color, fragment.color.primary;\n"
2217 "END\n";
2218 GL_EXTCALL(glGenProgramsARB(1, &context_gl->dummy_arbfp_prog));
2219 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, context_gl->dummy_arbfp_prog));
2220 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
2221 GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program));
2222 }
2223
2224 if (gl_info->supported[ARB_POINT_SPRITE])
2225 {
2226 /* The actual effect of D3DRS_POINTSPRITEENABLE is more accurately
2227 * congruent to GL_COORD_REPLACE_ARB. GL_POINT_SPRITE_ARB, when
2228 * disabled, affects point rasterization (which we do not want),
2229 * implicitly disables GL_COORD_REPLACE_ARB, and causes gl_PointCoord
2230 * to return an undefined value.
2231 *
2232 * We implement D3DRS_POINTSPRITEENABLE by altering the shader to read
2233 * from gl_PointCoord or from the actual texcoord, so we do not need
2234 * GL_COORD_REPLACE_ARB, nor do we need to dynamically toggle
2235 * GL_POINT_SPRITE_ARB. */
2236
2237 gl_info->gl_ops.gl.p_glEnable(GL_POINT_SPRITE_ARB);
2238
2239 for (i = 0; i < gl_info->limits.ffp_textures; ++i)
2240 {
2241 wined3d_context_gl_active_texture(context_gl, gl_info, i);
2242 gl_info->gl_ops.gl.p_glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
2243 checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
2244 }
2245 }
2246
2247 if (!gl_info->supported[ARB_CLIP_CONTROL] && gl_info->supported[WINED3D_GL_VERSION_2_0])
2248 {
2250 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT)");
2251 }
2252
2253 if (gl_info->supported[ARB_PROVOKING_VERTEX])
2254 {
2255 GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
2256 }
2257 else if (gl_info->supported[EXT_PROVOKING_VERTEX])
2258 {
2259 GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT));
2260 }
2262 {
2263 if (gl_info->supported[ARB_ES3_COMPATIBILITY])
2264 {
2265 gl_info->gl_ops.gl.p_glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
2266 checkGLcall("enable GL_PRIMITIVE_RESTART_FIXED_INDEX");
2267 }
2268 else
2269 {
2270 FIXME("OpenGL implementation does not support GL_PRIMITIVE_RESTART_FIXED_INDEX.\n");
2271 }
2272 }
2274 && gl_info->supported[ARB_SEAMLESS_CUBE_MAP])
2275 {
2276 gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
2277 checkGLcall("enable seamless cube map filtering");
2278 }
2279 if (gl_info->supported[ARB_CLIP_CONTROL])
2281
2282 /* If this happens to be the first context for the device, dummy textures
2283 * are not created yet. In that case, they will be created (and bound) by
2284 * create_dummy_textures right after this context is initialized. */
2285 if (wined3d_device_gl(device)->dummy_textures.tex_2d)
2287
2288 /* Initialise all rectangles to avoid resetting unused ones later. */
2289 gl_info->gl_ops.gl.p_glScissor(0, 0, 0, 0);
2290 checkGLcall("glScissor");
2291
2292 if (new_drawable)
2293 {
2294 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
2295 gl_info->gl_ops.gl.p_glClearDepth(1.0f);
2296 gl_info->gl_ops.gl.p_glClearStencil(0);
2298 checkGLcall("glClear");
2299 }
2300 return WINED3D_OK;
2301
2302fail:
2303 free(context_gl->texture_type);
2304 wined3d_release_dc(context_gl->window, context_gl->dc);
2305 return E_FAIL;
2306}
#define DCX_USESTYLE
Definition: GetDCEx.c:10
void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1790
static void WINE_GLAPI wined3d_debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, void *ctx)
Definition: context_gl.c:1856
#define E_FAIL
Definition: ddrawi.h:102
void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain)
Definition: context.c:89
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
#define GL_AUX_BUFFERS
Definition: gl.h:492
#define GL_PACK_ALIGNMENT
Definition: gl.h:626
#define GL_TEXTURE0_ARB
Definition: gl.h:1966
#define GL_BACK
Definition: gl.h:271
#define GL_TEXTURE_ENV
Definition: gl.h:642
#define GL_LIGHT_MODEL_LOCAL_VIEWER
Definition: gl.h:334
#define GL_UNPACK_ALIGNMENT
Definition: gl.h:632
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define GL_TEXTURE_ENV_MODE
Definition: gl.h:643
#define GL_DONT_CARE
Definition: gl.h:583
#define GL_STENCIL_BUFFER_BIT
Definition: gl.h:712
#define GL_LIGHT_MODEL_COLOR_CONTROL
Definition: gl.h:1498
#define GL_SEPARATE_SPECULAR_COLOR
Definition: gl.h:1500
#define GL_DEPTH_BUFFER_BIT
Definition: gl.h:710
#define GL_POINT_SPRITE_ARB
Definition: glext.h:1586
#define GL_COMBINE_EXT
Definition: glext.h:3229
#define GL_PROGRAM_FORMAT_ASCII_ARB
Definition: glext.h:1405
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466
#define GL_TEXTURE_SHADER_NV
Definition: glext.h:3685
#define GL_TEXTURE_CUBE_MAP_SEAMLESS
Definition: glext.h:1913
#define GL_FIRST_VERTEX_CONVENTION_EXT
Definition: glext.h:4920
#define GL_PREVIOUS_TEXTURE_INPUT_NV
Definition: glext.h:3694
#define GL_FIRST_VERTEX_CONVENTION
Definition: glext.h:1907
#define GL_COORD_REPLACE_ARB
Definition: glext.h:1587
#define GL_POINT_SPRITE_COORD_ORIGIN
Definition: glext.h:460
#define DCX_CACHE
Definition: winuser.h:2150
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
#define calloc
Definition: rosglue.h:14
unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS+WINED3D_MAX_VERTEX_SAMPLERS]
Definition: wined3d_gl.h:677
GLuint dummy_arbfp_prog
Definition: wined3d_gl.h:684
uint32_t wined3d_creation_flags
#define GL_DEBUG_TYPE_PORTABILITY
Definition: wgl.h:947
#define GL_PRIMITIVE_RESTART_FIXED_INDEX
Definition: wgl.h:3235
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
Definition: wgl.h:931
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
Definition: wgl.h:952
#define GL_DEBUG_TYPE_ERROR
Definition: wgl.h:934
#define GL_DEBUG_OUTPUT_SYNCHRONOUS
Definition: wgl.h:896
#define GL_DEBUG_TYPE_PERFORMANCE
Definition: wgl.h:942
#define WINED3D_MAX_COMBINED_SAMPLERS
Definition: wined3d.h:1600
#define WINED3D_OK
Definition: wined3d.h:33
#define WINED3D_NO_PRIMITIVE_RESTART
Definition: wined3d.h:1332
#define WINED3D_LEGACY_CUBEMAP_FILTERING
Definition: wined3d.h:1333
@ NV_TEXTURE_SHADER2
Definition: wined3d_gl.h:218
@ ARB_SEAMLESS_CUBE_MAP
Definition: wined3d_gl.h:107
@ ARB_FRAGMENT_PROGRAM
Definition: wined3d_gl.h:80
@ ARB_PROVOKING_VERTEX
Definition: wined3d_gl.h:103
@ ARB_ES3_COMPATIBILITY
Definition: wined3d_gl.h:76
@ WINED3D_GL_VERSION_2_0
Definition: wined3d_gl.h:235
@ ARB_POINT_SPRITE
Definition: wined3d_gl.h:101
@ EXT_PROVOKING_VERTEX
Definition: wined3d_gl.h:185
#define WINED3D_UNMAPPED_STAGE

Referenced by wined3d_swapchain_gl_create_context().

◆ wined3d_context_gl_load_numbered_arrays()

static void wined3d_context_gl_load_numbered_arrays ( struct wined3d_context_gl *  context_gl,
const struct wined3d_stream_info *  stream_info,
const struct wined3d_state *  state 
)
static

Definition at line 4885 of file context_gl.c.

4887{
4888 struct wined3d_context *context = &context_gl->c;
4889 const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
4890 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4891 GLuint current_bo, bo;
4892 unsigned int i;
4893
4894 /* Default to no instancing. */
4895 current_bo = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0u : 0;
4896
4897 if (stream_info->use_map & ~wined3d_mask_from_size(gl_info->limits.vertex_attribs))
4898 {
4899 static unsigned int once;
4900
4901 if (!once++)
4902 FIXME("More than the supported %u vertex attributes are in use.\n", gl_info->limits.vertex_attribs);
4903 }
4904
4905 for (i = 0; i < gl_info->limits.vertex_attribs; ++i)
4906 {
4907 const struct wined3d_stream_info_element *element = &stream_info->elements[i];
4908 const struct wined3d_stream_state *stream;
4909 const struct wined3d_format_gl *format_gl;
4910
4911 if (!(stream_info->use_map & (1u << i)))
4912 {
4913 if (context->numbered_array_mask & (1u << i))
4915 if (!(context_gl->default_attrib_value_set & (1u << i)))
4916 GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f));
4917 context_gl->default_attrib_value_set |= 1u << i;
4918 continue;
4919 }
4920
4921 format_gl = wined3d_format_gl(element->format);
4922 stream = &state->streams[element->stream_idx];
4923
4924 if (gl_info->supported[ARB_INSTANCED_ARRAYS])
4925 {
4926 unsigned int divisor = 0;
4927
4928 if (element->instanced)
4929 divisor = element->divisor ? element->divisor : UINT_MAX;
4930 GL_EXTCALL(glVertexAttribDivisor(i, divisor));
4931 }
4932 else if (element->divisor)
4933 {
4934 /* Unload instanced arrays, they will be loaded using immediate
4935 * mode instead. */
4936 if (context->numbered_array_mask & (1u << i))
4938 context_gl->default_attrib_value_set &= ~(1u << i);
4939 continue;
4940 }
4941
4942 TRACE("Loading array %u %s.\n", i, debug_bo_address(&element->data));
4943
4944 if (element->stride)
4945 {
4947 unsigned int format_attrs = format_gl->f.attrs;
4948
4949 bo = wined3d_bo_gl_id(element->data.buffer_object);
4950 if (current_bo != bo)
4951 {
4952 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, bo));
4953 checkGLcall("glBindBuffer");
4954 current_bo = bo;
4955 }
4956 if (bo)
4958
4959 /* Use the VBO to find out if a vertex buffer exists, not the vb
4960 * pointer. vb can point to a user pointer data blob. In that case
4961 * current_bo will be 0. If there is a vertex buffer but no vbo we
4962 * won't be load converted attributes anyway. */
4963 if (vs && vs->reg_maps.shader_version.major >= 4 && (format_attrs & WINED3D_FORMAT_ATTR_INTEGER))
4964 {
4965 GL_EXTCALL(glVertexAttribIPointer(i, format_gl->vtx_format,
4966 format_gl->vtx_type, element->stride, offset));
4967 }
4968 else
4969 {
4970 GL_EXTCALL(glVertexAttribPointer(i, format_gl->vtx_format, format_gl->vtx_type,
4971 !!(format_attrs & WINED3D_FORMAT_ATTR_NORMALISED), element->stride, offset));
4972 }
4973
4974 if (!(context->numbered_array_mask & (1u << i)))
4975 {
4976 GL_EXTCALL(glEnableVertexAttribArray(i));
4977 context->numbered_array_mask |= (1u << i);
4978 }
4979 }
4980 else
4981 {
4982 /* Stride = 0 means always the same values.
4983 * glVertexAttribPointer() doesn't do that. Instead disable the
4984 * pointer and set up the attribute statically. But we have to
4985 * figure out the system memory address. */
4986 const BYTE *ptr = element->data.addr;
4987 if (element->data.buffer_object)
4989
4990 if (context->numbered_array_mask & (1u << i))
4992
4993 switch (format_gl->f.id)
4994 {
4996 GL_EXTCALL(glVertexAttrib1fv(i, (const GLfloat *)ptr));
4997 break;
4999 GL_EXTCALL(glVertexAttrib2fv(i, (const GLfloat *)ptr));
5000 break;
5002 GL_EXTCALL(glVertexAttrib3fv(i, (const GLfloat *)ptr));
5003 break;
5005 GL_EXTCALL(glVertexAttrib4fv(i, (const GLfloat *)ptr));
5006 break;
5008 GL_EXTCALL(glVertexAttrib4ubv(i, ptr));
5009 break;
5011 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
5012 {
5013 const DWORD *src = (const DWORD *)ptr;
5014 DWORD c = *src & 0xff00ff00u;
5015 c |= (*src & 0xff0000u) >> 16;
5016 c |= (*src & 0xffu) << 16;
5017 GL_EXTCALL(glVertexAttrib4Nubv(i, (GLubyte *)&c));
5018 break;
5019 }
5020 /* else fallthrough */
5022 GL_EXTCALL(glVertexAttrib4Nubv(i, ptr));
5023 break;
5025 GL_EXTCALL(glVertexAttrib2sv(i, (const GLshort *)ptr));
5026 break;
5028 GL_EXTCALL(glVertexAttrib4sv(i, (const GLshort *)ptr));
5029 break;
5031 {
5032 const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
5033 GL_EXTCALL(glVertexAttrib4Nsv(i, s));
5034 break;
5035 }
5037 {
5038 const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
5039 GL_EXTCALL(glVertexAttrib4Nusv(i, s));
5040 break;
5041 }
5043 GL_EXTCALL(glVertexAttrib4Nsv(i, (const GLshort *)ptr));
5044 break;
5046 GL_EXTCALL(glVertexAttrib4Nusv(i, (const GLushort *)ptr));
5047 break;
5049 FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
5050 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
5051 break;
5053 FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
5054 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
5055 break;
5057 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
5058 {
5059 /* Not supported by GL_ARB_half_float_vertex. */
5060 GL_EXTCALL(glVertexAttrib2hvNV(i, (const GLhalfNV *)ptr));
5061 }
5062 else
5063 {
5064 float x = float_16_to_32(((const unsigned short *)ptr) + 0);
5065 float y = float_16_to_32(((const unsigned short *)ptr) + 1);
5066 GL_EXTCALL(glVertexAttrib2f(i, x, y));
5067 }
5068 break;
5070 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
5071 {
5072 /* Not supported by GL_ARB_half_float_vertex. */
5073 GL_EXTCALL(glVertexAttrib4hvNV(i, (const GLhalfNV *)ptr));
5074 }
5075 else
5076 {
5077 float x = float_16_to_32(((const unsigned short *)ptr) + 0);
5078 float y = float_16_to_32(((const unsigned short *)ptr) + 1);
5079 float z = float_16_to_32(((const unsigned short *)ptr) + 2);
5080 float w = float_16_to_32(((const unsigned short *)ptr) + 3);
5081 GL_EXTCALL(glVertexAttrib4f(i, x, y, z, w));
5082 }
5083 break;
5084 default:
5085 ERR("Unexpected declaration in stride 0 attributes.\n");
5086 break;
5087
5088 }
5089 context_gl->default_attrib_value_set &= ~(1u << i);
5090 }
5091 }
5092 checkGLcall("Loading numbered arrays");
5093}
static void wined3d_context_gl_unload_numbered_array(struct wined3d_context_gl *context_gl, unsigned int i)
Definition: context_gl.c:4861
static const void * get_vertex_attrib_pointer(const struct wined3d_stream_info_element *element, const struct wined3d_state *state)
Definition: context_gl.c:4851
float float_16_to_32(const unsigned short in)
Definition: math.c:2203
const char * debug_bo_address(const struct wined3d_bo_address *address)
Definition: utils.c:4600
#define UINT_MAX
Definition: limits.h:27
unsigned char GLubyte
Definition: gl.h:157
short GLshort
Definition: gl.h:155
float GLfloat
Definition: gl.h:161
GLdouble s
Definition: gl.h:2039
unsigned short GLushort
Definition: gl.h:158
unsigned short GLhalfNV
Definition: glext.h:5520
const GLubyte * c
Definition: glext.h:8905
GLuint divisor
Definition: glext.h:6313
GLdouble GLdouble z
Definition: glext.h:5874
Definition: parse.h:23
uint32_t default_attrib_value_set
Definition: wined3d_gl.h:616
struct wined3d_format f
Definition: wined3d_gl.h:1142
@ WINED3DFMT_R16G16_UNORM
Definition: wined3d.h:192
@ WINED3DFMT_R10G10B10X2_UINT
Definition: wined3d.h:145
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:171
@ WINED3DFMT_R16G16_SNORM
Definition: wined3d.h:194
@ WINED3DFMT_R16G16B16A16_SINT
Definition: wined3d.h:169
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:161
@ WINED3DFMT_R16G16B16A16_FLOAT
Definition: wined3d.h:165
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:185
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:166
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:198
@ WINED3DFMT_R16G16_FLOAT
Definition: wined3d.h:191
@ WINED3DFMT_R8G8B8A8_UINT
Definition: wined3d.h:187
@ WINED3DFMT_R10G10B10X2_SNORM
Definition: wined3d.h:146
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:157
@ WINED3DFMT_R16G16B16A16_SNORM
Definition: wined3d.h:168
@ WINED3DFMT_R16G16_SINT
Definition: wined3d.h:195
@ NV_HALF_FLOAT
Definition: wined3d_gl.h:210
@ NV_VERTEX_PROGRAM
Definition: wined3d_gl.h:219
@ ARB_VERTEX_ARRAY_BGRA
Definition: wined3d_gl.h:152
static GLuint wined3d_bo_gl_id(struct wined3d_bo *bo)
Definition: wined3d_gl.h:434
#define WINED3D_FORMAT_ATTR_INTEGER
static void wined3d_buffer_validate_user(struct wined3d_buffer *buffer)
#define WINED3D_FORMAT_ATTR_NORMALISED

Referenced by wined3d_context_gl_update_stream_sources().

◆ wined3d_context_gl_map_bo_address()

void * wined3d_context_gl_map_bo_address ( struct wined3d_context_gl *  context_gl,
const struct wined3d_bo_address *  data,
size_t  size,
uint32_t  flags 
)

Definition at line 2932 of file context_gl.c.

2934{
2935 struct wined3d_bo *bo;
2936 void *map_ptr;
2937
2938 if (!(bo = data->buffer_object))
2939 return data->addr;
2940
2941 if (!(map_ptr = wined3d_bo_gl_map(wined3d_bo_gl(bo), context_gl, flags)))
2942 {
2943 ERR("Failed to map bo.\n");
2944 return NULL;
2945 }
2946
2947 return (uint8_t *)map_ptr + bo->buffer_offset + (uintptr_t)data->addr;
2948}
static void * wined3d_bo_gl_map(struct wined3d_bo_gl *bo, struct wined3d_context_gl *context_gl, uint32_t flags)
Definition: context_gl.c:2797

Referenced by adapter_gl_map_bo_address(), wined3d_context_gl_copy_bo_address(), wined3d_texture_gl_load_texture(), and wined3d_texture_gl_upload_data().

◆ wined3d_context_gl_map_fixed_function_samplers()

static void wined3d_context_gl_map_fixed_function_samplers ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)
static

Definition at line 3564 of file context_gl.c.

3566{
3567 const struct wined3d_d3d_info *d3d_info = context_gl->c.d3d_info;
3568 unsigned int i, tex;
3569 uint32_t ffu_map;
3570
3571 ffu_map = context_gl->c.fixed_function_usage_map;
3572
3573 if (d3d_info->ffp_fragment_caps.max_textures == d3d_info->ffp_fragment_caps.max_blend_stages
3574 || context_gl->c.lowest_disabled_stage <= d3d_info->ffp_fragment_caps.max_textures)
3575 {
3576 while (ffu_map)
3577 {
3578 i = wined3d_bit_scan(&ffu_map);
3579 if (context_gl->tex_unit_map[i] != i)
3580 {
3581 wined3d_context_gl_map_stage(context_gl, i, i);
3583 context_invalidate_texture_stage(&context_gl->c, i);
3584 }
3585 }
3586 return;
3587 }
3588
3589 /* Now work out the mapping */
3590 tex = 0;
3591 while (ffu_map)
3592 {
3593 i = wined3d_bit_scan(&ffu_map);
3594 if (context_gl->tex_unit_map[i] != tex)
3595 {
3596 wined3d_context_gl_map_stage(context_gl, i, tex);
3598 context_invalidate_texture_stage(&context_gl->c, i);
3599 }
3600
3601 ++tex;
3602 }
3603}
static void wined3d_context_gl_map_stage(struct wined3d_context_gl *context_gl, unsigned int stage, unsigned int unit)
Definition: context_gl.c:3472
static void context_invalidate_texture_stage(struct wined3d_context *context, DWORD stage)
Definition: context_gl.c:3487
struct fragment_caps ffp_fragment_caps

Referenced by wined3d_context_gl_update_tex_unit_map().

◆ wined3d_context_gl_map_psamplers()

static void wined3d_context_gl_map_psamplers ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)
static

Definition at line 3605 of file context_gl.c.

3606{
3607 const struct wined3d_d3d_info *d3d_info = context_gl->c.d3d_info;
3608 const struct wined3d_shader_resource_info *resource_info =
3609 state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.resource_info;
3610 unsigned int i;
3611
3612 for (i = 0; i < WINED3D_MAX_FRAGMENT_SAMPLERS; ++i)
3613 {
3614 if (resource_info[i].type && context_gl->tex_unit_map[i] != i)
3615 {
3616 wined3d_context_gl_map_stage(context_gl, i, i);
3618 if (i < d3d_info->ffp_fragment_caps.max_blend_stages)
3619 context_invalidate_texture_stage(&context_gl->c, i);
3620 }
3621 }
3622}

Referenced by wined3d_context_gl_update_tex_unit_map().

◆ wined3d_context_gl_map_stage()

static void wined3d_context_gl_map_stage ( struct wined3d_context_gl *  context_gl,
unsigned int  stage,
unsigned int  unit 
)
static

Definition at line 3472 of file context_gl.c.

3473{
3474 unsigned int i = context_gl->rev_tex_unit_map[unit];
3475 unsigned int j = context_gl->tex_unit_map[stage];
3476
3477 TRACE("Mapping stage %u to unit %u.\n", stage, unit);
3478 context_gl->tex_unit_map[stage] = unit;
3479 if (i != WINED3D_UNMAPPED_STAGE && i != stage)
3480 context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
3481
3482 context_gl->rev_tex_unit_map[unit] = stage;
3483 if (j != WINED3D_UNMAPPED_STAGE && j != unit)
3485}

Referenced by wined3d_context_gl_map_fixed_function_samplers(), wined3d_context_gl_map_psamplers(), and wined3d_context_gl_map_vsamplers().

◆ wined3d_context_gl_map_vsamplers()

static void wined3d_context_gl_map_vsamplers ( struct wined3d_context_gl *  context_gl,
BOOL  ps,
const struct wined3d_state *  state 
)
static

Definition at line 3651 of file context_gl.c.

3653{
3654 const struct wined3d_shader_resource_info *vs_resource_info =
3655 state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.resource_info;
3656 const struct wined3d_shader_resource_info *ps_resource_info = NULL;
3657 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3658 int start = min(WINED3D_MAX_COMBINED_SAMPLERS, gl_info->limits.graphics_samplers) - 1;
3659 int i;
3660
3661 /* Note that we only care if a resource is used or not, not the
3662 * resource's specific type. Otherwise we'd need to call
3663 * shader_update_samplers() here for 1.x pixelshaders. */
3664 if (ps)
3665 ps_resource_info = state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.resource_info;
3666
3667 for (i = 0; i < WINED3D_MAX_VERTEX_SAMPLERS; ++i)
3668 {
3669 DWORD vsampler_idx = i + WINED3D_MAX_FRAGMENT_SAMPLERS;
3670 if (vs_resource_info[i].type)
3671 {
3672 while (start >= 0)
3673 {
3674 if (wined3d_context_gl_unit_free_for_vs(context_gl, ps_resource_info, start))
3675 {
3676 if (context_gl->tex_unit_map[vsampler_idx] != start)
3677 {
3678 wined3d_context_gl_map_stage(context_gl, vsampler_idx, start);
3680 }
3681
3682 --start;
3683 break;
3684 }
3685
3686 --start;
3687 }
3688 if (context_gl->tex_unit_map[vsampler_idx] == WINED3D_UNMAPPED_STAGE)
3689 WARN("Couldn't find a free texture unit for vertex sampler %u.\n", i);
3690 }
3691 }
3692}
static BOOL wined3d_context_gl_unit_free_for_vs(const struct wined3d_context_gl *context_gl, const struct wined3d_shader_resource_info *ps_resource_info, unsigned int unit)
Definition: context_gl.c:3624

Referenced by wined3d_context_gl_update_tex_unit_map().

◆ wined3d_context_gl_pause_transform_feedback()

static void wined3d_context_gl_pause_transform_feedback ( struct wined3d_context_gl *  context_gl,
BOOL  force 
)
static

Definition at line 4241 of file context_gl.c.

4242{
4243 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4244
4245 if (!context_gl->c.transform_feedback_active || context_gl->c.transform_feedback_paused)
4246 return;
4247
4248 if (gl_info->supported[ARB_TRANSFORM_FEEDBACK2])
4249 {
4250 GL_EXTCALL(glPauseTransformFeedback());
4251 checkGLcall("glPauseTransformFeedback");
4252 context_gl->c.transform_feedback_paused = 1;
4253 return;
4254 }
4255
4256 WARN("Cannot pause transform feedback operations.\n");
4257
4258 if (force)
4260}
void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:4228
BOOL force
Definition: metahost.c:100
@ ARB_TRANSFORM_FEEDBACK2
Definition: wined3d_gl.h:149

Referenced by draw_primitive(), and wined3d_context_gl_draw_shaded_quad().

◆ wined3d_context_gl_poll_fences()

static void wined3d_context_gl_poll_fences ( struct wined3d_context_gl *  context_gl)
static

Definition at line 2568 of file context_gl.c.

2569{
2570 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2572 SIZE_T i;
2573
2574 for (i = 0; i < context_gl->submitted.fence_count; ++i)
2575 {
2576 f = &context_gl->submitted.fences[i];
2577
2578 if (f->id > device_gl->completed_fence_id)
2579 {
2580 if (wined3d_fence_test(f->fence, &device_gl->d, 0) != WINED3D_FENCE_OK)
2581 continue;
2582 device_gl->completed_fence_id = f->id;
2583 }
2584
2585 wined3d_fence_destroy(f->fence);
2586 if (i != context_gl->submitted.fence_count - 1)
2587 *f = context_gl->submitted.fences[context_gl->submitted.fence_count - 1];
2588 --context_gl->submitted.fence_count;
2589 }
2590}
void wined3d_fence_destroy(struct wined3d_fence *fence)
Definition: query.c:373
enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence, struct wined3d_device *device, uint32_t flags)
Definition: query.c:178
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
@ WINED3D_FENCE_OK
Definition: wined3d_gl.h:447

Referenced by wined3d_context_gl_cleanup_resources().

◆ wined3d_context_gl_queue_fbo_entry_destruction()

static void wined3d_context_gl_queue_fbo_entry_destruction ( struct wined3d_context_gl *  context_gl,
struct fbo_entry *  entry 
)
static

Definition at line 1130 of file context_gl.c.

1132{
1133 list_remove(&entry->entry);
1134 list_add_head(&context_gl->fbo_destroy_list, &entry->entry);
1135}

Referenced by context_gl_resource_released().

◆ wined3d_context_gl_reacquire()

struct wined3d_context_gl * wined3d_context_gl_reacquire ( struct wined3d_context_gl *  context_gl)

Definition at line 4378 of file context_gl.c.

4379{
4380 struct wined3d_context *acquired_context;
4381 struct wined3d_device *device;
4382
4383 if (!context_gl || context_gl->tid != GetCurrentThreadId())
4384 return NULL;
4385
4386 device = context_gl->c.device;
4388
4389 if (context_gl->c.current_rt.texture)
4390 {
4391 wined3d_context_gl_activate(context_gl, context_gl->c.current_rt.texture,
4392 context_gl->c.current_rt.sub_resource_idx);
4393 return context_gl;
4394 }
4395
4396 acquired_context = context_acquire(device, NULL, 0);
4397 if (acquired_context != &context_gl->c)
4398 ERR("Acquired context %p instead of %p.\n", acquired_context, &context_gl->c);
4399 return wined3d_context_gl(acquired_context);
4400}

Referenced by wined3d_fence_issue(), wined3d_fence_test(), wined3d_fence_wait(), wined3d_occlusion_query_ops_issue(), wined3d_occlusion_query_ops_poll(), wined3d_pipeline_query_ops_issue(), wined3d_pipeline_query_ops_poll(), wined3d_so_statistics_query_ops_issue(), wined3d_so_statistics_query_ops_poll(), and wined3d_timestamp_query_ops_poll().

◆ wined3d_context_gl_release()

void wined3d_context_gl_release ( struct wined3d_context_gl *  context_gl)

Definition at line 1631 of file context_gl.c.

1632{
1633 TRACE("Releasing context %p, level %u.\n", context_gl, context_gl->level);
1634
1635 if (WARN_ON(d3d))
1636 {
1637 if (!context_gl->level)
1638 WARN("Context %p is not active.\n", context_gl);
1639 else if (context_gl != wined3d_context_gl_get_current())
1640 WARN("Context %p is not the current context.\n", context_gl);
1641 }
1642
1643 if (!--context_gl->level)
1644 {
1646 context_gl->needs_set = 1;
1647 if (context_gl->restore_ctx)
1648 {
1649 TRACE("Restoring GL context %p on device context %p.\n", context_gl->restore_ctx, context_gl->restore_dc);
1650 context_restore_gl_context(context_gl->gl_info, context_gl->restore_dc, context_gl->restore_ctx);
1651 context_gl->restore_ctx = NULL;
1652 context_gl->restore_dc = NULL;
1653 }
1654
1655 if (context_gl->c.destroy_delayed)
1656 {
1657 TRACE("Destroying context %p.\n", context_gl);
1658 wined3d_context_gl_destroy(context_gl);
1659 }
1660 }
1661}
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2308

Referenced by adapter_gl_release_context().

◆ wined3d_context_gl_restore_pixel_format()

static BOOL wined3d_context_gl_restore_pixel_format ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1165 of file context_gl.c.

1166{
1167 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1168 BOOL ret = FALSE;
1169
1170 if (context_gl->restore_pf && IsWindow(context_gl->restore_pf_win))
1171 {
1173 {
1174 HDC dc = GetDCEx(context_gl->restore_pf_win, 0, DCX_USESTYLE | DCX_CACHE);
1175 if (dc)
1176 {
1177 if (!(ret = GL_EXTCALL(wglSetPixelFormatWINE(dc, context_gl->restore_pf))))
1178 {
1179 ERR("Failed to restore pixel format %d on window %p.\n",
1180 context_gl->restore_pf, context_gl->restore_pf_win);
1181 }
1182 ReleaseDC(context_gl->restore_pf_win, dc);
1183 }
1184 }
1185 else
1186 {
1187 ERR("Unable to restore pixel format %d on window %p.\n",
1188 context_gl->restore_pf, context_gl->restore_pf_win);
1189 }
1190 }
1191
1192 context_gl->restore_pf = 0;
1193 context_gl->restore_pf_win = NULL;
1194 return ret;
1195}
return ret
Definition: mutex.c:147
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI IsWindow(_In_opt_ HWND)
@ WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
Definition: wined3d_gl.h:228

Referenced by wined3d_context_gl_cleanup(), wined3d_context_gl_release(), and wined3d_context_gl_set_pixel_format().

◆ wined3d_context_gl_reuse_fbo_entry()

static void wined3d_context_gl_reuse_fbo_entry ( struct wined3d_context_gl *  context_gl,
GLenum  target,
const struct wined3d_rendertarget_info *  render_targets,
const struct wined3d_rendertarget_info *  depth_stencil,
DWORD  color_location,
DWORD  ds_location,
struct fbo_entry *  entry 
)
static

Definition at line 600 of file context_gl.c.

603{
604 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
605
606 wined3d_context_gl_bind_fbo(context_gl, target, entry->id);
608
610 render_targets, depth_stencil, color_location, ds_location);
611 entry->flags = 0;
612 if (depth_stencil->resource)
613 {
614 if (depth_stencil->resource->format->depth_size)
616 if (depth_stencil->resource->format->stencil_size)
618 }
619}

Referenced by wined3d_context_gl_find_fbo_entry().

◆ wined3d_context_gl_set_current()

BOOL wined3d_context_gl_set_current ( struct wined3d_context_gl *  context_gl)

Definition at line 1571 of file context_gl.c.

1572{
1574
1575 if (old == context_gl)
1576 {
1577 TRACE("Already using D3D context %p.\n", context_gl);
1578 return TRUE;
1579 }
1580
1581 if (old)
1582 {
1583 if (old->c.destroyed)
1584 {
1585 TRACE("Switching away from destroyed context %p.\n", old);
1587 free((void *)old->gl_info);
1588 free(old);
1589 }
1590 else
1591 {
1593 {
1594 const struct wined3d_gl_info *gl_info = old->gl_info;
1595 TRACE("Flushing context %p before switching to %p.\n", old, context_gl);
1596 gl_info->gl_ops.gl.p_glFlush();
1597 }
1598 old->c.current = 0;
1599 }
1600 }
1601
1602 if (context_gl)
1603 {
1604 if (!context_gl->valid)
1605 {
1606 ERR("Trying to make invalid context %p current.\n", context_gl);
1607 return FALSE;
1608 }
1609
1610 TRACE("Switching to D3D context %p, GL context %p, device context %p.\n",
1611 context_gl, context_gl->gl_ctx, context_gl->dc);
1612 if (!wined3d_context_gl_set_gl_context(context_gl))
1613 return FALSE;
1614 context_gl->c.current = 1;
1615 }
1616 else if (wglGetCurrentContext())
1617 {
1618 TRACE("Clearing current D3D context.\n");
1619 if (!wglMakeCurrent(NULL, NULL))
1620 {
1621 unsigned int err = GetLastError();
1622 ERR("Failed to clear current GL context, last error %#x.\n", err);
1624 return FALSE;
1625 }
1626 }
1627
1628 return TlsSetValue(wined3d_context_tls_idx, context_gl);
1629}

Referenced by context_restore_gl_context(), DllMain(), wined3d_context_gl_activate(), wined3d_context_gl_init(), and wined3d_context_gl_set_gl_context().

◆ wined3d_context_gl_set_draw_buffer()

static void wined3d_context_gl_set_draw_buffer ( struct wined3d_context_gl *  context_gl,
GLenum  buffer 
)
static

Definition at line 470 of file context_gl.c.

471{
472 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
473 struct fbo_entry *current_fbo = context_gl->current_fbo;
475 uint32_t *current_mask;
476
477 current_mask = current_fbo ? &current_fbo->rt_mask : &context_gl->draw_buffers_mask;
478 if (new_mask == *current_mask)
479 return;
480
481 gl_info->gl_ops.gl.p_glDrawBuffer(buffer);
482 checkGLcall("glDrawBuffer()");
483
484 *current_mask = new_mask;
485}
uint32_t rt_mask
Definition: wined3d_gl.h:590

Referenced by wined3d_context_gl_apply_fbo_entry().

◆ wined3d_context_gl_set_fbo_key_for_render_target()

static void wined3d_context_gl_set_fbo_key_for_render_target ( const struct wined3d_context_gl *  context_gl,
struct wined3d_fbo_entry_key *  key,
unsigned int  idx,
const struct wined3d_rendertarget_info *  render_target,
DWORD  location 
)
inlinestatic

Definition at line 487 of file context_gl.c.

490{
491 unsigned int sub_resource_idx = render_target->sub_resource_idx;
492 struct wined3d_resource *resource = render_target->resource;
493 struct wined3d_texture_gl *texture_gl;
494
495 if (!resource || resource->format->id == WINED3DFMT_NULL || resource->type == WINED3D_RTYPE_BUFFER)
496 {
497 if (resource && resource->type == WINED3D_RTYPE_BUFFER)
498 FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
499 key->objects[idx].object = 0;
500 key->objects[idx].target = 0;
501 key->objects[idx].level = key->objects[idx].layer = 0;
502 return;
503 }
504
505 if (render_target->gl_view.name)
506 {
507 key->objects[idx].object = render_target->gl_view.name;
508 key->objects[idx].target = render_target->gl_view.target;
509 key->objects[idx].level = 0;
510 key->objects[idx].layer = (render_target->layer_count == 1 ? 0 : WINED3D_ALL_LAYERS);
511 return;
512 }
513
515 if (texture_gl->current_renderbuffer)
516 {
517 key->objects[idx].object = texture_gl->current_renderbuffer->id;
518 key->objects[idx].target = 0;
519 key->objects[idx].level = key->objects[idx].layer = 0;
520 key->rb_namespace |= 1 << idx;
521 return;
522 }
523
524 key->objects[idx].target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx);
525 key->objects[idx].level = sub_resource_idx % texture_gl->t.level_count;
526 key->objects[idx].layer = sub_resource_idx / texture_gl->t.level_count;
527
528 if (render_target->layer_count != 1)
529 key->objects[idx].layer = WINED3D_ALL_LAYERS;
530
531 switch (location)
532 {
534 key->objects[idx].object = wined3d_texture_gl_get_texture_name(texture_gl, &context_gl->c, FALSE);
535 break;
536
538 key->objects[idx].object = wined3d_texture_gl_get_texture_name(texture_gl, &context_gl->c, TRUE);
539 break;
540
542 key->objects[idx].object = texture_gl->rb_multisample;
543 key->objects[idx].target = 0;
544 key->objects[idx].level = key->objects[idx].layer = 0;
545 key->rb_namespace |= 1 << idx;
546 break;
547
549 key->objects[idx].object = texture_gl->rb_resolved;
550 key->objects[idx].target = 0;
551 key->objects[idx].level = key->objects[idx].layer = 0;
552 key->rb_namespace |= 1 << idx;
553 break;
554 }
555}
const struct wined3d_renderbuffer_entry * current_renderbuffer
Definition: wined3d_gl.h:951
static GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx)
Definition: wined3d_gl.h:964
#define WINED3D_LOCATION_TEXTURE_SRGB
#define WINED3D_LOCATION_RB_RESOLVED
#define WINED3D_LOCATION_RB_MULTISAMPLE

Referenced by wined3d_context_gl_generate_fbo_key().

◆ wined3d_context_gl_set_gl_context()

static BOOL wined3d_context_gl_set_gl_context ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1261 of file context_gl.c.

1262{
1263 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
1264 BOOL backup = FALSE;
1265
1266 TRACE("context_gl %p.\n", context_gl);
1267
1268 if (!wined3d_context_gl_set_pixel_format(context_gl))
1269 {
1270 WARN("Failed to set pixel format %d on device context %p.\n",
1271 context_gl->pixel_format, context_gl->dc);
1272 backup = TRUE;
1273 }
1274
1275 if (backup || !wglMakeCurrent(context_gl->dc, context_gl->gl_ctx))
1276 {
1277 WARN("Failed to make GL context %p current on device context %p, last error %#lx.\n",
1278 context_gl->gl_ctx, context_gl->dc, GetLastError());
1279 context_gl->valid = 0;
1280 WARN("Trying fallback to the backup window.\n");
1281
1282 if (context_gl->c.destroyed)
1283 {
1284 FIXME("Unable to get backup dc for destroyed context %p.\n", context_gl);
1286 return FALSE;
1287 }
1288
1289 wined3d_release_dc(context_gl->window, context_gl->dc);
1290 if (!(context_gl->dc = wined3d_device_gl_get_backup_dc(device_gl)))
1291 {
1293 return FALSE;
1294 }
1295
1296 TRACE("Using backup DC %p.\n", context_gl->dc);
1297 context_gl->dc_is_private = TRUE;
1298 context_gl->dc_has_format = FALSE;
1299
1300 if (!wined3d_context_gl_set_pixel_format(context_gl))
1301 {
1302 ERR("Failed to set pixel format %d on device context %p.\n",
1303 context_gl->pixel_format, context_gl->dc);
1305 return FALSE;
1306 }
1307
1308 if (!wglMakeCurrent(context_gl->dc, context_gl->gl_ctx))
1309 {
1310 ERR("Fallback to backup window (dc %p) failed too, last error %#lx.\n",
1311 context_gl->dc, GetLastError());
1313 return FALSE;
1314 }
1315
1316 context_gl->valid = 1;
1317 }
1318 context_gl->needs_set = 0;
1319
1320 return TRUE;
1321}
static long backup()
Definition: maze.c:403

Referenced by wined3d_context_gl_activate(), wined3d_context_gl_cleanup(), and wined3d_context_gl_set_current().

◆ wined3d_context_gl_set_pixel_format()

static BOOL wined3d_context_gl_set_pixel_format ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1197 of file context_gl.c.

1198{
1199 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1200 BOOL private = context_gl->dc_is_private;
1201 int format = context_gl->pixel_format;
1202 HDC dc = context_gl->dc;
1203 int current;
1204 HWND win;
1205
1206 if (private && context_gl->dc_has_format)
1207 return TRUE;
1208
1209 if (!private && WindowFromDC(dc) != context_gl->window)
1210 return FALSE;
1211
1212 current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc);
1213 if ((current == format) || (!current && context_gl->internal_format_set))
1214 goto success;
1215
1216 /* By default WGL doesn't allow pixel format adjustments but we need it
1217 * here. For this reason there's a Wine specific wglSetPixelFormat()
1218 * which allows us to set the pixel format multiple times. Use it when we
1219 * can, because even though no pixel format may currently be set, the
1220 * application may try to set one later. */
1222 {
1223 if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format)))
1224 {
1225 ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
1226 format, dc);
1227 return FALSE;
1228 }
1229 context_gl->internal_format_set = 1;
1230 }
1231 else if (current)
1232 {
1233 /* OpenGL doesn't allow pixel format adjustments. Print an error and
1234 * continue using the old format. There's a big chance that the old
1235 * format works although with a performance hit and perhaps rendering
1236 * errors. */
1237 ERR("Unable to set pixel format %d on device context %p. Already using format %d.\n",
1238 format, dc, current);
1239 return TRUE;
1240 }
1241 else if (!SetPixelFormat(dc, format, NULL))
1242 {
1243 /* This may also happen if the dc belongs to a destroyed window. */
1244 WARN("Failed to set pixel format %d on device context %p, last error %#lx.\n",
1245 format, dc, GetLastError());
1246 return FALSE;
1247 }
1248
1249 win = private ? NULL : WindowFromDC(dc);
1250 if (win != context_gl->restore_pf_win)
1252 context_gl->restore_pf = private ? 0 : current;
1253 context_gl->restore_pf_win = win;
1254
1255success:
1256 if (private)
1257 context_gl->dc_has_format = TRUE;
1258 return TRUE;
1259}
static real win[4][36]
HWND WINAPI WindowFromDC(_In_ HDC hDC)
#define success(from, fromstr, to, tostr)
BOOL WINAPI SetPixelFormat(_In_ HDC, _In_ int, _In_ const PIXELFORMATDESCRIPTOR *)

Referenced by wined3d_context_gl_create_wgl_ctx(), and wined3d_context_gl_set_gl_context().

◆ wined3d_context_gl_setup_target()

static void wined3d_context_gl_setup_target ( struct wined3d_context_gl *  context_gl,
struct wined3d_texture *  texture,
unsigned int  sub_resource_idx 
)
static

Definition at line 4262 of file context_gl.c.

4264{
4265 if (context_gl->c.current_rt.texture == texture
4266 && context_gl->c.current_rt.sub_resource_idx == sub_resource_idx)
4267 return;
4268
4269 /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers
4270 * the alpha blend state changes with different render target formats. */
4271 if (!context_gl->c.current_rt.texture)
4272 {
4273 context_invalidate_state(&context_gl->c, STATE_BLEND);
4274 }
4275 else
4276 {
4277 const struct wined3d_format *old = context_gl->c.current_rt.texture->resource.format;
4278 const struct wined3d_format *new = texture->resource.format;
4279
4280 if (old->id != new->id)
4281 {
4282 /* Disable blending when the alpha mask has changed and when a format doesn't support blending. */
4283 if ((old->alpha_size && !new->alpha_size) || (!old->alpha_size && new->alpha_size)
4284 || !(texture->resource.format_caps & WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING))
4285 context_invalidate_state(&context_gl->c, STATE_BLEND);
4286 }
4287 }
4288
4289 context_gl->c.current_rt.texture = texture;
4290 context_gl->c.current_rt.sub_resource_idx = sub_resource_idx;
4291}
#define new(TYPE, numElems)
Definition: treelist.c:54
#define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING

Referenced by wined3d_context_gl_activate().

◆ wined3d_context_gl_submit_command_fence()

void wined3d_context_gl_submit_command_fence ( struct wined3d_context_gl *  context_gl)

Definition at line 2653 of file context_gl.c.

2654{
2655 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2657 HRESULT hr;
2658
2659 if (!wined3d_array_reserve((void **)&context_gl->submitted.fences, &context_gl->submitted.fences_size,
2660 context_gl->submitted.fence_count + 1, sizeof(*context_gl->submitted.fences)))
2661 ERR("Failed to grow submitted command buffer array.\n");
2662
2663 f = &context_gl->submitted.fences[context_gl->submitted.fence_count++];
2664 f->id = device_gl->current_fence_id;
2665 if (FAILED(hr = wined3d_fence_create(&device_gl->d, &f->fence)))
2666 ERR("Failed to create fence, hr %#lx.\n", hr);
2667 wined3d_fence_issue(f->fence, &device_gl->d);
2668
2669 /* We don't expect this to ever happen, but handle it anyway. */
2670 if (!++device_gl->current_fence_id)
2671 {
2672 wined3d_context_gl_wait_command_fence(context_gl, device_gl->current_fence_id - 1);
2673 device_gl->completed_fence_id = 0;
2674 device_gl->current_fence_id = 1;
2675 }
2676 device_gl->retired_bo_size = 0;
2678}
static void wined3d_context_gl_cleanup_resources(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2600
HRESULT hr
Definition: delayimp.cpp:582
void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device)
Definition: query.c:331
HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence)
Definition: query.c:390
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by swapchain_gl_present(), wined3d_bo_gl_map(), wined3d_context_gl_cleanup(), wined3d_context_gl_destroy_bo(), and wined3d_device_gl_delete_opengl_contexts_cs().

◆ wined3d_context_gl_texture_update()

void wined3d_context_gl_texture_update ( struct wined3d_context_gl *  context_gl,
const struct wined3d_texture_gl *  texture_gl 
)

Definition at line 1143 of file context_gl.c.

1145{
1146 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1147 struct fbo_entry *entry = context_gl->current_fbo;
1148 unsigned int i;
1149
1150 if (!entry || context_gl->rebind_fbo)
1151 return;
1152
1153 for (i = 0; i < gl_info->limits.buffers + 1; ++i)
1154 {
1155 if (texture_gl->texture_rgb.name == entry->key.objects[i].object
1156 || texture_gl->texture_srgb.name == entry->key.objects[i].object)
1157 {
1158 TRACE("Updated texture %p is bound as attachment %u to the current FBO.\n", texture_gl, i);
1159 context_gl->rebind_fbo = TRUE;
1160 return;
1161 }
1162 }
1163}
struct gl_texture texture_rgb texture_srgb
Definition: wined3d_gl.h:943

Referenced by wined3d_texture_gl_upload_data().

◆ wined3d_context_gl_unit_free_for_vs()

static BOOL wined3d_context_gl_unit_free_for_vs ( const struct wined3d_context_gl *  context_gl,
const struct wined3d_shader_resource_info *  ps_resource_info,
unsigned int  unit 
)
static

Definition at line 3624 of file context_gl.c.

3626{
3627 unsigned int current_mapping = context_gl->rev_tex_unit_map[unit];
3628
3629 /* Not currently used */
3630 if (current_mapping == WINED3D_UNMAPPED_STAGE)
3631 return TRUE;
3632
3633 if (current_mapping < WINED3D_MAX_FRAGMENT_SAMPLERS)
3634 {
3635 /* Used by a fragment sampler */
3636
3637 if (!ps_resource_info)
3638 {
3639 /* No pixel shader, check fixed function */
3640 return current_mapping >= WINED3D_MAX_FFP_TEXTURES
3641 || !(context_gl->c.fixed_function_usage_map & (1u << current_mapping));
3642 }
3643
3644 /* Pixel shader, check the shader's sampler map */
3645 return !ps_resource_info[current_mapping].type;
3646 }
3647
3648 return TRUE;
3649}
enum wined3d_shader_resource_type type

Referenced by wined3d_context_gl_map_vsamplers().

◆ wined3d_context_gl_unload_numbered_array()

static void wined3d_context_gl_unload_numbered_array ( struct wined3d_context_gl *  context_gl,
unsigned int  i 
)
static

Definition at line 4861 of file context_gl.c.

4862{
4863 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
4864
4865 GL_EXTCALL(glDisableVertexAttribArray(i));
4866 checkGLcall("glDisableVertexAttribArray");
4867 if (gl_info->supported[ARB_INSTANCED_ARRAYS])
4868 GL_EXTCALL(glVertexAttribDivisor(i, 0));
4869
4870 context_gl->c.numbered_array_mask &= ~(1u << i);
4871}

Referenced by wined3d_context_gl_load_numbered_arrays(), and wined3d_context_gl_unload_numbered_arrays().

◆ wined3d_context_gl_unload_numbered_arrays()

static void wined3d_context_gl_unload_numbered_arrays ( struct wined3d_context_gl *  context_gl)
static

Definition at line 4873 of file context_gl.c.

4874{
4875 uint32_t mask = context_gl->c.numbered_array_mask;
4876 unsigned int i;
4877
4878 while (mask)
4879 {
4882 }
4883}

Referenced by wined3d_context_gl_draw_shaded_quad().

◆ wined3d_context_gl_unmap_bo_address()

void wined3d_context_gl_unmap_bo_address ( struct wined3d_context_gl *  context_gl,
const struct wined3d_bo_address *  data,
unsigned int  range_count,
const struct wined3d_range *  ranges 
)

Definition at line 2988 of file context_gl.c.

2990{
2991 struct wined3d_bo_gl *bo;
2992
2993 if (!data->buffer_object)
2994 return;
2995 bo = wined3d_bo_gl(data->buffer_object);
2996
2997 assert(bo->b.map_ptr);
2998
2999 flush_bo_ranges(context_gl, wined3d_const_bo_address(data), range_count, ranges);
3000 wined3d_bo_gl_unmap(bo, context_gl);
3001}
static void wined3d_bo_gl_unmap(struct wined3d_bo_gl *bo, struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2891

Referenced by adapter_gl_unmap_bo_address(), wined3d_context_gl_copy_bo_address(), wined3d_texture_gl_load_texture(), and wined3d_texture_gl_upload_data().

◆ wined3d_context_gl_update_stream_sources()

void wined3d_context_gl_update_stream_sources ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)

Definition at line 5095 of file context_gl.c.

5097{
5098 wined3d_context_gl_load_numbered_arrays(context_gl, &context_gl->c.stream_info, state);
5099}
static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *context_gl, const struct wined3d_stream_info *stream_info, const struct wined3d_state *state)
Definition: context_gl.c:4885

Referenced by streamsrc(), and vdecl_miscpart().

◆ wined3d_context_gl_update_tex_unit_map()

static void wined3d_context_gl_update_tex_unit_map ( struct wined3d_context_gl *  context_gl,
const struct wined3d_state *  state 
)
static

Definition at line 3694 of file context_gl.c.

3696{
3697 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
3698 BOOL vs = use_vs(state);
3699 BOOL ps = use_ps(state);
3700
3701 if (!ps)
3703
3704 /* Try to go for a 1:1 mapping of the samplers when possible. Pixel shaders
3705 * need a 1:1 map at the moment.
3706 * When the mapping of a stage is changed, sampler and ALL texture stage
3707 * states have to be reset. */
3708
3709 if (gl_info->limits.graphics_samplers >= WINED3D_MAX_COMBINED_SAMPLERS)
3710 return;
3711
3712 if (ps)
3714 else
3716
3717 if (vs)
3718 wined3d_context_gl_map_vsamplers(context_gl, ps, state);
3719}
static void context_update_fixed_function_usage_map(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context_gl.c:3506
static void wined3d_context_gl_map_psamplers(struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
Definition: context_gl.c:3605
static void wined3d_context_gl_map_fixed_function_samplers(struct wined3d_context_gl *context_gl, const struct wined3d_state *state)
Definition: context_gl.c:3564
static void wined3d_context_gl_map_vsamplers(struct wined3d_context_gl *context_gl, BOOL ps, const struct wined3d_state *state)
Definition: context_gl.c:3651
static BOOL use_ps(const struct wined3d_state *state)

Referenced by context_apply_draw_state().

◆ wined3d_context_gl_update_window()

static void wined3d_context_gl_update_window ( struct wined3d_context_gl *  context_gl)
static

Definition at line 1333 of file context_gl.c.

1334{
1335 if (!context_gl->c.swapchain)
1336 return;
1337
1338 if (context_gl->window == context_gl->c.swapchain->win_handle)
1339 return;
1340
1341 TRACE("Updating context %p window from %p to %p.\n",
1342 context_gl, context_gl->window, context_gl->c.swapchain->win_handle);
1343
1344 if (context_gl->dc)
1345 wined3d_release_dc(context_gl->window, context_gl->dc);
1346
1347 context_gl->window = context_gl->c.swapchain->win_handle;
1348 context_gl->dc_is_private = FALSE;
1349 context_gl->dc_has_format = FALSE;
1350 context_gl->needs_set = 1;
1351 context_gl->valid = 1;
1352 context_gl->internal_format_set = 0;
1353
1354 if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
1355 {
1356 ERR("Failed to get a device context for window %p.\n", context_gl->window);
1357 context_gl->valid = 0;
1358 }
1359}

Referenced by wined3d_context_gl_activate().

◆ wined3d_context_gl_wait_command_fence()

void wined3d_context_gl_wait_command_fence ( struct wined3d_context_gl *  context_gl,
uint64_t  id 
)

Definition at line 2629 of file context_gl.c.

2630{
2631 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
2633 SIZE_T i;
2634
2635 if (id <= device_gl->completed_fence_id
2636 || id > device_gl->current_fence_id) /* In case the fence ID wrapped. */
2637 return;
2638
2639 for (i = 0; i < context_gl->submitted.fence_count; ++i)
2640 {
2641 if (context_gl->submitted.fences[i].id != id)
2642 continue;
2643
2644 if ((ret = wined3d_fence_wait(context_gl->submitted.fences[i].fence, &device_gl->d)) != WINED3D_FENCE_OK)
2645 ERR("Failed to wait for command fence with id 0x%s, ret %#x.\n", wine_dbgstr_longlong(id), ret);
2647 return;
2648 }
2649
2650 ERR("Failed to find fence for command fence with id 0x%s.\n", wine_dbgstr_longlong(id));
2651}
enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence, struct wined3d_device *device)
Definition: query.c:256
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
wined3d_fence_result
Definition: wined3d_gl.h:446

Referenced by wined3d_bo_gl_map(), wined3d_context_gl_cleanup(), wined3d_context_gl_submit_command_fence(), and wined3d_device_gl_delete_opengl_contexts_cs().

◆ wined3d_debug_callback()

static void WINE_GLAPI wined3d_debug_callback ( GLenum  source,
GLenum  type,
GLuint  id,
GLenum  severity,
GLsizei  length,
const char *  message,
void *  ctx 
)
static

Definition at line 1856 of file context_gl.c.

1858{
1859 switch (type)
1860 {
1862 ERR("%p: %s.\n", ctx, debugstr_an(message, length));
1863 break;
1864
1868 FIXME("%p: %s.\n", ctx, debugstr_an(message, length));
1869 break;
1870
1872 WARN_(d3d_perf)("%p: %s.\n", ctx, debugstr_an(message, length));
1873 break;
1874
1875 default:
1876 FIXME("ctx %p, type %#x: %s.\n", ctx, type, debugstr_an(message, length));
1877 break;
1878 }
1879}
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB
Definition: glext.h:2239
#define GL_DEBUG_TYPE_PORTABILITY_ARB
Definition: glext.h:2240
#define GL_DEBUG_TYPE_PERFORMANCE_ARB
Definition: glext.h:2241
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB
Definition: glext.h:2238
#define GL_DEBUG_TYPE_ERROR_ARB
Definition: glext.h:2237
#define WARN_(ch,...)
Definition: debug.h:157
Definition: tftpd.h:60

Referenced by wined3d_context_gl_init().

◆ wined3d_device_gl_free_memory()

static void wined3d_device_gl_free_memory ( struct wined3d_device_gl *  device_gl,
struct wined3d_allocator_block *  block 
)
static

Definition at line 2592 of file context_gl.c.

2593{
2594 assert(block->chunk->allocator == &device_gl->allocator);
2598}
void wined3d_allocator_block_free(struct wined3d_allocator_block *block)
Definition: utils.c:7087
struct wined3d_allocator allocator
Definition: wined3d_gl.h:853
static void wined3d_device_gl_allocator_lock(struct wined3d_device_gl *device_gl)
Definition: wined3d_gl.h:880
static void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl *device_gl)
Definition: wined3d_gl.h:885

Referenced by wined3d_context_gl_cleanup_resources(), and wined3d_context_gl_destroy_allocator_block().

Variable Documentation

◆ wined3d_context_tls_idx