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

Go to the source code of this file.

Macros

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

Typedefs

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

Functions

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

Variables

static DWORD wined3d_context_tls_idx
 

Macro Definition Documentation

◆ SI_FORMAT

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

◆ SI_PTR

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

◆ WINED3D_ALL_LAYERS

#define WINED3D_ALL_LAYERS   (~0u)

Definition at line 46 of file context.c.

◆ WINED3D_MAX_FBO_ENTRIES

#define WINED3D_MAX_FBO_ENTRIES   64

Definition at line 45 of file context.c.

Typedef Documentation

◆ context_fbo_entry_func_t

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

Definition at line 1039 of file context.c.

Function Documentation

◆ context_acquire()

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

Definition at line 4242 of file context.c.

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

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

◆ context_activate()

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

Definition at line 4222 of file context.c.

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

Referenced by context_acquire(), and context_reacquire().

◆ context_active_texture()

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

Definition at line 2717 of file context.c.

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

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

◆ context_alloc_fence()

void context_alloc_fence ( struct wined3d_context context,
struct wined3d_fence fence 
)

Definition at line 863 of file context.c.

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

Referenced by wined3d_fence_issue().

◆ context_alloc_occlusion_query()

void context_alloc_occlusion_query ( struct wined3d_context context,
struct wined3d_occlusion_query query 
)

Definition at line 816 of file context.c.

817{
818 const struct wined3d_gl_info *gl_info = context->gl_info;
819
820 if (context->free_occlusion_query_count)
821 {
822 query->id = context->free_occlusion_queries[--context->free_occlusion_query_count];
823 }
824 else
825 {
826 if (gl_info->supported[ARB_OCCLUSION_QUERY])
827 {
828 GL_EXTCALL(glGenQueries(1, &query->id));
829 checkGLcall("glGenQueries");
830
831 TRACE("Allocated occlusion query %u in context %p.\n", query->id, context);
832 }
833 else
834 {
835 WARN("Occlusion queries not supported, not allocating query id.\n");
836 query->id = 0;
837 }
838 }
839
840 query->context = context;
841 list_add_head(&context->occlusion_queries, &query->entry);
842}
@ ARB_OCCLUSION_QUERY
Definition: wined3d_gl.h:86

Referenced by wined3d_occlusion_query_ops_issue().

◆ context_alloc_pipeline_statistics_query()

void context_alloc_pipeline_statistics_query ( struct wined3d_context context,
struct wined3d_pipeline_statistics_query query 
)

Definition at line 1002 of file context.c.

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

Referenced by wined3d_pipeline_query_ops_issue().

◆ context_alloc_so_statistics_query()

void context_alloc_so_statistics_query ( struct wined3d_context context,
struct wined3d_so_statistics_query query 
)

Definition at line 961 of file context.c.

963{
964 const struct wined3d_gl_info *gl_info = context->gl_info;
965
966 if (context->free_so_statistics_query_count)
967 {
968 query->u = context->free_so_statistics_queries[--context->free_so_statistics_query_count];
969 }
970 else
971 {
972 GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
973 checkGLcall("glGenQueries");
974
975 TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
976 query->u.id[0], query->u.id[1], context);
977 }
978
979 query->context = context;
980 list_add_head(&context->so_statistics_queries, &query->entry);
981}

Referenced by wined3d_so_statistics_query_ops_issue().

◆ context_alloc_timestamp_query()

void context_alloc_timestamp_query ( struct wined3d_context context,
struct wined3d_timestamp_query query 
)

Definition at line 923 of file context.c.

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

Referenced by wined3d_timestamp_query_ops_issue().

◆ context_apply_blit_state()

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

Definition at line 2981 of file context.c.

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

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

◆ context_apply_clear_state()

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

Definition at line 3047 of file context.c.

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

Referenced by device_clear_render_targets().

◆ context_apply_compute_state()

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

Definition at line 4060 of file context.c.

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

Referenced by dispatch_compute().

◆ context_apply_draw_buffers()

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

Definition at line 2652 of file context.c.

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

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

◆ context_apply_draw_state()

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

Definition at line 3947 of file context.c.

3949{
3950 const struct StateEntry *state_table = context->state_table;
3951 const struct wined3d_gl_info *gl_info = context->gl_info;
3952 const struct wined3d_fb_state *fb = state->fb;
3953 unsigned int i;
3954 WORD map;
3955
3956 if (!have_framebuffer_attachment(gl_info->limits.buffers, fb->render_targets, fb->depth_stencil))
3957 {
3959 {
3960 FIXME("OpenGL implementation does not support framebuffers with no attachments.\n");
3961 return FALSE;
3962 }
3963
3965 }
3966
3968 {
3970 }
3971
3972 /* Preload resources before FBO setup. Texture preload in particular may
3973 * result in changes to the current FBO, due to using e.g. FBO blits for
3974 * updating a resource location. */
3979 state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
3981 /* TODO: Right now the dependency on the vertex shader is necessary
3982 * since wined3d_stream_info_from_declaration() depends on the reg_maps of
3983 * the current VS but maybe it's possible to relax the coupling in some
3984 * situations at least. */
3987 {
3989 }
3990 else
3991 {
3992 for (i = 0, map = context->stream_info.use_map; map; map >>= 1, ++i)
3993 {
3994 if (map & 1)
3995 wined3d_buffer_load(state->streams[context->stream_info.elements[i].stream_idx].buffer,
3996 context, state);
3997 }
3998 /* Loading the buffers above may have invalidated the stream info. */
4001 }
4002 if (state->index_buffer)
4003 {
4004 if (context->stream_info.all_vbo)
4005 wined3d_buffer_load(state->index_buffer, context, state);
4006 else
4008 }
4009
4010 for (i = 0; i < context->numDirtyEntries; ++i)
4011 {
4012 DWORD rep = context->dirtyArray[i];
4013 DWORD idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
4014 BYTE shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
4015 context->isStateDirty[idx] &= ~(1u << shift);
4016 state_table[rep].apply(context, state, rep);
4017 }
4018
4019 if (context->shader_update_mask & ~(1u << WINED3D_SHADER_TYPE_COMPUTE))
4020 {
4021 device->shader_backend->shader_select(device->shader_priv, context, state);
4022 context->shader_update_mask &= 1u << WINED3D_SHADER_TYPE_COMPUTE;
4023 }
4024
4025 if (context->constant_update_mask)
4026 {
4027 device->shader_backend->shader_load_constants(device->shader_priv, context, state);
4028 context->constant_update_mask = 0;
4029 }
4030
4031 if (context->update_shader_resource_bindings)
4032 {
4033 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
4035 context->update_shader_resource_bindings = 0;
4036 if (gl_info->limits.combined_samplers == gl_info->limits.graphics_samplers)
4037 context->update_compute_shader_resource_bindings = 1;
4038 }
4039
4040 if (context->update_unordered_access_view_bindings)
4041 {
4044 state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
4045 context->update_unordered_access_view_bindings = 0;
4046 context->update_compute_unordered_access_view_bindings = 1;
4047 }
4048
4050 {
4052 }
4053
4054 context->numDirtyEntries = 0; /* This makes the whole list clean */
4055 context->last_was_blit = FALSE;
4056
4057 return TRUE;
4058}
#define FIXME(fmt,...)
Definition: debug.h:111
Definition: _map.h:48
BYTE * wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:706
void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state)
Definition: buffer.c:887
static void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3732
static void context_update_tex_unit_map(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3452
static void context_set_render_offscreen(struct wined3d_context *context, BOOL offscreen)
Definition: context.c:2894
static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3632
static void context_load_stream_output_buffers(struct wined3d_context *context, const struct wined3d_state *state)
Definition: context.c:3930
unsigned int idx
Definition: utils.c:41
unsigned short WORD
Definition: ntddk_ex.h:93
#define shift
Definition: input.c:1755
@ ARB_FRAMEBUFFER_NO_ATTACHMENTS
Definition: wined3d_gl.h:72
#define STATE_SHADER(a)
@ WINED3D_PIPELINE_GRAPHICS
#define STATE_STREAMSRC
@ WINED3D_SHADER_TYPE_PIXEL
@ WINED3D_SHADER_TYPE_GRAPHICS_COUNT
@ WINED3D_SHADER_TYPE_VERTEX
#define STATE_VDECL
unsigned char BYTE
Definition: xxhash.c:193

Referenced by draw_primitive().

◆ context_apply_fbo_entry()

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

Definition at line 711 of file context.c.

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

Referenced by context_apply_fbo_state().

◆ context_apply_fbo_state()

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

Definition at line 763 of file context.c.

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

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

◆ context_apply_fbo_state_blit()

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

Definition at line 802 of file context.c.

804{
805 memset(context->blit_targets, 0, sizeof(context->blit_targets));
806 if (render_target)
807 {
808 context->blit_targets[0].resource = &render_target->container->resource;
809 context->blit_targets[0].sub_resource_idx = surface_get_sub_resource_idx(render_target);
810 context->blit_targets[0].layer_count = 1;
811 }
812 context_apply_fbo_state(context, target, context->blit_targets, depth_stencil, location, location);
813}

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

◆ context_attach_depth_stencil_fbo()

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

Definition at line 178 of file context.c.

181{
182 const struct wined3d_gl_info *gl_info = context->gl_info;
183
184 if (resource->object)
185 {
186 TRACE("Attach depth stencil %u.\n", resource->object);
187
188 if (rb_namespace)
189 {
190 context_attach_depth_stencil_rb(gl_info, fbo_target,
191 flags, resource->object);
192 }
193 else
194 {
197
200 }
201
204
207 }
208 else
209 {
210 TRACE("Attach depth stencil 0.\n");
211
214 }
215}
static void context_attach_depth_stencil_rb(const struct wined3d_gl_info *gl_info, GLenum fbo_target, DWORD flags, GLuint rb)
Definition: context.c:115
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
GLbitfield flags
Definition: glext.h:7161
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define WINED3D_FBO_ENTRY_FLAG_STENCIL
#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
struct wined3d_fbo_ops fbo_ops

Referenced by context_attach_depth_stencil_fbo().

◆ context_attach_gl_texture_fbo()

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

Definition at line 131 of file context.c.

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

Referenced by context_attach_depth_stencil_fbo(), and context_attach_surface_fbo().

◆ context_attach_surface_fbo()

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

Definition at line 218 of file context.c.

220{
221 const struct wined3d_gl_info *gl_info = context->gl_info;
222
223 TRACE("Attach GL object %u to %u.\n", resource->object, idx);
224
225 if (resource->object)
226 {
227 if (rb_namespace)
228 {
229 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
230 GL_RENDERBUFFER, resource->object);
231 checkGLcall("glFramebufferRenderbuffer()");
232 }
233 else
234 {
236 }
237 }
238 else
239 {
241 }
242}

Referenced by context_apply_fbo_entry().

◆ context_bind_bo()

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

Definition at line 2724 of file context.c.

