summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/common')
-rw-r--r--src/mesa/drivers/common/meta.c42
-rw-r--r--src/mesa/drivers/common/meta.h6
-rw-r--r--src/mesa/drivers/common/meta_blit.c5
-rw-r--r--src/mesa/drivers/common/meta_generate_mipmap.c4
4 files changed, 37 insertions, 20 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 7848e5d7b67..798639f7069 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -310,9 +310,9 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
/**
* Configure vertex buffer and vertex array objects for tests
*
- * Regardless of whether a new VAO and new VBO are created, the objects
- * referenced by \c VAO and \c VBO will be bound into the GL state vector
- * when this function terminates.
+ * Regardless of whether a new VAO is created, the object referenced by \c VAO
+ * will be bound into the GL state vector when this function terminates. The
+ * object referenced by \c VBO will \b not be bound.
*
* \param VAO Storage for vertex array object handle. If 0, a new VAO
* will be created.
@@ -333,7 +333,8 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
* Use \c texcoord_size instead.
*/
void
-_mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO,
+_mesa_meta_setup_vertex_objects(struct gl_context *ctx,
+ GLuint *VAO, GLuint *VBO,
bool use_generic_attributes,
unsigned vertex_size, unsigned texcoord_size,
unsigned color_size)
@@ -381,9 +382,18 @@ _mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO,
_mesa_EnableClientState(GL_COLOR_ARRAY);
}
}
+
+ /* Restore the old VBO. This is done because we don't want the new VBO
+ * to be bound on exit. It would be nicer to use DSA type functions,
+ * but there are no DSA functions to bind a VBO to a VAO for
+ * fixed-function vertex attributes.
+ */
+ {
+ struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1];
+ _mesa_BindBuffer(GL_ARRAY_BUFFER, save->ArrayBufferObj->Name);
+ }
} else {
_mesa_BindVertexArray(*VAO);
- _mesa_BindBuffer(GL_ARRAY_BUFFER, *VBO);
}
}
@@ -1490,10 +1500,11 @@ _mesa_meta_setup_drawpix_texture(struct gl_context *ctx,
}
void
-_mesa_meta_setup_ff_tnl_for_blit(GLuint *VAO, GLuint *VBO,
+_mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx,
+ GLuint *VAO, GLuint *VBO,
unsigned texcoord_size)
{
- _mesa_meta_setup_vertex_objects(VAO, VBO, false, 2, texcoord_size, 0);
+ _mesa_meta_setup_vertex_objects(ctx, VAO, VBO, false, 2, texcoord_size, 0);
/* setup projection matrix */
_mesa_MatrixMode(GL_PROJECTION);
@@ -1538,7 +1549,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
GLuint vs, fs;
bool has_integer_textures;
- _mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, true, 3, 0, 0);
+ _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->VBO, true,
+ 3, 0, 0);
if (clear->ShaderProg != 0)
return;
@@ -1734,7 +1746,8 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl)
y1 = ((float) fb->_Ymax / fb->Height) * 2.0f - 1.0f;
z = -invert_z(ctx->Depth.Clear);
} else {
- _mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, false, 3, 0, 4);
+ _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->VBO, false,
+ 3, 0, 4);
x0 = (float) fb->_Xmin;
y0 = (float) fb->_Ymin;
@@ -1863,7 +1876,7 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
MESA_META_VERTEX |
MESA_META_VIEWPORT));
- _mesa_meta_setup_vertex_objects(&copypix->VAO, &copypix->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, &copypix->VAO, &copypix->VBO, false,
3, 2, 0);
/* Silence valgrind warnings about reading uninitialized stack. */
@@ -2184,7 +2197,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat);
- _mesa_meta_setup_vertex_objects(&drawpix->VAO, &drawpix->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, &drawpix->VAO, &drawpix->VBO, false,
3, 2, 0);
/* Silence valgrind warnings about reading uninitialized stack. */
@@ -2376,7 +2389,8 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
MESA_META_VERTEX |
MESA_META_VIEWPORT));
- _mesa_meta_setup_vertex_objects(&bitmap->VAO, &bitmap->VBO, false, 3, 2, 4);
+ _mesa_meta_setup_vertex_objects(ctx, &bitmap->VAO, &bitmap->VBO, false,
+ 3, 2, 4);
newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat);
@@ -3077,12 +3091,12 @@ decompress_texture_image(struct gl_context *ctx,
}
if (use_glsl_version) {
- _mesa_meta_setup_vertex_objects(&decompress->VAO, &decompress->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &decompress->VAO, &decompress->VBO, true,
2, 4, 0);
_mesa_meta_setup_blit_shader(ctx, target, false, &decompress->shaders);
} else {
- _mesa_meta_setup_ff_tnl_for_blit(&decompress->VAO, &decompress->VBO, 3);
+ _mesa_meta_setup_ff_tnl_for_blit(ctx, &decompress->VAO, &decompress->VBO, 3);
}
if (!decompress->Sampler) {
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index d4bf0b65524..48607d40e75 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -620,13 +620,15 @@ struct temp_texture *
_mesa_meta_get_temp_depth_texture(struct gl_context *ctx);
void
-_mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO,
+_mesa_meta_setup_vertex_objects(struct gl_context *ctx,
+ GLuint *VAO, GLuint *VBO,
bool use_generic_attributes,
unsigned vertex_size, unsigned texcoord_size,
unsigned color_size);
void
-_mesa_meta_setup_ff_tnl_for_blit(GLuint *VAO, GLuint *VBO,
+_mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx,
+ GLuint *VAO, GLuint *VBO,
unsigned texcoord_size);
void
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index da9f603440e..84c81309019 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -565,7 +565,7 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
texcoord_size = 2 + (src_rb->Depth > 1 ? 1 : 0);
- _mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &blit->VAO, &blit->VBO, true,
2, texcoord_size, 0);
if (is_target_multisample && is_filter_scaled_resolve && is_scaled_blit) {
@@ -691,7 +691,8 @@ blitframebuffer_texture(struct gl_context *ctx,
do_depth);
}
else {
- _mesa_meta_setup_ff_tnl_for_blit(&ctx->Meta->Blit.VAO,
+ _mesa_meta_setup_ff_tnl_for_blit(ctx,
+ &ctx->Meta->Blit.VAO,
&ctx->Meta->Blit.VBO,
2);
}
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index 8389217731c..28fc5ebe812 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -196,11 +196,11 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
* GenerateMipmap function.
*/
if (use_glsl_version) {
- _mesa_meta_setup_vertex_objects(&mipmap->VAO, &mipmap->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &mipmap->VAO, &mipmap->VBO, true,
2, 4, 0);
_mesa_meta_setup_blit_shader(ctx, target, false, &mipmap->shaders);
} else {
- _mesa_meta_setup_ff_tnl_for_blit(&mipmap->VAO, &mipmap->VBO, 3);
+ _mesa_meta_setup_ff_tnl_for_blit(ctx, &mipmap->VAO, &mipmap->VBO, 3);
_mesa_set_enable(ctx, target, GL_TRUE);
}