void
st_update_single_texture(struct st_context *st,
struct pipe_sampler_view **sampler_view,
- GLuint texUnit, unsigned glsl_version)
+ GLuint texUnit, bool glsl130_or_later)
{
struct gl_context *ctx = st->ctx;
const struct gl_sampler_object *samp;
/* Check a few pieces of state outside the texture object to see if we
* need to force revalidation.
*/
- if (stObj->prev_glsl_version != glsl_version ||
+ if (stObj->prev_glsl130_or_later != glsl130_or_later ||
stObj->prev_sRGBDecode != samp->sRGBDecode) {
st_texture_release_all_sampler_views(st, stObj);
- stObj->prev_glsl_version = glsl_version;
+ stObj->prev_glsl130_or_later = glsl130_or_later;
stObj->prev_sRGBDecode = samp->sRGBDecode;
}
stObj->pt->screen->resource_changed(stObj->pt->screen, stObj->pt);
*sampler_view =
- st_get_texture_sampler_view_from_stobj(st, stObj, samp, glsl_version);
+ st_get_texture_sampler_view_from_stobj(st, stObj, samp,
+ glsl130_or_later);
}
unsigned num_textures = 0;
+ /* prog->sh.data is NULL if it's ARB_fragment_program */
+ bool glsl130 = (prog->sh.data ? prog->sh.data->Version : 0) >= 130;
+
/* loop over sampler units (aka tex image units) */
for (unit = 0; samplers_used || unit < old_max;
unit++, samplers_used >>= 1) {
struct pipe_sampler_view *sampler_view = NULL;
if (samplers_used & 1) {
- /* prog->sh.data is NULL if it's ARB_fragment_program */
- unsigned glsl_version = prog->sh.data ? prog->sh.data->Version : 0;
const GLuint texUnit = prog->SamplerUnits[unit];
- st_update_single_texture(st, &sampler_view, texUnit, glsl_version);
+ st_update_single_texture(st, &sampler_view, texUnit, glsl130);
num_textures = unit + 1;
}
static unsigned
compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
enum pipe_format actualFormat,
- unsigned glsl_version)
+ bool glsl130_or_later)
{
switch (baseFormat) {
case GL_RGBA:
* BTW, it's required that sampler views are updated when
* shaders change (check_sampler_swizzle takes care of that).
*/
- if (glsl_version && glsl_version >= 130)
+ if (glsl130_or_later)
return SWIZZLE_XXXX;
else
return MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO,
static unsigned
get_texture_format_swizzle(const struct st_context *st,
const struct st_texture_object *stObj,
- unsigned glsl_version)
+ bool glsl130_or_later)
{
GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
unsigned tex_swizzle;
tex_swizzle = compute_texture_format_swizzle(baseFormat,
depth_mode,
stObj->pt->format,
- glsl_version);
+ glsl130_or_later);
/* Combine the texture format swizzle with user's swizzle */
return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle);
MAYBE_UNUSED static boolean
check_sampler_swizzle(const struct st_context *st,
const struct st_texture_object *stObj,
- const struct pipe_sampler_view *sv, unsigned glsl_version)
+ const struct pipe_sampler_view *sv,
+ bool glsl130_or_later)
{
- unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
(sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
st_create_texture_sampler_view_from_stobj(struct st_context *st,
struct st_texture_object *stObj,
enum pipe_format format,
- unsigned glsl_version)
+ bool glsl130_or_later)
{
struct pipe_sampler_view templ;
- unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
u_sampler_view_default_template(&templ, stObj->pt, format);
st_get_texture_sampler_view_from_stobj(struct st_context *st,
struct st_texture_object *stObj,
const struct gl_sampler_object *samp,
- unsigned glsl_version)
+ bool glsl130_or_later)
{
struct pipe_sampler_view **sv;
*/
MAYBE_UNUSED struct pipe_sampler_view *view = *sv;
assert(stObj->pt == view->texture);
- assert(!check_sampler_swizzle(st, stObj, view, glsl_version));
+ assert(!check_sampler_swizzle(st, stObj, view, glsl130_or_later));
assert(get_sampler_view_format(st, stObj, samp) == view->format);
assert(gl_target_to_pipe(stObj->base.Target) == view->target);
assert(stObj->base.MinLevel + stObj->base.BaseLevel ==
enum pipe_format format = get_sampler_view_format(st, stObj, samp);
*sv = st_create_texture_sampler_view_from_stobj(st, stObj,
- format, glsl_version);
+ format, glsl130_or_later);
}