2725{
2726 const struct wined3d_gl_info *gl_info = context->gl_info;
2727
2728 if (binding == GL_ELEMENT_ARRAY_BUFFER)
2730
2731 GL_EXTCALL(glBindBuffer(binding, name));
2732}
#define GL_ELEMENT_ARRAY_BUFFER
Definition: glext.h:337
Definition: name.c:39
#define STATE_INDEXBUFFER

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

◆ context_bind_dummy_textures()

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

Definition at line 1764 of file context.c.

1765{
1766 const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
1767 const struct wined3d_gl_info *gl_info = context->gl_info;
1768 unsigned int i;
1769
1770 for (i = 0; i < gl_info->limits.combined_samplers; ++i)
1771 {
1773
1774 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
1775 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
1776
1777 if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
1778 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
1779
1780 if (gl_info->supported[EXT_TEXTURE3D])
1781 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
1782
1783 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
1784 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
1785
1787 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
1788
1789 if (gl_info->supported[EXT_TEXTURE_ARRAY])
1790 {
1791 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
1792 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
1793 }
1795 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
1796
1797 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
1798 {
1799 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
1800 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
1801 }
1802 }
1803
1804 checkGLcall("bind dummy textures");
1805}
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
const GLuint * textures
Definition: glext.h:8098
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
@ ARB_TEXTURE_BUFFER_OBJECT
Definition: wined3d_gl.h:108
@ ARB_TEXTURE_CUBE_MAP
Definition: wined3d_gl.h:113
@ EXT_TEXTURE3D
Definition: wined3d_gl.h:171
@ ARB_TEXTURE_MULTISAMPLE
Definition: wined3d_gl.h:122
@ ARB_TEXTURE_RECTANGLE
Definition: wined3d_gl.h:125
@ EXT_TEXTURE_ARRAY
Definition: wined3d_gl.h:172
@ ARB_TEXTURE_CUBE_MAP_ARRAY
Definition: wined3d_gl.h:114

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}

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

◆ context_bind_shader_resources()

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

Definition at line 3802 of file context.c.

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

Referenced by context_apply_compute_state(), and context_apply_draw_state().

◆ context_bind_texture()

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

Definition at line 2734 of file context.c.

2735{
2736 const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
2737 const struct wined3d_gl_info *gl_info = context->gl_info;
2738 DWORD unit = context->active_texture;
2739 DWORD old_texture_type = context->texture_type[unit];
2740
2741 if (name)
2742 {
2743 gl_info->gl_ops.gl.p_glBindTexture(target, name);
2744 }
2745 else
2746 {
2747 target = GL_NONE;
2748 }
2749
2750 if (old_texture_type != target)
2751 {
2752 switch (old_texture_type)
2753 {
2754 case GL_NONE:
2755 /* nothing to do */
2756 break;
2757 case GL_TEXTURE_1D:
2758 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
2759 checkGLcall("glBindTexture");
2760 break;
2762 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
2763 checkGLcall("glBindTexture");
2764 break;
2765 case GL_TEXTURE_2D:
2766 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
2767 break;
2769 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
2770 break;
2772 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures->tex_rect);
2773 break;
2775 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
2776 break;
2778 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
2779 break;
2780 case GL_TEXTURE_3D:
2781 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
2782 break;
2783 case GL_TEXTURE_BUFFER:
2784 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
2785 break;
2787 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
2788 break;
2790 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
2791 break;
2792 default:
2793 ERR("Unexpected texture target %#x.\n", old_texture_type);
2794 }
2795
2796 context->texture_type[unit] = target;
2797 }
2798
2799 checkGLcall("bind texture");
2800}

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

◆ context_bind_unordered_access_views()

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

Definition at line 3881 of file context.c.

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

Referenced by context_apply_compute_state(), and context_apply_draw_state().

◆ context_check_fbo_status()

void context_check_fbo_status ( const struct wined3d_context context,
GLenum  target 
)

Definition at line 381 of file context.c.

382{
383 const struct wined3d_gl_info *gl_info = context->gl_info;
385
386 if (!FIXME_ON(d3d))
387 return;
388
389 status = gl_info->fbo_ops.glCheckFramebufferStatus(target);
391 {
392 TRACE("FBO complete.\n");
393 }
394 else
395 {
396 unsigned int i;
397
398 FIXME("FBO status %s (%#x).\n", debug_fbostatus(status), status);
399
400 if (!context->current_fbo)
401 {
402 ERR("FBO 0 is incomplete, driver bug?\n");
403 return;
404 }
405
408
409 for (i = 0; i < gl_info->limits.buffers; ++i)
411 }
412}
static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, GLenum target, GLenum attachment)
Definition: context.c:244
const char * debug_fbostatus(GLenum status)
Definition: utils.c:4774
#define GL_FRAMEBUFFER_COMPLETE
Definition: glext.h:1707
#define FIXME_ON(ch)
Definition: debug.h:407
Definition: ps.c:97

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

◆ context_choose_pixel_format()

static int context_choose_pixel_format ( const struct wined3d_device device,
HDC  hdc,
const struct wined3d_format color_format,
const struct wined3d_format ds_format,
BOOL  auxBuffers 
)
static

Definition at line 1667 of file context.c.

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

Referenced by 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}

Referenced by context_destroy_fbo(), and context_reuse_fbo_entry().

◆ context_copy_bo_address()

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

Definition at line 2846 of file context.c.

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

Referenced by wined3d_buffer_copy(), and wined3d_unordered_access_view_copy_counter().

◆ context_create()

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

Definition at line 1891 of file context.c.

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

Referenced by swapchain_create_context(), and wined3d_swapchain_cs_init().

◆ context_create_fbo_entry()

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

Definition at line 521 of file context.c.

