From f18a23d87c680faac7ba772e250e55e42256a136 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 24 May 2022 15:13:23 -0600 Subject: [PATCH] gallivm: clean-up in lp_bld_sample.c Signed-off-by: Brian Paul Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 97f97667988..118a21af45c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -98,26 +98,28 @@ void lp_sampler_static_texture_state(struct lp_static_texture_state *state, const struct pipe_sampler_view *view) { - const struct pipe_resource *texture; - memset(state, 0, sizeof *state); if (!view || !view->texture) return; - texture = view->texture; + const struct pipe_resource *texture = view->texture; - state->format = view->format; - state->swizzle_r = view->swizzle_r; - state->swizzle_g = view->swizzle_g; - state->swizzle_b = view->swizzle_b; - state->swizzle_a = view->swizzle_a; + state->format = view->format; + state->swizzle_r = view->swizzle_r; + state->swizzle_g = view->swizzle_g; + state->swizzle_b = view->swizzle_b; + state->swizzle_a = view->swizzle_a; + assert(state->swizzle_r < PIPE_SWIZZLE_NONE); + assert(state->swizzle_g < PIPE_SWIZZLE_NONE); + assert(state->swizzle_b < PIPE_SWIZZLE_NONE); + assert(state->swizzle_a < PIPE_SWIZZLE_NONE); - state->target = view->target; - state->pot_width = util_is_power_of_two_or_zero(texture->width0); - state->pot_height = util_is_power_of_two_or_zero(texture->height0); - state->pot_depth = util_is_power_of_two_or_zero(texture->depth0); - state->level_zero_only = !view->u.tex.last_level; + state->target = view->target; + state->pot_width = util_is_power_of_two_or_zero(texture->width0); + state->pot_height = util_is_power_of_two_or_zero(texture->height0); + state->pot_depth = util_is_power_of_two_or_zero(texture->depth0); + state->level_zero_only = !view->u.tex.last_level; /* * the layer / element / level parameters are all either dynamic @@ -134,26 +136,28 @@ void lp_sampler_static_texture_state_image(struct lp_static_texture_state *state, const struct pipe_image_view *view) { - const struct pipe_resource *resource; - memset(state, 0, sizeof *state); if (!view || !view->resource) return; - resource = view->resource; + const struct pipe_resource *resource = view->resource; - state->format = view->format; - state->swizzle_r = PIPE_SWIZZLE_X; - state->swizzle_g = PIPE_SWIZZLE_Y; - state->swizzle_b = PIPE_SWIZZLE_Z; - state->swizzle_a = PIPE_SWIZZLE_W; + state->format = view->format; + state->swizzle_r = PIPE_SWIZZLE_X; + state->swizzle_g = PIPE_SWIZZLE_Y; + state->swizzle_b = PIPE_SWIZZLE_Z; + state->swizzle_a = PIPE_SWIZZLE_W; + assert(state->swizzle_r < PIPE_SWIZZLE_NONE); + assert(state->swizzle_g < PIPE_SWIZZLE_NONE); + assert(state->swizzle_b < PIPE_SWIZZLE_NONE); + assert(state->swizzle_a < PIPE_SWIZZLE_NONE); - state->target = view->resource->target; - state->pot_width = util_is_power_of_two_or_zero(resource->width0); - state->pot_height = util_is_power_of_two_or_zero(resource->height0); - state->pot_depth = util_is_power_of_two_or_zero(resource->depth0); - state->level_zero_only = 0; + state->target = view->resource->target; + state->pot_width = util_is_power_of_two_or_zero(resource->width0); + state->pot_height = util_is_power_of_two_or_zero(resource->height0); + state->pot_depth = util_is_power_of_two_or_zero(resource->depth0); + state->level_zero_only = 0; /* * the layer / element / level parameters are all either dynamic