[Mesa-dev] [RFC PATCH 26/26] glsl: fix up an assertion in glsl_type::sampler_index()

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Apr 12 10:53:24 UTC 2017



On 04/12/2017 03:27 AM, Timothy Arceri wrote:
> 
> 
> On 12/04/17 02:48, Samuel Pitoiset wrote:
>> Used by glsl_to_tgsi.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>>  src/compiler/glsl_types.cpp | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
>> index cf0fe71d1a..6854169646 100644
>> --- a/src/compiler/glsl_types.cpp
>> +++ b/src/compiler/glsl_types.cpp
>> @@ -315,7 +315,8 @@ glsl_type::sampler_index() const
>>  {
>>     const glsl_type *const t = (this->is_array()) ? this->fields.array 
>> : this;
>>
>> -   assert(t->is_sampler() || t->is_image());
>> +   assert(t->base_type >= GLSL_TYPE_BINDLESS_SAMPLER &&
>> +          t->base_type <= GLSL_TYPE_IMAGE);
> 
> I'd rather just see all 4 types explicitly listed here. Since it's an 
> assert we don't care about efficiency, but we do care about correctness 
> and it would be easy for this code to silently break.

I'm not against changing this, but we use this "style" a lot in 
glsl_type. This was for consistency actually. Your call.

> 
>>
>>     switch (t->sampler_dimensionality) {
>>     case GLSL_SAMPLER_DIM_1D:
>>


More information about the mesa-dev mailing list