ReactOS  0.4.13-dev-249-gcba1a2f
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, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
 
void context_apply_fbo_state_blit (struct wined3d_context *context, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, 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)
 
void context_gl_resource_released (struct wined3d_device *device, GLuint name, BOOL rb_namespace)
 
void context_texture_update (struct wined3d_context *context, const struct wined3d_texture *texture)
 
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_texture *texture, unsigned int sub_resource_idx)
 
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 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 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_resource *rt)
 
void context_apply_blit_state (struct wined3d_context *context, const struct wined3d_device *device)
 
static void context_apply_blit_projection (const struct wined3d_context *context, unsigned int w, unsigned int h)
 
void context_apply_ffp_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)
 
void context_unload_tex_coords (const struct wined3d_context *context)
 
void context_load_tex_coords (const struct wined3d_context *context, const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state)
 
static void context_unload_vertex_data (struct wined3d_context *context)
 
static void context_load_vertex_data (struct wined3d_context *context, const struct wined3d_stream_info *si, const struct wined3d_state *state)
 
static void context_unload_numbered_array (struct wined3d_context *context, unsigned int i)
 
static void context_unload_numbered_arrays (struct wined3d_context *context)
 
static void context_load_numbered_arrays (struct wined3d_context *context, const struct wined3d_stream_info *stream_info, const struct wined3d_state *state)
 
void context_update_stream_sources (struct wined3d_context *context, const struct wined3d_state *state)
 
static void apply_texture_blit_state (const struct wined3d_gl_info *gl_info, struct gl_texture *texture, GLenum target, unsigned int level, enum wined3d_texture_filter_type filter)
 
void context_draw_shaded_quad (struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
 
void context_draw_textured_quad (struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
 

Variables

static DWORD wined3d_context_tls_idx
 

Macro Definition Documentation

◆ 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 1036 of file context.c.

Function Documentation

◆ apply_texture_blit_state()

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

Definition at line 5632 of file context.c.

5634 {
5635  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(filter));
5636  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
5638  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
5639  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
5640  if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
5641  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
5642  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, level);
5643 
5644  /* We changed the filtering settings on the texture. Make sure they get
5645  * reset on subsequent draws. */
5646  texture->sampler_desc.mag_filter = WINED3D_TEXF_POINT;
5647  texture->sampler_desc.min_filter = WINED3D_TEXF_POINT;
5648  texture->sampler_desc.mip_filter = WINED3D_TEXF_NONE;
5649  texture->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP;
5650  texture->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP;
5651  texture->sampler_desc.srgb_decode = FALSE;
5652  texture->base_level = level;
5653 }
GLint level
Definition: gl.h:1546
struct opengl_funcs gl_ops
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
BOOL supported[WINED3D_GL_EXT_COUNT]
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
GLenum target
Definition: glext.h:7315
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define GL_TEXTURE_BASE_LEVEL
Definition: gl.h:1503
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291

Referenced by context_draw_shaded_quad(), and context_draw_textured_quad().

◆ context_acquire()

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

Definition at line 4218 of file context.c.

4220 {
4221  struct wined3d_context *current_context = context_get_current();
4222  struct wined3d_context *context;
4223  BOOL swapchain_texture;
4224 
4225  TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
4226 
4227  wined3d_from_cs(device->cs);
4228 
4229  if (current_context && current_context->destroyed)
4230  current_context = NULL;
4231 
4232  swapchain_texture = texture && texture->swapchain;
4233  if (!texture)
4234  {
4235  if (current_context
4236  && current_context->current_rt.texture
4237  && current_context->device == device)
4238  {
4239  texture = current_context->current_rt.texture;
4240  sub_resource_idx = current_context->current_rt.sub_resource_idx;
4241  }
4242  else
4243  {
4244  struct wined3d_swapchain *swapchain = device->swapchains[0];
4245 
4246  if (swapchain->back_buffers)
4247  texture = swapchain->back_buffers[0];
4248  else
4249  texture = swapchain->front_buffer;
4250  sub_resource_idx = 0;
4251  }
4252  }
4253 
4254  if (current_context && current_context->current_rt.texture == texture)
4255  {
4256  context = current_context;
4257  }
4258  else if (swapchain_texture)
4259  {
4260  TRACE("Rendering onscreen.\n");
4261 
4262  context = swapchain_get_context(texture->swapchain);
4263  }
4264  else
4265  {
4266  TRACE("Rendering offscreen.\n");
4267 
4268  /* Stay with the current context if possible. Otherwise use the
4269  * context for the primary swapchain. */
4270  if (current_context && current_context->device == device)
4271  context = current_context;
4272  else
4273  context = swapchain_get_context(device->swapchains[0]);
4274  }
4275 
4276  context_activate(context, texture, sub_resource_idx);
4277 
4278  return context;
4279 }
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:4198
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:1495
#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:1072
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(), shader_arb_destroy(), shader_glsl_destroy(), shader_glsl_precompile(), shader_resource_view_generate_mipmaps(), surface_convert_format(), surface_cpu_blt(), surface_cpu_blt_colour_fill(), swapchain_gl_frontbuffer_updated(), swapchain_gl_present(), texture2d_blt(), texture2d_blt_fbo(), texture2d_load_drawable(), texture2d_load_fb_texture(), texture2d_read_from_framebuffer(), 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_swapchain_set_swap_interval(), wined3d_texture_cleanup(), wined3d_texture_copy_sysmem_location(), wined3d_texture_create_dc(), wined3d_texture_destroy_dc(), wined3d_texture_unload(), wined3d_texture_unload_gl_texture(), wined3d_texture_update_map_binding(), wined3d_texture_upload_from_texture(), 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 4198 of file context.c.

4200 {
4203  context_setup_target(context, texture, sub_resource_idx);
4204  if (!context->valid)
4205  return;
4206 
4207  if (context != context_get_current())
4208  {
4210  ERR("Failed to activate the new context.\n");
4211  }
4212  else if (context->needs_set)
4213  {
4215  }
4216 }
Definition: http.c:6587
struct wined3d_context * context_get_current(void)
Definition: context.c:1495
GLenum GLuint texture
Definition: glext.h:6295
static BOOL context_set_gl_context(struct wined3d_context *ctx)
Definition: context.c:1219
#define ERR(fmt,...)
Definition: debug.h:109
BOOL context_set_current(struct wined3d_context *ctx)
Definition: context.c:1500
static void context_setup_target(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4136
static void context_update_window(struct wined3d_context *context)
Definition: context.c:1290
static void context_enter(struct wined3d_context *context)
Definition: context.c:1605

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 2486 of file context.c.

2487 {
2489  checkGLcall("glActiveTexture");
2490  context->active_texture = unit;
2491 }
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_apply_blit_state(), context_apply_ffp_blit_state(), context_create(), create_dummy_textures(), glsl_blitter_upload_palette(), nvrc_colorop(), nvts_bumpenvmat(), sampler(), set_tex_op_atifs(), 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 860 of file context.c.

861 {
862  const struct wined3d_gl_info *gl_info = context->gl_info;
863 
864  if (context->free_fence_count)
865  {
866  fence->object = context->free_fences[--context->free_fence_count];
867  }
868  else
869  {
870  if (gl_info->supported[ARB_SYNC])
871  {
872  /* Using ARB_sync, not much to do here. */
873  fence->object.sync = NULL;
874  TRACE("Allocated sync object in context %p.\n", context);
875  }
876  else if (gl_info->supported[APPLE_FENCE])
877  {
878  GL_EXTCALL(glGenFencesAPPLE(1, &fence->object.id));
879  checkGLcall("glGenFencesAPPLE");
880 
881  TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
882  }
883  else if(gl_info->supported[NV_FENCE])
884  {
885  GL_EXTCALL(glGenFencesNV(1, &fence->object.id));
886  checkGLcall("glGenFencesNV");
887 
888  TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
889  }
890  else
891  {
892  WARN("Fences not supported, not allocating fence.\n");
893  fence->object.id = 0;
894  }
895  }
896 
897  fence->context = context;
898  list_add_head(&context->fences, &fence->entry);
899 }
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 813 of file context.c.

814 {
815  const struct wined3d_gl_info *gl_info = context->gl_info;
816 
817  if (context->free_occlusion_query_count)
818  {
819  query->id = context->free_occlusion_queries[--context->free_occlusion_query_count];
820  }
821  else
822  {
823  if (gl_info->supported[ARB_OCCLUSION_QUERY])
824  {
825  GL_EXTCALL(glGenQueries(1, &query->id));
826  checkGLcall("glGenQueries");
827 
828  TRACE("Allocated occlusion query %u in context %p.\n", query->id, context);
829  }
830  else
831  {
832  WARN("Occlusion queries not supported, not allocating query id.\n");
833  query->id = 0;
834  }
835  }
836 
837  query->context = context;
838  list_add_head(&context->occlusion_queries, &query->entry);
839 }
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 999 of file context.c.

1001 {
1002  const struct wined3d_gl_info *gl_info = context->gl_info;
1003 
1004  if (context->free_pipeline_statistics_query_count)
1005  {
1006  query->u = context->free_pipeline_statistics_queries[--context->free_pipeline_statistics_query_count];
1007  }
1008  else
1009  {
1010  GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
1011  checkGLcall("glGenQueries");
1012  }
1013 
1014  query->context = context;
1015  list_add_head(&context->pipeline_statistics_queries, &query->entry);
1016 }
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 958 of file context.c.

960 {
961  const struct wined3d_gl_info *gl_info = context->gl_info;
962 
963  if (context->free_so_statistics_query_count)
964  {
965  query->u = context->free_so_statistics_queries[--context->free_so_statistics_query_count];
966  }
967  else
968  {
969  GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
970  checkGLcall("glGenQueries");
971 
972  TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
973  query->u.id[0], query->u.id[1], context);
974  }
975 
976  query->context = context;
977  list_add_head(&context->so_statistics_queries, &query->entry);
978 }
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 920 of file context.c.

