Mesa (main): st/mesa: don't memset the sampler view array, don't init trailing slots to NULL
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jun 27 13:07:33 UTC 2021
Module: Mesa
Branch: main
Commit: 2ab21558d43ea155b3b3f9f9a1fd46e20787dc57
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ab21558d43ea155b3b3f9f9a1fd46e20787dc57
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sat Jun 5 22:35:09 2021 -0400
st/mesa: don't memset the sampler view array, don't init trailing slots to NULL
No functional change.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11428>
---
src/mesa/state_tracker/st_atom_texture.c | 82 +++++++++++++++----------------
src/mesa/state_tracker/st_cb_bitmap.c | 2 +-
src/mesa/state_tracker/st_cb_drawpixels.c | 2 +-
src/mesa/state_tracker/st_draw_feedback.c | 2 +-
4 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index f2667ffced3..8fda6ec2467 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -114,52 +114,52 @@ st_get_sampler_views(struct st_context *st,
if (samplers_used == 0x0 && old_max == 0)
return 0;
- unsigned num_textures = 0;
+ unsigned num_textures = util_last_bit(samplers_used);
/* 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, texel_fetch_samplers >>= 1) {
- struct pipe_sampler_view *sampler_view = NULL;
-
- if (samplers_used & 1) {
- const GLuint texUnit = prog->SamplerUnits[unit];
-
- /* The EXT_texture_sRGB_decode extension says:
- *
- * "The conversion of sRGB color space components to linear color
- * space is always performed if the texel lookup function is one
- * of the texelFetch builtin functions.
- *
- * Otherwise, if the texel lookup function is one of the texture
- * builtin functions or one of the texture gather functions, the
- * conversion of sRGB color space components to linear color space
- * is controlled by the TEXTURE_SRGB_DECODE_EXT parameter.
- *
- * If the TEXTURE_SRGB_DECODE_EXT parameter is DECODE_EXT, the
- * conversion of sRGB color space components to linear color space
- * is performed.
- *
- * If the TEXTURE_SRGB_DECODE_EXT parameter is SKIP_DECODE_EXT,
- * the value is returned without decoding. However, if the texture
- * is also [statically] accessed with a texelFetch function, then
- * the result of texture builtin functions and/or texture gather
- * functions may be returned with decoding or without decoding."
- *
- * Note: the "statically" will be added to the language per
- * https://cvs.khronos.org/bugzilla/show_bug.cgi?id=14934
- *
- * So we simply ignore the setting entirely for samplers that are
- * (statically) accessed with a texelFetch function.
- */
- st_update_single_texture(st, &sampler_view, texUnit, glsl130,
- texel_fetch_samplers & 1);
- num_textures = unit + 1;
+ for (unit = 0; unit < num_textures; unit++) {
+ unsigned bit = BITFIELD_BIT(unit);
+
+ if (!(samplers_used & bit)) {
+ sampler_views[unit] = NULL;
+ continue;
}
- pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view);
+ /* The EXT_texture_sRGB_decode extension says:
+ *
+ * "The conversion of sRGB color space components to linear color
+ * space is always performed if the texel lookup function is one
+ * of the texelFetch builtin functions.
+ *
+ * Otherwise, if the texel lookup function is one of the texture
+ * builtin functions or one of the texture gather functions, the
+ * conversion of sRGB color space components to linear color space
+ * is controlled by the TEXTURE_SRGB_DECODE_EXT parameter.
+ *
+ * If the TEXTURE_SRGB_DECODE_EXT parameter is DECODE_EXT, the
+ * conversion of sRGB color space components to linear color space
+ * is performed.
+ *
+ * If the TEXTURE_SRGB_DECODE_EXT parameter is SKIP_DECODE_EXT,
+ * the value is returned without decoding. However, if the texture
+ * is also [statically] accessed with a texelFetch function, then
+ * the result of texture builtin functions and/or texture gather
+ * functions may be returned with decoding or without decoding."
+ *
+ * Note: the "statically" will be added to the language per
+ * https://cvs.khronos.org/bugzilla/show_bug.cgi?id=14934
+ *
+ * So we simply ignore the setting entirely for samplers that are
+ * (statically) accessed with a texelFetch function.
+ */
+ struct pipe_sampler_view *sampler_view;
+ st_update_single_texture(st, &sampler_view, prog->SamplerUnits[unit],
+ glsl130, texel_fetch_samplers & bit);
+ sampler_views[unit] = NULL;
+ pipe_sampler_view_reference(&sampler_views[unit], sampler_view);
}
/* For any external samplers with multiplaner YUV, stuff the additional
@@ -279,8 +279,6 @@ update_textures(struct st_context *st, enum pipe_shader_type shader_stage,
unsigned old_num_textures = st->state.num_sampler_views[shader_stage];
unsigned num_unbind = old_num_textures > num_textures ?
old_num_textures - num_textures : 0;
- for (unsigned i = 0; i < num_unbind; i++)
- pipe_sampler_view_reference(&sampler_views[num_textures + i], NULL);
pipe->set_sampler_views(pipe, shader_stage, 0, num_textures, num_unbind,
sampler_views);
@@ -293,7 +291,7 @@ update_textures_local(struct st_context *st,
enum pipe_shader_type shader_stage,
const struct gl_program *prog)
{
- struct pipe_sampler_view *local_views[PIPE_MAX_SAMPLERS] = {0};
+ struct pipe_sampler_view *local_views[PIPE_MAX_SAMPLERS];
update_textures(st, shader_stage, prog, local_views);
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index b3f48ba2b91..db6065da85a 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -241,7 +241,7 @@ setup_render_state(struct gl_context *ctx,
/* user textures, plus the bitmap texture */
{
- struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS] = {};
+ struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
unsigned num_views =
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current, sampler_views);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 49478bf368d..4e400e0042f 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -873,7 +873,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* user textures, plus the drawpix textures */
if (fpv) {
/* drawing a color image */
- struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS] = {0};
+ struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
unsigned num_views =
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current, sampler_views);
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 06021842159..54e502e46af 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -311,7 +311,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
st->state.num_vert_samplers);
/* sampler views */
- struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS] = {0};
+ struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS];
unsigned num_views =
st_get_sampler_views(st, PIPE_SHADER_VERTEX, prog, views);
More information about the mesa-commit
mailing list