524{
525 const struct wined3d_gl_info *gl_info = context->gl_info;
526 struct fbo_entry *entry;
527
528 entry = heap_alloc(sizeof(*entry));
529 context_generate_fbo_key(context, &entry->key, render_targets, depth_stencil, color_location, ds_location);
530 entry->flags = 0;
531 if (depth_stencil->resource)
532 {
533 if (depth_stencil->resource->format_flags & WINED3DFMT_FLAG_DEPTH)
535 if (depth_stencil->resource->format_flags & WINED3DFMT_FLAG_STENCIL)
537 }
539 gl_info->fbo_ops.glGenFramebuffers(1, &entry->id);
540 checkGLcall("glGenFramebuffers()");
541 TRACE("Created FBO %u.\n", entry->id);
542
543 return entry;
544}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void context_generate_fbo_key(const struct wined3d_context *context, struct wined3d_fbo_entry_key *key, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context.c:505
struct wined3d_resource * resource
#define WINED3DFMT_FLAG_STENCIL
#define WINED3DFMT_FLAG_DEPTH

Referenced by context_find_fbo_entry().

◆ context_create_wgl_attribs()

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

Definition at line 1857 of file context.c.

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

Referenced by context_create(), and wined3d_caps_gl_ctx_create_attribs().

◆ context_debug_output_enabled()

static BOOL context_debug_output_enabled ( const struct wined3d_gl_info gl_info)
static

Definition at line 1826 of file context.c.

1827{
1828 return gl_info->supported[ARB_DEBUG_OUTPUT]
1829 && (ERR_ON(d3d) || FIXME_ON(d3d) || WARN_ON(d3d_perf));
1830}
@ ARB_DEBUG_OUTPUT
Definition: wined3d_gl.h:56

Referenced by context_create(), and context_create_wgl_attribs().

◆ context_destroy()

void context_destroy ( struct wined3d_device device,
struct wined3d_context context 
)

Definition at line 2290 of file context.c.

2291{
2292 BOOL destroy;
2293
2294 TRACE("Destroying ctx %p\n", context);
2295
2297
2298 /* We delay destroying a context when it is active. The context_release()
2299 * function invokes context_destroy() again while leaving the last level. */
2300 if (context->level)
2301 {
2302 TRACE("Delaying destruction of context %p.\n", context);
2303 context->destroy_delayed = 1;
2304 /* FIXME: Get rid of a pointer to swapchain from wined3d_context. */
2305 context->swapchain = NULL;
2306 return;
2307 }
2308
2309 if (context->tid == GetCurrentThreadId() || !context->current)
2310 {
2313 destroy = TRUE;
2314 }
2315 else
2316 {
2317 /* Make a copy of gl_info for context_destroy_gl_resources use, the one
2318 in wined3d_adapter may go away in the meantime */
2319 struct wined3d_gl_info *gl_info = heap_alloc(sizeof(*gl_info));
2320 *gl_info = *context->gl_info;
2321 context->gl_info = gl_info;
2322 context->destroyed = 1;
2323 destroy = FALSE;
2324 }
2325
2326 device->shader_backend->shader_free_context_data(context);
2327 device->adapter->fragment_pipe->free_context_data(context);
2328 heap_free(context->texture_type);
2330 if (destroy)
2332}
void destroy(_Tp *__pointer)
Definition: _construct.h:278
static DWORD wined3d_context_tls_idx
Definition: context.c:48
static void context_destroy_gl_resources(struct wined3d_context *context)
Definition: context.c:1332
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276

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

◆ context_destroy_fbo()

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

Definition at line 103 of file context.c.

104{
105 const struct wined3d_gl_info *gl_info = context->gl_info;
106
110
111 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
112 checkGLcall("glDeleteFramebuffers()");
113}
static void context_clean_fbo_attachments(const struct wined3d_gl_info *gl_info, GLenum target)
Definition: context.c:86

Referenced by context_destroy_fbo_entry().

◆ context_destroy_fbo_entry()

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

Definition at line 568 of file context.c.

569{
570 if (entry->id)
571 {
572 TRACE("Destroy FBO %u.\n", entry->id);
574 }
575 --context->fbo_entry_count;
576 list_remove(&entry->entry);
578}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void context_destroy_fbo(struct wined3d_context *context, GLuint fbo)
Definition: context.c:103

Referenced by context_apply_fbo_state(), and context_destroy_gl_resources().

◆ context_destroy_gl_resources()

static void context_destroy_gl_resources ( struct wined3d_context context)
static

Definition at line 1332 of file context.c.

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

Referenced by context_destroy(), and context_set_current().

◆ context_dump_fbo_attachment()

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

Definition at line 244 of file context.c.

246{
247 static const struct
248 {
250 GLenum binding;
251 const char *str;
252 enum wined3d_gl_extension extension;
253 }
254 texture_type[] =
255 {
262 };
263
264 GLint type, name, samples, width, height, old_texture, level, face, fmt, tex_target;
265 const char *tex_type_str;
266 unsigned int i;
267
268 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
270 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
272
273 if (type == GL_RENDERBUFFER)
274 {
275 gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, name);
276 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
277 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
278 if (gl_info->limits.samples > 1)
279 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
280 else
281 samples = 1;
282 gl_info->fbo_ops.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT, &fmt);
283 FIXME(" %s: renderbuffer %d, %dx%d, %d samples, format %#x.\n",
285 }
286 else if (type == GL_TEXTURE)
287 {
288 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
290 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv(target, attachment,
292
293 if (gl_info->gl_ops.ext.p_glGetTextureParameteriv)
294 {
295 GL_EXTCALL(glGetTextureParameteriv(name, GL_TEXTURE_TARGET, &tex_target));
296
297 for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
298 {
299 if (texture_type[i].target == tex_target)
300 {
301 tex_type_str = texture_type[i].str;
302 break;
303 }
304 }
305 if (i == ARRAY_SIZE(texture_type))
306 tex_type_str = wine_dbg_sprintf("%#x", tex_target);
307 }
308 else if (face)
309 {
310 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &old_texture);
311 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, name);
312
313 tex_target = GL_TEXTURE_CUBE_MAP;
314 tex_type_str = "cube";
315 }
316 else
317 {
318 tex_type_str = NULL;
319
320 for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
321 {
322 if (!gl_info->supported[texture_type[i].extension])
323 continue;
324
325 gl_info->gl_ops.gl.p_glGetIntegerv(texture_type[i].binding, &old_texture);
326 while (gl_info->gl_ops.gl.p_glGetError());
327
328 gl_info->gl_ops.gl.p_glBindTexture(texture_type[i].target, name);
329 if (!gl_info->gl_ops.gl.p_glGetError())
330 {
331 tex_target = texture_type[i].target;
332 tex_type_str = texture_type[i].str;
333 break;
334 }
335 gl_info->gl_ops.gl.p_glBindTexture(texture_type[i].target, old_texture);
336 }
337
338 if (!tex_type_str)
339 {
340 FIXME("Cannot find type of texture %d.\n", name);
341 return;
342 }
343 }
344
345 if (gl_info->gl_ops.ext.p_glGetTextureParameteriv)
346 {
347 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_INTERNAL_FORMAT, &fmt));
348 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_WIDTH, &width));
349 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_HEIGHT, &height));
350 GL_EXTCALL(glGetTextureLevelParameteriv(name, level, GL_TEXTURE_SAMPLES, &samples));
351 }
352 else
353 {
354 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
355 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_WIDTH, &width);
356 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_HEIGHT, &height);
358 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(tex_target, level, GL_TEXTURE_SAMPLES, &samples);
359 else
360 samples = 1;
361
362 gl_info->gl_ops.gl.p_glBindTexture(tex_target, old_texture);
363 }
364
365 FIXME(" %s: %s texture %d, %dx%d, %d samples, format %#x.\n",
367 }
368 else if (type == GL_NONE)
369 {
370 FIXME(" %s: NONE.\n", debug_fboattachment(attachment));
371 }
372 else
373 {
374 ERR(" %s: Unknown attachment %#x.\n", debug_fboattachment(attachment), type);
375 }
376
377 checkGLcall("dump FBO attachment");
378}
WORD face[3]
Definition: mesh.c:4747
const char * debug_fboattachment(GLenum attachment)
Definition: utils.c:4745
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
#define GL_TEXTURE_WIDTH
Definition: gl.h:657
#define GL_TEXTURE
Definition: gl.h:247
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_TEXTURE_HEIGHT
Definition: gl.h:658
#define GL_TEXTURE_INTERNAL_FORMAT
Definition: gl.h:732
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_TEXTURE_BINDING_CUBE_MAP
Definition: gl.h:1789
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_TEXTURE_BINDING_2D
Definition: gl.h:731
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
Definition: glext.h:1704
#define GL_RENDERBUFFER_SAMPLES
Definition: glext.h:1701
GLsizei samples
Definition: glext.h:7006
#define GL_RENDERBUFFER_WIDTH
Definition: glext.h:1734
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
Definition: glext.h:1703
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define GL_RENDERBUFFER_HEIGHT
Definition: glext.h:1735
#define GL_TEXTURE_BINDING_2D_ARRAY
Definition: glext.h:538
#define GL_TEXTURE_SAMPLES
Definition: glext.h:1945
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
Definition: glext.h:1705
#define GL_RENDERBUFFER_INTERNAL_FORMAT
Definition: glext.h:1736
#define GL_TEXTURE_BINDING_RECTANGLE_ARB
Definition: glext.h:1615
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE
Definition: glext.h:1943
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
Definition: glext.h:1702
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1944
const WCHAR * str
Definition: dsound.c:943
#define GL_TEXTURE_TARGET
Definition: wgl.h:4412
wined3d_gl_extension
Definition: wined3d_gl.h:36
@ WINED3D_GL_EXT_NONE
Definition: wined3d_gl.h:37

