[Mesa-dev] [PATCH v3 4/5] i965: handle nir_intrinsic_image_size

Martin Peres martin.peres at linux.intel.com
Fri Aug 14 00:24:19 PDT 2015


On 14/08/15 08:35, Pohjolainen, Topi wrote:
> On Thu, Aug 13, 2015 at 08:00:43PM +0300, Martin Peres wrote:
>> v2, Review from Francisco Jerez:
>> - avoid the camelCase for the booleans
>> - init the booleans using the sampler type
>> - force the initialization of all the components of the output register
>>
>> Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
>> ---
>>   src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 48 ++++++++++++++++++++++++++++++++
>>   1 file changed, 48 insertions(+)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> index ce4153d..cc0a5a6 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> @@ -1406,6 +1406,54 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
>>         break;
>>      }
>>   
>> +   case nir_intrinsic_image_size: {
>> +      /* Get the referenced image variable and type. */
>> +      const nir_variable *var = instr->variables[0]->var;
>> +      const glsl_type *type = var->type->without_array();
>> +      const brw_reg_type base_type = get_image_base_type(type);
>> +
>> +      /* Get the size of the image. */
>> +      const fs_reg image = get_nir_image_deref(instr->variables[0]);
>> +      const fs_reg size = offset(image, bld, BRW_IMAGE_PARAM_SIZE_OFFSET);
>> +
>> +      /*
>> +       * For 1DArray image types, the array index is stored in the Z component.
> Just a few style nits from my part.
>
> Usually (and in the rest of the file being modified) multi-line comments do
> not have separate first line, instead:
>
>           /* For 1DArray image types, the array index is stored in the Z
>            * component.
>
>> +       * Fix this by swizzling the Z component to the Y component.
>> +       */
>> +      const bool is_1d_array_image =
>> +              (type->sampler_dimensionality == GLSL_SAMPLER_DIM_1D &&
>> +               type->sampler_array);
> Indentation here looks a little odd and you can drop the extra (). I would
> write this:
>
>           const bool is_1d_array_image =
>              type->sampler_dimensionality == GLSL_SAMPLER_DIM_1D &&
>              type->sampler_array;
>
> Same comments just below.

Thanks Topi, fixed everything.
>
>> +
>> +      /*
>> +       * For CubeMapArray images, we should count the number of cubes instead
>> +       * of the number of faces. Fix it by dividing the (Z component) by 6.
>> +       */
>> +      const bool is_cube_map_array_image =
>> +              (type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&
>> +               type->sampler_array);
>> +
>> +      /* Copy all the components. */
>> +      const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
>> +      for (int c = 0; c < info->dest_components; ++c) {
>> +         if (c > type->coordinate_components()) {
In addition to the changes you asked for, I added a (int) cast to c to 
avoid a warning here as type->coordinate_components() returns an int.
>> +             bld.MOV(offset(retype(dest, base_type), bld, c),
>> +                     fs_reg(1));
>> +         } else if (c == 1 && is_1d_array_image) {
>> +            bld.MOV(offset(retype(dest, base_type), bld, c),
>> +                    offset(size, bld, 2));
>> +         } else if (c == 2 && is_cube_map_array_image) {
>> +            bld.emit(SHADER_OPCODE_INT_QUOTIENT,
>> +                     offset(retype(dest, base_type), bld, c),
>> +                     offset(size, bld, c), fs_reg(6));
>> +         } else {
>> +            bld.MOV(offset(retype(dest, base_type), bld, c),
>> +                    offset(size, bld, c));
>> +         }
>> +       }
>> +
>> +      break;
>> +   }
>> +
>>      case nir_intrinsic_load_front_face:
>>         bld.MOV(retype(dest, BRW_REGISTER_TYPE_D),
>>                 *emit_frontfacing_interpolation());
>> -- 
>> 2.5.0
>>
>> _______________________________________________
>> 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