921 {
922  const struct wined3d_gl_info *gl_info = context->gl_info;
923 
924  if (context->free_timestamp_query_count)
925  {
926  query->id = context->free_timestamp_queries[--context->free_timestamp_query_count];
927  }
928  else
929  {
930  GL_EXTCALL(glGenQueries(1, &query->id));
931  checkGLcall("glGenQueries");
932 
933  TRACE("Allocated timestamp query %u in context %p.\n", query->id, context);
934  }
935 
936  query->context = context;
937  list_add_head(&context->timestamp_queries, &query->entry);
938 }
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_projection()

static void context_apply_blit_projection ( const struct wined3d_context context,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 2882 of file context.c.

2883 {
2884  const struct wined3d_gl_info *gl_info = context->gl_info;
2885  const GLdouble projection[] =
2886  {
2887  2.0 / w, 0.0, 0.0, 0.0,
2888  0.0, 2.0 / h, 0.0, 0.0,
2889  0.0, 0.0, 2.0, 0.0,
2890  -1.0, -1.0, -1.0, 1.0,
2891  };
2892 
2893  gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
2894  gl_info->gl_ops.gl.p_glLoadMatrixd(projection);
2895 }
double GLdouble
Definition: gl.h:163
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
struct opengl_funcs gl_ops
Definition: http.c:6587
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define GL_PROJECTION
Definition: gl.h:246

Referenced by context_apply_ffp_blit_state().

◆ context_apply_blit_state()

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

Definition at line 2748 of file context.c.

2749 {
2750  const struct wined3d_gl_info *gl_info = context->gl_info;
2751  struct wined3d_texture *rt = context->current_rt.texture;
2752  DWORD rt_mask, *cur_mask;
2753  unsigned int i, sampler;
2754  SIZE rt_size;
2755 
2756  TRACE("Setting up context %p for blitting.\n", context);
2757 
2759  {
2760  if (context->render_offscreen)
2761  {
2763 
2765  context->current_rt.sub_resource_idx, NULL, 0, rt->resource.draw_binding);
2766  if (rt->resource.format->id != WINED3DFMT_NULL)
2767  rt_mask = 1;
2768  else
2769  rt_mask = 0;
2770  }
2771  else
2772  {
2773  context->current_fbo = NULL;
2776  }
2777  }
2778  else
2779  {
2781  }
2782 
2783  cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask;
2784 
2785  if (rt_mask != *cur_mask)
2786  {
2788  *cur_mask = rt_mask;
2789  }
2790 
2792  {
2794  }
2796 
2797  context_get_rt_size(context, &rt_size);
2798 
2799  if (context->last_was_blit)
2800  {
2801  if (context->blit_w != rt_size.cx || context->blit_h != rt_size.cy)
2802  {
2803  gl_info->gl_ops.gl.p_glViewport(0, 0, rt_size.cx, rt_size.cy);
2804  context->viewport_count = WINED3D_MAX_VIEWPORTS;
2805  context->blit_w = rt_size.cx;
2806  context->blit_h = rt_size.cy;
2807  /* No need to dirtify here, the states are still dirtified because
2808  * they weren't applied since the last context_apply_blit_state()
2809  * call. */
2810  }
2811  checkGLcall("blit state application");
2812  TRACE("Context is already set up for blitting, nothing to do.\n");
2813  return;
2814  }
2815  context->last_was_blit = TRUE;
2816 
2817  if (gl_info->supported[ARB_SAMPLER_OBJECTS])
2818  GL_EXTCALL(glBindSampler(0, 0));
2819  context_active_texture(context, gl_info, 0);
2820 
2821  sampler = context->rev_tex_unit_map[0];
2823  {
2824  if (sampler < MAX_TEXTURES)
2825  {
2828  }
2830  }
2831 
2832  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2833  {
2834  gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
2836  }
2837  gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST);
2839  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2841  gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE);
2843  gl_info->gl_ops.gl.p_glDisable(GL_STENCIL_TEST);
2845  gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
2847  if (gl_info->supported[ARB_POINT_SPRITE])
2848  {
2849  gl_info->gl_ops.gl.p_glDisable(GL_POINT_SPRITE_ARB);
2851  }
2852  if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
2853  {
2854  gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
2856  }
2857  gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2858  for (i = 0; i < MAX_RENDER_TARGETS; ++i)
2860 
2861  context->last_was_rhw = TRUE;
2862  context_invalidate_state(context, STATE_VDECL); /* because of last_was_rhw = TRUE */
2863 
2866 
2867  /* FIXME: Make draw_textured_quad() able to work with a upper left origin. */
2868  if (gl_info->supported[ARB_CLIP_CONTROL])
2870  gl_info->gl_ops.gl.p_glViewport(0, 0, rt_size.cx, rt_size.cy);
2871  context->viewport_count = WINED3D_MAX_VIEWPORTS;
2873 
2874  device->shader_backend->shader_disable(device->shader_priv, context);
2875 
2876  context->blit_w = rt_size.cx;
2877  context->blit_h = rt_size.cy;
2878 
2879  checkGLcall("blit state application");
2880 }
#define ORM_FBO
#define MAX_RENDER_TARGETS
#define STATE_TEXTURESTAGE(stage, num)
#define MAX_TEXTURES
#define TRUE
Definition: types.h:120
struct opengl_funcs gl_ops
#define STATE_VDECL
#define GL_BLEND
Definition: gl.h:371
#define GL_CULL_FACE
Definition: gl.h:276
Definition: http.c:6587
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context.c:2486
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location)
Definition: context.c:788
struct wined3d_resource resource
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
static enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
Definition: wined3d.h:399
#define GL_LOWER_LEFT
Definition: glext.h:461
#define STATE_TRANSFORM(a)
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
static void context_get_rt_size(const struct wined3d_context *context, SIZE *size)
Definition: context.c:2362
#define GL_POINT_SPRITE_ARB
Definition: glext.h:1586
Definition: devices.h:37
#define GL_FRAMEBUFFER_SRGB
Definition: glext.h:1758
BOOL supported[WINED3D_GL_EXT_COUNT]
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:382
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_EXTCALL(f)
#define GL_SCISSOR_TEST
Definition: gl.h:589
#define TRACE(s)
Definition: solgame.cpp:4
#define GL_STENCIL_TEST
Definition: gl.h:449
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:421
#define WINED3D_MAX_VIEWPORTS
Definition: wined3d.h:1579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_NEGATIVE_ONE_TO_ONE
Definition: wgl.h:2659
void context_enable_clip_distances(struct wined3d_context *context, unsigned int enable_mask)
Definition: context.c:2383
#define WINED3D_UNMAPPED_STAGE
#define STATE_RENDER(a)
#define STATE_SAMPLER(num)
#define STATE_VIEWPORT
#define GL_DEPTH_TEST
Definition: gl.h:301
#define GL_TRUE
Definition: gl.h:174
#define checkGLcall(A)
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1262
#define GL_ALPHA_TEST
Definition: gl.h:366
#define STATE_FRAMEBUFFER
LONG cy
Definition: windef.h:320
static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt_mask)
Definition: context.c:2421
static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_context *context, struct wined3d_resource *rt)
Definition: context.c:2737
GLuint sampler
Definition: glext.h:7283

