Browse Source

vtn/opencl: add clz support

This is needed for OpenCL

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
master
Dave Airlie 6 years ago
parent
commit
7325f6ac98
2 changed files with 10 additions and 0 deletions
  1. 8
    0
      src/compiler/nir/nir_builtin_builder.h
  2. 2
    0
      src/compiler/spirv/vtn_opencl.c

+ 8
- 0
src/compiler/nir/nir_builtin_builder.h View File

return nir_bcsel(b, nir_ieq(b, s, nir_imm_intN_t(b, 0, s->bit_size)), x, y); return nir_bcsel(b, nir_ieq(b, s, nir_imm_intN_t(b, 0, s->bit_size)), x, y);
} }


static inline nir_ssa_def *
nir_clz_u(nir_builder *b, nir_ssa_def *a)
{
nir_ssa_def *val;
val = nir_isub(b, nir_imm_intN_t(b, a->bit_size - 1, 32), nir_ufind_msb(b, a));
return nir_u2u(b, val, a->bit_size);
}

#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

+ 2
- 0
src/compiler/spirv/vtn_opencl.c View File

return nir_rotate(nb, srcs[0], srcs[1]); return nir_rotate(nb, srcs[0], srcs[1]);
case OpenCLstd_Smoothstep: case OpenCLstd_Smoothstep:
return nir_smoothstep(nb, srcs[0], srcs[1], srcs[2]); return nir_smoothstep(nb, srcs[0], srcs[1], srcs[2]);
case OpenCLstd_Clz:
return nir_clz_u(nb, srcs[0]);
case OpenCLstd_Select: case OpenCLstd_Select:
return nir_select(nb, srcs[0], srcs[1], srcs[2]); return nir_select(nb, srcs[0], srcs[1], srcs[2]);
case OpenCLstd_Step: case OpenCLstd_Step:

Loading…
Cancel
Save