summaryrefslogtreecommitdiffstats
path: root/video/out/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl')
-rw-r--r--video/out/opengl/ra.h4
-rw-r--r--video/out/opengl/video.c49
-rw-r--r--video/out/opengl/video.h3
-rw-r--r--video/out/opengl/video_shaders.c8
4 files changed, 23 insertions, 41 deletions
diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h
index 11b458b616..ac209a935d 100644
--- a/video/out/opengl/ra.h
+++ b/video/out/opengl/ra.h
@@ -19,8 +19,8 @@ struct ra {
};
enum {
- RA_CAP_TEX_1D = 0 << 0, // supports 1D textures (as shader source textures)
- RA_CAP_TEX_3D = 0 << 1, // supports 3D textures (as shader source textures)
+ RA_CAP_TEX_1D = 1 << 0, // supports 1D textures (as shader source textures)
+ RA_CAP_TEX_3D = 1 << 1, // supports 3D textures (as shader source textures)
};
enum ra_ctype {
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 2cbf99bad8..e3847ca4eb 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1311,10 +1311,8 @@ static void skip_unused(struct gl_video *p, int num_components)
static void uninit_scaler(struct gl_video *p, struct scaler *scaler)
{
- GL *gl = p->gl;
fbotex_uninit(&scaler->sep_fbo);
- gl->DeleteTextures(1, &scaler->gl_lut);
- scaler->gl_lut = 0;
+ ra_tex_free(p->ra, &scaler->lut);
scaler->kernel = NULL;
scaler->initialized = false;
}
@@ -1595,8 +1593,6 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
double scale_factor,
int sizes[])
{
- GL *gl = p->gl;
-
if (scaler_conf_eq(scaler->conf, *conf) &&
scaler->scale_factor == scale_factor &&
scaler->initialized)
@@ -1651,12 +1647,6 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
scaler->insufficient = !mp_init_filter(scaler->kernel, sizes, scale_factor);
- if (scaler->kernel->polar && (gl->mpgl_caps & MPGL_CAP_1D_TEX)) {
- scaler->gl_target = GL_TEXTURE_1D;
- } else {
- scaler->gl_target = GL_TEXTURE_2D;
- }
-
int size = scaler->kernel->size;
int elems_per_pixel = 4;
if (size == 1) {
@@ -1668,37 +1658,30 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
}
int width = size / elems_per_pixel;
assert(size == width * elems_per_pixel);
- const struct gl_format *fmt = gl_find_float16_format(gl, elems_per_pixel);
- GLenum target = scaler->gl_target;
-
- if (!scaler->gl_lut)
- gl->GenTextures(1, &scaler->gl_lut);
-
- gl->BindTexture(target, scaler->gl_lut);
+ const struct ra_format *fmt = ra_find_float16_format(p->ra, elems_per_pixel);
+ assert(fmt);
scaler->lut_size = 1 << p->opts.scaler_lut_size;
float *weights = talloc_array(NULL, float, scaler->lut_size * size);
mp_compute_lut(scaler->kernel, scaler->lut_size, weights);
- if (target == GL_TEXTURE_1D) {
- gl->TexImage1D(target, 0, fmt->internal_format, scaler->lut_size,
- 0, fmt->format, GL_FLOAT, weights);
- } else {
- gl->TexImage2D(target, 0, fmt->internal_format, width, scaler->lut_size,
- 0, fmt->format, GL_FLOAT, weights);
- }
+ bool use_1d = scaler->kernel->polar && (p->ra->caps & RA_CAP_TEX_1D);
+
+ struct ra_tex_params lut_params = {
+ .dimensions = use_1d ? 1 : 2,
+ .w = use_1d ? scaler->lut_size : width,
+ .h = use_1d ? 1 : scaler->lut_size,
+ .d = 1,
+ .format = fmt,
+ .render_src = true,
+ .src_linear = true,
+ .initial_data = weights,
+ };
+ scaler->lut = ra_tex_create(p->ra, &lut_params);
talloc_free(weights);
- gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- if (target != GL_TEXTURE_1D)
- gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- gl->BindTexture(target, 0);
-
debug_check_gl(p, "after initializing scaler");
}
diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h
index b19f6e099d..5b50cdd3f2 100644
--- a/video/out/opengl/video.h
+++ b/video/out/opengl/video.h
@@ -53,8 +53,7 @@ struct scaler {
double scale_factor;
bool initialized;
struct filter_kernel *kernel;
- GLuint gl_lut;
- GLenum gl_target;
+ struct ra_tex *lut;
struct fbotex sep_fbo;
bool insufficient;
int lut_size;
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index 22c1789d7f..d0e3eaff07 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -38,7 +38,7 @@ void sampler_prelude(struct gl_shader_cache *sc, int tex_num)
static void pass_sample_separated_get_weights(struct gl_shader_cache *sc,
struct scaler *scaler)
{
- gl_sc_uniform_tex(sc, "lut", scaler->gl_target, scaler->gl_lut);
+ gl_sc_uniform_texture(sc, "lut", scaler->lut);
// Define a new variable to cache the corrected fcoord.
GLSLF("float fcoord_lut = LUT_POS(fcoord, %d.0);\n", scaler->lut_size);
@@ -130,7 +130,7 @@ static void polar_sample(struct gl_shader_cache *sc, struct scaler *scaler,
GLSLF("if (d < %f) {\n", radius_cutoff);
// get the weight for this pixel
- if (scaler->gl_target == GL_TEXTURE_1D) {
+ if (scaler->lut->params.dimensions == 1) {
GLSLF("w = texture1D(lut, LUT_POS(d * 1.0/%f, %d.0)).r;\n",
radius, scaler->lut_size);
} else {
@@ -169,7 +169,7 @@ void pass_sample_polar(struct gl_shader_cache *sc, struct scaler *scaler,
for (int n = 0; n < components; n++)
GLSLF("vec4 c%d;\n", n);
- gl_sc_uniform_tex(sc, "lut", scaler->gl_target, scaler->gl_lut);
+ gl_sc_uniform_texture(sc, "lut", scaler->lut);
GLSLF("// scaler samples\n");
int bound = ceil(scaler->kernel->radius_cutoff);
@@ -233,7 +233,7 @@ void pass_compute_polar(struct gl_shader_cache *sc, struct scaler *scaler,
GLSL(vec2 base = pos - pt * fcoord;)
GLSL(ivec2 rel = ivec2(round((base - wbase) * size));)
GLSLF("float w, d, wsum = 0.0;\n");
- gl_sc_uniform_tex(sc, "lut", scaler->gl_target, scaler->gl_lut);
+ gl_sc_uniform_texture(sc, "lut", scaler->lut);
// Load all relevant texels into shmem
gl_sc_enable_extension(sc, "GL_ARB_arrays_of_arrays");