Referenced by context_apply_ffp_blit_state(), fb_copy_to_texture_direct(), glsl_blitter_blit(), and texture2d_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 3002 of file context.c.

3004 {
3005  struct wined3d_rendertarget_view * const *rts = fb->render_targets;
3006  struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
3007  const struct wined3d_gl_info *gl_info = context->gl_info;
3008  DWORD rt_mask = 0, *cur_mask;
3009  unsigned int i;
3010 
3011  if (isStateDirty(context, STATE_FRAMEBUFFER) || fb != state->fb
3012  || rt_count != gl_info->limits.buffers)
3013  {
3014  if (!have_framebuffer_attachment(rt_count, rts, dsv))
3015  {
3016  WARN("Invalid render target config, need at least one attachment.\n");
3017  return FALSE;
3018  }
3019 
3021  {
3022  struct wined3d_rendertarget_info ds_info = {{0}};
3023 
3025 
3026  if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))
3027  {
3028  memset(context->blit_targets, 0, sizeof(context->blit_targets));
3029  for (i = 0; i < rt_count; ++i)
3030  {
3031  if (rts[i])
3032  {
3033  context->blit_targets[i].gl_view = rts[i]->gl_view;
3034  context->blit_targets[i].resource = rts[i]->resource;
3035  context->blit_targets[i].sub_resource_idx = rts[i]->sub_resource_idx;
3036  context->blit_targets[i].layer_count = rts[i]->layer_count;
3037  }
3038  if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3039  rt_mask |= (1u << i);
3040  }
3041 
3042  if (dsv)
3043  {
3044  ds_info.gl_view = dsv->gl_view;
3045  ds_info.resource = dsv->resource;
3046  ds_info.sub_resource_idx = dsv->sub_resource_idx;
3047  ds_info.layer_count = dsv->layer_count;
3048  }
3049 
3050  context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, &ds_info,
3051  rt_count ? rts[0]->resource->draw_binding : 0,
3052  dsv ? dsv->resource->draw_binding : 0);
3053  }
3054  else
3055  {
3059  }
3060 
3061  /* If the framebuffer is not the device's fb the device's fb has to be reapplied
3062  * next draw. Otherwise we could mark the framebuffer state clean here, once the
3063  * state management allows this */
3065  }
3066  else
3067  {
3068  rt_mask = context_generate_rt_mask_no_fbo(context, rt_count ? rts[0]->resource : NULL);
3069  }
3070  }
3072  && (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)))
3073  {
3074  for (i = 0; i < rt_count; ++i)
3075  {
3076  if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
3077  rt_mask |= (1u << i);
3078  }
3079  }
3080  else
3081  {
3082  rt_mask = context_generate_rt_mask_no_fbo(context, rt_count ? rts[0]->resource : NULL);
3083  }
3084 
3085  cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask;
3086 
3087  if (rt_mask != *cur_mask)
3088  {
3090  *cur_mask = rt_mask;
3092  }
3093 
3095  {
3097  }
3098 
3099  context->last_was_blit = FALSE;
3100  context->last_was_ffp_blit = FALSE;
3101 
3102  /* Blending and clearing should be orthogonal, but tests on the nvidia
3103  * driver show that disabling blending when clearing improves the clearing
3104  * performance incredibly. */
3105  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
3106  gl_info->gl_ops.gl.p_glEnable(GL_SCISSOR_TEST);
3107  if (rt_count && gl_info->supported[ARB_FRAMEBUFFER_SRGB])
3108  {
3109  if (needs_srgb_write(context, state, fb))
3110  gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB);
3111  else
3112  gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
3114  }
3115  checkGLcall("setting up state for clear");
3116 
3120 
3121  return TRUE;
3122 }
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
struct opengl_funcs gl_ops
struct wined3d_resource * resource
#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:1638
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
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:382
#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:2698
static DWORD context_generate_rt_mask_from_resource(struct wined3d_resource *resource)
Definition: context.c:421
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:540
static void context_apply_fbo_state(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:757
static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
Definition: context.c:2984
static int state
Definition: maze.c:121
struct wined3d_gl_view gl_view
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:2421
static BOOL needs_srgb_write(const struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_fb_state *fb)
static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_context *context, struct wined3d_resource *rt)
Definition: context.c:2737
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 4035 of file context.c.

4037 {
4038  const struct StateEntry *state_table = context->state_table;
4039  const struct wined3d_gl_info *gl_info = context->gl_info;
4040  unsigned int state_id, i;
4041 
4044  state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4045 
4046  for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context->dirty_compute_states); ++i)
4047  {
4048  unsigned int dirty_mask = context->dirty_compute_states[i];
4049  while (dirty_mask)
4050  {
4051  unsigned int current_state_id = state_id + wined3d_bit_scan(&dirty_mask);
4052  state_table[current_state_id].apply(context, state, current_state_id);
4053  }
4054  state_id += sizeof(*context->dirty_compute_states) * CHAR_BIT;
4055  }
4056  memset(context->dirty_compute_states, 0, sizeof(*context->dirty_compute_states));
4057 
4058  if (context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_COMPUTE))
4059  {
4060  device->shader_backend->shader_select_compute(device->shader_priv, context, state);
4061  context->shader_update_mask &= ~(1u << WINED3D_SHADER_TYPE_COMPUTE);
4062  }
4063 
4064  if (context->update_compute_shader_resource_bindings)
4065  {
4067  context->update_compute_shader_resource_bindings = 0;
4068  if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4069  context->update_shader_resource_bindings = 1;
4070  }
4071 
4072  if (context->update_compute_unordered_access_view_bindings)
4073  {
4076  state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
4077  context->update_compute_unordered_access_view_bindings = 0;
4078  context->update_unordered_access_view_bindings = 1;
4079  }
4080 
4081  /* Updates to currently bound render targets aren't necessarily coherent
4082  * between the graphics and compute pipelines. Unbind any currently bound
4083  * FBO here to ensure preceding updates to its attachments by the graphics
4084  * pipeline are visible to the compute pipeline.
4085  *
4086  * Without this, the bloom effect in Nier:Automata is too bright on the
4087  * Mesa radeonsi driver, and presumably on other Mesa based drivers. */
4090 
4091  context->last_was_blit = FALSE;
4092  context->last_was_ffp_blit = FALSE;
4093 }
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:1638
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:3739
#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:3820
static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
Definition: context.c:3776
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:3855
#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 2421 of file context.c.

2422 {
2423  const struct wined3d_gl_info *gl_info = context->gl_info;
2424  GLenum draw_buffers[MAX_RENDER_TARGET_VIEWS];
2425 
2426  if (!rt_mask)
2427  {
2428  gl_info->gl_ops.gl.p_glDrawBuffer(GL_NONE);
2429  }
2430  else if (is_rt_mask_onscreen(rt_mask))
2431  {
2432  gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffer_from_rt_mask(rt_mask));
2433  }
2434  else
2435  {
2437  {
2438  unsigned int i = 0;
2439 
2440  while (rt_mask)
2441  {
2442  if (rt_mask & 1)
2443  draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
2444  else
2445  draw_buffers[i] = GL_NONE;
2446 
2447  rt_mask >>= 1;
2448  ++i;
2449  }
2450 
2451  if (gl_info->supported[ARB_DRAW_BUFFERS])
2452  {
2453  GL_EXTCALL(glDrawBuffers(i, draw_buffers));
2454  }
2455  else
2456  {
2457  gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]);
2458  }
2459  }
2460  else
2461  {
2462  ERR("Unexpected draw buffers mask with backbuffer ORM.\n");
2463  }
2464  }
2465 
2466  checkGLcall("apply draw buffers");
2467 }
#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:2415
#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:2410

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 3921 of file context.c.

