Commit 559a682d authored by Thomas Guillem's avatar Thomas Guillem

opengl: converter: change pf_allocate_texture

This callback is now used to allocate all textures. This will allow more
control on the converter side (some API allocate textures by batch).
parent 467f89ab
......@@ -699,15 +699,16 @@ error:
#endif /* VLCGL_HAS_PBO */
static int
tc_common_allocate_texture(const opengl_tex_converter_t *tc, GLuint texture,
unsigned tex_idx, const GLsizei tex_width,
const GLsizei tex_height)
tc_common_allocate_textures(const opengl_tex_converter_t *tc, GLuint *textures,
const GLsizei *tex_width, const GLsizei *tex_height)
{
(void) texture;
glTexImage2D(tc->tex_target, 0, tc->texs[tex_idx].internal,
tex_width, tex_height, 0, tc->texs[tex_idx].format,
tc->texs[tex_idx].type, NULL);
for (unsigned i = 0; i < tc->tex_count; i++)
{
glBindTexture(tc->tex_target, textures[i]);
glTexImage2D(tc->tex_target, 0, tc->texs[i].internal,
tex_width[i], tex_height[i], 0, tc->texs[i].format,
tc->texs[i].type, NULL);
}
return VLC_SUCCESS;
}
......@@ -820,7 +821,7 @@ common_init(opengl_tex_converter_t *tc)
tc->pf_update = tc_common_update;
tc->pf_release = tc_common_release;
tc->pf_allocate_texture = tc_common_allocate_texture;
tc->pf_allocate_textures = tc_common_allocate_textures;
#ifdef VLCGL_HAS_PBO
const bool supports_pbo = tc->api->BufferStorage
......
......@@ -212,22 +212,20 @@ struct opengl_tex_converter_t
void *priv;
/*
* Callback to allocate data for a bound texture
* Callback to allocate data for bound textures
*
* This function pointer can be NULL. Software converters should call
* glTexImage2D() to allocate texture data (it will be deallocated by the
* glTexImage2D() to allocate textures data (it will be deallocated by the
* caller when calling glDeleteTextures()).
*
* \param fc OpenGL tex converter
* \param texture bound texture
* \param tex_idx texture index
* \param tex_width texture width
* \param tex_height texture height
* \param textures array of textures to bind (one per plane)
* \param tex_width array of tex width (one per plane)
* \param tex_height array of tex height (one per plane)
* \return VLC_SUCCESS or a VLC error
*/
int (*pf_allocate_texture)(const opengl_tex_converter_t *fc, GLuint texture,
unsigned tex_idx, const GLsizei tex_width,
const GLsizei tex_height);
int (*pf_allocate_textures)(const opengl_tex_converter_t *tc, GLuint *textures,
const GLsizei *tex_width, const GLsizei *tex_height);
/*
* Callback to allocate a picture pool
......
......@@ -407,19 +407,16 @@ GenTextures(const opengl_tex_converter_t *tc,
glTexParameteri(tc->tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(tc->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(tc->tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (tc->pf_allocate_texture != NULL)
}
if (tc->pf_allocate_textures != NULL)
{
int ret = tc->pf_allocate_textures(tc, textures, tex_width, tex_height);
if (ret != VLC_SUCCESS)
{
int ret = tc->pf_allocate_texture(tc, textures[i], i, tex_width[i],
tex_height[i]);
if (ret != VLC_SUCCESS)
{
if (i > 0)
{
glDeleteTextures(i, textures);
memset(textures, 0, tc->tex_count * sizeof(GLuint));
}
return ret;
}
glDeleteTextures(tc->tex_count, textures);
memset(textures, 0, tc->tex_count * sizeof(GLuint));
return ret;
}
}
return VLC_SUCCESS;
......
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