ReactOS  0.4.14-dev-57-g333b8f1
context.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "wined3d_private.h"
Include dependency graph for context.c:

Go to the source code of this file.

Macros

#define WINED3D_MAX_FBO_ENTRIES   64
 
#define WINED3D_ALL_LAYERS   (~0u)
 
#define SI_FORMAT(idx)   (si->elements[(idx)].format->emit_idx)
 
#define SI_PTR(idx1, idx2)   (si->elements[(idx1)].data.addr + si->elements[(idx1)].stride * (idx2))
 

Typedefs

typedef void() context_fbo_entry_func_t(struct wined3d_context *context, struct fbo_entry *entry)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_synchronous)
 
static void context_bind_fbo (struct wined3d_context *context, GLenum target, GLuint fbo)
 
static void context_clean_fbo_attachments (const struct wined3d_gl_info *gl_info, GLenum target)
 
static void context_destroy_fbo (struct wined3d_context *context, GLuint fbo)
 
static void context_attach_depth_stencil_rb (const struct wined3d_gl_info *gl_info, GLenum fbo_target, DWORD flags, GLuint rb)
 
static void context_attach_gl_texture_fbo (struct wined3d_context *context, GLenum fbo_target, GLenum attachment, const struct wined3d_fbo_resource *resource)
 
static void context_attach_depth_stencil_fbo (struct wined3d_context *context, GLenum fbo_target, const struct wined3d_fbo_resource *resource, BOOL rb_namespace, DWORD flags)
 
