2013-09-27 00:15:13 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-10-03 16:03:17 +02:00
|
|
|
#include "wine/port.h"
|
2013-09-27 00:15:13 +02:00
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
2020-12-03 17:58:54 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(d3d_sync);
|
2020-05-21 20:51:38 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(fps);
|
2013-09-27 00:15:13 +02:00
|
|
|
|
|
|
|
#define WINED3D_INITIAL_CS_SIZE 4096
|
|
|
|
|
2021-05-27 18:14:33 +02:00
|
|
|
struct wined3d_command_list
|
|
|
|
{
|
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
struct wined3d_device *device;
|
|
|
|
|
|
|
|
SIZE_T data_size;
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
SIZE_T resource_count;
|
|
|
|
struct wined3d_resource **resources;
|
2021-05-27 18:14:35 +02:00
|
|
|
|
|
|
|
/* List of command lists queued for execution on this command list. We might
|
|
|
|
* be the only thing holding a pointer to another command list, so we need
|
|
|
|
* to hold a reference here (and in wined3d_deferred_context) as well. */
|
|
|
|
SIZE_T command_list_count;
|
|
|
|
struct wined3d_command_list **command_lists;
|
2021-05-27 18:14:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void wined3d_command_list_destroy_object(void *object)
|
|
|
|
{
|
|
|
|
struct wined3d_command_list *list = object;
|
|
|
|
|
|
|
|
TRACE("list %p.\n", list);
|
|
|
|
|
|
|
|
heap_free(list->resources);
|
|
|
|
heap_free(list->data);
|
|
|
|
heap_free(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG CDECL wined3d_command_list_incref(struct wined3d_command_list *list)
|
|
|
|
{
|
|
|
|
ULONG refcount = InterlockedIncrement(&list->refcount);
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", list, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
|
|
|
|
{
|
|
|
|
ULONG refcount = InterlockedDecrement(&list->refcount);
|
|
|
|
struct wined3d_device *device = list->device;
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", list, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
SIZE_T i;
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
for (i = 0; i < list->command_list_count; ++i)
|
|
|
|
wined3d_command_list_decref(list->command_lists[i]);
|
2021-05-27 18:14:33 +02:00
|
|
|
for (i = 0; i < list->resource_count; ++i)
|
|
|
|
wined3d_resource_decref(list->resources[i]);
|
|
|
|
|
|
|
|
wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2013-09-27 00:15:13 +02:00
|
|
|
enum wined3d_cs_op
|
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
WINED3D_CS_OP_NOP,
|
2013-09-27 00:15:13 +02:00
|
|
|
WINED3D_CS_OP_PRESENT,
|
2013-09-27 00:15:14 +02:00
|
|
|
WINED3D_CS_OP_CLEAR,
|
2017-02-02 12:43:40 +01:00
|
|
|
WINED3D_CS_OP_DISPATCH,
|
2013-09-27 00:15:15 +02:00
|
|
|
WINED3D_CS_OP_DRAW,
|
2017-04-13 00:11:00 +02:00
|
|
|
WINED3D_CS_OP_FLUSH,
|
2014-09-19 10:41:46 +02:00
|
|
|
WINED3D_CS_OP_SET_PREDICATION,
|
2018-04-14 11:12:38 +02:00
|
|
|
WINED3D_CS_OP_SET_VIEWPORTS,
|
2018-04-23 14:34:03 +02:00
|
|
|
WINED3D_CS_OP_SET_SCISSOR_RECTS,
|
2014-08-21 09:55:55 +02:00
|
|
|
WINED3D_CS_OP_SET_RENDERTARGET_VIEW,
|
2014-08-22 12:32:01 +02:00
|
|
|
WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW,
|
2013-10-01 10:38:31 +02:00
|
|
|
WINED3D_CS_OP_SET_VERTEX_DECLARATION,
|
2013-10-02 09:55:26 +02:00
|
|
|
WINED3D_CS_OP_SET_STREAM_SOURCE,
|
2013-10-03 08:54:11 +02:00
|
|
|
WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ,
|
2013-10-10 23:49:46 +02:00
|
|
|
WINED3D_CS_OP_SET_STREAM_OUTPUT,
|
2013-10-03 08:54:12 +02:00
|
|
|
WINED3D_CS_OP_SET_INDEX_BUFFER,
|
2013-10-10 23:49:44 +02:00
|
|
|
WINED3D_CS_OP_SET_CONSTANT_BUFFER,
|
2013-10-03 08:54:13 +02:00
|
|
|
WINED3D_CS_OP_SET_TEXTURE,
|
2014-09-16 10:44:16 +02:00
|
|
|
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW,
|
2016-11-23 14:36:05 +01:00
|
|
|
WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW,
|
2013-10-10 23:49:45 +02:00
|
|
|
WINED3D_CS_OP_SET_SAMPLER,
|
2013-10-09 22:57:45 +02:00
|
|
|
WINED3D_CS_OP_SET_SHADER,
|
2018-02-08 15:22:44 +01:00
|
|
|
WINED3D_CS_OP_SET_BLEND_STATE,
|
2020-09-25 05:43:11 +02:00
|
|
|
WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE,
|
2016-07-27 23:33:41 +02:00
|
|
|
WINED3D_CS_OP_SET_RASTERIZER_STATE,
|
2013-10-06 17:33:04 +02:00
|
|
|
WINED3D_CS_OP_SET_RENDER_STATE,
|
2013-10-07 22:15:47 +02:00
|
|
|
WINED3D_CS_OP_SET_TEXTURE_STATE,
|
2013-10-07 22:15:48 +02:00
|
|
|
WINED3D_CS_OP_SET_SAMPLER_STATE,
|
2013-10-07 22:15:49 +02:00
|
|
|
WINED3D_CS_OP_SET_TRANSFORM,
|
2013-10-09 10:39:36 +02:00
|
|
|
WINED3D_CS_OP_SET_CLIP_PLANE,
|
2015-04-09 22:48:11 +02:00
|
|
|
WINED3D_CS_OP_SET_COLOR_KEY,
|
2013-10-09 10:39:37 +02:00
|
|
|
WINED3D_CS_OP_SET_MATERIAL,
|
2017-02-19 18:16:35 +01:00
|
|
|
WINED3D_CS_OP_SET_LIGHT,
|
2017-02-19 18:16:36 +01:00
|
|
|
WINED3D_CS_OP_SET_LIGHT_ENABLE,
|
2021-03-15 16:11:36 +01:00
|
|
|
WINED3D_CS_OP_SET_FEATURE_LEVEL,
|
2017-04-13 00:11:01 +02:00
|
|
|
WINED3D_CS_OP_PUSH_CONSTANTS,
|
2014-01-09 12:16:58 +01:00
|
|
|
WINED3D_CS_OP_RESET_STATE,
|
2017-02-16 00:58:53 +01:00
|
|
|
WINED3D_CS_OP_CALLBACK,
|
2016-07-29 12:34:34 +02:00
|
|
|
WINED3D_CS_OP_QUERY_ISSUE,
|
2016-08-26 13:51:18 +02:00
|
|
|
WINED3D_CS_OP_PRELOAD_RESOURCE,
|
2016-08-05 12:39:01 +02:00
|
|
|
WINED3D_CS_OP_UNLOAD_RESOURCE,
|
2016-09-01 20:34:46 +02:00
|
|
|
WINED3D_CS_OP_MAP,
|
2016-09-01 20:34:47 +02:00
|
|
|
WINED3D_CS_OP_UNMAP,
|
2017-03-08 10:53:02 +01:00
|
|
|
WINED3D_CS_OP_BLT_SUB_RESOURCE,
|
2017-03-06 10:45:24 +01:00
|
|
|
WINED3D_CS_OP_UPDATE_SUB_RESOURCE,
|
2017-04-12 00:08:50 +02:00
|
|
|
WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION,
|
2017-05-12 15:09:20 +02:00
|
|
|
WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW,
|
2017-08-04 19:53:48 +02:00
|
|
|
WINED3D_CS_OP_COPY_UAV_COUNTER,
|
2017-12-04 18:07:31 +01:00
|
|
|
WINED3D_CS_OP_GENERATE_MIPMAPS,
|
2021-05-27 18:14:35 +02:00
|
|
|
WINED3D_CS_OP_EXECUTE_COMMAND_LIST,
|
2017-04-13 00:11:01 +02:00
|
|
|
WINED3D_CS_OP_STOP,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wined3d_cs_packet
|
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
BYTE data[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wined3d_cs_nop
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2013-09-27 00:15:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wined3d_cs_present
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
HWND dst_window_override;
|
|
|
|
struct wined3d_swapchain *swapchain;
|
2016-03-25 17:52:30 +01:00
|
|
|
RECT src_rect;
|
|
|
|
RECT dst_rect;
|
2018-03-22 08:48:31 +01:00
|
|
|
unsigned int swap_interval;
|
2013-09-27 00:15:13 +02:00
|
|
|
DWORD flags;
|
|
|
|
};
|
|
|
|
|
2013-09-27 00:15:14 +02:00
|
|
|
struct wined3d_cs_clear
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
DWORD flags;
|
2017-04-05 10:21:25 +02:00
|
|
|
unsigned int rt_count;
|
2021-05-27 18:14:28 +02:00
|
|
|
struct wined3d_fb_state fb;
|
2017-04-05 10:21:25 +02:00
|
|
|
RECT draw_rect;
|
2016-03-24 18:24:31 +01:00
|
|
|
struct wined3d_color color;
|
2013-09-27 00:15:14 +02:00
|
|
|
float depth;
|
|
|
|
DWORD stencil;
|
2016-03-24 18:24:31 +01:00
|
|
|
unsigned int rect_count;
|
|
|
|
RECT rects[1];
|
2013-09-27 00:15:14 +02:00
|
|
|
};
|
|
|
|
|
2017-02-02 12:43:40 +01:00
|
|
|
struct wined3d_cs_dispatch
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2017-08-14 23:47:41 +02:00
|
|
|
struct wined3d_dispatch_parameters parameters;
|
2017-02-02 12:43:40 +01:00
|
|
|
};
|
|
|
|
|
2013-09-27 00:15:15 +02:00
|
|
|
struct wined3d_cs_draw
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2020-05-20 15:42:28 +02:00
|
|
|
enum wined3d_primitive_type primitive_type;
|
2017-05-18 15:20:01 +02:00
|
|
|
GLint patch_vertex_count;
|
2017-11-01 22:08:42 +01:00
|
|
|
struct wined3d_draw_parameters parameters;
|
2013-09-27 00:15:15 +02:00
|
|
|
};
|
|
|
|
|
2017-04-13 00:11:00 +02:00
|
|
|
struct wined3d_cs_flush
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
};
|
|
|
|
|
2014-09-19 10:41:46 +02:00
|
|
|
struct wined3d_cs_set_predication
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_query *predicate;
|
|
|
|
BOOL value;
|
|
|
|
};
|
|
|
|
|
2018-04-14 11:12:38 +02:00
|
|
|
struct wined3d_cs_set_viewports
|
2013-09-30 09:40:39 +02:00
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2018-04-14 11:12:38 +02:00
|
|
|
unsigned int viewport_count;
|
|
|
|
struct wined3d_viewport viewports[1];
|
2013-09-30 09:40:39 +02:00
|
|
|
};
|
|
|
|
|
2018-04-23 14:34:03 +02:00
|
|
|
struct wined3d_cs_set_scissor_rects
|
2013-09-30 09:40:41 +02:00
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2018-04-23 14:34:03 +02:00
|
|
|
unsigned int rect_count;
|
|
|
|
RECT rects[1];
|
2013-09-30 09:40:41 +02:00
|
|
|
};
|
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
struct wined3d_cs_set_rendertarget_view
|
2013-10-01 10:38:29 +02:00
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2014-08-21 09:55:55 +02:00
|
|
|
unsigned int view_idx;
|
|
|
|
struct wined3d_rendertarget_view *view;
|
2013-10-01 10:38:29 +02:00
|
|
|
};
|
|
|
|
|
2014-08-22 12:32:01 +02:00
|
|
|
struct wined3d_cs_set_depth_stencil_view
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2014-08-22 12:32:01 +02:00
|
|
|
struct wined3d_rendertarget_view *view;
|
2013-10-01 10:38:30 +02:00
|
|
|
};
|
|
|
|
|
2013-10-01 10:38:31 +02:00
|
|
|
struct wined3d_cs_set_vertex_declaration
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_vertex_declaration *declaration;
|
|
|
|
};
|
|
|
|
|
2013-10-02 09:55:26 +02:00
|
|
|
struct wined3d_cs_set_stream_source
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT stream_idx;
|
|
|
|
struct wined3d_buffer *buffer;
|
|
|
|
UINT offset;
|
|
|
|
UINT stride;
|
|
|
|
};
|
|
|
|
|
2013-10-03 08:54:11 +02:00
|
|
|
struct wined3d_cs_set_stream_source_freq
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT stream_idx;
|
|
|
|
UINT frequency;
|
|
|
|
UINT flags;
|
|
|
|
};
|
|
|
|
|
2013-10-10 23:49:46 +02:00
|
|
|
struct wined3d_cs_set_stream_output
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT stream_idx;
|
|
|
|
struct wined3d_buffer *buffer;
|
|
|
|
UINT offset;
|
|
|
|
};
|
|
|
|
|
2013-10-03 08:54:12 +02:00
|
|
|
struct wined3d_cs_set_index_buffer
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_buffer *buffer;
|
|
|
|
enum wined3d_format_id format_id;
|
2016-06-02 11:14:13 +02:00
|
|
|
unsigned int offset;
|
2013-10-03 08:54:12 +02:00
|
|
|
};
|
|
|
|
|
2013-10-10 23:49:44 +02:00
|
|
|
struct wined3d_cs_set_constant_buffer
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_shader_type type;
|
|
|
|
UINT cb_idx;
|
|
|
|
struct wined3d_buffer *buffer;
|
|
|
|
};
|
|
|
|
|
2013-10-03 08:54:13 +02:00
|
|
|
struct wined3d_cs_set_texture
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT stage;
|
|
|
|
struct wined3d_texture *texture;
|
|
|
|
};
|
|
|
|
|
2015-04-09 22:48:11 +02:00
|
|
|
struct wined3d_cs_set_color_key
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_texture *texture;
|
|
|
|
WORD flags;
|
|
|
|
WORD set;
|
|
|
|
struct wined3d_color_key color_key;
|
|
|
|
};
|
|
|
|
|
2014-09-16 10:44:16 +02:00
|
|
|
struct wined3d_cs_set_shader_resource_view
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_shader_type type;
|
|
|
|
UINT view_idx;
|
|
|
|
struct wined3d_shader_resource_view *view;
|
|
|
|
};
|
|
|
|
|
2016-11-23 14:36:05 +01:00
|
|
|
struct wined3d_cs_set_unordered_access_view
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2017-02-09 12:00:36 +01:00
|
|
|
enum wined3d_pipeline pipeline;
|
2016-11-23 14:36:05 +01:00
|
|
|
unsigned int view_idx;
|
|
|
|
struct wined3d_unordered_access_view *view;
|
2017-08-04 19:53:50 +02:00
|
|
|
unsigned int initial_count;
|
2016-11-23 14:36:05 +01:00
|
|
|
};
|
|
|
|
|
2013-10-10 23:49:45 +02:00
|
|
|
struct wined3d_cs_set_sampler
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_shader_type type;
|
|
|
|
UINT sampler_idx;
|
|
|
|
struct wined3d_sampler *sampler;
|
|
|
|
};
|
|
|
|
|
2013-10-03 23:31:44 +02:00
|
|
|
struct wined3d_cs_set_shader
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2013-10-09 22:57:45 +02:00
|
|
|
enum wined3d_shader_type type;
|
2013-10-03 23:31:44 +02:00
|
|
|
struct wined3d_shader *shader;
|
|
|
|
};
|
|
|
|
|
2018-02-08 15:22:44 +01:00
|
|
|
struct wined3d_cs_set_blend_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_blend_state *state;
|
2018-10-18 00:41:13 +02:00
|
|
|
struct wined3d_color factor;
|
2020-09-02 07:27:42 +02:00
|
|
|
unsigned int sample_mask;
|
2018-02-08 15:22:44 +01:00
|
|
|
};
|
|
|
|
|
2020-09-25 05:43:11 +02:00
|
|
|
struct wined3d_cs_set_depth_stencil_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_depth_stencil_state *state;
|
2021-02-03 14:12:47 +01:00
|
|
|
unsigned int stencil_ref;
|
2020-09-25 05:43:11 +02:00
|
|
|
};
|
|
|
|
|
2016-07-27 23:33:41 +02:00
|
|
|
struct wined3d_cs_set_rasterizer_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_rasterizer_state *state;
|
|
|
|
};
|
|
|
|
|
2013-10-06 17:33:04 +02:00
|
|
|
struct wined3d_cs_set_render_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_render_state state;
|
|
|
|
DWORD value;
|
|
|
|
};
|
|
|
|
|
2013-10-07 22:15:47 +02:00
|
|
|
struct wined3d_cs_set_texture_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT stage;
|
|
|
|
enum wined3d_texture_stage_state state;
|
|
|
|
DWORD value;
|
|
|
|
};
|
|
|
|
|
2013-10-07 22:15:48 +02:00
|
|
|
struct wined3d_cs_set_sampler_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT sampler_idx;
|
|
|
|
enum wined3d_sampler_state state;
|
|
|
|
DWORD value;
|
|
|
|
};
|
|
|
|
|
2013-10-07 22:15:49 +02:00
|
|
|
struct wined3d_cs_set_transform
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_transform_state state;
|
2016-03-21 17:40:15 +01:00
|
|
|
struct wined3d_matrix matrix;
|
2013-10-07 22:15:49 +02:00
|
|
|
};
|
|
|
|
|
2013-10-09 10:39:36 +02:00
|
|
|
struct wined3d_cs_set_clip_plane
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
UINT plane_idx;
|
2016-03-19 10:35:51 +01:00
|
|
|
struct wined3d_vec4 plane;
|
2013-10-09 10:39:36 +02:00
|
|
|
};
|
|
|
|
|
2013-10-09 10:39:37 +02:00
|
|
|
struct wined3d_cs_set_material
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2016-03-17 16:30:07 +01:00
|
|
|
struct wined3d_material material;
|
2013-10-09 10:39:37 +02:00
|
|
|
};
|
|
|
|
|
2017-02-19 18:16:35 +01:00
|
|
|
struct wined3d_cs_set_light
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_light_info light;
|
|
|
|
};
|
|
|
|
|
2017-02-19 18:16:36 +01:00
|
|
|
struct wined3d_cs_set_light_enable
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
unsigned int idx;
|
|
|
|
BOOL enable;
|
|
|
|
};
|
|
|
|
|
2021-03-15 16:11:36 +01:00
|
|
|
struct wined3d_cs_set_feature_level
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_feature_level level;
|
|
|
|
};
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
struct wined3d_cs_push_constants
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
enum wined3d_push_constants type;
|
|
|
|
unsigned int start_idx;
|
|
|
|
unsigned int count;
|
|
|
|
BYTE constants[1];
|
|
|
|
};
|
|
|
|
|
2014-01-09 12:16:58 +01:00
|
|
|
struct wined3d_cs_reset_state
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
2021-05-27 18:14:32 +02:00
|
|
|
bool invalidate;
|
2014-01-09 12:16:58 +01:00
|
|
|
};
|
|
|
|
|
2017-02-16 00:58:53 +01:00
|
|
|
struct wined3d_cs_callback
|
2016-06-21 10:32:46 +02:00
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
void (*callback)(void *object);
|
|
|
|
void *object;
|
|
|
|
};
|
|
|
|
|
2016-07-29 12:34:34 +02:00
|
|
|
struct wined3d_cs_query_issue
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_query *query;
|
|
|
|
DWORD flags;
|
|
|
|
};
|
|
|
|
|
2016-08-26 13:51:18 +02:00
|
|
|
struct wined3d_cs_preload_resource
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *resource;
|
|
|
|
};
|
|
|
|
|
2016-08-05 12:39:01 +02:00
|
|
|
struct wined3d_cs_unload_resource
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *resource;
|
|
|
|
};
|
|
|
|
|
2016-09-01 20:34:46 +02:00
|
|
|
struct wined3d_cs_map
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *resource;
|
|
|
|
unsigned int sub_resource_idx;
|
2021-06-24 22:29:06 +02:00
|
|
|
void **map_ptr;
|
2016-09-01 20:34:46 +02:00
|
|
|
const struct wined3d_box *box;
|
|
|
|
DWORD flags;
|
|
|
|
HRESULT *hr;
|
|
|
|
};
|
|
|
|
|
2016-09-01 20:34:47 +02:00
|
|
|
struct wined3d_cs_unmap
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *resource;
|
|
|
|
unsigned int sub_resource_idx;
|
|
|
|
HRESULT *hr;
|
|
|
|
};
|
|
|
|
|
2017-03-08 10:53:02 +01:00
|
|
|
struct wined3d_cs_blt_sub_resource
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *dst_resource;
|
|
|
|
unsigned int dst_sub_resource_idx;
|
|
|
|
struct wined3d_box dst_box;
|
|
|
|
struct wined3d_resource *src_resource;
|
|
|
|
unsigned int src_sub_resource_idx;
|
|
|
|
struct wined3d_box src_box;
|
|
|
|
DWORD flags;
|
|
|
|
struct wined3d_blt_fx fx;
|
|
|
|
enum wined3d_texture_filter_type filter;
|
|
|
|
};
|
|
|
|
|
2017-03-06 10:45:24 +01:00
|
|
|
struct wined3d_cs_update_sub_resource
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_resource *resource;
|
|
|
|
unsigned int sub_resource_idx;
|
|
|
|
struct wined3d_box box;
|
2021-06-28 18:39:03 +02:00
|
|
|
struct wined3d_const_bo_address addr;
|
|
|
|
unsigned int row_pitch, slice_pitch;
|
2017-03-06 10:45:24 +01:00
|
|
|
};
|
|
|
|
|
2017-04-12 00:08:50 +02:00
|
|
|
struct wined3d_cs_add_dirty_texture_region
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_texture *texture;
|
|
|
|
unsigned int layer;
|
|
|
|
};
|
|
|
|
|
2017-05-12 15:09:20 +02:00
|
|
|
struct wined3d_cs_clear_unordered_access_view
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_unordered_access_view *view;
|
|
|
|
struct wined3d_uvec4 clear_value;
|
2021-06-07 16:55:10 +02:00
|
|
|
bool fp;
|
2017-05-12 15:09:20 +02:00
|
|
|
};
|
|
|
|
|
2017-08-04 19:53:48 +02:00
|
|
|
struct wined3d_cs_copy_uav_counter
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_buffer *buffer;
|
|
|
|
unsigned int offset;
|
|
|
|
struct wined3d_unordered_access_view *view;
|
|
|
|
};
|
|
|
|
|
2017-12-04 18:07:31 +01:00
|
|
|
struct wined3d_cs_generate_mipmaps
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_shader_resource_view *view;
|
|
|
|
};
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
struct wined3d_cs_execute_command_list
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
struct wined3d_command_list *list;
|
|
|
|
};
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
struct wined3d_cs_stop
|
|
|
|
{
|
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
};
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
static inline void *wined3d_device_context_require_space(struct wined3d_device_context *context,
|
2018-11-30 14:43:07 +01:00
|
|
|
size_t size, enum wined3d_cs_queue_id queue_id)
|
|
|
|
{
|
2021-03-05 04:29:46 +01:00
|
|
|
return context->ops->require_space(context, size, queue_id);
|
2018-11-30 14:43:07 +01:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
static inline void wined3d_device_context_submit(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_cs_queue_id queue_id)
|
2018-11-30 14:43:06 +01:00
|
|
|
{
|
2021-03-05 04:29:45 +01:00
|
|
|
context->ops->submit(context, queue_id);
|
2018-11-30 14:43:06 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 03:56:41 +02:00
|
|
|
static inline void wined3d_device_context_finish(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_cs_queue_id queue_id)
|
|
|
|
{
|
|
|
|
context->ops->finish(context, queue_id);
|
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static inline void wined3d_device_context_acquire_resource(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_resource *resource)
|
|
|
|
{
|
|
|
|
context->ops->acquire_resource(context, resource);
|
|
|
|
}
|
|
|
|
|
2021-04-14 04:05:26 +02:00
|
|
|
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(context, struct wined3d_cs, c);
|
|
|
|
}
|
|
|
|
|
2018-08-16 09:39:19 +02:00
|
|
|
static const char *debug_cs_op(enum wined3d_cs_op op)
|
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
#define WINED3D_TO_STR(type) case type: return #type
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_NOP);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_PRESENT);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_CLEAR);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_DISPATCH);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_DRAW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_FLUSH);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_PREDICATION);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_VIEWPORTS);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_SCISSOR_RECTS);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDERTARGET_VIEW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_VERTEX_DECLARATION);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_OUTPUT);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_INDEX_BUFFER);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_CONSTANT_BUFFER);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLER);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_BLEND_STATE);
|
2020-09-25 05:43:11 +02:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE);
|
2018-08-16 09:39:19 +02:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_RASTERIZER_STATE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDER_STATE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE_STATE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLER_STATE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_TRANSFORM);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_CLIP_PLANE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_COLOR_KEY);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_MATERIAL);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT_ENABLE);
|
2021-03-15 16:11:36 +01:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_SET_FEATURE_LEVEL);
|
2018-08-16 09:39:19 +02:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_PUSH_CONSTANTS);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_RESET_STATE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_CALLBACK);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_QUERY_ISSUE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_PRELOAD_RESOURCE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_UNLOAD_RESOURCE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_MAP);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_UNMAP);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_BLT_SUB_RESOURCE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_UPDATE_SUB_RESOURCE);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_COPY_UAV_COUNTER);
|
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_GENERATE_MIPMAPS);
|
2021-05-27 18:14:35 +02:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_EXECUTE_COMMAND_LIST);
|
2018-08-16 09:39:19 +02:00
|
|
|
WINED3D_TO_STR(WINED3D_CS_OP_STOP);
|
|
|
|
#undef WINED3D_TO_STR
|
|
|
|
}
|
2020-07-22 19:00:58 +02:00
|
|
|
return wine_dbg_sprintf("UNKNOWN_OP(%#x)", op);
|
2018-08-16 09:39:19 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static void wined3d_cs_exec_nop(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-09-27 00:15:14 +02:00
|
|
|
static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2020-05-26 18:10:10 +02:00
|
|
|
struct wined3d_texture *logo_texture, *cursor_texture, *back_buffer;
|
2020-05-29 18:03:34 +02:00
|
|
|
struct wined3d_rendertarget_view *dsv = cs->state.fb.depth_stencil;
|
2013-09-27 00:15:13 +02:00
|
|
|
const struct wined3d_cs_present *op = data;
|
2020-05-29 18:03:34 +02:00
|
|
|
const struct wined3d_swapchain_desc *desc;
|
2013-09-27 00:15:13 +02:00
|
|
|
struct wined3d_swapchain *swapchain;
|
2016-07-10 15:09:16 +02:00
|
|
|
unsigned int i;
|
2013-09-27 00:15:13 +02:00
|
|
|
|
|
|
|
swapchain = op->swapchain;
|
2020-05-29 18:03:34 +02:00
|
|
|
desc = &swapchain->state.desc;
|
2020-05-26 18:10:09 +02:00
|
|
|
back_buffer = swapchain->back_buffers[0];
|
2013-09-27 00:15:13 +02:00
|
|
|
wined3d_swapchain_set_window(swapchain, op->dst_window_override);
|
2018-03-22 08:48:31 +01:00
|
|
|
|
2020-05-26 18:10:09 +02:00
|
|
|
if ((logo_texture = swapchain->device->logo_texture))
|
|
|
|
{
|
|
|
|
RECT rect = {0, 0, logo_texture->resource.width, logo_texture->resource.height};
|
|
|
|
|
|
|
|
/* Blit the logo into the upper left corner of the back-buffer. */
|
2021-04-07 03:56:44 +02:00
|
|
|
wined3d_device_context_blt(&cs->c, back_buffer, 0, &rect, logo_texture, 0,
|
2020-05-26 18:10:09 +02:00
|
|
|
&rect, WINED3D_BLT_SRC_CKEY, NULL, WINED3D_TEXF_POINT);
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:10:10 +02:00
|
|
|
if ((cursor_texture = swapchain->device->cursor_texture)
|
|
|
|
&& swapchain->device->bCursorVisible && !swapchain->device->hardwareCursor)
|
|
|
|
{
|
|
|
|
RECT dst_rect =
|
|
|
|
{
|
|
|
|
swapchain->device->xScreenSpace - swapchain->device->xHotSpot,
|
|
|
|
swapchain->device->yScreenSpace - swapchain->device->yHotSpot,
|
|
|
|
swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot,
|
|
|
|
swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot,
|
|
|
|
};
|
|
|
|
RECT src_rect =
|
|
|
|
{
|
|
|
|
0, 0, cursor_texture->resource.width, cursor_texture->resource.height
|
|
|
|
};
|
|
|
|
const RECT clip_rect = {0, 0, back_buffer->resource.width, back_buffer->resource.height};
|
|
|
|
|
|
|
|
TRACE("Rendering the software cursor.\n");
|
|
|
|
|
2020-05-29 18:03:34 +02:00
|
|
|
if (desc->windowed)
|
2020-05-26 18:10:10 +02:00
|
|
|
MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&dst_rect, 2);
|
|
|
|
if (wined3d_clip_blit(&clip_rect, &dst_rect, &src_rect))
|
2021-04-07 03:56:44 +02:00
|
|
|
wined3d_device_context_blt(&cs->c, back_buffer, 0, &dst_rect, cursor_texture, 0,
|
2020-05-26 18:10:10 +02:00
|
|
|
&src_rect, WINED3D_BLT_ALPHA_TEST, NULL, WINED3D_TEXF_POINT);
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:51:04 +01:00
|
|
|
swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->swap_interval, op->flags);
|
2016-07-10 15:09:16 +02:00
|
|
|
|
2020-05-29 18:03:34 +02:00
|
|
|
/* Discard buffers if the swap effect allows it. */
|
|
|
|
back_buffer = swapchain->back_buffers[desc->backbuffer_count - 1];
|
|
|
|
if (desc->swap_effect == WINED3D_SWAP_EFFECT_DISCARD || desc->swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
|
|
|
|
wined3d_texture_validate_location(back_buffer, 0, WINED3D_LOCATION_DISCARDED);
|
|
|
|
|
|
|
|
if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
|
|
|
|
{
|
|
|
|
struct wined3d_texture *ds = texture_from_resource(dsv->resource);
|
|
|
|
|
|
|
|
if ((desc->flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL || ds->flags & WINED3D_TEXTURE_DISCARD))
|
|
|
|
wined3d_rendertarget_view_validate_location(dsv, WINED3D_LOCATION_DISCARDED);
|
|
|
|
}
|
|
|
|
|
2020-05-21 20:51:38 +02:00
|
|
|
if (TRACE_ON(fps))
|
|
|
|
{
|
|
|
|
DWORD time = GetTickCount();
|
|
|
|
++swapchain->frames;
|
|
|
|
|
|
|
|
/* every 1.5 seconds */
|
|
|
|
if (time - swapchain->prev_time > 1500)
|
|
|
|
{
|
|
|
|
TRACE_(fps)("%p @ approx %.2ffps\n",
|
|
|
|
swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time));
|
|
|
|
swapchain->prev_time = time;
|
|
|
|
swapchain->frames = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-10 15:09:16 +02:00
|
|
|
wined3d_resource_release(&swapchain->front_buffer->resource);
|
2020-05-29 18:03:34 +02:00
|
|
|
for (i = 0; i < desc->backbuffer_count; ++i)
|
2016-07-10 15:09:16 +02:00
|
|
|
{
|
|
|
|
wined3d_resource_release(&swapchain->back_buffers[i]->resource);
|
|
|
|
}
|
2017-05-02 11:35:30 +02:00
|
|
|
|
|
|
|
InterlockedDecrement(&cs->pending_presents);
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
|
2018-03-22 08:48:31 +01:00
|
|
|
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
|
|
|
|
unsigned int swap_interval, DWORD flags)
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_present *op;
|
2016-07-10 15:09:16 +02:00
|
|
|
unsigned int i;
|
2017-05-02 11:35:30 +02:00
|
|
|
LONG pending;
|
2013-09-27 00:15:13 +02:00
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-27 00:15:13 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_PRESENT;
|
|
|
|
op->dst_window_override = dst_window_override;
|
|
|
|
op->swapchain = swapchain;
|
2016-03-25 17:52:30 +01:00
|
|
|
op->src_rect = *src_rect;
|
|
|
|
op->dst_rect = *dst_rect;
|
2018-03-22 08:48:31 +01:00
|
|
|
op->swap_interval = swap_interval;
|
2013-09-27 00:15:13 +02:00
|
|
|
op->flags = flags;
|
|
|
|
|
2017-05-02 11:35:30 +02:00
|
|
|
pending = InterlockedIncrement(&cs->pending_presents);
|
|
|
|
|
2016-07-10 15:09:16 +02:00
|
|
|
wined3d_resource_acquire(&swapchain->front_buffer->resource);
|
2019-07-29 13:30:55 +02:00
|
|
|
for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
|
2016-07-10 15:09:16 +02:00
|
|
|
{
|
|
|
|
wined3d_resource_acquire(&swapchain->back_buffers[i]->resource);
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2017-05-02 11:35:30 +02:00
|
|
|
|
|
|
|
/* Limit input latency by limiting the number of presents that we can get
|
2018-04-30 20:15:01 +02:00
|
|
|
* ahead of the worker thread. */
|
|
|
|
while (pending >= swapchain->max_frame_latency)
|
2017-05-02 11:35:30 +02:00
|
|
|
{
|
2021-01-21 05:35:48 +01:00
|
|
|
YieldProcessor();
|
2017-05-02 11:35:30 +02:00
|
|
|
pending = InterlockedCompareExchange(&cs->pending_presents, 0, 0);
|
|
|
|
}
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 00:15:14 +02:00
|
|
|
static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
2021-03-05 04:29:47 +01:00
|
|
|
struct wined3d_device *device = cs->c.device;
|
2013-09-27 00:15:14 +02:00
|
|
|
const struct wined3d_cs_clear *op = data;
|
2016-07-10 15:09:17 +02:00
|
|
|
unsigned int i;
|
2013-09-27 00:15:14 +02:00
|
|
|
|
2021-05-27 18:14:28 +02:00
|
|
|
device->blitter->ops->blitter_clear(device->blitter, device, op->rt_count, &op->fb,
|
2017-04-05 10:21:25 +02:00
|
|
|
op->rect_count, op->rects, &op->draw_rect, op->flags, &op->color, op->depth, op->stencil);
|
2016-07-10 15:09:17 +02:00
|
|
|
|
|
|
|
if (op->flags & WINED3DCLEAR_TARGET)
|
|
|
|
{
|
2017-04-05 10:21:25 +02:00
|
|
|
for (i = 0; i < op->rt_count; ++i)
|
2016-07-10 15:09:17 +02:00
|
|
|
{
|
2021-05-27 18:14:28 +02:00
|
|
|
if (op->fb.render_targets[i])
|
|
|
|
wined3d_resource_release(op->fb.render_targets[i]->resource);
|
2016-07-10 15:09:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (op->flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
|
2021-05-27 18:14:28 +02:00
|
|
|
wined3d_resource_release(op->fb.depth_stencil->resource);
|
2013-09-27 00:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
|
|
|
|
DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
|
|
|
|
{
|
2021-03-05 04:29:48 +01:00
|
|
|
const struct wined3d_state *state = cs->c.state;
|
2018-04-14 11:12:38 +02:00
|
|
|
const struct wined3d_viewport *vp = &state->viewports[0];
|
2018-03-28 21:05:15 +02:00
|
|
|
struct wined3d_rendertarget_view *view;
|
2013-09-27 00:15:14 +02:00
|
|
|
struct wined3d_cs_clear *op;
|
2019-01-08 17:12:51 +01:00
|
|
|
unsigned int rt_count, i;
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
rt_count = flags & WINED3DCLEAR_TARGET ? cs->c.device->adapter->d3d_info.limits.max_rt_count : 0;
|
2013-09-27 00:15:14 +02:00
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, FIELD_OFFSET(struct wined3d_cs_clear, rects[rect_count]),
|
2017-05-21 17:53:42 +02:00
|
|
|
WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-27 00:15:14 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_CLEAR;
|
2019-01-10 15:10:13 +01:00
|
|
|
op->flags = flags & (WINED3DCLEAR_TARGET | WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL);
|
2019-01-08 17:12:51 +01:00
|
|
|
op->rt_count = rt_count;
|
2021-05-27 18:14:28 +02:00
|
|
|
op->fb = state->fb;
|
2018-02-08 22:58:44 +01:00
|
|
|
SetRect(&op->draw_rect, vp->x, vp->y, vp->x + vp->width, vp->y + vp->height);
|
2020-03-07 05:18:35 +01:00
|
|
|
if (state->rasterizer_state && state->rasterizer_state->desc.scissor)
|
2018-04-23 14:34:03 +02:00
|
|
|
IntersectRect(&op->draw_rect, &op->draw_rect, &state->scissor_rects[0]);
|
2016-03-24 18:24:31 +01:00
|
|
|
op->color = *color;
|
2013-09-27 00:15:14 +02:00
|
|
|
op->depth = depth;
|
|
|
|
op->stencil = stencil;
|
2016-03-24 18:24:31 +01:00
|
|
|
op->rect_count = rect_count;
|
|
|
|
memcpy(op->rects, rects, sizeof(*rects) * rect_count);
|
2013-09-27 00:15:14 +02:00
|
|
|
|
2019-01-08 17:12:51 +01:00
|
|
|
for (i = 0; i < rt_count; ++i)
|
2016-07-10 15:09:17 +02:00
|
|
|
{
|
2020-03-26 13:25:57 +01:00
|
|
|
if ((view = state->fb.render_targets[i]))
|
2019-01-08 17:12:51 +01:00
|
|
|
wined3d_resource_acquire(view->resource);
|
2016-07-10 15:09:17 +02:00
|
|
|
}
|
|
|
|
if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
|
2018-03-28 21:05:15 +02:00
|
|
|
{
|
2020-03-26 13:25:57 +01:00
|
|
|
view = state->fb.depth_stencil;
|
2018-03-28 21:05:15 +02:00
|
|
|
wined3d_resource_acquire(view->resource);
|
|
|
|
}
|
2016-07-10 15:09:17 +02:00
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-27 00:15:14 +02:00
|
|
|
}
|
|
|
|
|
2021-04-08 04:20:02 +02:00
|
|
|
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)
|
2017-04-05 10:21:25 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_clear *op;
|
2018-02-25 23:23:33 +01:00
|
|
|
size_t size;
|
2017-04-05 10:21:25 +02:00
|
|
|
|
2021-05-27 18:14:28 +02:00
|
|
|
size = FIELD_OFFSET(struct wined3d_cs_clear, rects[1]);
|
2021-04-08 04:20:02 +02:00
|
|
|
op = wined3d_device_context_require_space(context, size, WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-05 10:21:25 +02:00
|
|
|
|
|
|
|
op->opcode = WINED3D_CS_OP_CLEAR;
|
2019-01-10 15:10:13 +01:00
|
|
|
op->flags = flags & (WINED3DCLEAR_TARGET | WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL);
|
2017-04-05 10:21:25 +02:00
|
|
|
if (flags & WINED3DCLEAR_TARGET)
|
|
|
|
{
|
|
|
|
op->rt_count = 1;
|
2021-05-27 18:14:28 +02:00
|
|
|
op->fb.render_targets[0] = view;
|
|
|
|
op->fb.depth_stencil = NULL;
|
2017-04-05 10:21:25 +02:00
|
|
|
op->color = *color;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
op->rt_count = 0;
|
2021-05-27 18:14:28 +02:00
|
|
|
op->fb.render_targets[0] = NULL;
|
|
|
|
op->fb.depth_stencil = view;
|
2017-04-05 10:21:25 +02:00
|
|
|
op->depth = depth;
|
|
|
|
op->stencil = stencil;
|
|
|
|
}
|
|
|
|
SetRect(&op->draw_rect, 0, 0, view->width, view->height);
|
|
|
|
op->rect_count = 1;
|
|
|
|
op->rects[0] = *rect;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, view->resource);
|
2017-04-05 10:21:25 +02:00
|
|
|
|
2021-04-08 04:20:02 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2018-09-27 17:30:34 +02:00
|
|
|
if (flags & WINED3DCLEAR_SYNCHRONOUS)
|
2021-04-08 04:20:02 +02:00
|
|
|
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-05 10:21:25 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static void acquire_shader_resources(struct wined3d_device_context *context, unsigned int shader_mask)
|
2017-02-01 11:26:20 +01:00
|
|
|
{
|
2021-05-06 05:23:10 +02:00
|
|
|
const struct wined3d_state *state = context->state;
|
2017-02-01 11:26:20 +01:00
|
|
|
struct wined3d_shader_sampler_map_entry *entry;
|
|
|
|
struct wined3d_shader_resource_view *view;
|
|
|
|
struct wined3d_shader *shader;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
|
|
|
|
{
|
2017-02-01 11:26:22 +01:00
|
|
|
if (!(shader_mask & (1u << i)))
|
|
|
|
continue;
|
|
|
|
|
2017-02-01 11:26:20 +01:00
|
|
|
if (!(shader = state->shader[i]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < WINED3D_MAX_CBS; ++j)
|
|
|
|
{
|
|
|
|
if (state->cb[i][j])
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &state->cb[i][j]->resource);
|
2017-02-01 11:26:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
|
|
|
|
{
|
|
|
|
entry = &shader->reg_maps.sampler_map.entries[j];
|
|
|
|
|
|
|
|
if (!(view = state->shader_resource_view[i][entry->resource_idx]))
|
|
|
|
continue;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, view->resource);
|
2017-02-01 11:26:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-01 11:26:22 +01:00
|
|
|
static void release_shader_resources(const struct wined3d_state *state, unsigned int shader_mask)
|
2013-09-27 00:15:15 +02:00
|
|
|
{
|
2016-07-10 15:09:18 +02:00
|
|
|
struct wined3d_shader_sampler_map_entry *entry;
|
|
|
|
struct wined3d_shader_resource_view *view;
|
|
|
|
struct wined3d_shader *shader;
|
|
|
|
unsigned int i, j;
|
2013-09-27 00:15:15 +02:00
|
|
|
|
2017-02-01 11:26:21 +01:00
|
|
|
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
|
|
|
|
{
|
2017-02-01 11:26:22 +01:00
|
|
|
if (!(shader_mask & (1u << i)))
|
|
|
|
continue;
|
|
|
|
|
2017-02-01 11:26:21 +01:00
|
|
|
if (!(shader = state->shader[i]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < WINED3D_MAX_CBS; ++j)
|
|
|
|
{
|
|
|
|
if (state->cb[i][j])
|
|
|
|
wined3d_resource_release(&state->cb[i][j]->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
|
|
|
|
{
|
|
|
|
entry = &shader->reg_maps.sampler_map.entries[j];
|
|
|
|
|
|
|
|
if (!(view = state->shader_resource_view[i][entry->resource_idx]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wined3d_resource_release(view->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static void acquire_unordered_access_resources(struct wined3d_device_context *context,
|
|
|
|
const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views)
|
2017-02-09 12:00:30 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!shader)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
|
|
|
|
{
|
|
|
|
if (!shader->reg_maps.uav_resource_info[i].type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!views[i])
|
|
|
|
continue;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, views[i]->resource);
|
2017-02-09 12:00:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_unordered_access_resources(const struct wined3d_shader *shader,
|
|
|
|
struct wined3d_unordered_access_view * const *views)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!shader)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
|
|
|
|
{
|
|
|
|
if (!shader->reg_maps.uav_resource_info[i].type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!views[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wined3d_resource_release(views[i]->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-02 12:43:40 +01:00
|
|
|
static void wined3d_cs_exec_dispatch(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_dispatch *op = data;
|
2017-02-28 06:11:59 +01:00
|
|
|
struct wined3d_state *state = &cs->state;
|
2017-02-02 12:43:40 +01:00
|
|
|
|
2020-05-12 22:42:56 +02:00
|
|
|
if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE])
|
|
|
|
WARN("No compute shader bound, skipping dispatch.\n");
|
|
|
|
else
|
2021-03-05 04:29:47 +01:00
|
|
|
cs->c.device->adapter->adapter_ops->adapter_dispatch_compute(cs->c.device, state, &op->parameters);
|
2017-08-14 23:47:41 +02:00
|
|
|
|
|
|
|
if (op->parameters.indirect)
|
|
|
|
wined3d_resource_release(&op->parameters.u.indirect.buffer->resource);
|
2017-02-02 12:43:40 +01:00
|
|
|
|
2017-02-09 12:00:30 +01:00
|
|
|
release_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
|
|
|
|
release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
|
2017-02-09 12:00:36 +01:00
|
|
|
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
|
2017-02-02 12:43:40 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static void acquire_compute_pipeline_resources(struct wined3d_device_context *context)
|
2017-08-14 23:47:41 +02:00
|
|
|
{
|
2021-05-06 05:23:10 +02:00
|
|
|
const struct wined3d_state *state = context->state;
|
|
|
|
|
|
|
|
acquire_shader_resources(context, 1u << WINED3D_SHADER_TYPE_COMPUTE);
|
|
|
|
acquire_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_COMPUTE],
|
2017-08-14 23:47:41 +02:00
|
|
|
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
|
|
|
|
}
|
|
|
|
|
2021-03-26 04:09:52 +01:00
|
|
|
void CDECL wined3d_device_context_dispatch(struct wined3d_device_context *context,
|
2017-02-02 12:43:40 +01:00
|
|
|
unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_dispatch *op;
|
|
|
|
|
2021-03-26 04:09:52 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-02 12:43:40 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_DISPATCH;
|
2017-08-14 23:47:41 +02:00
|
|
|
op->parameters.indirect = FALSE;
|
|
|
|
op->parameters.u.direct.group_count_x = group_count_x;
|
|
|
|
op->parameters.u.direct.group_count_y = group_count_y;
|
|
|
|
op->parameters.u.direct.group_count_z = group_count_z;
|
2017-02-02 12:43:40 +01:00
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
acquire_compute_pipeline_resources(context);
|
2017-08-14 23:47:41 +02:00
|
|
|
|
2021-03-26 04:09:52 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-08-14 23:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-03-26 04:09:54 +01:00
|
|
|
void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_context *context,
|
2017-08-14 23:47:41 +02:00
|
|
|
struct wined3d_buffer *buffer, unsigned int offset)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_dispatch *op;
|
|
|
|
|
2021-03-26 04:09:54 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-08-14 23:47:41 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_DISPATCH;
|
|
|
|
op->parameters.indirect = TRUE;
|
|
|
|
op->parameters.u.indirect.buffer = buffer;
|
|
|
|
op->parameters.u.indirect.offset = offset;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
acquire_compute_pipeline_resources(context);
|
|
|
|
wined3d_device_context_acquire_resource(context, &buffer->resource);
|
2017-02-02 12:43:40 +01:00
|
|
|
|
2021-03-26 04:09:54 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-02 12:43:40 +01:00
|
|
|
}
|
|
|
|
|
2017-02-01 11:26:21 +01:00
|
|
|
static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
2021-03-05 04:29:47 +01:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &cs->c.device->adapter->d3d_info;
|
2018-04-23 16:20:16 +02:00
|
|
|
const struct wined3d_shader *geometry_shader;
|
2021-03-05 04:29:47 +01:00
|
|
|
struct wined3d_device *device = cs->c.device;
|
2018-11-22 17:49:02 +01:00
|
|
|
int base_vertex_idx, load_base_vertex_idx;
|
2017-02-28 06:11:58 +01:00
|
|
|
struct wined3d_state *state = &cs->state;
|
2017-02-01 11:26:21 +01:00
|
|
|
const struct wined3d_cs_draw *op = data;
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-11-22 17:49:02 +01:00
|
|
|
base_vertex_idx = 0;
|
|
|
|
if (!op->parameters.indirect)
|
|
|
|
{
|
|
|
|
const struct wined3d_direct_draw_parameters *direct = &op->parameters.u.direct;
|
|
|
|
|
2019-03-03 19:55:21 +01:00
|
|
|
if (op->parameters.indexed && d3d_info->draw_base_vertex_offset)
|
2018-11-22 17:49:02 +01:00
|
|
|
base_vertex_idx = direct->base_vertex_idx;
|
2018-11-22 17:49:03 +01:00
|
|
|
else if (!op->parameters.indexed)
|
|
|
|
base_vertex_idx = direct->start_idx;
|
2018-11-22 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
2017-11-01 22:08:42 +01:00
|
|
|
/* ARB_draw_indirect always supports a base vertex offset. */
|
2019-03-03 19:55:21 +01:00
|
|
|
if (!op->parameters.indirect && !d3d_info->draw_base_vertex_offset)
|
2017-11-01 22:08:42 +01:00
|
|
|
load_base_vertex_idx = op->parameters.u.direct.base_vertex_idx;
|
|
|
|
else
|
|
|
|
load_base_vertex_idx = 0;
|
|
|
|
|
2018-11-22 17:49:04 +01:00
|
|
|
if (state->base_vertex_index != base_vertex_idx)
|
|
|
|
{
|
|
|
|
state->base_vertex_index = base_vertex_idx;
|
|
|
|
for (i = 0; i < device->context_count; ++i)
|
|
|
|
device->contexts[i]->constant_update_mask |= WINED3D_SHADER_CONST_BASE_VERTEX_ID;
|
|
|
|
}
|
|
|
|
|
2017-11-01 22:08:42 +01:00
|
|
|
if (state->load_base_vertex_index != load_base_vertex_idx)
|
2016-06-21 10:32:45 +02:00
|
|
|
{
|
2017-11-01 22:08:42 +01:00
|
|
|
state->load_base_vertex_index = load_base_vertex_idx;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_BASEVERTEXINDEX);
|
2016-06-21 10:32:45 +02:00
|
|
|
}
|
|
|
|
|
2020-05-20 15:42:28 +02:00
|
|
|
if (state->primitive_type != op->primitive_type)
|
2017-02-26 07:46:33 +01:00
|
|
|
{
|
2018-04-23 16:20:16 +02:00
|
|
|
if ((geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]) && !geometry_shader->function)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY));
|
2020-05-20 15:42:28 +02:00
|
|
|
if (state->primitive_type == WINED3D_PT_POINTLIST || op->primitive_type == WINED3D_PT_POINTLIST)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_POINT_ENABLE);
|
2020-05-20 15:42:28 +02:00
|
|
|
state->primitive_type = op->primitive_type;
|
2017-02-26 07:46:33 +01:00
|
|
|
}
|
2020-05-20 15:42:29 +02:00
|
|
|
state->patch_vertex_count = op->patch_vertex_count;
|
2017-02-26 07:46:33 +01:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
cs->c.device->adapter->adapter_ops->adapter_draw_primitive(cs->c.device, state, &op->parameters);
|
2017-11-01 22:08:42 +01:00
|
|
|
|
|
|
|
if (op->parameters.indirect)
|
|
|
|
{
|
|
|
|
struct wined3d_buffer *buffer = op->parameters.u.indirect.buffer;
|
|
|
|
wined3d_resource_release(&buffer->resource);
|
|
|
|
}
|
2016-07-10 15:09:18 +02:00
|
|
|
|
2017-11-01 22:08:42 +01:00
|
|
|
if (op->parameters.indexed)
|
2016-07-10 15:09:18 +02:00
|
|
|
wined3d_resource_release(&state->index_buffer->resource);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
|
|
|
|
{
|
|
|
|
if (state->streams[i].buffer)
|
|
|
|
wined3d_resource_release(&state->streams[i].buffer->resource);
|
|
|
|
}
|
2017-03-29 15:11:07 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
|
|
|
|
{
|
|
|
|
if (state->stream_output[i].buffer)
|
|
|
|
wined3d_resource_release(&state->stream_output[i].buffer->resource);
|
|
|
|
}
|
2016-07-10 15:09:18 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
|
|
|
|
{
|
|
|
|
if (state->textures[i])
|
|
|
|
wined3d_resource_release(&state->textures[i]->resource);
|
|
|
|
}
|
2018-08-24 15:44:03 +02:00
|
|
|
for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
|
2016-07-10 15:09:18 +02:00
|
|
|
{
|
2020-03-26 13:25:57 +01:00
|
|
|
if (state->fb.render_targets[i])
|
|
|
|
wined3d_resource_release(state->fb.render_targets[i]->resource);
|
2016-07-10 15:09:18 +02:00
|
|
|
}
|
2020-03-26 13:25:57 +01:00
|
|
|
if (state->fb.depth_stencil)
|
|
|
|
wined3d_resource_release(state->fb.depth_stencil->resource);
|
2017-02-01 11:26:22 +01:00
|
|
|
release_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
|
2017-02-09 12:00:30 +01:00
|
|
|
release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
|
2017-02-09 12:00:36 +01:00
|
|
|
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
|
2013-09-27 00:15:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static void acquire_graphics_pipeline_resources(struct wined3d_device_context *context,
|
2018-08-24 15:44:03 +02:00
|
|
|
BOOL indexed, const struct wined3d_d3d_info *d3d_info)
|
2013-09-27 00:15:15 +02:00
|
|
|
{
|
2021-05-06 05:23:10 +02:00
|
|
|
const struct wined3d_state *state = context->state;
|
2017-02-01 11:26:20 +01:00
|
|
|
unsigned int i;
|
2013-09-27 00:15:15 +02:00
|
|
|
|
2016-07-10 15:09:18 +02:00
|
|
|
if (indexed)
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &state->index_buffer->resource);
|
2016-07-10 15:09:18 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
|
|
|
|
{
|
|
|
|
if (state->streams[i].buffer)
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &state->streams[i].buffer->resource);
|
2016-07-10 15:09:18 +02:00
|
|
|
}
|
2017-03-29 15:11:07 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
|
|
|
|
{
|
|
|
|
if (state->stream_output[i].buffer)
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &state->stream_output[i].buffer->resource);
|
2017-03-29 15:11:07 +02:00
|
|
|
}
|
2016-07-10 15:09:18 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
|
|
|
|
{
|
|
|
|
if (state->textures[i])
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &state->textures[i]->resource);
|
2016-07-10 15:09:18 +02:00
|
|
|
}
|
2018-08-24 15:44:03 +02:00
|
|
|
for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
|
2016-07-10 15:09:18 +02:00
|
|
|
{
|
2020-03-26 13:25:57 +01:00
|
|
|
if (state->fb.render_targets[i])
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, state->fb.render_targets[i]->resource);
|
2016-07-10 15:09:18 +02:00
|
|
|
}
|
2020-03-26 13:25:57 +01:00
|
|
|
if (state->fb.depth_stencil)
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, state->fb.depth_stencil->resource);
|
|
|
|
acquire_shader_resources(context, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
|
|
|
|
acquire_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_PIXEL],
|
2017-02-09 12:00:36 +01:00
|
|
|
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
|
2017-11-01 22:08:41 +01:00
|
|
|
}
|
|
|
|
|
2021-03-27 20:34:22 +01:00
|
|
|
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)
|
2017-11-01 22:08:41 +01:00
|
|
|
{
|
2021-03-27 20:34:22 +01:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &context->device->adapter->d3d_info;
|
2017-11-01 22:08:41 +01:00
|
|
|
struct wined3d_cs_draw *op;
|
|
|
|
|
2021-03-27 20:34:22 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-11-01 22:08:41 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_DRAW;
|
|
|
|
op->primitive_type = primitive_type;
|
|
|
|
op->patch_vertex_count = patch_vertex_count;
|
2017-11-01 22:08:42 +01:00
|
|
|
op->parameters.indirect = FALSE;
|
|
|
|
op->parameters.u.direct.base_vertex_idx = base_vertex_idx;
|
|
|
|
op->parameters.u.direct.start_idx = start_idx;
|
|
|
|
op->parameters.u.direct.index_count = index_count;
|
|
|
|
op->parameters.u.direct.start_instance = start_instance;
|
|
|
|
op->parameters.u.direct.instance_count = instance_count;
|
|
|
|
op->parameters.indexed = indexed;
|
2017-11-01 22:08:41 +01:00
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
acquire_graphics_pipeline_resources(context, indexed, d3d_info);
|
2016-07-10 15:09:18 +02:00
|
|
|
|
2021-03-27 20:34:22 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-27 00:15:15 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 18:00:06 +02:00
|
|
|
void CDECL wined3d_device_context_draw_indirect(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_buffer *buffer, unsigned int offset, bool indexed)
|
2017-11-01 22:08:42 +01:00
|
|
|
{
|
2021-04-02 18:00:06 +02:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &context->device->adapter->d3d_info;
|
|
|
|
const struct wined3d_state *state = context->state;
|
2017-11-01 22:08:42 +01:00
|
|
|
struct wined3d_cs_draw *op;
|
|
|
|
|
2021-04-02 18:00:06 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-11-01 22:08:42 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_DRAW;
|
2021-04-02 18:00:06 +02:00
|
|
|
op->primitive_type = state->primitive_type;
|
|
|
|
op->patch_vertex_count = state->patch_vertex_count;
|
2017-11-01 22:08:42 +01:00
|
|
|
op->parameters.indirect = TRUE;
|
|
|
|
op->parameters.u.indirect.buffer = buffer;
|
|
|
|
op->parameters.u.indirect.offset = offset;
|
|
|
|
op->parameters.indexed = indexed;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
acquire_graphics_pipeline_resources(context, indexed, d3d_info);
|
|
|
|
wined3d_device_context_acquire_resource(context, &buffer->resource);
|
2017-11-01 22:08:42 +01:00
|
|
|
|
2021-04-02 18:00:06 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-11-01 22:08:42 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:00 +02:00
|
|
|
static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
2019-08-15 11:50:01 +02:00
|
|
|
struct wined3d_context *context;
|
2017-04-13 00:11:00 +02:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
|
|
|
cs->c.device->adapter->adapter_ops->adapter_flush_context(context);
|
2019-08-15 11:50:01 +02:00
|
|
|
context_release(context);
|
2017-04-13 00:11:00 +02:00
|
|
|
}
|
|
|
|
|
2021-04-14 04:05:26 +02:00
|
|
|
static void wined3d_cs_flush(struct wined3d_device_context *context)
|
2017-04-13 00:11:00 +02:00
|
|
|
{
|
2021-04-14 04:05:26 +02:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2017-04-13 00:11:00 +02:00
|
|
|
struct wined3d_cs_flush *op;
|
|
|
|
|
2021-04-14 04:05:26 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-13 00:11:00 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_FLUSH;
|
|
|
|
|
2021-04-14 04:05:26 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-09-08 18:44:08 +02:00
|
|
|
cs->queries_flushed = TRUE;
|
2017-04-13 00:11:00 +02:00
|
|
|
}
|
|
|
|
|
2014-09-19 10:41:46 +02:00
|
|
|
static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_predication *op = data;
|
|
|
|
|
|
|
|
cs->state.predicate = op->predicate;
|
|
|
|
cs->state.predicate_value = op->value;
|
|
|
|
}
|
|
|
|
|
2021-03-19 05:16:37 +01:00
|
|
|
void wined3d_device_context_emit_set_predication(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_query *predicate, BOOL value)
|
2014-09-19 10:41:46 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_predication *op;
|
|
|
|
|
2021-03-19 05:16:37 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2014-09-19 10:41:46 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_PREDICATION;
|
|
|
|
op->predicate = predicate;
|
|
|
|
op->value = value;
|
|
|
|
|
2021-03-19 05:16:37 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2014-09-19 10:41:46 +02:00
|
|
|
}
|
|
|
|
|
2018-04-14 11:12:38 +02:00
|
|
|
static void wined3d_cs_exec_set_viewports(struct wined3d_cs *cs, const void *data)
|
2013-09-30 09:40:39 +02:00
|
|
|
{
|
2018-04-14 11:12:38 +02:00
|
|
|
const struct wined3d_cs_set_viewports *op = data;
|
2013-09-30 09:40:39 +02:00
|
|
|
|
2018-04-14 11:12:38 +02:00
|
|
|
if (op->viewport_count)
|
|
|
|
memcpy(cs->state.viewports, op->viewports, op->viewport_count * sizeof(*op->viewports));
|
|
|
|
else
|
|
|
|
memset(cs->state.viewports, 0, sizeof(*cs->state.viewports));
|
|
|
|
cs->state.viewport_count = op->viewport_count;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_VIEWPORT);
|
2013-09-30 09:40:39 +02:00
|
|
|
}
|
|
|
|
|
2021-03-16 06:42:18 +01:00
|
|
|
void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count,
|
2018-04-14 11:12:38 +02:00
|
|
|
const struct wined3d_viewport *viewports)
|
2013-09-30 09:40:39 +02:00
|
|
|
{
|
2018-04-14 11:12:38 +02:00
|
|
|
struct wined3d_cs_set_viewports *op;
|
2013-09-30 09:40:39 +02:00
|
|
|
|
2021-03-16 06:42:18 +01:00
|
|
|
op = wined3d_device_context_require_space(context,
|
|
|
|
FIELD_OFFSET(struct wined3d_cs_set_viewports,viewports[viewport_count]), WINED3D_CS_QUEUE_DEFAULT);
|
2018-04-14 11:12:38 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_VIEWPORTS;
|
2018-04-25 11:23:50 +02:00
|
|
|
memcpy(op->viewports, viewports, viewport_count * sizeof(*viewports));
|
2018-04-14 11:12:38 +02:00
|
|
|
op->viewport_count = viewport_count;
|
2013-09-30 09:40:39 +02:00
|
|
|
|
2021-03-16 06:42:18 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-30 09:40:39 +02:00
|
|
|
}
|
|
|
|
|
2018-04-23 14:34:03 +02:00
|
|
|
static void wined3d_cs_exec_set_scissor_rects(struct wined3d_cs *cs, const void *data)
|
2013-09-30 09:40:41 +02:00
|
|
|
{
|
2018-04-23 14:34:03 +02:00
|
|
|
const struct wined3d_cs_set_scissor_rects *op = data;
|
2013-09-30 09:40:41 +02:00
|
|
|
|
2018-04-23 14:34:03 +02:00
|
|
|
if (op->rect_count)
|
|
|
|
memcpy(cs->state.scissor_rects, op->rects, op->rect_count * sizeof(*op->rects));
|
|
|
|
else
|
|
|
|
SetRectEmpty(cs->state.scissor_rects);
|
|
|
|
cs->state.scissor_rect_count = op->rect_count;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SCISSORRECT);
|
2013-09-30 09:40:41 +02:00
|
|
|
}
|
|
|
|
|
2021-03-16 06:42:21 +01:00
|
|
|
void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context,
|
|
|
|
unsigned int rect_count, const RECT *rects)
|
2013-09-30 09:40:41 +02:00
|
|
|
{
|
2018-04-23 14:34:03 +02:00
|
|
|
struct wined3d_cs_set_scissor_rects *op;
|
2013-09-30 09:40:41 +02:00
|
|
|
|
2021-03-16 06:42:21 +01:00
|
|
|
op = wined3d_device_context_require_space(context, FIELD_OFFSET(struct wined3d_cs_set_scissor_rects, rects[rect_count]),
|
2018-04-23 14:34:03 +02:00
|
|
|
WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECTS;
|
2018-04-25 11:23:50 +02:00
|
|
|
memcpy(op->rects, rects, rect_count * sizeof(*rects));
|
2018-04-23 14:34:03 +02:00
|
|
|
op->rect_count = rect_count;
|
2013-09-30 09:40:41 +02:00
|
|
|
|
2021-03-16 06:42:21 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-09-30 09:40:41 +02:00
|
|
|
}
|
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
static void wined3d_cs_exec_set_rendertarget_view(struct wined3d_cs *cs, const void *data)
|
2013-10-01 10:38:29 +02:00
|
|
|
{
|
2014-08-21 09:55:55 +02:00
|
|
|
const struct wined3d_cs_set_rendertarget_view *op = data;
|
2021-03-25 16:46:42 +01:00
|
|
|
bool prev_alpha_swizzle, curr_alpha_swizzle;
|
2018-10-01 18:01:15 +02:00
|
|
|
struct wined3d_rendertarget_view *prev;
|
2021-03-25 16:46:42 +01:00
|
|
|
bool prev_srgb_write, curr_srgb_write;
|
|
|
|
struct wined3d_device *device;
|
2013-10-01 10:38:29 +02:00
|
|
|
|
2021-03-25 16:46:42 +01:00
|
|
|
device = cs->c.device;
|
2020-03-26 13:25:57 +01:00
|
|
|
prev = cs->state.fb.render_targets[op->view_idx];
|
|
|
|
cs->state.fb.render_targets[op->view_idx] = op->view;
|
2021-03-25 16:46:42 +01:00
|
|
|
device_invalidate_state(device, STATE_FRAMEBUFFER);
|
2018-10-01 18:01:15 +02:00
|
|
|
|
|
|
|
prev_alpha_swizzle = prev && prev->format->id == WINED3DFMT_A8_UNORM;
|
|
|
|
curr_alpha_swizzle = op->view && op->view->format->id == WINED3DFMT_A8_UNORM;
|
|
|
|
if (prev_alpha_swizzle != curr_alpha_swizzle)
|
2021-03-25 16:46:42 +01:00
|
|
|
device_invalidate_state(device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL));
|
|
|
|
|
|
|
|
if (!(device->adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
|
|
|
|
|| cs->state.render_states[WINED3D_RS_SRGBWRITEENABLE])
|
|
|
|
{
|
|
|
|
prev_srgb_write = prev && prev->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
|
|
|
|
curr_srgb_write = op->view && op->view->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
|
|
|
|
if (prev_srgb_write != curr_srgb_write)
|
|
|
|
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE));
|
|
|
|
}
|
2013-10-01 10:38:29 +02:00
|
|
|
}
|
|
|
|
|
2021-03-18 01:45:16 +01:00
|
|
|
void wined3d_device_context_emit_set_rendertarget_view(struct wined3d_device_context *context, unsigned int view_idx,
|
2014-08-21 09:55:55 +02:00
|
|
|
struct wined3d_rendertarget_view *view)
|
2013-10-01 10:38:29 +02:00
|
|
|
{
|
2014-08-21 09:55:55 +02:00
|
|
|
struct wined3d_cs_set_rendertarget_view *op;
|
2013-10-01 10:38:29 +02:00
|
|
|
|
2021-03-18 01:45:16 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2014-08-21 09:55:55 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW;
|
|
|
|
op->view_idx = view_idx;
|
|
|
|
op->view = view;
|
2013-10-01 10:38:29 +02:00
|
|
|
|
2021-03-18 01:45:16 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-01 10:38:29 +02:00
|
|
|
}
|
|
|
|
|
2014-08-22 12:32:01 +02:00
|
|
|
static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const void *data)
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
2014-08-22 12:32:01 +02:00
|
|
|
const struct wined3d_cs_set_depth_stencil_view *op = data;
|
2021-03-05 04:29:47 +01:00
|
|
|
struct wined3d_device *device = cs->c.device;
|
2014-08-22 12:32:01 +02:00
|
|
|
struct wined3d_rendertarget_view *prev;
|
2013-10-01 10:38:30 +02:00
|
|
|
|
2020-03-26 13:25:57 +01:00
|
|
|
if ((prev = cs->state.fb.depth_stencil) && prev->resource->type != WINED3D_RTYPE_BUFFER)
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
2018-03-14 09:09:14 +01:00
|
|
|
struct wined3d_texture *prev_texture = texture_from_resource(prev->resource);
|
2014-08-22 12:32:01 +02:00
|
|
|
|
2019-07-29 13:30:55 +02:00
|
|
|
if (device->swapchains[0]->state.desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
|
2018-03-14 09:09:14 +01:00
|
|
|
|| prev_texture->flags & WINED3D_TEXTURE_DISCARD)
|
|
|
|
wined3d_texture_validate_location(prev_texture,
|
2017-01-26 13:25:19 +01:00
|
|
|
prev->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
|
2013-10-01 10:38:30 +02:00
|
|
|
}
|
|
|
|
|
2020-03-26 13:25:57 +01:00
|
|
|
cs->state.fb.depth_stencil = op->view;
|
2013-10-01 10:38:30 +02:00
|
|
|
|
2014-08-22 12:32:01 +02:00
|
|
|
if (!prev != !op->view)
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
|
|
|
/* Swapping NULL / non NULL depth stencil affects the depth and tests */
|
2020-09-25 05:43:13 +02:00
|
|
|
device_invalidate_state(device, STATE_DEPTH_STENCIL);
|
2021-02-05 11:37:16 +01:00
|
|
|
device_invalidate_state(device, STATE_STENCIL_REF);
|
2020-03-07 05:18:34 +01:00
|
|
|
device_invalidate_state(device, STATE_RASTERIZER);
|
2013-10-01 10:38:30 +02:00
|
|
|
}
|
2019-08-28 18:44:28 +02:00
|
|
|
else if (prev)
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
2019-08-28 18:44:28 +02:00
|
|
|
if (prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
|
2020-03-07 05:18:34 +01:00
|
|
|
device_invalidate_state(device, STATE_RASTERIZER);
|
2019-08-28 18:44:28 +02:00
|
|
|
if (prev->format->stencil_size != op->view->format->stencil_size)
|
2021-02-03 14:12:47 +01:00
|
|
|
device_invalidate_state(device, STATE_STENCIL_REF);
|
2013-10-01 10:38:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
device_invalidate_state(device, STATE_FRAMEBUFFER);
|
|
|
|
}
|
|
|
|
|
2021-03-19 05:16:34 +01:00
|
|
|
void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_rendertarget_view *view)
|
2013-10-01 10:38:30 +02:00
|
|
|
{
|
2014-08-22 12:32:01 +02:00
|
|
|
struct wined3d_cs_set_depth_stencil_view *op;
|
2013-10-01 10:38:30 +02:00
|
|
|
|
2021-03-19 05:16:34 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2014-08-22 12:32:01 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW;
|
|
|
|
op->view = view;
|
2013-10-01 10:38:30 +02:00
|
|
|
|
2021-03-19 05:16:34 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-01 10:38:30 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 10:38:31 +02:00
|
|
|
static void wined3d_cs_exec_set_vertex_declaration(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_vertex_declaration *op = data;
|
|
|
|
|
|
|
|
cs->state.vertex_declaration = op->declaration;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_VDECL);
|
2013-10-01 10:38:31 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 00:19:25 +01:00
|
|
|
void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_vertex_declaration *declaration)
|
2013-10-01 10:38:31 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_vertex_declaration *op;
|
|
|
|
|
2021-03-25 00:19:25 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-01 10:38:31 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION;
|
|
|
|
op->declaration = declaration;
|
|
|
|
|
2021-03-25 00:19:25 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-01 10:38:31 +02:00
|
|
|
}
|
|
|
|
|
2013-10-02 09:55:26 +02:00
|
|
|
static void wined3d_cs_exec_set_stream_source(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_stream_source *op = data;
|
|
|
|
struct wined3d_stream_state *stream;
|
|
|
|
struct wined3d_buffer *prev;
|
|
|
|
|
|
|
|
stream = &cs->state.streams[op->stream_idx];
|
|
|
|
prev = stream->buffer;
|
|
|
|
stream->buffer = op->buffer;
|
|
|
|
stream->offset = op->offset;
|
|
|
|
stream->stride = op->stride;
|
|
|
|
|
|
|
|
if (op->buffer)
|
|
|
|
InterlockedIncrement(&op->buffer->resource.bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource.bind_count);
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_STREAMSRC);
|
2013-10-02 09:55:26 +02:00
|
|
|
}
|
|
|
|
|
2021-03-23 16:39:13 +01:00
|
|
|
void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx,
|
|
|
|
struct wined3d_buffer *buffer, unsigned int offset, unsigned int stride)
|
2013-10-02 09:55:26 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_stream_source *op;
|
|
|
|
|
2021-03-23 16:39:13 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-02 09:55:26 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE;
|
|
|
|
op->stream_idx = stream_idx;
|
|
|
|
op->buffer = buffer;
|
|
|
|
op->offset = offset;
|
|
|
|
op->stride = stride;
|
|
|
|
|
2021-03-23 16:39:13 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-02 09:55:26 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 08:54:11 +02:00
|
|
|
static void wined3d_cs_exec_set_stream_source_freq(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_stream_source_freq *op = data;
|
|
|
|
struct wined3d_stream_state *stream;
|
|
|
|
|
|
|
|
stream = &cs->state.streams[op->stream_idx];
|
|
|
|
stream->frequency = op->frequency;
|
|
|
|
stream->flags = op->flags;
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_STREAMSRC);
|
2013-10-03 08:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx, UINT frequency, UINT flags)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_set_stream_source_freq *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:11 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ;
|
|
|
|
op->stream_idx = stream_idx;
|
|
|
|
op->frequency = frequency;
|
|
|
|
op->flags = flags;
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:11 +02:00
|
|
|
}
|
|
|
|
|
2013-10-10 23:49:46 +02:00
|
|
|
static void wined3d_cs_exec_set_stream_output(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_stream_output *op = data;
|
|
|
|
struct wined3d_stream_output *stream;
|
|
|
|
struct wined3d_buffer *prev;
|
|
|
|
|
|
|
|
stream = &cs->state.stream_output[op->stream_idx];
|
|
|
|
prev = stream->buffer;
|
|
|
|
stream->buffer = op->buffer;
|
|
|
|
stream->offset = op->offset;
|
|
|
|
|
|
|
|
if (op->buffer)
|
|
|
|
InterlockedIncrement(&op->buffer->resource.bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource.bind_count);
|
2017-03-29 15:11:08 +02:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_STREAM_OUTPUT);
|
2013-10-10 23:49:46 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 00:19:28 +01:00
|
|
|
void wined3d_device_context_emit_set_stream_output(struct wined3d_device_context *context, unsigned int stream_idx,
|
|
|
|
struct wined3d_buffer *buffer, unsigned int offset)
|
2013-10-10 23:49:46 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_stream_output *op;
|
|
|
|
|
2021-03-25 00:19:28 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:46 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT;
|
|
|
|
op->stream_idx = stream_idx;
|
|
|
|
op->buffer = buffer;
|
|
|
|
op->offset = offset;
|
|
|
|
|
2021-03-25 00:19:28 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:46 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 08:54:12 +02:00
|
|
|
static void wined3d_cs_exec_set_index_buffer(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_index_buffer *op = data;
|
|
|
|
struct wined3d_buffer *prev;
|
|
|
|
|
|
|
|
prev = cs->state.index_buffer;
|
|
|
|
cs->state.index_buffer = op->buffer;
|
|
|
|
cs->state.index_format = op->format_id;
|
2016-06-02 11:14:13 +02:00
|
|
|
cs->state.index_offset = op->offset;
|
2013-10-03 08:54:12 +02:00
|
|
|
|
|
|
|
if (op->buffer)
|
|
|
|
InterlockedIncrement(&op->buffer->resource.bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource.bind_count);
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_INDEXBUFFER);
|
2013-10-03 08:54:12 +02:00
|
|
|
}
|
|
|
|
|
2021-03-23 16:39:16 +01:00
|
|
|
void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer,
|
2016-06-02 11:14:13 +02:00
|
|
|
enum wined3d_format_id format_id, unsigned int offset)
|
2013-10-03 08:54:12 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_index_buffer *op;
|
|
|
|
|
2021-03-23 16:39:16 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:12 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_INDEX_BUFFER;
|
|
|
|
op->buffer = buffer;
|
|
|
|
op->format_id = format_id;
|
2016-06-02 11:14:13 +02:00
|
|
|
op->offset = offset;
|
2013-10-03 08:54:12 +02:00
|
|
|
|
2021-03-23 16:39:16 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:12 +02:00
|
|
|
}
|
|
|
|
|
2013-10-10 23:49:44 +02:00
|
|
|
static void wined3d_cs_exec_set_constant_buffer(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_constant_buffer *op = data;
|
|
|
|
struct wined3d_buffer *prev;
|
|
|
|
|
|
|
|
prev = cs->state.cb[op->type][op->cb_idx];
|
|
|
|
cs->state.cb[op->type][op->cb_idx] = op->buffer;
|
|
|
|
|
|
|
|
if (op->buffer)
|
|
|
|
InterlockedIncrement(&op->buffer->resource.bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource.bind_count);
|
2014-08-04 12:17:23 +02:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_CONSTANT_BUFFER(op->type));
|
2013-10-10 23:49:44 +02:00
|
|
|
}
|
|
|
|
|
2021-03-07 23:19:22 +01:00
|
|
|
void wined3d_device_context_emit_set_constant_buffer(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer)
|
2013-10-10 23:49:44 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_constant_buffer *op;
|
|
|
|
|
2021-03-07 23:19:22 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:44 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER;
|
|
|
|
op->type = type;
|
|
|
|
op->cb_idx = cb_idx;
|
|
|
|
op->buffer = buffer;
|
|
|
|
|
2021-03-07 23:19:22 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:44 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 08:54:13 +02:00
|
|
|
static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
2021-03-05 04:29:47 +01:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &cs->c.device->adapter->d3d_info;
|
2013-10-03 08:54:13 +02:00
|
|
|
const struct wined3d_cs_set_texture *op = data;
|
|
|
|
struct wined3d_texture *prev;
|
2015-04-14 11:16:22 +02:00
|
|
|
BOOL old_use_color_key = FALSE, new_use_color_key = FALSE;
|
2013-10-03 08:54:13 +02:00
|
|
|
|
|
|
|
prev = cs->state.textures[op->stage];
|
|
|
|
cs->state.textures[op->stage] = op->texture;
|
|
|
|
|
|
|
|
if (op->texture)
|
|
|
|
{
|
2014-11-03 22:38:27 +01:00
|
|
|
const struct wined3d_format *new_format = op->texture->resource.format;
|
|
|
|
const struct wined3d_format *old_format = prev ? prev->resource.format : NULL;
|
2015-04-22 11:30:15 +02:00
|
|
|
unsigned int old_fmt_flags = prev ? prev->resource.format_flags : 0;
|
|
|
|
unsigned int new_fmt_flags = op->texture->resource.format_flags;
|
2014-11-03 22:38:27 +01:00
|
|
|
|
2013-10-03 08:54:13 +02:00
|
|
|
if (InterlockedIncrement(&op->texture->resource.bind_count) == 1)
|
|
|
|
op->texture->sampler = op->stage;
|
|
|
|
|
2018-10-30 10:48:44 +01:00
|
|
|
if (!prev || wined3d_texture_gl(op->texture)->target != wined3d_texture_gl(prev)->target
|
2016-03-23 21:19:10 +01:00
|
|
|
|| (!is_same_fixup(new_format->color_fixup, old_format->color_fixup)
|
2019-05-07 11:03:38 +02:00
|
|
|
&& !(can_use_texture_swizzle(d3d_info, new_format) && can_use_texture_swizzle(d3d_info, old_format)))
|
2015-04-22 11:30:15 +02:00
|
|
|
|| (new_fmt_flags & WINED3DFMT_FLAG_SHADOW) != (old_fmt_flags & WINED3DFMT_FLAG_SHADOW))
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL));
|
2013-10-03 08:54:13 +02:00
|
|
|
|
|
|
|
if (!prev && op->stage < d3d_info->limits.ffp_blend_stages)
|
|
|
|
{
|
|
|
|
/* The source arguments for color and alpha ops have different
|
|
|
|
* meanings when a NULL texture is bound, so the COLOR_OP and
|
|
|
|
* ALPHA_OP have to be dirtified. */
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, WINED3D_TSS_COLOR_OP));
|
|
|
|
device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, WINED3D_TSS_ALPHA_OP));
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
2015-04-14 11:16:22 +02:00
|
|
|
|
|
|
|
if (!op->stage && op->texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT)
|
|
|
|
new_use_color_key = TRUE;
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
{
|
|
|
|
if (InterlockedDecrement(&prev->resource.bind_count) && prev->sampler == op->stage)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
/* Search for other stages the texture is bound to. Shouldn't
|
|
|
|
* happen if applications bind textures to a single stage only. */
|
|
|
|
TRACE("Searching for other stages the texture is bound to.\n");
|
2019-02-20 21:54:00 +01:00
|
|
|
for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
|
2013-10-03 08:54:13 +02:00
|
|
|
{
|
|
|
|
if (cs->state.textures[i] == prev)
|
|
|
|
{
|
|
|
|
TRACE("Texture is also bound to stage %u.\n", i);
|
|
|
|
prev->sampler = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!op->texture && op->stage < d3d_info->limits.ffp_blend_stages)
|
|
|
|
{
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, WINED3D_TSS_COLOR_OP));
|
|
|
|
device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, WINED3D_TSS_ALPHA_OP));
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
2015-04-14 11:16:22 +02:00
|
|
|
|
|
|
|
if (!op->stage && prev->async.color_key_flags & WINED3D_CKEY_SRC_BLT)
|
|
|
|
old_use_color_key = TRUE;
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SAMPLER(op->stage));
|
2015-04-14 11:16:22 +02:00
|
|
|
|
|
|
|
if (new_use_color_key != old_use_color_key)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_RENDER(WINED3D_RS_COLORKEYENABLE));
|
2015-04-14 11:16:22 +02:00
|
|
|
|
|
|
|
if (new_use_color_key)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_COLOR_KEY);
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 18:10:00 +02:00
|
|
|
void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage,
|
|
|
|
struct wined3d_texture *texture)
|
2013-10-03 08:54:13 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_texture *op;
|
|
|
|
|
2021-05-12 18:10:00 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:13 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_TEXTURE;
|
|
|
|
op->stage = stage;
|
|
|
|
op->texture = texture;
|
|
|
|
|
2021-05-12 18:10:00 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 08:54:13 +02:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:44:16 +02:00
|
|
|
static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_shader_resource_view *op = data;
|
2017-02-13 13:07:33 +01:00
|
|
|
struct wined3d_shader_resource_view *prev;
|
2014-09-16 10:44:16 +02:00
|
|
|
|
2017-02-13 13:07:33 +01:00
|
|
|
prev = cs->state.shader_resource_view[op->type][op->view_idx];
|
2014-09-16 10:44:16 +02:00
|
|
|
cs->state.shader_resource_view[op->type][op->view_idx] = op->view;
|
2017-02-13 13:07:33 +01:00
|
|
|
|
|
|
|
if (op->view)
|
|
|
|
InterlockedIncrement(&op->view->resource->bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource->bind_count);
|
|
|
|
|
2017-02-06 14:12:14 +01:00
|
|
|
if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
|
2017-02-22 13:19:30 +01:00
|
|
|
else
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
|
2014-09-16 10:44:16 +02:00
|
|
|
}
|
|
|
|
|
2021-03-17 01:06:05 +01:00
|
|
|
void wined3d_device_context_emit_set_shader_resource_view(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_shader_type type, unsigned int view_idx, struct wined3d_shader_resource_view *view)
|
2016-11-23 14:36:05 +01:00
|
|
|
{
|
2017-02-09 12:00:28 +01:00
|
|
|
struct wined3d_cs_set_shader_resource_view *op;
|
2016-11-23 14:36:05 +01:00
|
|
|
|
2021-03-17 01:06:05 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-09 12:00:28 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW;
|
|
|
|
op->type = type;
|
2016-11-23 14:36:05 +01:00
|
|
|
op->view_idx = view_idx;
|
|
|
|
op->view = view;
|
|
|
|
|
2021-03-17 01:06:05 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2016-11-23 14:36:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_cs_exec_set_unordered_access_view(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_unordered_access_view *op = data;
|
|
|
|
struct wined3d_unordered_access_view *prev;
|
|
|
|
|
2017-02-09 12:00:36 +01:00
|
|
|
prev = cs->state.unordered_access_view[op->pipeline][op->view_idx];
|
|
|
|
cs->state.unordered_access_view[op->pipeline][op->view_idx] = op->view;
|
2016-11-23 14:36:05 +01:00
|
|
|
|
|
|
|
if (op->view)
|
|
|
|
InterlockedIncrement(&op->view->resource->bind_count);
|
|
|
|
if (prev)
|
|
|
|
InterlockedDecrement(&prev->resource->bind_count);
|
|
|
|
|
2017-08-31 09:04:34 +02:00
|
|
|
if (op->view && op->initial_count != ~0u)
|
2017-08-04 19:53:50 +02:00
|
|
|
wined3d_unordered_access_view_set_counter(op->view, op->initial_count);
|
2017-08-31 09:04:34 +02:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_UNORDERED_ACCESS_VIEW_BINDING(op->pipeline));
|
2016-11-23 14:36:05 +01:00
|
|
|
}
|
|
|
|
|
2021-03-18 01:45:13 +01:00
|
|
|
void wined3d_device_context_emit_set_unordered_access_view(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_pipeline pipeline, unsigned int view_idx, struct wined3d_unordered_access_view *view,
|
|
|
|
unsigned int initial_count)
|
2014-09-16 10:44:16 +02:00
|
|
|
{
|
2017-02-09 12:00:28 +01:00
|
|
|
struct wined3d_cs_set_unordered_access_view *op;
|
2014-09-16 10:44:16 +02:00
|
|
|
|
2021-03-18 01:45:13 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-09 12:00:28 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW;
|
2017-02-09 12:00:36 +01:00
|
|
|
op->pipeline = pipeline;
|
2017-02-09 12:00:29 +01:00
|
|
|
op->view_idx = view_idx;
|
|
|
|
op->view = view;
|
2017-08-04 19:53:50 +02:00
|
|
|
op->initial_count = initial_count;
|
2017-02-09 12:00:29 +01:00
|
|
|
|
2021-03-18 01:45:13 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-09 12:00:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-10 23:49:45 +02:00
|
|
|
static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_sampler *op = data;
|
|
|
|
|
|
|
|
cs->state.sampler[op->type][op->sampler_idx] = op->sampler;
|
2017-02-22 13:19:30 +01:00
|
|
|
if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
|
2017-02-22 13:19:30 +01:00
|
|
|
else
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
|
2013-10-10 23:49:45 +02:00
|
|
|
}
|
|
|
|
|
2021-03-17 01:06:08 +01:00
|
|
|
void wined3d_device_context_emit_set_sampler(struct wined3d_device_context *context, enum wined3d_shader_type type,
|
|
|
|
unsigned int sampler_idx, struct wined3d_sampler *sampler)
|
2013-10-10 23:49:45 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_sampler *op;
|
|
|
|
|
2021-03-17 01:06:08 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:45 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_SAMPLER;
|
|
|
|
op->type = type;
|
|
|
|
op->sampler_idx = sampler_idx;
|
|
|
|
op->sampler = sampler;
|
|
|
|
|
2021-03-17 01:06:08 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-10 23:49:45 +02:00
|
|
|
}
|
|
|
|
|
2013-10-09 22:57:45 +02:00
|
|
|
static void wined3d_cs_exec_set_shader(struct wined3d_cs *cs, const void *data)
|
2013-10-03 23:31:44 +02:00
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_shader *op = data;
|
|
|
|
|
2013-10-09 22:57:45 +02:00
|
|
|
cs->state.shader[op->type] = op->shader;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SHADER(op->type));
|
2017-02-06 14:12:14 +01:00
|
|
|
if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
|
2017-02-22 13:19:30 +01:00
|
|
|
else
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
|
2013-10-03 23:31:44 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:49 +01:00
|
|
|
void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_shader_type type, struct wined3d_shader *shader)
|
2013-10-03 23:31:44 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_shader *op;
|
|
|
|
|
2021-03-05 04:29:49 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-09 22:57:45 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_SHADER;
|
|
|
|
op->type = type;
|
2013-10-03 23:31:46 +02:00
|
|
|
op->shader = shader;
|
|
|
|
|
2021-03-05 04:29:49 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-03 23:31:46 +02:00
|
|
|
}
|
|
|
|
|
2018-02-08 15:22:44 +01:00
|
|
|
static void wined3d_cs_exec_set_blend_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_blend_state *op = data;
|
2018-10-18 00:41:13 +02:00
|
|
|
struct wined3d_state *state = &cs->state;
|
2018-02-08 15:22:44 +01:00
|
|
|
|
2018-10-18 00:41:13 +02:00
|
|
|
if (state->blend_state != op->state)
|
|
|
|
{
|
|
|
|
state->blend_state = op->state;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_BLEND);
|
2018-10-18 00:41:13 +02:00
|
|
|
}
|
|
|
|
state->blend_factor = op->factor;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_BLEND_FACTOR);
|
2020-09-02 07:27:42 +02:00
|
|
|
state->sample_mask = op->sample_mask;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SAMPLE_MASK);
|
2018-02-08 15:22:44 +01:00
|
|
|
}
|
|
|
|
|
2021-03-10 03:08:59 +01:00
|
|
|
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)
|
2018-02-08 15:22:44 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_blend_state *op;
|
|
|
|
|
2021-03-10 03:08:59 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2018-02-08 15:22:44 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_BLEND_STATE;
|
|
|
|
op->state = state;
|
2018-10-18 00:41:13 +02:00
|
|
|
op->factor = *blend_factor;
|
2020-09-02 07:27:42 +02:00
|
|
|
op->sample_mask = sample_mask;
|
2018-02-08 15:22:44 +01:00
|
|
|
|
2021-03-10 03:08:59 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2018-02-08 15:22:44 +01:00
|
|
|
}
|
|
|
|
|
2020-09-25 05:43:11 +02:00
|
|
|
static void wined3d_cs_exec_set_depth_stencil_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_depth_stencil_state *op = data;
|
2021-02-03 14:12:47 +01:00
|
|
|
struct wined3d_state *state = &cs->state;
|
2020-09-25 05:43:11 +02:00
|
|
|
|
2021-02-03 14:12:47 +01:00
|
|
|
if (state->depth_stencil_state != op->state)
|
|
|
|
{
|
|
|
|
state->depth_stencil_state = op->state;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_DEPTH_STENCIL);
|
2021-02-03 14:12:47 +01:00
|
|
|
}
|
|
|
|
state->stencil_ref = op->stencil_ref;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_STENCIL_REF);
|
2020-09-25 05:43:11 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:25:15 +01:00
|
|
|
void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context *context,
|
2021-02-03 14:12:47 +01:00
|
|
|
struct wined3d_depth_stencil_state *state, unsigned int stencil_ref)
|
2020-09-25 05:43:11 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_depth_stencil_state *op;
|
|
|
|
|
2021-03-11 02:25:15 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2020-09-25 05:43:11 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE;
|
|
|
|
op->state = state;
|
2021-02-03 14:12:47 +01:00
|
|
|
op->stencil_ref = stencil_ref;
|
2020-09-25 05:43:11 +02:00
|
|
|
|
2021-03-11 02:25:15 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2020-09-25 05:43:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-27 23:33:41 +02:00
|
|
|
static void wined3d_cs_exec_set_rasterizer_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_rasterizer_state *op = data;
|
|
|
|
|
|
|
|
cs->state.rasterizer_state = op->state;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_RASTERIZER);
|
2016-07-27 23:33:41 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:25:18 +01:00
|
|
|
void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context *context,
|
2016-07-27 23:33:41 +02:00
|
|
|
struct wined3d_rasterizer_state *rasterizer_state)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_set_rasterizer_state *op;
|
|
|
|
|
2021-03-11 02:25:18 +01:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2016-07-27 23:33:41 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE;
|
|
|
|
op->state = rasterizer_state;
|
|
|
|
|
2021-03-11 02:25:18 +01:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2016-07-27 23:33:41 +02:00
|
|
|
}
|
|
|
|
|
2013-10-06 17:33:04 +02:00
|
|
|
static void wined3d_cs_exec_set_render_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_render_state *op = data;
|
|
|
|
|
|
|
|
cs->state.render_states[op->state] = op->value;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_RENDER(op->state));
|
2013-10-06 17:33:04 +02:00
|
|
|
}
|
|
|
|
|
2021-05-16 23:36:36 +02:00
|
|
|
void wined3d_device_context_emit_set_render_state(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_render_state state, unsigned int value)
|
2013-10-06 17:33:04 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_render_state *op;
|
|
|
|
|
2021-05-16 23:36:36 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-06 17:33:04 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_RENDER_STATE;
|
|
|
|
op->state = state;
|
|
|
|
op->value = value;
|
|
|
|
|
2021-05-16 23:36:36 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-06 17:33:04 +02:00
|
|
|
}
|
|
|
|
|
2013-10-07 22:15:47 +02:00
|
|
|
static void wined3d_cs_exec_set_texture_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_texture_state *op = data;
|
|
|
|
|
|
|
|
cs->state.texture_states[op->stage][op->state] = op->value;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_TEXTURESTAGE(op->stage, op->state));
|
2013-10-07 22:15:47 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 18:10:01 +02:00
|
|
|
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)
|
2013-10-07 22:15:47 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_texture_state *op;
|
|
|
|
|
2021-05-12 18:10:01 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:47 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_TEXTURE_STATE;
|
|
|
|
op->stage = stage;
|
|
|
|
op->state = state;
|
|
|
|
op->value = value;
|
|
|
|
|
2021-05-12 18:10:01 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:47 +02:00
|
|
|
}
|
|
|
|
|
2013-10-07 22:15:48 +02:00
|
|
|
static void wined3d_cs_exec_set_sampler_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_sampler_state *op = data;
|
|
|
|
|
|
|
|
cs->state.sampler_states[op->sampler_idx][op->state] = op->value;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_SAMPLER(op->sampler_idx));
|
2013-10-07 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 18:10:02 +02:00
|
|
|
void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx,
|
|
|
|
enum wined3d_sampler_state state, unsigned int value)
|
2013-10-07 22:15:48 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_sampler_state *op;
|
|
|
|
|
2021-05-12 18:10:02 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:48 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE;
|
|
|
|
op->sampler_idx = sampler_idx;
|
|
|
|
op->state = state;
|
|
|
|
op->value = value;
|
|
|
|
|
2021-05-12 18:10:02 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2013-10-07 22:15:49 +02:00
|
|
|
static void wined3d_cs_exec_set_transform(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_transform *op = data;
|
|
|
|
|
2016-03-21 17:40:15 +01:00
|
|
|
cs->state.transforms[op->state] = op->matrix;
|
2021-03-05 04:29:47 +01:00
|
|
|
if (op->state < WINED3D_TS_WORLD_MATRIX(cs->c.device->adapter->d3d_info.limits.ffp_vertex_blend_matrices))
|
|
|
|
device_invalidate_state(cs->c.device, STATE_TRANSFORM(op->state));
|
2013-10-07 22:15:49 +02:00
|
|
|
}
|
|
|
|
|
2021-05-13 17:47:48 +02:00
|
|
|
void wined3d_device_context_emit_set_transform(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
|
2013-10-07 22:15:49 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_transform *op;
|
|
|
|
|
2021-05-13 17:47:48 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:49 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_TRANSFORM;
|
|
|
|
op->state = state;
|
2016-03-21 17:40:15 +01:00
|
|
|
op->matrix = *matrix;
|
2013-10-07 22:15:49 +02:00
|
|
|
|
2021-05-13 17:47:48 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-07 22:15:49 +02:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:39:36 +02:00
|
|
|
static void wined3d_cs_exec_set_clip_plane(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_clip_plane *op = data;
|
|
|
|
|
2016-03-19 10:35:51 +01:00
|
|
|
cs->state.clip_planes[op->plane_idx] = op->plane;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_CLIPPLANE(op->plane_idx));
|
2013-10-09 10:39:36 +02:00
|
|
|
}
|
|
|
|
|
2021-05-13 17:47:49 +02:00
|
|
|
void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context *context,
|
|
|
|
unsigned int plane_idx, const struct wined3d_vec4 *plane)
|
2013-10-09 10:39:36 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_clip_plane *op;
|
|
|
|
|
2021-05-13 17:47:49 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-09 10:39:36 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE;
|
|
|
|
op->plane_idx = plane_idx;
|
2016-03-19 10:35:51 +01:00
|
|
|
op->plane = *plane;
|
2013-10-09 10:39:36 +02:00
|
|
|
|
2021-05-13 17:47:49 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-09 10:39:36 +02:00
|
|
|
}
|
|
|
|
|
2015-04-09 22:48:11 +02:00
|
|
|
static void wined3d_cs_exec_set_color_key(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_color_key *op = data;
|
|
|
|
struct wined3d_texture *texture = op->texture;
|
|
|
|
|
|
|
|
if (op->set)
|
|
|
|
{
|
2015-08-23 21:59:35 +02:00
|
|
|
switch (op->flags)
|
2015-04-09 22:48:11 +02:00
|
|
|
{
|
|
|
|
case WINED3D_CKEY_DST_BLT:
|
|
|
|
texture->async.dst_blt_color_key = op->color_key;
|
|
|
|
texture->async.color_key_flags |= WINED3D_CKEY_DST_BLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_DST_OVERLAY:
|
|
|
|
texture->async.dst_overlay_color_key = op->color_key;
|
|
|
|
texture->async.color_key_flags |= WINED3D_CKEY_DST_OVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_SRC_BLT:
|
2015-04-14 11:16:23 +02:00
|
|
|
if (texture == cs->state.textures[0])
|
|
|
|
{
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_COLOR_KEY);
|
2015-04-14 11:16:23 +02:00
|
|
|
if (!(texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT))
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_RENDER(WINED3D_RS_COLORKEYENABLE));
|
2015-04-14 11:16:23 +02:00
|
|
|
}
|
|
|
|
|
2015-04-09 22:48:11 +02:00
|
|
|
texture->async.src_blt_color_key = op->color_key;
|
|
|
|
texture->async.color_key_flags |= WINED3D_CKEY_SRC_BLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_SRC_OVERLAY:
|
|
|
|
texture->async.src_overlay_color_key = op->color_key;
|
|
|
|
texture->async.color_key_flags |= WINED3D_CKEY_SRC_OVERLAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-23 21:59:35 +02:00
|
|
|
switch (op->flags)
|
2015-04-09 22:48:11 +02:00
|
|
|
{
|
|
|
|
case WINED3D_CKEY_DST_BLT:
|
|
|
|
texture->async.color_key_flags &= ~WINED3D_CKEY_DST_BLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_DST_OVERLAY:
|
|
|
|
texture->async.color_key_flags &= ~WINED3D_CKEY_DST_OVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_SRC_BLT:
|
2015-04-14 11:16:23 +02:00
|
|
|
if (texture == cs->state.textures[0] && texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_RENDER(WINED3D_RS_COLORKEYENABLE));
|
2015-04-14 11:16:23 +02:00
|
|
|
|
2015-04-09 22:48:11 +02:00
|
|
|
texture->async.color_key_flags &= ~WINED3D_CKEY_SRC_BLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_CKEY_SRC_OVERLAY:
|
|
|
|
texture->async.color_key_flags &= ~WINED3D_CKEY_SRC_OVERLAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
|
|
|
|
WORD flags, const struct wined3d_color_key *color_key)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_set_color_key *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2015-04-09 22:48:11 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_COLOR_KEY;
|
|
|
|
op->texture = texture;
|
|
|
|
op->flags = flags;
|
|
|
|
if (color_key)
|
|
|
|
{
|
|
|
|
op->color_key = *color_key;
|
|
|
|
op->set = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
op->set = 0;
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2015-04-09 22:48:11 +02:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:39:37 +02:00
|
|
|
static void wined3d_cs_exec_set_material(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_material *op = data;
|
|
|
|
|
2016-03-17 16:30:07 +01:00
|
|
|
cs->state.material = op->material;
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_MATERIAL);
|
2013-10-09 10:39:37 +02:00
|
|
|
}
|
|
|
|
|
2021-05-13 17:47:50 +02:00
|
|
|
void wined3d_device_context_emit_set_material(struct wined3d_device_context *context,
|
|
|
|
const struct wined3d_material *material)
|
2013-10-09 10:39:37 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_material *op;
|
|
|
|
|
2021-05-13 17:47:50 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-09 10:39:37 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_MATERIAL;
|
2016-03-17 16:30:07 +01:00
|
|
|
op->material = *material;
|
2013-10-09 10:39:37 +02:00
|
|
|
|
2021-05-13 17:47:50 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2013-10-09 10:39:37 +02:00
|
|
|
}
|
|
|
|
|
2017-02-19 18:16:35 +01:00
|
|
|
static void wined3d_cs_exec_set_light(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_light *op = data;
|
|
|
|
struct wined3d_light_info *light_info;
|
|
|
|
unsigned int light_idx, hash_idx;
|
|
|
|
|
|
|
|
light_idx = op->light.OriginalIndex;
|
|
|
|
|
2019-02-12 17:45:05 +01:00
|
|
|
if (!(light_info = wined3d_light_state_get_light(&cs->state.light_state, light_idx)))
|
2017-02-19 18:16:35 +01:00
|
|
|
{
|
|
|
|
TRACE("Adding new light.\n");
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(light_info = heap_alloc_zero(sizeof(*light_info))))
|
2017-02-19 18:16:35 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate light info.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hash_idx = LIGHTMAP_HASHFUNC(light_idx);
|
2019-02-12 17:45:05 +01:00
|
|
|
list_add_head(&cs->state.light_state.light_map[hash_idx], &light_info->entry);
|
2017-02-19 18:16:35 +01:00
|
|
|
light_info->glIndex = -1;
|
|
|
|
light_info->OriginalIndex = light_idx;
|
|
|
|
}
|
|
|
|
|
2017-02-19 18:16:36 +01:00
|
|
|
if (light_info->glIndex != -1)
|
|
|
|
{
|
|
|
|
if (light_info->OriginalParms.type != op->light.OriginalParms.type)
|
2021-03-05 04:29:47 +01:00
|
|
|
device_invalidate_state(cs->c.device, STATE_LIGHT_TYPE);
|
|
|
|
device_invalidate_state(cs->c.device, STATE_ACTIVELIGHT(light_info->glIndex));
|
2017-02-19 18:16:36 +01:00
|
|
|
}
|
|
|
|
|
2017-02-19 18:16:35 +01:00
|
|
|
light_info->OriginalParms = op->light.OriginalParms;
|
|
|
|
light_info->position = op->light.position;
|
|
|
|
light_info->direction = op->light.direction;
|
|
|
|
light_info->exponent = op->light.exponent;
|
|
|
|
light_info->cutoff = op->light.cutoff;
|
|
|
|
}
|
|
|
|
|
2021-05-13 17:47:52 +02:00
|
|
|
void wined3d_device_context_emit_set_light(struct wined3d_device_context *context,
|
|
|
|
const struct wined3d_light_info *light)
|
2017-02-19 18:16:35 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_light *op;
|
|
|
|
|
2021-05-13 17:47:52 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-19 18:16:35 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_LIGHT;
|
|
|
|
op->light = *light;
|
|
|
|
|
2021-05-13 17:47:52 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-19 18:16:35 +01:00
|
|
|
}
|
|
|
|
|
2017-02-19 18:16:36 +01:00
|
|
|
static void wined3d_cs_exec_set_light_enable(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_light_enable *op = data;
|
2021-03-05 04:29:47 +01:00
|
|
|
struct wined3d_device *device = cs->c.device;
|
2017-02-19 18:16:36 +01:00
|
|
|
struct wined3d_light_info *light_info;
|
|
|
|
int prev_idx;
|
|
|
|
|
2019-02-12 17:45:05 +01:00
|
|
|
if (!(light_info = wined3d_light_state_get_light(&cs->state.light_state, op->idx)))
|
2017-02-19 18:16:36 +01:00
|
|
|
{
|
|
|
|
ERR("Light doesn't exist.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_idx = light_info->glIndex;
|
2019-02-12 17:45:05 +01:00
|
|
|
wined3d_light_state_enable_light(&cs->state.light_state, &device->adapter->d3d_info, light_info, op->enable);
|
2017-02-19 18:16:36 +01:00
|
|
|
if (light_info->glIndex != prev_idx)
|
|
|
|
{
|
|
|
|
device_invalidate_state(device, STATE_LIGHT_TYPE);
|
|
|
|
device_invalidate_state(device, STATE_ACTIVELIGHT(op->enable ? light_info->glIndex : prev_idx));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-13 17:47:51 +02:00
|
|
|
void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context *context, unsigned int idx, BOOL enable)
|
2017-02-19 18:16:36 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_light_enable *op;
|
|
|
|
|
2021-05-13 17:47:51 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-19 18:16:36 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE;
|
|
|
|
op->idx = idx;
|
|
|
|
op->enable = enable;
|
|
|
|
|
2021-05-13 17:47:51 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-19 18:16:36 +01:00
|
|
|
}
|
|
|
|
|
2021-03-15 16:11:36 +01:00
|
|
|
static void wined3d_cs_exec_set_feature_level(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_set_feature_level *op = data;
|
|
|
|
|
|
|
|
cs->state.feature_level = op->level;
|
|
|
|
}
|
|
|
|
|
2021-05-12 18:09:58 +02:00
|
|
|
void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_feature_level level)
|
2021-03-15 16:11:36 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_set_feature_level *op;
|
|
|
|
|
2021-05-12 18:09:58 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2021-03-15 16:11:36 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_SET_FEATURE_LEVEL;
|
|
|
|
op->level = level;
|
|
|
|
|
2021-05-12 18:09:58 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2021-03-15 16:11:36 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
|
|
|
DWORD mask;
|
|
|
|
}
|
|
|
|
wined3d_cs_push_constant_info[] =
|
|
|
|
{
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_VS_F */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, vs_consts_f), sizeof(struct wined3d_vec4), WINED3D_SHADER_CONST_VS_F},
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_PS_F */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, ps_consts_f), sizeof(struct wined3d_vec4), WINED3D_SHADER_CONST_PS_F},
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_VS_I */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, vs_consts_i), sizeof(struct wined3d_ivec4), WINED3D_SHADER_CONST_VS_I},
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_PS_I */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, ps_consts_i), sizeof(struct wined3d_ivec4), WINED3D_SHADER_CONST_PS_I},
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_VS_B */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, vs_consts_b), sizeof(BOOL), WINED3D_SHADER_CONST_VS_B},
|
|
|
|
/* WINED3D_PUSH_CONSTANTS_PS_B */
|
|
|
|
{FIELD_OFFSET(struct wined3d_state, ps_consts_b), sizeof(BOOL), WINED3D_SHADER_CONST_PS_B},
|
|
|
|
};
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_st_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants p,
|
2017-04-13 00:11:01 +02:00
|
|
|
unsigned int start_idx, unsigned int count, const void *constants)
|
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2021-03-05 04:29:47 +01:00
|
|
|
struct wined3d_device *device = cs->c.device;
|
2017-04-13 00:11:01 +02:00
|
|
|
unsigned int context_count;
|
|
|
|
unsigned int i;
|
|
|
|
size_t offset;
|
|
|
|
|
|
|
|
if (p == WINED3D_PUSH_CONSTANTS_VS_F)
|
|
|
|
device->shader_backend->shader_update_float_vertex_constants(device, start_idx, count);
|
|
|
|
else if (p == WINED3D_PUSH_CONSTANTS_PS_F)
|
|
|
|
device->shader_backend->shader_update_float_pixel_constants(device, start_idx, count);
|
|
|
|
|
|
|
|
offset = wined3d_cs_push_constant_info[p].offset + start_idx * wined3d_cs_push_constant_info[p].size;
|
|
|
|
memcpy((BYTE *)&cs->state + offset, constants, count * wined3d_cs_push_constant_info[p].size);
|
|
|
|
for (i = 0, context_count = device->context_count; i < context_count; ++i)
|
|
|
|
{
|
|
|
|
device->contexts[i]->constant_update_mask |= wined3d_cs_push_constant_info[p].mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_cs_exec_push_constants(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_push_constants *op = data;
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
wined3d_cs_st_push_constants(&cs->c, op->type, op->start_idx, op->count, op->constants);
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_mt_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants p,
|
2017-04-13 00:11:01 +02:00
|
|
|
unsigned int start_idx, unsigned int count, const void *constants)
|
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2017-04-13 00:11:01 +02:00
|
|
|
struct wined3d_cs_push_constants *op;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
size = count * wined3d_cs_push_constant_info[p].size;
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, FIELD_OFFSET(struct wined3d_cs_push_constants, constants[size]),
|
2017-05-21 17:53:42 +02:00
|
|
|
WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-13 00:11:01 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_PUSH_CONSTANTS;
|
|
|
|
op->type = p;
|
|
|
|
op->start_idx = start_idx;
|
|
|
|
op->count = count;
|
|
|
|
memcpy(op->constants, constants, size);
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
|
2014-01-09 12:16:58 +01:00
|
|
|
static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
2021-06-25 15:01:28 +02:00
|
|
|
const struct wined3d_device *device = cs->c.device;
|
2021-05-27 18:14:32 +02:00
|
|
|
const struct wined3d_cs_reset_state *op = data;
|
2021-06-25 15:01:28 +02:00
|
|
|
const struct wined3d_state_entry *state_table;
|
2021-05-27 18:14:32 +02:00
|
|
|
unsigned int state;
|
|
|
|
|
2014-01-09 12:16:58 +01:00
|
|
|
state_cleanup(&cs->state);
|
2021-06-25 15:01:28 +02:00
|
|
|
wined3d_state_reset(&cs->state, &device->adapter->d3d_info);
|
2021-05-27 18:14:32 +02:00
|
|
|
if (op->invalidate)
|
|
|
|
{
|
2021-06-25 15:01:28 +02:00
|
|
|
state_table = device->state_table;
|
2021-05-27 18:14:32 +02:00
|
|
|
for (state = 0; state <= STATE_HIGHEST; ++state)
|
2021-06-25 15:01:28 +02:00
|
|
|
{
|
|
|
|
if (state_table[state].representative)
|
|
|
|
device_invalidate_state(device, state);
|
|
|
|
}
|
2021-05-27 18:14:32 +02:00
|
|
|
}
|
2014-01-09 12:16:58 +01:00
|
|
|
}
|
|
|
|
|
2021-05-27 18:14:32 +02:00
|
|
|
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate)
|
2014-01-09 12:16:58 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_reset_state *op;
|
|
|
|
|
2021-05-27 18:14:32 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2014-01-09 12:16:58 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_RESET_STATE;
|
2021-05-27 18:14:32 +02:00
|
|
|
op->invalidate = invalidate;
|
2014-01-09 12:16:58 +01:00
|
|
|
|
2021-05-27 18:14:32 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2014-01-09 12:16:58 +01:00
|
|
|
}
|
|
|
|
|
2017-02-16 00:58:53 +01:00
|
|
|
static void wined3d_cs_exec_callback(struct wined3d_cs *cs, const void *data)
|
2016-06-21 10:32:46 +02:00
|
|
|
{
|
2017-02-16 00:58:53 +01:00
|
|
|
const struct wined3d_cs_callback *op = data;
|
2016-06-21 10:32:46 +02:00
|
|
|
|
|
|
|
op->callback(op->object);
|
|
|
|
}
|
|
|
|
|
2017-02-16 00:58:53 +01:00
|
|
|
static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
|
2016-06-21 10:32:46 +02:00
|
|
|
{
|
2017-02-16 00:58:53 +01:00
|
|
|
struct wined3d_cs_callback *op;
|
2016-06-21 10:32:46 +02:00
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-02-16 00:58:53 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_CALLBACK;
|
2016-06-21 10:32:46 +02:00
|
|
|
op->callback = callback;
|
|
|
|
op->object = object;
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2016-06-21 10:32:46 +02:00
|
|
|
}
|
|
|
|
|
2017-02-16 00:58:53 +01:00
|
|
|
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
|
|
|
|
{
|
|
|
|
wined3d_cs_emit_callback(cs, callback, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_init_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
|
|
|
|
{
|
|
|
|
wined3d_cs_emit_callback(cs, callback, object);
|
|
|
|
}
|
|
|
|
|
2016-07-29 12:34:34 +02:00
|
|
|
static void wined3d_cs_exec_query_issue(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_query_issue *op = data;
|
|
|
|
struct wined3d_query *query = op->query;
|
2017-04-13 00:11:01 +02:00
|
|
|
BOOL poll;
|
|
|
|
|
|
|
|
poll = query->query_ops->query_issue(query, op->flags);
|
2016-07-29 12:34:34 +02:00
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
if (!cs->thread)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (poll && list_empty(&query->poll_list_entry))
|
|
|
|
{
|
2018-09-28 20:18:29 +02:00
|
|
|
if (query->buffer_object)
|
|
|
|
InterlockedIncrement(&query->counter_retrieved);
|
|
|
|
else
|
|
|
|
list_add_tail(&cs->query_poll_list, &query->poll_list_entry);
|
2017-04-13 00:11:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This can happen if occlusion queries are restarted. This discards the
|
|
|
|
* old result, since polling it could result in a GL error. */
|
|
|
|
if ((op->flags & WINED3DISSUE_BEGIN) && !poll && !list_empty(&query->poll_list_entry))
|
|
|
|
{
|
|
|
|
list_remove(&query->poll_list_entry);
|
|
|
|
list_init(&query->poll_list_entry);
|
|
|
|
InterlockedIncrement(&query->counter_retrieved);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This can happen when an occlusion query is ended without being started,
|
|
|
|
* in which case we don't want to poll, but still have to counter-balance
|
|
|
|
* the increment of the main counter.
|
|
|
|
*
|
|
|
|
* This can also happen if an event query is re-issued before the first
|
|
|
|
* fence was reached. In this case the query is already in the list and
|
|
|
|
* the poll function will check the new fence. We have to counter-balance
|
|
|
|
* the discarded increment. */
|
|
|
|
if (op->flags & WINED3DISSUE_END)
|
|
|
|
InterlockedIncrement(&query->counter_retrieved);
|
2016-07-29 12:34:34 +02:00
|
|
|
}
|
|
|
|
|
2021-04-14 04:05:23 +02:00
|
|
|
static void wined3d_cs_issue_query(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_query *query, unsigned int flags)
|
2016-07-29 12:34:34 +02:00
|
|
|
{
|
2021-04-14 04:05:23 +02:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2016-07-29 12:34:34 +02:00
|
|
|
struct wined3d_cs_query_issue *op;
|
|
|
|
|
2021-05-06 05:23:12 +02:00
|
|
|
if (flags & WINED3DISSUE_END)
|
|
|
|
++query->counter_main;
|
|
|
|
|
2021-04-14 04:05:23 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2016-07-29 12:34:34 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_QUERY_ISSUE;
|
|
|
|
op->query = query;
|
|
|
|
op->flags = flags;
|
|
|
|
|
2021-04-14 04:05:23 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-09-08 18:44:08 +02:00
|
|
|
cs->queries_flushed = FALSE;
|
2021-05-06 05:23:12 +02:00
|
|
|
|
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
|
|
|
query->state = QUERY_BUILDING;
|
|
|
|
else
|
|
|
|
query->state = QUERY_SIGNALLED;
|
2016-07-29 12:34:34 +02:00
|
|
|
}
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
static void wined3d_cs_execute_command_list(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_command_list *list, bool restore_state)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_execute_command_list *op;
|
|
|
|
SIZE_T i;
|
|
|
|
|
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
op->opcode = WINED3D_CS_OP_EXECUTE_COMMAND_LIST;
|
|
|
|
op->list = list;
|
|
|
|
|
|
|
|
for (i = 0; i < list->resource_count; ++i)
|
|
|
|
wined3d_resource_acquire(list->resources[i]);
|
|
|
|
|
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
|
|
|
|
if (restore_state)
|
|
|
|
wined3d_device_context_set_state(context, context->state);
|
|
|
|
else
|
|
|
|
wined3d_device_context_reset_state(context);
|
|
|
|
}
|
|
|
|
|
2016-08-26 13:51:18 +02:00
|
|
|
static void wined3d_cs_exec_preload_resource(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_preload_resource *op = data;
|
|
|
|
struct wined3d_resource *resource = op->resource;
|
|
|
|
|
|
|
|
resource->resource_ops->resource_preload(resource);
|
|
|
|
wined3d_resource_release(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_preload_resource *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2016-08-26 13:51:18 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_PRELOAD_RESOURCE;
|
|
|
|
op->resource = resource;
|
|
|
|
|
|
|
|
wined3d_resource_acquire(resource);
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2016-08-26 13:51:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-05 12:39:01 +02:00
|
|
|
static void wined3d_cs_exec_unload_resource(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_unload_resource *op = data;
|
|
|
|
struct wined3d_resource *resource = op->resource;
|
|
|
|
|
|
|
|
resource->resource_ops->resource_unload(resource);
|
2016-08-10 18:44:46 +02:00
|
|
|
wined3d_resource_release(resource);
|
2016-08-05 12:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_unload_resource *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2016-08-05 12:39:01 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE;
|
|
|
|
op->resource = resource;
|
|
|
|
|
2016-08-10 18:44:46 +02:00
|
|
|
wined3d_resource_acquire(resource);
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2016-08-05 12:39:01 +02:00
|
|
|
}
|
|
|
|
|
2016-09-01 20:34:46 +02:00
|
|
|
static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_map *op = data;
|
|
|
|
struct wined3d_resource *resource = op->resource;
|
|
|
|
|
|
|
|
*op->hr = resource->resource_ops->resource_sub_resource_map(resource,
|
2021-06-24 22:29:06 +02:00
|
|
|
op->sub_resource_idx, op->map_ptr, op->box, op->flags);
|
2016-09-01 20:34:46 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
|
2021-06-24 22:29:06 +02:00
|
|
|
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
|
2016-09-01 20:34:46 +02:00
|
|
|
{
|
2021-04-13 05:46:29 +02:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2016-09-01 20:34:46 +02:00
|
|
|
struct wined3d_cs_map *op;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-05-02 11:35:30 +02:00
|
|
|
/* Mapping resources from the worker thread isn't an issue by itself, but
|
|
|
|
* increasing the map count would be visible to applications. */
|
|
|
|
wined3d_not_from_cs(cs);
|
|
|
|
|
2021-05-06 05:23:11 +02:00
|
|
|
wined3d_resource_wait_idle(resource);
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
|
2016-09-01 20:34:46 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_MAP;
|
|
|
|
op->resource = resource;
|
|
|
|
op->sub_resource_idx = sub_resource_idx;
|
2021-06-24 22:29:06 +02:00
|
|
|
op->map_ptr = map_ptr;
|
2016-09-01 20:34:46 +02:00
|
|
|
op->box = box;
|
|
|
|
op->flags = flags;
|
|
|
|
op->hr = &hr;
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
|
2018-11-29 14:33:47 +01:00
|
|
|
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
|
2016-09-01 20:34:46 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-09-01 20:34:47 +02:00
|
|
|
static void wined3d_cs_exec_unmap(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_unmap *op = data;
|
|
|
|
struct wined3d_resource *resource = op->resource;
|
|
|
|
|
|
|
|
*op->hr = resource->resource_ops->resource_sub_resource_unmap(resource, op->sub_resource_idx);
|
|
|
|
}
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
static HRESULT wined3d_cs_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource,
|
|
|
|
unsigned int sub_resource_idx)
|
2016-09-01 20:34:47 +02:00
|
|
|
{
|
2021-04-13 05:46:29 +02:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2016-09-01 20:34:47 +02:00
|
|
|
struct wined3d_cs_unmap *op;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-05-02 11:35:30 +02:00
|
|
|
wined3d_not_from_cs(cs);
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
|
2016-09-01 20:34:47 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_UNMAP;
|
|
|
|
op->resource = resource;
|
|
|
|
op->sub_resource_idx = sub_resource_idx;
|
|
|
|
op->hr = &hr;
|
|
|
|
|
2021-04-13 05:46:29 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
|
2018-11-29 14:33:47 +01:00
|
|
|
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
|
2016-09-01 20:34:47 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-03-08 10:53:02 +01:00
|
|
|
static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_blt_sub_resource *op = data;
|
|
|
|
|
2017-03-08 10:53:03 +01:00
|
|
|
if (op->dst_resource->type == WINED3D_RTYPE_BUFFER)
|
2017-03-08 10:53:02 +01:00
|
|
|
{
|
2017-08-04 19:53:51 +02:00
|
|
|
wined3d_buffer_copy(buffer_from_resource(op->dst_resource), op->dst_box.left,
|
2017-03-08 10:53:03 +01:00
|
|
|
buffer_from_resource(op->src_resource), op->src_box.left,
|
2017-08-04 19:53:51 +02:00
|
|
|
op->src_box.right - op->src_box.left);
|
2017-03-08 10:53:02 +01:00
|
|
|
}
|
2017-04-06 23:44:33 +02:00
|
|
|
else if (op->dst_resource->type == WINED3D_RTYPE_TEXTURE_3D)
|
|
|
|
{
|
|
|
|
struct wined3d_texture *src_texture, *dst_texture;
|
|
|
|
unsigned int level, update_w, update_h, update_d;
|
|
|
|
unsigned int row_pitch, slice_pitch;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
struct wined3d_bo_address addr;
|
|
|
|
|
2017-11-15 22:13:01 +01:00
|
|
|
if (op->flags & ~WINED3D_BLT_RAW)
|
2017-04-06 23:44:33 +02:00
|
|
|
{
|
|
|
|
FIXME("Flags %#x not implemented for %s resources.\n",
|
|
|
|
op->flags, debug_d3dresourcetype(op->dst_resource->type));
|
2017-04-19 18:55:17 +02:00
|
|
|
goto error;
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
|
2017-11-15 22:13:01 +01:00
|
|
|
if (!(op->flags & WINED3D_BLT_RAW) && op->src_resource->format != op->dst_resource->format)
|
2017-04-06 23:44:33 +02:00
|
|
|
{
|
|
|
|
FIXME("Format conversion not implemented for %s resources.\n",
|
|
|
|
debug_d3dresourcetype(op->dst_resource->type));
|
2017-04-19 18:55:17 +02:00
|
|
|
goto error;
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
update_w = op->dst_box.right - op->dst_box.left;
|
|
|
|
update_h = op->dst_box.bottom - op->dst_box.top;
|
|
|
|
update_d = op->dst_box.back - op->dst_box.front;
|
|
|
|
if (op->src_box.right - op->src_box.left != update_w
|
|
|
|
|| op->src_box.bottom - op->src_box.top != update_h
|
|
|
|
|| op->src_box.back - op->src_box.front != update_d)
|
|
|
|
{
|
|
|
|
FIXME("Stretching not implemented for %s resources.\n",
|
|
|
|
debug_d3dresourcetype(op->dst_resource->type));
|
2017-04-19 18:55:17 +02:00
|
|
|
goto error;
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dst_texture = texture_from_resource(op->dst_resource);
|
|
|
|
src_texture = texture_from_resource(op->src_resource);
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
2017-04-06 23:44:33 +02:00
|
|
|
|
|
|
|
if (!wined3d_texture_load_location(src_texture, op->src_sub_resource_idx,
|
|
|
|
context, src_texture->resource.map_binding))
|
|
|
|
{
|
|
|
|
ERR("Failed to load source sub-resource into %s.\n",
|
|
|
|
wined3d_debug_location(src_texture->resource.map_binding));
|
|
|
|
context_release(context);
|
2017-04-19 18:55:17 +02:00
|
|
|
goto error;
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
level = op->dst_sub_resource_idx % dst_texture->level_count;
|
|
|
|
if (update_w == wined3d_texture_get_level_width(dst_texture, level)
|
|
|
|
&& update_h == wined3d_texture_get_level_height(dst_texture, level)
|
|
|
|
&& update_d == wined3d_texture_get_level_depth(dst_texture, level))
|
|
|
|
{
|
2019-06-12 13:29:32 +02:00
|
|
|
wined3d_texture_prepare_location(dst_texture, op->dst_sub_resource_idx,
|
|
|
|
context, WINED3D_LOCATION_TEXTURE_RGB);
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx,
|
|
|
|
context, WINED3D_LOCATION_TEXTURE_RGB))
|
|
|
|
{
|
|
|
|
ERR("Failed to load destination sub-resource.\n");
|
|
|
|
context_release(context);
|
2017-04-19 18:55:17 +02:00
|
|
|
goto error;
|
2017-04-06 23:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_texture_get_memory(src_texture, op->src_sub_resource_idx, &addr, src_texture->resource.map_binding);
|
|
|
|
wined3d_texture_get_pitch(src_texture, op->src_sub_resource_idx % src_texture->level_count,
|
|
|
|
&row_pitch, &slice_pitch);
|
|
|
|
|
2019-06-07 14:52:31 +02:00
|
|
|
dst_texture->texture_ops->texture_upload_data(context, wined3d_const_bo_address(&addr),
|
|
|
|
dst_texture->resource.format, &op->src_box, row_pitch, slice_pitch, dst_texture,
|
|
|
|
op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB,
|
|
|
|
op->dst_box.left, op->dst_box.top, op->dst_box.front);
|
2017-04-06 23:44:33 +02:00
|
|
|
wined3d_texture_validate_location(dst_texture, op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
|
|
|
|
wined3d_texture_invalidate_location(dst_texture, op->dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
}
|
2017-03-08 10:53:03 +01:00
|
|
|
else
|
|
|
|
{
|
2018-04-27 14:52:45 +02:00
|
|
|
if (FAILED(texture2d_blt(texture_from_resource(op->dst_resource), op->dst_sub_resource_idx,
|
|
|
|
&op->dst_box, texture_from_resource(op->src_resource), op->src_sub_resource_idx,
|
|
|
|
&op->src_box, op->flags, &op->fx, op->filter)))
|
|
|
|
FIXME("Blit failed.\n");
|
2017-03-08 10:53:03 +01:00
|
|
|
}
|
2017-03-08 10:53:02 +01:00
|
|
|
|
2017-04-19 18:55:17 +02:00
|
|
|
error:
|
2017-03-08 10:53:02 +01:00
|
|
|
if (op->src_resource)
|
|
|
|
wined3d_resource_release(op->src_resource);
|
|
|
|
wined3d_resource_release(op->dst_resource);
|
|
|
|
}
|
|
|
|
|
2021-04-07 03:56:41 +02:00
|
|
|
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)
|
2017-03-08 10:53:02 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_blt_sub_resource *op;
|
|
|
|
|
2021-04-07 03:56:41 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-03-08 10:53:02 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_BLT_SUB_RESOURCE;
|
|
|
|
op->dst_resource = dst_resource;
|
|
|
|
op->dst_sub_resource_idx = dst_sub_resource_idx;
|
|
|
|
op->dst_box = *dst_box;
|
|
|
|
op->src_resource = src_resource;
|
|
|
|
op->src_sub_resource_idx = src_sub_resource_idx;
|
|
|
|
op->src_box = *src_box;
|
|
|
|
op->flags = flags;
|
|
|
|
if (fx)
|
|
|
|
op->fx = *fx;
|
2017-09-15 15:12:24 +02:00
|
|
|
else
|
|
|
|
memset(&op->fx, 0, sizeof(op->fx));
|
2017-03-08 10:53:02 +01:00
|
|
|
op->filter = filter;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, dst_resource);
|
2017-03-08 10:53:02 +01:00
|
|
|
if (src_resource)
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, src_resource);
|
2017-03-08 10:53:02 +01:00
|
|
|
|
2021-04-07 03:56:41 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-05-02 11:35:30 +02:00
|
|
|
if (flags & WINED3D_BLT_SYNCHRONOUS)
|
2021-04-07 03:56:41 +02:00
|
|
|
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-03-08 10:53:02 +01:00
|
|
|
}
|
|
|
|
|
2017-03-06 10:45:24 +01:00
|
|
|
static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_update_sub_resource *op = data;
|
2018-01-30 11:58:22 +01:00
|
|
|
struct wined3d_resource *resource = op->resource;
|
2017-03-06 10:45:24 +01:00
|
|
|
const struct wined3d_box *box = &op->box;
|
|
|
|
unsigned int width, height, depth, level;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
struct wined3d_texture *texture;
|
2018-03-20 12:41:56 +01:00
|
|
|
struct wined3d_box src_box;
|
2017-03-06 10:45:24 +01:00
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
2018-01-30 11:58:22 +01:00
|
|
|
|
|
|
|
if (resource->type == WINED3D_RTYPE_BUFFER)
|
2017-03-06 10:45:24 +01:00
|
|
|
{
|
2018-01-30 11:58:22 +01:00
|
|
|
struct wined3d_buffer *buffer = buffer_from_resource(resource);
|
2017-03-06 10:45:24 +01:00
|
|
|
|
2021-06-28 18:39:03 +02:00
|
|
|
wined3d_buffer_copy_bo_address(buffer, context, box->left, &op->addr, box->right - box->left);
|
2017-03-06 10:45:24 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2018-01-30 11:58:22 +01:00
|
|
|
texture = wined3d_texture_from_resource(resource);
|
2017-03-06 10:45:24 +01:00
|
|
|
|
|
|
|
level = op->sub_resource_idx % texture->level_count;
|
|
|
|
width = wined3d_texture_get_level_width(texture, level);
|
|
|
|
height = wined3d_texture_get_level_height(texture, level);
|
|
|
|
depth = wined3d_texture_get_level_depth(texture, level);
|
|
|
|
|
|
|
|
/* Only load the sub-resource for partial updates. */
|
|
|
|
if (!box->left && !box->top && !box->front
|
|
|
|
&& box->right == width && box->bottom == height && box->back == depth)
|
2019-06-12 13:29:32 +02:00
|
|
|
wined3d_texture_prepare_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
|
2017-03-06 10:45:24 +01:00
|
|
|
else
|
|
|
|
wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
|
|
|
|
|
2018-03-20 12:41:56 +01:00
|
|
|
wined3d_box_set(&src_box, 0, 0, box->right - box->left, box->bottom - box->top, 0, box->back - box->front);
|
2021-06-28 18:39:03 +02:00
|
|
|
texture->texture_ops->texture_upload_data(context, &op->addr, texture->resource.format, &src_box,
|
|
|
|
op->row_pitch, op->slice_pitch, texture, op->sub_resource_idx,
|
2019-06-10 22:15:30 +02:00
|
|
|
WINED3D_LOCATION_TEXTURE_RGB, box->left, box->top, box->front);
|
2017-03-06 10:45:24 +01:00
|
|
|
|
|
|
|
wined3d_texture_validate_location(texture, op->sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
|
|
|
|
wined3d_texture_invalidate_location(texture, op->sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
|
|
|
|
|
|
|
|
done:
|
2018-01-30 11:58:22 +01:00
|
|
|
context_release(context);
|
|
|
|
|
|
|
|
wined3d_resource_release(resource);
|
2017-03-06 10:45:24 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:13 +02:00
|
|
|
static void wined3d_cs_update_sub_resource(struct wined3d_device_context *context,
|
2021-04-09 06:45:09 +02:00
|
|
|
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)
|
2017-03-06 10:45:24 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_update_sub_resource *op;
|
|
|
|
|
2021-05-06 05:23:13 +02:00
|
|
|
wined3d_resource_wait_idle(resource);
|
|
|
|
|
2021-04-09 06:45:09 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
|
2017-03-06 10:45:24 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
|
|
|
|
op->resource = resource;
|
|
|
|
op->sub_resource_idx = sub_resource_idx;
|
|
|
|
op->box = *box;
|
2021-06-28 18:39:03 +02:00
|
|
|
op->addr.buffer_object = 0;
|
|
|
|
op->addr.addr = data;
|
|
|
|
op->row_pitch = row_pitch;
|
|
|
|
op->slice_pitch = slice_pitch;
|
2017-03-06 10:45:24 +01:00
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, resource);
|
2017-03-06 10:45:24 +01:00
|
|
|
|
2021-04-09 06:45:09 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
|
2017-05-02 11:35:30 +02:00
|
|
|
/* The data pointer may go away, so we need to wait until it is read.
|
|
|
|
* Copying the data may be faster if it's small. */
|
2021-04-09 06:45:09 +02:00
|
|
|
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_MAP);
|
2017-03-06 10:45:24 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 00:08:50 +02:00
|
|
|
static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_add_dirty_texture_region *op = data;
|
|
|
|
struct wined3d_texture *texture = op->texture;
|
|
|
|
unsigned int sub_resource_idx, i;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
2017-04-12 00:08:50 +02:00
|
|
|
sub_resource_idx = op->layer * texture->level_count;
|
|
|
|
for (i = 0; i < texture->level_count; ++i, ++sub_resource_idx)
|
|
|
|
{
|
|
|
|
if (wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding))
|
|
|
|
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
|
|
|
|
else
|
|
|
|
ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
|
|
|
|
}
|
|
|
|
context_release(context);
|
|
|
|
|
|
|
|
wined3d_resource_release(&texture->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
|
|
|
|
struct wined3d_texture *texture, unsigned int layer)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_add_dirty_texture_region *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-12 00:08:50 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION;
|
|
|
|
op->texture = texture;
|
|
|
|
op->layer = layer;
|
|
|
|
|
|
|
|
wined3d_resource_acquire(&texture->resource);
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-12 00:08:50 +02:00
|
|
|
}
|
|
|
|
|
2017-05-12 15:09:20 +02:00
|
|
|
static void wined3d_cs_exec_clear_unordered_access_view(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_clear_unordered_access_view *op = data;
|
|
|
|
struct wined3d_unordered_access_view *view = op->view;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
2021-06-07 16:55:10 +02:00
|
|
|
cs->c.device->adapter->adapter_ops->adapter_clear_uav(context, view, &op->clear_value, op->fp);
|
2017-05-12 15:09:20 +02:00
|
|
|
context_release(context);
|
|
|
|
|
|
|
|
wined3d_resource_release(view->resource);
|
|
|
|
}
|
|
|
|
|
2021-06-07 16:55:10 +02:00
|
|
|
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)
|
2017-05-12 15:09:20 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_clear_unordered_access_view *op;
|
|
|
|
|
2021-04-09 06:45:07 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-05-12 15:09:20 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW;
|
|
|
|
op->view = view;
|
|
|
|
op->clear_value = *clear_value;
|
2021-06-07 16:55:10 +02:00
|
|
|
op->fp = fp;
|
2017-05-12 15:09:20 +02:00
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, view->resource);
|
2017-05-12 15:09:20 +02:00
|
|
|
|
2021-04-09 06:45:07 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-05-12 15:09:20 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 19:53:48 +02:00
|
|
|
static void wined3d_cs_exec_copy_uav_counter(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_copy_uav_counter *op = data;
|
|
|
|
struct wined3d_unordered_access_view *view = op->view;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
|
2021-03-05 04:29:47 +01:00
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
2017-08-04 19:53:48 +02:00
|
|
|
wined3d_unordered_access_view_copy_counter(view, op->buffer, op->offset, context);
|
|
|
|
context_release(context);
|
|
|
|
|
|
|
|
wined3d_resource_release(&op->buffer->resource);
|
|
|
|
}
|
|
|
|
|
2021-04-06 06:40:21 +02:00
|
|
|
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)
|
2017-08-04 19:53:48 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_copy_uav_counter *op;
|
|
|
|
|
2021-04-06 06:40:21 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-08-04 19:53:48 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_COPY_UAV_COUNTER;
|
|
|
|
op->buffer = dst_buffer;
|
|
|
|
op->offset = offset;
|
|
|
|
op->view = uav;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, &dst_buffer->resource);
|
2017-08-04 19:53:48 +02:00
|
|
|
|
2021-04-06 06:40:21 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-08-04 19:53:48 +02:00
|
|
|
}
|
|
|
|
|
2017-12-04 18:07:31 +01:00
|
|
|
static void wined3d_cs_exec_generate_mipmaps(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_generate_mipmaps *op = data;
|
|
|
|
struct wined3d_shader_resource_view *view = op->view;
|
2021-03-12 17:59:06 +01:00
|
|
|
struct wined3d_context *context;
|
|
|
|
|
|
|
|
context = context_acquire(cs->c.device, NULL, 0);
|
|
|
|
cs->c.device->adapter->adapter_ops->adapter_generate_mipmap(context, view);
|
|
|
|
context_release(context);
|
2017-12-04 18:07:31 +01:00
|
|
|
|
|
|
|
wined3d_resource_release(view->resource);
|
|
|
|
}
|
|
|
|
|
2021-04-08 04:19:59 +02:00
|
|
|
void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_shader_resource_view *view)
|
2017-12-04 18:07:31 +01:00
|
|
|
{
|
|
|
|
struct wined3d_cs_generate_mipmaps *op;
|
|
|
|
|
2021-04-08 04:19:59 +02:00
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-12-04 18:07:31 +01:00
|
|
|
op->opcode = WINED3D_CS_OP_GENERATE_MIPMAPS;
|
|
|
|
op->view = view;
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_device_context_acquire_resource(context, view->resource);
|
2017-12-04 18:07:31 +01:00
|
|
|
|
2021-04-08 04:19:59 +02:00
|
|
|
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
2017-12-04 18:07:31 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static void wined3d_cs_emit_stop(struct wined3d_cs *cs)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_stop *op;
|
|
|
|
|
2021-03-05 04:29:46 +01:00
|
|
|
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-13 00:11:01 +02:00
|
|
|
op->opcode = WINED3D_CS_OP_STOP;
|
|
|
|
|
2021-03-05 04:29:45 +01:00
|
|
|
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
|
2018-11-29 14:33:47 +01:00
|
|
|
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_DEFAULT);
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:23:10 +02:00
|
|
|
static void wined3d_cs_acquire_resource(struct wined3d_device_context *context, struct wined3d_resource *resource)
|
|
|
|
{
|
|
|
|
wined3d_resource_acquire(resource);
|
|
|
|
}
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
static void wined3d_cs_exec_execute_command_list(struct wined3d_cs *cs, const void *data);
|
|
|
|
|
2013-09-27 00:15:14 +02:00
|
|
|
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2017-05-12 15:09:20 +02:00
|
|
|
/* WINED3D_CS_OP_NOP */ wined3d_cs_exec_nop,
|
|
|
|
/* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present,
|
|
|
|
/* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear,
|
|
|
|
/* WINED3D_CS_OP_DISPATCH */ wined3d_cs_exec_dispatch,
|
|
|
|
/* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw,
|
|
|
|
/* WINED3D_CS_OP_FLUSH */ wined3d_cs_exec_flush,
|
|
|
|
/* WINED3D_CS_OP_SET_PREDICATION */ wined3d_cs_exec_set_predication,
|
2018-04-14 11:12:38 +02:00
|
|
|
/* WINED3D_CS_OP_SET_VIEWPORTS */ wined3d_cs_exec_set_viewports,
|
2018-04-23 14:34:03 +02:00
|
|
|
/* WINED3D_CS_OP_SET_SCISSOR_RECTS */ wined3d_cs_exec_set_scissor_rects,
|
2017-05-12 15:09:20 +02:00
|
|
|
/* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view,
|
|
|
|
/* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view,
|
|
|
|
/* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration,
|
|
|
|
/* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source,
|
|
|
|
/* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq,
|
|
|
|
/* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output,
|
|
|
|
/* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer,
|
|
|
|
/* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer,
|
|
|
|
/* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture,
|
|
|
|
/* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW */ wined3d_cs_exec_set_shader_resource_view,
|
|
|
|
/* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_set_unordered_access_view,
|
|
|
|
/* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler,
|
|
|
|
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader,
|
2018-02-08 15:22:44 +01:00
|
|
|
/* WINED3D_CS_OP_SET_BLEND_STATE */ wined3d_cs_exec_set_blend_state,
|
2020-09-25 05:43:11 +02:00
|
|
|
/* WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE */ wined3d_cs_exec_set_depth_stencil_state,
|
2017-05-12 15:09:20 +02:00
|
|
|
/* WINED3D_CS_OP_SET_RASTERIZER_STATE */ wined3d_cs_exec_set_rasterizer_state,
|
|
|
|
/* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state,
|
|
|
|
/* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state,
|
|
|
|
/* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state,
|
|
|
|
/* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform,
|
|
|
|
/* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane,
|
|
|
|
/* WINED3D_CS_OP_SET_COLOR_KEY */ wined3d_cs_exec_set_color_key,
|
|
|
|
/* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material,
|
|
|
|
/* WINED3D_CS_OP_SET_LIGHT */ wined3d_cs_exec_set_light,
|
|
|
|
/* WINED3D_CS_OP_SET_LIGHT_ENABLE */ wined3d_cs_exec_set_light_enable,
|
2021-03-15 16:11:36 +01:00
|
|
|
/* WINED3D_CS_OP_SET_FEATURE_LEVEL */ wined3d_cs_exec_set_feature_level,
|
2017-05-12 15:09:20 +02:00
|
|
|
/* WINED3D_CS_OP_PUSH_CONSTANTS */ wined3d_cs_exec_push_constants,
|
|
|
|
/* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state,
|
|
|
|
/* WINED3D_CS_OP_CALLBACK */ wined3d_cs_exec_callback,
|
|
|
|
/* WINED3D_CS_OP_QUERY_ISSUE */ wined3d_cs_exec_query_issue,
|
|
|
|
/* WINED3D_CS_OP_PRELOAD_RESOURCE */ wined3d_cs_exec_preload_resource,
|
|
|
|
/* WINED3D_CS_OP_UNLOAD_RESOURCE */ wined3d_cs_exec_unload_resource,
|
|
|
|
/* WINED3D_CS_OP_MAP */ wined3d_cs_exec_map,
|
|
|
|
/* WINED3D_CS_OP_UNMAP */ wined3d_cs_exec_unmap,
|
|
|
|
/* WINED3D_CS_OP_BLT_SUB_RESOURCE */ wined3d_cs_exec_blt_sub_resource,
|
|
|
|
/* WINED3D_CS_OP_UPDATE_SUB_RESOURCE */ wined3d_cs_exec_update_sub_resource,
|
|
|
|
/* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region,
|
|
|
|
/* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view,
|
2017-08-04 19:53:48 +02:00
|
|
|
/* WINED3D_CS_OP_COPY_UAV_COUNTER */ wined3d_cs_exec_copy_uav_counter,
|
2017-12-04 18:07:31 +01:00
|
|
|
/* WINED3D_CS_OP_GENERATE_MIPMAPS */ wined3d_cs_exec_generate_mipmaps,
|
2021-05-27 18:14:35 +02:00
|
|
|
/* WINED3D_CS_OP_EXECUTE_COMMAND_LIST */ wined3d_cs_exec_execute_command_list,
|
2013-09-27 00:15:13 +02:00
|
|
|
};
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
static void wined3d_cs_exec_execute_command_list(struct wined3d_cs *cs, const void *data)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_execute_command_list *op = data;
|
|
|
|
size_t start = 0, end = op->list->data_size;
|
|
|
|
const BYTE *cs_data = op->list->data;
|
|
|
|
|
|
|
|
TRACE("Executing command list %p.\n", op->list);
|
|
|
|
|
|
|
|
while (start < end)
|
|
|
|
{
|
|
|
|
const struct wined3d_cs_packet *packet = (const struct wined3d_cs_packet *)&cs_data[start];
|
|
|
|
enum wined3d_cs_op opcode = *(const enum wined3d_cs_op *)packet->data;
|
|
|
|
|
|
|
|
if (opcode >= WINED3D_CS_OP_STOP)
|
|
|
|
ERR("Invalid opcode %#x.\n", opcode);
|
|
|
|
else
|
|
|
|
wined3d_cs_op_handlers[opcode](cs, packet->data);
|
|
|
|
TRACE("%s executed.\n", debug_cs_op(opcode));
|
|
|
|
|
|
|
|
start += offsetof(struct wined3d_cs_packet, data[packet->size]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void *wined3d_cs_st_require_space(struct wined3d_device_context *context,
|
|
|
|
size_t size, enum wined3d_cs_queue_id queue_id)
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
|
|
|
|
2017-02-17 14:08:15 +01:00
|
|
|
if (size > (cs->data_size - cs->end))
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2017-02-17 14:08:15 +01:00
|
|
|
size_t new_size;
|
2013-09-27 00:15:13 +02:00
|
|
|
void *new_data;
|
|
|
|
|
2017-02-17 14:08:15 +01:00
|
|
|
new_size = max(size, cs->data_size * 2);
|
|
|
|
if (!cs->end)
|
2018-02-14 07:39:59 +01:00
|
|
|
new_data = heap_realloc(cs->data, new_size);
|
2017-02-17 14:08:15 +01:00
|
|
|
else
|
2018-02-14 07:39:59 +01:00
|
|
|
new_data = heap_alloc(new_size);
|
2017-02-17 14:08:15 +01:00
|
|
|
if (!new_data)
|
2013-09-27 00:15:13 +02:00
|
|
|
return NULL;
|
|
|
|
|
2017-02-17 14:08:15 +01:00
|
|
|
cs->data_size = new_size;
|
|
|
|
cs->start = cs->end = 0;
|
2013-09-27 00:15:13 +02:00
|
|
|
cs->data = new_data;
|
|
|
|
}
|
|
|
|
|
2017-02-17 14:08:15 +01:00
|
|
|
cs->end += size;
|
|
|
|
|
|
|
|
return (BYTE *)cs->data + cs->start;
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_st_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
2017-02-17 14:08:15 +01:00
|
|
|
enum wined3d_cs_op opcode;
|
|
|
|
size_t start;
|
|
|
|
BYTE *data;
|
|
|
|
|
|
|
|
data = cs->data;
|
|
|
|
start = cs->start;
|
|
|
|
cs->start = cs->end;
|
2017-02-17 16:54:45 +01:00
|
|
|
|
2017-02-17 14:08:15 +01:00
|
|
|
opcode = *(const enum wined3d_cs_op *)&data[start];
|
2017-04-13 00:11:01 +02:00
|
|
|
if (opcode >= WINED3D_CS_OP_STOP)
|
|
|
|
ERR("Invalid opcode %#x.\n", opcode);
|
|
|
|
else
|
|
|
|
wined3d_cs_op_handlers[opcode](cs, &data[start]);
|
2017-02-17 16:54:45 +01:00
|
|
|
|
|
|
|
if (cs->data == data)
|
|
|
|
cs->start = cs->end = start;
|
|
|
|
else if (!start)
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(data);
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
2017-05-02 11:35:30 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static const struct wined3d_device_context_ops wined3d_cs_st_ops =
|
2016-05-22 18:23:07 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_st_require_space,
|
|
|
|
wined3d_cs_st_submit,
|
2017-05-02 11:35:30 +02:00
|
|
|
wined3d_cs_st_finish,
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_st_push_constants,
|
2021-04-13 05:46:29 +02:00
|
|
|
wined3d_cs_map,
|
|
|
|
wined3d_cs_unmap,
|
2021-05-06 05:23:13 +02:00
|
|
|
wined3d_cs_update_sub_resource,
|
2021-04-14 04:05:23 +02:00
|
|
|
wined3d_cs_issue_query,
|
2021-04-14 04:05:26 +02:00
|
|
|
wined3d_cs_flush,
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_cs_acquire_resource,
|
2021-05-27 18:14:35 +02:00
|
|
|
wined3d_cs_execute_command_list,
|
2017-04-13 00:11:01 +02:00
|
|
|
};
|
|
|
|
|
2017-08-27 23:22:42 +02:00
|
|
|
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
|
2017-04-13 00:11:01 +02:00
|
|
|
{
|
2017-08-27 23:22:42 +02:00
|
|
|
wined3d_from_cs(cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
return *(volatile LONG *)&queue->head == queue->tail;
|
|
|
|
}
|
2016-05-22 18:23:07 +02:00
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
static void wined3d_cs_queue_submit(struct wined3d_cs_queue *queue, struct wined3d_cs *cs)
|
2017-04-13 00:11:01 +02:00
|
|
|
{
|
|
|
|
struct wined3d_cs_packet *packet;
|
|
|
|
size_t packet_size;
|
|
|
|
|
|
|
|
packet = (struct wined3d_cs_packet *)&queue->data[queue->head];
|
|
|
|
packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[packet->size]);
|
|
|
|
InterlockedExchange(&queue->head, (queue->head + packet_size) & (WINED3D_CS_QUEUE_SIZE - 1));
|
|
|
|
|
|
|
|
if (InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE))
|
|
|
|
SetEvent(cs->event);
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_mt_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
2017-05-21 17:53:42 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
if (cs->thread_id == GetCurrentThreadId())
|
2021-03-05 04:29:44 +01:00
|
|
|
return wined3d_cs_st_submit(context, queue_id);
|
2017-05-21 17:53:42 +02:00
|
|
|
|
|
|
|
wined3d_cs_queue_submit(&cs->queue[queue_id], cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs)
|
2017-04-13 00:11:01 +02:00
|
|
|
{
|
|
|
|
size_t queue_size = ARRAY_SIZE(queue->data);
|
|
|
|
size_t header_size, packet_size, remaining;
|
|
|
|
struct wined3d_cs_packet *packet;
|
|
|
|
|
|
|
|
header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]);
|
|
|
|
packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]);
|
2020-03-24 17:35:24 +01:00
|
|
|
packet_size = (packet_size + header_size - 1) & ~(header_size - 1);
|
|
|
|
size = packet_size - header_size;
|
2017-04-13 00:11:01 +02:00
|
|
|
if (packet_size >= WINED3D_CS_QUEUE_SIZE)
|
2016-05-22 18:23:07 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
ERR("Packet size %lu >= queue size %u.\n",
|
|
|
|
(unsigned long)packet_size, WINED3D_CS_QUEUE_SIZE);
|
|
|
|
return NULL;
|
2016-05-22 18:23:07 +02:00
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
remaining = queue_size - queue->head;
|
|
|
|
if (remaining < packet_size)
|
2016-05-22 18:23:07 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
size_t nop_size = remaining - header_size;
|
|
|
|
struct wined3d_cs_nop *nop;
|
2016-05-22 18:23:07 +02:00
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
TRACE("Inserting a nop for %lu + %lu bytes.\n",
|
|
|
|
(unsigned long)header_size, (unsigned long)nop_size);
|
2016-05-22 18:23:07 +02:00
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
nop = wined3d_cs_queue_require_space(queue, nop_size, cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
if (nop_size)
|
|
|
|
nop->opcode = WINED3D_CS_OP_NOP;
|
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
wined3d_cs_queue_submit(queue, cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
assert(!queue->head);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
2016-05-22 18:23:07 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
LONG tail = *(volatile LONG *)&queue->tail;
|
|
|
|
LONG head = queue->head;
|
|
|
|
LONG new_pos;
|
|
|
|
|
|
|
|
/* Empty. */
|
|
|
|
if (head == tail)
|
|
|
|
break;
|
|
|
|
new_pos = (head + packet_size) & (WINED3D_CS_QUEUE_SIZE - 1);
|
|
|
|
/* Head ahead of tail. We checked the remaining size above, so we only
|
|
|
|
* need to make sure we don't make head equal to tail. */
|
|
|
|
if (head > tail && (new_pos != tail))
|
|
|
|
break;
|
|
|
|
/* Tail ahead of head. Make sure the new head is before the tail as
|
|
|
|
* well. Note that new_pos is 0 when it's at the end of the queue. */
|
|
|
|
if (new_pos < tail && new_pos)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TRACE("Waiting for free space. Head %u, tail %u, packet size %lu.\n",
|
|
|
|
head, tail, (unsigned long)packet_size);
|
2016-05-22 18:23:07 +02:00
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
packet = (struct wined3d_cs_packet *)&queue->data[queue->head];
|
|
|
|
packet->size = size;
|
|
|
|
return packet->data;
|
2016-05-22 18:23:07 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void *wined3d_cs_mt_require_space(struct wined3d_device_context *context,
|
|
|
|
size_t size, enum wined3d_cs_queue_id queue_id)
|
2017-05-02 11:35:30 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
|
|
|
|
2017-05-02 11:35:30 +02:00
|
|
|
if (cs->thread_id == GetCurrentThreadId())
|
2021-03-05 04:29:44 +01:00
|
|
|
return wined3d_cs_st_require_space(context, size, queue_id);
|
2017-05-02 11:35:30 +02:00
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
return wined3d_cs_queue_require_space(&cs->queue[queue_id], size, cs);
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static void wined3d_cs_mt_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
2017-05-21 17:53:42 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
struct wined3d_cs *cs = wined3d_cs_from_context(context);
|
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
if (cs->thread_id == GetCurrentThreadId())
|
2021-03-05 04:29:44 +01:00
|
|
|
return wined3d_cs_st_finish(context, queue_id);
|
2017-05-21 17:53:42 +02:00
|
|
|
|
2017-08-27 23:22:42 +02:00
|
|
|
while (cs->queue[queue_id].head != *(volatile LONG *)&cs->queue[queue_id].tail)
|
2021-01-21 05:35:48 +01:00
|
|
|
YieldProcessor();
|
2017-05-02 11:35:30 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_mt_require_space,
|
|
|
|
wined3d_cs_mt_submit,
|
2017-05-02 11:35:30 +02:00
|
|
|
wined3d_cs_mt_finish,
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_mt_push_constants,
|
2021-04-13 05:46:29 +02:00
|
|
|
wined3d_cs_map,
|
|
|
|
wined3d_cs_unmap,
|
2021-05-06 05:23:13 +02:00
|
|
|
wined3d_cs_update_sub_resource,
|
2021-04-14 04:05:23 +02:00
|
|
|
wined3d_cs_issue_query,
|
2021-04-14 04:05:26 +02:00
|
|
|
wined3d_cs_flush,
|
2021-05-06 05:23:10 +02:00
|
|
|
wined3d_cs_acquire_resource,
|
2021-05-27 18:14:35 +02:00
|
|
|
wined3d_cs_execute_command_list,
|
2013-09-27 00:15:13 +02:00
|
|
|
};
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static void poll_queries(struct wined3d_cs *cs)
|
|
|
|
{
|
|
|
|
struct wined3d_query *query, *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(query, cursor, &cs->query_poll_list, struct wined3d_query, poll_list_entry)
|
|
|
|
{
|
|
|
|
if (!query->query_ops->query_poll(query, 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
list_remove(&query->poll_list_entry);
|
|
|
|
list_init(&query->poll_list_entry);
|
|
|
|
InterlockedIncrement(&query->counter_retrieved);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_cs_wait_event(struct wined3d_cs *cs)
|
|
|
|
{
|
|
|
|
InterlockedExchange(&cs->waiting_for_event, TRUE);
|
|
|
|
|
|
|
|
/* The main thread might have enqueued a command and blocked on it after
|
|
|
|
* the CS thread decided to enter wined3d_cs_wait_event(), but before
|
|
|
|
* "waiting_for_event" was set.
|
|
|
|
*
|
|
|
|
* Likewise, we can race with the main thread when resetting
|
|
|
|
* "waiting_for_event", in which case we would need to call
|
|
|
|
* WaitForSingleObject() because the main thread called SetEvent(). */
|
2017-08-27 23:22:42 +02:00
|
|
|
if (!(wined3d_cs_queue_is_empty(cs, &cs->queue[WINED3D_CS_QUEUE_DEFAULT])
|
|
|
|
&& wined3d_cs_queue_is_empty(cs, &cs->queue[WINED3D_CS_QUEUE_MAP]))
|
2017-04-13 00:11:01 +02:00
|
|
|
&& InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WaitForSingleObject(cs->event, INFINITE);
|
|
|
|
}
|
|
|
|
|
2020-12-03 17:58:54 +01:00
|
|
|
static void wined3d_cs_command_lock(const struct wined3d_cs *cs)
|
|
|
|
{
|
|
|
|
if (cs->serialize_commands)
|
|
|
|
EnterCriticalSection(&wined3d_command_cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_cs_command_unlock(const struct wined3d_cs *cs)
|
|
|
|
{
|
|
|
|
if (cs->serialize_commands)
|
|
|
|
LeaveCriticalSection(&wined3d_command_cs);
|
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static DWORD WINAPI wined3d_cs_run(void *ctx)
|
|
|
|
{
|
|
|
|
struct wined3d_cs_packet *packet;
|
|
|
|
struct wined3d_cs_queue *queue;
|
|
|
|
unsigned int spin_count = 0;
|
|
|
|
struct wined3d_cs *cs = ctx;
|
|
|
|
enum wined3d_cs_op opcode;
|
2017-09-08 18:44:11 +02:00
|
|
|
HMODULE wined3d_module;
|
2017-04-13 00:11:01 +02:00
|
|
|
unsigned int poll = 0;
|
|
|
|
LONG tail;
|
|
|
|
|
|
|
|
TRACE("Started.\n");
|
|
|
|
|
2017-09-08 18:44:11 +02:00
|
|
|
/* Copy the module handle to a local variable to avoid racing with the
|
|
|
|
* thread freeing "cs" before the FreeLibraryAndExitThread() call. */
|
|
|
|
wined3d_module = cs->wined3d_module;
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
list_init(&cs->query_poll_list);
|
|
|
|
cs->thread_id = GetCurrentThreadId();
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (++poll == WINED3D_CS_QUERY_POLL_INTERVAL)
|
|
|
|
{
|
2020-12-03 17:58:54 +01:00
|
|
|
wined3d_cs_command_lock(cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
poll_queries(cs);
|
2020-12-03 17:58:54 +01:00
|
|
|
wined3d_cs_command_unlock(cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
poll = 0;
|
|
|
|
}
|
|
|
|
|
2017-05-21 17:53:42 +02:00
|
|
|
queue = &cs->queue[WINED3D_CS_QUEUE_MAP];
|
2017-08-27 23:22:42 +02:00
|
|
|
if (wined3d_cs_queue_is_empty(cs, queue))
|
2017-04-13 00:11:01 +02:00
|
|
|
{
|
2017-05-21 17:53:42 +02:00
|
|
|
queue = &cs->queue[WINED3D_CS_QUEUE_DEFAULT];
|
2017-08-27 23:22:42 +02:00
|
|
|
if (wined3d_cs_queue_is_empty(cs, queue))
|
2017-05-21 17:53:42 +02:00
|
|
|
{
|
|
|
|
if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list))
|
|
|
|
wined3d_cs_wait_event(cs);
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
spin_count = 0;
|
|
|
|
|
|
|
|
tail = queue->tail;
|
|
|
|
packet = (struct wined3d_cs_packet *)&queue->data[tail];
|
|
|
|
if (packet->size)
|
|
|
|
{
|
|
|
|
opcode = *(const enum wined3d_cs_op *)packet->data;
|
|
|
|
|
2018-08-16 09:39:19 +02:00
|
|
|
TRACE("Executing %s.\n", debug_cs_op(opcode));
|
2017-04-13 00:11:01 +02:00
|
|
|
if (opcode >= WINED3D_CS_OP_STOP)
|
|
|
|
{
|
|
|
|
if (opcode > WINED3D_CS_OP_STOP)
|
|
|
|
ERR("Invalid opcode %#x.\n", opcode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-12-03 17:58:54 +01:00
|
|
|
wined3d_cs_command_lock(cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_op_handlers[opcode](cs, packet->data);
|
2020-12-03 17:58:54 +01:00
|
|
|
wined3d_cs_command_unlock(cs);
|
2018-08-16 09:39:19 +02:00
|
|
|
TRACE("%s executed.\n", debug_cs_op(opcode));
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tail += FIELD_OFFSET(struct wined3d_cs_packet, data[packet->size]);
|
|
|
|
tail &= (WINED3D_CS_QUEUE_SIZE - 1);
|
|
|
|
InterlockedExchange(&queue->tail, tail);
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:22:41 +02:00
|
|
|
cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head;
|
|
|
|
cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head;
|
2017-04-13 00:11:01 +02:00
|
|
|
TRACE("Stopped.\n");
|
2017-09-08 18:44:11 +02:00
|
|
|
FreeLibraryAndExitThread(wined3d_module, 0);
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
|
|
|
|
2021-03-15 16:11:37 +01:00
|
|
|
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device,
|
|
|
|
const enum wined3d_feature_level *levels, unsigned int level_count)
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2018-08-23 14:34:04 +02:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
|
2013-09-27 00:15:13 +02:00
|
|
|
struct wined3d_cs *cs;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(cs = heap_alloc_zero(sizeof(*cs))))
|
2013-09-30 09:40:39 +02:00
|
|
|
return NULL;
|
|
|
|
|
2021-03-15 16:11:37 +01:00
|
|
|
if (FAILED(wined3d_state_create(device, levels, level_count, &cs->c.state)))
|
2021-03-05 04:29:48 +01:00
|
|
|
{
|
|
|
|
heap_free(cs);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:44 +01:00
|
|
|
cs->c.ops = &wined3d_cs_st_ops;
|
2021-03-05 04:29:47 +01:00
|
|
|
cs->c.device = device;
|
2020-12-03 17:58:54 +01:00
|
|
|
cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
|
2017-04-13 00:11:01 +02:00
|
|
|
|
2021-03-15 16:11:36 +01:00
|
|
|
state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT, cs->c.state->feature_level);
|
2013-09-27 00:15:13 +02:00
|
|
|
|
|
|
|
cs->data_size = WINED3D_INITIAL_CS_SIZE;
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(cs->data = heap_alloc(cs->data_size)))
|
2017-04-13 00:11:01 +02:00
|
|
|
goto fail;
|
|
|
|
|
2020-12-03 17:58:54 +01:00
|
|
|
if (wined3d_settings.cs_multithreaded & WINED3D_CSMT_ENABLE
|
2017-04-13 00:11:01 +02:00
|
|
|
&& !RtlIsCriticalSectionLockedByThread(NtCurrentTeb()->Peb->LoaderLock))
|
2013-09-27 00:15:13 +02:00
|
|
|
{
|
2021-03-05 04:29:44 +01:00
|
|
|
cs->c.ops = &wined3d_cs_mt_ops;
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
if (!(cs->event = CreateEventW(NULL, FALSE, FALSE, NULL)))
|
|
|
|
{
|
|
|
|
ERR("Failed to create command stream event.\n");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(cs->data);
|
2017-04-13 00:11:01 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-04-19 23:40:50 +02:00
|
|
|
if (!(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
|
|
|
(const WCHAR *)wined3d_cs_run, &cs->wined3d_module)))
|
|
|
|
{
|
|
|
|
ERR("Failed to get wined3d module handle.\n");
|
|
|
|
CloseHandle(cs->event);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(cs->data);
|
2017-04-19 23:40:50 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
if (!(cs->thread = CreateThread(NULL, 0, wined3d_cs_run, cs, 0, NULL)))
|
|
|
|
{
|
|
|
|
ERR("Failed to create wined3d command stream thread.\n");
|
2017-04-19 23:40:50 +02:00
|
|
|
FreeLibrary(cs->wined3d_module);
|
2017-04-13 00:11:01 +02:00
|
|
|
CloseHandle(cs->event);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(cs->data);
|
2017-04-13 00:11:01 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cs;
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
fail:
|
2021-03-05 04:29:48 +01:00
|
|
|
wined3d_state_destroy(cs->c.state);
|
2017-04-13 00:11:01 +02:00
|
|
|
state_cleanup(&cs->state);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(cs);
|
2017-04-13 00:11:01 +02:00
|
|
|
return NULL;
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_cs_destroy(struct wined3d_cs *cs)
|
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
if (cs->thread)
|
|
|
|
{
|
|
|
|
wined3d_cs_emit_stop(cs);
|
|
|
|
CloseHandle(cs->thread);
|
|
|
|
if (!CloseHandle(cs->event))
|
|
|
|
ERR("Closing event failed.\n");
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:29:48 +01:00
|
|
|
wined3d_state_destroy(cs->c.state);
|
2017-05-10 20:00:43 +02:00
|
|
|
state_cleanup(&cs->state);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(cs->data);
|
|
|
|
heap_free(cs);
|
2013-09-27 00:15:13 +02:00
|
|
|
}
|
2021-05-27 18:14:29 +02:00
|
|
|
|
|
|
|
struct wined3d_deferred_context
|
|
|
|
{
|
|
|
|
struct wined3d_device_context c;
|
|
|
|
|
|
|
|
SIZE_T data_size, data_capacity;
|
|
|
|
void *data;
|
2021-05-27 18:14:31 +02:00
|
|
|
|
|
|
|
SIZE_T resource_count, resources_capacity;
|
|
|
|
struct wined3d_resource **resources;
|
2021-05-27 18:14:35 +02:00
|
|
|
|
|
|
|
/* List of command lists queued for execution on this context. A command
|
|
|
|
* list can be the only thing holding a pointer to another command list, so
|
|
|
|
* we need to hold a reference here and in wined3d_command_list as well. */
|
|
|
|
SIZE_T command_list_count, command_lists_capacity;
|
|
|
|
struct wined3d_command_list **command_lists;
|
2021-05-27 18:14:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(context, struct wined3d_deferred_context, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *wined3d_deferred_context_require_space(struct wined3d_device_context *context,
|
|
|
|
size_t size, enum wined3d_cs_queue_id queue_id)
|
|
|
|
{
|
|
|
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
|
|
|
struct wined3d_cs_packet *packet;
|
|
|
|
size_t header_size, packet_size;
|
|
|
|
|
|
|
|
assert(queue_id == WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
|
|
|
|
header_size = offsetof(struct wined3d_cs_packet, data[0]);
|
|
|
|
packet_size = offsetof(struct wined3d_cs_packet, data[size]);
|
|
|
|
packet_size = (packet_size + header_size - 1) & ~(header_size - 1);
|
|
|
|
|
|
|
|
if (!wined3d_array_reserve(&deferred->data, &deferred->data_capacity, deferred->data_size + packet_size, 1))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
packet = (struct wined3d_cs_packet *)((BYTE *)deferred->data + deferred->data_size);
|
|
|
|
TRACE("size was %zu, adding %zu\n", (size_t)deferred->data_size, packet_size);
|
|
|
|
deferred->data_size += packet_size;
|
|
|
|
packet->size = packet_size - header_size;
|
|
|
|
return &packet->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
|
|
|
{
|
|
|
|
assert(queue_id == WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
|
|
|
|
/* Nothing to do. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
|
|
|
|
{
|
|
|
|
/* This should not happen; we cannot meaningfully finish a deferred context. */
|
|
|
|
ERR("Ignoring finish() on a deferred context.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_push_constants(struct wined3d_device_context *context,
|
|
|
|
enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants)
|
|
|
|
{
|
|
|
|
FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants);
|
|
|
|
}
|
|
|
|
|
2021-06-24 22:29:06 +02:00
|
|
|
static HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
|
|
|
|
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
|
2021-05-27 18:14:29 +02:00
|
|
|
{
|
2021-06-24 22:29:06 +02:00
|
|
|
FIXME("context %p, resource %p, sub_resource_idx %u, map_ptr %p, box %p, flags %#x, stub!\n",
|
|
|
|
context, resource, sub_resource_idx, map_ptr, box, flags);
|
2021-05-27 18:14:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT wined3d_deferred_context_unmap(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_resource *resource, unsigned int sub_resource_idx)
|
|
|
|
{
|
|
|
|
FIXME("context %p, resource %p, sub_resource_idx %u, stub!\n", context, resource, sub_resource_idx);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_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)
|
|
|
|
{
|
|
|
|
FIXME("context %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, slice_pitch %u, stub!\n",
|
|
|
|
context, resource, sub_resource_idx, debug_box(box), data, row_pitch, slice_pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_issue_query(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_query *query, unsigned int flags)
|
|
|
|
{
|
|
|
|
FIXME("context %p, query %p, flags %#x, stub!\n", context, query, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_flush(struct wined3d_device_context *context)
|
|
|
|
{
|
|
|
|
FIXME("context %p, stub!\n", context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_deferred_context_acquire_resource(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_resource *resource)
|
|
|
|
{
|
2021-05-27 18:14:31 +02:00
|
|
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
|
|
|
|
|
|
|
if (!wined3d_array_reserve((void **)&deferred->resources, &deferred->resources_capacity,
|
|
|
|
deferred->resource_count + 1, sizeof(*deferred->resources)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
deferred->resources[deferred->resource_count++] = resource;
|
|
|
|
wined3d_resource_incref(resource);
|
2021-05-27 18:14:29 +02:00
|
|
|
}
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
static void wined3d_deferred_context_execute_command_list(struct wined3d_device_context *context,
|
|
|
|
struct wined3d_command_list *list, bool restore_state)
|
|
|
|
{
|
|
|
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
|
|
|
struct wined3d_cs_execute_command_list *op;
|
|
|
|
|
|
|
|
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
op->opcode = WINED3D_CS_OP_EXECUTE_COMMAND_LIST;
|
|
|
|
op->list = list;
|
|
|
|
|
|
|
|
if (restore_state)
|
|
|
|
wined3d_device_context_set_state(context, context->state);
|
|
|
|
else
|
|
|
|
wined3d_device_context_reset_state(context);
|
|
|
|
|
|
|
|
/* Grab a reference to the command list. Note that this implicitly prevents
|
|
|
|
* any dependent command lists or resources from being freed as well. */
|
|
|
|
if (!wined3d_array_reserve((void **)&deferred->command_lists, &deferred->command_lists_capacity,
|
|
|
|
deferred->command_list_count + 1, sizeof(*deferred->command_lists)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
wined3d_command_list_incref(deferred->command_lists[deferred->command_list_count++] = list);
|
|
|
|
}
|
|
|
|
|
2021-05-27 18:14:29 +02:00
|
|
|
static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
|
|
|
|
{
|
|
|
|
wined3d_deferred_context_require_space,
|
|
|
|
wined3d_deferred_context_submit,
|
|
|
|
wined3d_deferred_context_finish,
|
|
|
|
wined3d_deferred_context_push_constants,
|
|
|
|
wined3d_deferred_context_map,
|
|
|
|
wined3d_deferred_context_unmap,
|
|
|
|
wined3d_deferred_context_update_sub_resource,
|
|
|
|
wined3d_deferred_context_issue_query,
|
|
|
|
wined3d_deferred_context_flush,
|
|
|
|
wined3d_deferred_context_acquire_resource,
|
2021-05-27 18:14:35 +02:00
|
|
|
wined3d_deferred_context_execute_command_list,
|
2021-05-27 18:14:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context)
|
|
|
|
{
|
|
|
|
struct wined3d_deferred_context *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("device %p, context %p.\n", device, context);
|
|
|
|
|
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_state_create(device, &device->cs->c.state->feature_level, 1, &object->c.state)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
object->c.ops = &wined3d_deferred_context_ops;
|
|
|
|
object->c.device = device;
|
|
|
|
|
|
|
|
TRACE("Created deferred context %p.\n", object);
|
|
|
|
*context = &object->c;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *context)
|
|
|
|
{
|
|
|
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
2021-05-27 18:14:31 +02:00
|
|
|
SIZE_T i;
|
2021-05-27 18:14:29 +02:00
|
|
|
|
|
|
|
TRACE("context %p.\n", context);
|
|
|
|
|
2021-05-27 18:14:31 +02:00
|
|
|
for (i = 0; i < deferred->resource_count; ++i)
|
|
|
|
wined3d_resource_decref(deferred->resources[i]);
|
|
|
|
heap_free(deferred->resources);
|
|
|
|
|
2021-05-27 18:14:29 +02:00
|
|
|
wined3d_state_destroy(deferred->c.state);
|
|
|
|
heap_free(deferred->data);
|
|
|
|
heap_free(deferred);
|
|
|
|
}
|
2021-05-27 18:14:33 +02:00
|
|
|
|
|
|
|
HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device_context *context,
|
|
|
|
bool restore, struct wined3d_command_list **list)
|
|
|
|
{
|
|
|
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
|
|
|
struct wined3d_command_list *object;
|
|
|
|
|
|
|
|
TRACE("context %p, list %p.\n", context, list);
|
|
|
|
|
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->refcount = 1;
|
|
|
|
object->device = deferred->c.device;
|
|
|
|
|
|
|
|
if (!(object->data = heap_alloc(deferred->data_size)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
object->data_size = deferred->data_size;
|
|
|
|
memcpy(object->data, deferred->data, deferred->data_size);
|
|
|
|
|
|
|
|
if (!(object->resources = heap_alloc(deferred->resource_count * sizeof(*object->resources))))
|
|
|
|
{
|
|
|
|
heap_free(object->data);
|
|
|
|
heap_free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
object->resource_count = deferred->resource_count;
|
|
|
|
memcpy(object->resources, deferred->resources, deferred->resource_count * sizeof(*object->resources));
|
|
|
|
/* Transfer our references to the resources to the command list. */
|
|
|
|
|
2021-05-27 18:14:35 +02:00
|
|
|
if (!(object->command_lists = heap_alloc(deferred->command_list_count * sizeof(*object->command_lists))))
|
|
|
|
{
|
|
|
|
heap_free(object->resources);
|
|
|
|
heap_free(object->data);
|
|
|
|
heap_free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
object->command_list_count = deferred->command_list_count;
|
|
|
|
memcpy(object->command_lists, deferred->command_lists,
|
|
|
|
deferred->command_list_count * sizeof(*object->command_lists));
|
|
|
|
/* Transfer our references to the command lists to the command list. */
|
|
|
|
|
2021-05-27 18:14:33 +02:00
|
|
|
deferred->data_size = 0;
|
|
|
|
deferred->resource_count = 0;
|
2021-05-27 18:14:35 +02:00
|
|
|
deferred->command_list_count = 0;
|
2021-05-27 18:14:33 +02:00
|
|
|
|
|
|
|
/* This is in fact recorded into a subsequent command list. */
|
2021-05-27 18:14:34 +02:00
|
|
|
if (restore)
|
|
|
|
wined3d_device_context_set_state(&deferred->c, deferred->c.state);
|
|
|
|
else
|
|
|
|
wined3d_device_context_reset_state(&deferred->c);
|
2021-05-27 18:14:33 +02:00
|
|
|
|
|
|
|
TRACE("Created command list %p.\n", object);
|
|
|
|
*list = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|