3923 {
3924  const struct StateEntry *state_table = context->state_table;
3925  const struct wined3d_gl_info *gl_info = context->gl_info;
3926  const struct wined3d_fb_state *fb = state->fb;
3927  unsigned int i;
3928  WORD map;
3929 
3930  if (!have_framebuffer_attachment(gl_info->limits.buffers, fb->render_targets, fb->depth_stencil))
3931  {
3933  {
3934  FIXME("OpenGL implementation does not support framebuffers with no attachments.\n");
3935  return FALSE;
3936  }
3937 
3939  }
3940 
3942  {
3944  }
3945 
3946  /* Preload resources before FBO setup. Texture preload in particular may
3947  * result in changes to the current FBO, due to using e.g. FBO blits for
3948  * updating a resource location. */
3953  state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
3955  /* TODO: Right now the dependency on the vertex shader is necessary
3956  * since wined3d_stream_info_from_declaration() depends on the reg_maps of
3957  * the current VS but maybe it's possible to relax the coupling in some
3958  * situations at least. */
3961  {
3963  }
3964  else
3965  {
3966  for (i = 0, map = context->stream_info.use_map; map; map >>= 1, ++i)
3967  {
3968  if (map & 1)
3969  wined3d_buffer_load(state->streams[context->stream_info.elements[i].stream_idx].buffer,
3970  context, state);
3971  }
3972  /* Loading the buffers above may have invalidated the stream info. */
3975  }
3976  if (state->index_buffer)
3977  {
3978  if (context->stream_info.all_vbo)
3979  wined3d_buffer_load(state->index_buffer, context, state);
3980  else
3981  wined3d_buffer_load_sysmem(state->index_buffer, context);
3982  }
3983 
3984  for (i = 0; i < context->numDirtyEntries; ++i)
3985  {
3986  DWORD rep = context->dirtyArray[i];
3987  DWORD idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
3988  BYTE shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
3989  context->isStateDirty[idx] &= ~(1u << shift);
3990  state_table[rep].apply(context, state, rep);
3991  }
3992 
3993  if (context->shader_update_mask & ~(1u << WINED3D_SHADER_TYPE_COMPUTE))
3994  {
3995  device->shader_backend->shader_select(device->shader_priv, context, state);
3996  context->shader_update_mask &= 1u << WINED3D_SHADER_TYPE_COMPUTE;
3997  }
3998 
3999  if (context->constant_update_mask)
4000  {
4001  device->shader_backend->shader_load_constants(device->shader_priv, context, state);
4002  context->constant_update_mask = 0;
4003  }
4004 
4005  if (context->update_shader_resource_bindings)
4006  {
4007  for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
4009  context->update_shader_resource_bindings = 0;
4010  if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4011  context->update_compute_shader_resource_bindings = 1;
4012  }
4013 
4014  if (context->update_unordered_access_view_bindings)
4015  {
4018  state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
4019  context->update_unordered_access_view_bindings = 0;
4020  context->update_compute_unordered_access_view_bindings = 1;
4021  }
4022 
4024  {
4026  }
4027 
4028  context->numDirtyEntries = 0; /* This makes the whole list clean */
4029  context->last_was_blit = FALSE;
4030  context->last_was_ffp_blit = FALSE;
4031 
4032  return TRUE;
4033 }
static void context_load_stream_output_buffers(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3904
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:703
#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:3739
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:382
#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:3820
#define STATE_STREAMSRC
static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3606
static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state, enum wined3d_shader_type shader_type)
Definition: context.c:3776
static void context_validate_onscreen_formats(struct wined3d_context *context, const struct wined3d_rendertarget_view *depth_stencil)
Definition: context.c:2698
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:3426
static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view *const *rts, const struct wined3d_rendertarget_view *ds)
Definition: context.c:2984
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:3855
#define STATE_FRAMEBUFFER
void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state)
Definition: buffer.c:884
static void context_set_render_offscreen(struct wined3d_context *context, BOOL offscreen)
Definition: context.c:2661
struct wined3d_gl_limits limits
static void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c: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 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 705 of file context.c.

706 {
707  const struct wined3d_gl_info *gl_info = context->gl_info;
708  GLuint read_binding, draw_binding;
709  unsigned int i;
710 
712  {
714  return;
715  }
716 
717  read_binding = context->fbo_read_binding;
718  draw_binding = context->fbo_draw_binding;
720 
722  {
723  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
724  GL_FRAMEBUFFER_DEFAULT_WIDTH, gl_info->limits.framebuffer_width));
725  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER,
726  GL_FRAMEBUFFER_DEFAULT_HEIGHT, gl_info->limits.framebuffer_height));
727  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_LAYERS, 1));
728  GL_EXTCALL(glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1));
729  }
730 
731  /* Apply render targets */
732  for (i = 0; i < gl_info->limits.buffers; ++i)
733  {
734  context_attach_surface_fbo(context, target, i, &entry->key.objects[i + 1],
735  entry->key.rb_namespace & (1 << (i + 1)));
736  }
737 
739  entry->key.rb_namespace & 0x1, entry->flags);
740 
741  /* Set valid read and draw buffer bindings to satisfy pedantic pre-ES2_compatibility
742  * GL contexts requirements. */
743  gl_info->gl_ops.gl.p_glReadBuffer(GL_NONE);
745  if (target != GL_FRAMEBUFFER)
746  {
749  else
751  }
752 
754 }
#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:177
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:217
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2470
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,
const struct wined3d_rendertarget_info render_targets,
const struct wined3d_rendertarget_info depth_stencil,
DWORD  color_location,
DWORD  ds_location 
)
static

Definition at line 757 of file context.c.

760 {
761  struct fbo_entry *entry, *entry2;
762 
763  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
764  {
766  }
767 
768  if (context->rebind_fbo)
769  {
771  context->rebind_fbo = FALSE;
772  }
773 
774  if (color_location == WINED3D_LOCATION_DRAWABLE)
775  {
776  context->current_fbo = NULL;
778  }
779  else
780  {
782  render_targets, depth_stencil, color_location, ds_location);
784  }
785 }
Definition: http.c:6587
static void context_apply_fbo_entry(struct wined3d_context *context, GLenum target, struct fbo_entry *entry)
Definition: context.c:705
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:578
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
static void context_destroy_fbo_entry(struct wined3d_context *context, struct fbo_entry *entry)
Definition: context.c:565

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_resource rt,
unsigned int  rt_sub_resource_idx,
struct wined3d_resource ds,
unsigned int  ds_sub_resource_idx,
DWORD  location 
)

Definition at line 788 of file context.c.

