Commit 708b938f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Send clear operations through the command stream.

parent 602c82bc
...@@ -26,6 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); ...@@ -26,6 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
enum wined3d_cs_op enum wined3d_cs_op
{ {
WINED3D_CS_OP_PRESENT, WINED3D_CS_OP_PRESENT,
WINED3D_CS_OP_CLEAR,
}; };
struct wined3d_cs_present struct wined3d_cs_present
...@@ -39,7 +40,18 @@ struct wined3d_cs_present ...@@ -39,7 +40,18 @@ struct wined3d_cs_present
DWORD flags; DWORD flags;
}; };
static void wined3d_cs_exec_present(const void *data) struct wined3d_cs_clear
{
enum wined3d_cs_op opcode;
DWORD rect_count;
const RECT *rects;
DWORD flags;
const struct wined3d_color *color;
float depth;
DWORD stencil;
};
static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
{ {
const struct wined3d_cs_present *op = data; const struct wined3d_cs_present *op = data;
struct wined3d_swapchain *swapchain; struct wined3d_swapchain *swapchain;
...@@ -69,9 +81,40 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw ...@@ -69,9 +81,40 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
cs->ops->submit(cs); cs->ops->submit(cs);
} }
static void (* const wined3d_cs_op_handlers[])(const void *data) = static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_clear *op = data;
struct wined3d_device *device;
RECT draw_rect;
device = cs->device;
wined3d_get_draw_rect(&device->state, &draw_rect);
device_clear_render_targets(device, device->adapter->gl_info.limits.buffers,
&device->fb, op->rect_count, op->rects, &draw_rect, op->flags,
op->color, op->depth, op->stencil);
}
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)
{
struct wined3d_cs_clear *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_CLEAR;
op->rect_count = rect_count;
op->rects = rects;
op->flags = flags;
op->color = color;
op->depth = depth;
op->stencil = stencil;
cs->ops->submit(cs);
}
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
{ {
/* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present,
/* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear,
}; };
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
...@@ -94,7 +137,7 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs) ...@@ -94,7 +137,7 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs)
{ {
enum wined3d_cs_op opcode = *(const enum wined3d_cs_op *)cs->data; enum wined3d_cs_op opcode = *(const enum wined3d_cs_op *)cs->data;
wined3d_cs_op_handlers[opcode](cs->data); wined3d_cs_op_handlers[opcode](cs, cs->data);
} }
static const struct wined3d_cs_ops wined3d_cs_st_ops = static const struct wined3d_cs_ops wined3d_cs_st_ops =
...@@ -103,7 +146,7 @@ static const struct wined3d_cs_ops wined3d_cs_st_ops = ...@@ -103,7 +146,7 @@ static const struct wined3d_cs_ops wined3d_cs_st_ops =
wined3d_cs_st_submit, wined3d_cs_st_submit,
}; };
struct wined3d_cs *wined3d_cs_create(void) struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
{ {
struct wined3d_cs *cs; struct wined3d_cs *cs;
...@@ -111,6 +154,7 @@ struct wined3d_cs *wined3d_cs_create(void) ...@@ -111,6 +154,7 @@ struct wined3d_cs *wined3d_cs_create(void)
return NULL; return NULL;
cs->ops = &wined3d_cs_st_ops; cs->ops = &wined3d_cs_st_ops;
cs->device = device;
cs->data_size = WINED3D_INITIAL_CS_SIZE; cs->data_size = WINED3D_INITIAL_CS_SIZE;
if (!(cs->data = HeapAlloc(GetProcessHeap(), 0, cs->data_size))) if (!(cs->data = HeapAlloc(GetProcessHeap(), 0, cs->data_size)))
......
...@@ -3466,8 +3466,6 @@ HRESULT CDECL wined3d_device_present(const struct wined3d_device *device, const ...@@ -3466,8 +3466,6 @@ HRESULT CDECL wined3d_device_present(const struct wined3d_device *device, const
HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
{ {
RECT draw_rect;
TRACE("device %p, rect_count %u, rects %p, flags %#x, color {%.8e, %.8e, %.8e, %.8e}, depth %.8e, stencil %u.\n", TRACE("device %p, rect_count %u, rects %p, flags %#x, color {%.8e, %.8e, %.8e, %.8e}, depth %.8e, stencil %u.\n",
device, rect_count, rects, flags, color->r, color->g, color->b, color->a, depth, stencil); device, rect_count, rects, flags, color->r, color->g, color->b, color->a, depth, stencil);
...@@ -3497,9 +3495,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou ...@@ -3497,9 +3495,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
} }
} }
wined3d_get_draw_rect(&device->state, &draw_rect); wined3d_cs_emit_clear(device->cs, rect_count, rects, flags, color, depth, stencil);
device_clear_render_targets(device, device->adapter->gl_info.limits.buffers,
&device->fb, rect_count, rects, &draw_rect, flags, color, depth, stencil);
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -4982,7 +4978,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, ...@@ -4982,7 +4978,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
state_init_default(&device->state, &adapter->gl_info); state_init_default(&device->state, &adapter->gl_info);
device->update_state = &device->state; device->update_state = &device->state;
if (!(device->cs = wined3d_cs_create())) if (!(device->cs = wined3d_cs_create(device)))
{ {
WARN("Failed to create command stream.\n"); WARN("Failed to create command stream.\n");
state_cleanup(&device->state); state_cleanup(&device->state);
......
...@@ -2464,14 +2464,17 @@ struct wined3d_cs_ops ...@@ -2464,14 +2464,17 @@ struct wined3d_cs_ops
struct wined3d_cs struct wined3d_cs
{ {
const struct wined3d_cs_ops *ops; const struct wined3d_cs_ops *ops;
struct wined3d_device *device;
size_t data_size; size_t data_size;
void *data; void *data;
}; };
struct wined3d_cs *wined3d_cs_create(void) DECLSPEC_HIDDEN; struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
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) DECLSPEC_HIDDEN;
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN; const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment