ReactOS 0.4.17-dev-966-gf06eace
cs.c File Reference
#include "wined3d_private.h"
#include "wined3d_gl.h"
Include dependency graph for cs.c:

Go to the source code of this file.

Classes

struct  wined3d_deferred_upload
 
struct  wined3d_deferred_query_issue
 
struct  wined3d_command_list
 
struct  wined3d_cs_packet
 
struct  wined3d_cs_nop
 
struct  wined3d_cs_present
 
struct  wined3d_cs_clear
 
struct  wined3d_cs_clear_sysmem_texture
 
struct  wined3d_cs_dispatch
 
struct  wined3d_cs_draw
 
struct  wined3d_cs_flush
 
struct  wined3d_cs_set_predication
 
struct  wined3d_cs_set_viewports
 
struct  wined3d_cs_set_scissor_rects
 
struct  wined3d_cs_set_rendertarget_views
 
struct  wined3d_cs_set_depth_stencil_view
 
struct  wined3d_cs_set_vertex_declaration
 
struct  wined3d_cs_set_stream_sources
 
struct  wined3d_cs_set_stream_outputs
 
struct  wined3d_cs_set_index_buffer
 
struct  wined3d_cs_set_constant_buffers
 
struct  wined3d_cs_set_texture
 
struct  wined3d_cs_set_color_key
 
struct  wined3d_cs_set_shader_resource_views
 
struct  wined3d_cs_set_unordered_access_views
 
struct  wined3d_cs_set_samplers
 
struct  wined3d_cs_set_shader
 
struct  wined3d_cs_set_blend_state
 
struct  wined3d_cs_set_depth_stencil_state
 
struct  wined3d_cs_set_rasterizer_state
 
struct  wined3d_cs_set_depth_bounds
 
struct  wined3d_cs_set_render_state
 
struct  wined3d_cs_set_texture_state
 
struct  wined3d_cs_set_transform
 
struct  wined3d_cs_set_clip_plane
 
struct  wined3d_cs_set_light
 
struct  wined3d_cs_set_light_enable
 
struct  wined3d_cs_set_feature_level
 
struct  wined3d_cs_push_constants
 
struct  wined3d_cs_reset_state
 
struct  wined3d_cs_callback
 
struct  wined3d_cs_query_issue
 
struct  wined3d_cs_preload_resource
 
struct  wined3d_cs_unload_resource
 
struct  wined3d_cs_map
 
struct  wined3d_cs_unmap
 
struct  wined3d_cs_map_bo_address
 
struct  wined3d_cs_blt_sub_resource
 
struct  wined3d_cs_update_sub_resource
 
struct  wined3d_cs_add_dirty_texture_region
 
struct  wined3d_cs_clear_unordered_access_view
 
struct  wined3d_cs_copy_uav_counter
 
struct  wined3d_cs_generate_mipmaps
 
struct  wined3d_cs_execute_command_list
 
struct  wined3d_cs_stop
 
struct  push_constant_info
 
struct  wined3d_deferred_context
 

Macros

#define WINED3D_INITIAL_CS_SIZE   4096
 
#define WINED3D_TO_STR(type)   case type: return #type
 

Enumerations

enum  wined3d_cs_op {
  WINED3D_CS_OP_NOP , WINED3D_CS_OP_PRESENT , WINED3D_CS_OP_CLEAR , WINED3D_CS_OP_DISPATCH ,
  WINED3D_CS_OP_DRAW , WINED3D_CS_OP_FLUSH , WINED3D_CS_OP_SET_PREDICATION , WINED3D_CS_OP_SET_VIEWPORTS ,
  WINED3D_CS_OP_SET_SCISSOR_RECTS , WINED3D_CS_OP_SET_RENDERTARGET_VIEWS , WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW , WINED3D_CS_OP_SET_VERTEX_DECLARATION ,
  WINED3D_CS_OP_SET_STREAM_SOURCES , WINED3D_CS_OP_SET_STREAM_OUTPUTS , WINED3D_CS_OP_SET_INDEX_BUFFER , WINED3D_CS_OP_SET_CONSTANT_BUFFERS ,
  WINED3D_CS_OP_SET_TEXTURE , WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS , WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS , WINED3D_CS_OP_SET_SAMPLERS ,
  WINED3D_CS_OP_SET_SHADER , WINED3D_CS_OP_SET_BLEND_STATE , WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE , WINED3D_CS_OP_SET_RASTERIZER_STATE ,
  WINED3D_CS_OP_SET_DEPTH_BOUNDS , WINED3D_CS_OP_SET_RENDER_STATE , WINED3D_CS_OP_SET_TEXTURE_STATE , WINED3D_CS_OP_SET_TRANSFORM ,
  WINED3D_CS_OP_SET_CLIP_PLANE , WINED3D_CS_OP_SET_COLOR_KEY , WINED3D_CS_OP_SET_LIGHT , WINED3D_CS_OP_SET_LIGHT_ENABLE ,
  WINED3D_CS_OP_SET_FEATURE_LEVEL , WINED3D_CS_OP_PUSH_CONSTANTS , WINED3D_CS_OP_RESET_STATE , WINED3D_CS_OP_CALLBACK ,
  WINED3D_CS_OP_QUERY_ISSUE , WINED3D_CS_OP_PRELOAD_RESOURCE , WINED3D_CS_OP_UNLOAD_RESOURCE , WINED3D_CS_OP_MAP ,
  WINED3D_CS_OP_UNMAP , WINED3D_CS_OP_MAP_BO_ADDRESS , WINED3D_CS_OP_BLT_SUB_RESOURCE , WINED3D_CS_OP_UPDATE_SUB_RESOURCE ,
  WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION , WINED3D_CS_OP_CLEAR_SYSMEM_TEXTURE , WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW , WINED3D_CS_OP_COPY_UAV_COUNTER ,
  WINED3D_CS_OP_GENERATE_MIPMAPS , WINED3D_CS_OP_EXECUTE_COMMAND_LIST , WINED3D_CS_OP_STOP
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_sync)
 
 WINE_DECLARE_DEBUG_CHANNEL (fps)
 
 WINE_DECLARE_DEBUG_CHANNEL (frametime)
 
static NTSTATUS (WINAPI *pNtAlertThreadByThreadId)(HANDLE tid)
 
static void discard_client_address (struct wined3d_resource *resource)
 
static void invalidate_client_address (struct wined3d_resource *resource)
 
