From 972d9dae8b704adc66da87dd3b1daef8b109b787 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 13 Apr 2017 00:11:00 +0200 Subject: [PATCH] wined3d: Send flushes through the command stream. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/cs.c | 26 ++++++++++++++++++++++++++ dlls/wined3d/device.c | 9 +-------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 85594e45ac4..6d413d49483 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -30,6 +30,7 @@ enum wined3d_cs_op WINED3D_CS_OP_CLEAR, WINED3D_CS_OP_DISPATCH, WINED3D_CS_OP_DRAW, + WINED3D_CS_OP_FLUSH, WINED3D_CS_OP_SET_PREDICATION, WINED3D_CS_OP_SET_VIEWPORT, WINED3D_CS_OP_SET_SCISSOR_RECT, @@ -112,6 +113,11 @@ struct wined3d_cs_draw BOOL indexed; }; +struct wined3d_cs_flush +{ + enum wined3d_cs_op opcode; +}; + struct wined3d_cs_set_predication { enum wined3d_cs_op opcode; @@ -759,6 +765,25 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base cs->ops->submit(cs); } +static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data) +{ + struct wined3d_context *context; + + context = context_acquire(cs->device, NULL, 0); + context->gl_info->gl_ops.gl.p_glFlush(); + context_release(context); +} + +void wined3d_cs_emit_flush(struct wined3d_cs *cs) +{ + struct wined3d_cs_flush *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_FLUSH; + + cs->ops->submit(cs); +} + static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_predication *op = data; @@ -2007,6 +2032,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* 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, /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index a43e080c121..83965e7869b 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3374,8 +3374,6 @@ HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device) HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device) { - struct wined3d_context *context; - TRACE("device %p.\n", device); if (!device->inScene) @@ -3384,12 +3382,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device) return WINED3DERR_INVALIDCALL; } - context = context_acquire(device, NULL, 0); - /* We only have to do this if we need to read the, swapbuffers performs a flush for us */ - context->gl_info->gl_ops.gl.p_glFlush(); - /* No checkGLcall here to avoid locking the lock just for checking a call that hardly ever - * fails. */ - context_release(context); + wined3d_cs_emit_flush(device->cs); device->inScene = FALSE; return WINED3D_OK; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b39bc2fc0e2..74b61fb839c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3258,6 +3258,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base_vertex_idx, unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN; +void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN; 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, DWORD flags) DECLSPEC_HIDDEN;