static void context_attach_surface_fbo (struct wined3d_context *context, GLenum fbo_target, DWORD 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 context_check_fbo_status (const struct wined3d_context *context, GLenum target)
 
static DWORD context_generate_rt_mask (GLenum buffer)
 
static DWORD context_generate_rt_mask_from_resource (struct wined3d_resource *resource)
 
static void context_set_fbo_key_for_render_target (const struct wined3d_context *context, struct wined3d_fbo_entry_key *key, unsigned int idx, const struct wined3d_rendertarget_info *render_target, DWORD location)
 
static void context_generate_fbo_key (const struct wined3d_context *context, 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_entrycontext_create_fbo_entry (const struct wined3d_context *context, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
static void context_reuse_fbo_entry (struct wined3d_context *context, 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 context_destroy_fbo_entry (struct wined3d_context *context, struct fbo_entry *entry)
 
static struct fbo_entrycontext_find_fbo_entry (struct wined3d_context *context, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
static void context_apply_fbo_entry (struct wined3d_context *context, GLenum target, struct fbo_entry *entry)
 
static void context_apply_fbo_state (struct wined3d_context *context, GLenum target, struct wined3d_rendertarget_info *render_targets, struct wined3d_surface *depth_stencil, DWORD color_location, DWORD ds_location)
 
void context_apply_fbo_state_blit (struct wined3d_context *context, GLenum target, struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location)
 
void context_alloc_occlusion_query (struct wined3d_context *context, struct wined3d_occlusion_query *query)
 
void context_free_occlusion_query (struct wined3d_occlusion_query *query)
 
void context_alloc_fence (struct wined3d_context *context, struct wined3d_fence *fence)
 
void context_free_fence (struct wined3d_fence *fence)
 
void context_alloc_timestamp_query (struct wined3d_context *context, struct wined3d_timestamp_query *query)
 
void context_free_timestamp_query (struct wined3d_timestamp_query *query)
 
void context_alloc_so_statistics_query (struct wined3d_context *context, struct wined3d_so_statistics_query *query)
 
void context_free_so_statistics_query (struct wined3d_so_statistics_query *query)
 
void context_alloc_pipeline_statistics_query (struct wined3d_context *context, struct wined3d_pipeline_statistics_query *query)
 
void context_free_pipeline_statistics_query (struct wined3d_pipeline_statistics_query *query)
 
static void context_enum_fbo_entries (const struct wined3d_device *device, GLuint name, BOOL rb_namespace, context_fbo_entry_func_t *callback)
 
static void context_queue_fbo_entry_destruction (struct wined3d_context *context, struct fbo_entry *entry)
 
void context_resource_released (const struct wined3d_device *device, struct wined3d_resource *resource, enum wined3d_resource_type type)
 
void context_gl_resource_released (struct wined3d_device *device, GLuint name, BOOL rb_namespace)
 
void context_surface_update (struct wined3d_context *context, const struct wined3d_surface *surface)
 
static BOOL context_restore_pixel_format (struct wined3d_context *ctx)
 
static BOOL context_set_pixel_format (struct wined3d_context *context)
 
static BOOL context_set_gl_context (struct wined3d_context *ctx)
 
static void context_restore_gl_context (const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx)
 
static void context_update_window (struct wined3d_context *context)
 
static void context_destroy_gl_resources (struct wined3d_context *context)
 
DWORD context_get_tls_idx (void)
 
void context_set_tls_idx (DWORD idx)
 
struct wined3d_contextcontext_get_current (void)
 
BOOL context_set_current (struct wined3d_context *ctx)
 
void context_release (struct wined3d_context *context)
 
void context_restore (struct wined3d_context *context, struct wined3d_surface *restore)
 
static void context_enter (struct wined3d_context *context)
 
void context_invalidate_compute_state (struct wined3d_context *context, DWORD state_id)
 
void context_invalidate_state (struct wined3d_context *context, DWORD state)
 
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 auxBuffers)
 
void context_bind_dummy_textures (const struct wined3d_device *device, const struct wined3d_context *context)
 
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)
 
struct wined3d_contextcontext_create (struct wined3d_swapchain *swapchain, struct wined3d_texture *target, const struct wined3d_format *ds_format)
 
void context_destroy (struct wined3d_device *device, struct wined3d_context *context)
 
const DWORDcontext_get_tex_unit_mapping (const struct wined3d_context *context, const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count)
 
static void set_blit_dimension (const struct wined3d_gl_info *gl_info, UINT width, UINT height)
 
static void context_get_rt_size (const struct wined3d_context *context, SIZE *size)
 
void context_enable_clip_distances (struct wined3d_context *context, unsigned int enable_mask)
 
static void SetupForBlit (const struct wined3d_device *device, struct wined3d_context *context)
 
static BOOL is_rt_mask_onscreen (DWORD rt_mask)
 
static GLenum draw_buffer_from_rt_mask (DWORD rt_mask)
 
static void context_apply_draw_buffers (struct wined3d_context *context, DWORD rt_mask)
 
void context_set_draw_buffer (struct wined3d_context *context, GLenum buffer)
 
void context_active_texture (struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
 
void context_bind_bo (struct wined3d_context *context, GLenum binding, GLuint name)
 
void context_bind_texture (struct wined3d_context *context, GLenum target, GLuint name)
 
voidcontext_map_bo_address (struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
 
void context_unmap_bo_address (struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
 
void context_copy_bo_address (struct wined3d_context *context, const struct wined3d_bo_address *dst, GLenum dst_binding, const struct wined3d_bo_address *src, GLenum src_binding, size_t size)
 
static void context_set_render_offscreen (struct wined3d_context *context, BOOL offscreen)
 
static BOOL match_depth_stencil_format (const struct wined3d_format *existing, const struct wined3d_format *required)
 
static void context_validate_onscreen_formats (struct wined3d_context *context, const struct wined3d_rendertarget_view *depth_stencil)
 
GLenum context_get_offscreen_gl_buffer (const struct wined3d_context *context)
 
static DWORD context_generate_rt_mask_no_fbo (const struct wined3d_context *context, struct wined3d_texture *rt)
 
void context_apply_blit_state (struct wined3d_context *context, 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 context_apply_clear_state (struct wined3d_context *context, const struct wined3d_state *state, UINT rt_count, const struct wined3d_fb_state *fb)
 
static DWORD find_draw_buffers_mask (const struct wined3d_context *context, const struct wined3d_state *state)
 
void context_state_fb (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void context_map_stage (struct wined3d_context *context, DWORD stage, DWORD unit)
 
static void context_invalidate_texture_stage (struct wined3d_context *context, DWORD stage)
 
static void context_update_fixed_function_usage_map (struct wined3d_context *context, const struct wined3d_state *state)
 
static void context_map_fixed_function_samplers (struct wined3d_context *context, const struct wined3d_state *state)
 
static void context_map_psamplers (struct wined3d_context *context, const struct wined3d_state *state)
 
static BOOL context_unit_free_for_vs (const struct wined3d_context *context, const struct wined3d_shader_resource_info *ps_resource_info, DWORD unit)
 
static void context_map_vsamplers (struct wined3d_context *context, BOOL ps, const struct wined3d_state *state)
 
static void context_update_tex_unit_map (struct wined3d_context *context, const struct wined3d_state *state)
 
void context_state_drawbuf (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static BOOL fixed_get_input (BYTE usage, BYTE usage_idx, unsigned int *regnum)
 
void wined3d_stream_info_from_declaration (struct wined3d_stream_info *stream_info, const struct wined3d_state *state, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info)
 
static void context_update_stream_info (struct wined3d_context *context, const struct wined3d_state *state)
 
static void context_preload_texture (struct wined3d_context *context, const struct wined3d_state *state, unsigned int idx)
 
static void context_preload_textures (struct wined3d_context *context, const struct wined3d_state *state)
 
static void context_load_shader_resources (struct wined3d_context *context, const struct wined3d_state *state, unsigned int shader_mask)
 
static void context_bind_shader_resources (struct wined3d_context *context, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
 
static void context_load_unordered_access_resources (struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
 
static void context_bind_unordered_access_views (struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
 
static void context_load_stream_output_buffers (struct wined3d_context *context, 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)
 
static void context_apply_compute_state (struct wined3d_context *context, const struct wined3d_device *device, const struct wined3d_state *state)
 
static BOOL use_transform_feedback (const struct wined3d_state *state)
 
void context_end_transform_feedback (struct wined3d_context *context)
 
static void context_pause_transform_feedback (struct wined3d_context *context, BOOL force)
 
static void context_setup_target (struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
static void context_activate (struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
struct wined3d_contextcontext_acquire (const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
struct wined3d_contextcontext_reacquire (const struct wined3d_device *device, struct wined3d_context *context)
 
void dispatch_compute (struct wined3d_device *device, const struct wined3d_state *state, const struct wined3d_dispatch_parameters *parameters)
 
static void draw_primitive_arrays (struct wined3d_context *context, 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 const BYTEsoftware_vertex_blending (struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_stream_info *si, unsigned int element_idx, unsigned int stride_idx, float *result)
 
static unsigned int get_stride_idx (const void *idx_data, unsigned int idx_size, unsigned int base_vertex_idx, unsigned int start_idx, unsigned int vertex_idx)
 
static void draw_primitive_immediate_mode (struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_stream_info *si, const void *idx_data, unsigned int idx_size, int base_vertex_idx, unsigned int start_idx, unsigned int vertex_count, unsigned int instance_count)
 
static void draw_indirect (struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size)
 
static void remove_vbos (struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_stream_info *s)
 
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)
 

Variables

static DWORD wined3d_context_tls_idx
 

Macro Definition Documentation

◆ SI_FORMAT

#define SI_FORMAT (   idx)    (si->elements[(idx)].format->emit_idx)

◆ SI_PTR

#define SI_PTR (   idx1,
  idx2 
)    (si->elements[(idx1)].data.addr + si->elements[(idx1)].stride * (idx2))

◆ WINED3D_ALL_LAYERS

#define WINED3D_ALL_LAYERS   (~0u)

Definition at line 46 of file context.c.

◆ WINED3D_MAX_FBO_ENTRIES

#define WINED3D_MAX_FBO_ENTRIES   64

Definition at line 45 of file context.c.

Typedef Documentation

◆ context_fbo_entry_func_t

typedef void() context_fbo_entry_func_t(struct wined3d_context *context, struct fbo_entry *entry)

Definition at line 1039 of file context.c.

Function Documentation

◆ context_acquire()

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

Definition at line 4242 of file context.c.

4244 {
4245  struct wined3d_context *current_context = context_get_current();
4246  struct wined3d_context *context;
4247  BOOL swapchain_texture;
4248 
4249  TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
4250 
4251  wined3d_from_cs(device->cs);
4252 
4253  if (current_context && current_context->destroyed)
4254  current_context = NULL;
4255 
4256  swapchain_texture = texture && texture->swapchain;
4257  if (!texture)
4258  {
4259  if (current_context
4260  && current_context->current_rt.texture
4261  && current_context->device == device)
4262  {
4263  texture = current_context->current_rt.texture;
4264  sub_resource_idx = current_context->current_rt.sub_resource_idx;
4265  }
4266  else
4267  {
4268  struct wined3d_swapchain *swapchain = device->swapchains[0];
4269 
4270  if (swapchain->back_buffers)
4271  texture = swapchain->back_buffers[0];
4272  else
4273  texture = swapchain->front_buffer;
4274  sub_resource_idx = 0;
4275  }
4276  }
4277 
4278  if (current_context && current_context->current_rt.texture == texture)
4279  {
4280  context = current_context;
4281  }
4282  else if (swapchain_texture)
4283  {
4284  TRACE("Rendering onscreen.\n");
4285 
4286  context = swapchain_get_context(texture->swapchain);
4287  }
4288  else
4289  {
4290  TRACE("Rendering offscreen.\n");
4291 
4292  /* Stay with the current context if possible. Otherwise use the
4293  * context for the primary swapchain. */
4294  if (current_context && current_context->device == device)
4295  context = current_context;
4296  else
4297  context = swapchain_get_context(device->swapchains[0]);
4298  }
4299 
4300  context_activate(context, texture, sub_resource_idx);
4301 
4302  return context;
4303 }
struct wined3d_texture * front_buffer
Definition: http.c:6587
static void wined3d_from_cs(const struct wined3d_cs *cs)
static void context_activate(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4222
struct wined3d_texture ** back_buffers
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
struct wined3d_context * context_get_current(void)
Definition: context.c:1507
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_context ** context
GLenum GLuint texture
Definition: glext.h:6295
struct wined3d_context * swapchain_get_context(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1092
struct wined3d_device * device
struct wined3d_context::@271 current_rt
unsigned int sub_resource_idx

Referenced by buffer_resource_preload(), buffer_unload(), context_reacquire(), context_restore(), create_texture_view(), device_clear_render_targets(), dispatch_compute(), draw_primitive(), fb_copy_to_texture_direct(), fb_copy_to_texture_hwstretch(), read_from_framebuffer(), shader_arb_destroy(), shader_glsl_destroy(), shader_glsl_precompile(), shader_resource_view_generate_mipmaps(), surface_blt_fbo(), surface_convert_format(), surface_cpu_blt(), surface_cpu_blt_colour_fill(), surface_depth_blt_fbo(), surface_load_drawable(), surface_load_fb_texture(), surface_upload_from_surface(), swapchain_gl_frontbuffer_updated(), swapchain_gl_present(), texture2d_cleanup_sub_resources(), texture2d_create_dc(), texture2d_destroy_dc(), texture_resource_preload(), texture_resource_sub_resource_map(), texture_resource_sub_resource_unmap(), wined3d_buffer_copy(), wined3d_buffer_destroy_object(), wined3d_buffer_map(), wined3d_buffer_unmap(), wined3d_cs_exec_add_dirty_texture_region(), wined3d_cs_exec_blt_sub_resource(), wined3d_cs_exec_clear_unordered_access_view(), wined3d_cs_exec_copy_uav_counter(), wined3d_cs_exec_flush(), wined3d_cs_exec_update_sub_resource(), wined3d_device_create_primary_opengl_context_cs(), wined3d_device_delete_opengl_contexts_cs(), wined3d_fence_issue(), wined3d_fence_test(), wined3d_fence_wait(), wined3d_occlusion_query_ops_issue(), wined3d_pipeline_query_ops_issue(), wined3d_rendertarget_view_destroy_object(), wined3d_sampler_cs_init(), wined3d_sampler_destroy_object(), wined3d_shader_resource_view_cs_init(), wined3d_shader_resource_view_destroy_object(), wined3d_so_statistics_query_ops_issue(), wined3d_surface_blt(), wined3d_swapchain_update_swap_interval_cs(), wined3d_texture_cleanup(), wined3d_texture_copy_sysmem_location(), wined3d_texture_unload(), wined3d_texture_unload_gl_texture(), wined3d_texture_update_map_binding(), wined3d_timestamp_query_ops_issue(), wined3d_unordered_access_view_cs_init(), wined3d_unordered_access_view_destroy_object(), and wined3d_unordered_access_view_set_counter().

◆ context_activate()

static void context_activate ( struct wined3d_context context,
struct wined3d_texture texture,
unsigned int  sub_resource_idx 
)
static

Definition at line 4222 of file context.c.

4224 {
4227  context_setup_target(context, texture, sub_resource_idx);
4228  if (!context->valid)
4229  return;
4230 
4231  if (context != context_get_current())
4232  {
4234  ERR("Failed to activate the new context.\n");
4235  }
4236  else if (context->needs_set)
4237  {
4239  }
4240 }
Definition: http.c:6587
struct wined3d_context * context_get_current(void)
Definition: context.c:1507
GLenum GLuint texture
Definition: glext.h:6295
static BOOL context_set_gl_context(struct wined3d_context *ctx)
Definition: context.c:1234
#define ERR(fmt,...)
Definition: debug.h:109
BOOL context_set_current(struct wined3d_context *ctx)
Definition: context.c:1512
static void context_setup_target(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4160
static void context_update_window(struct wined3d_context *context)
Definition: context.c:1305
static void context_enter(struct wined3d_context *context)
Definition: context.c:1619

Referenced by context_acquire(), and context_reacquire().

◆ context_active_texture()

void context_active_texture ( struct wined3d_context context,
const struct wined3d_gl_info gl_info,
unsigned int  unit 
)

Definition at line 2717 of file context.c.

2718 {
2720  checkGLcall("glActiveTexture");
2721  context->active_texture = unit;
2722 }
Definition: http.c:6587
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
#define GL_EXTCALL(f)
#define checkGLcall(A)
GLAPI void GLAPIENTRY glActiveTexture(GLenum texture)
#define GL_TEXTURE0
Definition: gl.h:1750

Referenced by context_create(), create_dummy_textures(), nvrc_colorop(), nvts_bumpenvmat(), sampler(), set_tex_op_atifs(), SetupForBlit(), state_texfactor(), tex_alphaop(), tex_colorop(), tex_coordindex(), transform_texture(), upload_palette(), and wined3d_shader_resource_view_bind().

◆ context_alloc_fence()

void context_alloc_fence ( struct wined3d_context context,
struct wined3d_fence fence 
)

Definition at line 863 of file context.c.

864 {
865  const struct wined3d_gl_info *gl_info = context->gl_info;
866 
867  if (context->free_fence_count)
868  {
869  fence->object = context->free_fences[--context->free_fence_count];
870  }
871  else
872  {
873  if (gl_info->supported[ARB_SYNC])
874  {
875  /* Using ARB_sync, not much to do here. */
876  fence->object.sync = NULL;
877  TRACE("Allocated sync object in context %p.\n", context);
878  }
879  else if (gl_info->supported[APPLE_FENCE])
880  {
881  GL_EXTCALL(glGenFencesAPPLE(1, &fence->object.id));
882  checkGLcall("glGenFencesAPPLE");
883 
884  TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
885  }
886  else if(gl_info->supported[NV_FENCE])
887  {
888  GL_EXTCALL(glGenFencesNV(1, &fence->object.id));
889  checkGLcall("glGenFencesNV");
890 
891  TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
892  }
893  else
894  {
895  WARN("Fences not supported, not allocating fence.\n");
896  fence->object.id = 0;
897  }
898  }
899 
900  fence->context = context;
901  list_add_head(&context->fences, &fence->entry);
902 }
union wined3d_gl_fence_object object
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
BOOL supported[WINED3D_GL_EXT_COUNT]
smooth NULL
Definition: ftsmooth.c:416
struct list entry
struct wined3d_context * context
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
#define checkGLcall(A)

Referenced by wined3d_fence_issue().

◆ context_alloc_occlusion_query()

void context_alloc_occlusion_query ( struct wined3d_context context,
struct wined3d_occlusion_query query 
)

Definition at line 816 of file context.c.

817 {
818  const struct wined3d_gl_info *gl_info = context->gl_info;
819 
820  if (context->free_occlusion_query_count)
821  {
822  query->id = context->free_occlusion_queries[--context->free_occlusion_query_count];
823  }
824  else
825  {
826  if (gl_info->supported[ARB_OCCLUSION_QUERY])
827  {
828  GL_EXTCALL(glGenQueries(1, &query->id));
829  checkGLcall("glGenQueries");
830 
831  TRACE("Allocated occlusion query %u in context %p.\n", query->id, context);
832  }
833  else
834  {
835  WARN("Occlusion queries not supported, not allocating query id.\n");
836  query->id = 0;
837  }
838  }
839 
840  query->context = context;
841  list_add_head(&context->occlusion_queries, &query->entry);
842 }
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
#define checkGLcall(A)

Referenced by wined3d_occlusion_query_ops_issue().

◆ context_alloc_pipeline_statistics_query()

void context_alloc_pipeline_statistics_query ( struct wined3d_context context,
struct wined3d_pipeline_statistics_query query 
)

Definition at line 1002 of file context.c.

1004 {
1005  const struct wined3d_gl_info *gl_info = context->gl_info;
1006 
1007  if (context->free_pipeline_statistics_query_count)
1008  {
1009  query->u = context->free_pipeline_statistics_queries[--context->free_pipeline_statistics_query_count];
1010  }
1011  else
1012  {
1013  GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
1014  checkGLcall("glGenQueries");
1015  }
1016 
1017  query->context = context;
1018  list_add_head(&context->pipeline_statistics_queries, &query->entry);
1019 }
Definition: http.c:6587
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define GL_EXTCALL(f)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define checkGLcall(A)

Referenced by wined3d_pipeline_query_ops_issue().

◆ context_alloc_so_statistics_query()

void context_alloc_so_statistics_query ( struct wined3d_context context,
struct wined3d_so_statistics_query query 
)

Definition at line 961 of file context.c.

963 {
964  const struct wined3d_gl_info *gl_info = context->gl_info;
965 
966  if (context->free_so_statistics_query_count)
967  {
968  query->u = context->free_so_statistics_queries[--context->free_so_statistics_query_count];
969  }
970  else
971  {
972  GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
973  checkGLcall("glGenQueries");
974 
975  TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
976  query->u.id[0], query->u.id[1], context);
977  }
978 
979  query->context = context;
980  list_add_head(&context->so_statistics_queries, &query->entry);
981 }
Definition: http.c:6587
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
#define ARRAY_SIZE(a)
Definition: main.h:24
#define checkGLcall(A)

Referenced by wined3d_so_statistics_query_ops_issue().

◆ context_alloc_timestamp_query()

void context_alloc_timestamp_query ( struct wined3d_context context,
struct wined3d_timestamp_query query 
)

Definition at line 923 of file context.c.

924 {
925  const struct wined3d_gl_info *gl_info = context->gl_info;
926 
927  if (context->free_timestamp_query_count)
928  {
929  query->id = context->free_timestamp_queries[--context->free_timestamp_query_count];
930  }
931  else
932  {
933  GL_EXTCALL(glGenQueries(1, &query->id));
934  checkGLcall("glGenQueries");
935 
936  TRACE("Allocated timestamp query %u in context %p.\n", query->id, context);
937  }
938 
939  query->context = context;
940  list_add_head(&context->timestamp_queries, &query->entry);
941 }
Definition: http.c:6587
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
#define checkGLcall(A)

Referenced by wined3d_timestamp_query_ops_issue().

◆ context_apply_blit_state()

void context_apply_blit_state ( struct wined3d_context context,
const struct wined3d_device device 
)

Definition at line 2981 of file context.c.

2982 {
2983  struct wined3d_texture *rt = context->current_rt.texture;
2984  struct wined3d_surface *surface;
2985  DWORD rt_mask, *cur_mask;
2986 
2988  {
2989  if (context->render_offscreen)
2990  {
2992 
2993  surface = rt->sub_resources[context->current_rt.sub_resource_idx].u.surface;
2994  context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, surface, NULL, rt->resource.draw_binding);
2995  if (rt->resource.format->id != WINED3DFMT_NULL)
2996  rt_mask = 1;
2997  else
2998  rt_mask = 0;
2999  }
3000  else
3001  {
3002  context->current_fbo = NULL;
3005  }
3006  }
3007  else
3008  {
3010  }
3011 
3012  cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask;
3013 
3014  if (rt_mask != *cur_mask)
3015  {
3017  *cur_mask = rt_mask;
3018  }
3019 
3021  {
3023  }
3024 
3027 }
#define ORM_FBO
static void SetupForBlit(const struct wined3d_device *device, struct wined3d_context *context)
Definition: context.c:2458
Definition: http.c:6587
struct wined3d_resource resource
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
#define GL_FRAMEBUFFER
Definition: glext.h:1732
static void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint fbo)
Definition: context.c:53
static DWORD context_generate_rt_mask_from_resource(struct wined3d_resource *resource)
Definition: context.c:420
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_context *context, struct wined3d_texture *rt)
Definition: context.c:2970
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location)
Definition: context.c:802
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
#define STATE_FRAMEBUFFER
static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt_mask)
Definition: context.c:2652

Referenced by arbfp_blitter_blit(), fb_copy_to_texture_direct(), fb_copy_to_texture_hwstretch(), ffp_blitter_blit(), and read_from_framebuffer().

◆ context_apply_clear_state()

BOOL context_apply_clear_state ( struct wined3d_context context,
const struct wined3d_state state,
UINT  rt_count,
const struct wined3d_fb_state fb 
)

Definition at line 3047 of file context.c.

3049 {
3050  struct wined3d_rendertarget_view * const *rts = fb->render_targets;
3051  struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
3052  const struct wined3d_gl_info *gl_info = context->gl_info;
3053  DWORD rt_mask = 0, *cur_mask;
3054  unsigned int i;
3055 
3056  if (isStateDirty(context, STATE_FRAMEBUFFER) || fb != state->fb
3057  || rt_count != gl_info->limits.buffers)
3058  {
3059  if (!have_framebuffer_attachment(rt_count, rts, dsv))
3060  {
3061  WARN("Invalid render target config, need at least one attachment.\n");
3062  return FALSE;
3063  }
3064 
3066  {
3068 
3069  if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))
3070  {
3071  memset(context->blit_targets, 0, sizeof(context->blit_targets));
3072  for (i = 0; i < rt_count; ++i)
3073  {
3074  if (rts[i])
3075  {
3076  context->blit_targets[i].gl_view = rts[i]->gl_view;
3077  context->blit_targets[i].resource = rts[i]->resource;
3078  context->blit_targets[i].sub_resource_idx = rts[i]->sub_resource_idx;
3079  context->blit_targets[i].layer_count = rts[i]->layer_count;
3080  }
3081  if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3082  rt_mask |= (1u << i);
3083  }
3086  rt_count ? rts[0]->resource->draw_binding : 0,
3087  dsv ? dsv->resource->draw_binding : 0);
3088  }
3089  else
3090  {
3094  }
3095 
3096  /* If the framebuffer is not the device's fb the device's fb has to be reapplied
3097  * next draw. Otherwise we could mark the framebuffer state clean here, once the
3098  * state management allows this */
3100  }
3101  else
3102  {
3104  rt_count ? wined3d_rendertarget_view_get_surface(rts[0])->container : NULL);
3105  }
3106  }
3108  && (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)))
3109  {
3110  for (i = 0; i < rt_count; ++i)
3111  {
3112  if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3113  rt_mask |= (1u << i);
3114  }
3115  }
3116  else
3117  {
3119  rt_count ? wined3d_rendertarget_view_get_surface(rts[0])->container : NULL);
3120  }
3121 
3122  cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask;
3123 
3124  if (rt_mask != *cur_mask)
3125  {
3127  *cur_mask = rt_mask;
3129  }
3130 
3132  {
3134  }
3135 
3136  context->last_was_blit = FALSE;
3137 
3138  /* Blending and clearing should be orthogonal, but tests on the nvidia
3139  * driver show that disabling blending when clearing improves the clearing
3140  * performance incredibly. */
3141  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
3142  gl_info->gl_ops.gl.p_glEnable(GL_SCISSOR_TEST);
3143  if (rt_count && gl_info->supported[ARB_FRAMEBUFFER_SRGB])
3144  {
3145  if (needs_srgb_write(context, state, fb))
3146  gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB);
3147  else
3148  gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
3150  }
3151  checkGLcall("setting up state for clear");
3152 
3156 
3157  return TRUE;
3158 }
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
#define ORM_FBO
static void context_apply_fbo_state(struct wined3d_context *context, GLenum target, struct wined3d_rendertarget_info *render_targets, struct wined3d_surface *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context.c:763
#define TRUE
Definition: types.h:120
struct opengl_funcs gl_ops
#define GL_BLEND
Definition: gl.h:371
Definition: http.c:6587
struct wined3d_rendertarget_view * render_targets[MAX_RENDER_TARGET_VIEWS]
#define STATE_SCISSORRECT
#define WARN(fmt,...)
Definition: debug.h:111
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
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 GL_FRAMEBUFFER_SRGB
Definition: glext.h:1758
static struct wined3d_surface * wined3d_rendertarget_view_get_surface(const struct wined3d_rendertarget_view *view)
BOOL supported[WINED3D_GL_EXT_COUNT]
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_SCISSOR_TEST
Definition: gl.h:589
static void context_validate_onscreen_formats(struct wined3d_context *context, const struct wined3d_rendertarget_view *depth_stencil)
Definition: context.c:2931
static DWORD context_generate_rt_mask_from_resource(struct wined3d_resource *resource)
Definition: context.c:420
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_context *context, struct wined3d_texture *rt)
Definition: context.c:2970
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
Definition: context.c:3029
static int state
Definition: maze.c:121
struct wined3d_rendertarget_view * depth_stencil
#define STATE_RENDER(a)
#define checkGLcall(A)
#define STATE_FRAMEBUFFER
struct wined3d_gl_view gl_view
#define memset(x, y, z)
Definition: compat.h:39
struct wined3d_gl_limits limits
static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt_mask)
Definition: context.c:2652
static BOOL needs_srgb_write(const struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_fb_state *fb)
struct wined3d_resource * resource

Referenced by device_clear_render_targets().

◆ context_apply_compute_state()

static void context_apply_compute_state ( struct wined3d_context context,
const struct wined3d_device device,
const struct wined3d_state state 
)
static

Definition at line 4060 of file context.c.

4062 {
4063  const struct StateEntry *state_table = context->state_table;
4064  const struct wined3d_gl_info *gl_info = context->gl_info;
4065  unsigned int state_id, i;
4066 
4069  state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4070 
4071  for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context->dirty_compute_states); ++i)
4072  {
4073  unsigned int dirty_mask = context->dirty_compute_states[i];
4074  while (dirty_mask)
4075  {
4076  unsigned int current_state_id = state_id + wined3d_bit_scan(&dirty_mask);
4077  state_table[current_state_id].apply(context, state, current_state_id);
4078  }
4079  state_id += sizeof(*context->dirty_compute_states) * CHAR_BIT;
4080  }
4081  memset(context->dirty_compute_states, 0, sizeof(*context->dirty_compute_states));
4082 
4083  if (context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_COMPUTE))
4084  {
4085  device->shader_backend->shader_select_compute(device->shader_priv, context, state);
4086  context->shader_update_mask &= ~(1u << WINED3D_SHADER_TYPE_COMPUTE);
4087  }
4088 
4089  if (context->update_compute_shader_resource_bindings)
4090  {
4092  context->update_compute_shader_resource_bindings = 0;
4093  if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4094  context->update_shader_resource_bindings = 1;
4095  }
4096 
4097  if (context->update_compute_unordered_access_view_bindings)
4098  {
4101  state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4102  context->update_compute_unordered_access_view_bindings = 0;
4103  context->update_unordered_access_view_bindings = 1;
4104  }
4105 
4106  /* Updates to currently bound render targets aren't necessarily coherent
4107  * between the graphics and compute pipelines. Unbind any currently bound
4108  * FBO here to ensure preceding updates to its attachments by the graphics
4109  * pipeline are visible to the compute pipeline.
4110  *
4111  * Without this, the bloom effect in Nier:Automata is too bright on the
4112  * Mesa radeonsi driver, and presumably on other Mesa based drivers. */
4115 
4116  context->last_was_blit = FALSE;
4117 }
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
Definition: http.c:6587
#define STATE_COMPUTE_OFFSET
#define CHAR_BIT
Definition: urlcache.c:57
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
static const struct @239 state_table[]
static int wined3d_bit_scan(unsigned int *x)
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
Definition: devices.h:37
static void context_load_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, unsigned int shader_mask)
Definition: context.c:3765
#define GL_FRAMEBUFFER
Definition: glext.h:1732
static void context_load_unordered_access_resources(struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context.c:3846
static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
Definition: context.c:3802
static void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint fbo)
Definition: context.c:53
static int state
Definition: maze.c:121
static void context_bind_unordered_access_views(struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context.c:3881
#define ARRAY_SIZE(a)
Definition: main.h:24
#define STATE_FRAMEBUFFER
#define memset(x, y, z)
Definition: compat.h:39
struct wined3d_gl_limits limits

Referenced by dispatch_compute().

◆ context_apply_draw_buffers()

static void context_apply_draw_buffers ( struct wined3d_context context,
DWORD  rt_mask 
)
static

Definition at line 2652 of file context.c.

2653 {
2654  const struct wined3d_gl_info *gl_info = context->gl_info;
2655  GLenum draw_buffers[MAX_RENDER_TARGET_VIEWS];
2656 
2657  if (!rt_mask)
2658  {
2659  gl_info->gl_ops.gl.p_glDrawBuffer(GL_NONE);
2660  }
2661  else if (is_rt_mask_onscreen(rt_mask))
2662  {
2663  gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffer_from_rt_mask(rt_mask));
2664  }
2665  else
2666  {
2668  {
2669  unsigned int i = 0;
2670 
2671  while (rt_mask)
2672  {
2673  if (rt_mask & 1)
2674  draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
2675  else
2676  draw_buffers[i] = GL_NONE;
2677 
2678  rt_mask >>= 1;
2679  ++i;
2680  }
2681 
2682  if (gl_info->supported[ARB_DRAW_BUFFERS])
2683  {
2684  GL_EXTCALL(glDrawBuffers(i, draw_buffers));
2685  }
2686  else
2687  {
2688  gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]);
2689  }
2690  }
2691  else
2692  {
2693  ERR("Unexpected draw buffers mask with backbuffer ORM.\n");
2694  }
2695  }
2696 
2697  checkGLcall("apply draw buffers");
2698 }
#define ORM_FBO
struct opengl_funcs gl_ops
Definition: http.c:6587
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 GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_EXTCALL(f)
static GLenum draw_buffer_from_rt_mask(DWORD rt_mask)
Definition: context.c:2646
#define GL_NONE
Definition: gl.h:465
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
#define MAX_RENDER_TARGET_VIEWS
#define checkGLcall(A)
static BOOL is_rt_mask_onscreen(DWORD rt_mask)
Definition: context.c:2641

Referenced by context_apply_blit_state(), context_apply_clear_state(), context_state_drawbuf(), and context_state_fb().

◆ context_apply_draw_state()

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

Definition at line 3947 of file context.c.

3949 {
3950  const struct StateEntry *state_table = context->state_table;
3951  const struct wined3d_gl_info *gl_info = context->gl_info;
3952  const struct wined3d_fb_state *fb = state->fb;
3953  unsigned int i;
3954  WORD map;
3955 
3956  if (!have_framebuffer_attachment(gl_info->limits.buffers, fb->render_targets, fb->depth_stencil))
3957  {
3959  {
3960  FIXME("OpenGL implementation does not support framebuffers with no attachments.\n");
3961  return FALSE;
3962  }
3963 
3965  }
3966 
3968  {
3970  }
3971 
3972  /* Preload resources before FBO setup. Texture preload in particular may
3973  * result in changes to the current FBO, due to using e.g. FBO blits for
3974  * updating a resource location. */
3979  state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
3981  /* TODO: Right now the dependency on the vertex shader is necessary
3982  * since wined3d_stream_info_from_declaration() depends on the reg_maps of
3983  * the current VS but maybe it's possible to relax the coupling in some
3984  * situations at least. */
3987  {
3989  }
3990  else
3991  {
3992  for (i = 0, map = context->stream_info.use_map; map; map >>= 1, ++i)
3993  {
3994  if (map & 1)
3995  wined3d_buffer_load(state->streams[context->stream_info.elements[i].stream_idx].buffer,
3996  context, state);
3997  }
3998  /* Loading the buffers above may have invalidated the stream info. */
4001  }
4002  if (state->index_buffer)
4003  {
4004  if (context->stream_info.all_vbo)
4005  wined3d_buffer_load(state->index_buffer, context, state);
4006  else
4007  wined3d_buffer_load_sysmem(state->index_buffer, context);
4008  }
4009 
4010  for (i = 0; i < context->numDirtyEntries; ++i)
4011  {
4012  DWORD rep = context->dirtyArray[i];
4013  DWORD idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
4014  BYTE shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
4015  context->isStateDirty[idx] &= ~(1u << shift);
4016  state_table[rep].apply(context, state, rep);
4017  }
4018 
4019  if (context->shader_update_mask & ~(1u << WINED3D_SHADER_TYPE_COMPUTE))
4020  {
4021  device->shader_backend->shader_select(device->shader_priv, context, state);
4022  context->shader_update_mask &= 1u << WINED3D_SHADER_TYPE_COMPUTE;
4023  }
4024 
4025  if (context->constant_update_mask)
4026  {
4027  device->shader_backend->shader_load_constants(device->shader_priv, context, state);
4028  context->constant_update_mask = 0;
4029  }
4030 
4031  if (context->update_shader_resource_bindings)
4032  {
4033  for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
4035  context->update_shader_resource_bindings = 0;
4036  if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4037  context->update_compute_shader_resource_bindings = 1;
4038  }
4039 
4040  if (context->update_unordered_access_view_bindings)
4041  {
4044  state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
4045  context->update_unordered_access_view_bindings = 0;
4046  context->update_compute_unordered_access_view_bindings = 1;
4047  }
4048 
4050  {
4052  }
4053 
4054  context->numDirtyEntries = 0; /* This makes the whole list clean */
4055  context->last_was_blit = FALSE;
4056 
4057  return TRUE;
4058 }
static void context_load_stream_output_buffers(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3930
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
#define ORM_FBO
#define TRUE
Definition: types.h:120
#define shift
Definition: input.c:1668
BYTE * wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:706
#define STATE_VDECL
Definition: http.c:6587
struct wined3d_rendertarget_view * render_targets[MAX_RENDER_TARGET_VIEWS]
#define CHAR_BIT
Definition: urlcache.c:57
#define STATE_SHADER(a)
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
static const struct @239 state_table[]
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
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL supported[WINED3D_GL_EXT_COUNT]
unsigned int idx
Definition: utils.c:41
static void context_load_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, unsigned int shader_mask)
Definition: context.c:3765
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
#define GL_FRAMEBUFFER
Definition: glext.h:1732
static void context_load_unordered_access_resources(struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context.c:3846
#define STATE_STREAMSRC
static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3632
static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
Definition: context.c:3802
static void context_validate_onscreen_formats(struct wined3d_context *context, const struct wined3d_rendertarget_view *depth_stencil)
Definition: context.c:2931
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: _map.h:44
static void context_update_tex_unit_map(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3452
static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
Definition: context.c:3029
static int state
Definition: maze.c:121
unsigned char BYTE
Definition: mem.h:68
struct wined3d_rendertarget_view * depth_stencil
static void context_bind_unordered_access_views(struct wined3d_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: context.c:3881
#define STATE_FRAMEBUFFER
void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state)
Definition: buffer.c:887
static void context_set_render_offscreen(struct wined3d_context *context, BOOL offscreen)
Definition: context.c:2894
struct wined3d_gl_limits limits
static void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3732
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 GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262

Referenced by draw_primitive().

◆ context_apply_fbo_entry()

static void context_apply_fbo_entry ( struct wined3d_context context,
GLenum  target,
struct fbo_entry entry 
)
static

Definition at line 711 of file context.c.

712 {
713  const struct wined3d_gl_info *gl_info = context->gl_info;
714  GLuint read_binding, draw_binding;
715  unsigned int i;
716 
718  {
720  return;
721  }
722 
723  read_binding = context->fbo_read_binding;
724  draw_binding = context->fbo_draw_binding;
726 
728  {
729  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
730  GL_FRAMEBUFFER_DEFAULT_WIDTH, gl_info->limits.framebuffer_width));
731  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
732  GL_FRAMEBUFFER_DEFAULT_HEIGHT, gl_info->limits.framebuffer_height));
733  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_LAYERS, 1));
734  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1));
735  }
736 
737  /* Apply render targets */
738  for (i = 0; i < gl_info->limits.buffers; ++i)
739  {
740  context_attach_surface_fbo(context, target, i, &entry->key.objects[i + 1],
741  entry->key.rb_namespace & (1 << (i + 1)));
742  }
743 
745  entry->key.rb_namespace & 0x1, entry->flags);
746 
747  /* Set valid read and draw buffer bindings to satisfy pedantic pre-ES2_compatibility
748  * GL contexts requirements. */
749  gl_info->gl_ops.gl.p_glReadBuffer(GL_NONE);
751  if (target != GL_FRAMEBUFFER)
752  {
755  else
757  }
758 
760 }
#define GL_FRAMEBUFFER_DEFAULT_LAYERS
Definition: wgl.h:1489
struct opengl_funcs gl_ops
Definition: http.c:6587
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
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 GL_FRAMEBUFFER_DEFAULT_HEIGHT
Definition: wgl.h:1488
static void context_attach_depth_stencil_fbo(struct wined3d_context *context, GLenum fbo_target, const struct wined3d_fbo_resource *resource, BOOL rb_namespace, DWORD flags)
Definition: context.c:178
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_FRAMEBUFFER_DEFAULT_WIDTH
Definition: wgl.h:1491
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
#define GL_EXTCALL(f)
#define GL_FRAMEBUFFER_DEFAULT_SAMPLES
Definition: wgl.h:1490
static void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint fbo)
Definition: context.c:53
#define GL_NONE
Definition: gl.h:465
#define WINED3D_FBO_ENTRY_FLAG_ATTACHED
uint32_t entry
Definition: isohybrid.c:63
unsigned int GLuint
Definition: gl.h:159
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
GLenum target
Definition: glext.h:7315
static void context_attach_surface_fbo(struct wined3d_context *context, GLenum fbo_target, DWORD idx, const struct wined3d_fbo_resource *resource, BOOL rb_namespace)
Definition: context.c:218
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
struct wined3d_gl_limits limits

