On Sat, Mar 9, 2013 at 12:30 PM, Jose Fonseca <jfons...@vmware.com> wrote:
> Looks a sensible thing to do.
>
> Reviewed-by: Jose Fonseca <jfons...@vmware.com>
>

Thanks for the review.

> Any insight how the caller can be fixed so that this doesn't happen?

It happens to me when draw stages add more samplers on top of the max
samplers from the application.

Stéphane


>
> Jose
>
> ----- Original Message -----
>> With the current code, the sampler count can become higher than
>> PIPE_MAX_SAMPLERS and once it gets to the driver this can lead to
>> miscellaneous crashes and memory corruptions.
>>
>> Although this is taken care of in debug mode with an assert,
>> there is still a way to cause a crash/overflow in release mode.
>>
>> So instead, we bound the number of samplers in the state tracker.
>> ---
>>  src/mesa/state_tracker/st_atom_texture.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/src/mesa/state_tracker/st_atom_texture.c
>> b/src/mesa/state_tracker/st_atom_texture.c
>> index fc2d690..bcd5856 100644
>> --- a/src/mesa/state_tracker/st_atom_texture.c
>> +++ b/src/mesa/state_tracker/st_atom_texture.c
>> @@ -311,6 +311,7 @@ update_textures(struct st_context *st,
>>      */
>>     new_count = MAX2(*num_textures, old_max);
>>     assert(new_count <= max_units);
>> +   new_count = MIN2(new_count, max_units);
>>
>>     cso_set_sampler_views(st->cso_context,
>>                           shader_stage,
>> --
>> 1.8.1.3
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to