791 {
792  struct wined3d_rendertarget_info ds_info = {{0}};
793 
794  memset(context->blit_targets, 0, sizeof(context->blit_targets));
795  if (rt)
796  {
797  context->blit_targets[0].resource = rt;
798  context->blit_targets[0].sub_resource_idx = rt_sub_resource_idx;
799  context->blit_targets[0].layer_count = 1;
800  }
801 
802  if (ds)
803  {
804  ds_info.resource = ds;
805  ds_info.sub_resource_idx = ds_sub_resource_idx;
806  ds_info.layer_count = 1;
807  }
808 
809  context_apply_fbo_state(context, target, context->blit_targets, &ds_info, location, location);
810 }
struct wined3d_resource * resource
Definition: http.c:6587
#define ds
Definition: i386-dis.c:434
static void context_apply_fbo_state(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:757
GLenum target
Definition: glext.h:7315
#define memset(x, y, z)
Definition: compat.h:39

Referenced by arbfp_blitter_blit(), context_apply_blit_state(), ffp_blitter_blit(), glsl_blitter_blit(), texture2d_blt_fbo(), texture2d_depth_blt_fbo(), and texture2d_read_from_framebuffer().

◆ context_apply_ffp_blit_state()

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

Definition at line 2899 of file context.c.

2900 {
2901  const struct wined3d_gl_info *gl_info = context->gl_info;
2902  unsigned int i, sampler;
2903 
2904  if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2905  ERR("Applying fixed-function state without legacy context support.\n");
2906 
2907  if (context->last_was_ffp_blit)
2908  {
2909  SIZE rt_size;
2910 
2911  context_get_rt_size(context, &rt_size);
2912  if (context->blit_w != rt_size.cx || context->blit_h != rt_size.cy)
2913  context_apply_blit_projection(context, rt_size.cx, rt_size.cy);
2915 
2916  checkGLcall("ffp blit state application");
2917  return;
2918  }
2919  context->last_was_ffp_blit = TRUE;
2920 
2922 
2923  /* Disable all textures. The caller can then bind a texture it wants to blit
2924  * from. */
2925  for (i = gl_info->limits.textures - 1; i > 0 ; --i)
2926  {
2927  context_active_texture(context, gl_info, i);
2928 
2929  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2930  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
2931  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
2932  if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
2933  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
2934  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
2935 
2936  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2937 
2938  sampler = context->rev_tex_unit_map[i];
2940  {
2941  if (sampler < MAX_TEXTURES)
2944  }
2945  }
2946 
2947  context_active_texture(context, gl_info, 0);
2948 
2949  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2950  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
2951  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
2952  if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
2953  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
2954  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
2955 
2956  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2957  if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
2958  gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.0f);
2959 
2960  gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
2961  gl_info->gl_ops.gl.p_glLoadIdentity();
2962 
2963  /* Setup transforms. */
2964  gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
2965  gl_info->gl_ops.gl.p_glLoadIdentity();
2969 
2970  /* Other misc states. */
2971  gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING);
2973  glDisableWINE(GL_FOG);
2975 
2976  if (gl_info->supported[EXT_SECONDARY_COLOR])
2977  {
2978  gl_info->gl_ops.gl.p_glDisable(GL_COLOR_SUM_EXT);
2980  }
2981  checkGLcall("ffp blit state application");
2982 }
#define STATE_TEXTURESTAGE(stage, num)
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2748
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:673
#define MAX_TEXTURES
#define TRUE
Definition: types.h:120
struct opengl_funcs gl_ops
#define GL_TEXTURE_LOD_BIAS_EXT
Definition: glext.h:3362
Definition: http.c:6587
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context.c:2486
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
#define STATE_TRANSFORM(a)
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#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
static void context_get_rt_size(const struct wined3d_context *context, SIZE *size)
Definition: context.c:2362
Definition: devices.h:37
#define GL_COLOR_SUM_EXT
Definition: glext.h:3178
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_TEXTURE_3D
Definition: gl.h:1515
LONG cx
Definition: windef.h:319
GLfloat f
Definition: glext.h:7540
#define GL_TEXTURE_ENV_MODE
Definition: gl.h:643
#define GL_LIGHTING
Definition: gl.h:310
#define GL_REPLACE
Definition: gl.h:460
#define GL_FOG
Definition: gl.h:414
#define WINED3D_UNMAPPED_STAGE
#define STATE_RENDER(a)
#define STATE_SAMPLER(num)
#define ERR(fmt,...)
Definition: debug.h:109
#define GL_TEXTURE_ENV
Definition: gl.h:642
static void context_apply_blit_projection(const struct wined3d_context *context, unsigned int w, unsigned int h)
Definition: context.c:2882
#define checkGLcall(A)
#define GL_MODELVIEW
Definition: gl.h:245
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_TEXTURE_FILTER_CONTROL_EXT
Definition: glext.h:3361
#define GL_TEXTURE
Definition: gl.h:247
LONG cy
Definition: windef.h:320
struct wined3d_gl_limits limits
GLuint sampler
Definition: glext.h:7283

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

◆ 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 177 of file context.c.

180 {
181  const struct wined3d_gl_info *gl_info = context->gl_info;
182 
183  if (resource->object)
184  {
185  TRACE("Attach depth stencil %u.\n", resource->object);
186 
187  if (rb_namespace)
188  {
189  context_attach_depth_stencil_rb(gl_info, fbo_target,
190  flags, resource->object);
191  }
192  else
193  {
196 
199  }
200 
203 
206  }
207  else
208  {
209  TRACE("Attach depth stencil 0.\n");
210 
213  }
214 }
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  }
168  else
169  {
170  gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment,
171  resource->target, resource->object, resource->level);
172  }
173  checkGLcall("attach texture to fbo");
174 }
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 217 of file context.c.

219 {
220  const struct wined3d_gl_info *gl_info = context->gl_info;
221 
222  TRACE("Attach GL object %u to %u.\n", resource->object, idx);
223 
224  if (resource->object)
225  {
226  if (rb_namespace)
227  {
228  gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
229  GL_RENDERBUFFER, resource->object);
230  checkGLcall("glFramebufferRenderbuffer()");
231  }
232  else
233  {
235  }
236  }
237  else
238  {
240  }
241 }
#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 2493 of file context.c.

2494 {
2495  const struct wined3d_gl_info *gl_info = context->gl_info;
2496 
2497  if (binding == GL_ELEMENT_ARRAY_BUFFER)
2499 
2500  GL_EXTCALL(glBindBuffer(binding, name));
2501 }
Definition: http.c:6587
#define STATE_INDEXBUFFER
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
#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 1750 of file context.c.

1751 {
1752  const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
1753  const struct wined3d_gl_info *gl_info = context->gl_info;
1754  unsigned int i;
1755 
1756  for (i = 0; i < gl_info->limits.combined_samplers; ++i)
1757  {
1759 
1760  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
1761  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
1762 
1763  if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
1764  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
1765 
1766  if (gl_info->supported[EXT_TEXTURE3D])
1767  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
1768 
1769  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
1770  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
1771 
1772  if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY])
1773  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
1774 
1775  if (gl_info->supported[EXT_TEXTURE_ARRAY])
1776  {
1777  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
1778  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
1779  }
1780 
1781  if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
1782  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
1783 
1784  if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
1785  {
1786  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
1787  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
1788  }
1789  }
1790 
1791  checkGLcall("bind dummy textures");
1792 }
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 3776 of file context.c.

3778 {
3779  unsigned int bind_idx, shader_sampler_count, base, count, i;
3780  const struct wined3d_device *device = context->device;
3783  const struct wined3d_shader *shader;
3784  struct wined3d_sampler *sampler;
3785  const DWORD *tex_unit_map;
3786 
3787  if (!(shader = state->shader[shader_type]))
3788  return;
3789 
3790  tex_unit_map = context_get_tex_unit_mapping(context,
3791  &shader->reg_maps.shader_version, &base, &count);
3792 
3793  shader_sampler_count = shader->reg_maps.sampler_map.count;
3794  if (shader_sampler_count > count)
3795  FIXME("Shader %p needs %u samplers, but only %u are supported.\n",
3796  shader, shader_sampler_count, count);
3797  count = min(shader_sampler_count, count);
3798 
3799  for (i = 0; i < count; ++i)
3800  {
3801  entry = &shader->reg_maps.sampler_map.entries[i];
3802  bind_idx = base + entry->bind_idx;
3803  if (tex_unit_map)
3804  bind_idx = tex_unit_map[bind_idx];
3805 
3806  if (!(view = state->shader_resource_view[shader_type][entry->resource_idx]))
3807  {
3808  WARN("No resource view bound at index %u, %u.\n", shader_type, entry->resource_idx);
3809  continue;
3810  }
3811 
3812  if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
3813  sampler = device->default_sampler;
3814  else if (!(sampler = state->sampler[shader_type][entry->sampler_idx]))
3815  sampler = device->null_sampler;
3817  }
3818 }
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:2325
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:803
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 2503 of file context.c.

2504 {
2505  const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
2506  const struct wined3d_gl_info *gl_info = context->gl_info;
2507  DWORD unit = context->active_texture;
2508  DWORD old_texture_type = context->texture_type[unit];
2509 
2510  if (name)
2511  {
2512  gl_info->gl_ops.gl.p_glBindTexture(target, name);
2513  }
2514  else
2515  {
2516  target = GL_NONE;
2517  }
2518 
2519  if (old_texture_type != target)
2520  {
2521  switch (old_texture_type)
2522  {
2523  case GL_NONE:
2524  /* nothing to do */
2525  break;
2526  case GL_TEXTURE_1D:
2527  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
2528  break;
2529  case GL_TEXTURE_1D_ARRAY:
2530  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
2531  break;
2532  case GL_TEXTURE_2D:
2533  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
2534  break;
2535  case GL_TEXTURE_2D_ARRAY:
2536  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
2537  break;
2539  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
2540  break;
2541  case GL_TEXTURE_CUBE_MAP:
2542  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
2543  break;
2545  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
2546  break;
2547  case GL_TEXTURE_3D:
2548  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
2549  break;
2550  case GL_TEXTURE_BUFFER:
2551  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
2552  break;
2554  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
2555  break;
2557  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
2558  break;
2559  default:
2560  ERR("Unexpected texture target %#x.\n", old_texture_type);
2561  }
2562 
2563  context->texture_type[unit] = target;
2564  }
2565 
2566  checkGLcall("bind texture");
2567 }
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 context_draw_shaded_quad(), context_draw_textured_quad(), create_buffer_texture(), create_texture_view(), 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 3855 of file context.c.

3857 {
3858  const struct wined3d_gl_info *gl_info = context->gl_info;
3860  GLuint texture_name;
3861  unsigned int i;
3862  GLint level;
3863 
3864  if (!shader)
3865  return;
3866 
3867  for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
3868  {
3869  if (!(view = views[i]))
3870  {
3871  if (shader->reg_maps.uav_resource_info[i].type)
3872  WARN("No unordered access view bound at index %u.\n", i);
3873  GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3874  continue;
3875  }
3876 
3877  if (view->gl_view.name)
3878  {
3879  texture_name = view->gl_view.name;
3880  level = 0;
3881  }
3882  else if (view->resource->type != WINED3D_RTYPE_BUFFER)
3883  {
3884  struct wined3d_texture *texture = texture_from_resource(view->resource);
3886  level = view->desc.u.texture.level_idx;
3887  }
3888  else
3889  {
3890  FIXME("Unsupported buffer unordered access view.\n");
3891  GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
3892  continue;
3893  }
3894 
3895  GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE,
3896  view->format->glInternal));
3897 
3898  if (view->counter_bo)
3899  GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo));
3900  }
3901  checkGLcall("Bind unordered access views");
3902 }
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 382 of file context.c.

383 {
384  const struct wined3d_gl_info *gl_info = context->gl_info;
385  GLenum status;
386 
387  if (!FIXME_ON(d3d))
388  return;
389 
390  status = gl_info->fbo_ops.glCheckFramebufferStatus(target);
392  {
393  TRACE("FBO complete.\n");
394  }
395  else
396  {
397  unsigned int i;
398 
399  FIXME("FBO status %s (%#x).\n", debug_fbostatus(status), status);
400 
401  if (!context->current_fbo)
402  {
403  ERR("FBO 0 is incomplete, driver bug?\n");
404  return;
405  }
406 
409 
410  for (i = 0; i < gl_info->limits.buffers; ++i)
412  }
413 }
#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:4715
#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:243
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(), glsl_blitter_blit(), texture2d_blt_fbo(), texture2d_depth_blt_fbo(), and texture2d_read_from_framebuffer().

◆ 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 1653 of file context.c.

1656 {
1657  unsigned int cfg_count = device->adapter->cfg_count;
1658  unsigned int current_value;
1660  int iPixelFormat = 0;
1661  unsigned int i;
1662 
1663  TRACE("device %p, dc %p, color_format %s, ds_format %s, aux_buffers %#x.\n",
1664  device, hdc, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id),
1665  auxBuffers);
1666 
1667  current_value = 0;
1668  for (i = 0; i < cfg_count; ++i)
1669  {
1670  const struct wined3d_pixel_format *cfg = &device->adapter->cfgs[i];
1671  unsigned int value;
1672 
1673  /* For now only accept RGBA formats. Perhaps some day we will
1674  * allow floating point formats for pbuffers. */
1675  if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
1676  continue;
1677  /* In window mode we need a window drawable format and double buffering. */
1678  if (!(cfg->windowDrawable && cfg->doubleBuffer))
1679  continue;
1680  if (cfg->redSize < color_format->red_size)
1681  continue;
1682  if (cfg->greenSize < color_format->green_size)
1683  continue;
1684  if (cfg->blueSize < color_format->blue_size)
1685  continue;
1686  if (cfg->alphaSize < color_format->alpha_size)
1687  continue;
1688  if (cfg->depthSize < ds_format->depth_size)
1689  continue;
1690  if (ds_format->stencil_size && cfg->stencilSize != ds_format->stencil_size)
1691  continue;
1692  /* Check multisampling support. */
1693  if (cfg->numSamples)
1694  continue;
1695 
1696  value = 1;
1697  /* We try to locate a format which matches our requirements exactly. In case of
1698  * depth it is no problem to emulate 16-bit using e.g. 24-bit, so accept that. */
1699  if (cfg->depthSize == ds_format->depth_size)
1700  value += 1;
1701  if (cfg->stencilSize == ds_format->stencil_size)
1702  value += 2;
1703  if (cfg->alphaSize == color_format->alpha_size)
1704  value += 4;
1705  /* We like to have aux buffers in backbuffer mode */
1706  if (auxBuffers && cfg->auxBuffers)
1707  value += 8;
1708  if (cfg->redSize == color_format->red_size
1709  && cfg->greenSize == color_format->green_size
1710  && cfg->blueSize == color_format->blue_size)
1711  value += 16;
1712 
1713  if (value > current_value)
1714  {
1715  iPixelFormat = cfg->iPixelFormat;
1716  current_value = value;
1717  }
1718  }
1719 
1720  if (!iPixelFormat)
1721  {
1722  ERR("Trying to locate a compatible pixel format because an exact match failed.\n");
1723 
1724  memset(&pfd, 0, sizeof(pfd));
1725  pfd.nSize = sizeof(pfd);
1726  pfd.nVersion = 1;
1727  pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/
1729  pfd.cAlphaBits = color_format->alpha_size;
1730  pfd.cColorBits = color_format->red_size + color_format->green_size
1731  + color_format->blue_size + color_format->alpha_size;
1732  pfd.cDepthBits = ds_format->depth_size;
1733  pfd.cStencilBits = ds_format->stencil_size;
1735 
1736  if (!(iPixelFormat = ChoosePixelFormat(hdc, &pfd)))
1737  {
1738  /* Something is very wrong as ChoosePixelFormat() barely fails. */
1739  ERR("Can't find a suitable pixel format.\n");
1740  return 0;
1741  }
1742  }
1743 
1744  TRACE("Found iPixelFormat=%d for ColorFormat=%s, DepthStencilFormat=%s.\n",
1745  iPixelFormat, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id));
1746  return iPixelFormat;
1747 }
#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:3922

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 2613 of file context.c.

