[Mesa-dev] [PATCH 01/20] mesa: In emit_texenv() type mismatch was forced with typecast
Ian Romanick
idr at freedesktop.org
Wed May 14 12:17:10 PDT 2014
On 05/14/2014 10:55 AM, Juha-Pekka Heikkila wrote:
> Type mismatch caused random memory to be copied when casted
> memory area was smaller than expected type.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> src/mesa/main/ff_fragment_shader.cpp | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
> index 8c36097..2115837 100644
> --- a/src/mesa/main/ff_fragment_shader.cpp
> +++ b/src/mesa/main/ff_fragment_shader.cpp
> @@ -877,14 +877,15 @@ emit_texenv(texenv_fragment_program *p, GLuint unit)
> shift = new(p->mem_ctx) ir_constant((float)(1 << rgb_shift));
> }
> else {
> - float const_data[4] = {
> - float(1 << rgb_shift),
> - float(1 << rgb_shift),
> - float(1 << rgb_shift),
> - float(1 << alpha_shift)
> - };
> - shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
> - (ir_constant_data *)const_data);
> + ir_constant_data const_data;
> +
> + const_data.f[0] = float(1 << rgb_shift);
> + const_data.f[1] = float(1 << rgb_shift);
> + const_data.f[2] = float(1 << rgb_shift);
> + const_data.f[3] = float(1 << alpha_shift);
> +
> + shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
> + &const_data);
After this change, does Valgrind complain about (later) reads of
uninitialized memory? I think we might want to toss an extra memset in
there just to make Valgrind quiet too. If Valgrind is already quiet,
this patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
as-is.
> }
>
> return saturate(mul(deref, shift));
More information about the mesa-dev
mailing list