From f7926c079318662052df863cb204eb165436b1c7 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Thu, 19 Apr 2018 15:50:16 +0430 Subject: [PATCH] wined3d: Allow context_draw_shaded_quad() to function without immediate mode draws. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 41 +++++++++++++++++++++++++++++++++++------ dlls/wined3d/glsl_shader.c | 3 --- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 9ba625319c0..d5378e203e0 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1447,6 +1447,9 @@ static void context_destroy_gl_resources(struct wined3d_context *context) } } + if (context->blit_vbo) + GL_EXTCALL(glDeleteBuffers(1, &context->blit_vbo)); + checkGLcall("context cleanup"); } @@ -5564,15 +5567,41 @@ void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_te quad[3].texcoord = info.texcoords[3]; /* Draw a quad. */ - gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP); - - for (i = 0; i < ARRAY_SIZE(quad); ++i) + if (gl_info->supported[ARB_VERTEX_BUFFER_OBJECT]) { - GL_EXTCALL(glVertexAttrib3fv(1, &quad[i].texcoord.x)); - GL_EXTCALL(glVertexAttrib2fv(0, &quad[i].x)); + if (!context->blit_vbo) + GL_EXTCALL(glGenBuffers(1, &context->blit_vbo)); + GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, context->blit_vbo)); + + context_unload_vertex_data(context); + context_unload_numbered_arrays(context); + + GL_EXTCALL(glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW)); + GL_EXTCALL(glVertexAttribPointer(0, 2, GL_FLOAT, FALSE, sizeof(*quad), NULL)); + GL_EXTCALL(glVertexAttribPointer(1, 3, GL_FLOAT, FALSE, sizeof(*quad), + (void *)FIELD_OFFSET(struct blit_vertex, texcoord))); + + GL_EXTCALL(glEnableVertexAttribArray(0)); + GL_EXTCALL(glEnableVertexAttribArray(1)); + + gl_info->gl_ops.gl.p_glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, 0)); + GL_EXTCALL(glDisableVertexAttribArray(1)); + GL_EXTCALL(glDisableVertexAttribArray(0)); } + else + { + gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP); - gl_info->gl_ops.gl.p_glEnd(); + for (i = 0; i < ARRAY_SIZE(quad); ++i) + { + GL_EXTCALL(glVertexAttrib3fv(1, &quad[i].texcoord.x)); + GL_EXTCALL(glVertexAttrib2fv(0, &quad[i].x)); + } + + gl_info->gl_ops.gl.p_glEnd(); + } checkGLcall("draw"); gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture->level_count - 1); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 799b2ff1caf..dfd8e61f902 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12628,9 +12628,6 @@ void wined3d_glsl_blitter_create(struct wined3d_blitter **next, const struct win if (!gl_info->supported[ARB_VERTEX_SHADER] || !gl_info->supported[ARB_FRAGMENT_SHADER]) return; - if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) - return; - if (!(blitter = heap_alloc(sizeof(*blitter)))) { ERR("Failed to allocate blitter.\n"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d53941318cc..8cdc3ef6f93 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1983,6 +1983,8 @@ struct wined3d_context struct wined3d_fence *buffer_fences[MAX_ATTRIBS]; unsigned int buffer_fence_count; + GLuint blit_vbo; + DWORD tex_unit_map[MAX_COMBINED_SAMPLERS]; DWORD rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS]; -- 2.11.4.GIT