2616 {
2617  const struct wined3d_gl_info *gl_info;
2618  BYTE *dst_ptr, *src_ptr;
2619 
2620  gl_info = context->gl_info;
2621 
2622  if (dst->buffer_object && src->buffer_object)
2623  {
2624  if (gl_info->supported[ARB_COPY_BUFFER])
2625  {
2626  GL_EXTCALL(glBindBuffer(GL_COPY_READ_BUFFER, src->buffer_object));
2627  GL_EXTCALL(glBindBuffer(GL_COPY_WRITE_BUFFER, dst->buffer_object));
2629  (GLintptr)src->addr, (GLintptr)dst->addr, size));
2630  checkGLcall("direct buffer copy");
2631  }
2632  else
2633  {
2634  src_ptr = context_map_bo_address(context, src, size, src_binding, WINED3D_MAP_READ);
2635  dst_ptr = context_map_bo_address(context, dst, size, dst_binding, WINED3D_MAP_WRITE);
2636 
2637  memcpy(dst_ptr, src_ptr, size);
2638 
2639  context_unmap_bo_address(context, dst, dst_binding);
2640  context_unmap_bo_address(context, src, src_binding);
2641  }
2642  }
2643  else if (!dst->buffer_object && src->buffer_object)
2644  {
2645  context_bind_bo(context, src_binding, src->buffer_object);
2646  GL_EXTCALL(glGetBufferSubData(src_binding, (GLintptr)src->addr, size, dst->addr));
2647  checkGLcall("buffer download");
2648  }
2649  else if (dst->buffer_object && !src->buffer_object)
2650  {
2651  context_bind_bo(context, dst_binding, dst->buffer_object);
2652  GL_EXTCALL(glBufferSubData(dst_binding, (GLintptr)dst->addr, size, src->addr));
2653  checkGLcall("buffer upload");
2654  }
2655  else
2656  {
2657  memcpy(dst->addr, src->addr, size);
2658  }
2659 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2598
Definition: http.c:6587
ptrdiff_t GLintptr
Definition: glext.h:5498
BOOL supported[WINED3D_GL_EXT_COUNT]
#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:948
#define WINED3D_MAP_WRITE
Definition: wined3d.h:947
#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:2569
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name)
Definition: context.c:2493

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 1887 of file context.c.