Referenced by context_check_fbo_status().

◆ context_enable_clip_distances()

void context_enable_clip_distances ( struct wined3d_context context,
unsigned int  enable_mask 
)

Definition at line 2414 of file context.c.

2415{
2416 const struct wined3d_gl_info *gl_info = context->gl_info;
2417 unsigned int clip_distance_count = gl_info->limits.user_clip_distances;
2418 unsigned int i, disable_mask, current_mask;
2419
2420 disable_mask = ~enable_mask;
2421 enable_mask &= (1u << clip_distance_count) - 1;
2422 disable_mask &= (1u << clip_distance_count) - 1;
2423 current_mask = context->clip_distance_mask;
2424 context->clip_distance_mask = enable_mask;
2425
2426 enable_mask &= ~current_mask;
2427 while (enable_mask)
2428 {
2429 i = wined3d_bit_scan(&enable_mask);
2430 gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i);
2431 }
2432 disable_mask &= current_mask;
2433 while (disable_mask)
2434 {
2435 i = wined3d_bit_scan(&disable_mask);
2436 gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i);
2437 }
2438 checkGLcall("toggle clip distances");
2439}
#define GL_CLIP_DISTANCE0
Definition: glext.h:506

Referenced by SetupForBlit(), shader_glsl_select(), state_clipping(), and vertexdeclaration().

◆ context_end_transform_feedback()

void context_end_transform_feedback ( struct wined3d_context context)