Referenced by context_apply_fbo_state().

◆ context_apply_fbo_state()

static void context_apply_fbo_state ( struct wined3d_context context,
GLenum  target,
struct wined3d_rendertarget_info render_targets,
struct wined3d_surface depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 763 of file context.c.

766 {
767  struct fbo_entry *entry, *entry2;
768 
769  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
770  {
772  }
773 
774  if (context->rebind_fbo)
775  {
777  context->rebind_fbo = FALSE;
778  }
779 
780  if (color_location == WINED3D_LOCATION_DRAWABLE)
781  {
782  context->current_fbo = NULL;
784  }
785  else
786  {
787  struct wined3d_rendertarget_info ds = {{0}};
788 
789  if (depth_stencil)
790  {
791  ds.resource = &depth_stencil->container->resource;
792  ds.sub_resource_idx = surface_get_sub_resource_idx(depth_stencil);
793  ds.layer_count = 1;
794  }
796  render_targets, &ds, color_location, ds_location);
798  }
799 }
Definition: http.c:6587
static void context_apply_fbo_entry(struct wined3d_context *context, GLenum target, struct fbo_entry *entry)
Definition: context.c:711
#define ds
Definition: i386-dis.c:434
static struct fbo_entry * context_find_fbo_entry(struct wined3d_context *context, GLenum target, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context.c:581
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
#define GL_FRAMEBUFFER
Definition: glext.h:1732
static void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint fbo)
Definition: context.c:53
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
GLenum target
Definition: glext.h:7315
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
static void context_destroy_fbo_entry(struct wined3d_context *context, struct fbo_entry *entry)
Definition: context.c:568

Referenced by context_apply_clear_state(), context_apply_fbo_state_blit(), and context_state_fb().

◆ context_apply_fbo_state_blit()

void context_apply_fbo_state_blit ( struct wined3d_context context,
GLenum  target,
struct wined3d_surface render_target,
struct wined3d_surface depth_stencil,
DWORD  location 
)

Definition at line 802 of file context.c.

804 {
805  memset(context->blit_targets, 0, sizeof(context->blit_targets));
806  if (render_target)
807  {
808  context->blit_targets[0].resource = &render_target->container->resource;
809  context->blit_targets[0].sub_resource_idx = surface_get_sub_resource_idx(render_target);
810  context->blit_targets[0].layer_count = 1;
811  }
812  context_apply_fbo_state(context, target, context->blit_targets, depth_stencil, location, location);
813 }
static void context_apply_fbo_state(struct wined3d_context *context, GLenum target, struct wined3d_rendertarget_info *render_targets, struct wined3d_surface *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context.c:763
Definition: http.c:6587
GLenum target
Definition: glext.h:7315
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by arbfp_blitter_blit(), context_apply_blit_state(), ffp_blitter_blit(), read_from_framebuffer(), surface_blt_fbo(), and surface_depth_blt_fbo().

◆ context_attach_depth_stencil_fbo()

static void context_attach_depth_stencil_fbo ( struct wined3d_context context,
GLenum  fbo_target,
const struct wined3d_fbo_resource resource,
BOOL  rb_namespace,
DWORD  flags 
)
static

Definition at line 178 of file context.c.

181 {
182  const struct wined3d_gl_info *gl_info = context->gl_info;
183 
184  if (resource->object)
185  {
186  TRACE("Attach depth stencil %u.\n", resource->object);
187 
188  if (rb_namespace)
189  {
190  context_attach_depth_stencil_rb(gl_info, fbo_target,
191  flags, resource->object);
192  }
193  else
194  {
197 
200  }
201 
204 
207  }
208  else
209  {
210  TRACE("Attach depth stencil 0.\n");
211 
214  }
215 }
static void context_attach_gl_texture_fbo(struct wined3d_context *context, GLenum fbo_target, GLenum attachment, const struct wined3d_fbo_resource *resource)
Definition: context.c:131
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
Definition: http.c:6587
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define WINED3D_FBO_ENTRY_FLAG_STENCIL
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static void context_attach_depth_stencil_rb(const struct wined3d_gl_info *gl_info, GLenum fbo_target, DWORD flags, GLuint rb)
Definition: context.c:115
#define WINED3D_FBO_ENTRY_FLAG_DEPTH

Referenced by context_apply_fbo_entry().

◆ context_attach_depth_stencil_rb()

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

Definition at line 115 of file context.c.

117 {
119  {
120  gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
121  checkGLcall("glFramebufferRenderbuffer()");
122  }
123 
125  {
126  gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
127  checkGLcall("glFramebufferRenderbuffer()");
128  }
129 }
#define GL_RENDERBUFFER
Definition: glext.h:1733
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define WINED3D_FBO_ENTRY_FLAG_STENCIL
GLbitfield flags
Definition: glext.h:7161
#define checkGLcall(A)
struct wined3d_fbo_ops fbo_ops
#define WINED3D_FBO_ENTRY_FLAG_DEPTH

Referenced by context_attach_depth_stencil_fbo().

◆ context_attach_gl_texture_fbo()

static void context_attach_gl_texture_fbo ( struct wined3d_context context,
GLenum  fbo_target,
GLenum  attachment,
const struct wined3d_fbo_resource resource 
)
static

Definition at line 131 of file context.c.

133 {
134  const struct wined3d_gl_info *gl_info = context->gl_info;
135 
136  if (!resource)
137  {
138  gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, GL_TEXTURE_2D, 0, 0);
139  }
140  else if (resource->layer == WINED3D_ALL_LAYERS)
141  {
142  if (!gl_info->fbo_ops.glFramebufferTexture)
143  {
144  FIXME("OpenGL implementation doesn't support glFramebufferTexture().\n");
145  return;
146  }
147 
148  gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment,
149  resource->object, resource->level);
150  }
151  else if (resource->target == GL_TEXTURE_1D_ARRAY || resource->target == GL_TEXTURE_2D_ARRAY ||
152  resource->target == GL_TEXTURE_3D)
153  {
154  if (!gl_info->fbo_ops.glFramebufferTextureLayer)
155  {
156  FIXME("OpenGL implementation doesn't support glFramebufferTextureLayer().\n");
157  return;
158  }
159 
160  gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment,
161  resource->object, resource->level, resource->layer);
162  }
163  else if (resource->target == GL_TEXTURE_1D)
164  {
165  gl_info->fbo_ops.glFramebufferTexture1D(fbo_target, attachment,
166  resource->target, resource->object, resource->level);
167  checkGLcall("glFramebufferTexture1D()");
168  }
169  else
170  {
171  gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment,
172  resource->target, resource->object, resource->level);
173  }
174  checkGLcall("attach texture to fbo");
175 }
GLenum attachment
Definition: glext.h:6295
Definition: http.c:6587
#define WINED3D_ALL_LAYERS
Definition: context.c:46
#define GL_TEXTURE_1D
Definition: gl.h:644
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
#define checkGLcall(A)
#define GL_TEXTURE_2D
Definition: gl.h:645
struct wined3d_fbo_ops fbo_ops

Referenced by context_attach_depth_stencil_fbo(), and context_attach_surface_fbo().

◆ context_attach_surface_fbo()

static void context_attach_surface_fbo ( struct wined3d_context context,
GLenum  fbo_target,
DWORD  idx,
const struct wined3d_fbo_resource resource,
BOOL  rb_namespace 
)
static

Definition at line 218 of file context.c.

220 {
221  const struct wined3d_gl_info *gl_info = context->gl_info;
222 
223  TRACE("Attach GL object %u to %u.\n", resource->object, idx);
224 
225  if (resource->object)
226  {
227  if (rb_namespace)
228  {
229  gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
230  GL_RENDERBUFFER, resource->object);
231  checkGLcall("glFramebufferRenderbuffer()");
232  }
233  else
234  {
236  }
237  }
238  else
239  {
241  }
242 }
#define GL_RENDERBUFFER
Definition: glext.h:1733
static void context_attach_gl_texture_fbo(struct wined3d_context *context, GLenum fbo_target, GLenum attachment, const struct wined3d_fbo_resource *resource)
Definition: context.c:131
Definition: http.c:6587
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define checkGLcall(A)
struct wined3d_fbo_ops fbo_ops

Referenced by context_apply_fbo_entry().

◆ context_bind_bo()

void context_bind_bo ( struct wined3d_context context,
GLenum  binding,
GLuint  name 
)

Definition at line 2724 of file context.c.

2725 {
2726  const struct wined3d_gl_info *gl_info = context->gl_info;
2727 
2728  if (binding == GL_ELEMENT_ARRAY_BUFFER)
2730 
2731  GL_EXTCALL(glBindBuffer(binding, name));
2732 }
Definition: http.c:6587
#define STATE_INDEXBUFFER
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
#define GL_EXTCALL(f)
Definition: name.c:36
#define GL_ELEMENT_ARRAY_BUFFER
Definition: glext.h:337

Referenced by buffer_bind(), context_copy_bo_address(), context_map_bo_address(), context_unmap_bo_address(), and wined3d_unordered_access_view_clear_uint().

◆ context_bind_dummy_textures()

void context_bind_dummy_textures ( const struct wined3d_device device,
const struct wined3d_context context 
)

Definition at line 1764 of file context.c.

1765 {
1766  const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
1767  const struct wined3d_gl_info *gl_info = context->gl_info;
1768  unsigned int i;
1769 
1770  for (i = 0; i < gl_info->limits.combined_samplers; ++i)
1771  {
1773 
1774  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
1775  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
1776 
1777  if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
1778  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
1779 
1780  if (gl_info->supported[EXT_TEXTURE3D])
1781  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
1782 
1783  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
1784  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
1785 
1786  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY])
1787  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
1788 
1789  if (gl_info->supported[EXT_TEXTURE_ARRAY])
1790  {
1791  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
1792  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
1793  }
1794  if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
1795  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
1796 
1797  if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
1798  {
1799  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
1800  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
1801  }
1802  }
1803 
1804  checkGLcall("bind dummy textures");
1805 }
struct opengl_funcs gl_ops
Definition: http.c:6587
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
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 GL_TEXTURE_1D
Definition: gl.h:644
const GLuint * textures
Definition: glext.h:8098
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_EXTCALL(f)
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define checkGLcall(A)
#define GL_TEXTURE_2D
Definition: gl.h:645
GLAPI void GLAPIENTRY glActiveTexture(GLenum texture)
struct wined3d_gl_limits limits
#define GL_TEXTURE0
Definition: gl.h:1750