1889 {
1890  struct wined3d_device *device = swapchain->device;
1891  const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
1892  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1893  const struct wined3d_format *color_format;
1894  struct wined3d_context *ret;
1895  BOOL auxBuffers = FALSE;
1896  HGLRC ctx, share_ctx;
1897  DWORD target_usage;
1898  unsigned int i;
1899  DWORD state;
1900 
1901  TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
1902 
1903  wined3d_from_cs(device->cs);
1904 
1905  if (!(ret = heap_alloc_zero(sizeof(*ret))))
1906  return NULL;
1907 
1908  ret->free_timestamp_query_size = 4;
1909  if (!(ret->free_timestamp_queries = heap_calloc(ret->free_timestamp_query_size,
1910  sizeof(*ret->free_timestamp_queries))))
1911  goto out;
1912  list_init(&ret->timestamp_queries);
1913 
1914  ret->free_occlusion_query_size = 4;
1915  if (!(ret->free_occlusion_queries = heap_calloc(ret->free_occlusion_query_size,
1916  sizeof(*ret->free_occlusion_queries))))
1917  goto out;
1918  list_init(&ret->occlusion_queries);
1919 
1920  ret->free_fence_size = 4;
1921  if (!(ret->free_fences = heap_calloc(ret->free_fence_size, sizeof(*ret->free_fences))))
1922  goto out;
1923  list_init(&ret->fences);
1924 
1925  list_init(&ret->so_statistics_queries);
1926 
1927  list_init(&ret->pipeline_statistics_queries);
1928 
1929  list_init(&ret->fbo_list);
1930  list_init(&ret->fbo_destroy_list);
1931 
1932  if (!device->shader_backend->shader_allocate_context_data(ret))
1933  {
1934  ERR("Failed to allocate shader backend context data.\n");
1935  goto out;
1936  }
1937  if (!device->adapter->fragment_pipe->allocate_context_data(ret))
1938  {
1939  ERR("Failed to allocate fragment pipeline context data.\n");
1940  goto out;
1941  }
1942 
1943  for (i = 0; i < ARRAY_SIZE(ret->tex_unit_map); ++i)
1944  ret->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
1945  for (i = 0; i < ARRAY_SIZE(ret->rev_tex_unit_map); ++i)
1946  ret->rev_tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
1947  if (gl_info->limits.graphics_samplers >= MAX_COMBINED_SAMPLERS)
1948  {
1949  /* Initialize the texture unit mapping to a 1:1 mapping. */
1950  unsigned int base, count;
1951 
1953  if (base + MAX_FRAGMENT_SAMPLERS > ARRAY_SIZE(ret->rev_tex_unit_map))
1954  {
1955  ERR("Unexpected texture unit base index %u.\n", base);
1956  goto out;
1957  }
1958  for (i = 0; i < min(count, MAX_FRAGMENT_SAMPLERS); ++i)
1959  {
1960  ret->tex_unit_map[i] = base + i;
1961  ret->rev_tex_unit_map[base + i] = i;
1962  }
1963 
1965  if (base + MAX_VERTEX_SAMPLERS > ARRAY_SIZE(ret->rev_tex_unit_map))
1966  {
1967  ERR("Unexpected texture unit base index %u.\n", base);
1968  goto out;
1969  }
1970  for (i = 0; i < min(count, MAX_VERTEX_SAMPLERS); ++i)
1971  {
1972  ret->tex_unit_map[MAX_FRAGMENT_SAMPLERS + i] = base + i;
1973  ret->rev_tex_unit_map[base + i] = MAX_FRAGMENT_SAMPLERS + i;
1974  }
1975  }
1976 
1977  if (!(ret->texture_type = heap_calloc(gl_info->limits.combined_samplers,
1978  sizeof(*ret->texture_type))))
1979  goto out;
1980 
1981  if (!(ret->hdc = GetDCEx(swapchain->win_handle, 0, DCX_USESTYLE | DCX_CACHE)))
1982  {
1983  WARN("Failed to retrieve device context, trying swapchain backup.\n");
1984 
1985  if ((ret->hdc = swapchain_get_backup_dc(swapchain)))
1986  ret->hdc_is_private = TRUE;
1987  else
1988  {
1989  ERR("Failed to retrieve a device context.\n");
1990  goto out;
1991  }
1992  }
1993 
1994  color_format = target->resource.format;
1995  target_usage = target->resource.usage;
1996 
1997  /* In case of ORM_BACKBUFFER, make sure to request an alpha component for
1998  * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
2000  {
2001  auxBuffers = TRUE;
2002 
2003  if (color_format->id == WINED3DFMT_B4G4R4X4_UNORM)
2004  color_format = wined3d_get_format(gl_info, WINED3DFMT_B4G4R4A4_UNORM, target_usage);
2005  else if (color_format->id == WINED3DFMT_B8G8R8X8_UNORM)
2006  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2007  }
2008 
2009  /* DirectDraw supports 8bit paletted render targets and these are used by
2010  * old games like StarCraft and C&C. Most modern hardware doesn't support
2011  * 8bit natively so we perform some form of 8bit -> 32bit conversion. The
2012  * conversion (ab)uses the alpha component for storing the palette index.
2013  * For this reason we require a format with 8bit alpha, so request
2014  * A8R8G8B8. */
2015  if (color_format->id == WINED3DFMT_P8_UINT)
2016  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2017 
2018  /* When using FBOs for off-screen rendering, we only use the drawable for
2019  * presentation blits, and don't do any rendering to it. That means we
2020  * don't need depth or stencil buffers, and can mostly ignore the render
2021  * target format. This wouldn't necessarily be quite correct for 10bpc
2022  * display modes, but we don't currently support those.
2023  * Using the same format regardless of the color/depth/stencil targets
2024  * makes it much less likely that different wined3d instances will set
2025  * conflicting pixel formats. */
2027  {
2028  color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
2030  }
2031 
2032  /* Try to find a pixel format which matches our requirements. */
2033  if (!(ret->pixel_format = context_choose_pixel_format(device, ret->hdc, color_format, ds_format, auxBuffers)))
2034  goto out;
2035 
2036  ret->gl_info = gl_info;
2037  ret->win_handle = swapchain->win_handle;
2038 
2039  context_enter(ret);
2040 
2042  {
2043  ERR("Failed to set pixel format %d on device context %p.\n", ret->pixel_format, ret->hdc);
2045  goto out;
2046  }
2047 
2048  share_ctx = device->context_count ? device->contexts[0]->glCtx : NULL;
2049  if (gl_info->p_wglCreateContextAttribsARB)
2050  {
2051  if (!(ctx = context_create_wgl_attribs(gl_info, ret->hdc, share_ctx)))
2052  goto out;
2053  }
2054  else
2055  {
2056  if (!(ctx = wglCreateContext(ret->hdc)))
2057  {
2058  ERR("Failed to create a WGL context.\n");
2060  goto out;
2061  }
2062 
2063  if (share_ctx && !wglShareLists(share_ctx, ctx))
2064  {
2065  ERR("wglShareLists(%p, %p) failed, last error %#x.\n", share_ctx, ctx, GetLastError());
2067  if (!wglDeleteContext(ctx))
2068  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2069  goto out;
2070  }
2071  }
2072 
2073  if (!device_context_add(device, ret))
2074  {
2075  ERR("Failed to add the newly created context to the context list\n");
2077  if (!wglDeleteContext(ctx))
2078  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2079  goto out;
2080  }
2081 
2082  ret->d3d_info = d3d_info;
2083  ret->state_table = device->StateTable;
2084 
2085  /* Mark all states dirty to force a proper initialization of the states on
2086  * the first use of the context. Compute states do not need initialization. */
2087  for (state = 0; state <= STATE_HIGHEST; ++state)
2088  {
2089  if (ret->state_table[state].representative && !STATE_IS_COMPUTE(state))
2091  }
2092 
2093  ret->device = device;
2094  ret->swapchain = swapchain;
2095  ret->current_rt.texture = target;
2096  ret->current_rt.sub_resource_idx = 0;
2097  ret->tid = GetCurrentThreadId();
2098 
2099  ret->render_offscreen = wined3d_resource_is_offscreen(&target->resource);
2100  ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
2101  ret->valid = 1;
2102 
2103  ret->glCtx = ctx;
2104  ret->hdc_has_format = TRUE;
2105  ret->needs_set = 1;
2106 
2107  /* Set up the context defaults */
2108  if (!context_set_current(ret))
2109  {
2110  ERR("Cannot activate context to set up defaults.\n");
2113  if (!wglDeleteContext(ctx))
2114  ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, GetLastError());
2115  goto out;
2116  }
2117 
2119  {
2120  GL_EXTCALL(glDebugMessageCallback(wined3d_debug_callback, ret));
2121  if (TRACE_ON(d3d_synchronous))
2122  gl_info->gl_ops.gl.p_glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
2123  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_FALSE));
2124  if (ERR_ON(d3d))
2125  {
2126  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_ERROR,
2127  GL_DONT_CARE, 0, NULL, GL_TRUE));
2128  }
2129  if (FIXME_ON(d3d))
2130  {
2132  GL_DONT_CARE, 0, NULL, GL_TRUE));
2134  GL_DONT_CARE, 0, NULL, GL_TRUE));
2135  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PORTABILITY,
2136  GL_DONT_CARE, 0, NULL, GL_TRUE));
2137  }
2138  if (WARN_ON(d3d_perf))
2139  {
2140  GL_EXTCALL(glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE,
2141  GL_DONT_CARE, 0, NULL, GL_TRUE));
2142  }
2143  }
2144 
2145  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2146  gl_info->gl_ops.gl.p_glGetIntegerv(GL_AUX_BUFFERS, &ret->aux_buffers);
2147 
2148  TRACE("Setting up the screen\n");
2149 
2150  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2151  {
2152  gl_info->gl_ops.gl.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
2153  checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
2154 
2155  gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2156  checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
2157 
2159  checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
2160  }
2161  else
2162  {
2163  GLuint vao;
2164 
2165  GL_EXTCALL(glGenVertexArrays(1, &vao));
2166  GL_EXTCALL(glBindVertexArray(vao));
2167  checkGLcall("creating VAO");
2168  }
2169 
2170  gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);
2171  checkGLcall("glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);");
2172  gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2173  checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, 1);");
2174 
2175  if (gl_info->supported[NV_TEXTURE_SHADER2])
2176  {
2177  /* Set up the previous texture input for all shader units. This applies to bump mapping, and in d3d
2178  * the previous texture where to source the offset from is always unit - 1.
2179  */
2180  for (i = 1; i < gl_info->limits.textures; ++i)
2181  {
2183  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV,
2185  checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...");
2186  }
2187  }
2188  if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2189  {
2190  /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are
2191  * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but
2192  * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline,
2193  * because the ARBFP extension is enabled by the ARBFP pipeline at context creation, but no program
2194  * is ever assigned.
2195  *
2196  * So make sure a program is assigned to each context. The first real ARBFP use will set a different
2197  * program and the dummy program is destroyed when the context is destroyed.
2198  */
2199  static const char dummy_program[] =
2200  "!!ARBfp1.0\n"
2201  "MOV result.color, fragment.color.primary;\n"
2202  "END\n";
2203  GL_EXTCALL(glGenProgramsARB(1, &ret->dummy_arbfp_prog));
2204  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret->dummy_arbfp_prog));
2205  GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program));
2206  }
2207 
2208  if (gl_info->supported[ARB_POINT_SPRITE])
2209  {
2210  for (i = 0; i < gl_info->limits.textures; ++i)
2211  {
2213  gl_info->gl_ops.gl.p_glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
2214  checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
2215  }
2216  }
2217 
2218  if (gl_info->supported[ARB_PROVOKING_VERTEX])
2219  {
2220  GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
2221  }
2222  else if (gl_info->supported[EXT_PROVOKING_VERTEX])
2223  {
2224  GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT));
2225  }
2226  if (!(d3d_info->wined3d_creation_flags & WINED3D_NO_PRIMITIVE_RESTART))
2227  {
2228  if (gl_info->supported[ARB_ES3_COMPATIBILITY])
2229  {
2230  gl_info->gl_ops.gl.p_glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
2231  checkGLcall("enable GL_PRIMITIVE_RESTART_FIXED_INDEX");
2232  }
2233  else
2234  {
2235  FIXME("OpenGL implementation does not support GL_PRIMITIVE_RESTART_FIXED_INDEX.\n");
2236  }
2237  }
2238  if (!(d3d_info->wined3d_creation_flags & WINED3D_LEGACY_CUBEMAP_FILTERING)
2239  && gl_info->supported[ARB_SEAMLESS_CUBE_MAP])
2240  {
2241  gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
2242  checkGLcall("enable seamless cube map filtering");
2243  }
2244  if (gl_info->supported[ARB_CLIP_CONTROL])
2246  device->shader_backend->shader_init_context_state(ret);
2247  ret->shader_update_mask = (1u << WINED3D_SHADER_TYPE_PIXEL)
2250  | (1u << WINED3D_SHADER_TYPE_HULL)
2253 
2254  /* If this happens to be the first context for the device, dummy textures
2255  * are not created yet. In that case, they will be created (and bound) by
2256  * create_dummy_textures right after this context is initialized. */
2257  if (device->dummy_textures.tex_2d)
2259 
2260  /* Initialise all rectangles to avoid resetting unused ones later. */
2261  gl_info->gl_ops.gl.p_glScissor(0, 0, 0, 0);
2262  checkGLcall("glScissor");
2263 
2264  TRACE("Created context %p.\n", ret);
2265 
2266  return ret;
2267 
2268 out:
2269  if (ret->hdc)
2270  wined3d_release_dc(swapchain->win_handle, ret->hdc);
2271  device->shader_backend->shader_free_context_data(ret);
2272  device->adapter->fragment_pipe->free_context_data(ret);
2273  heap_free(ret->texture_type);
2274  heap_free(ret->free_fences);
2275  heap_free(ret->free_occlusion_queries);
2276  heap_free(ret->free_timestamp_queries);
2277  heap_free(ret);
2278  return NULL;
2279 }
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:1819
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
#define GL_BACK
Definition: gl.h:271
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:1146
#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:6408
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx)
Definition: context.c:1844
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:2486
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:1813
#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:3773
#define DCX_USESTYLE
Definition: GetDCEx.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define WINED3DUSAGE_DEPTHSTENCIL
Definition: wined3d.h:909
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
#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:1750
#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:1559
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define GL_COMBINE_EXT
Definition: glext.h:3229
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6354
#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:1329
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:540
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:1087
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:1653
#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:2075