Definition at line 4127 of file context.c.

4128{
4129 const struct wined3d_gl_info *gl_info = context->gl_info;
4130 if (context->transform_feedback_active)
4131 {
4132 GL_EXTCALL(glEndTransformFeedback());
4133 checkGLcall("glEndTransformFeedback");
4134 context->transform_feedback_active = 0;
4135 context->transform_feedback_paused = 0;
4136 }
4137}

Referenced by buffer_destroy_buffer_object(), context_pause_transform_feedback(), and state_so().

◆ context_enter()

static void context_enter ( struct wined3d_context context)
static

Definition at line 1619 of file context.c.

1620{
1621 TRACE("Entering context %p, level %u.\n", context, context->level + 1);
1622
1623 if (!context->level++)
1624 {
1625 const struct wined3d_context *current_context = context_get_current();
1626 HGLRC current_gl = wglGetCurrentContext();
1627
1628 if (current_gl && (!current_context || current_context->glCtx != current_gl))
1629 {
1630 TRACE("Another GL context (%p on device context %p) is already current.\n",
1631 current_gl, wglGetCurrentDC());
1632 context->restore_ctx = current_gl;
1633 context->restore_dc = wglGetCurrentDC();
1634 context->needs_set = 1;
1635 }
1636 else if (!context->needs_set && !(context->hdc_is_private && context->hdc_has_format)
1637 && context->pixel_format != context->gl_info->gl_ops.wgl.p_wglGetPixelFormat(context->hdc))
1638 context->needs_set = 1;
1639 }
1640}

Referenced by context_activate(), and context_create().

◆ context_enum_fbo_entries()

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

Definition at line 1041 of file context.c.

1043{
1044 unsigned int i, j;
1045
1046 for (i = 0; i < device->context_count; ++i)
1047 {
1048 struct wined3d_context *context = device->contexts[i];
1049 const struct wined3d_gl_info *gl_info = context->gl_info;
1050 struct fbo_entry *entry, *entry2;
1051
1052 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry)
1053 {
1054 for (j = 0; j < gl_info->limits.buffers + 1; ++j)
1055 {
1056 if (entry->key.objects[j].object == name
1057 && !(entry->key.rb_namespace & (1 << j)) == !rb_namespace)
1058 {
1060 break;
1061 }
1062 }
1063 }
1064 }
1065}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static IPrintDialogCallback callback
Definition: printdlg.c:326

Referenced by context_gl_resource_released().

◆ context_find_fbo_entry()

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 
)
static

Definition at line 581 of file context.c.

584{
585 static const struct wined3d_rendertarget_info ds_null = {{0}};
586 const struct wined3d_gl_info *gl_info = context->gl_info;
587 struct wined3d_texture *rt_texture, *ds_texture;
588 struct wined3d_fbo_entry_key fbo_key;
589 unsigned int i, ds_level, rt_level;
590 struct fbo_entry *entry;
591
592 if (depth_stencil->resource && depth_stencil->resource->type != WINED3D_RTYPE_BUFFER
593 && render_targets[0].resource && render_targets[0].resource->type != WINED3D_RTYPE_BUFFER)
594 {
595 rt_texture = wined3d_texture_from_resource(render_targets[0].resource);
596 rt_level = render_targets[0].sub_resource_idx % rt_texture->level_count;
597 ds_texture = wined3d_texture_from_resource(depth_stencil->resource);
598 ds_level = depth_stencil->sub_resource_idx % ds_texture->level_count;
599
600 if (wined3d_texture_get_level_width(ds_texture, ds_level)
601 < wined3d_texture_get_level_width(rt_texture, rt_level)
602 || wined3d_texture_get_level_height(ds_texture, ds_level)
603 < wined3d_texture_get_level_height(rt_texture, rt_level))
604 {
605 WARN("Depth stencil is smaller than the primary color buffer, disabling.\n");
606 depth_stencil = &ds_null;
607 }
608 else if (ds_texture->resource.multisample_type != rt_texture->resource.multisample_type
609 || ds_texture->resource.multisample_quality != rt_texture->resource.multisample_quality)
610 {
611 WARN("Color multisample type %u and quality %u, depth stencil has %u and %u, disabling ds buffer.\n",
612 rt_texture->resource.multisample_type, rt_texture->resource.multisample_quality,
613 ds_texture->resource.multisample_type, ds_texture->resource.multisample_quality);
614 depth_stencil = &ds_null;
615 }
616 else if (depth_stencil->resource->type == WINED3D_RTYPE_TEXTURE_2D)
617 {
618 struct wined3d_surface *surface;
619
620 surface = ds_texture->sub_resources[depth_stencil->sub_resource_idx].u.surface;
621 surface_set_compatible_renderbuffer(surface, &render_targets[0]);
622 }
623 }
624
625 context_generate_fbo_key(context, &fbo_key, render_targets, depth_stencil, color_location, ds_location);
626
627 if (TRACE_ON(d3d))
628 {
630 unsigned int width, height;
631 const char *resource_type;
632
633 TRACE("Dumping FBO attachments:\n");
634 for (i = 0; i < gl_info->limits.buffers; ++i)
635 {
636 if ((resource = render_targets[i].resource))
637 {
638 if (resource->type == WINED3D_RTYPE_BUFFER)
639 {
641 height = 1;
642 resource_type = "buffer";
643 }
644 else
645 {
647 rt_level = render_targets[i].sub_resource_idx % rt_texture->level_count;
648 width = wined3d_texture_get_level_pow2_width(rt_texture, rt_level);
649 height = wined3d_texture_get_level_pow2_height(rt_texture, rt_level);
650 resource_type = "texture";
651 }
652
653 TRACE(" Color attachment %u: %p, %u format %s, %s %u, %ux%u, %u samples.\n",
654 i, resource, render_targets[i].sub_resource_idx, debug_d3dformat(resource->format->id),
655 fbo_key.rb_namespace & (1 << (i + 1)) ? "renderbuffer" : resource_type,
656 fbo_key.objects[i + 1].object, width, height, resource->multisample_type);
657 }
658 }
659 if ((resource = depth_stencil->resource))
660 {
661 if (resource->type == WINED3D_RTYPE_BUFFER)
662 {
664 height = 1;
665 resource_type = "buffer";
666 }
667 else
668 {
670 ds_level = depth_stencil->sub_resource_idx % ds_texture->level_count;
671 width = wined3d_texture_get_level_pow2_width(ds_texture, ds_level);
672 height = wined3d_texture_get_level_pow2_height(ds_texture, ds_level);
673 resource_type = "texture";
674 }
675
676 TRACE(" Depth attachment: %p, %u format %s, %s %u, %ux%u, %u samples.\n",
677 resource, depth_stencil->sub_resource_idx, debug_d3dformat(resource->format->id),
678 fbo_key.rb_namespace & (1 << 0) ? "renderbuffer" : resource_type,
679 fbo_key.objects[0].object, width, height, resource->multisample_type);
680 }
681 }
682
683 LIST_FOR_EACH_ENTRY(entry, &context->fbo_list, struct fbo_entry, entry)
684 {
685 if (memcmp(&fbo_key, &entry->key, sizeof(fbo_key)))
686 continue;
687
688 list_remove(&entry->entry);
689 list_add_head(&context->fbo_list, &entry->entry);
690 return entry;
691 }
692
693 if (context->fbo_entry_count < WINED3D_MAX_FBO_ENTRIES)
694 {
695 entry = context_create_fbo_entry(context, render_targets, depth_stencil, color_location, ds_location);
696 list_add_head(&context->fbo_list, &entry->entry);
697 ++context->fbo_entry_count;
698 }
699 else
700 {
701 entry = LIST_ENTRY(list_tail(&context->fbo_list), struct fbo_entry, entry);
702 context_reuse_fbo_entry(context, target, render_targets, depth_stencil, color_location, ds_location, entry);
703 list_remove(&entry->entry);
704 list_add_head(&context->fbo_list, &entry->entry);
705 }
706
707 return entry;
708}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static struct fbo_entry * context_create_fbo_entry(const struct wined3d_context *context, const struct wined3d_rendertarget_info *render_targets, const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location)
Definition: context.c:521
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)
Definition: context.c:547
#define WINED3D_MAX_FBO_ENTRIES
Definition: context.c:45
void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const struct wined3d_rendertarget_info *rt)
Definition: surface.c:981
struct wined3d_texture *__cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
Definition: texture.c:2210
#define resource
Definition: kernel32.h:9
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
size_t size
Definition: utils.c:259
#define LIST_ENTRY(type)
Definition: queue.h:175
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:700
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by context_apply_fbo_state().

