Commit 44b4f779 authored by Niklas Haas's avatar Niklas Haas

shaders: change implicit GLSL version assumptions

Instead of assuming the lowest possible, assume GLSL 130 as the
baseline. This requires bumping the API version because it is a breaking
change to some use cases.

Also a missing GLSL version compat check to the dither code.
parent 717e49c5
......@@ -2,7 +2,7 @@ project('libplacebo', ['c', 'cpp'],
license: 'LGPL2.1+',
default_options: ['c_std=c99'],
meson_version: '>=0.47',
version: '1.18.0',
version: '1.19.0',
)
# Version number
......
......@@ -919,9 +919,5 @@ const char *sh_bvec(const struct pl_shader *sh, int dims)
};
pl_assert(dims > 0 && dims < PL_ARRAY_SIZE(bvecs));
if (sh->gpu && sh->gpu->glsl.version >= 130) {
return bvecs[dims];
} else {
return vecs[dims];
}
return sh_glsl_ver(sh) >= 130 ? bvecs[dims] : vecs[dims];
}
......@@ -205,3 +205,9 @@ ident_t sh_lut(struct pl_shader *sh, struct pl_shader_obj **obj,
// returns bvecN. For GLSL 120, this returns vecN instead. The intended use of
// this function is with mix(), which only accepts bvec in GLSL 130+.
const char *sh_bvec(const struct pl_shader *sh, int dims);
// Returns the GLSL version, defaulting to 130 if no information is known
static inline int sh_glsl_ver(const struct pl_shader *sh)
{
return sh->gpu ? sh->gpu->glsl.version : 130;
}
......@@ -1019,13 +1019,20 @@ void pl_shader_dither(struct pl_shader *sh, int new_depth,
}
enum pl_dither_method method = params->method;
bool can_fixed = sh_glsl_ver(sh) >= 130;
ident_t lut = NULL;
int lut_size = 0;
if (method == PL_DITHER_ORDERED_FIXED && !can_fixed) {
PL_WARN(sh, "PL_DITHER_ORDERED_FIXED requires glsl version >= 130.."
" falling back.");
goto fallback;
}
if (dither_method_is_lut(method)) {
if (!dither_state) {
PL_TRACE(sh, "LUT-based dither method specified but no dither state "
"object given, falling back to non-LUT based methods.");
PL_WARN(sh, "LUT-based dither method specified but no dither state "
"object given, falling back to non-LUT based methods.");
goto fallback;
}
......@@ -1048,13 +1055,9 @@ void pl_shader_dither(struct pl_shader *sh, int new_depth,
goto done;
fallback:
if (sh->gpu && sh->gpu->glsl.version >= 130) {
method = PL_DITHER_ORDERED_FIXED;
} else {
method = PL_DITHER_WHITE_NOISE;
}
method = can_fixed ? PL_DITHER_ORDERED_FIXED : PL_DITHER_WHITE_NOISE;
// fall through
done: ;
int size = 0;
......
......@@ -446,7 +446,7 @@ bool pl_shader_sample_polar(struct pl_shader *sh,
bool use_gather = sqrt(x*x + y*y) < obj->filter->radius_cutoff;
// Make sure all required features are supported
use_gather &= gpu->glsl.version >= 400;
use_gather &= sh_glsl_ver(sh) >= 400;
use_gather &= gpu->limits.max_gather_offset != 0;
use_gather &= PL_MAX(x, y) <= gpu->limits.max_gather_offset;
use_gather &= PL_MIN(x, y) >= gpu->limits.min_gather_offset;
......
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