static void * wined3d_device_context_require_space (struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_device_context_submit (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_device_context_finish (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_device_context_reference_resource (struct wined3d_device_context *context, struct wined3d_resource *resource)
 
static struct wined3d_cs * wined3d_cs_from_context (struct wined3d_device_context *context)
 
static const char * debug_cs_op (enum wined3d_cs_op op)
 
static struct wined3d_cs_packet * wined3d_next_cs_packet (const uint8_t *data, SIZE_T *offset, SIZE_T mask)
 
static void wined3d_cs_exec_nop (struct wined3d_cs *cs, const void *data)
 
static void wined3d_cs_exec_present (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_present (struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, uint32_t flags)
 
static void wined3d_cs_exec_clear (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_clear (struct wined3d_cs *cs, DWORD rect_count, const RECT *rects, uint32_t flags, const struct wined3d_color *color, float depth, DWORD stencil)
 
void wined3d_device_context_emit_clear_rendertarget_view (struct wined3d_device_context *context, struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags, const struct wined3d_color *color, float depth, unsigned int stencil)
 
static void wined3d_cs_exec_clear_sysmem_texture (struct wined3d_cs *cs, const void *data)
 
HRESULT CDECL wined3d_device_context_clear_sysmem_texture (struct wined3d_device_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *rect, unsigned int flags, const struct wined3d_color *color)
 
static void reference_shader_resources (struct wined3d_device_context *context, unsigned int shader_mask)
 
static void reference_unordered_access_resources (struct wined3d_device_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
 
static void wined3d_cs_exec_dispatch (struct wined3d_cs *cs, const void *data)
 
static void reference_compute_pipeline_resources (struct wined3d_device_context *context)
 
void CDECL wined3d_device_context_dispatch (struct wined3d_device_context *context, unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z)
 
void CDECL wined3d_device_context_dispatch_indirect (struct wined3d_device_context *context, struct wined3d_buffer *buffer, unsigned int offset)
 
static void wined3d_cs_exec_draw (struct wined3d_cs *cs, const void *data)
 
static void reference_graphics_pipeline_resources (struct wined3d_device_context *context, BOOL indexed, const struct wined3d_d3d_info *d3d_info)
 
void wined3d_device_context_emit_draw (struct wined3d_device_context *context, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count, int base_vertex_idx, unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count, bool indexed)
 
void CDECL wined3d_device_context_draw_indirect (struct wined3d_device_context *context, struct wined3d_buffer *buffer, unsigned int offset, bool indexed)
 
static void wined3d_cs_exec_flush (struct wined3d_cs *cs, const void *data)
 
static void wined3d_cs_flush (struct wined3d_device_context *context)
 
static void wined3d_cs_exec_set_predication (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_predication (struct wined3d_device_context *context, struct wined3d_query *predicate, BOOL value)
 
static void wined3d_cs_exec_set_viewports (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_viewports (struct wined3d_device_context *context, unsigned int viewport_count, const struct wined3d_viewport *viewports)
 
static void wined3d_cs_exec_set_scissor_rects (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_scissor_rects (struct wined3d_device_context *context, unsigned int rect_count, const RECT *rects)
 
static void wined3d_cs_exec_set_rendertarget_views (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_rendertarget_views (struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, struct wined3d_rendertarget_view *const *views)
 
static void wined3d_cs_exec_set_depth_stencil_view (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_depth_stencil_view (struct wined3d_device_context *context, struct wined3d_rendertarget_view *view)
 
static void wined3d_cs_exec_set_vertex_declaration (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_vertex_declaration (struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration)
 
static void wined3d_cs_exec_set_stream_sources (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_stream_sources (struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
 
static void wined3d_cs_exec_set_stream_outputs (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_stream_outputs (struct wined3d_device_context *context, const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS])
 
static void wined3d_cs_exec_set_index_buffer (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_index_buffer (struct wined3d_device_context *context, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
 
static void wined3d_cs_exec_set_constant_buffers (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_constant_buffers (struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, const struct wined3d_constant_buffer_state *buffers)
 
static bool texture_binding_might_invalidate_ps (struct wined3d_shader_resource_view *view, struct wined3d_shader_resource_view *prev, const struct wined3d_d3d_info *d3d_info)
 
static void wined3d_cs_exec_set_texture (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_texture (struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int bind_index, struct wined3d_shader_resource_view *view)
 
static void wined3d_cs_exec_set_shader_resource_views (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_shader_resource_views (struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_shader_resource_view *const *views)
 
static void wined3d_cs_exec_set_unordered_access_views (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_unordered_access_views (struct wined3d_device_context *context, enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, struct wined3d_unordered_access_view *const *views, const unsigned int *initial_counts)
 
static void wined3d_cs_exec_set_samplers (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_samplers (struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
 
static void wined3d_cs_exec_set_shader (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_shader (struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader)
 
static void wined3d_cs_exec_set_blend_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_blend_state (struct wined3d_device_context *context, struct wined3d_blend_state *state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
 
static void wined3d_cs_exec_set_depth_stencil_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_depth_stencil_state (struct wined3d_device_context *context, struct wined3d_depth_stencil_state *state, unsigned int stencil_ref)
 
static void wined3d_cs_exec_set_rasterizer_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_rasterizer_state (struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state)
 
static void wined3d_cs_exec_set_depth_bounds (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_set_depth_bounds (struct wined3d_device_context *context, bool enable, float min_depth, float max_depth)
 
static void wined3d_cs_exec_set_render_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_render_state (struct wined3d_device_context *context, enum wined3d_render_state state, unsigned int value)
 
static void wined3d_cs_exec_set_texture_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_texture_state (struct wined3d_device_context *context, unsigned int stage, enum wined3d_texture_stage_state state, unsigned int value)
 
static void wined3d_cs_exec_set_transform (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_transform (struct wined3d_device_context *context, enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
 
static void wined3d_cs_exec_set_clip_plane (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_clip_plane (struct wined3d_device_context *context, unsigned int plane_idx, const struct wined3d_vec4 *plane)
 
static void wined3d_cs_exec_set_color_key (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_set_color_key (struct wined3d_cs *cs, struct wined3d_texture *texture, WORD flags, const struct wined3d_color_key *color_key)
 
static void wined3d_cs_exec_set_light (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_light (struct wined3d_device_context *context, const struct wined3d_light_info *light)
 
static void wined3d_cs_exec_set_light_enable (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_light_enable (struct wined3d_device_context *context, unsigned int idx, BOOL enable)
 
static void wined3d_cs_exec_set_feature_level (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_set_feature_level (struct wined3d_device_context *context, enum wined3d_feature_level level)
 
static bool prepare_push_constant_buffer (struct wined3d_device_context *context, enum wined3d_push_constants type)
 
static void wined3d_cs_exec_push_constants (struct wined3d_cs *cs, const void *data)
 
static void wined3d_device_context_emit_push_constants (struct wined3d_device_context *context, enum wined3d_push_constants type, uint32_t update_mask, unsigned int start_idx, unsigned int count)
 
void wined3d_device_context_push_constants (struct wined3d_device_context *context, enum wined3d_push_constants type, uint32_t update_mask, unsigned int start_idx, unsigned int count, const void *constants)
 
static void wined3d_cs_exec_reset_state (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_reset_state (struct wined3d_device_context *context, bool invalidate)
 
static void wined3d_cs_exec_callback (struct wined3d_cs *cs, const void *data)
 
static void wined3d_cs_emit_callback (struct wined3d_cs *cs, void(*callback)(void *object), void *object)
 
void wined3d_cs_destroy_object (struct wined3d_cs *cs, void(*callback)(void *object), void *object)
 
void wined3d_cs_init_object (struct wined3d_cs *cs, void(*callback)(void *object), void *object)
 
static void wined3d_cs_exec_query_issue (struct wined3d_cs *cs, const void *data)
 
static void wined3d_cs_issue_query (struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags)
 
static void wined3d_cs_reference_command_list (struct wined3d_device_context *context, struct wined3d_command_list *list)
 
static void wined3d_cs_exec_preload_resource (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_preload_resource (struct wined3d_cs *cs, struct wined3d_resource *resource)
 
static void wined3d_cs_exec_unload_resource (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_unload_resource (struct wined3d_cs *cs, struct wined3d_resource *resource)
 
static void wined3d_device_context_upload_bo (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const struct upload_bo *bo, unsigned int row_pitch, unsigned int slice_pitch)
 
static void wined3d_cs_exec_map (struct wined3d_cs *cs, const void *data)
 
HRESULT wined3d_device_context_emit_map (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
 
static void wined3d_cs_exec_unmap (struct wined3d_cs *cs, const void *data)
 
HRESULT wined3d_device_context_emit_unmap (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx)
 
static void wined3d_cs_exec_map_bo_address (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_map_bo_address (struct wined3d_cs *cs, struct wined3d_bo_address *addr, size_t size, unsigned int flags)
 
static void wined3d_cs_exec_blt_sub_resource (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_blt_sub_resource (struct wined3d_device_context *context, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
 
static void wined3d_cs_exec_update_sub_resource (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_update_sub_resource (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int slice_pitch)
 
static void wined3d_cs_exec_add_dirty_texture_region (struct wined3d_cs *cs, const void *data)
 
void wined3d_cs_emit_add_dirty_texture_region (struct wined3d_cs *cs, struct wined3d_texture *texture, unsigned int layer)
 
static void wined3d_cs_exec_clear_unordered_access_view (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_clear_uav (struct wined3d_device_context *context, struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value, bool fp)
 
static void wined3d_cs_exec_copy_uav_counter (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_copy_uav_counter (struct wined3d_device_context *context, struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav)
 
static void wined3d_cs_exec_generate_mipmaps (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_generate_mipmaps (struct wined3d_device_context *context, struct wined3d_shader_resource_view *view)
 
static void wined3d_cs_emit_stop (struct wined3d_cs *cs)
 
static void wined3d_cs_reference_resource (struct wined3d_device_context *context, struct wined3d_resource *resource)
 
static void wined3d_cs_exec_execute_command_list (struct wined3d_cs *cs, const void *data)
 
void wined3d_device_context_emit_execute_command_list (struct wined3d_device_context *context, struct wined3d_command_list *list, bool restore_state)
 
static void * wined3d_cs_st_require_space (struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_cs_st_submit (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_cs_st_finish (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void get_map_pitch (const struct wined3d_format *format, const struct wined3d_box *box, struct wined3d_map_desc *map_desc, size_t *size)
 
static bool wined3d_cs_map_upload_bo (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
 
static bool wined3d_bo_address_is_null (struct wined3d_const_bo_address *addr)
 
static bool wined3d_cs_unmap_upload_bo (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo)
 
static BOOL wined3d_cs_queue_is_empty (const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
 
static void wined3d_cs_queue_submit (struct wined3d_cs_queue *queue, struct wined3d_cs *cs)
 
static void wined3d_cs_mt_submit (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void * wined3d_cs_queue_require_space (struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs)
 
static void * wined3d_cs_mt_require_space (struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_cs_mt_finish (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void poll_queries (struct wined3d_cs *cs)
 
static void wined3d_cs_wait_event (struct wined3d_cs *cs)
 
static void wined3d_cs_command_lock (const struct wined3d_cs *cs)
 
static void wined3d_cs_command_unlock (const struct wined3d_cs *cs)
 
static bool wined3d_cs_execute_next (struct wined3d_cs *cs, struct wined3d_cs_queue *queue)
 
static DWORD WINAPI wined3d_cs_run (void *ctx)
 
void CDECL wined3d_device_context_flush_mapped_buffer (struct wined3d_device_context *context, struct wined3d_buffer *buffer)
 
struct wined3d_cs * wined3d_cs_create (struct wined3d_device *device, const enum wined3d_feature_level *levels, unsigned int level_count)
 
void wined3d_cs_destroy (struct wined3d_cs *cs)
 
static void wined3d_cs_packet_decref_objects (const struct wined3d_cs_packet *packet)
 
static void wined3d_cs_packet_incref_objects (struct wined3d_cs_packet *packet)
 
static struct wined3d_deferred_context * wined3d_deferred_context_from_context (struct wined3d_device_context *context)
 
static void * wined3d_deferred_context_require_space (struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_deferred_context_submit (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static void wined3d_deferred_context_finish (struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
 
static struct wined3d_deferred_upload * deferred_context_get_upload (struct wined3d_deferred_context *deferred, struct wined3d_resource *resource, unsigned int sub_resource_idx)
 
static bool wined3d_deferred_context_map_upload_bo (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
 
static bool wined3d_deferred_context_unmap_upload_bo (struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo)
 
static void wined3d_deferred_context_issue_query (struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags)
 
static void wined3d_deferred_context_flush (struct wined3d_device_context *context)
 
static void wined3d_deferred_context_reference_resource (struct wined3d_device_context *context, struct wined3d_resource *resource)
 
static void wined3d_deferred_context_reference_command_list (struct wined3d_device_context *context, struct wined3d_command_list *list)
 
HRESULT CDECL wined3d_deferred_context_create (struct wined3d_device *device, struct wined3d_device_context **context)
 
void CDECL wined3d_deferred_context_destroy (struct wined3d_device_context *context)
 
HRESULT CDECL wined3d_deferred_context_record_command_list (struct wined3d_device_context *context, bool restore, struct wined3d_command_list **list)
 
static void wined3d_command_list_destroy_object (void *object)
 
ULONG CDECL wined3d_command_list_incref (struct wined3d_command_list *list)
 
ULONG CDECL wined3d_command_list_decref (struct wined3d_command_list *list)
 

Variables

static const LARGE_INTEGER * timeout
 
static const struct push_constant_info wined3d_cs_push_constant_info []
 
static void(*const wined3d_cs_op_handlers [])(struct wined3d_cs *cs, const void *data)
 
static const struct wined3d_device_context_ops wined3d_cs_st_ops
 
static const struct wined3d_device_context_ops wined3d_cs_mt_ops
 
static const struct wined3d_device_context_ops wined3d_deferred_context_ops
 

Macro Definition Documentation

◆ WINED3D_INITIAL_CS_SIZE

#define WINED3D_INITIAL_CS_SIZE   4096

Definition at line 31 of file cs.c.

◆ WINED3D_TO_STR

#define WINED3D_TO_STR (   type)    case type: return #type

Enumeration Type Documentation

◆ wined3d_cs_op

Enumerator
WINED3D_CS_OP_NOP 
WINED3D_CS_OP_PRESENT 
WINED3D_CS_OP_CLEAR 
WINED3D_CS_OP_DISPATCH 
WINED3D_CS_OP_DRAW 
WINED3D_CS_OP_FLUSH 
WINED3D_CS_OP_SET_PREDICATION 
WINED3D_CS_OP_SET_VIEWPORTS 
WINED3D_CS_OP_SET_SCISSOR_RECTS 
WINED3D_CS_OP_SET_RENDERTARGET_VIEWS 
WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW 
WINED3D_CS_OP_SET_VERTEX_DECLARATION 
WINED3D_CS_OP_SET_STREAM_SOURCES 
WINED3D_CS_OP_SET_STREAM_OUTPUTS 
WINED3D_CS_OP_SET_INDEX_BUFFER 
WINED3D_CS_OP_SET_CONSTANT_BUFFERS 
WINED3D_CS_OP_SET_TEXTURE 
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS 
WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS 
WINED3D_CS_OP_SET_SAMPLERS 
WINED3D_CS_OP_SET_SHADER 
WINED3D_CS_OP_SET_BLEND_STATE 
WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE 
WINED3D_CS_OP_SET_RASTERIZER_STATE 
WINED3D_CS_OP_SET_DEPTH_BOUNDS 
WINED3D_CS_OP_SET_RENDER_STATE 
WINED3D_CS_OP_SET_TEXTURE_STATE 
WINED3D_CS_OP_SET_TRANSFORM 
WINED3D_CS_OP_SET_CLIP_PLANE 
WINED3D_CS_OP_SET_COLOR_KEY 
WINED3D_CS_OP_SET_LIGHT 
WINED3D_CS_OP_SET_LIGHT_ENABLE 
WINED3D_CS_OP_SET_FEATURE_LEVEL 
WINED3D_CS_OP_PUSH_CONSTANTS 
WINED3D_CS_OP_RESET_STATE 
WINED3D_CS_OP_CALLBACK 
WINED3D_CS_OP_QUERY_ISSUE 
WINED3D_CS_OP_PRELOAD_RESOURCE 
WINED3D_CS_OP_UNLOAD_RESOURCE 
WINED3D_CS_OP_MAP 
WINED3D_CS_OP_UNMAP 
WINED3D_CS_OP_MAP_BO_ADDRESS 
WINED3D_CS_OP_BLT_SUB_RESOURCE 
WINED3D_CS_OP_UPDATE_SUB_RESOURCE 
WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION 
WINED3D_CS_OP_CLEAR_SYSMEM_TEXTURE 
WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW 
WINED3D_CS_OP_COPY_UAV_COUNTER 
WINED3D_CS_OP_GENERATE_MIPMAPS 
WINED3D_CS_OP_EXECUTE_COMMAND_LIST 
WINED3D_CS_OP_STOP 

Definition at line 92 of file cs.c.

93{
145};
@ WINED3D_CS_OP_MAP
Definition: cs.c:133
@ WINED3D_CS_OP_SET_SAMPLERS
Definition: cs.c:113
@ WINED3D_CS_OP_SET_FEATURE_LEVEL
Definition: cs.c:126
@ WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW
Definition: cs.c:140
@ WINED3D_CS_OP_COPY_UAV_COUNTER
Definition: cs.c:141
@ WINED3D_CS_OP_SET_TEXTURE_STATE
Definition: cs.c:120
@ WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION
Definition: cs.c:138
@ WINED3D_CS_OP_SET_STREAM_OUTPUTS
Definition: cs.c:107
@ WINED3D_CS_OP_SET_LIGHT
Definition: cs.c:124
@ WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW
Definition: cs.c:104
@ WINED3D_CS_OP_STOP
Definition: cs.c:144
@ WINED3D_CS_OP_SET_STREAM_SOURCES
Definition: cs.c:106
@ WINED3D_CS_OP_SET_INDEX_BUFFER
Definition: cs.c:108
@ WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS
Definition: cs.c:111
@ WINED3D_CS_OP_SET_VERTEX_DECLARATION
Definition: cs.c:105
@ WINED3D_CS_OP_SET_CONSTANT_BUFFERS
Definition: cs.c:109
@ WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS
Definition: cs.c:112
@ WINED3D_CS_OP_CLEAR
Definition: cs.c:96
@ WINED3D_CS_OP_NOP
Definition: cs.c:94
@ WINED3D_CS_OP_QUERY_ISSUE
Definition: cs.c:130
@ WINED3D_CS_OP_SET_LIGHT_ENABLE
Definition: cs.c:125
@ WINED3D_CS_OP_SET_TEXTURE
Definition: cs.c:110
@ WINED3D_CS_OP_PUSH_CONSTANTS
Definition: cs.c:127
@ WINED3D_CS_OP_SET_SCISSOR_RECTS
Definition: cs.c:102
@ WINED3D_CS_OP_UPDATE_SUB_RESOURCE
Definition: cs.c:137
@ WINED3D_CS_OP_RESET_STATE
Definition: cs.c:128
@ WINED3D_CS_OP_MAP_BO_ADDRESS
Definition: cs.c:135
@ WINED3D_CS_OP_UNMAP
Definition: cs.c:134
@ WINED3D_CS_OP_PRELOAD_RESOURCE
Definition: cs.c:131
@ WINED3D_CS_OP_SET_RENDER_STATE
Definition: cs.c:119
@ WINED3D_CS_OP_SET_RASTERIZER_STATE
Definition: cs.c:117
@ WINED3D_CS_OP_EXECUTE_COMMAND_LIST
Definition: cs.c:143
@ WINED3D_CS_OP_BLT_SUB_RESOURCE
Definition: cs.c:136
@ WINED3D_CS_OP_DRAW
Definition: cs.c:98
@ WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE
Definition: cs.c:116
@ WINED3D_CS_OP_SET_BLEND_STATE
Definition: cs.c:115
@ WINED3D_CS_OP_SET_VIEWPORTS
Definition: cs.c:101
@ WINED3D_CS_OP_FLUSH
Definition: cs.c:99
@ WINED3D_CS_OP_SET_CLIP_PLANE
Definition: cs.c:122
@ WINED3D_CS_OP_PRESENT
Definition: cs.c:95
@ WINED3D_CS_OP_SET_PREDICATION
Definition: cs.c:100
@ WINED3D_CS_OP_SET_DEPTH_BOUNDS
Definition: cs.c:118
@ WINED3D_CS_OP_GENERATE_MIPMAPS
Definition: cs.c:142
@ WINED3D_CS_OP_SET_SHADER
Definition: cs.c:114
@ WINED3D_CS_OP_CLEAR_SYSMEM_TEXTURE
Definition: cs.c:139
@ WINED3D_CS_OP_DISPATCH
Definition: cs.c:97
@ WINED3D_CS_OP_SET_RENDERTARGET_VIEWS
Definition: cs.c:103
@ WINED3D_CS_OP_UNLOAD_RESOURCE
Definition: cs.c:132
@ WINED3D_CS_OP_SET_COLOR_KEY
Definition: cs.c:123
@ WINED3D_CS_OP_SET_TRANSFORM
Definition: cs.c:121
@ WINED3D_CS_OP_CALLBACK
Definition: cs.c:129

Function Documentation

◆ debug_cs_op()

static const char * debug_cs_op ( enum wined3d_cs_op  op)
static

Definition at line 575 of file cs.c.

576{
577 switch (op)
578 {
579#define WINED3D_TO_STR(type) case type: return #type
631#undef WINED3D_TO_STR
632 }
633 return wine_dbg_sprintf("UNKNOWN_OP(%#x)", op);
634}
#define WINED3D_TO_STR(type)
UINT op
Definition: effect.c:235
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296

Referenced by wined3d_cs_exec_execute_command_list(), wined3d_cs_execute_next(), and wined3d_cs_queue_submit().

◆ deferred_context_get_upload()

static struct wined3d_deferred_upload * deferred_context_get_upload ( struct wined3d_deferred_context *  deferred,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx 
)
static

Definition at line 4243 of file cs.c.

4245{
4246 SIZE_T i = deferred->upload_count;
4247
4248 while (i--)
4249 {
4250 struct wined3d_deferred_upload *upload = &deferred->uploads[i];
4251
4252 if (upload->resource == resource && upload->sub_resource_idx == sub_resource_idx)
4253 return upload;
4254 }
4255
4256 return NULL;
4257}
#define NULL
Definition: types.h:112
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
struct wined3d_deferred_upload * uploads
Definition: cs.c:4184
unsigned int sub_resource_idx
Definition: cs.c:36
struct wined3d_resource * resource
Definition: cs.c:35
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by wined3d_deferred_context_map_upload_bo(), and wined3d_deferred_context_unmap_upload_bo().

◆ discard_client_address()

static void discard_client_address ( struct wined3d_resource *  resource)
static

Definition at line 77 of file cs.c.

78{
79 struct wined3d_client_resource *client = &resource->client;
80
81 client->addr.buffer_object = CLIENT_BO_DISCARDED;
82 client->addr.addr = NULL;
83}
static FILE * client
Definition: client.c:37
#define CLIENT_BO_DISCARDED

Referenced by wined3d_cs_emit_unload_resource().

◆ get_map_pitch()

static void get_map_pitch ( const struct wined3d_format *  format,
const struct wined3d_box *  box,
struct wined3d_map_desc *  map_desc,
size_t *  size 
)
static

Definition at line 3068 of file cs.c.

3070{
3071 unsigned int height = box->bottom - box->top;
3072 unsigned int width = box->right - box->left;
3073 unsigned int depth = box->back - box->front;
3074
3076
3077 *size = (depth - 1) * map_desc->slice_pitch
3078 + ((height - 1) / format->block_height) * map_desc->row_pitch
3079 + ((width + format->block_width - 1) / format->block_width) * format->block_byte_count;
3080}
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment, unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: utils.c:4489
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
Definition: palette.c:466

Referenced by wined3d_cs_map_upload_bo(), and wined3d_deferred_context_map_upload_bo().

◆ invalidate_client_address()

static void invalidate_client_address ( struct wined3d_resource *  resource)
static

Definition at line 85 of file cs.c.

86{
87 struct wined3d_client_resource *client = &resource->client;
88
89 memset(&client->addr, 0, sizeof(client->addr));
90}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by wined3d_cs_reference_command_list(), wined3d_device_context_emit_blt_sub_resource(), wined3d_device_context_emit_map(), and wined3d_device_context_emit_update_sub_resource().

◆ NTSTATUS()

static NTSTATUS ( WINAPI *  pNtAlertThreadByThreadId)
static

◆ poll_queries()

static void poll_queries ( struct wined3d_cs *  cs)
static

Definition at line 3362 of file cs.c.

3363{
3364 struct wined3d_query *query, *cursor;
3365
3367 {
3368 if (!query->query_ops->query_poll(query, 0))
3369 continue;
3370
3371 list_remove(&query->poll_list_entry);
3372 list_init(&query->poll_list_entry);
3373 InterlockedIncrement(&query->counter_retrieved);
3374 }
3375}
#define InterlockedIncrement
Definition: armddk.h:53
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_init(struct list_entry *head)
Definition: list.h:51
#define cs
Definition: i386-dis.c:442
const char cursor[]
Definition: icontest.c:13
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
struct list poll_list_entry

Referenced by wined3d_cs_run().

◆ prepare_push_constant_buffer()

static bool prepare_push_constant_buffer ( struct wined3d_device_context *  context,
enum wined3d_push_constants  type 
)
static

Definition at line 2159 of file cs.c.

2160{
2162 struct wined3d_device *device = context->device;
2163 bool gpu = device->adapter->d3d_info.gpu_push_constants;
2164 HRESULT hr;
2165
2166 struct wined3d_buffer_desc desc =
2167 {
2168 .byte_width = info->max_count * info->size,
2169 .bind_flags = 0,
2171 };
2172
2173 if (gpu)
2174 {
2177 }
2178
2179 if (!device->push_constants[type] && FAILED(hr = wined3d_buffer_create(device,
2180 &desc, NULL, NULL, &wined3d_null_parent_ops, &device->push_constants[type])))
2181 {
2182 ERR("Failed to create push constant buffer, hr %#lx.\n", hr);
2183 return false;
2184 }
2185
2186 return true;
2187}
#define ERR(fmt,...)
Definition: precomp.h:57
static const struct push_constant_info wined3d_cs_push_constant_info[]
HRESULT hr
Definition: delayimp.cpp:582
HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
Definition: buffer.c:1329
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: http.c:7252
Definition: devices.h:37
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:3472
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:51
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:52
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:53
#define WINED3D_BIND_CONSTANT_BUFFER
Definition: wined3d.h:911
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:54

Referenced by wined3d_device_context_push_constants().

◆ reference_compute_pipeline_resources()

static void reference_compute_pipeline_resources ( struct wined3d_device_context *  context)
static

Definition at line 1021 of file cs.c.

1022{
1023 const struct wined3d_state *state = context->state;
1024
1027 state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
1028}
static int state
Definition: maze.c:121
static void reference_unordered_access_resources(struct wined3d_device_context *context, const struct wined3d_shader *shader, struct wined3d_unordered_access_view *const *views)
Definition: cs.c:990
static void reference_shader_resources(struct wined3d_device_context *context, unsigned int shader_mask)
Definition: cs.c:946
@ WINED3D_PIPELINE_COMPUTE
Definition: wined3d.h:856
@ WINED3D_SHADER_TYPE_COMPUTE
Definition: wined3d.h:848

Referenced by wined3d_device_context_dispatch(), and wined3d_device_context_dispatch_indirect().

◆ reference_graphics_pipeline_resources()

static void reference_graphics_pipeline_resources ( struct wined3d_device_context *  context,
BOOL  indexed,
const struct wined3d_d3d_info *  d3d_info 
)
static

Definition at line 1131 of file cs.c.

1133{
1134 const struct wined3d_state *state = context->state;
1135 unsigned int i;
1136
1137 if (indexed)
1138 wined3d_device_context_reference_resource(context, &state->index_buffer->resource);
1139 for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
1140 {
1141 if (state->streams[i].buffer)
1142 wined3d_device_context_reference_resource(context, &state->streams[i].buffer->resource);
1143 }
1144 for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
1145 {
1146 if (state->stream_output[i].buffer)
1147 wined3d_device_context_reference_resource(context, &state->stream_output[i].buffer->resource);
1148 }
1149 for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
1150 {
1151 if (state->fb.render_targets[i])
1152 wined3d_device_context_reference_resource(context, state->fb.render_targets[i]->resource);
1153 }
1154 for (i = 0; i < WINED3D_PUSH_CONSTANTS_COUNT; ++i)
1155 {
1156 if (context->device->push_constants[i])
1157 wined3d_device_context_reference_resource(context, &context->device->push_constants[i]->resource);
1158 }
1159 if (state->fb.depth_stencil)
1160 wined3d_device_context_reference_resource(context, state->fb.depth_stencil->resource);
1163 state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
1164}
#define ARRAY_SIZE(A)
Definition: main.h:20
static void wined3d_device_context_reference_resource(struct wined3d_device_context *context, struct wined3d_resource *resource)
Definition: cs.c:564
struct wined3d_d3d_limits limits
@ WINED3D_PIPELINE_GRAPHICS
Definition: wined3d.h:855
@ WINED3D_SHADER_TYPE_PIXEL
Definition: wined3d.h:841
@ WINED3D_PUSH_CONSTANTS_COUNT

Referenced by wined3d_device_context_draw_indirect(), and wined3d_device_context_emit_draw().

◆ reference_shader_resources()

static void reference_shader_resources ( struct wined3d_device_context *  context,
unsigned int  shader_mask 
)
static

Definition at line 946 of file cs.c.

947{
948 const struct wined3d_state *state = context->state;
951 struct wined3d_shader *shader;
952 unsigned int i, j;
953
954 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
955 {
956 if (!(shader_mask & (1u << i)))
957 continue;
958
959 if (!(shader = state->shader[i]))
960 {
962 {
963 for (j = 0; j < WINED3D_MAX_FFP_TEXTURES; ++j)
964 {
965 if ((view = state->shader_resource_view[WINED3D_SHADER_TYPE_PIXEL][j]))
967 }
968 }
969 continue;
970 }
971
972 for (j = 0; j < WINED3D_MAX_CBS; ++j)
973 {
974 if (state->cb[i][j].buffer)
976 }
977
978 for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
979 {
980 entry = &shader->reg_maps.sampler_map.entries[j];
981
982 if (!(view = state->shader_resource_view[i][entry->resource_idx]))
983 continue;
984
986 }
987 }
988}
GLuint shader
Definition: glext.h:6030
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
uint32_t entry
Definition: isohybrid.c:63
@ WINED3D_SHADER_TYPE_COUNT
Definition: wined3d.h:849
#define WINED3D_MAX_FFP_TEXTURES
Definition: wined3d.h:1597
#define WINED3D_MAX_CBS

Referenced by reference_compute_pipeline_resources(), and reference_graphics_pipeline_resources().

◆ reference_unordered_access_resources()

static void reference_unordered_access_resources ( struct wined3d_device_context *  context,
const struct wined3d_shader *  shader,
struct wined3d_unordered_access_view *const *  views 
)
static

Definition at line 990 of file cs.c.

992{
993 unsigned int i;
994
995 if (!shader)
996 return;
997
998 for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
999 {
1000 if (!shader->reg_maps.uav_resource_info[i].type)
1001 continue;
1002
1003 if (!views[i])
1004 continue;
1005
1007 }
1008}
#define MAX_UNORDERED_ACCESS_VIEWS

Referenced by reference_compute_pipeline_resources(), and reference_graphics_pipeline_resources().

◆ texture_binding_might_invalidate_ps()

static bool texture_binding_might_invalidate_ps ( struct wined3d_shader_resource_view *  view,
struct wined3d_shader_resource_view *  prev,
const struct wined3d_d3d_info *  d3d_info 
)
static

Definition at line 1563 of file cs.c.

1565{
1566 unsigned int old_usage, new_usage, old_caps, new_caps;
1567 const struct wined3d_format *old_format, *new_format;
1568
1569 if (!prev)
1570 return true;
1571
1572 /* 1.x pixel shaders need to be recompiled based on the resource type. */
1573 old_usage = prev->resource->usage;
1574 new_usage = view->resource->usage;
1575 if (view->resource->type != prev->resource->type
1576 || ((old_usage & WINED3DUSAGE_LEGACY_CUBEMAP) != (new_usage & WINED3DUSAGE_LEGACY_CUBEMAP)))
1577 return true;
1578
1579 old_format = prev->resource->format;
1580 new_format = view->resource->format;
1581 old_caps = prev->resource->format_caps;
1582 new_caps = view->resource->format_caps;
1583 if ((old_caps & WINED3D_FORMAT_CAP_SHADOW) != (new_caps & WINED3D_FORMAT_CAP_SHADOW))
1584 return true;
1585
1586 if (is_same_fixup(old_format->color_fixup, new_format->color_fixup))
1587 return false;
1588
1589 if (can_use_texture_swizzle(d3d_info, new_format) && can_use_texture_swizzle(d3d_info, old_format))
1590 return false;
1591
1592 return true;
1593}
enum view_type type
struct color_fixup_desc color_fixup
struct wined3d_resource * resource
#define WINED3DUSAGE_LEGACY_CUBEMAP
Definition: wined3d.h:934
#define WINED3D_FORMAT_CAP_SHADOW
static BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
static BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)

Referenced by wined3d_cs_exec_set_texture().

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/4]

WINE_DECLARE_DEBUG_CHANNEL ( d3d_perf  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/4]

WINE_DECLARE_DEBUG_CHANNEL ( d3d_sync  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [3/4]

WINE_DECLARE_DEBUG_CHANNEL ( fps  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [4/4]

WINE_DECLARE_DEBUG_CHANNEL ( frametime  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_bo_address_is_null()

static bool wined3d_bo_address_is_null ( struct wined3d_const_bo_address *  addr)
static

Definition at line 3186 of file cs.c.

3187{
3188 return !addr->buffer_object && !addr->addr;
3189}
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by wined3d_cs_unmap_upload_bo(), and wined3d_device_context_flush_mapped_buffer().

◆ wined3d_command_list_decref()

ULONG CDECL wined3d_command_list_decref ( struct wined3d_command_list *  list)

Definition at line 4651 of file cs.c.

4652{
4653 unsigned int refcount = InterlockedDecrement(&list->refcount);
4654 struct wined3d_device *device = list->device;
4655 const struct wined3d_cs_packet *packet;
4656 SIZE_T i, offset;
4657
4658 TRACE("%p decreasing refcount to %u.\n", list, refcount);
4659
4660 if (!refcount)
4661 {
4662 for (i = 0; i < list->command_list_count; ++i)
4663 wined3d_command_list_decref(list->command_lists[i]);
4664 for (i = 0; i < list->resource_count; ++i)
4665 wined3d_resource_decref(list->resources[i]);
4666 for (i = 0; i < list->upload_count; ++i)
4667 wined3d_resource_decref(list->uploads[i].resource);
4668 for (i = 0; i < list->query_count; ++i)
4669 wined3d_query_decref(list->queries[i].query);
4670
4671 offset = 0;
4672 while (offset < list->data_size)
4673 {
4676 }
4677
4681 }
4682
4683 return refcount;
4684}
#define InterlockedDecrement
Definition: armddk.h:52
Definition: list.h:39
static void wined3d_command_list_destroy_object(void *object)
Definition: cs.c:4600
static struct wined3d_cs_packet * wined3d_next_cs_packet(const uint8_t *data, SIZE_T *offset, SIZE_T mask)
Definition: cs.c:636
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2299
static void wined3d_cs_packet_decref_objects(const struct wined3d_cs_packet *packet)
Definition: cs.c:3675
ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
Definition: cs.c:4651
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
Definition: query.c:432
GLintptr offset
Definition: glext.h:5920
#define TRACE(s)
Definition: solgame.cpp:4
Definition: dhcpd.h:135
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
static ULONG wined3d_resource_decref(struct wined3d_resource *resource)

Referenced by d3d11_command_list_Release(), wined3d_command_list_decref(), and wined3d_deferred_context_destroy().

◆ wined3d_command_list_destroy_object()

static void wined3d_command_list_destroy_object ( void *  object)
static

Definition at line 4600 of file cs.c.

4601{
4603 struct wined3d_context *context;
4604 unsigned int i;
4605
4606 TRACE("list %p.\n", list);
4607
4608 context = context_acquire(list->device, NULL, 0);
4609
4610 for (i = 0; i < list->upload_count; ++i)
4611 {
4612 struct wined3d_bo *bo;
4613
4614 if ((bo = list->uploads[i].bo))
4615 {
4616 if (!--bo->refcount)
4617 {
4619 free(bo);
4620 }
4621 }
4622 else
4623 {
4624 HeapFree(list->upload_heap, 0, list->uploads[i].sysmem);
4625 }
4626 }
4627
4629
4630 if (list->upload_heap)
4631 {
4632 if (!InterlockedDecrement(list->upload_heap_refcount))
4633 {
4634 HeapDestroy(list->upload_heap);
4635 free(list->upload_heap_refcount);
4636 }
4637 }
4638
4639 free(list);
4640}
#define free
Definition: debug_ros.c:5
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85
uint8_t refcount
static void context_release(struct wined3d_context *context)
static void wined3d_context_destroy_bo(struct wined3d_context *context, struct wined3d_bo *bo)
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)

Referenced by wined3d_command_list_decref().

◆ wined3d_command_list_incref()

ULONG CDECL wined3d_command_list_incref ( struct wined3d_command_list *  list)

Definition at line 4642 of file cs.c.

4643{
4644 unsigned int refcount = InterlockedIncrement(&list->refcount);
4645
4646 TRACE("%p increasing refcount to %u.\n", list, refcount);
4647
4648 return refcount;
4649}

Referenced by wined3d_deferred_context_reference_command_list().

◆ wined3d_cs_command_lock()

static void wined3d_cs_command_lock ( const struct wined3d_cs *  cs)
static

Definition at line 3405 of file cs.c.

3406{
3407 if (cs->serialize_commands)
3409}
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION wined3d_command_cs
Definition: wined3d_main.c:104

Referenced by wined3d_cs_execute_next(), and wined3d_cs_run().

◆ wined3d_cs_command_unlock()

static void wined3d_cs_command_unlock ( const struct wined3d_cs *  cs)
static

Definition at line 3411 of file cs.c.

3412{
3413 if (cs->serialize_commands)
3415}
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by wined3d_cs_execute_next(), and wined3d_cs_run().

◆ wined3d_cs_create()

struct wined3d_cs * wined3d_cs_create ( struct wined3d_device *  device,
const enum wined3d_feature_level *  levels,
unsigned int  level_count 
)

Definition at line 3561 of file cs.c.

3563{
3564 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
3565 struct wined3d_cs *cs;
3566
3567 if (!(cs = calloc(1, sizeof(*cs))))
3568 return NULL;
3569
3570 if (FAILED(wined3d_state_create(device, levels, level_count, &cs->c.state)))
3571 {
3572 free(cs);
3573 return NULL;
3574 }
3575
3576 cs->c.ops = &wined3d_cs_st_ops;
3577 cs->c.device = device;
3578 cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
3579
3580 if (cs->serialize_commands)
3581 ERR_(d3d_sync)("Forcing serialization of all command streams.\n");
3582
3583 state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT, cs->c.state->feature_level);
3584
3585 cs->data_size = WINED3D_INITIAL_CS_SIZE;
3586 if (!(cs->data = malloc(cs->data_size)))
3587 goto fail;
3588
3590 {
3591 if (!d3d_info->fences)
3592 {
3593 WARN("Disabling CSMT, adapter doesn't support fences.\n");
3594 wined3d_settings.cs_multithreaded &= ~WINED3D_CSMT_ENABLE;
3595 }
3596 }
3597
3600 {
3601 cs->c.ops = &wined3d_cs_mt_ops;
3602
3603 if (!pNtAlertThreadByThreadId)
3604 {
3605 HANDLE ntdll = GetModuleHandleW(L"ntdll.dll");
3606
3607 pNtAlertThreadByThreadId = (void *)GetProcAddress(ntdll, "NtAlertThreadByThreadId");
3608 pNtWaitForAlertByThreadId = (void *)GetProcAddress(ntdll, "NtWaitForAlertByThreadId");
3609 }
3610
3611 if (!pNtAlertThreadByThreadId && !(cs->event = CreateEventW(NULL, FALSE, FALSE, NULL)))
3612 {
3613 ERR("Failed to create command stream event.\n");
3614 free(cs->data);
3615 goto fail;
3616 }
3617 if (!(cs->present_event = CreateEventW(NULL, FALSE, FALSE, NULL)))
3618 {
3619 ERR("Failed to create command stream present event.\n");
3620 free(cs->data);
3621 goto fail;
3622 }
3623
3624 if (!(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
3625 (const WCHAR *)wined3d_cs_run, &cs->wined3d_module)))
3626 {
3627 ERR("Failed to get wined3d module handle.\n");
3628 CloseHandle(cs->present_event);
3629 if (cs->event)
3630 CloseHandle(cs->event);
3631 free(cs->data);
3632 goto fail;
3633 }
3634
3635 if (!(cs->thread = CreateThread(NULL, 0, wined3d_cs_run, cs, 0, NULL)))
3636 {
3637 ERR("Failed to create wined3d command stream thread.\n");
3638 FreeLibrary(cs->wined3d_module);
3639 CloseHandle(cs->present_event);
3640 if (cs->event)
3641 CloseHandle(cs->event);
3642 free(cs->data);
3643 goto fail;
3644 }
3645 }
3646
3647 TRACE("Created command stream %p.\n", cs);
3648 return cs;
3649
3650fail:
3651 wined3d_state_destroy(cs->c.state);
3652 state_cleanup(&cs->state);
3653 free(cs);
3654 return NULL;
3655}
#define WARN(fmt,...)
Definition: precomp.h:61
static DWORD WINAPI wined3d_cs_run(void *ctx)
Definition: cs.c:3477
#define WINED3D_INITIAL_CS_SIZE
Definition: cs.c:31
static const struct wined3d_device_context_ops wined3d_cs_st_ops
Definition: cs.c:3215
static const struct wined3d_device_context_ops wined3d_cs_mt_ops
Definition: cs.c:3349
#define malloc
Definition: debug_ros.c:4
void state_init(void *ipp)
Definition: dhclient.c:210
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define TRACE_ON(x)
Definition: compat.h:75
PPEB Peb
Definition: dllmain.c:27
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:866
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define L(x)
Definition: resources.c:13
GLsizei levels
Definition: glext.h:7884
#define NtCurrentTeb
static HMODULE ntdll
Definition: debugger.c:59
NTSYSAPI LOGICAL NTAPI RtlIsCriticalSectionLockedByThread(_In_ PRTL_CRITICAL_SECTION CriticalSection)
short WCHAR
Definition: pedump.c:58
#define calloc
Definition: rosglue.h:14
#define ERR_(ch,...)
Definition: debug.h:156
PVOID LoaderLock
Definition: ntddk_ex.h:295
unsigned int cs_multithreaded
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
void state_cleanup(struct wined3d_state *state)
Definition: stateblock.c:648
void CDECL wined3d_state_destroy(struct wined3d_state *state)
Definition: stateblock.c:2385
HRESULT CDECL wined3d_state_create(struct wined3d_device *device, const enum wined3d_feature_level *levels, unsigned int level_count, struct wined3d_state **state)
Definition: stateblock.c:2357
#define WINED3D_STATE_NO_REF
#define WINED3D_CSMT_ENABLE
#define WINED3D_STATE_INIT_DEFAULT
#define WINED3D_CSMT_SERIALIZE

Referenced by wined3d_device_init().

◆ wined3d_cs_destroy()

void wined3d_cs_destroy ( struct wined3d_cs *  cs)

Definition at line 3657 of file cs.c.

3658{
3659 if (cs->thread)
3660 {
3662 CloseHandle(cs->thread);
3663 if (!CloseHandle(cs->present_event))
3664 ERR("Closing present event failed.\n");
3665 if (cs->event && !CloseHandle(cs->event))
3666 ERR("Closing event failed.\n");
3667 }
3668
3669 wined3d_state_destroy(cs->c.state);
3670 state_cleanup(&cs->state);
3671 free(cs->data);
3672 free(cs);
3673}
static void wined3d_cs_emit_stop(struct wined3d_cs *cs)
Definition: cs.c:2922

Referenced by wined3d_device_cleanup().

◆ wined3d_cs_destroy_object()

◆ wined3d_cs_emit_add_dirty_texture_region()

void wined3d_cs_emit_add_dirty_texture_region ( struct wined3d_cs *  cs,
struct wined3d_texture *  texture,
unsigned int  layer 
)

Definition at line 2828 of file cs.c.

2830{
2832
2835 op->texture = texture;
2836 op->layer = layer;
2837
2839
2841}
static void wined3d_device_context_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:552
static void * wined3d_device_context_require_space(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:546
GLenum GLuint texture
Definition: glext.h:6295
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
static void wined3d_resource_reference(struct wined3d_resource *resource)
@ WINED3D_CS_QUEUE_DEFAULT

Referenced by wined3d_texture_add_dirty_region().

◆ wined3d_cs_emit_callback()

static void wined3d_cs_emit_callback ( struct wined3d_cs *  cs,
void(*)(void *object)  callback,
void *  object 
)
static

Definition at line 2287 of file cs.c.

2288{
2289 struct wined3d_cs_callback *op;
2290
2292 op->opcode = WINED3D_CS_OP_CALLBACK;
2293 op->callback = callback;
2294 op->object = object;
2295
2297}
void * object
Definition: cs.c:433

Referenced by wined3d_cs_destroy_object(), and wined3d_cs_init_object().

◆ wined3d_cs_emit_clear()

void wined3d_cs_emit_clear ( struct wined3d_cs *  cs,
DWORD  rect_count,
const RECT *  rects,
uint32_t  flags,
const struct wined3d_color *  color,
float  depth,
DWORD  stencil 
)

Definition at line 804 of file cs.c.

806{
807 const struct wined3d_state *state = cs->c.state;
808 const struct wined3d_viewport *vp = &state->viewports[0];
810 struct wined3d_cs_clear *op;
811 unsigned int rt_count, i;
812
813 rt_count = flags & WINED3DCLEAR_TARGET ? cs->c.device->adapter->d3d_info.limits.max_rt_count : 0;
814
817 op->opcode = WINED3D_CS_OP_CLEAR;
819 op->rt_count = rt_count;
820 op->fb = state->fb;
821 SetRect(&op->draw_rect, vp->x, vp->y, vp->x + vp->width, vp->y + vp->height);
822 if (state->rasterizer_state && state->rasterizer_state->desc.scissor)
823 IntersectRect(&op->draw_rect, &op->draw_rect, &state->scissor_rects[0]);
824 op->color = *color;
825 op->depth = depth;
826 op->stencil = stencil;
827 op->rect_count = rect_count;
828 memcpy(op->rects, rects, sizeof(*rects) * rect_count);
829
830 for (i = 0; i < rt_count; ++i)
831 {
832 if ((view = state->fb.render_targets[i]))
834 }
836 {
837 view = state->fb.depth_stencil;
839 }
840
842}
GLuint color
Definition: glext.h:6243
GLbitfield flags
Definition: glext.h:7161
GLint GLfloat GLint stencil
Definition: glext.h:6260
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
unsigned int rt_count
Definition: cs.c:173
RECT rects[1]
Definition: cs.c:180
unsigned int rect_count
Definition: cs.c:179
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define WINED3DCLEAR_TARGET
Definition: wined3d.h:1008
#define WINED3DCLEAR_STENCIL
Definition: wined3d.h:1010
#define WINED3DCLEAR_ZBUFFER
Definition: wined3d.h:1009

Referenced by wined3d_device_clear().

◆ wined3d_cs_emit_preload_resource()

void wined3d_cs_emit_preload_resource ( struct wined3d_cs *  cs,
struct wined3d_resource *  resource 
)

Definition at line 2419 of file cs.c.

Referenced by wined3d_resource_preload().

◆ wined3d_cs_emit_present()

void wined3d_cs_emit_present ( struct wined3d_cs *  cs,
struct wined3d_swapchain *  swapchain,
const RECT *  src_rect,
const RECT *  dst_rect,
HWND  dst_window_override,
unsigned int  swap_interval,
uint32_t  flags 
)

Definition at line 748 of file cs.c.

751{
752 struct wined3d_cs_present *op;
753 unsigned int i;
754 LONG pending;
755
757
759 op->opcode = WINED3D_CS_OP_PRESENT;
760 op->dst_window_override = dst_window_override;
761 op->swapchain = swapchain;
762 op->src_rect = *src_rect;
763 op->dst_rect = *dst_rect;
764 op->swap_interval = swap_interval;
765 op->flags = flags;
766
767 pending = InterlockedIncrement(&cs->pending_presents);
768
769 wined3d_resource_reference(&swapchain->front_buffer->resource);
770 for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
771 {
772 wined3d_resource_reference(&swapchain->back_buffers[i]->resource);
773 }
774
776
777 /* Limit input latency by limiting the number of presents that we can get
778 * ahead of the worker thread. */
779 while (pending >= swapchain->max_frame_latency)
780 {
781 InterlockedExchange(&cs->waiting_for_present, TRUE);
782
783 pending = InterlockedCompareExchange(&cs->pending_presents, 0, 0);
784 if (pending >= swapchain->max_frame_latency || !InterlockedCompareExchange(&cs->waiting_for_present, FALSE, TRUE))
785 {
786 TRACE_(d3d_perf)("Reached latency limit (%u frames), blocking to wait.\n", swapchain->max_frame_latency);
788 WaitForSingleObject(cs->present_event, INFINITE);
790 TRACE_(d3d_perf)("Woken up from the wait.\n");
791 }
792 }
793}
#define InterlockedExchange
Definition: armddk.h:54
#define TRUE
Definition: types.h:120
#define TRACE_(x)
Definition: compat.h:76
#define INFINITE
Definition: serial.h:102
#define InterlockedCompareExchange
Definition: interlocked.h:119
long LONG
Definition: pedump.c:60
HWND dst_window_override
Definition: cs.c:161
unsigned int swap_interval
Definition: cs.c:165
RECT src_rect
Definition: cs.c:163
struct wined3d_swapchain * swapchain
Definition: cs.c:162
RECT dst_rect
Definition: cs.c:164
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static void wined3d_not_from_cs(const struct wined3d_cs *cs)

Referenced by wined3d_swapchain_present().

◆ wined3d_cs_emit_set_color_key()

void wined3d_cs_emit_set_color_key ( struct wined3d_cs *  cs,
struct wined3d_texture *  texture,
WORD  flags,
const struct wined3d_color_key *  color_key 
)

Definition at line 2037 of file cs.c.

2039{
2041
2044 op->texture = texture;
2045 op->flags = flags;
2046 if (color_key)
2047 {
2048 op->color_key = *color_key;
2049 op->set = 1;
2050 }
2051 else
2052 op->set = 0;
2053
2055}
struct wined3d_color_key color_key
Definition: cs.c:297

Referenced by wined3d_texture_set_color_key().

◆ wined3d_cs_emit_stop()

static void wined3d_cs_emit_stop ( struct wined3d_cs *  cs)
static

Definition at line 2922 of file cs.c.

2923{
2924 struct wined3d_cs_stop *op;
2925
2927 op->opcode = WINED3D_CS_OP_STOP;
2928
2931}
static void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)

Referenced by wined3d_cs_destroy().

◆ wined3d_cs_emit_unload_resource()

void wined3d_cs_emit_unload_resource ( struct wined3d_cs *  cs,
struct wined3d_resource *  resource 
)

Definition at line 2440 of file cs.c.

2441{
2443
2445
2448 op->resource = resource;
2449
2451
2453}
static void discard_client_address(struct wined3d_resource *resource)
Definition: cs.c:77

Referenced by wined3d_device_evict_managed_resources(), wined3d_device_reset(), wined3d_device_uninit_3d(), and wined3d_texture_update_desc().

◆ wined3d_cs_exec_add_dirty_texture_region()

static void wined3d_cs_exec_add_dirty_texture_region ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2809 of file cs.c.

2810{
2812 struct wined3d_texture *texture = op->texture;
2813 unsigned int sub_resource_idx, i;
2814 struct wined3d_context *context;
2815
2816 context = context_acquire(cs->c.device, NULL, 0);
2817 sub_resource_idx = op->layer * texture->level_count;
2818 for (i = 0; i < texture->level_count; ++i, ++sub_resource_idx)
2819 {
2822 else
2823 ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
2824 }
2826}
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:702
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, uint32_t location)
Definition: texture.c:770
const char * wined3d_debug_location(uint32_t location)
Definition: utils.c:6588
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned int sub_resource_idx

◆ wined3d_cs_exec_blt_sub_resource()

static void wined3d_cs_exec_blt_sub_resource ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2601 of file cs.c.

2602{
2603 const struct wined3d_cs_blt_sub_resource *op = data;
2604
2605 if (op->dst_resource->type == WINED3D_RTYPE_BUFFER)
2606 {
2607 wined3d_buffer_copy(buffer_from_resource(op->dst_resource), op->dst_box.left,
2608 buffer_from_resource(op->src_resource), op->src_box.left,
2609 op->src_box.right - op->src_box.left);
2610 }
2611 else if (op->dst_resource->type == WINED3D_RTYPE_TEXTURE_3D)
2612 {
2613 struct wined3d_texture *src_texture, *dst_texture;
2614 unsigned int level, update_w, update_h, update_d;
2615 unsigned int row_pitch, slice_pitch;
2616 struct wined3d_context *context;
2617 struct wined3d_bo_address addr;
2618 unsigned int location;
2619
2620 if (op->flags & ~WINED3D_BLT_RAW)
2621 {
2622 FIXME("Flags %#x not implemented for %s resources.\n",
2623 op->flags, debug_d3dresourcetype(op->dst_resource->type));
2624 return;
2625 }
2626
2627 if (!(op->flags & WINED3D_BLT_RAW) && op->src_resource->format != op->dst_resource->format)
2628 {
2629 FIXME("Format conversion not implemented for %s resources.\n",
2630 debug_d3dresourcetype(op->dst_resource->type));
2631 return;
2632 }
2633
2634 update_w = op->dst_box.right - op->dst_box.left;
2635 update_h = op->dst_box.bottom - op->dst_box.top;
2636 update_d = op->dst_box.back - op->dst_box.front;
2637 if (op->src_box.right - op->src_box.left != update_w
2638 || op->src_box.bottom - op->src_box.top != update_h
2639 || op->src_box.back - op->src_box.front != update_d)
2640 {
2641 FIXME("Stretching not implemented for %s resources.\n",
2642 debug_d3dresourcetype(op->dst_resource->type));
2643 return;
2644 }
2645
2646 dst_texture = texture_from_resource(op->dst_resource);
2647 src_texture = texture_from_resource(op->src_resource);
2648
2649 context = context_acquire(cs->c.device, NULL, 0);
2650
2651 location = src_texture->resource.map_binding;
2653 && wined3d_texture_can_use_pbo(src_texture, &context->device->adapter->d3d_info))
2655
2656 if (!wined3d_texture_load_location(src_texture, op->src_sub_resource_idx,
2657 context, location))
2658 {
2659 ERR("Failed to load source sub-resource into %s.\n",
2662 return;
2663 }
2664
2665 level = op->dst_sub_resource_idx % dst_texture->level_count;
2666 if (update_w == wined3d_texture_get_level_width(dst_texture, level)
2667 && update_h == wined3d_texture_get_level_height(dst_texture, level)
2668 && update_d == wined3d_texture_get_level_depth(dst_texture, level))
2669 {
2670 wined3d_texture_prepare_location(dst_texture, op->dst_sub_resource_idx,
2672 }
2673 else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx,
2675 {
2676 ERR("Failed to load destination sub-resource.\n");
2678 return;
2679 }
2680
2681 wined3d_texture_get_bo_address(src_texture, op->src_sub_resource_idx, &addr, location);
2682 wined3d_texture_get_pitch(src_texture, op->src_sub_resource_idx % src_texture->level_count,
2683 &row_pitch, &slice_pitch);
2684
2685 dst_texture->texture_ops->texture_upload_data(context, wined3d_const_bo_address(&addr),
2686 dst_texture->resource.format, &op->src_box, row_pitch, slice_pitch, dst_texture,
2687 op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB,
2688 op->dst_box.left, op->dst_box.top, op->dst_box.front);
2689 wined3d_texture_validate_location(dst_texture, op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
2690 wined3d_texture_invalidate_location(dst_texture, op->dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
2691
2693 }
2694 else
2695 {
2696 if (FAILED(texture2d_blt(texture_from_resource(op->dst_resource), op->dst_sub_resource_idx,
2697 &op->dst_box, texture_from_resource(op->src_resource), op->src_sub_resource_idx,
2698 &op->src_box, op->flags, &op->fx, op->filter)))
2699 FIXME("Blit failed.\n");
2700 }
2701}
#define FIXME(fmt,...)
Definition: precomp.h:53
void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size)
Definition: buffer.c:808
HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, uint32_t flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: surface.c:1342
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:678
BOOL wined3d_texture_can_use_pbo(const struct wined3d_texture *texture, const struct wined3d_d3d_info *d3d_info)
Definition: texture.c:59
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
Definition: texture.c:2116
void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, uint32_t location)
Definition: texture.c:727
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1697
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4992
GLint level
Definition: gl.h:1546
#define location(file, line)
Definition: kmtest.h:18
unsigned int slice_pitch
const struct wined3d_texture_ops * texture_ops
unsigned int row_pitch
struct wined3d_resource resource
unsigned int level_count
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:718
@ WINED3D_RTYPE_TEXTURE_3D
Definition: wined3d.h:721
#define WINED3D_BLT_RAW
Definition: wined3d.h:1371
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
#define WINED3D_LOCATION_SYSMEM
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WINED3D_LOCATION_BUFFER
#define WINED3D_LOCATION_TEXTURE_RGB
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
static struct wined3d_buffer * buffer_from_resource(struct wined3d_resource *resource)
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)

◆ wined3d_cs_exec_callback()

static void wined3d_cs_exec_callback ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2280 of file cs.c.

2281{
2282 const struct wined3d_cs_callback *op = data;
2283
2284 op->callback(op->object);
2285}

◆ wined3d_cs_exec_clear()

static void wined3d_cs_exec_clear ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 795 of file cs.c.

796{
797 struct wined3d_device *device = cs->c.device;
798 const struct wined3d_cs_clear *op = data;
799
800 device->blitter->ops->blitter_clear(device->blitter, device, op->rt_count, &op->fb,
801 op->rect_count, op->rects, &op->draw_rect, op->flags, &op->color, op->depth, op->stencil);
802}

◆ wined3d_cs_exec_clear_sysmem_texture()

static void wined3d_cs_exec_clear_sysmem_texture ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 882 of file cs.c.

883{
885 struct wined3d_box box;
886
887 box.left = op->rect.left;
888 box.right = op->rect.right;
889 box.top = op->rect.top;
890 box.bottom = op->rect.bottom;
891 box.front = 0;
892 box.back = 1;
893 cpu_blitter_clear_texture(op->texture, op->sub_resource_idx, &box, &op->color);
894}
void cpu_blitter_clear_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_box *box, const struct wined3d_color *colour)
Definition: surface.c:1128

◆ wined3d_cs_exec_clear_unordered_access_view()

static void wined3d_cs_exec_clear_unordered_access_view ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2843 of file cs.c.

2844{
2846 struct wined3d_unordered_access_view *view = op->view;
2847 struct wined3d_context *context;
2848
2849 context = context_acquire(cs->c.device, NULL, 0);
2850 cs->c.device->adapter->adapter_ops->adapter_clear_uav(context, view, &op->clear_value, op->fp);
2852}

◆ wined3d_cs_exec_copy_uav_counter()

static void wined3d_cs_exec_copy_uav_counter ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2870 of file cs.c.

2871{
2872 const struct wined3d_cs_copy_uav_counter *op = data;
2873 struct wined3d_unordered_access_view *view = op->view;
2874 struct wined3d_context *context;
2875
2876 context = context_acquire(cs->c.device, NULL, 0);
2879}
void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view, struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context)
Definition: view.c:1739

◆ wined3d_cs_exec_dispatch()

static void wined3d_cs_exec_dispatch ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1010 of file cs.c.

1011{
1012 const struct wined3d_cs_dispatch *op = data;
1013 struct wined3d_state *state = &cs->state;
1014
1015 if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE])
1016 WARN("No compute shader bound, skipping dispatch.\n");
1017 else
1018 cs->c.device->adapter->adapter_ops->adapter_dispatch_compute(cs->c.device, state, &op->parameters);
1019}

◆ wined3d_cs_exec_draw()

static void wined3d_cs_exec_draw ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1068 of file cs.c.

1069{
1070 const struct wined3d_d3d_info *d3d_info = &cs->c.device->adapter->d3d_info;
1071 const struct wined3d_shader *geometry_shader;
1072 struct wined3d_device *device = cs->c.device;
1073 int base_vertex_idx, load_base_vertex_idx;
1074 struct wined3d_state *state = &cs->state;
1075 const struct wined3d_cs_draw *op = data;
1076 unsigned int i;
1077
1078 base_vertex_idx = 0;
1079 if (!op->parameters.indirect)
1080 {
1081 const struct wined3d_direct_draw_parameters *direct = &op->parameters.u.direct;
1082
1083 if (op->parameters.indexed && d3d_info->draw_base_vertex_offset)
1085 else if (!op->parameters.indexed)
1086 base_vertex_idx = direct->start_idx;
1087 }
1088
1089 /* ARB_draw_indirect always supports a base vertex offset. */
1090 if (!op->parameters.indirect && !d3d_info->draw_base_vertex_offset)
1091 load_base_vertex_idx = op->parameters.u.direct.base_vertex_idx;
1092 else
1093 load_base_vertex_idx = 0;
1094
1095 if (state->base_vertex_index != base_vertex_idx)
1096 {
1097 state->base_vertex_index = base_vertex_idx;
1098 for (i = 0; i < device->context_count; ++i)
1099 device->contexts[i]->constant_update_mask |= WINED3D_SHADER_CONST_BASE_VERTEX_ID;
1100 }
1101
1102 if (state->load_base_vertex_index != load_base_vertex_idx)
1103 {
1104 state->load_base_vertex_index = load_base_vertex_idx;
1106 }
1107
1108 if (state->primitive_type != op->primitive_type)
1109 {
1110 if ((geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]) && !geometry_shader->function)
1112 if (state->primitive_type == WINED3D_PT_POINTLIST || op->primitive_type == WINED3D_PT_POINTLIST)
1113 {
1116 }
1117 state->primitive_type = op->primitive_type;
1118 for (i = 0; i < device->context_count; ++i)
1119 device->contexts[i]->update_primitive_type = 1;
1120 }
1121 if (state->patch_vertex_count != op->patch_vertex_count)
1122 {
1123 for (i = 0; i < device->context_count; ++i)
1124 device->contexts[i]->update_patch_vertex_count = 1;
1125 }
1126 state->patch_vertex_count = op->patch_vertex_count;
1127
1128 cs->c.device->adapter->adapter_ops->adapter_draw_primitive(cs->c.device, state, &op->parameters);
1129}
void device_invalidate_state(const struct wined3d_device *device, unsigned int state_id)
Definition: device.c:5565
uint32_t draw_base_vertex_offset
const DWORD * function
@ WINED3D_PT_POINTLIST
Definition: wined3d.h:76
@ WINED3D_SHADER_TYPE_GEOMETRY
Definition: wined3d.h:843
@ WINED3D_SHADER_TYPE_VERTEX
Definition: wined3d.h:842
#define STATE_BASEVERTEXINDEX
#define WINED3D_SHADER_CONST_BASE_VERTEX_ID
#define STATE_SHADER(a)

◆ wined3d_cs_exec_execute_command_list()

static void wined3d_cs_exec_execute_command_list ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 3448 of file cs.c.

3449{
3450 const struct wined3d_cs_execute_command_list *op = data;
3451 SIZE_T start = 0, end = op->list->data_size;
3452 const BYTE *cs_data = op->list->data;
3453 struct wined3d_cs_queue *queue;
3454
3455 TRACE("Executing command list %p.\n", op->list);
3456
3457 queue = &cs->queue[WINED3D_CS_QUEUE_MAP];
3458 while (start < end)
3459 {
3460 const struct wined3d_cs_packet *packet;
3461 enum wined3d_cs_op opcode;
3462
3465
3467 opcode = *(const enum wined3d_cs_op *)packet->data;
3468
3469 if (opcode >= WINED3D_CS_OP_STOP)
3470 ERR("Invalid opcode %#x.\n", opcode);
3471 else
3472 wined3d_cs_op_handlers[opcode](cs, packet->data);
3473 TRACE("%s executed.\n", debug_cs_op(opcode));
3474 }
3475}
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
Definition: cs.c:3228
wined3d_cs_op
Definition: cs.c:93
static bool wined3d_cs_execute_next(struct wined3d_cs *cs, struct wined3d_cs_queue *queue)
Definition: cs.c:3417
static const char * debug_cs_op(enum wined3d_cs_op op)
Definition: cs.c:575
static void(*const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data)
Definition: cs.c:2940
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
if(dx< 0)
Definition: linetemp.h:194
Definition: queue.c:179
#define WINED3D_CS_QUEUE_MASK
@ WINED3D_CS_QUEUE_MAP
unsigned char BYTE
Definition: xxhash.c:193

◆ wined3d_cs_exec_flush()

static void wined3d_cs_exec_flush ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1215 of file cs.c.

1216{
1217 struct wined3d_context *context;
1218
1219 TRACE_(d3d_perf)("Flushing adapter.\n");
1220 context = context_acquire(cs->c.device, NULL, 0);
1221 cs->c.device->adapter->adapter_ops->adapter_flush_context(context);
1223}

◆ wined3d_cs_exec_generate_mipmaps()

static void wined3d_cs_exec_generate_mipmaps ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2897 of file cs.c.

2898{
2899 const struct wined3d_cs_generate_mipmaps *op = data;
2900 struct wined3d_shader_resource_view *view = op->view;
2901 struct wined3d_context *context;
2902
2903 context = context_acquire(cs->c.device, NULL, 0);
2904 cs->c.device->adapter->adapter_ops->adapter_generate_mipmap(context, view);
2906}

◆ wined3d_cs_exec_map()

static void wined3d_cs_exec_map ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2479 of file cs.c.

2480{
2481 const struct wined3d_cs_map *op = data;
2482 struct wined3d_resource *resource = op->resource;
2483
2484 *op->hr = resource->resource_ops->resource_sub_resource_map(resource,
2485 op->sub_resource_idx, op->map_ptr, op->box, op->flags);
2486}

◆ wined3d_cs_exec_map_bo_address()

static void wined3d_cs_exec_map_bo_address ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2576 of file cs.c.

2577{
2578 const struct wined3d_cs_map_bo_address *op = data;
2579 struct wined3d_context *context;
2580
2581 context = context_acquire(cs->c.device, NULL, 0);
2582 wined3d_context_map_bo_address(context, &op->addr, op->size, op->flags);
2584}
static void * wined3d_context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)

◆ wined3d_cs_exec_nop()

static void wined3d_cs_exec_nop ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 645 of file cs.c.

646{
647}

◆ wined3d_cs_exec_preload_resource()

static void wined3d_cs_exec_preload_resource ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2411 of file cs.c.

2412{
2413 const struct wined3d_cs_preload_resource *op = data;
2414 struct wined3d_resource *resource = op->resource;
2415
2416 resource->resource_ops->resource_preload(resource);
2417}

◆ wined3d_cs_exec_present()

static void wined3d_cs_exec_present ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 649 of file cs.c.

650{
651 static LARGE_INTEGER freq;
652
653 struct wined3d_texture *logo_texture, *cursor_texture, *back_buffer;
654 struct wined3d_rendertarget_view *dsv = cs->state.fb.depth_stencil;
655 const struct wined3d_cs_present *op = data;
656 const struct wined3d_swapchain_desc *desc;
657 struct wined3d_swapchain *swapchain;
658 LONGLONG elapsed_time;
660
661 if (!freq.QuadPart)
663
664 swapchain = op->swapchain;
665 desc = &swapchain->state.desc;
666 back_buffer = swapchain->back_buffers[0];
667 wined3d_swapchain_set_window(swapchain, op->dst_window_override);
668
669 if ((logo_texture = swapchain->device->logo_texture))
670 {
671 RECT rect = {0, 0, logo_texture->resource.width, logo_texture->resource.height};
672
673 /* Blit the logo into the upper left corner of the back-buffer. */
674 wined3d_device_context_blt(&cs->c, back_buffer, 0, &rect, logo_texture, 0,
676 }
677
678 if ((cursor_texture = swapchain->device->cursor_texture)
679 && swapchain->device->bCursorVisible && !swapchain->device->hardwareCursor)
680 {
681 RECT dst_rect =
682 {
683 swapchain->device->xScreenSpace - swapchain->device->xHotSpot,
684 swapchain->device->yScreenSpace - swapchain->device->yHotSpot,
685 swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot,
686 swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot,
687 };
688 RECT src_rect =
689 {
690 0, 0, cursor_texture->resource.width, cursor_texture->resource.height
691 };
692 const RECT clip_rect = {0, 0, back_buffer->resource.width, back_buffer->resource.height};
693
694 TRACE("Rendering the software cursor.\n");
695
696 if (desc->windowed)
697 MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&dst_rect, 2);
698 if (wined3d_clip_blit(&clip_rect, &dst_rect, &src_rect))
699 wined3d_device_context_blt(&cs->c, back_buffer, 0, &dst_rect, cursor_texture, 0,
701 }
702
703 swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->swap_interval, op->flags);
704
705 /* Discard buffers if the swap effect allows it. */
706 back_buffer = swapchain->back_buffers[desc->backbuffer_count - 1];
707 if (desc->swap_effect == WINED3D_SWAP_EFFECT_DISCARD || desc->swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
709
710 if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
711 {
713
716 }
717
718 if (TRACE_ON(frametime))
719 {
721 if (swapchain->last_present_time.QuadPart)
722 {
723 elapsed_time = time.QuadPart - swapchain->last_present_time.QuadPart;
724 TRACE_(frametime)("Frame duration %u μs.\n", (unsigned int)(elapsed_time * 1000000 / freq.QuadPart));
725 }
726 swapchain->last_present_time = time;
727 }
728 if (TRACE_ON(fps))
729 {
731 ++swapchain->frames;
732
733 /* every 1.5 seconds */
734 if (time - swapchain->prev_time > 1500)
735 {
736 TRACE_(fps)("%p @ approx %.2ffps\n",
737 swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time));
738 swapchain->prev_time = time;
739 swapchain->frames = 0;
740 }
741 }
742
743 InterlockedDecrement(&cs->pending_presents);
744 if (InterlockedCompareExchange(&cs->waiting_for_present, FALSE, TRUE))
745 SetEvent(cs->present_event);
746}
RECT rect
Definition: combotst.c:67
HRESULT CDECL wined3d_device_context_blt(struct wined3d_device_context *context, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const RECT *src_rect, unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: texture.c:3854
BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other)
Definition: utils.c:6672
void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view, uint32_t location)
Definition: view.c:495
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ds
Definition: i386-dis.c:443
__u16 time
Definition: mkdosfs.c:8
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
Definition: dcommon.idl:28
struct wined3d_resource * resource
struct wined3d_texture ** back_buffers
const struct wined3d_swapchain_ops * swapchain_ops
struct wined3d_swapchain_state state
struct wined3d_device * device
struct wined3d_swapchain * swapchain
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window)
Definition: swapchain.c:177
#define WINED3D_BLT_ALPHA_TEST
Definition: wined3d.h:1373
@ WINED3D_SWAP_EFFECT_FLIP_DISCARD
Definition: wined3d.h:536
@ WINED3D_SWAP_EFFECT_DISCARD
Definition: wined3d.h:534
#define WINED3D_BLT_SRC_CKEY
Definition: wined3d.h:1367
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
#define WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
Definition: wined3d.h:892
#define WINED3D_TEXTURE_DISCARD
#define WINED3D_LOCATION_DISCARDED

◆ wined3d_cs_exec_push_constants()

static void wined3d_cs_exec_push_constants ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2189 of file cs.c.

2190{
2191 const struct wined3d_cs_push_constants *op = data;
2192 struct wined3d_device *device = cs->c.device;
2193 unsigned int ffp_start_idx, ffp_end_idx;
2194 unsigned int context_count, i;
2195
2196 /* The constant buffers were already updated; this op is just to mark the
2197 * constants as invalid in the device state. */
2198
2199 ffp_start_idx = op->start_idx / sizeof(struct wined3d_vec4);
2200 ffp_end_idx = (op->start_idx + op->count + sizeof(struct wined3d_vec4)) / sizeof(struct wined3d_vec4);
2201
2202 if (op->type == WINED3D_PUSH_CONSTANTS_VS_F)
2203 device->shader_backend->shader_update_float_vertex_constants(device, op->start_idx, op->count);
2204 else if (op->type == WINED3D_PUSH_CONSTANTS_PS_F)
2205 device->shader_backend->shader_update_float_pixel_constants(device, op->start_idx, op->count);
2206 else if (op->type == WINED3D_PUSH_CONSTANTS_VS_FFP)
2207 device->shader_backend->shader_update_float_vertex_constants(device, ffp_start_idx, ffp_end_idx - ffp_start_idx);
2208 else if (op->type == WINED3D_PUSH_CONSTANTS_PS_FFP)
2209 device->shader_backend->shader_update_float_pixel_constants(device, ffp_start_idx, ffp_end_idx - ffp_start_idx);
2210
2211 for (i = 0, context_count = device->context_count; i < context_count; ++i)
2212 device->contexts[i]->constant_update_mask |= op->update_mask;
2213}
@ WINED3D_PUSH_CONSTANTS_PS_FFP
@ WINED3D_PUSH_CONSTANTS_VS_FFP
@ WINED3D_PUSH_CONSTANTS_PS_F
@ WINED3D_PUSH_CONSTANTS_VS_F
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ wined3d_cs_exec_query_issue()

static void wined3d_cs_exec_query_issue ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2309 of file cs.c.

2310{
2311 const struct wined3d_cs_query_issue *op = data;
2312 struct wined3d_query *query = op->query;
2313 BOOL poll;
2314
2315 poll = query->query_ops->query_issue(query, op->flags);
2316
2317 if (!query->poll_in_cs)
2318 {
2319 if (op->flags & WINED3DISSUE_END)
2320 InterlockedIncrement(&query->counter_retrieved);
2321 return;
2322 }
2323
2324 if (poll && list_empty(&query->poll_list_entry))
2325 {
2326 if (query->buffer_object)
2327 InterlockedIncrement(&query->counter_retrieved);
2328 else
2329 list_add_tail(&cs->query_poll_list, &query->poll_list_entry);
2330 return;
2331 }
2332
2333 /* This can happen if occlusion queries are restarted. This discards the
2334 * old result, since polling it could result in a GL error. */
2335 if ((op->flags & WINED3DISSUE_BEGIN) && !poll && !list_empty(&query->poll_list_entry))
2336 {
2337 list_remove(&query->poll_list_entry);
2338 list_init(&query->poll_list_entry);
2339 InterlockedIncrement(&query->counter_retrieved);
2340 return;
2341 }
2342
2343 /* This can happen when an occlusion query is ended without being started,
2344 * in which case we don't want to poll, but still have to counter-balance
2345 * the increment of the main counter.
2346 *
2347 * This can also happen if an event query is re-issued before the first
2348 * fence was reached. In this case the query is already in the list and
2349 * the poll function will check the new fence. We have to counter-balance
2350 * the discarded increment. */
2351 if (op->flags & WINED3DISSUE_END)
2352 InterlockedIncrement(&query->counter_retrieved);
2353}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINED3DISSUE_BEGIN
Definition: wined3d.h:781
#define WINED3DISSUE_END
Definition: wined3d.h:782
#define poll
Definition: wintirpc.h:59

◆ wined3d_cs_exec_reset_state()

static void wined3d_cs_exec_reset_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2249 of file cs.c.

2250{
2251 const struct wined3d_device *device = cs->c.device;
2252 const struct wined3d_cs_reset_state *op = data;
2253 const struct wined3d_state_entry *state_table;
2254 unsigned int state;
2255
2256 state_cleanup(&cs->state);
2257 wined3d_state_reset(&cs->state, &device->adapter->d3d_info);
2258 if (op->invalidate)
2259 {
2260 state_table = device->state_table;
2261 for (state = 0; state <= STATE_HIGHEST; ++state)
2262 {
2265 }
2266 }
2267}
static const struct @282 state_table[]
unsigned int representative
#define STATE_HIGHEST
static void wined3d_state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)

◆ wined3d_cs_exec_set_blend_state()

static void wined3d_cs_exec_set_blend_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1781 of file cs.c.

1782{
1783 const struct wined3d_cs_set_blend_state *op = data;
1784 struct wined3d_device *device = cs->c.device;
1785 struct wined3d_state *state = &cs->state;
1786
1787 if (state->blend_state != op->state)
1788 {
1789 state->blend_state = op->state;
1791 }
1792 state->blend_factor = op->factor;
1794 state->sample_mask = op->sample_mask;
1796 for (unsigned int i = 0; i < device->context_count; ++i)
1797 device->contexts[i]->update_multisample_state = 1;
1798}
#define STATE_BLEND_FACTOR
#define STATE_SAMPLE_MASK
#define STATE_BLEND

◆ wined3d_cs_exec_set_clip_plane()

static void wined3d_cs_exec_set_clip_plane ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1953 of file cs.c.

1954{
1955 const struct wined3d_cs_set_clip_plane *op = data;
1956
1957 cs->state.clip_planes[op->plane_idx] = op->plane;
1958 device_invalidate_state(cs->c.device, STATE_CLIPPLANE(op->plane_idx));
1959}
#define STATE_CLIPPLANE(a)

◆ wined3d_cs_exec_set_color_key()

static void wined3d_cs_exec_set_color_key ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1974 of file cs.c.

1975{
1976 const struct wined3d_cs_set_color_key *op = data;
1977 struct wined3d_texture *texture = op->texture;
1978
1979 if (op->set)
1980 {
1981 switch (op->flags)
1982 {
1984 texture->async.dst_blt_color_key = op->color_key;
1985 texture->async.color_key_flags |= WINED3D_CKEY_DST_BLT;
1986 break;
1987
1989 texture->async.dst_overlay_color_key = op->color_key;
1990 texture->async.color_key_flags |= WINED3D_CKEY_DST_OVERLAY;
1991 break;
1992
1994 if (texture == wined3d_state_get_ffp_texture(&cs->state, 0))
1995 {
1996 if (!(texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT))
1998 }
1999
2000 texture->async.src_blt_color_key = op->color_key;
2001 texture->async.color_key_flags |= WINED3D_CKEY_SRC_BLT;
2002 break;
2003
2005 texture->async.src_overlay_color_key = op->color_key;
2006 texture->async.color_key_flags |= WINED3D_CKEY_SRC_OVERLAY;
2007 break;
2008 }
2009 }
2010 else
2011 {
2012 switch (op->flags)
2013 {
2015 texture->async.color_key_flags &= ~WINED3D_CKEY_DST_BLT;
2016 break;
2017
2019 texture->async.color_key_flags &= ~WINED3D_CKEY_DST_OVERLAY;
2020 break;
2021
2023 if (texture == wined3d_state_get_ffp_texture(&cs->state, 0)
2024 && texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT)
2026
2027 texture->async.color_key_flags &= ~WINED3D_CKEY_SRC_BLT;
2028 break;
2029
2031 texture->async.color_key_flags &= ~WINED3D_CKEY_SRC_OVERLAY;
2032 break;
2033 }
2034 }
2035}
#define WINED3D_CKEY_DST_BLT
Definition: wined3d.h:1339
#define WINED3D_CKEY_SRC_OVERLAY
Definition: wined3d.h:1342
#define WINED3D_CKEY_SRC_BLT
Definition: wined3d.h:1341
#define WINED3D_CKEY_DST_OVERLAY
Definition: wined3d.h:1340
static struct wined3d_texture * wined3d_state_get_ffp_texture(const struct wined3d_state *state, unsigned int idx)

◆ wined3d_cs_exec_set_constant_buffers()

static void wined3d_cs_exec_set_constant_buffers ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1525 of file cs.c.

1526{
1527 const struct wined3d_cs_set_constant_buffers *op = data;
1528 unsigned int i;
1529
1530 for (i = 0; i < op->count; ++i)
1531 {
1532 struct wined3d_buffer *prev = cs->state.cb[op->type][op->start_idx + i].buffer;
1533 struct wined3d_buffer *buffer = op->buffers[i].buffer;
1534
1535 cs->state.cb[op->type][op->start_idx + i] = op->buffers[i];
1536
1537 if (buffer)
1538 ++buffer->resource.bind_count;
1539 if (prev)
1540 --prev->resource.bind_count;
1541 }
1542
1544}
GLuint buffer
Definition: glext.h:5915
struct wined3d_resource resource
#define STATE_CONSTANT_BUFFER(a)

◆ wined3d_cs_exec_set_depth_bounds()

static void wined3d_cs_exec_set_depth_bounds ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1861 of file cs.c.

1862{
1863 const struct wined3d_cs_set_depth_bounds *op = data;
1864
1865 cs->state.depth_bounds_enable = op->enable;
1866 cs->state.depth_bounds_min = op->min_depth;
1867 cs->state.depth_bounds_max = op->max_depth;
1869}
#define STATE_DEPTH_BOUNDS

◆ wined3d_cs_exec_set_depth_stencil_state()

static void wined3d_cs_exec_set_depth_stencil_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1814 of file cs.c.

1815{
1817 struct wined3d_state *state = &cs->state;
1818
1819 if (state->depth_stencil_state != op->state)
1820 {
1821 state->depth_stencil_state = op->state;
1823 }
1824 state->stencil_ref = op->stencil_ref;
1826}
#define STATE_DEPTH_STENCIL
#define STATE_STENCIL_REF

◆ wined3d_cs_exec_set_depth_stencil_view()

static void wined3d_cs_exec_set_depth_stencil_view ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1358 of file cs.c.

1359{
1361 struct wined3d_device *device = cs->c.device;
1362 struct wined3d_rendertarget_view *prev;
1363
1364 if ((prev = cs->state.fb.depth_stencil) && prev->resource->type != WINED3D_RTYPE_BUFFER)
1365 {
1366 struct wined3d_texture *prev_texture = texture_from_resource(prev->resource);
1367
1368 if (device->swapchains[0]->state.desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
1369 || prev_texture->flags & WINED3D_TEXTURE_DISCARD)
1372 }
1373
1374 cs->state.fb.depth_stencil = op->view;
1375
1376 if (!prev != !op->view)
1377 {
1378 /* Swapping NULL / non NULL depth stencil affects the depth and tests */
1382 }
1383 else if (prev)
1384 {
1385 if (prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
1387 if (prev->format->stencil_size != op->view->format->stencil_size)
1389 }
1390
1392}
const struct wined3d_format * format
#define STATE_RASTERIZER
#define STATE_FRAMEBUFFER

◆ wined3d_cs_exec_set_feature_level()

static void wined3d_cs_exec_set_feature_level ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2122 of file cs.c.

2123{
2124 const struct wined3d_cs_set_feature_level *op = data;
2125
2126 cs->state.feature_level = op->level;
2127}

◆ wined3d_cs_exec_set_index_buffer()

static void wined3d_cs_exec_set_index_buffer ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1493 of file cs.c.

1494{
1495 const struct wined3d_cs_set_index_buffer *op = data;
1496 struct wined3d_buffer *prev;
1497
1498 prev = cs->state.index_buffer;
1499 cs->state.index_buffer = op->buffer;
1500 cs->state.index_format = op->format_id;
1501 cs->state.index_offset = op->offset;
1502
1503 if (op->buffer)
1504 ++op->buffer->resource.bind_count;
1505 if (prev)
1506 --prev->resource.bind_count;
1507
1509}
#define STATE_INDEXBUFFER

◆ wined3d_cs_exec_set_light()

static void wined3d_cs_exec_set_light ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2057 of file cs.c.

2058{
2059 const struct wined3d_cs_set_light *op = data;
2060 struct wined3d_light_info *light_info;
2061 unsigned int light_idx;
2062
2063 light_idx = op->light.OriginalIndex;
2064
2065 if (!(light_info = wined3d_light_state_get_light(&cs->state.light_state, light_idx)))
2066 {
2067 TRACE("Adding new light.\n");
2068 if (!(light_info = calloc(1, sizeof(*light_info))))
2069 {
2070 ERR("Failed to allocate light info.\n");
2071 return;
2072 }
2073
2074 light_info->glIndex = -1;
2075 light_info->OriginalIndex = light_idx;
2076 rb_put(&cs->state.light_state.lights_tree, (void *)(ULONG_PTR)light_idx, &light_info->entry);
2077 }
2078
2079 light_info->OriginalParms = op->light.OriginalParms;
2080 light_info->constants = op->light.constants;
2081}
static int rb_put(struct rb_tree *tree, const void *key, struct rb_entry *entry)
Definition: rbtree.h:204
struct rb_entry entry
unsigned int OriginalIndex
struct wined3d_light_constants constants
struct wined3d_light OriginalParms
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct wined3d_light_info * wined3d_light_state_get_light(const struct wined3d_light_state *state, unsigned int idx)
Definition: stateblock.c:687

◆ wined3d_cs_exec_set_light_enable()

static void wined3d_cs_exec_set_light_enable ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2095 of file cs.c.

2096{
2097 const struct wined3d_cs_set_light_enable *op = data;
2098 struct wined3d_device *device = cs->c.device;
2099 struct wined3d_light_info *light_info;
2100
2101 if (!(light_info = wined3d_light_state_get_light(&cs->state.light_state, op->idx)))
2102 {
2103 ERR("Light doesn't exist.\n");
2104 return;
2105 }
2106
2107 wined3d_light_state_enable_light(&cs->state.light_state, &device->adapter->d3d_info, light_info, op->enable);
2108}
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable)
Definition: stateblock.c:803

◆ wined3d_cs_exec_set_predication()

static void wined3d_cs_exec_set_predication ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1237 of file cs.c.

1238{
1239 const struct wined3d_cs_set_predication *op = data;
1240
1241 cs->state.predicate = op->predicate;
1242 cs->state.predicate_value = op->value;
1243}

◆ wined3d_cs_exec_set_rasterizer_state()

static void wined3d_cs_exec_set_rasterizer_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1841 of file cs.c.

1842{
1843 const struct wined3d_cs_set_rasterizer_state *op = data;
1844
1845 cs->state.rasterizer_state = op->state;
1847}

◆ wined3d_cs_exec_set_render_state()

static void wined3d_cs_exec_set_render_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1885 of file cs.c.

1886{
1887 const struct wined3d_cs_set_render_state *op = data;
1888
1889 cs->state.render_states[op->state] = op->value;
1890 device_invalidate_state(cs->c.device, STATE_RENDER(op->state));
1891}
#define STATE_RENDER(a)

◆ wined3d_cs_exec_set_rendertarget_views()

static void wined3d_cs_exec_set_rendertarget_views ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1310 of file cs.c.

1311{
1313 struct wined3d_device *device = cs->c.device;
1314 unsigned int i;
1315
1316 for (i = 0; i < op->count; ++i)
1317 {
1318 struct wined3d_rendertarget_view *prev = cs->state.fb.render_targets[op->start_idx + i];
1319 struct wined3d_rendertarget_view *view = op->views[i];
1320 bool prev_alpha_swizzle, curr_alpha_swizzle;
1321 bool prev_srgb_write, curr_srgb_write;
1322
1323 cs->state.fb.render_targets[op->start_idx + i] = view;
1324
1325 prev_alpha_swizzle = prev && prev->format->id == WINED3DFMT_A8_UNORM;
1326 curr_alpha_swizzle = view && view->format->id == WINED3DFMT_A8_UNORM;
1327 if (prev_alpha_swizzle != curr_alpha_swizzle)
1329
1330 if (!(device->adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
1331 || cs->state.render_states[WINED3D_RS_SRGBWRITEENABLE])
1332 {
1333 prev_srgb_write = prev && prev->format_caps & WINED3D_FORMAT_CAP_SRGB_WRITE;
1334 curr_srgb_write = view && view->format_caps & WINED3D_FORMAT_CAP_SRGB_WRITE;
1335 if (prev_srgb_write != curr_srgb_write)
1337 }
1338 }
1339
1341}
@ WINED3D_RS_SRGBWRITEENABLE
Definition: wined3d.h:400
@ WINED3DFMT_A8_UNORM
Definition: wined3d.h:222
#define WINED3D_SRGB_READ_WRITE_CONTROL
Definition: wined3d.h:1330
#define WINED3D_FORMAT_CAP_SRGB_WRITE

◆ wined3d_cs_exec_set_samplers()

static void wined3d_cs_exec_set_samplers ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1723 of file cs.c.

1724{
1725 const struct wined3d_cs_set_samplers *op = data;
1726 unsigned int i;
1727
1728 for (i = 0; i < op->count; ++i)
1729 cs->state.sampler[op->type][op->start_idx + i] = op->samplers[i];
1730
1733 else
1735}
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
#define STATE_COMPUTE_SHADER_RESOURCE_BINDING

◆ wined3d_cs_exec_set_scissor_rects()

static void wined3d_cs_exec_set_scissor_rects ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1284 of file cs.c.

1285{
1286 const struct wined3d_cs_set_scissor_rects *op = data;
1287
1288 if (op->rect_count)
1289 memcpy(cs->state.scissor_rects, op->rects, op->rect_count * sizeof(*op->rects));
1290 else
1291 SetRectEmpty(cs->state.scissor_rects);
1292 cs->state.scissor_rect_count = op->rect_count;
1294}
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define STATE_SCISSORRECT

◆ wined3d_cs_exec_set_shader()

static void wined3d_cs_exec_set_shader ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1753 of file cs.c.

1754{
1755 const struct wined3d_cs_set_shader *op = data;
1756
1757 /* CB binding may have been skipped earlier if the shader wasn't set, so make it happen. */
1758 if (!cs->state.shader[op->type] && op->shader)
1760 cs->state.shader[op->type] = op->shader;
1761 device_invalidate_state(cs->c.device, STATE_SHADER(op->type));
1762 if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
1764 else
1766}

◆ wined3d_cs_exec_set_shader_resource_views()

static void wined3d_cs_exec_set_shader_resource_views ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1635 of file cs.c.

1636{
1638 unsigned int i;
1639
1640 for (i = 0; i < op->count; ++i)
1641 {
1642 struct wined3d_shader_resource_view *prev = cs->state.shader_resource_view[op->type][op->start_idx + i];
1643 struct wined3d_shader_resource_view *view = op->views[i];
1644
1645 cs->state.shader_resource_view[op->type][op->start_idx + i] = view;
1646
1647 if (view)
1648 ++view->resource->bind_count;
1649 if (prev)
1650 --prev->resource->bind_count;
1651 }
1652
1653 if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
1655 else
1657}

◆ wined3d_cs_exec_set_stream_outputs()

static void wined3d_cs_exec_set_stream_outputs ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1461 of file cs.c.

1462{
1463 const struct wined3d_cs_set_stream_outputs *op = data;
1464 unsigned int i;
1465
1466 for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
1467 {
1468 struct wined3d_buffer *prev = cs->state.stream_output[i].buffer;
1469 struct wined3d_buffer *buffer = op->outputs[i].buffer;
1470
1471 if (buffer)
1472 ++buffer->resource.bind_count;
1473 if (prev)
1474 --prev->resource.bind_count;
1475 }
1476
1477 memcpy(cs->state.stream_output, op->outputs, sizeof(op->outputs));
1479}
#define WINED3D_MAX_STREAM_OUTPUT_BUFFERS
Definition: wined3d.h:1576
#define STATE_STREAM_OUTPUT

◆ wined3d_cs_exec_set_stream_sources()

static void wined3d_cs_exec_set_stream_sources ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1426 of file cs.c.

1427{
1428 const struct wined3d_cs_set_stream_sources *op = data;
1429 unsigned int i;
1430
1431 for (i = 0; i < op->count; ++i)
1432 {
1433 struct wined3d_buffer *prev = cs->state.streams[op->start_idx + i].buffer;
1434 struct wined3d_buffer *buffer = op->streams[i].buffer;
1435
1436 if (buffer)
1437 ++buffer->resource.bind_count;
1438 if (prev)
1439 --prev->resource.bind_count;
1440 }
1441
1442 memcpy(&cs->state.streams[op->start_idx], op->streams, op->count * sizeof(*op->streams));
1444}
#define STATE_STREAMSRC

◆ wined3d_cs_exec_set_texture()

static void wined3d_cs_exec_set_texture ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1595 of file cs.c.

1596{
1597 const struct wined3d_d3d_info *d3d_info = &cs->c.device->adapter->d3d_info;
1598 const struct wined3d_cs_set_texture *op = data;
1599 struct wined3d_shader_resource_view *prev;
1600
1601 prev = cs->state.shader_resource_view[op->shader_type][op->bind_index];
1602 cs->state.shader_resource_view[op->shader_type][op->bind_index] = op->view;
1603
1604 if (op->view)
1605 {
1606 ++op->view->resource->bind_count;
1607
1608 if (op->shader_type == WINED3D_SHADER_TYPE_PIXEL)
1609 {
1610 if (texture_binding_might_invalidate_ps(op->view, prev, d3d_info))
1612 }
1613 }
1614
1615 if (prev)
1616 --prev->resource->bind_count;
1617
1619}
static bool texture_binding_might_invalidate_ps(struct wined3d_shader_resource_view *view, struct wined3d_shader_resource_view *prev, const struct wined3d_d3d_info *d3d_info)
Definition: cs.c:1563

◆ wined3d_cs_exec_set_texture_state()

static void wined3d_cs_exec_set_texture_state ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1906 of file cs.c.

1907{
1908 const struct wined3d_cs_set_texture_state *op = data;
1909
1910 cs->state.texture_states[op->stage][op->state] = op->value;
1911 device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, op->state));
1912}
#define STATE_TEXTURESTAGE(stage, num)

◆ wined3d_cs_exec_set_transform()

static void wined3d_cs_exec_set_transform ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1928 of file cs.c.

1929{
1930 const struct wined3d_cs_set_transform *op = data;
1931
1932 cs->state.transforms[op->state] = op->matrix;
1933 /* Fog behaviour depends on the projection matrix. */
1934 if (op->state == WINED3D_TS_PROJECTION
1935 && cs->state.render_states[WINED3D_RS_FOGENABLE]
1936 && cs->state.render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE)
1938}
@ WINED3D_FOG_NONE
Definition: wined3d.h:480
@ WINED3D_RS_FOGTABLEMODE
Definition: wined3d.h:318
@ WINED3D_RS_FOGENABLE
Definition: wined3d.h:311
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:668

◆ wined3d_cs_exec_set_unordered_access_views()

static void wined3d_cs_exec_set_unordered_access_views ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1676 of file cs.c.

1677{
1679 unsigned int i;
1680
1681 for (i = 0; i < op->count; ++i)
1682 {
1683 struct wined3d_unordered_access_view *prev = cs->state.unordered_access_view[op->pipeline][op->start_idx + i];
1684 struct wined3d_unordered_access_view *view = op->uavs[i].view;
1685 unsigned int initial_count = op->uavs[i].initial_count;
1686
1687 cs->state.unordered_access_view[op->pipeline][op->start_idx + i] = view;
1688
1689 if (view)
1690 ++view->resource->bind_count;
1691 if (prev)
1692 --prev->resource->bind_count;
1693
1694 if (view && initial_count != ~0u)
1696 }
1697
1699}
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view, unsigned int value)
Definition: view.c:1714
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
struct wined3d_resource * resource
#define STATE_UNORDERED_ACCESS_VIEW_BINDING(a)

◆ wined3d_cs_exec_set_vertex_declaration()

static void wined3d_cs_exec_set_vertex_declaration ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1406 of file cs.c.

1407{
1409
1410 cs->state.vertex_declaration = op->declaration;
1412}
#define STATE_VDECL

◆ wined3d_cs_exec_set_viewports()

static void wined3d_cs_exec_set_viewports ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 1258 of file cs.c.

1259{
1260 const struct wined3d_cs_set_viewports *op = data;
1261
1262 if (op->viewport_count)
1263 memcpy(cs->state.viewports, op->viewports, op->viewport_count * sizeof(*op->viewports));
1264 else
1265 memset(cs->state.viewports, 0, sizeof(*cs->state.viewports));
1266 cs->state.viewport_count = op->viewport_count;
1268}
#define STATE_VIEWPORT

◆ wined3d_cs_exec_unload_resource()

static void wined3d_cs_exec_unload_resource ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2432 of file cs.c.

2433{
2434 const struct wined3d_cs_unload_resource *op = data;
2435 struct wined3d_resource *resource = op->resource;
2436
2437 resource->resource_ops->resource_unload(resource);
2438}

◆ wined3d_cs_exec_unmap()

static void wined3d_cs_exec_unmap ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2533 of file cs.c.

2534{
2535 const struct wined3d_cs_unmap *op = data;
2536 struct wined3d_resource *resource = op->resource;
2537
2538 *op->hr = resource->resource_ops->resource_sub_resource_unmap(resource, op->sub_resource_idx);
2539}

◆ wined3d_cs_exec_update_sub_resource()

static void wined3d_cs_exec_update_sub_resource ( struct wined3d_cs *  cs,
const void *  data 
)
static

Definition at line 2739 of file cs.c.

2740{
2741 const struct wined3d_cs_update_sub_resource *op = data;
2742 struct wined3d_resource *resource = op->resource;
2743 const struct wined3d_box *box = &op->box;
2744 struct wined3d_context *context;
2745
2746 context = context_acquire(cs->c.device, NULL, 0);
2747
2748 if (resource->type == WINED3D_RTYPE_BUFFER)
2750 context, &op->bo, box->left, box->right - box->left);
2751 else
2753 op->sub_resource_idx, context, &op->bo, box, op->row_pitch, op->slice_pitch);
2754
2756
2757 if (op->bo.flags & UPLOAD_BO_FREE_ON_UNMAP)
2758 {
2759 if (op->bo.addr.buffer_object)
2760 FIXME("Free BO address %s.\n", debug_const_bo_address(&op->bo.addr));
2761 else
2762 free((void *)op->bo.addr.addr);
2763 }
2764}
void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct upload_bo *upload_bo, unsigned int offset, unsigned int size)
Definition: buffer.c:827
void wined3d_texture_update_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const struct upload_bo *upload_bo, const struct wined3d_box *box, unsigned int row_pitch, unsigned int slice_pitch)
Definition: texture.c:4440
const char * debug_const_bo_address(const struct wined3d_const_bo_address *address)
Definition: utils.c:4593
#define UPLOAD_BO_FREE_ON_UNMAP

◆ wined3d_cs_execute_next()

static bool wined3d_cs_execute_next ( struct wined3d_cs *  cs,
struct wined3d_cs_queue *  queue 
)
inlinestatic

Definition at line 3417 of file cs.c.

3418{
3419 struct wined3d_cs_packet *packet;
3420 enum wined3d_cs_op opcode;
3421 SIZE_T tail;
3422
3423 tail = queue->tail;
3425
3426 if (packet->size)
3427 {
3428 opcode = *(const enum wined3d_cs_op *)packet->data;
3429
3430 TRACE("Executing %s at %p.\n", debug_cs_op(opcode), packet);
3431 if (opcode >= WINED3D_CS_OP_STOP)
3432 {
3433 if (opcode > WINED3D_CS_OP_STOP)
3434 ERR("Invalid opcode %#x.\n", opcode);
3435 return false;
3436 }
3437
3439 wined3d_cs_op_handlers[opcode](cs, packet->data);
3441 TRACE("%s at %p executed.\n", debug_cs_op(opcode), packet);
3442 }
3443
3444 InterlockedExchange((LONG *)&queue->tail, tail);
3445 return true;
3446}
struct outqueuenode * tail
Definition: adnsresfilter.c:66
static void wined3d_cs_command_lock(const struct wined3d_cs *cs)
Definition: cs.c:3405
static void wined3d_cs_command_unlock(const struct wined3d_cs *cs)
Definition: cs.c:3411

Referenced by wined3d_cs_exec_execute_command_list(), and wined3d_cs_run().

◆ wined3d_cs_flush()

static void wined3d_cs_flush ( struct wined3d_device_context *  context)
static

Definition at line 1225 of file cs.c.

1226{
1228 struct wined3d_cs_flush *op;
1229
1231 op->opcode = WINED3D_CS_OP_FLUSH;
1232
1234 cs->queries_flushed = TRUE;
1235}
static struct wined3d_cs * wined3d_cs_from_context(struct wined3d_device_context *context)
Definition: cs.c:570

◆ wined3d_cs_from_context()

static struct wined3d_cs * wined3d_cs_from_context ( struct wined3d_device_context *  context)
static

◆ wined3d_cs_init_object()

◆ wined3d_cs_issue_query()

static void wined3d_cs_issue_query ( struct wined3d_device_context *  context,
struct wined3d_query *  query,
unsigned int  flags 
)
static

Definition at line 2355 of file cs.c.

2357{
2359 struct wined3d_cs_query_issue *op;
2360
2361 if (flags & WINED3DISSUE_END)
2362 ++query->counter_main;
2363
2365 op->opcode = WINED3D_CS_OP_QUERY_ISSUE;
2366 op->query = query;
2367 op->flags = flags;
2368
2370 cs->queries_flushed = FALSE;
2371
2373 query->state = QUERY_BUILDING;
2374 else
2375 query->state = QUERY_SIGNALLED;
2376}
struct wined3d_query * query
Definition: cs.c:439
@ QUERY_BUILDING
@ QUERY_SIGNALLED

◆ wined3d_cs_map_bo_address()

Definition at line 2586 of file cs.c.

2588{
2589 struct wined3d_device_context *context = &cs->c;
2591
2594 op->addr = *addr;
2595 op->size = size;
2596 op->flags = flags;
2599}
static void wined3d_device_context_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:558

◆ wined3d_cs_map_upload_bo()

static bool wined3d_cs_map_upload_bo ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
struct wined3d_map_desc *  map_desc,
const struct wined3d_box *  box,
uint32_t  flags 
)
static

Definition at line 3082 of file cs.c.

3084{
3085 struct wined3d_client_resource *client = &resource->client;
3086 const struct wined3d_format *format = resource->format;
3087 size_t size;
3088
3090 {
3091 struct wined3d_device *device = context->device;
3092 struct wined3d_bo_address addr;
3093 struct wined3d_bo *bo;
3095
3096 if (resource->pin_sysmem)
3097 {
3098 TRACE("Not allocating an upload buffer because system memory is pinned for this resource.\n");
3099 return false;
3100 }
3101
3102 if ((flags & WINED3D_MAP_NOOVERWRITE) && client->addr.buffer_object == CLIENT_BO_DISCARDED)
3103 flags = (flags & ~WINED3D_MAP_NOOVERWRITE) | WINED3D_MAP_DISCARD;
3104
3106 {
3107 if (!device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &addr))
3108 return false;
3109
3110 /* Limit NOOVERWRITE maps to buffers for now; there are too many
3111 * ways that a texture can be invalidated to even count. */
3112 if (resource->type == WINED3D_RTYPE_BUFFER)
3113 client->addr = addr;
3114 }
3115 else
3116 {
3117 addr = client->addr;
3118 }
3119
3120 map_ptr = NULL;
3121 if ((bo = addr.buffer_object))
3122 {
3124 if ((map_ptr = bo->map_ptr))
3125 ++bo->client_map_count;
3127
3128 if (!map_ptr)
3129 {
3130 /* adapter_alloc_bo() should have given us a mapped BO if we are
3131 * discarding. */
3133 WARN_(d3d_perf)("Not accelerating a NOOVERWRITE map because the BO is not mapped.\n");
3134 return false;
3135 }
3136 }
3137 map_ptr += (uintptr_t)addr.addr;
3138
3139 if (!map_ptr)
3140 {
3142 WARN_(d3d_perf)("Not accelerating a NOOVERWRITE map because the sub-resource has no valid address.\n");
3143 return false;
3144 }
3145
3147 &map_desc->row_pitch, &map_desc->slice_pitch);
3148
3149 client->mapped_upload.addr = *wined3d_const_bo_address(&addr);
3150 client->mapped_upload.flags = 0;
3151 if (bo)
3152 {
3153 map_ptr += bo->memory_offset;
3154 /* If we are not mapping all buffers persistently, use
3155 * UPDATE_SUB_RESOURCE as a means of telling the CS thread to try
3156 * to unmap the resource, so that we can free VA space. */
3157 if (!bo->coherent || !wined3d_map_persistent())
3158 client->mapped_upload.flags |= UPLOAD_BO_UPLOAD_ON_UNMAP;
3159 }
3160 map_desc->data = resource_offset_map_pointer(resource, sub_resource_idx, map_ptr, box);
3161
3164
3165 client->mapped_box = *box;
3166
3167 TRACE("Returning bo %s, flags %#x.\n", debug_const_bo_address(&client->mapped_upload.addr),
3168 client->mapped_upload.flags);
3169 return true;
3170 }
3171
3172 get_map_pitch(format, box, map_desc, &size);
3173
3174 if (!(map_desc->data = malloc(size)))
3175 {
3176 WARN_(d3d_perf)("Failed to allocate a heap memory buffer.\n");
3177 return false;
3178 }
3179 client->mapped_upload.addr.buffer_object = 0;
3180 client->mapped_upload.addr.addr = map_desc->data;
3182 client->mapped_box = *box;
3183 return true;
3184}
static void get_map_pitch(const struct wined3d_format *format, const struct wined3d_box *box, struct wined3d_map_desc *map_desc, size_t *size)
Definition: cs.c:3068
void * resource_offset_map_pointer(struct wined3d_resource *resource, unsigned int sub_resource_idx, uint8_t *base_memory, const struct wined3d_box *box)
Definition: resource.c:574
#define assert(_expr)
Definition: assert.h:32
unsigned int uintptr_t
Definition: corecrt.h:185
unsigned char uint8_t
Definition: stdint.h:33
#define WARN_(ch,...)
Definition: debug.h:157
size_t memory_offset
unsigned int client_map_count
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:953
#define WINED3D_MAP_NOOVERWRITE
Definition: wined3d.h:952
#define UPLOAD_BO_RENAME_ON_UNMAP
static void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource *resource, unsigned int sub_resource_idx, unsigned int *row_pitch, unsigned int *slice_pitch)
static void wined3d_device_bo_map_lock(struct wined3d_device *device)
static void wined3d_device_bo_map_unlock(struct wined3d_device *device)
static bool wined3d_map_persistent(void)
#define UPLOAD_BO_UPLOAD_ON_UNMAP

◆ wined3d_cs_mt_finish()

static void wined3d_cs_mt_finish ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3335 of file cs.c.

3336{
3338 unsigned int spin_count = 0;
3339
3340 if (cs->thread_id == GetCurrentThreadId())
3341 return wined3d_cs_st_finish(context, queue_id);
3342
3343 TRACE_(d3d_perf)("Waiting for queue %u to be empty.\n", queue_id);
3344 while (cs->queue[queue_id].head != *(volatile ULONG *)&cs->queue[queue_id].tail)
3345 wined3d_pause(&spin_count);
3346 TRACE_(d3d_perf)("Queue is now empty.\n");
3347}
static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3064
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
static void wined3d_pause(unsigned int *spin_count)

◆ wined3d_cs_mt_require_space()

static void * wined3d_cs_mt_require_space ( struct wined3d_device_context *  context,
size_t  size,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3324 of file cs.c.

3326{
3328
3329 if (cs->thread_id == GetCurrentThreadId())
3330 return wined3d_cs_st_require_space(context, size, queue_id);
3331
3332 return wined3d_cs_queue_require_space(&cs->queue[queue_id], size, cs);
3333}
static void * wined3d_cs_st_require_space(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3013
static void * wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs)
Definition: cs.c:3263

◆ wined3d_cs_mt_submit()

static void wined3d_cs_mt_submit ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3253 of file cs.c.

3254{
3256
3257 if (cs->thread_id == GetCurrentThreadId())
3258 return wined3d_cs_st_submit(context, queue_id);
3259
3260 wined3d_cs_queue_submit(&cs->queue[queue_id], cs);
3261}
static void wined3d_cs_queue_submit(struct wined3d_cs_queue *queue, struct wined3d_cs *cs)
Definition: cs.c:3234
static void wined3d_cs_st_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3041

◆ wined3d_cs_packet_decref_objects()

static void wined3d_cs_packet_decref_objects ( const struct wined3d_cs_packet *  packet)
static

Definition at line 3675 of file cs.c.

3676{
3677 enum wined3d_cs_op opcode = *(const enum wined3d_cs_op *)packet->data;
3678 unsigned int i;
3679
3680 switch (opcode)
3681 {
3683 {
3684 struct wined3d_cs_set_samplers *op = (struct wined3d_cs_set_samplers *)packet->data;
3685
3686 for (i = 0; i < op->count; ++i)
3687 {
3688 if (op->samplers[i])
3689 wined3d_sampler_decref(op->samplers[i]);
3690 }
3691 break;
3692 }
3693
3695 {
3696 struct wined3d_cs_set_shader *op = (struct wined3d_cs_set_shader *)packet->data;
3697
3698 if (op->shader)
3699 wined3d_shader_decref(op->shader);
3700 break;
3701 }
3702
3704 {
3706
3708 if (op->state)
3710 break;
3711 }
3712
3714 {
3716
3717 op = (struct wined3d_cs_set_rasterizer_state *)packet->data;
3718 if (op->state)
3720 break;
3721 }
3722
3724 {
3726
3727 op = (struct wined3d_cs_set_blend_state *)packet->data;
3728 if (op->state)
3730 break;
3731 }
3732
3734 {
3736
3738 for (i = 0; i < op->count; ++i)
3739 {
3740 if (op->views[i])
3742 }
3743 break;
3744 }
3745
3747 {
3749
3751 for (i = 0; i < op->count; ++i)
3752 {
3753 if (op->views[i])
3755 }
3756 break;
3757 }
3758
3760 {
3762
3764 for (i = 0; i < op->count; ++i)
3765 {
3766 if (op->uavs[i].view)
3768 }
3769 break;
3770 }
3771
3773 {
3775
3777 if (op->view)
3779 break;
3780 }
3781
3783 {
3785
3786 op = (struct wined3d_cs_set_constant_buffers *)packet->data;
3787 for (i = 0; i < op->count; ++i)
3788 {
3789 if (op->buffers[i].buffer)
3790 wined3d_buffer_decref(op->buffers[i].buffer);
3791 }
3792 break;
3793 }
3794
3796 {
3798
3801 break;
3802 }
3803
3805 {
3806 struct wined3d_cs_clear *op = (struct wined3d_cs_clear *)packet->data;
3807
3808 for (i = 0; i < op->rt_count; ++i)
3809 {
3810 if (op->fb.render_targets[i])
3811 wined3d_rendertarget_view_decref(op->fb.render_targets[i]);
3812 }
3813 if (op->fb.depth_stencil)
3814 wined3d_rendertarget_view_decref(op->fb.depth_stencil);
3815 break;
3816 }
3817
3819 {
3821
3822 wined3d_texture_decref(op->texture);
3823 break;
3824 }
3825
3827 {
3828 struct wined3d_cs_dispatch *op = (struct wined3d_cs_dispatch *)packet->data;
3829
3830 if (op->parameters.indirect)
3831 wined3d_buffer_decref(op->parameters.u.indirect.buffer);
3832 break;
3833 }
3834
3835 case WINED3D_CS_OP_DRAW:
3836 {
3837 struct wined3d_cs_draw *op = (struct wined3d_cs_draw *)packet->data;
3838
3839 if (op->parameters.indirect)
3840 wined3d_buffer_decref(op->parameters.u.indirect.buffer);
3841 break;
3842 }
3843
3845 {
3847
3848 op = (struct wined3d_cs_set_index_buffer *)packet->data;
3849 if (op->buffer)
3850 wined3d_buffer_decref(op->buffer);
3851 break;
3852 }
3853
3855 {
3857
3858 op = (struct wined3d_cs_set_stream_outputs *)packet->data;
3859 for (i = 0; i < ARRAY_SIZE(op->outputs); ++i)
3860 {
3861 if (op->outputs[i].buffer)
3862 wined3d_buffer_decref(op->outputs[i].buffer);
3863 }
3864 break;
3865 }
3866
3868 {
3870
3871 op = (struct wined3d_cs_set_stream_sources *)packet->data;
3872 for (i = 0; i < op->count; ++i)
3873 {
3874 if (op->streams[i].buffer)
3875 wined3d_buffer_decref(op->streams[i].buffer);
3876 }
3877 break;
3878 }
3879
3881 {
3883
3884 op = (struct wined3d_cs_update_sub_resource *)packet->data;
3885 wined3d_resource_decref(op->resource);
3886 break;
3887 }
3888
3890 {
3892
3893 op = (struct wined3d_cs_blt_sub_resource *)packet->data;
3894 if (op->src_resource)
3895 wined3d_resource_decref(op->src_resource);
3896 wined3d_resource_decref(op->dst_resource);
3897 break;
3898 }
3899
3901 {
3903
3904 op = (struct wined3d_cs_copy_uav_counter *)packet->data;
3905 wined3d_buffer_decref(op->buffer);
3907 break;
3908 }
3909
3911 {
3913
3914 op = (struct wined3d_cs_generate_mipmaps *)packet->data;
3916 break;
3917 }
3918
3919 default:
3920 break;
3921 }
3922}
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
Definition: buffer.c:459
ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state *state)
Definition: device.c:359
ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state)
Definition: device.c:284
ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state)
Definition: device.c:446
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:2588
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1606
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
Definition: view.c:1536
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
Definition: view.c:379
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
Definition: view.c:990
switch(r->id)
Definition: btrfs.c:3046
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:35

Referenced by wined3d_command_list_decref(), and wined3d_deferred_context_destroy().

◆ wined3d_cs_packet_incref_objects()

static void wined3d_cs_packet_incref_objects ( struct wined3d_cs_packet *  packet)
static

Definition at line 3924 of file cs.c.

3925{
3926 enum wined3d_cs_op opcode = *(const enum wined3d_cs_op *)packet->data;
3927 unsigned int i;
3928
3929 switch (opcode)
3930 {
3932 {
3933 struct wined3d_cs_set_samplers *op = (struct wined3d_cs_set_samplers *)packet->data;
3934
3935 for (i = 0; i < op->count; ++i)
3936 {
3937 if (op->samplers[i])
3938 wined3d_sampler_incref(op->samplers[i]);
3939 }
3940 break;
3941 }
3942
3944 {
3945 struct wined3d_cs_set_shader *op = (struct wined3d_cs_set_shader *)packet->data;
3946
3947 if (op->shader)
3948 wined3d_shader_incref(op->shader);
3949 break;
3950 }
3951
3953 {
3955
3957 if (op->state)
3959 break;
3960 }
3961
3963 {
3965
3966 op = (struct wined3d_cs_set_rasterizer_state *)packet->data;
3967 if (op->state)
3969 break;
3970 }
3971
3973 {
3975
3976 op = (struct wined3d_cs_set_blend_state *)packet->data;
3977 if (op->state)
3979 break;
3980 }
3981
3983 {
3985
3987 for (i = 0; i < op->count; ++i)
3988 {
3989 if (op->views[i])
3991 }
3992 break;
3993 }
3994
3996 {
3998
4000 for (i = 0; i < op->count; ++i)
4001 {
4002 if (op->views[i])
4004 }
4005 break;
4006 }
4007
4009 {
4011
4013 for (i = 0; i < op->count; ++i)
4014 {
4015 if (op->uavs[i].view)
4017 }
4018 break;
4019 }
4020
4022 {
4024
4026 if (op->view)
4028 break;
4029 }
4030
4032 {
4034
4035 op = (struct wined3d_cs_set_constant_buffers *)packet->data;
4036 for (i = 0; i < op->count; ++i)
4037 {
4038 if (op->buffers[i].buffer)
4039 wined3d_buffer_incref(op->buffers[i].buffer);
4040 }
4041 break;
4042 }
4043
4045 {
4047
4050 break;
4051 }
4052
4054 {
4055 struct wined3d_cs_clear *op = (struct wined3d_cs_clear *)packet->data;
4056
4057 for (i = 0; i < op->rt_count; ++i)
4058 {
4059 if (op->fb.render_targets[i])
4060 wined3d_rendertarget_view_incref(op->fb.render_targets[i]);
4061 }
4062 if (op->fb.depth_stencil)
4063 wined3d_rendertarget_view_incref(op->fb.depth_stencil);
4064 break;
4065 }
4066
4068 {
4070
4071 wined3d_texture_incref(op->texture);
4072 break;
4073 }
4074
4076 {
4077 struct wined3d_cs_dispatch *op = (struct wined3d_cs_dispatch *)packet->data;
4078
4079 if (op->parameters.indirect)
4080 wined3d_buffer_incref(op->parameters.u.indirect.buffer);
4081 break;
4082 }
4083
4084 case WINED3D_CS_OP_DRAW:
4085 {
4086 struct wined3d_cs_draw *op = (struct wined3d_cs_draw *)packet->data;
4087
4088 if (op->parameters.indirect)
4089 wined3d_buffer_incref(op->parameters.u.indirect.buffer);
4090 break;
4091 }
4092
4094 {
4096
4097 op = (struct wined3d_cs_set_index_buffer *)packet->data;
4098 if (op->buffer)
4099 wined3d_buffer_incref(op->buffer);
4100 break;
4101 }
4102
4104 {
4106
4107 op = (struct wined3d_cs_set_stream_outputs *)packet->data;
4108 for (i = 0; i < ARRAY_SIZE(op->outputs); ++i)
4109 {
4110 if (op->outputs[i].buffer)
4111 wined3d_buffer_incref(op->outputs[i].buffer);
4112 }
4113 break;
4114 }
4115
4117 {
4119
4120 op = (struct wined3d_cs_set_stream_sources *)packet->data;
4121 for (i = 0; i < op->count; ++i)
4122 {
4123 if (op->streams[i].buffer)
4124 wined3d_buffer_incref(op->streams[i].buffer);
4125 }
4126 break;
4127 }
4128
4130 {
4132
4133 op = (struct wined3d_cs_update_sub_resource *)packet->data;
4134 wined3d_resource_incref(op->resource);
4135 break;
4136 }
4137
4139 {
4141
4142 op = (struct wined3d_cs_blt_sub_resource *)packet->data;
4143 if (op->src_resource)
4144 wined3d_resource_incref(op->src_resource);
4145 wined3d_resource_incref(op->dst_resource);
4146 break;
4147 }
4148
4150 {
4152
4153 op = (struct wined3d_cs_copy_uav_counter *)packet->data;
4154 wined3d_buffer_incref(op->buffer);
4156 break;
4157 }
4158
4160 {
4162
4163 op = (struct wined3d_cs_generate_mipmaps *)packet->data;
4165 break;
4166 }
4167
4168 default:
4169 break;
4170 }
4171}
ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
Definition: buffer.c:248
ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state)
Definition: device.c:268
ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *state)
Definition: device.c:430
ULONG CDECL wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state *state)
Definition: device.c:343
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:2535
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:1516
ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view)
Definition: view.c:965
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
Definition: view.c:365
ULONG CDECL wined3d_unordered_access_view_incref(struct wined3d_unordered_access_view *view)
Definition: view.c:1522
ULONG CDECL wined3d_sampler_incref(struct wined3d_sampler *sampler)
Definition: sampler.c:26
static ULONG wined3d_resource_incref(struct wined3d_resource *resource)

Referenced by wined3d_deferred_context_submit().

◆ wined3d_cs_queue_is_empty()

static BOOL wined3d_cs_queue_is_empty ( const struct wined3d_cs *  cs,
const struct wined3d_cs_queue *  queue 
)
static

Definition at line 3228 of file cs.c.

3229{
3231 return *(volatile ULONG *)&queue->head == queue->tail;
3232}
static void wined3d_from_cs(const struct wined3d_cs *cs)

Referenced by wined3d_cs_exec_execute_command_list(), wined3d_cs_run(), and wined3d_cs_wait_event().

◆ wined3d_cs_queue_require_space()

static void * wined3d_cs_queue_require_space ( struct wined3d_cs_queue *  queue,
size_t  size,
struct wined3d_cs *  cs 
)
static

Definition at line 3263 of file cs.c.

3264{
3265 size_t queue_size = ARRAY_SIZE(queue->data);
3266 size_t header_size, packet_size, remaining;
3267 struct wined3d_cs_packet *packet;
3269
3270 header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]);
3271 packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]);
3272 packet_size = (packet_size + header_size - 1) & ~(header_size - 1);
3273 size = packet_size - header_size;
3274 if (packet_size >= WINED3D_CS_QUEUE_SIZE)
3275 {
3276 ERR("Packet size %Iu >= queue size %u.\n", packet_size, WINED3D_CS_QUEUE_SIZE);
3277 return NULL;
3278 }
3279
3280 remaining = queue_size - head;
3281 if (remaining < packet_size)
3282 {
3283 size_t nop_size = remaining - header_size;
3284 struct wined3d_cs_nop *nop;
3285
3286 TRACE("Inserting a nop for %Iu + %Iu bytes.\n", header_size, nop_size);
3287
3288 nop = wined3d_cs_queue_require_space(queue, nop_size, cs);
3289 if (nop_size)
3291
3294 assert(!head);
3295 }
3296
3297 for (;;)
3298 {
3299 ULONG tail = (*(volatile ULONG *)&queue->tail) & WINED3D_CS_QUEUE_MASK;
3300 ULONG new_pos;
3301
3302 /* Empty. */
3303 if (head == tail)
3304 break;
3305 new_pos = (head + packet_size) & WINED3D_CS_QUEUE_MASK;
3306 /* Head ahead of tail. We checked the remaining size above, so we only
3307 * need to make sure we don't make head equal to tail. */
3308 if (head > tail && (new_pos != tail))
3309 break;
3310 /* Tail ahead of head. Make sure the new head is before the tail as
3311 * well. Note that new_pos is 0 when it's at the end of the queue. */
3312 if (new_pos < tail && new_pos)
3313 break;
3314
3315 TRACE_(d3d_perf)("Waiting for free space. Head %lu, tail %lu, packet size %Iu.\n",
3316 head, tail, packet_size);
3317 }
3318
3319 packet = (struct wined3d_cs_packet *)&queue->data[head];
3320 packet->size = size;
3321 return packet->data;
3322}
struct outqueuenode * head
Definition: adnsresfilter.c:66
enum wined3d_cs_op opcode
Definition: cs.c:155
#define WINED3D_CS_QUEUE_SIZE

Referenced by wined3d_cs_mt_require_space(), and wined3d_cs_queue_require_space().

◆ wined3d_cs_queue_submit()

static void wined3d_cs_queue_submit ( struct wined3d_cs_queue *  queue,
struct wined3d_cs *  cs 
)
static

Definition at line 3234 of file cs.c.

3235{
3236 struct wined3d_cs_packet *packet;
3237 size_t packet_size;
3238
3239 packet = (struct wined3d_cs_packet *)&queue->data[queue->head & WINED3D_CS_QUEUE_MASK];
3240 TRACE("Queuing op %s at %p.\n", debug_cs_op(*(const enum wined3d_cs_op *)packet->data), packet);
3241 packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[packet->size]);
3242 InterlockedExchange((LONG *)&queue->head, queue->head + packet_size);
3243
3244 if (InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE))
3245 {
3246 if (pNtAlertThreadByThreadId)
3247 pNtAlertThreadByThreadId((HANDLE)(ULONG_PTR)cs->thread_id);
3248 else
3249 SetEvent(cs->event);
3250 }
3251}

Referenced by wined3d_cs_mt_submit(), and wined3d_cs_queue_require_space().

◆ wined3d_cs_reference_command_list()

static void wined3d_cs_reference_command_list ( struct wined3d_device_context *  context,
struct wined3d_command_list *  list 
)
static

Definition at line 2378 of file cs.c.

2379{
2381 SIZE_T i;
2382
2383 if (list->query_count)
2384 {
2385 cs->queries_flushed = FALSE;
2386
2387 for (i = 0; i < list->query_count; ++i)
2388 {
2389 if (list->queries[i].flags & WINED3DISSUE_END)
2390 {
2391 list->queries[i].query->counter_main++;
2392 list->queries[i].query->state = QUERY_SIGNALLED;
2393 }
2394 else
2395 {
2396 list->queries[i].query->state = QUERY_BUILDING;
2397 }
2398 }
2399 }
2400
2401 for (i = 0; i < list->resource_count; ++i)
2402 wined3d_resource_reference(list->resources[i]);
2403
2404 for (i = 0; i < list->command_list_count; ++i)
2406
2407 for (i = 0; i < list->upload_count; ++i)
2408 invalidate_client_address(list->uploads[i].resource);
2409}
static void invalidate_client_address(struct wined3d_resource *resource)
Definition: cs.c:85
static void wined3d_cs_reference_command_list(struct wined3d_device_context *context, struct wined3d_command_list *list)
Definition: cs.c:2378

Referenced by wined3d_cs_reference_command_list().

◆ wined3d_cs_reference_resource()

static void wined3d_cs_reference_resource ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource 
)
static

Definition at line 2933 of file cs.c.

◆ wined3d_cs_run()

static DWORD WINAPI wined3d_cs_run ( void *  ctx)
static

Definition at line 3477 of file cs.c.

3478{
3479 struct wined3d_cs_queue *queue;
3480 unsigned int spin_count = 0;
3481 struct wined3d_cs *cs = ctx;
3483 unsigned int poll = 0;
3484 bool run = true;
3485
3486 TRACE("Started.\n");
3487 SetThreadDescription(GetCurrentThread(), L"wined3d_cs");
3488
3489 /* Copy the module handle to a local variable to avoid racing with the
3490 * thread freeing "cs" before the FreeLibraryAndExitThread() call. */
3491 wined3d_module = cs->wined3d_module;
3492
3493 list_init(&cs->query_poll_list);
3494 cs->thread_id = GetCurrentThreadId();
3495 while (run)
3496 {
3498 {
3502 poll = 0;
3503 }
3504
3505 queue = &cs->queue[WINED3D_CS_QUEUE_MAP];
3507 {
3510 {
3512 if (++spin_count >= WINED3D_CS_SPIN_COUNT)
3513 {
3514 if (poll)
3516 else
3518 }
3519 continue;
3520 }
3521 }
3522 spin_count = 0;
3523
3525 }
3526
3527 cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head;
3528 cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head;
3529 TRACE("Stopped.\n");
3531}
HRESULT WINAPI DECLSPEC_HOTPATCH SetThreadDescription(_In_ HANDLE hThread, _In_ PCWSTR lpThreadDescription)
static void poll_queries(struct wined3d_cs *cs)
Definition: cs.c:3362
static void wined3d_cs_wait_event(struct wined3d_cs *cs)
Definition: cs.c:3377
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:507
#define YieldProcessor
Definition: ke.h:48
HMODULE wined3d_module
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1195
#define WINED3D_CS_SPIN_COUNT
#define WINED3D_CS_QUERY_POLL_INTERVAL

Referenced by wined3d_cs_create().

◆ wined3d_cs_st_finish()

static void wined3d_cs_st_finish ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3064 of file cs.c.

3065{
3066}

Referenced by wined3d_cs_mt_finish().

◆ wined3d_cs_st_require_space()

static void * wined3d_cs_st_require_space ( struct wined3d_device_context *  context,
size_t  size,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3013 of file cs.c.

3015{
3017
3018 if (size > (cs->data_size - cs->end))
3019 {
3020 size_t new_size;
3021 void *new_data;
3022
3023 new_size = max(size, cs->data_size * 2);
3024 if (!cs->end)
3025 new_data = realloc(cs->data, new_size);
3026 else
3027 new_data = malloc(new_size);
3028 if (!new_data)
3029 return NULL;
3030
3031 cs->data_size = new_size;
3032 cs->start = cs->end = 0;
3033 cs->data = new_data;
3034 }
3035
3036 cs->end += size;
3037
3038 return (BYTE *)cs->data + cs->start;
3039}
#define realloc
Definition: debug_ros.c:6
size_t const new_size
Definition: expand.cpp:66
#define max(a, b)
Definition: svc.c:63

Referenced by wined3d_cs_mt_require_space().

◆ wined3d_cs_st_submit()

static void wined3d_cs_st_submit ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 3041 of file cs.c.

3042{
3044 enum wined3d_cs_op opcode;
3045 size_t start;
3046 BYTE *data;
3047
3048 data = cs->data;
3049 start = cs->start;
3050 cs->start = cs->end;
3051
3052 opcode = *(const enum wined3d_cs_op *)&data[start];
3053 if (opcode >= WINED3D_CS_OP_STOP)
3054 ERR("Invalid opcode %#x.\n", opcode);
3055 else
3056 wined3d_cs_op_handlers[opcode](cs, &data[start]);
3057
3058 if (cs->data == data)
3059 cs->start = cs->end = start;
3060 else if (!start)
3061 free(data);
3062}

Referenced by wined3d_cs_mt_submit().

◆ wined3d_cs_unmap_upload_bo()

static bool wined3d_cs_unmap_upload_bo ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
struct wined3d_box *  box,
struct upload_bo *  upload_bo 
)
static

Definition at line 3191 of file cs.c.

3193{
3194 struct wined3d_client_resource *client = &resource->client;
3195 struct wined3d_device *device = context->device;
3196 struct wined3d_bo *bo;
3197
3198 if (wined3d_bo_address_is_null(&client->mapped_upload.addr))
3199 return false;
3200
3201 if ((bo = client->mapped_upload.addr.buffer_object))
3202 {
3204 --bo->client_map_count;
3206 }
3207
3208 *upload_bo = client->mapped_upload;
3209 *box = client->mapped_box;
3210 memset(&client->mapped_upload, 0, sizeof(client->mapped_upload));
3211 memset(&client->mapped_box, 0, sizeof(client->mapped_box));
3212 return true;
3213}
static bool wined3d_bo_address_is_null(struct wined3d_const_bo_address *addr)
Definition: cs.c:3186

◆ wined3d_cs_wait_event()

static void wined3d_cs_wait_event ( struct wined3d_cs *  cs)
static

Definition at line 3377 of file cs.c.

3378{
3379 static const LARGE_INTEGER query_timeout = {.QuadPart = WINED3D_CS_COMMAND_WAIT_WITH_QUERIES_TIMEOUT * -10};
3380 const LARGE_INTEGER *timeout = NULL;
3381
3382 if (!list_empty(&cs->query_poll_list))
3383 timeout = &query_timeout;
3384
3385 InterlockedExchange(&cs->waiting_for_event, TRUE);
3386
3387 /* The main thread might have enqueued a command and blocked on it after
3388 * the CS thread decided to enter wined3d_cs_wait_event(), but before
3389 * "waiting_for_event" was set.
3390 *
3391 * Likewise, we can race with the main thread when resetting
3392 * "waiting_for_event", in which case we would need to call
3393 * WaitForSingleObject() because the main thread called SetEvent(). */
3396 && InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE))
3397 return;
3398
3399 if (pNtWaitForAlertByThreadId)
3400 pNtWaitForAlertByThreadId(NULL, timeout);
3401 else
3403}
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
Definition: dhcpd.h:248
#define WINED3D_CS_COMMAND_WAIT_WITH_QUERIES_TIMEOUT

Referenced by wined3d_cs_run().

◆ wined3d_deferred_context_create()

HRESULT CDECL wined3d_deferred_context_create ( struct wined3d_device *  device,
struct wined3d_device_context **  context 
)

Definition at line 4443 of file cs.c.

4444{
4446 HRESULT hr;
4447
4448 TRACE("device %p, context %p.\n", device, context);
4449
4450 if (!(object = calloc(1, sizeof(*object))))
4451 return E_OUTOFMEMORY;
4452
4453 if (FAILED(hr = wined3d_state_create(device, &device->cs->c.state->feature_level, 1, &object->c.state)))
4454 {
4455 free(object);
4456 return hr;
4457 }
4458
4459 object->c.ops = &wined3d_deferred_context_ops;
4460 object->c.device = device;
4461
4462 /* Make sure the first command list gets the state reset when executed.
4463 * Resets for subsequent command lists are encoded in wined3d_deferred_context_record_command_list(). */
4465
4466 TRACE("Created deferred context %p.\n", object);
4467 *context = &object->c;
4468
4469 return S_OK;
4470}
static const struct wined3d_device_context_ops wined3d_deferred_context_ops
Definition: cs.c:4430
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate)
Definition: cs.c:2269
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:52

Referenced by d3d11_deferred_context_create().

◆ wined3d_deferred_context_destroy()

void CDECL wined3d_deferred_context_destroy ( struct wined3d_device_context *  context)

Definition at line 4472 of file cs.c.

4473{
4475 const struct wined3d_cs_packet *packet;
4476 SIZE_T i, offset = 0;
4477
4478 TRACE("context %p.\n", context);
4479
4480 for (i = 0; i < deferred->resource_count; ++i)
4482 free(deferred->resources);
4483
4484 for (i = 0; i < deferred->upload_count; ++i)
4485 {
4486 wined3d_resource_decref(deferred->uploads[i].resource);
4487 HeapFree(deferred->upload_heap, 0, deferred->uploads[i].resource);
4488 }
4489
4490 if (deferred->upload_heap)
4491 {
4493 {
4494 HeapDestroy(deferred->upload_heap);
4495 free(deferred->upload_heap_refcount);
4496 }
4497 }
4498
4499 free(deferred->uploads);
4500
4501 for (i = 0; i < deferred->command_list_count; ++i)
4503 free(deferred->command_lists);
4504
4505 for (i = 0; i < deferred->query_count; ++i)
4506 wined3d_query_decref(deferred->queries[i].query);
4507 free(deferred->queries);
4508
4509 while (offset < deferred->data_size)
4510 {
4511 packet = wined3d_next_cs_packet(deferred->data, &offset, ~(SIZE_T)0);
4513 }
4514
4515 wined3d_state_destroy(deferred->c.state);
4516 free(deferred->data);
4517 free(deferred);
4518}
static struct wined3d_deferred_context * wined3d_deferred_context_from_context(struct wined3d_device_context *context)
Definition: cs.c:4199
SIZE_T command_list_count
Definition: cs.c:4192
struct wined3d_resource ** resources
Definition: cs.c:4181
struct wined3d_deferred_query_issue * queries
Definition: cs.c:4196
struct wined3d_command_list ** command_lists
Definition: cs.c:4193
LONG * upload_heap_refcount
Definition: cs.c:4187
SIZE_T resource_count
Definition: cs.c:4180
struct wined3d_device_context c
Definition: cs.c:4175

Referenced by d3d11_device_context_Release().

◆ wined3d_deferred_context_finish()

static void wined3d_deferred_context_finish ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 4237 of file cs.c.

4238{
4239 /* This should not happen; we cannot meaningfully finish a deferred context. */
4240 ERR("Ignoring finish() on a deferred context.\n");
4241}

◆ wined3d_deferred_context_flush()

static void wined3d_deferred_context_flush ( struct wined3d_device_context *  context)
static

Definition at line 4398 of file cs.c.

4399{
4400 FIXME("context %p, stub!\n", context);
4401}

◆ wined3d_deferred_context_from_context()

◆ wined3d_deferred_context_issue_query()

static void wined3d_deferred_context_issue_query ( struct wined3d_device_context *  context,
struct wined3d_query *  query,
unsigned int  flags 
)
static

Definition at line 4374 of file cs.c.

4376{
4378 struct wined3d_cs_query_issue *op;
4379
4381 op->opcode = WINED3D_CS_OP_QUERY_ISSUE;
4382 op->query = query;
4383 op->flags = flags;
4384
4386
4387 if (!wined3d_array_reserve((void **)&deferred->queries, &deferred->queries_capacity,
4388 deferred->query_count + 1, sizeof(*deferred->queries)))
4389 {
4390 ERR("Failed to reserve memory.\n");
4391 return;
4392 }
4393
4394 deferred->queries[deferred->query_count].flags = flags;
4395 wined3d_query_incref(deferred->queries[deferred->query_count++].query = query);
4396}
ULONG CDECL wined3d_query_incref(struct wined3d_query *query)
Definition: query.c:413
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: utils.c:6740
SIZE_T queries_capacity
Definition: cs.c:4195

◆ wined3d_deferred_context_map_upload_bo()

static bool wined3d_deferred_context_map_upload_bo ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
struct wined3d_map_desc *  map_desc,
const struct wined3d_box *  box,
uint32_t  flags 
)
static

Definition at line 4259 of file cs.c.

4262{
4264 const struct wined3d_format *format = resource->format;
4265 struct wined3d_device *device = context->device;
4266 struct wined3d_deferred_upload *upload;
4267 struct wined3d_bo_address addr;
4268 uint8_t *sysmem;
4269 size_t size;
4270
4271 get_map_pitch(format, box, map_desc, &size);
4272
4273 if (!(flags & WINED3D_MAP_WRITE))
4274 {
4275 WARN("Flags %#x are not valid on a deferred context.\n", flags);
4276 return false;
4277 }
4278
4280 {
4281 FIXME("Unhandled flags %#x.\n", flags);
4282 return false;
4283 }
4284
4286 {
4287 if (!(upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
4288 return false;
4289
4290 upload->upload_flags = 0;
4291 map_desc->data = upload->map_ptr;
4292 return true;
4293 }
4294
4295 if (!wined3d_array_reserve((void **)&deferred->uploads, &deferred->uploads_capacity,
4296 deferred->upload_count + 1, sizeof(*deferred->uploads)))
4297 return false;
4298
4299 upload = &deferred->uploads[deferred->upload_count++];
4300
4302 && device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &addr))
4303 {
4304 upload->bo = addr.buffer_object;
4305 upload->sysmem = NULL;
4306
4307 TRACE("Allocated BO %s.\n", debug_bo_address(&addr));
4308
4310 upload->map_ptr = addr.buffer_object->map_ptr;
4312 upload->map_ptr += addr.buffer_object->memory_offset;
4313 assert(upload->map_ptr);
4314 }
4315 else
4316 {
4317 if (!deferred->upload_heap)
4318 {
4319 if (!(deferred->upload_heap = HeapCreate(0, 0, 0)))
4320 {
4321 ERR("Failed to create upload heap.\n");
4322 return false;
4323 }
4324
4325 if (!(deferred->upload_heap_refcount = malloc(sizeof(*deferred->upload_heap_refcount))))
4326 {
4327 HeapDestroy(deferred->upload_heap);
4328 deferred->upload_heap = 0;
4329 return false;
4330 }
4331
4332 *deferred->upload_heap_refcount = 1;
4333 }
4334
4335 if (!(sysmem = HeapAlloc(deferred->upload_heap, 0, size + RESOURCE_ALIGNMENT - 1)))
4336 return false;
4337
4338 upload->bo = NULL;
4339 upload->sysmem = sysmem;
4340 upload->map_ptr = (void *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
4341 }
4342
4344 upload->resource = resource;
4346 upload->sub_resource_idx = sub_resource_idx;
4347 upload->box = *box;
4348
4349 map_desc->data = upload->map_ptr;
4350 return true;
4351}
static struct wined3d_deferred_upload * deferred_context_get_upload(struct wined3d_deferred_context *deferred, struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: cs.c:4243
const char * debug_bo_address(const struct wined3d_bo_address *address)
Definition: utils.c:4600
#define HeapAlloc
Definition: compat.h:733
HANDLE WINAPI HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
Definition: heapmem.c:45
SIZE_T uploads_capacity
Definition: cs.c:4183
struct wined3d_box box
Definition: cs.c:39
struct wined3d_bo * bo
Definition: cs.c:37
uint8_t * sysmem
Definition: cs.c:38
uint8_t * map_ptr
Definition: cs.c:38
uint32_t upload_flags
Definition: cs.c:40
#define WINED3D_MAP_WRITE
Definition: wined3d.h:956
#define RESOURCE_ALIGNMENT
static size_t align(size_t addr, size_t alignment)

◆ wined3d_deferred_context_record_command_list()

HRESULT CDECL wined3d_deferred_context_record_command_list ( struct wined3d_device_context *  context,
bool  restore,
struct wined3d_command_list **  list 
)

Definition at line 4520 of file cs.c.

4522{
4525 void *memory;
4526
4527 TRACE("context %p, list %p.\n", context, list);
4528
4530 memory = malloc(sizeof(*object) + deferred->resource_count * sizeof(*object->resources)
4531 + deferred->upload_count * sizeof(*object->uploads)
4532 + deferred->command_list_count * sizeof(*object->command_lists)
4533 + deferred->query_count * sizeof(*object->queries)
4534 + deferred->data_size);
4535
4536 if (!memory)
4537 {
4539 return E_OUTOFMEMORY;
4540 }
4541
4542 object = memory;
4543 memory = &object[1];
4544 memset(object, 0, sizeof(*object));
4545 object->refcount = 1;
4546 object->device = deferred->c.device;
4547
4548 object->resources = memory;
4549 memory = &object->resources[deferred->resource_count];
4550 object->resource_count = deferred->resource_count;
4551 memcpy(object->resources, deferred->resources, deferred->resource_count * sizeof(*object->resources));
4552 /* Transfer our references to the resources to the command list. */
4553
4554 object->uploads = memory;
4555 memory = &object->uploads[deferred->upload_count];
4556 object->upload_count = deferred->upload_count;
4557 memcpy(object->uploads, deferred->uploads, deferred->upload_count * sizeof(*object->uploads));
4558 /* Transfer our references to the resources to the command list. */
4559
4560 object->command_lists = memory;
4561 memory = &object->command_lists[deferred->command_list_count];
4562 object->command_list_count = deferred->command_list_count;
4563 memcpy(object->command_lists, deferred->command_lists,
4564 deferred->command_list_count * sizeof(*object->command_lists));
4565 /* Transfer our references to the command lists to the command list. */
4566
4567 object->queries = memory;
4568 memory = &object->queries[deferred->query_count];
4569 object->query_count = deferred->query_count;
4570 memcpy(object->queries, deferred->queries, deferred->query_count * sizeof(*object->queries));
4571 /* Transfer our references to the queries to the command list. */
4572
4573 object->data = memory;
4574 object->data_size = deferred->data_size;
4575 memcpy(object->data, deferred->data, deferred->data_size);
4576
4577 deferred->data_size = 0;
4578 deferred->resource_count = 0;
4579 deferred->upload_count = 0;
4580 deferred->command_list_count = 0;
4581 deferred->query_count = 0;
4582
4583 object->upload_heap = deferred->upload_heap;
4584 if ((object->upload_heap_refcount = deferred->upload_heap_refcount))
4585 InterlockedIncrement(object->upload_heap_refcount);
4586
4587 /* This is in fact recorded into a subsequent command list. */
4588 if (restore)
4589 wined3d_device_context_set_state(&deferred->c, deferred->c.state);
4590 else
4592
4593 TRACE("Created command list %p.\n", object);
4594 *list = object;
4596
4597 return S_OK;
4598}
void CDECL wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state)
Definition: device.c:1915
void CDECL wined3d_device_context_reset_state(struct wined3d_device_context *context)
Definition: device.c:1904
static char memory[1024 *256]
Definition: process.c:122
static void wined3d_device_context_unlock(struct wined3d_device_context *context)
static void wined3d_device_context_lock(struct wined3d_device_context *context)

Referenced by d3d11_device_context_FinishCommandList().

◆ wined3d_deferred_context_reference_command_list()

static void wined3d_deferred_context_reference_command_list ( struct wined3d_device_context *  context,
struct wined3d_command_list *  list 
)
static

Definition at line 4416 of file cs.c.

4418{
4420
4421 /* Grab a reference to the command list. Note that this implicitly prevents
4422 * any dependent command lists or resources from being freed as well. */
4423 if (!wined3d_array_reserve((void **)&deferred->command_lists, &deferred->command_lists_capacity,
4424 deferred->command_list_count + 1, sizeof(*deferred->command_lists)))
4425 return;
4426
4428}
ULONG CDECL wined3d_command_list_incref(struct wined3d_command_list *list)
Definition: cs.c:4642
SIZE_T command_lists_capacity
Definition: cs.c:4192

◆ wined3d_deferred_context_reference_resource()

static void wined3d_deferred_context_reference_resource ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource 
)
static

Definition at line 4403 of file cs.c.

4405{
4407
4408 if (!wined3d_array_reserve((void **)&deferred->resources, &deferred->resources_capacity,
4409 deferred->resource_count + 1, sizeof(*deferred->resources)))
4410 return;
4411
4412 deferred->resources[deferred->resource_count++] = resource;
4414}
SIZE_T resources_capacity
Definition: cs.c:4180

◆ wined3d_deferred_context_require_space()

static void * wined3d_deferred_context_require_space ( struct wined3d_device_context *  context,
size_t  size,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 4204 of file cs.c.

4206{
4208 struct wined3d_cs_packet *packet;
4209 size_t header_size, packet_size;
4210
4211 if (queue_id != WINED3D_CS_QUEUE_DEFAULT)
4212 return NULL;
4213
4214 header_size = offsetof(struct wined3d_cs_packet, data[0]);
4215 packet_size = offsetof(struct wined3d_cs_packet, data[size]);
4216 packet_size = (packet_size + header_size - 1) & ~(header_size - 1);
4217
4218 if (!wined3d_array_reserve(&deferred->data, &deferred->data_capacity, deferred->data_size + packet_size, 1))
4219 return NULL;
4220
4221 packet = (struct wined3d_cs_packet *)((BYTE *)deferred->data + deferred->data_size);
4222 TRACE("size was %Iu, adding %Iu\n", (size_t)deferred->data_size, packet_size);
4223 packet->size = packet_size - header_size;
4224 return &packet->data;
4225}
#define offsetof(TYPE, MEMBER)
SIZE_T data_capacity
Definition: cs.c:4177

◆ wined3d_deferred_context_submit()

static void wined3d_deferred_context_submit ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
static

Definition at line 4227 of file cs.c.

4228{
4230 struct wined3d_cs_packet *packet;
4231
4232 assert(queue_id == WINED3D_CS_QUEUE_DEFAULT);
4233 packet = wined3d_next_cs_packet(deferred->data, &deferred->data_size, ~(SIZE_T)0);
4235}
static void wined3d_cs_packet_incref_objects(struct wined3d_cs_packet *packet)
Definition: cs.c:3924

◆ wined3d_deferred_context_unmap_upload_bo()

static bool wined3d_deferred_context_unmap_upload_bo ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
struct wined3d_box *  box,
struct upload_bo *  bo 
)
static

Definition at line 4353 of file cs.c.

4355{
4357 struct wined3d_deferred_upload *upload;
4358
4359 if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
4360 {
4361 *box = upload->box;
4362 if ((bo->addr.buffer_object = upload->bo))
4363 bo->addr.addr = NULL;
4364 else
4365 bo->addr.addr = upload->map_ptr;
4366 bo->flags = upload->upload_flags;
4367 upload->upload_flags = 0;
4368 return true;
4369 }
4370
4371 return false;
4372}

◆ wined3d_device_context_clear_sysmem_texture()

HRESULT CDECL wined3d_device_context_clear_sysmem_texture ( struct wined3d_device_context *  context,
struct wined3d_texture *  texture,
unsigned int  sub_resource_idx,
const RECT *  rect,
unsigned int  flags,
const struct wined3d_color *  color 
)

Definition at line 896 of file cs.c.

899{
901
902 TRACE("context %p, texture %p, sub_resource_idx %u, rect %s, flags %#x, color %s.\n",
904
905 if (rect)
906 {
907 struct wined3d_box b = {rect->left, rect->top, rect->right, rect->bottom, 0, 1};
908 HRESULT hr;
909
910 if (FAILED(hr = wined3d_resource_check_box_dimensions(&texture->resource, sub_resource_idx, &b)))
911 return hr;
912 }
913
915
918 op->texture = texture;
919 op->sub_resource_idx = sub_resource_idx;
920 op->color = *color;
921
922 if (rect)
923 {
924 op->rect = *rect;
925 }
926 else
927 {
928 unsigned int level_idx = sub_resource_idx % texture->level_count;
929
930 op->rect.left = 0;
931 op->rect.top = 0;
932 op->rect.right = wined3d_texture_get_level_width(texture, level_idx);
933 op->rect.bottom = wined3d_texture_get_level_height(texture, level_idx);
934 }
935
937
941
943 return S_OK;
944}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
HRESULT wined3d_resource_check_box_dimensions(struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box)
Definition: resource.c:488
const char * debug_color(const struct wined3d_color *color)
Definition: utils.c:4561
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
unsigned int sub_resource_idx
Definition: cs.c:187
#define WINED3DCLEAR_SYNCHRONOUS
Definition: wined3d.h:1011

Referenced by ddraw_surface_blt().

◆ wined3d_device_context_dispatch()

void CDECL wined3d_device_context_dispatch ( struct wined3d_device_context *  context,
unsigned int  group_count_x,
unsigned int  group_count_y,
unsigned int  group_count_z 
)

Definition at line 1030 of file cs.c.

1032{
1033 struct wined3d_cs_dispatch *op;
1034
1037 op->opcode = WINED3D_CS_OP_DISPATCH;
1038 op->parameters.indirect = FALSE;
1039 op->parameters.u.direct.group_count_x = group_count_x;
1040 op->parameters.u.direct.group_count_y = group_count_y;
1041 op->parameters.u.direct.group_count_z = group_count_z;
1042
1044
1047}
static void reference_compute_pipeline_resources(struct wined3d_device_context *context)
Definition: cs.c:1021

Referenced by d3d11_device_context_Dispatch().

◆ wined3d_device_context_dispatch_indirect()

void CDECL wined3d_device_context_dispatch_indirect ( struct wined3d_device_context *  context,
struct wined3d_buffer *  buffer,
unsigned int  offset 
)

Definition at line 1049 of file cs.c.

1051{
1052 struct wined3d_cs_dispatch *op;
1053
1056 op->opcode = WINED3D_CS_OP_DISPATCH;
1057 op->parameters.indirect = TRUE;
1058 op->parameters.u.indirect.buffer = buffer;
1059 op->parameters.u.indirect.offset = offset;
1060
1063
1066}

Referenced by d3d11_device_context_DispatchIndirect().

◆ wined3d_device_context_draw_indirect()

void CDECL wined3d_device_context_draw_indirect ( struct wined3d_device_context *  context,
struct wined3d_buffer *  buffer,
unsigned int  offset,
bool  indexed 
)

Definition at line 1191 of file cs.c.

1193{
1194 const struct wined3d_d3d_info *d3d_info = &context->device->adapter->d3d_info;
1195 const struct wined3d_state *state = context->state;
1196 struct wined3d_cs_draw *op;
1197
1200 op->opcode = WINED3D_CS_OP_DRAW;
1201 op->primitive_type = state->primitive_type;
1202 op->patch_vertex_count = state->patch_vertex_count;
1203 op->parameters.indirect = TRUE;
1204 op->parameters.u.indirect.buffer = buffer;
1205 op->parameters.u.indirect.offset = offset;
1206 op->parameters.indexed = indexed;
1207
1210
1213}
static void reference_graphics_pipeline_resources(struct wined3d_device_context *context, BOOL indexed, const struct wined3d_d3d_info *d3d_info)
Definition: cs.c:1131

Referenced by d3d11_device_context_DrawIndexedInstancedIndirect(), and d3d11_device_context_DrawInstancedIndirect().

◆ wined3d_device_context_emit_blt_sub_resource()

void wined3d_device_context_emit_blt_sub_resource ( struct wined3d_device_context *  context,
struct wined3d_resource *  dst_resource,
unsigned int  dst_sub_resource_idx,
const struct wined3d_box *  dst_box,
struct wined3d_resource *  src_resource,
unsigned int  src_sub_resource_idx,
const struct wined3d_box *  src_box,
unsigned int  flags,
const struct wined3d_blt_fx *  fx,
enum wined3d_texture_filter_type  filter 
)

Definition at line 2703 of file cs.c.

2707{
2709
2710 /* If we are replacing the whole resource, the CS thread might discard and
2711 * rename the buffer object, in which case ours is no longer valid. */
2712 if (dst_resource->type == WINED3D_RTYPE_BUFFER && dst_box->right - dst_box->left == dst_resource->size)
2714
2717 op->dst_resource = dst_resource;
2718 op->dst_sub_resource_idx = dst_sub_resource_idx;
2719 op->dst_box = *dst_box;
2720 op->src_resource = src_resource;
2721 op->src_sub_resource_idx = src_sub_resource_idx;
2722 op->src_box = *src_box;
2723 op->flags = flags;
2724 if (fx)
2725 op->fx = *fx;
2726 else
2727 memset(&op->fx, 0, sizeof(op->fx));
2728 op->filter = filter;
2729
2731 if (src_resource)
2733
2737}
struct wined3d_resource * dst_resource
Definition: cs.c:485
struct wined3d_box src_box
Definition: cs.c:490
struct wined3d_resource * src_resource
Definition: cs.c:488
unsigned int src_sub_resource_idx
Definition: cs.c:489
struct wined3d_box dst_box
Definition: cs.c:487
enum wined3d_texture_filter_type filter
Definition: cs.c:493
unsigned int dst_sub_resource_idx
Definition: cs.c:486
GLfixed fx
Definition: tritemp.h:484
#define WINED3D_BLT_SYNCHRONOUS
Definition: wined3d.h:1372

Referenced by wined3d_device_context_blt(), wined3d_device_context_copy_resource(), wined3d_device_context_copy_sub_resource_region(), and wined3d_device_update_texture().

◆ wined3d_device_context_emit_clear_rendertarget_view()

void wined3d_device_context_emit_clear_rendertarget_view ( struct wined3d_device_context *  context,
struct wined3d_rendertarget_view *  view,
const RECT *  rect,
unsigned int  flags,
const struct wined3d_color *  color,
float  depth,
unsigned int  stencil 
)

Definition at line 844 of file cs.c.

847{
848 struct wined3d_cs_clear *op;
849 size_t size;
850
853
854 op->opcode = WINED3D_CS_OP_CLEAR;
857 {
858 op->rt_count = 1;
859 op->fb.render_targets[0] = view;
860 op->fb.depth_stencil = NULL;
861 op->color = *color;
862 }
863 else
864 {
865 op->rt_count = 0;
866 op->fb.render_targets[0] = NULL;
867 op->fb.depth_stencil = view;
868 op->depth = depth;
869 op->stencil = stencil;
870 }
871 SetRect(&op->draw_rect, 0, 0, view->width, view->height);
872 op->rect_count = 1;
873 op->rects[0] = *rect;
874
876
880}

Referenced by wined3d_device_context_clear_rendertarget_view().

◆ wined3d_device_context_emit_clear_uav()

void wined3d_device_context_emit_clear_uav ( struct wined3d_device_context *  context,
struct wined3d_unordered_access_view *  view,
const struct wined3d_uvec4 *  clear_value,
bool  fp 
)

◆ wined3d_device_context_emit_copy_uav_counter()

void wined3d_device_context_emit_copy_uav_counter ( struct wined3d_device_context *  context,
struct wined3d_buffer *  dst_buffer,
unsigned int  offset,
struct wined3d_unordered_access_view *  uav 
)

Definition at line 2881 of file cs.c.

2883{
2885
2888 op->buffer = dst_buffer;
2889 op->offset = offset;
2890 op->view = uav;
2891
2893
2895}

Referenced by wined3d_device_context_copy_uav_counter().

◆ wined3d_device_context_emit_draw()

void wined3d_device_context_emit_draw ( struct wined3d_device_context *  context,
enum wined3d_primitive_type  primitive_type,
unsigned int  patch_vertex_count,
int  base_vertex_idx,
unsigned int  start_idx,
unsigned int  index_count,
unsigned int  start_instance,
unsigned int  instance_count,
bool  indexed 
)

Definition at line 1166 of file cs.c.

1170{
1171 const struct wined3d_d3d_info *d3d_info = &context->device->adapter->d3d_info;
1172 struct wined3d_cs_draw *op;
1173
1175 op->opcode = WINED3D_CS_OP_DRAW;
1176 op->primitive_type = primitive_type;
1177 op->patch_vertex_count = patch_vertex_count;
1178 op->parameters.indirect = FALSE;
1179 op->parameters.u.direct.base_vertex_idx = base_vertex_idx;
1180 op->parameters.u.direct.start_idx = start_idx;
1181 op->parameters.u.direct.index_count = index_count;
1182 op->parameters.u.direct.start_instance = start_instance;
1183 op->parameters.u.direct.instance_count = instance_count;
1184 op->parameters.indexed = indexed;
1185
1187
1189}
enum wined3d_primitive_type primitive_type
Definition: cs.c:201
unsigned int patch_vertex_count
Definition: cs.c:202

Referenced by wined3d_device_context_draw(), and wined3d_device_context_draw_indexed().

◆ wined3d_device_context_emit_execute_command_list()

void wined3d_device_context_emit_execute_command_list ( struct wined3d_device_context *  context,
struct wined3d_command_list *  list,
bool  restore_state 
)

Definition at line 2994 of file cs.c.

2996{
2998
3001 op->list = list;
3002
3003 context->ops->reference_command_list(context, list);
3004
3006
3007 if (restore_state)
3009 else
3011}
#define list
Definition: rosglue.h:35

Referenced by wined3d_device_context_execute_command_list().

◆ wined3d_device_context_emit_generate_mipmaps()

void wined3d_device_context_emit_generate_mipmaps ( struct wined3d_device_context *  context,
struct wined3d_shader_resource_view *  view 
)

Definition at line 2908 of file cs.c.

Referenced by wined3d_device_context_generate_mipmaps().

◆ wined3d_device_context_emit_map()

HRESULT wined3d_device_context_emit_map ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
struct wined3d_map_desc *  map_desc,
const struct wined3d_box *  box,
unsigned int  flags 
)

Definition at line 2488 of file cs.c.

2491{
2492 struct wined3d_cs_map *op;
2493 HRESULT hr;
2494
2495 /* Mapping resources from the worker thread isn't an issue by itself, but
2496 * increasing the map count would be visible to applications. */
2497 wined3d_not_from_cs(context->device->cs);
2498
2500 && context->ops->map_upload_bo(context, resource, sub_resource_idx, map_desc, box, flags))
2501 {
2502 TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n",
2503 map_desc->data, map_desc->row_pitch, map_desc->slice_pitch);
2504 return WINED3D_OK;
2505 }
2506
2507 TRACE_(d3d_perf)("Mapping resource %p (type %u), flags %#x through the CS.\n", resource, resource->type, flags);
2508
2510
2511 /* We might end up invalidating the resource on the CS thread. */
2513
2515 return E_OUTOFMEMORY;
2516 op->opcode = WINED3D_CS_OP_MAP;
2517 op->resource = resource;
2518 op->sub_resource_idx = sub_resource_idx;
2519 op->map_ptr = &map_desc->data;
2520 op->box = box;
2521 op->flags = flags;
2522 op->hr = &hr;
2523
2526
2527 if (SUCCEEDED(hr))
2529 &map_desc->row_pitch, &map_desc->slice_pitch);
2530 return hr;
2531}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int sub_resource_idx
Definition: cs.c:459
const struct wined3d_box * box
Definition: cs.c:461
#define WINED3D_OK
Definition: wined3d.h:33
static void wined3d_resource_wait_idle(const struct wined3d_resource *resource)

Referenced by wined3d_device_context_map().

◆ wined3d_device_context_emit_push_constants()

static void wined3d_device_context_emit_push_constants ( struct wined3d_device_context *  context,
enum wined3d_push_constants  type,
uint32_t  update_mask,
unsigned int  start_idx,
unsigned int  count 
)
static

Definition at line 2215 of file cs.c.

2217{
2220
2223 op->type = type;
2224 op->update_mask = update_mask;
2225 op->start_idx = start_idx;
2226 op->count = count;
2227
2229}
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int start_idx
Definition: cs.c:418
uint32_t update_mask
Definition: cs.c:420

Referenced by wined3d_device_context_push_constants().

◆ wined3d_device_context_emit_reset_state()

void wined3d_device_context_emit_reset_state ( struct wined3d_device_context *  context,
bool  invalidate 
)

◆ wined3d_device_context_emit_set_blend_state()

void wined3d_device_context_emit_set_blend_state ( struct wined3d_device_context *  context,
struct wined3d_blend_state *  state,
const struct wined3d_color *  blend_factor,
unsigned int  sample_mask 
)

Definition at line 1800 of file cs.c.

1802{
1804
1807 op->state = state;
1808 op->factor = *blend_factor;
1809 op->sample_mask = sample_mask;
1810
1812}
unsigned int sample_mask
Definition: cs.c:343

Referenced by wined3d_device_context_set_blend_state(), and wined3d_device_context_set_state().

◆ wined3d_device_context_emit_set_clip_plane()

void wined3d_device_context_emit_set_clip_plane ( struct wined3d_device_context *  context,
unsigned int  plane_idx,
const struct wined3d_vec4 *  plane 
)

Definition at line 1961 of file cs.c.

1963{
1965
1968 op->plane_idx = plane_idx;
1969 op->plane = *plane;
1970
1972}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270

Referenced by wined3d_device_set_clip_plane().

◆ wined3d_device_context_emit_set_constant_buffers()

void wined3d_device_context_emit_set_constant_buffers ( struct wined3d_device_context *  context,
enum wined3d_shader_type  type,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_constant_buffer_state *  buffers 
)

Definition at line 1546 of file cs.c.

1549{
1551
1555 op->type = type;
1556 op->start_idx = start_idx;
1557 op->count = count;
1558 memcpy(op->buffers, buffers, count * sizeof(*buffers));
1559
1561}
const GLuint * buffers
Definition: glext.h:5916
unsigned int start_idx
Definition: cs.c:278

Referenced by wined3d_device_context_set_constant_buffers(), and wined3d_device_context_set_state().

◆ wined3d_device_context_emit_set_depth_stencil_state()

void wined3d_device_context_emit_set_depth_stencil_state ( struct wined3d_device_context *  context,
struct wined3d_depth_stencil_state *  state,
unsigned int  stencil_ref 
)

◆ wined3d_device_context_emit_set_depth_stencil_view()

void wined3d_device_context_emit_set_depth_stencil_view ( struct wined3d_device_context *  context,
struct wined3d_rendertarget_view *  view 
)

◆ wined3d_device_context_emit_set_feature_level()

void wined3d_device_context_emit_set_feature_level ( struct wined3d_device_context *  context,
enum wined3d_feature_level  level 
)

◆ wined3d_device_context_emit_set_index_buffer()

void wined3d_device_context_emit_set_index_buffer ( struct wined3d_device_context *  context,
struct wined3d_buffer *  buffer,
enum wined3d_format_id  format_id,
unsigned int  offset 
)

Definition at line 1511 of file cs.c.

1513{
1515
1518 op->buffer = buffer;
1519 op->format_id = format_id;
1520 op->offset = offset;
1521
1523}
static UINT format_id
Definition: clipboard.c:1455

Referenced by wined3d_device_context_set_index_buffer(), and wined3d_device_context_set_state().

◆ wined3d_device_context_emit_set_light()

void wined3d_device_context_emit_set_light ( struct wined3d_device_context *  context,
const struct wined3d_light_info *  light 
)

Definition at line 2083 of file cs.c.

2085{
2086 struct wined3d_cs_set_light *op;
2087
2089 op->opcode = WINED3D_CS_OP_SET_LIGHT;
2090 op->light = *light;
2091
2093}
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 light
Definition: glfuncs.h:170

Referenced by wined3d_device_context_set_light().

◆ wined3d_device_context_emit_set_light_enable()

void wined3d_device_context_emit_set_light_enable ( struct wined3d_device_context *  context,
unsigned int  idx,
BOOL  enable 
)

Definition at line 2110 of file cs.c.

2111{
2113
2116 op->idx = idx;
2117 op->enable = enable;
2118
2120}
unsigned int idx
Definition: utils.c:40
GLboolean enable
Definition: glext.h:11120

Referenced by wined3d_device_set_light_enable().

◆ wined3d_device_context_emit_set_predication()

void wined3d_device_context_emit_set_predication ( struct wined3d_device_context *  context,
struct wined3d_query *  predicate,
BOOL  value 
)

Definition at line 1245 of file cs.c.

1247{
1249
1252 op->predicate = predicate;
1253 op->value = value;
1254
1256}
struct wined3d_query * predicate
Definition: cs.c:214

Referenced by wined3d_device_context_set_predication(), and wined3d_device_context_set_state().

◆ wined3d_device_context_emit_set_rasterizer_state()

void wined3d_device_context_emit_set_rasterizer_state ( struct wined3d_device_context *  context,
struct wined3d_rasterizer_state *  rasterizer_state 
)

◆ wined3d_device_context_emit_set_render_state()

void wined3d_device_context_emit_set_render_state ( struct wined3d_device_context *  context,
enum wined3d_render_state  state,
unsigned int  value 
)

Definition at line 1893 of file cs.c.

Referenced by wined3d_device_set_render_state().

◆ wined3d_device_context_emit_set_rendertarget_views()

void wined3d_device_context_emit_set_rendertarget_views ( struct wined3d_device_context *  context,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_rendertarget_view *const *  views 
)

◆ wined3d_device_context_emit_set_samplers()

void wined3d_device_context_emit_set_samplers ( struct wined3d_device_context *  context,
enum wined3d_shader_type  type,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_sampler *const *  samplers 
)

Definition at line 1737 of file cs.c.

1739{
1741
1745 op->type = type;
1746 op->start_idx = start_idx;
1747 op->count = count;
1748 memcpy(op->samplers, samplers, count * sizeof(*samplers));
1749
1751}
GLuint * samplers
Definition: glext.h:7280
unsigned int start_idx
Definition: cs.c:326

Referenced by wined3d_device_context_set_samplers(), and wined3d_device_context_set_state().

◆ wined3d_device_context_emit_set_scissor_rects()

◆ wined3d_device_context_emit_set_shader()

void wined3d_device_context_emit_set_shader ( struct wined3d_device_context *  context,
enum wined3d_shader_type  type,
struct wined3d_shader *  shader 
)

◆ wined3d_device_context_emit_set_shader_resource_views()

void wined3d_device_context_emit_set_shader_resource_views ( struct wined3d_device_context *  context,
enum wined3d_shader_type  type,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_shader_resource_view *const *  views 
)

◆ wined3d_device_context_emit_set_stream_outputs()

void wined3d_device_context_emit_set_stream_outputs ( struct wined3d_device_context *  context,
const struct wined3d_stream_output  outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS] 
)

Definition at line 1481 of file cs.c.

1483{
1485
1488 memcpy(op->outputs, outputs, sizeof(op->outputs));
1489
1491}
struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]
Definition: cs.c:263

Referenced by wined3d_device_context_set_state(), and wined3d_device_context_set_stream_outputs().

◆ wined3d_device_context_emit_set_stream_sources()

void wined3d_device_context_emit_set_stream_sources ( struct wined3d_device_context *  context,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_stream_state *  streams 
)

Definition at line 1446 of file cs.c.

1448{
1450
1454 op->start_idx = start_idx;
1455 op->count = count;
1456 memcpy(op->streams, streams, count * sizeof(*streams));
1457
1459}
struct wined3d_stream_state streams[1]
Definition: cs.c:257
unsigned int start_idx
Definition: cs.c:255

Referenced by wined3d_device_context_set_state(), and wined3d_device_context_set_stream_sources().

◆ wined3d_device_context_emit_set_texture()

void wined3d_device_context_emit_set_texture ( struct wined3d_device_context *  context,
enum wined3d_shader_type  shader_type,
unsigned int  bind_index,
struct wined3d_shader_resource_view *  view 
)

Definition at line 1621 of file cs.c.

1623{
1624 struct wined3d_cs_set_texture *op;
1625
1627 op->opcode = WINED3D_CS_OP_SET_TEXTURE;
1628 op->shader_type = shader_type;
1629 op->bind_index = bind_index;
1630 op->view = view;
1631
1633}
struct wined3d_shader_resource_view * view
Definition: cs.c:288
unsigned int bind_index
Definition: cs.c:287

Referenced by wined3d_device_set_texture().

◆ wined3d_device_context_emit_set_texture_state()

void wined3d_device_context_emit_set_texture_state ( struct wined3d_device_context *  context,
unsigned int  stage,
enum wined3d_texture_stage_state  state,
unsigned int  value 
)

Definition at line 1914 of file cs.c.

Referenced by wined3d_device_set_texture_stage_state().

◆ wined3d_device_context_emit_set_transform()

void wined3d_device_context_emit_set_transform ( struct wined3d_device_context *  context,
enum wined3d_transform_state  state,
const struct wined3d_matrix *  matrix 
)

Definition at line 1940 of file cs.c.

1942{
1944
1947 op->state = state;
1948 op->matrix = *matrix;
1949
1951}
GLuint GLenum matrix
Definition: glext.h:9407

Referenced by wined3d_device_set_transform().

◆ wined3d_device_context_emit_set_unordered_access_views()

void wined3d_device_context_emit_set_unordered_access_views ( struct wined3d_device_context *  context,
enum wined3d_pipeline  pipeline,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_unordered_access_view *const *  views,
const unsigned int *  initial_counts 
)

Definition at line 1701 of file cs.c.

1704{
1706 unsigned int i;
1707
1711 op->pipeline = pipeline;
1712 op->start_idx = start_idx;
1713 op->count = count;
1714 for (i = 0; i < count; ++i)
1715 {
1716 op->uavs[i].view = views[i];
1717 op->uavs[i].initial_count = initial_counts ? initial_counts[i] : ~0u;
1718 }
1719
1721}
struct wined3d_cs_set_unordered_access_views::@333 uavs[1]
enum wined3d_pipeline pipeline
Definition: cs.c:312

Referenced by wined3d_device_context_set_state(), and wined3d_device_context_set_unordered_access_views().

◆ wined3d_device_context_emit_set_vertex_declaration()

void wined3d_device_context_emit_set_vertex_declaration ( struct wined3d_device_context *  context,
struct wined3d_vertex_declaration *  declaration 
)

◆ wined3d_device_context_emit_set_viewports()

void wined3d_device_context_emit_set_viewports ( struct wined3d_device_context *  context,
unsigned int  viewport_count,
const struct wined3d_viewport *  viewports 
)

◆ wined3d_device_context_emit_unmap()

HRESULT wined3d_device_context_emit_unmap ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx 
)

Definition at line 2541 of file cs.c.

2543{
2544 struct wined3d_cs_unmap *op;
2545 struct wined3d_box box;
2546 struct upload_bo bo;
2547 HRESULT hr;
2548
2549 if (context->ops->unmap_upload_bo(context, resource, sub_resource_idx, &box, &bo))
2550 {
2551 unsigned int row_pitch, slice_pitch;
2552
2553 wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
2554 if (bo.flags & UPLOAD_BO_UPLOAD_ON_UNMAP)
2555 wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch);
2556 return WINED3D_OK;
2557 }
2558
2559 wined3d_not_from_cs(context->device->cs);
2560
2561 TRACE_(d3d_perf)("Unmapping resource %p (type %u) through the CS.\n", resource, resource->type);
2562
2564 return E_OUTOFMEMORY;
2565 op->opcode = WINED3D_CS_OP_UNMAP;
2566 op->resource = resource;
2567 op->sub_resource_idx = sub_resource_idx;
2568 op->hr = &hr;
2569
2572
2573 return hr;
2574}
static void wined3d_device_context_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const struct upload_bo *bo, unsigned int row_pitch, unsigned int slice_pitch)
Definition: cs.c:2455

Referenced by wined3d_device_context_unmap().

◆ wined3d_device_context_emit_update_sub_resource()

void wined3d_device_context_emit_update_sub_resource ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
const struct wined3d_box *  box,
const void *  data,
unsigned int  row_pitch,
unsigned int  slice_pitch 
)

Definition at line 2766 of file cs.c.

2769{
2771 struct wined3d_map_desc map_desc;
2772 struct wined3d_box dummy_box;
2773 struct upload_bo bo;
2774
2775 /* If we are replacing the whole resource, the CS thread might discard and
2776 * rename the buffer object, in which case ours is no longer valid. */
2777 if (resource->type == WINED3D_RTYPE_BUFFER && box->right - box->left == resource->size)
2779
2780 if (context->ops->map_upload_bo(context, resource, sub_resource_idx, &map_desc, box, WINED3D_MAP_WRITE))
2781 {
2782 wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_desc.data, map_desc.row_pitch,
2783 map_desc.slice_pitch, box->right - box->left, box->bottom - box->top, box->back - box->front);
2784 context->ops->unmap_upload_bo(context, resource, sub_resource_idx, &dummy_box, &bo);
2786 box, &bo, map_desc.row_pitch, map_desc.slice_pitch);
2787 return;
2788 }
2789
2791
2794 op->resource = resource;
2795 op->sub_resource_idx = sub_resource_idx;
2796 op->box = *box;
2797 op->bo.addr.buffer_object = 0;
2798 op->bo.addr.addr = data;
2799 op->bo.flags = 0;
2800 op->row_pitch = row_pitch;
2801 op->slice_pitch = slice_pitch;
2802
2804 /* The data pointer may go away, so we need to wait until it is read.
2805 * Copying the data may be faster if it's small. */
2807}
void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src, unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d)
Definition: utils.c:6080
size_t size
Definition: utils.c:170
unsigned char * data
Definition: utils.c:169

Referenced by wined3d_buffer_init_data(), wined3d_device_context_push_constants(), wined3d_device_context_update_sub_resource(), and wined3d_texture_create().

◆ wined3d_device_context_finish()

◆ wined3d_device_context_flush_mapped_buffer()

void CDECL wined3d_device_context_flush_mapped_buffer ( struct wined3d_device_context *  context,
struct wined3d_buffer *  buffer 
)

Definition at line 3533 of file cs.c.

3535{
3536 struct wined3d_client_resource *client = &buffer->resource.client;
3537
3538 /* d3d9 applications can draw from a mapped dynamic buffer.
3539 * Castlevania 2 depends on this behaviour.
3540 * This means that we need to upload a pending discard bo, without actually
3541 * unmapping it. */
3542
3543 assert(context == &context->device->cs->c);
3544
3545 if (wined3d_bo_address_is_null(&client->mapped_upload.addr))
3546 return;
3547
3548 if (client->mapped_upload.flags & UPLOAD_BO_UPLOAD_ON_UNMAP)
3550 &client->mapped_box, &client->mapped_upload, buffer->resource.size, buffer->resource.size);
3551
3552 if (client->mapped_upload.flags & UPLOAD_BO_RENAME_ON_UNMAP)
3553 {
3554 client->mapped_upload.flags &= ~UPLOAD_BO_RENAME_ON_UNMAP;
3555 /* This logic matches wined3d_cs_map_upload_bo(). */
3556 if (client->mapped_upload.addr.buffer_object->coherent && wined3d_map_persistent())
3557 client->mapped_upload.flags &= ~UPLOAD_BO_UPLOAD_ON_UNMAP;
3558 }
3559}

Referenced by d3d9_device_DrawIndexedPrimitive(), and d3d9_device_flush_mapped_vertex_buffers().

◆ wined3d_device_context_push_constants()

void wined3d_device_context_push_constants ( struct wined3d_device_context *  context,
enum wined3d_push_constants  type,
uint32_t  update_mask,
unsigned int  start_idx,
unsigned int  count,
const void *  constants 
)

Definition at line 2231 of file cs.c.

2234{
2236 unsigned int byte_offset = start_idx * info->size;
2237 unsigned int byte_size = count * info->size;
2238 struct wined3d_box box;
2239
2241 return;
2242
2243 wined3d_box_set(&box, byte_offset, 0, byte_offset + byte_size, 1, 0, 1);
2245 &context->device->push_constants[type]->resource, 0, &box, constants, byte_size, byte_size);
2247}
static bool prepare_push_constant_buffer(struct wined3d_device_context *context, enum wined3d_push_constants type)
Definition: cs.c:2159
static void wined3d_device_context_emit_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants type, uint32_t update_mask, unsigned int start_idx, unsigned int count)
Definition: cs.c:2215
void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: cs.c:2766
constants
Definition: resource.c:30
static void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
Definition: wined3d.h:3006

Referenced by wined3d_device_apply_stateblock(), wined3d_device_set_ps_consts_b(), wined3d_device_set_ps_consts_f(), wined3d_device_set_ps_consts_i(), wined3d_device_set_vs_consts_b(), wined3d_device_set_vs_consts_f(), and wined3d_device_set_vs_consts_i().

◆ wined3d_device_context_reference_resource()

◆ wined3d_device_context_require_space()

static void * wined3d_device_context_require_space ( struct wined3d_device_context *  context,
size_t  size,
enum wined3d_cs_queue_id  queue_id 
)
inlinestatic

Definition at line 546 of file cs.c.

548{
549 return context->ops->require_space(context, size, queue_id);
550}

Referenced by wined3d_cs_emit_add_dirty_texture_region(), wined3d_cs_emit_callback(), wined3d_cs_emit_clear(), wined3d_cs_emit_preload_resource(), wined3d_cs_emit_present(), wined3d_cs_emit_set_color_key(), wined3d_cs_emit_stop(), wined3d_cs_emit_unload_resource(), wined3d_cs_flush(), wined3d_cs_issue_query(), wined3d_cs_map_bo_address(), wined3d_deferred_context_issue_query(), wined3d_device_context_clear_sysmem_texture(), wined3d_device_context_dispatch(), wined3d_device_context_dispatch_indirect(), wined3d_device_context_draw_indirect(), wined3d_device_context_emit_blt_sub_resource(), wined3d_device_context_emit_clear_rendertarget_view(), wined3d_device_context_emit_clear_uav(), wined3d_device_context_emit_copy_uav_counter(), wined3d_device_context_emit_draw(), wined3d_device_context_emit_execute_command_list(), wined3d_device_context_emit_generate_mipmaps(), wined3d_device_context_emit_map(), wined3d_device_context_emit_push_constants(), wined3d_device_context_emit_reset_state(), wined3d_device_context_emit_set_blend_state(), wined3d_device_context_emit_set_clip_plane(), wined3d_device_context_emit_set_constant_buffers(), wined3d_device_context_emit_set_depth_stencil_state(), wined3d_device_context_emit_set_depth_stencil_view(), wined3d_device_context_emit_set_feature_level(), wined3d_device_context_emit_set_index_buffer(), wined3d_device_context_emit_set_light(), wined3d_device_context_emit_set_light_enable(), wined3d_device_context_emit_set_predication(), wined3d_device_context_emit_set_rasterizer_state(), wined3d_device_context_emit_set_render_state(), wined3d_device_context_emit_set_rendertarget_views(), wined3d_device_context_emit_set_samplers(), wined3d_device_context_emit_set_scissor_rects(), wined3d_device_context_emit_set_shader(), wined3d_device_context_emit_set_shader_resource_views(), wined3d_device_context_emit_set_stream_outputs(), wined3d_device_context_emit_set_stream_sources(), wined3d_device_context_emit_set_texture(), wined3d_device_context_emit_set_texture_state(), wined3d_device_context_emit_set_transform(), wined3d_device_context_emit_set_unordered_access_views(), wined3d_device_context_emit_set_vertex_declaration(), wined3d_device_context_emit_set_viewports(), wined3d_device_context_emit_unmap(), wined3d_device_context_emit_update_sub_resource(), wined3d_device_context_set_depth_bounds(), and wined3d_device_context_upload_bo().

◆ wined3d_device_context_set_depth_bounds()

void wined3d_device_context_set_depth_bounds ( struct wined3d_device_context *  context,
bool  enable,
float  min_depth,
float  max_depth 
)

Definition at line 1871 of file cs.c.

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_context_submit()

static void wined3d_device_context_submit ( struct wined3d_device_context *  context,
enum wined3d_cs_queue_id  queue_id 
)
inlinestatic

Definition at line 552 of file cs.c.

554{
555 context->ops->submit(context, queue_id);
556}

Referenced by wined3d_cs_emit_add_dirty_texture_region(), wined3d_cs_emit_callback(), wined3d_cs_emit_clear(), wined3d_cs_emit_preload_resource(), wined3d_cs_emit_present(), wined3d_cs_emit_set_color_key(), wined3d_cs_emit_stop(), wined3d_cs_emit_unload_resource(), wined3d_cs_flush(), wined3d_cs_issue_query(), wined3d_cs_map_bo_address(), wined3d_deferred_context_issue_query(), wined3d_device_context_clear_sysmem_texture(), wined3d_device_context_dispatch(), wined3d_device_context_dispatch_indirect(), wined3d_device_context_draw_indirect(), wined3d_device_context_emit_blt_sub_resource(), wined3d_device_context_emit_clear_rendertarget_view(), wined3d_device_context_emit_clear_uav(), wined3d_device_context_emit_copy_uav_counter(), wined3d_device_context_emit_draw(), wined3d_device_context_emit_execute_command_list(), wined3d_device_context_emit_generate_mipmaps(), wined3d_device_context_emit_map(), wined3d_device_context_emit_push_constants(), wined3d_device_context_emit_reset_state(), wined3d_device_context_emit_set_blend_state(), wined3d_device_context_emit_set_clip_plane(), wined3d_device_context_emit_set_constant_buffers(), wined3d_device_context_emit_set_depth_stencil_state(), wined3d_device_context_emit_set_depth_stencil_view(), wined3d_device_context_emit_set_feature_level(), wined3d_device_context_emit_set_index_buffer(), wined3d_device_context_emit_set_light(), wined3d_device_context_emit_set_light_enable(), wined3d_device_context_emit_set_predication(), wined3d_device_context_emit_set_rasterizer_state(), wined3d_device_context_emit_set_render_state(), wined3d_device_context_emit_set_rendertarget_views(), wined3d_device_context_emit_set_samplers(), wined3d_device_context_emit_set_scissor_rects(), wined3d_device_context_emit_set_shader(), wined3d_device_context_emit_set_shader_resource_views(), wined3d_device_context_emit_set_stream_outputs(), wined3d_device_context_emit_set_stream_sources(), wined3d_device_context_emit_set_texture(), wined3d_device_context_emit_set_texture_state(), wined3d_device_context_emit_set_transform(), wined3d_device_context_emit_set_unordered_access_views(), wined3d_device_context_emit_set_vertex_declaration(), wined3d_device_context_emit_set_viewports(), wined3d_device_context_emit_unmap(), wined3d_device_context_emit_update_sub_resource(), wined3d_device_context_set_depth_bounds(), and wined3d_device_context_upload_bo().

◆ wined3d_device_context_upload_bo()

static void wined3d_device_context_upload_bo ( struct wined3d_device_context *  context,
struct wined3d_resource *  resource,
unsigned int  sub_resource_idx,
const struct wined3d_box *  box,
const struct upload_bo *  bo,
unsigned int  row_pitch,
unsigned int  slice_pitch 
)
static

Definition at line 2455 of file cs.c.

2458{
2460
2461 TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, flags %#x, row_pitch %u, slice_pitch %u.\n",
2464
2467 op->resource = resource;
2468 op->sub_resource_idx = sub_resource_idx;
2469 op->box = *box;
2470 op->bo = *bo;
2471 op->row_pitch = row_pitch;
2472 op->slice_pitch = slice_pitch;
2473
2475
2477}
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:4552
struct upload_bo bo
Definition: cs.c:502
struct wined3d_box box
Definition: cs.c:501
unsigned int row_pitch
Definition: cs.c:503
unsigned int sub_resource_idx
Definition: cs.c:500
unsigned int slice_pitch
Definition: cs.c:503

Referenced by wined3d_device_context_emit_unmap(), wined3d_device_context_emit_update_sub_resource(), and wined3d_device_context_flush_mapped_buffer().

◆ wined3d_next_cs_packet()

static struct wined3d_cs_packet * wined3d_next_cs_packet ( const uint8_t *  data,
SIZE_T *  offset,
SIZE_T  mask 
)
static

Definition at line 636 of file cs.c.

637{
638 struct wined3d_cs_packet *packet = (struct wined3d_cs_packet *)&data[*offset & mask];
639
640 *offset += offsetof(struct wined3d_cs_packet, data[packet->size]);
641
642 return packet;
643}
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by wined3d_command_list_decref(), wined3d_cs_exec_execute_command_list(), wined3d_cs_execute_next(), wined3d_deferred_context_destroy(), and wined3d_deferred_context_submit().

Variable Documentation

◆ timeout

Definition at line 29 of file cs.c.

◆ wined3d_cs_mt_ops

const struct wined3d_device_context_ops wined3d_cs_mt_ops
static
Initial value:
=
{
}
static void wined3d_cs_reference_resource(struct wined3d_device_context *context, struct wined3d_resource *resource)
Definition: cs.c:2933
static void wined3d_cs_mt_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3335
static void wined3d_cs_issue_query(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags)
Definition: cs.c:2355
static void * wined3d_cs_mt_require_space(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3324
static bool wined3d_cs_unmap_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo)
Definition: cs.c:3191
static void wined3d_cs_mt_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:3253
static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
Definition: cs.c:3082

Definition at line 3349 of file cs.c.

Referenced by wined3d_cs_create().

◆ wined3d_cs_op_handlers

void(*const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) ( struct wined3d_cs *  cs,
const void *  data 
)
static

◆ wined3d_cs_push_constant_info

const struct push_constant_info wined3d_cs_push_constant_info[]
static
Initial value:
=
{
}
#define BOOL
Definition: nt_native.h:43
#define WINED3D_MAX_PS_CONSTS_F
Definition: wined3d.h:1605
#define WINED3D_MAX_VS_CONSTS_F
Definition: wined3d.h:1604
#define WINED3D_MAX_CONSTS_B
Definition: wined3d.h:1602
#define WINED3D_MAX_CONSTS_I
Definition: wined3d.h:1603
@ WINED3D_PUSH_CONSTANTS_PS_B
@ WINED3D_PUSH_CONSTANTS_VS_B
@ WINED3D_PUSH_CONSTANTS_VS_I
@ WINED3D_PUSH_CONSTANTS_PS_I

Referenced by prepare_push_constant_buffer(), and wined3d_device_context_push_constants().

◆ wined3d_cs_st_ops

◆ wined3d_deferred_context_ops

const struct wined3d_device_context_ops wined3d_deferred_context_ops
static
Initial value:
=
{
}
static bool wined3d_deferred_context_unmap_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo)
Definition: cs.c:4353
static void wined3d_deferred_context_issue_query(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags)
Definition: cs.c:4374
static void wined3d_deferred_context_flush(struct wined3d_device_context *context)
Definition: cs.c:4398
static void * wined3d_deferred_context_require_space(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:4204
static void wined3d_deferred_context_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:4237
static void wined3d_deferred_context_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
Definition: cs.c:4227
static bool wined3d_deferred_context_map_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
Definition: cs.c:4259
static void wined3d_deferred_context_reference_resource(struct wined3d_device_context *context, struct wined3d_resource *resource)
Definition: cs.c:4403
static void wined3d_deferred_context_reference_command_list(struct wined3d_device_context *context, struct wined3d_command_list *list)
Definition: cs.c:4416

Definition at line 4430 of file cs.c.

Referenced by wined3d_deferred_context_create().