◆ context_free_fence()

void context_free_fence ( struct wined3d_fence fence)

Definition at line 904 of file context.c.

905{
906 struct wined3d_context *context = fence->context;
907
908 list_remove(&fence->entry);
909 fence->context = NULL;
910
911 if (!wined3d_array_reserve((void **)&context->free_fences,
912 &context->free_fence_size, context->free_fence_count + 1,
913 sizeof(*context->free_fences)))
914 {
915 ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context);
916 return;
917 }
918
919 context->free_fences[context->free_fence_count++] = fence->object;
920}
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: utils.c:6526

Referenced by wined3d_fence_free(), and wined3d_fence_issue().

◆ context_free_occlusion_query()

void context_free_occlusion_query ( struct wined3d_occlusion_query query)

Definition at line 844 of file context.c.

845{
846 struct wined3d_context *context = query->context;
847
848 list_remove(&query->entry);
849 query->context = NULL;
850
851 if (!wined3d_array_reserve((void **)&context->free_occlusion_queries,
852 &context->free_occlusion_query_size, context->free_occlusion_query_count + 1,
853 sizeof(*context->free_occlusion_queries)))
854 {
855 ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context);
856 return;
857 }
858
859 context->free_occlusion_queries[context->free_occlusion_query_count++] = query->id;
860}

Referenced by wined3d_occlusion_query_ops_destroy(), and wined3d_occlusion_query_ops_issue().

◆ context_free_pipeline_statistics_query()

void context_free_pipeline_statistics_query ( struct wined3d_pipeline_statistics_query query)

Definition at line 1021 of file context.c.

1022{
1023 struct wined3d_context *context = query->context;
1024
1025 list_remove(&query->entry);
1026 query->context = NULL;
1027
1028 if (!wined3d_array_reserve((void **)&context->free_pipeline_statistics_queries,
1029 &context->free_pipeline_statistics_query_size, context->free_pipeline_statistics_query_count + 1,
1030 sizeof(*context->free_pipeline_statistics_queries)))
1031 {
1032 ERR("Failed to grow free list, leaking GL queries in context %p.\n", context);
1033 return;
1034 }
1035
1036 context->free_pipeline_statistics_queries[context->free_pipeline_statistics_query_count++] = query->u;
1037}

Referenced by wined3d_pipeline_query_ops_destroy(), and wined3d_pipeline_query_ops_issue().

◆ context_free_so_statistics_query()

void context_free_so_statistics_query ( struct wined3d_so_statistics_query query)

Definition at line 983 of file context.c.

