Commit bd5a40b0 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/xvab_video_glx.c: Various fixes

- Fix memleak in render_thread
- Destroy shaders, procam, scalers from the correct 'target'
- other small issues
parent 353d1203
......@@ -303,21 +303,21 @@ static void destroy_hw_image_glx(
object_image_glx_p const hwi = obj_image->hw.glx;
ASSERT(hwi);
ASSERT(hwi->num_textures > 0);
if (hwi->num_textures > 0) {
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;
}
hwi->num_textures = 0;
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;
}
hwi->num_textures = 0;
if (hwi->shader) {
gl_destroy_shader_object(hwi->shader);
hwi->shader = NULL;
}
free(obj_image->hw.glx);
obj_image->hw.glx = NULL;
}
......@@ -330,6 +330,7 @@ create_hw_image_glx(
XVBASession *session
)
{
assert(obj_image->hw.glx == NULL);
object_image_glx_p hwi = calloc(1, sizeof(*hwi));
if (!hwi)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
......@@ -439,6 +440,13 @@ commit_hw_image_glx(
unsigned int i;
for (i = 0; i < hwi->num_textures; i++) {
GLenum type;
type = GL_UNSIGNED_BYTE;
if (hwi->formats[i] == GL_RGBA32F_ARB)
type = GL_FLOAT;
if (!glIsTexture(hwi->textures[i]))
abort();
glBindTexture(hwi->target, hwi->textures[i]);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glTexSubImage2D(
......@@ -448,9 +456,12 @@ commit_hw_image_glx(
0,
hwi->width >> (i > 0),
hwi->height >> (i > 0),
hwi->formats[i], GL_UNSIGNED_BYTE,
(uint8_t *)obj_buffer->buffer_data + offsets[i]
hwi->formats[i],
type,
(uint8_t *)(obj_buffer->buffer_data + offsets[i])
);
if (gl_check_error())
abort();
glBindTexture(hwi->target, 0);
}
......@@ -574,6 +585,7 @@ render_subpicture(
glEnd();
glBindTexture(hwi->target, 0);
glDisable(hwi->target);
return VA_STATUS_SUCCESS;
}
......@@ -666,7 +678,7 @@ destroy_glx_surface(
}
if (obj_glx_surface->hqscaler_texture) {
gl_destroy_texture(&obj_glx_surface->hqscaler_texture, obj_glx_surface->target);
gl_destroy_texture(&obj_glx_surface->hqscaler_texture, GL_TEXTURE_1D);
obj_glx_surface->hqscaler_texture = 0;
}
free(obj_glx_surface);
......@@ -980,7 +992,7 @@ transfer_surface_native(
if (!obj_glx_surface->evergreen_texture) {
obj_glx_surface->evergreen_texture = gl_create_texture(
GL_TEXTURE_2D,
obj_glx_surface->target,
GL_BGRA,
src_xvba_surface->info.normal.width,
src_xvba_surface->info.normal.height
......@@ -990,15 +1002,15 @@ transfer_surface_native(
/* 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);
glBindTexture(obj_glx_surface->target, obj_glx_surface->evergreen_texture);
gl_set_texture_wrapping(obj_glx_surface->target, GL_REPEAT);
glBindTexture(obj_glx_surface->target, 0);
glDisable(obj_glx_surface->target);
}
if (!obj_glx_surface->evergreen_fbo) {
obj_glx_surface->evergreen_fbo = gl_create_framebuffer_object(
GL_TEXTURE_2D,
obj_glx_surface->target,
obj_glx_surface->evergreen_texture,
src_xvba_surface->info.normal.width,
src_xvba_surface->info.normal.height
......@@ -1105,7 +1117,7 @@ transfer_surface_native(
if (!obj_glx_surface->tx_texture) {
obj_glx_surface->tx_texture = gl_create_texture(
GL_TEXTURE_2D,
obj_glx_surface->target,
GL_BGRA,
src_xvba_surface->info.normal.width,
src_xvba_surface->info.normal.height
......@@ -1153,7 +1165,7 @@ transfer_surface_native(
glEnable(obj_glx_surface->target);
gl_bind_framebuffer_object(obj_glx_surface->evergreen_fbo);
glBindTexture(GL_TEXTURE_2D, obj_glx_surface->tx_texture);
glBindTexture(obj_glx_surface->target, obj_glx_surface->tx_texture);
if (obj_glx_surface->evergreen_shader) {
gl_bind_shader_object(obj_glx_surface->evergreen_shader);
......@@ -1189,7 +1201,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);
glBindTexture(obj_glx_surface->target, alternate_texture);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
{
......
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