From 41717a148e48544811a5eefcb7e49c8433d5f90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Sun, 25 Feb 2018 23:23:28 +0100 Subject: [PATCH] wined3d: Move dispatch_compute() to context.c file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 61 +++++++++++++++++++++++++++++++++- dlls/wined3d/drawprim.c | 59 -------------------------------- dlls/wined3d/wined3d_private.h | 2 -- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index d552c8cc249..1c39f0a06ca 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -4023,7 +4023,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, return TRUE; } -void context_apply_compute_state(struct wined3d_context *context, +static void context_apply_compute_state(struct wined3d_context *context, const struct wined3d_device *device, const struct wined3d_state *state) { const struct StateEntry *state_table = context->state_table; @@ -4247,3 +4247,62 @@ struct wined3d_context *context_reacquire(const struct wined3d_device *device, ERR("Acquired context %p instead of %p.\n", current_context, context); return current_context; } + +void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state, + const struct wined3d_dispatch_parameters *parameters) +{ + const struct wined3d_gl_info *gl_info; + struct wined3d_context *context; + + context = context_acquire(device, NULL, 0); + if (!context->valid) + { + context_release(context); + WARN("Invalid context, skipping dispatch.\n"); + return; + } + gl_info = context->gl_info; + + if (!gl_info->supported[ARB_COMPUTE_SHADER]) + { + context_release(context); + FIXME("OpenGL implementation does not support compute shaders.\n"); + return; + } + + if (parameters->indirect) + wined3d_buffer_load(parameters->u.indirect.buffer, context, state); + + context_apply_compute_state(context, device, state); + + if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE]) + { + context_release(context); + WARN("No compute shader bound, skipping dispatch.\n"); + return; + } + + if (parameters->indirect) + { + const struct wined3d_indirect_dispatch_parameters *indirect = ¶meters->u.indirect; + struct wined3d_buffer *buffer = indirect->buffer; + + GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer->buffer_object)); + GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset)); + GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0)); + } + else + { + const struct wined3d_direct_dispatch_parameters *direct = ¶meters->u.direct; + GL_EXTCALL(glDispatchCompute(direct->group_count_x, direct->group_count_y, direct->group_count_z)); + } + checkGLcall("dispatch compute"); + + GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS)); + checkGLcall("glMemoryBarrier"); + + if (wined3d_settings.strict_draw_ordering) + gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ + + context_release(context); +} diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 7eccc8f7d62..f87f0919c16 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -727,62 +727,3 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s TRACE("Done all gl drawing.\n"); } - -void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state, - const struct wined3d_dispatch_parameters *parameters) -{ - const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; - - context = context_acquire(device, NULL, 0); - if (!context->valid) - { - context_release(context); - WARN("Invalid context, skipping dispatch.\n"); - return; - } - gl_info = context->gl_info; - - if (!gl_info->supported[ARB_COMPUTE_SHADER]) - { - context_release(context); - FIXME("OpenGL implementation does not support compute shaders.\n"); - return; - } - - if (parameters->indirect) - wined3d_buffer_load(parameters->u.indirect.buffer, context, state); - - context_apply_compute_state(context, device, state); - - if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE]) - { - context_release(context); - WARN("No compute shader bound, skipping dispatch.\n"); - return; - } - - if (parameters->indirect) - { - const struct wined3d_indirect_dispatch_parameters *indirect = ¶meters->u.indirect; - struct wined3d_buffer *buffer = indirect->buffer; - - GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer->buffer_object)); - GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset)); - GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0)); - } - else - { - const struct wined3d_direct_dispatch_parameters *direct = ¶meters->u.direct; - GL_EXTCALL(glDispatchCompute(direct->group_count_x, direct->group_count_y, direct->group_count_z)); - } - checkGLcall("dispatch compute"); - - GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS)); - checkGLcall("glMemoryBarrier"); - - if (wined3d_settings.strict_draw_ordering) - gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ - - context_release(context); -} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b4d15c5b5f9..650c1a554e2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2135,8 +2135,6 @@ void context_alloc_occlusion_query(struct wined3d_context *context, void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device) DECLSPEC_HIDDEN; BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state, UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN; -void context_apply_compute_state(struct wined3d_context *context, - const struct wined3d_device *device, const struct wined3d_state *state) DECLSPEC_HIDDEN; BOOL context_apply_draw_state(struct wined3d_context *context, const struct wined3d_device *device, const struct wined3d_state *state) DECLSPEC_HIDDEN; void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,