Referenced by context_create(), and create_dummy_textures().

◆ context_bind_fbo()

static void context_bind_fbo ( struct wined3d_context context,
GLenum  target,
GLuint  fbo 
)
static

Definition at line 53 of file context.c.

54 {
55  const struct wined3d_gl_info *gl_info = context->gl_info;
56 
57  switch (target)
58  {
60  if (context->fbo_read_binding == fbo) return;
61  context->fbo_read_binding = fbo;
62  break;
63 
65  if (context->fbo_draw_binding == fbo) return;
66  context->fbo_draw_binding = fbo;
67  break;
68 
69  case GL_FRAMEBUFFER:
70  if (context->fbo_read_binding == fbo
71  && context->fbo_draw_binding == fbo) return;
72  context->fbo_read_binding = fbo;
73  context->fbo_draw_binding = fbo;
74  break;
75 
76  default:
77  FIXME("Unhandled target %#x.\n", target);
78  break;
79  }
80 
81  gl_info->fbo_ops.glBindFramebuffer(target, fbo);
82  checkGLcall("glBindFramebuffer()");
83 }
Definition: http.c:6587
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
#define checkGLcall(A)
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
GLenum target
Definition: glext.h:7315
struct wined3d_fbo_ops fbo_ops

Referenced by context_apply_blit_state(), context_apply_compute_state(), context_apply_fbo_entry(), context_apply_fbo_state(), context_destroy_fbo(), and context_reuse_fbo_entry().

◆ context_bind_shader_resources()

static void context_bind_shader_resources ( struct wined3d_context context,
const struct wined3d_state state,
enum wined3d_shader_type  shader_type 
)
static

Definition at line 3802 of file context.c.

3804 {
3805  unsigned int bind_idx, shader_sampler_count, base, count, i;
3806  const struct wined3d_device *device = context->device;
3809  const struct wined3d_shader *shader;
3810  struct wined3d_sampler *sampler;
3811  const DWORD *tex_unit_map;
3812 
3813  if (!(shader = state->shader[shader_type]))
3814  return;
3815 
3816  tex_unit_map = context_get_tex_unit_mapping(context,
3817  &shader->reg_maps.shader_version, &base, &count);
3818 
3819  shader_sampler_count = shader->reg_maps.sampler_map.count;
3820  if (shader_sampler_count > count)
3821  FIXME("Shader %p needs %u samplers, but only %u are supported.\n",
3822  shader, shader_sampler_count, count);
3823  count = min(shader_sampler_count, count);
3824 
3825  for (i = 0; i < count; ++i)
3826  {
3827  entry = &shader->reg_maps.sampler_map.entries[i];
3828  bind_idx = base + entry->bind_idx;
3829  if (tex_unit_map)
3830  bind_idx = tex_unit_map[bind_idx];
3831 
3832  if (!(view = state->shader_resource_view[shader_type][entry->resource_idx]))
3833  {
3834  WARN("No resource view bound at index %u, %u.\n", shader_type, entry->resource_idx);
3835  continue;
3836  }
3837 
3838  if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
3839  sampler = device->default_sampler;
3840  else if (!(sampler = state->sampler[shader_type][entry->sampler_idx]))
3841  sampler = device->null_sampler;
3843  }
3844 }
const DWORD * context_get_tex_unit_mapping(const struct wined3d_context *context, const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count)
Definition: context.c:2334
void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view, unsigned int unit, struct wined3d_sampler *sampler, struct wined3d_context *context)
Definition: view.c:807
Definition: http.c:6587
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
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 WINED3D_SAMPLER_DEFAULT
GLuint base
Definition: 3dtext.c:35
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
GLuint shader
Definition: glext.h:6030
unsigned long DWORD
Definition: ntddk_ex.h:95
static int state
Definition: maze.c:121
uint32_t entry
Definition: isohybrid.c:63
#define min(a, b)
Definition: monoChain.cc:55
static IOleDocumentView * view
Definition: activex.c:1749
GLuint sampler
Definition: glext.h:7283

Referenced by context_apply_compute_state(), and context_apply_draw_state().

◆ context_bind_texture()

void context_bind_texture ( struct wined3d_context context,
GLenum  target,
GLuint  name 
)

Definition at line 2734 of file context.c.

2735 {
2736  const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
2737  const struct wined3d_gl_info *gl_info = context->gl_info;
2738  DWORD unit = context->active_texture;
2739  DWORD old_texture_type = context->texture_type[unit];
2740 
2741  if (name)
2742  {
2743  gl_info->gl_ops.gl.p_glBindTexture(target, name);
2744  }
2745  else
2746  {
2747  target = GL_NONE;
2748  }
2749 
2750  if (old_texture_type != target)
2751  {
2752  switch (old_texture_type)
2753  {
2754  case GL_NONE:
2755  /* nothing to do */
2756  break;
2757  case GL_TEXTURE_1D:
2758  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
2759  checkGLcall("glBindTexture");
2760  break;
2761  case GL_TEXTURE_1D_ARRAY:
2762  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
2763  checkGLcall("glBindTexture");
2764  break;
2765  case GL_TEXTURE_2D:
2766  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
2767  break;
2768  case GL_TEXTURE_2D_ARRAY:
2769  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
2770  break;
2772  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
2773  break;
2774  case GL_TEXTURE_CUBE_MAP:
2775  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
2776  break;
2778  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
2779  break;
2780  case GL_TEXTURE_3D:
2781  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
2782  break;
2783  case GL_TEXTURE_BUFFER:
2784  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
2785  break;
2787  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
2788  break;
2790  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
2791  break;
2792  default:
2793  ERR("Unexpected texture target %#x.\n", old_texture_type);
2794  }
2795 
2796  context->texture_type[unit] = target;
2797  }
2798 
2799  checkGLcall("bind texture");
2800 }
struct opengl_funcs gl_ops
Definition: http.c:6587
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
#define GL_TEXTURE_1D
Definition: gl.h:644
const GLuint * textures
Definition: glext.h:8098
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
#define GL_TEXTURE_3D
Definition: gl.h:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_NONE
Definition: gl.h:465
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define ERR(fmt,...)
Definition: debug.h:109
#define checkGLcall(A)
#define GL_TEXTURE_2D
Definition: gl.h:645
Definition: name.c:36
GLenum target
Definition: glext.h:7315

Referenced by create_buffer_texture(), create_texture_view(), draw_textured_quad(), fb_copy_to_texture_direct(), fb_copy_to_texture_hwstretch(), sampler(), shader_resource_view_bind_and_dirtify(), wined3d_shader_resource_view_bind(), and wined3d_texture_bind().

◆ context_bind_unordered_access_views()

static void context_bind_unordered_access_views ( struct wined3d_context context,
const struct wined3d_shader shader,
struct wined3d_unordered_access_view *const views 
)
static

Definition at line 3881 of file context.c.

3883 {
3884  const struct wined3d_gl_info *gl_info = context->gl_info;
3886  GLuint texture_name;
3887  unsigned int i;
3888  GLint level;
3889 
3890  if (!shader)
3891  return;
3892 
3893  for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
3894  {
3895  if (!(view = views[i]))
3896  {
3897  if (shader->reg_maps.uav_resource_info[i].type)
3898  WARN("No unordered access view bound at index %u.\n", i);
3899  GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3900  continue;
3901  }
3902 
3903  if (view->gl_view.name)
3904  {
3905  texture_name = view->gl_view.name;
3906  level = 0;
3907  }
3908  else if (view->resource->type != WINED3D_RTYPE_BUFFER)
3909  {
3910  struct wined3d_texture *texture = texture_from_resource(view->resource);
3912  level = view->desc.u.texture.level_idx;
3913  }
3914  else
3915  {
3916  FIXME("Unsupported buffer unordered access view.\n");
3917  GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3918  continue;
3919  }
3920 
3921  GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE,
3922  view->format->glInternal));
3923 
3924  if (view->counter_bo)
3925  GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo));
3926  }
3927  checkGLcall("Bind unordered access views");
3928 }
GLint level
Definition: gl.h:1546
Definition: http.c:6587
static GLuint wined3d_texture_get_texture_name(const struct wined3d_texture *texture, const struct wined3d_context *context, BOOL srgb)
#define GL_FALSE
Definition: gl.h:173
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_R8
Definition: glext.h:1819
#define GL_READ_WRITE
Definition: glext.h:343
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 FIXME(fmt,...)
Definition: debug.h:110
#define MAX_UNORDERED_ACCESS_VIEWS
#define GL_EXTCALL(f)
GLuint shader
Definition: glext.h:6030
GLenum GLuint texture
Definition: glext.h:6295
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
unsigned int GLuint
Definition: gl.h:159
#define GL_TRUE
Definition: gl.h:174
#define checkGLcall(A)
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glext.h:2297
static IOleDocumentView * view
Definition: activex.c:1749
int GLint
Definition: gl.h:156

Referenced by context_apply_compute_state(), and context_apply_draw_state().

◆ context_check_fbo_status()

void context_check_fbo_status ( const struct wined3d_context context,
GLenum  target 
)

Definition at line 381 of file context.c.

382 {
383  const struct wined3d_gl_info *gl_info = context->gl_info;
384  GLenum status;
385 
386  if (!FIXME_ON(d3d))
387  return;
388 
389  status = gl_info->fbo_ops.glCheckFramebufferStatus(target);
391  {
392  TRACE("FBO complete.\n");
393  }
394  else
395  {
396  unsigned int i;
397 
398  FIXME("FBO status %s (%#x).\n", debug_fbostatus(status), status);
399 
400  if (!context->current_fbo)
401  {
402  ERR("FBO 0 is incomplete, driver bug?\n");
403  return;
404  }
405 
408 
409  for (i = 0; i < gl_info->limits.buffers; ++i)
411  }
412 }
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define FIXME_ON(ch)
Definition: debug.h:406
Definition: http.c:6587
const char * debug_fbostatus(GLenum status)
Definition: utils.c:4767
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
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 GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_FRAMEBUFFER_COMPLETE
Definition: glext.h:1707
#define TRACE(s)
Definition: solgame.cpp:4
static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, GLenum target, GLenum attachment)
Definition: context.c:244
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
GLenum target
Definition: glext.h:7315
struct wined3d_fbo_ops fbo_ops
static SERVICE_STATUS status
Definition: service.c:31
struct wined3d_gl_limits limits
Definition: ps.c:97

Referenced by arbfp_blitter_blit(), context_apply_blit_state(), context_apply_clear_state(), context_apply_draw_state(), ffp_blitter_blit(), read_from_framebuffer(), surface_blt_fbo(), and surface_depth_blt_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  auxBuffers 
)
static

Definition at line 1667 of file context.c.

1670 {
1671  unsigned int cfg_count = device->adapter->cfg_count;
1672  unsigned int current_value;
1674  int iPixelFormat = 0;
1675  unsigned int i;
1676 
1677  TRACE("device %p, dc %p, color_format %s, ds_format %s, aux_buffers %#x.\n",
1678  device, hdc, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id),
1679  auxBuffers);
1680 
1681  current_value = 0;
1682  for (i = 0; i < cfg_count; ++i)
1683  {
1684  const struct wined3d_pixel_format *cfg = &device->adapter->cfgs[i];
1685  unsigned int value;
1686 
1687  /* For now only accept RGBA formats. Perhaps some day we will
1688  * allow floating point formats for pbuffers. */
1689  if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
1690  continue;
1691  /* In window mode we need a window drawable format and double buffering. */
1692  if (!(cfg->windowDrawable && cfg->doubleBuffer))
1693  continue;
1694  if (cfg->redSize < color_format->red_size)
1695  continue;
1696  if (cfg->greenSize < color_format->green_size)
1697  continue;
1698  if (cfg->blueSize < color_format->blue_size)
1699  continue;
1700  if (cfg->alphaSize < color_format->alpha_size)
1701  continue;
1702  if (cfg->depthSize < ds_format->depth_size)
1703  continue;
1704  if (ds_format->stencil_size && cfg->stencilSize != ds_format->stencil_size)
1705  continue;
1706  /* Check multisampling support. */
1707  if (cfg->numSamples)
1708  continue;
1709 
1710  value = 1;
1711  /* We try to locate a format which matches our requirements exactly. In case of
1712  * depth it is no problem to emulate 16-bit using e.g. 24-bit, so accept that. */
1713  if (cfg->depthSize == ds_format->depth_size)
1714  value += 1;
1715  if (cfg->stencilSize == ds_format->stencil_size)
1716  value += 2;
1717  if (cfg->alphaSize == color_format->alpha_size)
1718  value += 4;
1719  /* We like to have aux buffers in backbuffer mode */
1720  if (auxBuffers && cfg->auxBuffers)
1721  value += 8;
1722  if (cfg->redSize == color_format->red_size
1723  && cfg->greenSize == color_format->green_size
1724  && cfg->blueSize == color_format->blue_size)
1725  value += 16;
1726 
1727  if (value > current_value)
1728  {
1729  iPixelFormat = cfg->iPixelFormat;
1730  current_value = value;
1731  }
1732  }
1733 
1734  if (!iPixelFormat)
1735  {
1736  ERR("Trying to locate a compatible pixel format because an exact match failed.\n");
1737 
1738  memset(&pfd, 0, sizeof(pfd));
1739  pfd.nSize = sizeof(pfd);
1740  pfd.nVersion = 1;
1741  pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/
1743  pfd.cAlphaBits = color_format->alpha_size;
1744  pfd.cColorBits = color_format->red_size + color_format->green_size
1745  + color_format->blue_size + color_format->alpha_size;
1746  pfd.cDepthBits = ds_format->depth_size;
1747  pfd.cStencilBits = ds_format->stencil_size;
1749 
1750  if (!(iPixelFormat = ChoosePixelFormat(hdc, &pfd)))
1751  {
1752  /* Something is very wrong as ChoosePixelFormat() barely fails. */
1753  ERR("Can't find a suitable pixel format.\n");
1754  return 0;
1755  }
1756  }
1757 
1758  TRACE("Found iPixelFormat=%d for ColorFormat=%s, DepthStencilFormat=%s.\n",
1759  iPixelFormat, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id));
1760  return iPixelFormat;
1761 }
#define PFD_MAIN_PLANE
Definition: wingdi.h:297
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
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
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI ChoosePixelFormat(_In_ HDC hdc, _In_ const PIXELFORMATDESCRIPTOR *ppfd)
#define PFD_TYPE_RGBA
Definition: wingdi.h:295
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
HDC hdc
Definition: main.c:9
enum wined3d_format_id id
GLsizei const GLfloat * value
Definition: glext.h:6069
#define ERR(fmt,...)
Definition: debug.h:109
_In_ LONG iPixelFormat
Definition: winddi.h:3488
#define WGL_TYPE_RGBA_ARB
Definition: wgl.h:5099
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:305
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:302
#define memset(x, y, z)
Definition: compat.h:39
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3973

Referenced by context_create().

◆ context_clean_fbo_attachments()

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

Definition at line 86 of file context.c.

87 {
88  unsigned int i;
89 
90  for (i = 0; i < gl_info->limits.buffers; ++i)
91  {
92  gl_info->fbo_ops.glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, 0, 0);
93  checkGLcall("glFramebufferTexture2D()");
94  }
95  gl_info->fbo_ops.glFramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
96  checkGLcall("glFramebufferTexture2D()");
97 
98  gl_info->fbo_ops.glFramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
99  checkGLcall("glFramebufferTexture2D()");
100 }
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
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 GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define checkGLcall(A)
#define GL_TEXTURE_2D
Definition: gl.h:645
GLenum target
Definition: glext.h:7315
struct wined3d_fbo_ops fbo_ops
struct wined3d_gl_limits limits

Referenced by context_destroy_fbo(), and context_reuse_fbo_entry().

◆ context_copy_bo_address()

void context_copy_bo_address ( struct wined3d_context context,
const struct wined3d_bo_address dst,
GLenum  dst_binding,
const struct wined3d_bo_address src,
GLenum  src_binding,
size_t  size 
)

Definition at line 2846 of file context.c.

2849 {
2850  const struct wined3d_gl_info *gl_info;
2851  BYTE *dst_ptr, *src_ptr;
2852 
2853  gl_info = context->gl_info;
2854 
2855  if (dst->buffer_object && src->buffer_object)
2856  {
2857  if (gl_info->supported[ARB_COPY_BUFFER])
2858  {
2859  GL_EXTCALL(glBindBuffer(GL_COPY_READ_BUFFER, src->buffer_object));
2860  GL_EXTCALL(glBindBuffer(GL_COPY_WRITE_BUFFER, dst->buffer_object));
2862  (GLintptr)src->addr, (GLintptr)dst->addr, size));
2863  checkGLcall("direct buffer copy");
2864  }
2865  else
2866  {
2867  src_ptr = context_map_bo_address(context, src, size, src_binding, WINED3D_MAP_READ);
2868  dst_ptr = context_map_bo_address(context, dst, size, dst_binding, WINED3D_MAP_WRITE);
2869 
2870  memcpy(dst_ptr, src_ptr, size);
2871 
2872  context_unmap_bo_address(context, dst, dst_binding);
2873  context_unmap_bo_address(context, src, src_binding);
2874  }
2875  }
2876  else if (!dst->buffer_object && src->buffer_object)
2877  {
2878  context_bind_bo(context, src_binding, src->buffer_object);
2879  GL_EXTCALL(glGetBufferSubData(src_binding, (GLintptr)src->addr, size, dst->addr));
2880  checkGLcall("buffer download");
2881  }
2882  else if (dst->buffer_object && !src->buffer_object)
2883  {
2884  context_bind_bo(context, dst_binding, dst->buffer_object);
2885  GL_EXTCALL(glBufferSubData(dst_binding, (GLintptr)dst->addr, size, src->addr));
2886  checkGLcall("buffer upload");
2887  }
2888  else
2889  {
2890  memcpy(dst->addr, src->addr, size);
2891  }
2892 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2831
Definition: http.c:6587
BOOL supported[WINED3D_GL_EXT_COUNT]
ptrdiff_t GLintptr
Definition: glext.h:5498
#define GL_COPY_READ_BUFFER
Definition: glext.h:1887
#define GL_EXTCALL(f)
GLsizeiptr size
Definition: glext.h:5919
#define WINED3D_MAP_READ
Definition: wined3d.h:939
#define WINED3D_MAP_WRITE
Definition: wined3d.h:938
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
#define GL_COPY_WRITE_BUFFER
Definition: glext.h:1889
GLenum GLenum dst
Definition: glext.h:6340
#define checkGLcall(A)
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2802
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name)
Definition: context.c:2724

Referenced by wined3d_buffer_copy(), and wined3d_unordered_access_view_copy_counter().

◆ context_create()

struct wined3d_context* context_create ( struct wined3d_swapchain swapchain,
struct wined3d_texture target,
const struct wined3d_format ds_format 
)

Definition at line 1891 of file context.c.

