[Mesa-dev] [PATCH 1/2] svga: use switch statement in svga_shader_type()

Marek Olšák maraeo at gmail.com
Fri Jun 28 07:42:17 PDT 2013


The renumbering only makes sense for the GLSL linker and the only
reason for doing that in gallium too is that PIPE_SHADER_x must be
equal to MESA_SHADER_x.

Marek

On Fri, Jun 28, 2013 at 4:32 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
>
>
> ----- Original Message -----
>> Safer in case the PIPE_SHADER_x tokens get renumbered (as Marek
>> wanted to do).
>
> Renumbering PIPE_SHADER_x seems a pure time waster -- there is much more code that expects the current order -- and I see no benefit.
>
> This patch looks good nevertheles.
>> ---
>>  src/gallium/drivers/svga/svga_state_constants.c |   15 ++++++++++-----
>>  1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/gallium/drivers/svga/svga_state_constants.c
>> b/src/gallium/drivers/svga/svga_state_constants.c
>> index 77c9349..1c0edb4 100644
>> --- a/src/gallium/drivers/svga/svga_state_constants.c
>> +++ b/src/gallium/drivers/svga/svga_state_constants.c
>> @@ -46,13 +46,18 @@
>>  /**
>>   * Convert from PIPE_SHADER_* to SVGA3D_SHADERTYPE_*
>>   */
>> -static int
>> +static unsigned
>>  svga_shader_type(unsigned shader)
>>  {
>> -   assert(PIPE_SHADER_VERTEX + 1 == SVGA3D_SHADERTYPE_VS);
>> -   assert(PIPE_SHADER_FRAGMENT + 1 == SVGA3D_SHADERTYPE_PS);
>> -   assert(shader <= PIPE_SHADER_FRAGMENT);
>> -   return shader + 1;
>> +   switch (shader) {
>> +   case PIPE_SHADER_VERTEX:
>> +      return SVGA3D_SHADERTYPE_VS;
>> +   case PIPE_SHADER_FRAGMENT:
>> +      return SVGA3D_SHADERTYPE_PS;
>> +   default:
>> +      assert(!"Unexpected shader type");
>> +      return SVGA3D_SHADERTYPE_VS;
>> +   }
>>  }
>>
>>
>> --
>> 1.7.10.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>


More information about the mesa-dev mailing list