Commit 3ac0592a authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/xvba_video_glx.c: Use glEnable/glDisable on targets when using OpenGL functions.

Explicitly enable/disable targets when using OpenGL code.
parent c2d0d864
......@@ -302,8 +302,9 @@ static void destroy_hw_image_glx(
ASSERT(hwi);
if (hwi->num_textures > 0) {
glDeleteTextures(hwi->num_textures, hwi->textures);
for (i = 0; i < hwi->num_textures; i++) {
assert(hwi->textures[i]);
gl_destroy_texture(&hwi->textures[i], hwi->target);
hwi->formats[i] = GL_NONE;
hwi->textures[i] = 0;
}
......@@ -314,7 +315,6 @@ static void destroy_hw_image_glx(
gl_destroy_shader_object(hwi->shader);
hwi->shader = NULL;
}
free(obj_image->hw.glx);
obj_image->hw.glx = NULL;
}
......@@ -432,6 +432,8 @@ commit_hw_image_glx(
offsets[0] = obj_image->image.offsets[0];
}
glEnable(hwi->target);
unsigned int i;
for (i = 0; i < hwi->num_textures; i++) {
glBindTexture(hwi->target, hwi->textures[i]);
......@@ -448,6 +450,8 @@ commit_hw_image_glx(
);
glBindTexture(hwi->target, 0);
}
glDisable(hwi->target);
return VA_STATUS_SUCCESS;
}
......@@ -493,6 +497,7 @@ render_subpicture(
hwi->formats[0] != GL_RGBA && hwi->formats[0] != GL_BGRA)
return VA_STATUS_ERROR_INVALID_IMAGE;
glEnable(hwi->target);
glBindTexture(hwi->target, hwi->textures[0]);
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glBegin(GL_QUADS);
......@@ -565,6 +570,7 @@ render_subpicture(
}
glEnd();
glBindTexture(hwi->target, 0);
glDisable(hwi->target);
return VA_STATUS_SUCCESS;
}
......@@ -622,7 +628,7 @@ destroy_glx_surface(
}
if (obj_glx_surface->tx_texture) {
glDeleteTextures(1, &obj_glx_surface->tx_texture);
gl_destroy_texture(&obj_glx_surface->tx_texture, obj_glx_surface->target);
obj_glx_surface->tx_texture = 0;
}
......@@ -642,7 +648,7 @@ destroy_glx_surface(
}
if (obj_glx_surface->evergreen_texture) {
glDeleteTextures(1, &obj_glx_surface->evergreen_texture);
gl_destroy_texture(&obj_glx_surface->evergreen_texture, obj_glx_surface->target);
obj_glx_surface->evergreen_texture = 0;
}
......@@ -657,7 +663,7 @@ destroy_glx_surface(
}
if (obj_glx_surface->hqscaler_texture) {
glDeleteTextures(1, &obj_glx_surface->hqscaler_texture);
gl_destroy_texture(&obj_glx_surface->hqscaler_texture, obj_glx_surface->target);
obj_glx_surface->hqscaler_texture = 0;
}
free(obj_glx_surface);
......@@ -731,6 +737,7 @@ create_glx_surface_from_texture(
obj_glx_surface->evergreen_workaround = -1;
/* XXX: we don't support other textures than RGBA */
glEnable(target);
glBindTexture(target, texture);
if (!gl_get_texture_param(target, GL_TEXTURE_INTERNAL_FORMAT, &iformat))
goto end;
......@@ -759,6 +766,8 @@ create_glx_surface_from_texture(
is_error = 0;
end:
glBindTexture(target, 0);
glDisable(target);
if (is_error && obj_glx_surface) {
destroy_glx_surface(driver_data, obj_glx_surface);
obj_glx_surface = NULL;
......@@ -977,9 +986,11 @@ transfer_surface_native(
return VA_STATUS_ERROR_ALLOCATION_FAILED;
/* XXX: some algorithms work modulo the texture size */
glEnable(obj_glx_surface->target);
glBindTexture(GL_TEXTURE_2D, obj_glx_surface->evergreen_texture);
gl_set_texture_wrapping(GL_TEXTURE_2D, GL_REPEAT);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(obj_glx_surface->target);
}
if (!obj_glx_surface->evergreen_fbo) {
......@@ -1137,6 +1148,7 @@ transfer_surface_native(
needs_alternate_texture = 1;
alternate_texture = obj_glx_surface->evergreen_texture;
glEnable(obj_glx_surface->target);
gl_bind_framebuffer_object(obj_glx_surface->evergreen_fbo);
glBindTexture(GL_TEXTURE_2D, obj_glx_surface->tx_texture);
if (obj_glx_surface->evergreen_shader) {
......@@ -1164,6 +1176,7 @@ transfer_surface_native(
if (obj_glx_surface->evergreen_shader)
gl_unbind_shader_object(obj_glx_surface->evergreen_shader);
gl_unbind_framebuffer_object(obj_glx_surface->evergreen_fbo);
glDisable(obj_glx_surface->target);
}
else if (needs_tx_texture) {
needs_alternate_texture = 1;
......@@ -1171,6 +1184,7 @@ transfer_surface_native(
}
if (needs_alternate_texture) {
glEnable(obj_glx_surface->target);
gl_bind_framebuffer_object(obj_glx_surface->fbo);
glBindTexture(GL_TEXTURE_2D, alternate_texture);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
......@@ -1188,6 +1202,7 @@ transfer_surface_native(
}
glEnd();
gl_unbind_framebuffer_object(obj_glx_surface->fbo);
glDisable(obj_glx_surface->target);
}
return VA_STATUS_SUCCESS;
}
......@@ -1229,6 +1244,8 @@ transfer_surface(
if (!obj_buffer)
return VA_STATUS_ERROR_INVALID_BUFFER;
glEnable(hwi->target);
GLVTable * const gl_vtable = gl_get_vtable();
unsigned int i;
for (i = 0; i < hwi->num_textures; i++) {
......@@ -1286,6 +1303,8 @@ transfer_surface(
gl_vtable->gl_active_texture(GL_TEXTURE0 + i);
glBindTexture(hwi->target, 0);
} while (i > 0);
glDisable(hwi->target);
return VA_STATUS_SUCCESS;
}
......@@ -1380,6 +1399,7 @@ ensure_hqscaler_texture(void)
data[i*4 + 3] = g1;
}
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, tex);
gl_set_texture_scaling(GL_TEXTURE_1D, GL_NEAREST);
gl_set_texture_wrapping(GL_TEXTURE_1D, GL_REPEAT);
......@@ -1393,13 +1413,14 @@ ensure_hqscaler_texture(void)
data
);
glBindTexture(GL_TEXTURE_1D, 0);
glDisable(GL_TEXTURE_1D);
free(data);
return tex;
/* ERRORS */
error:
if (tex)
glDeleteTextures(1, &tex);
gl_destroy_texture(&tex, GL_TEXTURE_1D);
if (data)
free(data);
return 0;
......@@ -1428,6 +1449,7 @@ ensure_scaler(
}
const GLenum target = obj_glx_surface->target;
glEnable(target);
switch (va_scale) {
case VA_FILTER_SCALING_DEFAULT:
glBindTexture(target, obj_glx_surface->texture);
......@@ -1464,8 +1486,9 @@ ensure_scaler(
if (!obj_glx_surface->hqscaler)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
break;
} /* end VA_FILTER_SCALING_HQ */
}
}
glDisable(target);
obj_glx_surface->va_scale = va_scale;
return VA_STATUS_SUCCESS;
......@@ -1585,6 +1608,8 @@ do_copy_surface_glx(
/* Create framebuffer surface */
if (!fbo_ensure(obj_glx_surface))
return VA_STATUS_ERROR_ALLOCATION_FAILED;
glEnable(obj_glx_surface->target);
gl_bind_framebuffer_object(obj_glx_surface->fbo);
/* Re-render the video frame with ProcAmp adjustments */
......@@ -1645,6 +1670,7 @@ do_copy_surface_glx(
status = render_subpictures(driver_data, obj_surface, &surface_rect);
gl_unbind_framebuffer_object(obj_glx_surface->fbo);
glDisable(obj_glx_surface->target);
return status;
}
......@@ -2108,6 +2134,7 @@ flip_surface(
object_glx_surface_p const obj_glx_surface = obj_output->gl_surface;
/* Draw GL surface to screen */
glEnable(obj_glx_surface->target);
glBindTexture(obj_glx_surface->target, obj_glx_surface->texture);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
......@@ -2142,6 +2169,7 @@ flip_surface(
gl_swap_buffers(glx_output_surface_get_context(obj_output));
obj_output->render_ticks++;
glDisable(obj_glx_surface->target);
return VA_STATUS_SUCCESS;
}
......@@ -2213,6 +2241,7 @@ do_put_surface_glx(
float params[4];
unsigned int i;
glEnable(obj_glx_surface->target);
gl_bind_framebuffer_object(obj_output->gl_surface->fbo);
gl_vtable->gl_active_texture(GL_TEXTURE0);
glBindTexture(obj_glx_surface->target, obj_glx_surface->texture);
......@@ -2298,6 +2327,7 @@ do_put_surface_glx(
gl_unbind_shader_object(obj_glx_surface->hqscaler);
}
gl_unbind_framebuffer_object(obj_output->gl_surface->fbo);
glDisable(obj_glx_surface->target);
/* Queue surface for display */
return queue_surface(driver_data, obj_output, obj_surface);
......
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