vo_opengl: remove 1D texture usage
Broke operation with GLSL. Since 1D texture usage was apparently (and mysteriously) good for speed, it might be added back, but it's unknown how to do so in a clean way.
This commit is contained in:
1 parent
9eca8b49db
commit
46a3974200
4 files changed
+32
-52
No files matched your search
+15
-16
@@ -61,6 +61,7 @@ bool mp_init_filter(struct filter_kernel *filter, const int *sizes,
|
||||
// polar filters can be of any radius, and nothing special is needed
|
||||
if (filter->polar) {
|
||||
filter->size = filter->radius;
|
||||
filter->num_coefficients = 1;
|
||||
return true;
|
||||
}
|
||||
// only downscaling requires widening the filter
|
||||
@@ -75,12 +76,14 @@ bool mp_init_filter(struct filter_kernel *filter, const int *sizes,
|
||||
cursize++;
|
||||
if (*cursize) {
|
||||
filter->size = *cursize;
|
||||
filter->num_coefficients = filter->size;
|
||||
return true;
|
||||
} else {
|
||||
// The filter doesn't fit - instead of failing completely, use the
|
||||
// largest filter available. This is incorrect, but better than refusing
|
||||
// to do anything.
|
||||
filter->size = cursize[-1];
|
||||
filter->num_coefficients = filter->size;
|
||||
filter->inv_scale = filter->size / 2.0 / filter->radius;
|
||||
return false;
|
||||
}
|
||||
@@ -107,24 +110,20 @@ void mp_compute_weights(struct filter_kernel *filter, double f, float *out_w)
|
||||
}
|
||||
|
||||
// Fill the given array with weights for the range [0.0, 1.0]. The array is
|
||||
// interpreted as rectangular array of count * filter->size items.
|
||||
// interpreted as rectangular array of count * filter->num_coefficients items.
|
||||
void mp_compute_lut(struct filter_kernel *filter, int count, float *out_array)
|
||||
{
|
||||
for (int n = 0; n < count; n++) {
|
||||
mp_compute_weights(filter, n / (double)(count - 1),
|
||||
out_array + filter->size * n);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the given array with weights for the range [0, R], where R is the
|
||||
// radius of hte filter. The array is interpreted as a one-dimensional array
|
||||
// of count items.
|
||||
void mp_compute_lut_polar(struct filter_kernel *filter, int count, float *out_array)
|
||||
{
|
||||
assert(filter->radius > 0);
|
||||
for (int x = 0; x < count; x++) {
|
||||
double r = x * filter->radius / (count - 1);
|
||||
out_array[x] = r <= filter->radius ? filter->weight(filter, r) : 0;
|
||||
if (filter->polar) {
|
||||
assert(filter->radius > 0);
|
||||
for (int x = 0; x < count; x++) {
|
||||
double r = x * filter->radius / (count - 1);
|
||||
out_array[x] = r <= filter->radius ? filter->weight(filter, r) : 0;
|
||||
}
|
||||
} else {
|
||||
for (int n = 0; n < count; n++) {
|
||||
mp_compute_weights(filter, n / (double)(count - 1),
|
||||
out_array + filter->size * n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@ struct filter_kernel {
|
||||
// Whether or not the filter uses polar coordinates
|
||||
bool polar;
|
||||
// The following values are set by mp_init_filter() at runtime.
|
||||
// Number of coefficients; equals the rounded up radius multiplied with 2.
|
||||
int size;
|
||||
// Number of coefficients; equals the rounded up radius multiplied with 2.
|
||||
int num_coefficients;
|
||||
double inv_scale;
|
||||
};
|
||||
|
||||
|
||||
+14
-32
@@ -1304,9 +1304,9 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
|
||||
|
||||
update_scale_factor(p, scaler);
|
||||
|
||||
int size = scaler->kernel->size;
|
||||
int size = scaler->kernel->num_coefficients;
|
||||
int elems_per_pixel = 4;
|
||||
if (scaler->kernel->polar) {
|
||||
if (size == 1) {
|
||||
elems_per_pixel = 1;
|
||||
} else if (size == 2) {
|
||||
elems_per_pixel = 2;
|
||||
@@ -1314,45 +1314,27 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
|
||||
elems_per_pixel = 3;
|
||||
}
|
||||
int width = size / elems_per_pixel;
|
||||
assert(size == width * elems_per_pixel);
|
||||
const struct fmt_entry *fmt = &gl_float16_formats[elems_per_pixel - 1];
|
||||
if (scaler->kernel->polar) {
|
||||
scaler->lut_name = scaler->index == 0 ? "lut_polar_l" : "lut_polar_c";
|
||||
} else {
|
||||
scaler->lut_name = scaler->index == 0 ? "lut_l" : "lut_c";
|
||||
}
|
||||
scaler->lut_name = scaler->index == 0 ? "lut_l" : "lut_c";
|
||||
|
||||
gl->ActiveTexture(GL_TEXTURE0 + TEXUNIT_SCALERS + scaler->index);
|
||||
|
||||
if (!scaler->gl_lut)
|
||||
gl->GenTextures(1, &scaler->gl_lut);
|
||||
|
||||
if (scaler->kernel->polar) {
|
||||
gl->BindTexture(GL_TEXTURE_1D, scaler->gl_lut);
|
||||
gl->BindTexture(GL_TEXTURE_2D, scaler->gl_lut);
|
||||
|
||||
float *weights = talloc_array(NULL, float, LOOKUP_TEXTURE_SIZE);
|
||||
mp_compute_lut_polar(scaler->kernel, LOOKUP_TEXTURE_SIZE, weights);
|
||||
gl->TexImage1D(GL_TEXTURE_1D, 0, fmt->internal_format, LOOKUP_TEXTURE_SIZE,
|
||||
0, fmt->format, GL_FLOAT, weights);
|
||||
talloc_free(weights);
|
||||
|
||||
gl->TexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
} else {
|
||||
gl->BindTexture(GL_TEXTURE_2D, scaler->gl_lut);
|
||||
|
||||
float *weights = talloc_array(NULL, float, LOOKUP_TEXTURE_SIZE * size);
|
||||
mp_compute_lut(scaler->kernel, LOOKUP_TEXTURE_SIZE, weights);
|
||||
gl->TexImage2D(GL_TEXTURE_2D, 0, fmt->internal_format, width,
|
||||
LOOKUP_TEXTURE_SIZE, 0, fmt->format, GL_FLOAT, weights);
|
||||
talloc_free(weights);
|
||||
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
float *weights = talloc_array(NULL, float, LOOKUP_TEXTURE_SIZE * size);
|
||||
mp_compute_lut(scaler->kernel, LOOKUP_TEXTURE_SIZE, weights);
|
||||
gl->TexImage2D(GL_TEXTURE_2D, 0, fmt->internal_format, width,
|
||||
LOOKUP_TEXTURE_SIZE, 0, fmt->format, GL_FLOAT, weights);
|
||||
talloc_free(weights);
|
||||
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
gl->ActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
||||
@@ -165,8 +165,6 @@ uniform vec2 chroma_center_offset;
|
||||
uniform vec2 chroma_div;
|
||||
uniform sampler2D lut_c;
|
||||
uniform sampler2D lut_l;
|
||||
uniform sampler1D lut_polar_c;
|
||||
uniform sampler1D lut_polar_l;
|
||||
#if HAVE_3DTEX
|
||||
uniform sampler3D lut_3d;
|
||||
#endif
|
||||
@@ -307,7 +305,7 @@ float[6] weights6(sampler2D lookup, float f) {
|
||||
for (int y = 1-R; y <= R; y++) { \
|
||||
for (int x = 1-R; x <= R; x++) { \
|
||||
vec2 d = vec2(x,y) - fcoord; \
|
||||
float w = texture1D(LUT, sqrt(d.x*d.x + d.y*d.y)/R).r; \
|
||||
float w = texture(LUT, vec2(0.5, length(d) / R)).r; \
|
||||
wsum += w; \
|
||||
res += w * texture(tex, base + pt * vec2(x, y)); \
|
||||
} \
|
||||
|
||||
Reference in new issue
Block a user