Commit cca5562f authored by Thomas Guillem's avatar Thomas Guillem

opengl: converter: add GL_TEXTURE_RECTANGLE

This is the default tex format for IOSurface on Macos.
parent ca7d2ea4
......@@ -267,6 +267,15 @@ tc_base_fetch_locations(opengl_tex_converter_t *tc, GLuint program)
tc->uloc.Texture[i] = tc->api->GetUniformLocation(program, name);
if (tc->uloc.Texture[i] == -1)
return VLC_EGENERIC;
#ifdef GL_TEXTURE_RECTANGLE
if (tc->tex_target == GL_TEXTURE_RECTANGLE)
{
snprintf(name, sizeof(name), "TexSize%1u", i);
tc->uloc.TexSize[i] = tc->api->GetUniformLocation(program, name);
if (tc->uloc.TexSize[i] == -1)
return VLC_EGENERIC;
}
#endif
}
tc->uloc.FillColor = tc->api->GetUniformLocation(program, "FillColor");
......@@ -289,6 +298,15 @@ tc_base_prepare_shader(const opengl_tex_converter_t *tc,
tc->api->Uniform1i(tc->uloc.Texture[i], i);
tc->api->Uniform4f(tc->uloc.FillColor, 1.0f, 1.0f, 1.0f, alpha);
#ifdef GL_TEXTURE_RECTANGLE
if (tc->tex_target == GL_TEXTURE_RECTANGLE)
{
for (unsigned i = 0; i < tc->tex_count; ++i)
tc->api->Uniform2f(tc->uloc.TexSize[i], tex_width[i],
tex_height[i]);
}
#endif
}
GLuint
......@@ -316,6 +334,13 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target,
lookup = "texture2D";
coord_name = "TexCoord";
break;
#ifdef GL_TEXTURE_RECTANGLE
case GL_TEXTURE_RECTANGLE:
sampler = "sampler2DRect";
lookup = "texture2DRect";
coord_name = "TexCoordRect";
break;
#endif
default:
vlc_assert_unreachable();
}
......@@ -333,6 +358,14 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target,
ADDF("uniform %s Texture%u;"
"varying vec2 TexCoord%u;", sampler, i, i);
#ifdef GL_TEXTURE_RECTANGLE
if (tex_target == GL_TEXTURE_RECTANGLE)
{
for (unsigned i = 0; i < tc->tex_count; ++i)
ADDF("uniform vec2 TexSize%u;", i);
}
#endif
if (is_yuv)
ADD("uniform vec4 Coefficients[4];");
......@@ -340,6 +373,15 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target,
"void main(void) {"
"float val;vec4 colors;");
#ifdef GL_TEXTURE_RECTANGLE
if (tex_target == GL_TEXTURE_RECTANGLE)
{
for (unsigned i = 0; i < tc->tex_count; ++i)
ADDF("vec2 TexCoordRect%u = vec2(TexCoord%u.x * TexSize%u.x, "
"TexCoord%u.y * TexSize%u.y);", i, i, i, i, i);
}
#endif
unsigned color_idx = 0;
for (unsigned i = 0; i < tc->tex_count; ++i)
{
......
......@@ -196,6 +196,7 @@ struct opengl_tex_converter_t
* function. */
struct {
GLint Texture[PICTURE_PLANE_MAX];
GLint TexSize[PICTURE_PLANE_MAX]; /* for GL_TEXTURE_RECTANGLE */
GLint Coefficients;
GLint FillColor;
} uloc;
......@@ -305,7 +306,7 @@ struct opengl_tex_converter_t
* pf_get_pool, pf_update, and pf_release.
*
* \param tc OpenGL tex converter
* \param tex_target GL_TEXTURE_2D
* \param tex_target GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE
* \param chroma chroma used to generate the fragment shader
* \param if not COLOR_SPACE_UNDEF, YUV planes will be converted to RGB
* according to the color space
......
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