[Mesa-dev] [PATCH 01/17] i965/fs: Use a switch statement in fs_inst::regs_read()

Iago Toral itoral at igalia.com
Fri Jun 19 02:00:40 PDT 2015


Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

On Thu, 2015-06-18 at 17:50 -0700, Jason Ekstrand wrote:
> This makes things a little simpler, more efficient, and quite a bit more
> readable.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 45 ++++++++++++++++++------------------
>  1 file changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 5563c5a..37b6d0d 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -744,28 +744,29 @@ fs_inst::is_partial_write() const
>  int
>  fs_inst::regs_read(int arg) const
>  {
> -   if (is_tex() && arg == 0 && src[0].file == GRF) {
> -      return mlen;
> -   } else if (opcode == FS_OPCODE_FB_WRITE && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_URB_WRITE_SIMD8 && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_UNTYPED_ATOMIC && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_UNTYPED_SURFACE_READ && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_UNTYPED_SURFACE_WRITE && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_TYPED_ATOMIC && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_TYPED_SURFACE_READ && arg == 0) {
> -      return mlen;
> -   } else if (opcode == SHADER_OPCODE_TYPED_SURFACE_WRITE && arg == 0) {
> -      return mlen;
> -   } else if (opcode == FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET && arg == 0) {
> -      return mlen;
> -   } else if (opcode == FS_OPCODE_LINTERP && arg == 0) {
> -      return exec_size / 4;
> +   switch (opcode) {
> +   case FS_OPCODE_FB_WRITE:
> +   case SHADER_OPCODE_URB_WRITE_SIMD8:
> +   case SHADER_OPCODE_UNTYPED_ATOMIC:
> +   case SHADER_OPCODE_UNTYPED_SURFACE_READ:
> +   case SHADER_OPCODE_UNTYPED_SURFACE_WRITE:
> +   case SHADER_OPCODE_TYPED_ATOMIC:
> +   case SHADER_OPCODE_TYPED_SURFACE_READ:
> +   case SHADER_OPCODE_TYPED_SURFACE_WRITE:
> +   case FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET:
> +      if (arg == 0)
> +         return mlen;
> +      break;
> +
> +   case FS_OPCODE_LINTERP:
> +      if (arg == 0)
> +         return exec_size / 4;
> +      break;
> +
> +   default:
> +      if (is_tex() && arg == 0 && src[0].file == GRF)
> +         return mlen;
> +      break;
>     }
>  
>     switch (src[arg].file) {




More information about the mesa-dev mailing list