1893 {
1894  struct wined3d_device *device = swapchain->device;
1895  const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
1896  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1897  const struct wined3d_format *color_format;
1898  struct wined3d_context *ret;
1899  BOOL auxBuffers = FALSE;
1900  HGLRC ctx, share_ctx;
1901  DWORD target_usage;
1902  unsigned int i;
1903  DWORD state;
1904 
1905  TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
1906 
1907  wined3d_from_cs(device->cs);
1908 
1909  if (!(ret = heap_alloc_zero(sizeof(*ret))))
1910  return NULL;
1911 
1912  ret->free_timestamp_query_size = 4;
1913  if (!(ret->free_timestamp_queries = heap_calloc(ret->free_timestamp_query_size,
1914  sizeof(*ret->free_timestamp_queries))))
1915  goto out;
1916  list_init(&ret->timestamp_queries);
1917 
1918  ret->free_occlusion_query_size = 4;
1919  if (!(ret->free_occlusion_queries = heap_calloc(ret->free_occlusion_query_size,
1920  sizeof(*ret->free_occlusion_queries))))
1921  goto out;
1922  list_init(&ret->occlusion_queries);
1923 
1924  ret->free_fence_size = 4;
1925  if (!(ret->free_fences = heap_calloc(ret->free_fence_size, sizeof(*ret->free_fences))))
1926  goto out;
1927  list_init(&ret->fences);
1928 
1929  list_init(&ret->so_statistics_queries);
1930 
1931  list_init(&ret->pipeline_statistics_queries);
1932 
1933  list_init(&ret->fbo_list);
1934  list_init(&ret->fbo_destroy_list);
1935 
1936  if (!device->shader_backend->shader_allocate_context_data(ret))
1937  {
1938  ERR("Failed to allocate shader backend context data.\n");
1939  goto out;
1940  }
1941  if (!device->adapter->fragment_pipe->allocate_context_data(ret))
1942  {
1943  ERR("Failed to allocate fragment pipeline context data.\n");
1944  goto out;
1945  }
1946 
1947  for (i = 0; i < ARRAY_SIZE(ret->tex_unit_map); ++i)
1948  ret->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
1949  for (i = 0; i < ARRAY_SIZE(ret->rev_tex_unit_map); ++i)
1950  ret->rev_tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
1951  if (gl_info->limits.graphics_samplers >= MAX_COMBINED_SAMPLERS)
1952  {
1953  /* Initialize the texture unit mapping to a 1:1 mapping. */
1954  unsigned int base, count;
1955 
1957  if (base + MAX_FRAGMENT_SAMPLERS > ARRAY_SIZE(ret->rev_tex_unit_map))
1958  {
1959  ERR("Unexpected texture unit base index %u.\n", base);
1960  goto out;
1961  }
1962  for (i = 0; i < min(count, MAX_FRAGMENT_SAMPLERS); ++i)
1963  {
1964  ret->tex_unit_map[i] = base + i;
1965  ret->rev_tex_unit_map[base + i] = i;
1966  }
1967 
1969  if (base + MAX_VERTEX_SAMPLERS > ARRAY_SIZE(ret->rev_tex_unit_map))
1970  {
1971  ERR("Unexpected texture unit base index %u.\n", base);
1972  goto out;
1973  }
1974  for (i = 0; i < min(count, MAX_VERTEX_SAMPLERS); ++i)
1975  {
1976  ret->tex_unit_map[MAX_FRAGMENT_SAMPLERS + i] = base + i;
1977  ret->rev_tex_unit_map[base + i] = MAX_FRAGMENT_SAMPLERS + i;
1978  }
1979  }
1980 
1981  if (!(ret->texture_type = heap_calloc(gl_info->limits.combined_samplers,
1982  sizeof(*ret->texture_type))))
1983  goto out;
1984 
1985  if (!(ret->hdc = GetDCEx(swapchain->win_handle, 0, DCX_USESTYLE | DCX_CACHE)))
1986  {
1987  WARN("Failed to retrieve device context, trying swapchain backup.\n");
1988 
1989  if ((ret->hdc = swapchain_get_backup_dc(swapchain)))
1990  ret->hdc_is_private = TRUE;
1991  else
1992  {
1993  ERR("Failed to retrieve a device context.\n");
1994  goto out;
1995  }
1996  }
1997 
1998  color_format = target->resource.format;
1999  target_usage = target->resource.usage;
2000 
2001  /* In case of ORM_BACKBUFFER, make sure to request an alpha component for
2002  * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
2004  {
2005  auxBuffers = TRUE;
2006 
2007  if (color_format->id == WINED3DFMT_B4G4R4X4_UNORM)
2008  color_format = wined3d_get_format(gl_info, WINED3DFMT_B4G4R4A4_UNORM, target_usage);
2009  else if (color_format->id == WINED3DFMT_B8G8R8X8_UNORM)
2010  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2011  }
2012 
2013  /* DirectDraw supports 8bit paletted render targets and these are used by
2014  * old games like StarCraft and C&C. Most modern hardware doesn't support
2015  * 8bit natively so we perform some form of 8bit -> 32bit conversion. The
2016  * conversion (ab)uses the alpha component for storing the palette index.
2017  * For this reason we require a format with 8bit alpha, so request
2018  * A8R8G8B8. */
2019  if (color_format->id == WINED3DFMT_P8_UINT)
2020  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2021 
2022  /* When using FBOs for off-screen rendering, we only use the drawable for
2023  * presentation blits, and don't do any rendering to it. That means we
2024  * don't need depth or stencil buffers, and can mostly ignore the render
2025  * target format. This wouldn't necessarily be quite correct for 10bpc
2026  * display modes, but we don't currently support those.
2027  * Using the same format regardless of the color/depth/stencil targets
2028  * makes it much less likely that different wined3d instances will set
2029  * conflicting pixel formats. */
2031  {
2032  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2034  }
2035 
2036  /* Try to find a pixel format which matches our requirements. */
2037  if (!(ret->pixel_format = context_choose_pixel_format(device, ret->hdc, color_format, ds_format, auxBuffers)))
2038  goto out;
2039 
2040  ret->gl_info = gl_info;
2041  ret->win_handle = swapchain->win_handle;
2042 
2043  context_enter(ret);
2044 
2046  {
2047  ERR("Failed to set pixel format %d on device context %p.\n", ret->pixel_format, ret->hdc);
2049  goto out;
2050  }
2051 
2052  share_ctx = device->context_count ? device->contexts[0]->glCtx : NULL;
2053  if (gl_info->p_wglCreateContextAttribsARB)
2054  {
2055  if (!(ctx = context_create_wgl_attribs(gl_info, ret->hdc, share_ctx)))
2056  goto out;
2057  }
2058  else
2059  {
2060  if (!(ctx = wglCreateContext(ret->hdc)))
2061  {
2062  ERR("Failed to create a WGL context.\n");
2064  goto out;
2065  }
2066 
2067  if (share_ctx && !wglShareLists(share_ctx, ctx))
2068  {
2069  ERR("wglShareLists(%p, %p) failed, last error %#x.\n", share_ctx, ctx, GetLastError());
2071  if (!wglDeleteContext(ctx))
2072  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2073  goto out;
2074  }
2075  }
2076 
2077  if (!device_context_add(device, ret))
2078  {
2079  ERR("Failed to add the newly created context to the context list\n");
2081  if (!wglDeleteContext(ctx))
2082  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2083  goto out;
2084  }
2085 
2086  ret->d3d_info = d3d_info;
2087  ret->state_table = device->StateTable;
2088 
2089  /* Mark all states dirty to force a proper initialization of the states on
2090  * the first use of the context. Compute states do not need initialization. */
2091  for (state = 0; state <= STATE_HIGHEST; ++state)
2092  {
2093  if (ret->state_table[state].representative && !STATE_IS_COMPUTE(state))
2095  }
2096 
2097  ret->device = device;
2098  ret->swapchain = swapchain;
2099  ret->current_rt.texture = target;
2100  ret->current_rt.sub_resource_idx = 0;
2101  ret->tid = GetCurrentThreadId();
2102 
2103  ret->render_offscreen = wined3d_resource_is_offscreen(&target->resource);
2104  ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
2105  ret->valid = 1;
2106 
2107  ret->glCtx = ctx;
2108  ret->hdc_has_format = TRUE;
2109  ret->needs_set = 1;
2110 
2111  /* Set up the context defaults */
2112  if (!context_set_current(ret))
2113  {
2114  ERR("Cannot activate context to set up defaults.\n");
2117  if (!wglDeleteContext(ctx))
2118  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2119  goto out;
2120  }
2121 
2123  {
2124  GL_EXTCALL(glDebugMessageCallback(wined3d_debug_callback, ret));
2125  if (TRACE_ON(d3d_synchronous))
2126  gl_info->gl_ops.gl.p_glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
2127  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_FALSE));
2128  if (ERR_ON(d3d))
2129  {
2130  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_ERROR,
2131  GL_DONT_CARE, 0, NULL, GL_TRUE));
2132  }
2133  if (FIXME_ON(d3d))
2134  {
2136  GL_DONT_CARE, 0, NULL, GL_TRUE));
2138  GL_DONT_CARE, 0, NULL, GL_TRUE));
2139  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PORTABILITY,
2140  GL_DONT_CARE, 0, NULL, GL_TRUE));
2141  }
2142  if (WARN_ON(d3d_perf))
2143  {
2144  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE,
2145  GL_DONT_CARE, 0, NULL, GL_TRUE));
2146  }
2147  }
2148 
2149  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2150  gl_info->gl_ops.gl.p_glGetIntegerv(GL_AUX_BUFFERS, &ret->aux_buffers);
2151 
2152  TRACE("Setting up the screen\n");
2153 
2154  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2155  {
2156  gl_info->gl_ops.gl.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
2157  checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
2158 
2159  gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2160  checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
2161 
2163  checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
2164  }
2165  else
2166  {
2167  GLuint vao;
2168 
2169  GL_EXTCALL(glGenVertexArrays(1, &vao));
2170  GL_EXTCALL(glBindVertexArray(vao));
2171  checkGLcall("creating VAO");
2172  }
2173 
2174  gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);
2175  checkGLcall("glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);");
2176  gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2177  checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, 1);");
2178 
2179  if (gl_info->supported[ARB_VERTEX_BLEND])
2180  {
2181  /* Direct3D always uses n-1 weights for n world matrices and uses
2182  * 1 - sum for the last one this is equal to GL_WEIGHT_SUM_UNITY_ARB.
2183  * Enabling it doesn't do anything unless GL_VERTEX_BLEND_ARB isn't
2184  * enabled as well. */
2185  gl_info->gl_ops.gl.p_glEnable(GL_WEIGHT_SUM_UNITY_ARB);
2186  checkGLcall("glEnable(GL_WEIGHT_SUM_UNITY_ARB)");
2187  }
2188  if (gl_info->supported[NV_TEXTURE_SHADER2])
2189  {
2190  /* Set up the previous texture input for all shader units. This applies to bump mapping, and in d3d
2191  * the previous texture where to source the offset from is always unit - 1.
2192  */
2193  for (i = 1; i < gl_info->limits.textures; ++i)
2194  {
2196  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV,
2198  checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...");
2199  }
2200  }
2201  if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2202  {
2203  /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are
2204  * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but
2205  * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline,
2206  * because the ARBFP extension is enabled by the ARBFP pipeline at context creation, but no program
2207  * is ever assigned.
2208  *
2209  * So make sure a program is assigned to each context. The first real ARBFP use will set a different
2210  * program and the dummy program is destroyed when the context is destroyed.
2211  */
2212  static const char dummy_program[] =
2213  "!!ARBfp1.0\n"
2214  "MOV result.color, fragment.color.primary;\n"
2215  "END\n";
2216  GL_EXTCALL(glGenProgramsARB(1, &ret->dummy_arbfp_prog));
2217  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret->dummy_arbfp_prog));
2218  GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program));
2219  }
2220 
2221  if (gl_info->supported[ARB_POINT_SPRITE])
2222  {
2223  for (i = 0; i < gl_info->limits.textures; ++i)
2224  {
2226  gl_info->gl_ops.gl.p_glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
2227  checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
2228  }
2229  }
2230 
2231  if (gl_info->supported[ARB_PROVOKING_VERTEX])
2232  {
2233  GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
2234  }
2235  else if (gl_info->supported[EXT_PROVOKING_VERTEX])
2236  {
2237  GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT));
2238  }
2239  if (!(d3d_info->wined3d_creation_flags & WINED3D_NO_PRIMITIVE_RESTART))
2240  {
2241  if (gl_info->supported[ARB_ES3_COMPATIBILITY])
2242  {
2243  gl_info->gl_ops.gl.p_glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
2244  checkGLcall("enable GL_PRIMITIVE_RESTART_FIXED_INDEX");
2245  }
2246  else
2247  {
2248  FIXME("OpenGL implementation does not support GL_PRIMITIVE_RESTART_FIXED_INDEX.\n");
2249  }
2250  }
2251  if (!(d3d_info->wined3d_creation_flags & WINED3D_LEGACY_CUBEMAP_FILTERING)
2252  && gl_info->supported[ARB_SEAMLESS_CUBE_MAP])
2253  {
2254  gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
2255  checkGLcall("enable seamless cube map filtering");
2256  }
2257  if (gl_info->supported[ARB_CLIP_CONTROL])
2259  device->shader_backend->shader_init_context_state(ret);
2260  ret->shader_update_mask = (1u << WINED3D_SHADER_TYPE_PIXEL)
2263  | (1u << WINED3D_SHADER_TYPE_HULL)
2266 
2267  /* If this happens to be the first context for the device, dummy textures
2268  * are not created yet. In that case, they will be created (and bound) by
2269  * create_dummy_textures right after this context is initialized. */
2270  if (device->dummy_textures.tex_2d)
2272 
2273  TRACE("Created context %p.\n", ret);
2274 
2275  return ret;
2276 
2277 out:
2278  if (ret->hdc)
2279  wined3d_release_dc(swapchain->win_handle, ret->hdc);
2280  device->shader_backend->shader_free_context_data(ret);
2281  device->adapter->fragment_pipe->free_context_data(ret);
2282  heap_free(ret->texture_type);
2283  heap_free(ret->free_fences);
2284  heap_free(ret->free_occlusion_queries);
2285  heap_free(ret->free_timestamp_queries);
2286  heap_free(ret);
2287  return NULL;
2288 }
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
static void WINE_GLAPI wined3d_debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, void *ctx)
Definition: context.c:1832
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
#define GL_BACK
Definition: gl.h:271
#define GL_WEIGHT_SUM_UNITY_ARB
Definition: glext.h:1270
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define STATE_HIGHEST
#define TRUE
Definition: types.h:120
#define GL_POINT_SPRITE_COORD_ORIGIN
Definition: glext.h:460
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
static BOOL context_set_pixel_format(struct wined3d_context *context)
Definition: context.c:1161
#define FIXME_ON(ch)
Definition: debug.h:406
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:6491
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx)
Definition: context.c:1857
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context.c:2717
static void wined3d_from_cs(const struct wined3d_cs *cs)
#define GL_FALSE
Definition: gl.h:173
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define MAX_VERTEX_SAMPLERS
static BOOL context_debug_output_enabled(const struct wined3d_gl_info *gl_info)
Definition: context.c:1826
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_TEXTURE0_ARB
Definition: gl.h:1966
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
Definition: wgl.h:949
const struct wined3d_format * wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
Definition: utils.c:3824
#define DCX_USESTYLE
Definition: GetDCEx.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define WINED3DUSAGE_DEPTHSTENCIL
Definition: wined3d.h:900
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
#define GL_FIRST_VERTEX_CONVENTION
Definition: glext.h:1907
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
#define STATE_IS_COMPUTE(a)
#define GL_UNPACK_ALIGNMENT
Definition: gl.h:632
#define GL_LOWER_LEFT
Definition: glext.h:461
#define GL_LIGHT_MODEL_COLOR_CONTROL
Definition: gl.h:1498
#define WARN_ON(c)
Definition: module.h:255
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 MAX_COMBINED_SAMPLERS
#define GL_POINT_SPRITE_ARB
Definition: glext.h:1586
#define GL_AUX_BUFFERS
Definition: gl.h:492
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint base
Definition: 3dtext.c:35
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
#define ORM_BACKBUFFER
void context_bind_dummy_textures(const struct wined3d_device *device, const struct wined3d_context *context)
Definition: context.c:1764
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
Definition: wgl.h:928
smooth NULL
Definition: ftsmooth.c:416
void context_release(struct wined3d_context *context)
Definition: context.c:1571
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define GL_COMBINE_EXT
Definition: glext.h:3229
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6437
#define GL_EXTCALL(f)
#define GL_TEXTURE_SHADER_NV
Definition: glext.h:3685
#define TRACE(s)
Definition: solgame.cpp:4
#define GL_LIGHT_MODEL_LOCAL_VIEWER
Definition: gl.h:334
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define GL_TEXTURE_ENV_MODE
Definition: gl.h:643
#define GL_COORD_REPLACE_ARB
Definition: glext.h:1587
#define MAX_FRAGMENT_SAMPLERS
static FILE * out
Definition: regtests2xml.c:44
struct wined3d_device * device
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINED3D_LEGACY_CUBEMAP_FILTERING
Definition: wined3d.h:1327
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
void device_context_remove(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:163
#define ERR_ON(ch)
Definition: debug.h:411
int ret
#define GL_SEPARATE_SPECULAR_COLOR
Definition: gl.h:1500
HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1107
enum wined3d_format_id id
static int state
Definition: maze.c:121
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 auxBuffers)
Definition: context.c:1667
#define WINED3D_UNMAPPED_STAGE
struct wined3d_swapchain * swapchain
#define ERR(fmt,...)
Definition: debug.h:109
#define GL_DEBUG_OUTPUT_SYNCHRONOUS
Definition: wgl.h:893
#define DCX_CACHE
Definition: winuser.h:2096
#define GL_TEXTURE_ENV
Definition: gl.h:642
unsigned int GLuint
Definition: gl.h:159
BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:146
BOOL context_set_current(struct wined3d_context *ctx)
Definition: context.c:1512
#define GL_DEBUG_TYPE_PERFORMANCE
Definition: wgl.h:939
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst)
Definition: wgl.c:868
#define GL_TRUE
Definition: gl.h:174
#define GL_TEXTURE_CUBE_MAP_SEAMLESS
Definition: glext.h:1913
#define checkGLcall(A)
#define min(a, b)
Definition: monoChain.cc:55
#define GL_PACK_ALIGNMENT
Definition: gl.h:626
#define GL_PROGRAM_FORMAT_ASCII_ARB
Definition: glext.h:1405
#define WINED3D_NO_PRIMITIVE_RESTART
Definition: wined3d.h:1326
#define GL_FIRST_VERTEX_CONVENTION_EXT
Definition: glext.h:4920
#define GL_DONT_CARE
Definition: gl.h:583
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
GLenum target
Definition: glext.h:7315
#define GL_DEBUG_TYPE_PORTABILITY
Definition: wgl.h:944
#define GL_PRIMITIVE_RESTART_FIXED_INDEX
Definition: wgl.h:3178
const struct wined3d_gl_info * gl_info
const struct wined3d_d3d_info * d3d_info
static void context_enter(struct wined3d_context *context)
Definition: context.c:1619
static DWORD context_generate_rt_mask(GLenum buffer)
Definition: context.c:414
#define TRACE_ON(x)
Definition: compat.h:65
struct wined3d_device * device
HGLRC WINAPI wglCreateContext(HDC hdc)
Definition: wgl.c:383
#define GL_PREVIOUS_TEXTURE_INPUT_NV
Definition: glext.h:3694
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define GL_DEBUG_TYPE_ERROR
Definition: wgl.h:931
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by swapchain_create_context(), and wined3d_swapchain_cs_init().

◆ context_create_fbo_entry()

