diff options
author | Marek Olšák <[email protected]> | 2017-06-12 01:15:59 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-22 01:51:02 +0200 |
commit | 25723857d95e40147e59e3fda5b5fba1b41ec5a4 (patch) | |
tree | 1418e83ece9b85835b2a9bc3efc50d23bafee937 | |
parent | 3ee1c9b1263adcf68ca7c376d29c94a0fc31b2b0 (diff) |
st/mesa: samplers only need to track whether GLSL >= 130
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 16 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_sampler_view.c | 23 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_sampler_view.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 4 |
5 files changed, 25 insertions, 22 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index b71b73506f8..cb6b4005fa6 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -58,7 +58,7 @@ 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; @@ -88,12 +88,12 @@ st_update_single_texture(struct st_context *st, /* 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; } @@ -102,7 +102,8 @@ st_update_single_texture(struct st_context *st, 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); } @@ -125,17 +126,18 @@ update_textures(struct st_context *st, 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; } diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c index e8a46a72244..7a6993e67c7 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -190,7 +190,7 @@ swizzle_swizzle(unsigned swizzle1, unsigned swizzle2) 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: @@ -257,7 +257,7 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode, * 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, @@ -279,7 +279,7 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode, 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; @@ -302,7 +302,7 @@ get_texture_format_swizzle(const struct st_context *st, 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); @@ -318,9 +318,10 @@ get_texture_format_swizzle(const struct st_context *st, 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)) || @@ -393,10 +394,10 @@ static struct pipe_sampler_view * 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); @@ -425,7 +426,7 @@ struct pipe_sampler_view * 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; @@ -441,7 +442,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, */ 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 == @@ -458,7 +459,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, 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); } diff --git a/src/mesa/state_tracker/st_sampler_view.h b/src/mesa/state_tracker/st_sampler_view.h index b08ca4a70f2..392206be4f7 100644 --- a/src/mesa/state_tracker/st_sampler_view.h +++ b/src/mesa/state_tracker/st_sampler_view.h @@ -73,7 +73,7 @@ struct pipe_sampler_view * 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 * st_get_buffer_sampler_view_from_stobj(struct st_context *st, diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 2b43cecc521..b409f286eb5 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -512,7 +512,7 @@ st_create_texture_handle_from_unit(struct st_context *st, struct pipe_sampler_view *view; struct pipe_sampler_state sampler = {0}; - st_update_single_texture(st, &view, texUnit, prog->sh.data->Version); + st_update_single_texture(st, &view, texUnit, prog->sh.data->Version >= 130); if (!view) return 0; diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index b9336544bb3..a6f6ee8ebef 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -121,7 +121,7 @@ struct st_texture_object uint layer_override; /** The glsl version of the shader seen during the previous validation */ - unsigned prev_glsl_version; + bool prev_glsl130_or_later; /** The value of the sampler's sRGBDecode state at the previous validation */ GLenum prev_sRGBDecode; @@ -291,7 +291,7 @@ st_convert_sampler_from_unit(const struct st_context *st, 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); void st_make_bound_samplers_resident(struct st_context *st, |