984{
985 struct wined3d_context *context = query->context;
986
987 list_remove(&query->entry);
988 query->context = NULL;
989
990 if (!wined3d_array_reserve((void **)&context->free_so_statistics_queries,
991 &context->free_so_statistics_query_size, context->free_so_statistics_query_count + 1,
992 sizeof(*context->free_so_statistics_queries)))
993 {
994 ERR("Failed to grow free list, leaking GL queries %u, %u in context %p.\n",
995 query->u.id[0], query->u.id[1], context);
996 return;
997 }
998
999 context->free_so_statistics_queries[context->free_so_statistics_query_count++] = query->u;
1000}

Referenced by wined3d_so_statistics_query_ops_destroy(), and wined3d_so_statistics_query_ops_issue().

◆ context_free_timestamp_query()

void context_free_timestamp_query ( struct wined3d_timestamp_query query)

Definition at line 943 of file context.c.

944{
945 struct wined3d_context *context = query->context;
946
947 list_remove(&query->entry);
948 query->context = NULL;
949
950 if (!wined3d_array_reserve((void **)&context->free_timestamp_queries,
951 &context->free_timestamp_query_size, context->free_timestamp_query_count + 1,
952 sizeof(*context->free_timestamp_queries)))
953 {
954 ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context);
955 return;
956 }
957
958 context->free_timestamp_queries[context->free_timestamp_query_count++] = query->id;
959}

Referenced by wined3d_timestamp_query_ops_destroy(), and wined3d_timestamp_query_ops_issue().

◆ context_generate_fbo_key()

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

Definition at line 505 of file context.c.

508{
509 unsigned int buffers = context->gl_info->limits.buffers;
510 unsigned int i;
511
512 key->rb_namespace = 0;
513 context_set_fbo_key_for_render_target(context, key, 0, depth_stencil, ds_location);
514
515 for (i = 0; i < buffers; ++i)
516 context_set_fbo_key_for_render_target(context, key, i + 1, &render_targets[i], color_location);
517
518 memset(&key->objects[buffers + 1], 0, (ARRAY_SIZE(key->objects) - buffers - 1) * sizeof(*key->objects));
519}
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)
Definition: context.c:431
const GLuint * buffers
Definition: glext.h:5916
Definition: copy.c:22

Referenced by context_create_fbo_entry(), context_find_fbo_entry(), and context_reuse_fbo_entry().

◆ context_generate_rt_mask()

static DWORD context_generate_rt_mask ( GLenum  buffer)
inlinestatic

Definition at line 414 of file context.c.

415{
416 /* Should take care of all the GL_FRONT/GL_BACK/GL_AUXi/GL_NONE... cases */
417 return buffer ? (1u << 31) | buffer : 0;
418}
GLuint buffer
Definition: glext.h:5915

Referenced by context_create(), context_create_fbo_entry(), context_generate_rt_mask_no_fbo(), and context_set_draw_buffer().

◆ context_generate_rt_mask_from_resource()

static DWORD context_generate_rt_mask_from_resource ( struct wined3d_resource resource)
inlinestatic

Definition at line 420 of file context.c.

421{
423 {
424 FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
425 return 0;
426 }
427
429}
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4329

Referenced by context_apply_blit_state(), context_apply_clear_state(), context_generate_rt_mask_no_fbo(), and find_draw_buffers_mask().

◆ context_generate_rt_mask_no_fbo()

static DWORD context_generate_rt_mask_no_fbo ( const struct wined3d_context context,
struct wined3d_texture rt 
)
static

Definition at line 2970 of file context.c.

2971{
2972 if (!rt || rt->resource.format->id == WINED3DFMT_NULL)
2973 return 0;
2974 else if (rt->swapchain)
2976 else
2978}
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context)
Definition: context.c:2954
struct wined3d_swapchain * swapchain

Referenced by context_apply_blit_state(), context_apply_clear_state(), and find_draw_buffers_mask().

◆ context_get_current()

◆ context_get_offscreen_gl_buffer()

GLenum context_get_offscreen_gl_buffer ( const struct wined3d_context context)

Definition at line 2954 of file context.c.

2955{
2957 {
2958 case ORM_FBO:
2959 return GL_COLOR_ATTACHMENT0;
2960
2961 case ORM_BACKBUFFER:
2962 return context->aux_buffers > 0 ? GL_AUX0 : GL_BACK;
2963
2964 default:
2965 FIXME("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode);
2966 return GL_BACK;
2967 }
2968}
#define GL_AUX0
Definition: gl.h:475

Referenced by context_generate_rt_mask_no_fbo(), fb_copy_to_texture_direct(), fb_copy_to_texture_hwstretch(), read_from_framebuffer(), and surface_load_fb_texture().

◆ context_get_rt_size()

static void context_get_rt_size ( const struct wined3d_context context,
SIZE size 
)
static

Definition at line 2393 of file context.c.

2394{
2395 const struct wined3d_texture *rt = context->current_rt.texture;
2396 unsigned int level;
2397
2398 if (rt->swapchain)
2399 {
2400 RECT window_size;
2401
2402 GetClientRect(context->win_handle, &window_size);
2403 size->cx = window_size.right - window_size.left;
2404 size->cy = window_size.bottom - window_size.top;
2405
2406 return;
2407 }
2408
2409 level = context->current_rt.sub_resource_idx % rt->level_count;
2412}
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by SetupForBlit().

◆ context_get_tex_unit_mapping()

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 at line 2334 of file context.c.

2336{
2337 const struct wined3d_gl_info *gl_info = context->gl_info;
2338
2339 if (!shader_version)
2340 {
2341 *base = 0;
2343 return context->tex_unit_map;
2344 }
2345
2346 if (shader_version->