static struct fbo_entry* context_create_fbo_entry ( const struct wined3d_context context,
const struct wined3d_rendertarget_info render_targets,
const struct wined3d_rendertarget_info depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 521 of file context.c.

524 {
525  const struct wined3d_gl_info *gl_info = context->gl_info;
526  struct fbo_entry *entry;
527 
528  entry = heap_alloc(sizeof(*entry));
529  context_generate_fbo_key(context, &entry->key, render_targets, depth_stencil, color_location, ds_location);
530  entry->flags = 0;
531  if (depth_stencil->resource)
532  {
533  if (depth_stencil->resource->format_flags & WINED3DFMT_FLAG_DEPTH)
535  if (depth_stencil->resource->format_flags & WINED3DFMT_FLAG_STENCIL)
537  }
539  gl_info->fbo_ops.glGenFramebuffers(1, &entry->id);
540  checkGLcall("glGenFramebuffers()");
541  TRACE("Created FBO %u.\n", entry->id);
542 
543  return entry;
544 }
#define WINED3DFMT_FLAG_STENCIL
struct wined3d_resource * resource
Definition: http.c:6587
static void context_generate_fbo_key(const struct wined3d_context *context, 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.c:505
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define WINED3D_FBO_ENTRY_FLAG_STENCIL
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define checkGLcall(A)
struct wined3d_fbo_ops fbo_ops
#define WINED3DFMT_FLAG_DEPTH
static DWORD context_generate_rt_mask(GLenum buffer)
Definition: context.c:414
#define WINED3D_FBO_ENTRY_FLAG_DEPTH

Referenced by context_find_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 1857 of file context.c.

1858 {
1859  HGLRC ctx;
1860  unsigned int ctx_attrib_idx = 0;
1861  GLint ctx_attribs[7], ctx_flags = 0;
1862 
1863  if (context_debug_output_enabled(gl_info))
1864  ctx_flags = WGL_CONTEXT_DEBUG_BIT_ARB;
1865  ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
1866  ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version >> 16;
1867  ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MINOR_VERSION_ARB;
1868  ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version & 0xffff;
1869  if (gl_info->selected_gl_version >= MAKEDWORD_VERSION(3, 2))
1871  if (ctx_flags)
1872  {
1873  ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_FLAGS_ARB;
1874  ctx_attribs[ctx_attrib_idx++] = ctx_flags;
1875  }
1876  ctx_attribs[ctx_attrib_idx] = 0;
1877 
1878  if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
1879  {
1881  {
1882  ctx_attribs[ctx_attrib_idx - 1] &= ~WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
1883  if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
1884  WARN("Failed to create a WGL context with wglCreateContextAttribsARB, last error %#x.\n",
1885  GetLastError());
1886  }
1887  }
1888  return ctx;
1889 }
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
static BOOL context_debug_output_enabled(const struct wined3d_gl_info *gl_info)
Definition: context.c:1826
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define WGL_CONTEXT_DEBUG_BIT_ARB
Definition: wgl.h:5003
#define WGL_CONTEXT_MAJOR_VERSION_ARB
Definition: wgl.h:5008
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
Definition: wgl.h:5006
HDC hdc
Definition: main.c:9
#define MAKEDWORD_VERSION(maj, min)
#define WGL_CONTEXT_MINOR_VERSION_ARB
Definition: wgl.h:5009
int GLint
Definition: gl.h:156
#define WGL_CONTEXT_FLAGS_ARB
Definition: wgl.h:5005

Referenced by context_create(), and wined3d_caps_gl_ctx_create_attribs().

◆ context_debug_output_enabled()

static BOOL context_debug_output_enabled ( const struct wined3d_gl_info gl_info)
static

Definition at line 1826 of file context.c.

1827 {
1828  return gl_info->supported[ARB_DEBUG_OUTPUT]
1829  && (ERR_ON(d3d) || FIXME_ON(d3d) || WARN_ON(d3d_perf));
1830 }
#define FIXME_ON(ch)
Definition: debug.h:406
#define WARN_ON(c)
Definition: module.h:255
BOOL supported[WINED3D_GL_EXT_COUNT]
#define ERR_ON(ch)
Definition: debug.h:411

Referenced by context_create(), and context_create_wgl_attribs().

◆ context_destroy()

void context_destroy ( struct wined3d_device device,
struct wined3d_context context 
)

Definition at line 2290 of file context.c.

2291 {
2292  BOOL destroy;
2293 
2294  TRACE("Destroying ctx %p\n", context);
2295 
2296  wined3d_from_cs(device->cs);
2297 
2298  /* We delay destroying a context when it is active. The context_release()
2299  * function invokes context_destroy() again while leaving the last level. */
2300  if (context->level)
2301  {
2302  TRACE("Delaying destruction of context %p.\n", context);
2303  context->destroy_delayed = 1;
2304  /* FIXME: Get rid of a pointer to swapchain from wined3d_context. */
2305  context->swapchain = NULL;
2306  return;
2307  }
2308 
2309  if (context->tid == GetCurrentThreadId() || !context->current)
2310  {
2313  destroy = TRUE;
2314  }
2315  else
2316  {
2317  /* Make a copy of gl_info for context_destroy_gl_resources use, the one
2318  in wined3d_adapter may go away in the meantime */
2319  struct wined3d_gl_info *gl_info = heap_alloc(sizeof(*gl_info));
2320  *gl_info = *context->gl_info;
2321  context->gl_info = gl_info;
2322  context->destroyed = 1;
2323  destroy = FALSE;
2324  }
2325 
2326  device->shader_backend->shader_free_context_data(context);
2327  device->adapter->fragment_pipe->free_context_data(context);
2328  heap_free(context->texture_type);
2330  if (destroy)
2331  heap_free(context);
2332 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1264
static void wined3d_from_cs(const struct wined3d_cs *cs)
static void context_destroy_gl_resources(struct wined3d_context *context)
Definition: context.c:1332
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define TRACE(s)
Definition: solgame.cpp:4
static DWORD wined3d_context_tls_idx
Definition: context.c:48
void device_context_remove(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:163
void destroy(_Tp *__pointer)
Definition: _construct.h:278
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by context_release(), swapchain_create_context(), swapchain_destroy_contexts(), and wined3d_device_delete_opengl_contexts_cs().

◆ context_destroy_fbo()

static void context_destroy_fbo ( struct wined3d_context context,
GLuint  fbo 
)
static

Definition at line 103 of file context.c.

104 {
105  const struct wined3d_gl_info *gl_info = context->gl_info;
106 
110 
111  gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
112  checkGLcall("glDeleteFramebuffers()");
113 }
Definition: http.c:6587
#define GL_FRAMEBUFFER
Definition: glext.h:1732
static void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint fbo)
Definition: context.c:53
#define checkGLcall(A)
struct wined3d_fbo_ops fbo_ops
static void context_clean_fbo_attachments(const struct wined3d_gl_info *gl_info, GLenum target)
Definition: context.c:86

Referenced by context_destroy_fbo_entry().

◆ context_destroy_fbo_entry()

static void context_destroy_fbo_entry ( struct wined3d_context context,
struct fbo_entry entry 
)
static

Definition at line 568 of file context.c.

569 {
570  if (entry->id)
571  {
572  TRACE("Destroy FBO %u.\n", entry->id);
574  }
575  --context->fbo_entry_count;
576  list_remove(&entry->entry);
577  heap_free(entry);
578 }
static void context_destroy_fbo(struct wined3d_context *context, GLuint fbo)
Definition: context.c:103
Definition: http.c:6587
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by context_apply_fbo_state(), and context_destroy_gl_resources().

◆ context_destroy_gl_resources()

static void context_destroy_gl_resources ( struct wined3d_context context)
static

Definition at line 1332 of file context.c.

1333 {
1334  struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
1335  const struct wined3d_gl_info *gl_info = context->gl_info;
1336  struct wined3d_so_statistics_query *so_statistics_query;
1337  struct wined3d_timestamp_query *timestamp_query;
1338  struct wined3d_occlusion_query *occlusion_query;
1339  struct fbo_entry *entry, *entry2;
1340  struct wined3d_fence *fence;
1341  HGLRC restore_ctx;
1342  HDC restore_dc;
1343  unsigned int i;
1344 
1345  restore_ctx = wglGetCurrentContext();
1347 
1348  if (restore_ctx == context->glCtx)
1349  restore_ctx = NULL;
1350  else if (context->valid)
1352 
1353  LIST_FOR_EACH_ENTRY(so_statistics_query, &context->so_statistics_queries,
1355  {
1356  if (context->valid)
1357  GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
1358  so_statistics_query->context = NULL;
1359  }
1360 
1361  LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context->pipeline_statistics_queries,
1363  {
1364  if (context->valid)
1365  GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
1366  pipeline_statistics_query->context = NULL;
1367  }
1368 
1369  LIST_FOR_EACH_ENTRY(timestamp_query, &context->timestamp_queries, struct wined3d_timestamp_query, entry)
1370  {
1371  if (context->valid)
1372  GL_EXTCALL(glDeleteQueries(1, &timestamp_query->id));
1373  timestamp_query->context = NULL;
1374  }
1375 
1376  LIST_FOR_EACH_ENTRY(occlusion_query, &context->occlusion_queries, struct wined3d_occlusion_query, entry)
1377  {
1378  if (context->valid && gl_info->supported[ARB_OCCLUSION_QUERY])
1379  GL_EXTCALL(glDeleteQueries(1, &occlusion_query->id));
1380  occlusion_query->context = NULL;
1381  }
1382 
1383  LIST_FOR_EACH_ENTRY(fence, &context->fences, struct wined3d_fence, entry)
1384  {
1385  if (context->valid)
1386  {
1387  if (gl_info->supported[ARB_SYNC])
1388  {
1389  if (fence->object.sync)
1390  GL_EXTCALL(glDeleteSync(fence->object.sync));
1391  }
1392  else if (gl_info->supported[APPLE_FENCE])
1393  {
1394  GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
1395  }
1396  else if (gl_info->supported[NV_FENCE])
1397  {
1398  GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
1399  }
1400  }
1401  fence->context = NULL;
1402  }
1403 
1404  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
1405  {
1406  if (!context->valid) entry->id = 0;
1408  }
1409 
1410  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry)
1411  {
1412  if (!context->valid) entry->id = 0;
1414  }
1415 
1416  if (context->valid)
1417  {
1418  if (context->dummy_arbfp_prog)
1419  {
1420  GL_EXTCALL(glDeleteProgramsARB(1, &context->dummy_arbfp_prog));
1421  }
1422 
1423  if (gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY])
1424  {
1425  for (i = 0; i < context->free_so_statistics_query_count; ++i)
1426  {
1427  union wined3d_gl_so_statistics_query *q = &context->free_so_statistics_queries[i];
1428  GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
1429  }
1430  }
1431 
1433  {
1434  for (i = 0; i < context->free_pipeline_statistics_query_count; ++i)
1435  {
1436  union wined3d_gl_pipeline_statistics_query *q = &context->free_pipeline_statistics_queries[i];
1437  GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
1438  }
1439  }
1440 
1441  if (gl_info->supported[ARB_TIMER_QUERY])
1442  GL_EXTCALL(glDeleteQueries(context->free_timestamp_query_count, context->free_timestamp_queries));
1443 
1444  if (gl_info->supported[ARB_OCCLUSION_QUERY])
1445  GL_EXTCALL(glDeleteQueries(context->free_occlusion_query_count, context->free_occlusion_queries));
1446 
1447  if (gl_info->supported[ARB_SYNC])
1448  {
1449  for (i = 0; i < context->free_fence_count; ++i)
1450  {
1451  GL_EXTCALL(glDeleteSync(context->free_fences[i].sync));
1452  }
1453  }
1454  else if (gl_info->supported[APPLE_FENCE])
1455  {
1456  for (i = 0; i < context->free_fence_count; ++i)
1457  {
1458  GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_fences[i].id));
1459  }
1460  }
1461  else if (gl_info->supported[NV_FENCE])
1462  {
1463  for (i = 0; i < context->free_fence_count; ++i)
1464  {
1465  GL_EXTCALL(glDeleteFencesNV(1, &context->free_fences[i].id));
1466  }
1467  }
1468 
1469  checkGLcall("context cleanup");
1470  }
1471 
1472  heap_free(context->free_so_statistics_queries);
1473  heap_free(context->free_pipeline_statistics_queries);
1474  heap_free(context->free_timestamp_queries);
1475  heap_free(context->free_occlusion_queries);
1476  heap_free(context->free_fences);
1477 
1479  if (restore_ctx)
1480  {
1481  context_restore_gl_context(gl_info, restore_dc, restore_ctx);
1482  }
1483  else if (wglGetCurrentContext() && !wglMakeCurrent(NULL, NULL))
1484  {
1485  ERR("Failed to disable GL context.\n");
1486  }
1487 
1488  wined3d_release_dc(context->win_handle, context->hdc);
1489 
1490  if (!wglDeleteContext(context->glCtx))
1491  {
1492  DWORD err = GetLastError();
1493  ERR("wglDeleteContext(%p) failed, last error %#x.\n", context->glCtx, err);
1494  }
1495 }
static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx)
Definition: context.c:1295
union wined3d_gl_fence_object object
union wined3d_gl_pipeline_statistics_query u
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
struct wined3d_context * context
Definition: http.c:6587
HDC WINAPI wglGetCurrentDC(void)
Definition: wgl.c:579
static HDC
Definition: imagelist.c:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static BOOL context_restore_pixel_format(struct wined3d_context *ctx)
Definition: context.c:1130
struct wined3d_context * context
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
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
HGLRC WINAPI wglGetCurrentContext(void)
Definition: wgl.c:574
BOOL supported[WINED3D_GL_EXT_COUNT]
smooth NULL
Definition: ftsmooth.c:416
struct wined3d_context * context
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6437
#define GL_EXTCALL(f)