summaryrefslogtreecommitdiff
path: root/lib/mesa/src
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:08:19 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:08:19 +0000
commitfe66a9951ba25a6038d9d3c1ad474f1d369a1731 (patch)
tree4b14edc880b1c268d9ffcb292d325c842b47a6d6 /lib/mesa/src
parentf1efffae355cb8c9669b5c2bdc9de661c9db1831 (diff)
Import Mesa 19.2.8
Diffstat (limited to 'lib/mesa/src')
-rw-r--r--lib/mesa/src/compiler/spirv/vtn_opencl.c105
1 files changed, 12 insertions, 93 deletions
diff --git a/lib/mesa/src/compiler/spirv/vtn_opencl.c b/lib/mesa/src/compiler/spirv/vtn_opencl.c
index 55980fd72..e26b5bc04 100644
--- a/lib/mesa/src/compiler/spirv/vtn_opencl.c
+++ b/lib/mesa/src/compiler/spirv/vtn_opencl.c
@@ -25,6 +25,7 @@
*/
#include "math.h"
+
#include "nir/nir_builtin_builder.h"
#include "vtn_private.h"
@@ -128,18 +129,6 @@ handle_special(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
return nir_uabs_diff(nb, srcs[0], srcs[1]);
case OpenCLstd_Bitselect:
return nir_bitselect(nb, srcs[0], srcs[1], srcs[2]);
- case OpenCLstd_SMad_hi:
- return nir_imad_hi(nb, srcs[0], srcs[1], srcs[2]);
- case OpenCLstd_UMad_hi:
- return nir_umad_hi(nb, srcs[0], srcs[1], srcs[2]);
- case OpenCLstd_SMul24:
- return nir_imul24(nb, srcs[0], srcs[1]);
- case OpenCLstd_UMul24:
- return nir_umul24(nb, srcs[0], srcs[1]);
- case OpenCLstd_SMad24:
- return nir_imad24(nb, srcs[0], srcs[1], srcs[2]);
- case OpenCLstd_UMad24:
- return nir_umad24(nb, srcs[0], srcs[1], srcs[2]);
case OpenCLstd_FClamp:
return nir_fclamp(nb, srcs[0], srcs[1], srcs[2]);
case OpenCLstd_SClamp:
@@ -184,8 +173,6 @@ handle_special(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
return nir_rotate(nb, srcs[0], srcs[1]);
case OpenCLstd_Smoothstep:
return nir_smoothstep(nb, srcs[0], srcs[1], srcs[2]);
- case OpenCLstd_Clz:
- return nir_clz_u(nb, srcs[0]);
case OpenCLstd_Select:
return nir_select(nb, srcs[0], srcs[1], srcs[2]);
case OpenCLstd_Step:
@@ -212,34 +199,25 @@ _handle_v_load_store(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
const struct glsl_type *dest_type = type->type;
unsigned components = glsl_get_vector_elements(dest_type);
+ unsigned stride = components * glsl_get_bit_size(dest_type) / 8;
nir_ssa_def *offset = vtn_ssa_value(b, w[5 + a])->def;
struct vtn_value *p = vtn_value(b, w[6 + a], vtn_value_type_pointer);
- struct vtn_ssa_value *comps[NIR_MAX_VEC_COMPONENTS];
- nir_ssa_def *ncomps[NIR_MAX_VEC_COMPONENTS];
-
- nir_ssa_def *moffset = nir_imul_imm(&b->nb, offset, components);
nir_deref_instr *deref = vtn_pointer_to_deref(b, p->pointer);
- for (int i = 0; i < components; i++) {
- nir_ssa_def *coffset = nir_iadd_imm(&b->nb, moffset, i);
- nir_deref_instr *arr_deref = nir_build_deref_ptr_as_array(&b->nb, deref, coffset);
+ /* 1. cast to vec type with adjusted stride */
+ deref = nir_build_deref_cast(&b->nb, &deref->dest.ssa, deref->mode,
+ dest_type, stride);
+ /* 2. deref ptr_as_array */
+ deref = nir_build_deref_ptr_as_array(&b->nb, deref, offset);
- if (load) {
- comps[i] = vtn_local_load(b, arr_deref, p->type->access);
- ncomps[i] = comps[i]->def;
- } else {
- struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, glsl_scalar_type(glsl_get_base_type(dest_type)));
- struct vtn_ssa_value *val = vtn_ssa_value(b, w[5]);
- ssa->def = vtn_vector_extract(b, val->def, i);
- vtn_local_store(b, ssa, arr_deref, p->type->access);
- }
- }
if (load) {
- struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, dest_type);
- ssa->def = nir_vec(&b->nb, ncomps, components);
- vtn_push_ssa(b, w[2], type, ssa);
+ struct vtn_ssa_value *val = vtn_local_load(b, deref, p->type->access);
+ vtn_push_ssa(b, w[2], type, val);
+ } else {
+ struct vtn_ssa_value *val = vtn_ssa_value(b, w[5]);
+ vtn_local_store(b, val, deref, p->type->access);
}
}
@@ -266,52 +244,6 @@ handle_printf(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
return nir_imm_int(&b->nb, -1);
}
-static nir_ssa_def *
-handle_shuffle(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode, unsigned num_srcs,
- nir_ssa_def **srcs, const struct glsl_type *dest_type)
-{
- struct nir_ssa_def *input = srcs[0];
- struct nir_ssa_def *mask = srcs[1];
-
- unsigned out_elems = glsl_get_vector_elements(dest_type);
- nir_ssa_def *outres[NIR_MAX_VEC_COMPONENTS];
- unsigned in_elems = input->num_components;
- if (mask->bit_size != 32)
- mask = nir_u2u32(&b->nb, mask);
- mask = nir_iand(&b->nb, mask, nir_imm_intN_t(&b->nb, in_elems - 1, mask->bit_size));
- for (unsigned i = 0; i < out_elems; i++)
- outres[i] = nir_vector_extract(&b->nb, input, nir_channel(&b->nb, mask, i));
-
- return nir_vec(&b->nb, outres, out_elems);
-}
-
-static nir_ssa_def *
-handle_shuffle2(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode, unsigned num_srcs,
- nir_ssa_def **srcs, const struct glsl_type *dest_type)
-{
- struct nir_ssa_def *input0 = srcs[0];
- struct nir_ssa_def *input1 = srcs[1];
- struct nir_ssa_def *mask = srcs[2];
-
- unsigned out_elems = glsl_get_vector_elements(dest_type);
- nir_ssa_def *outres[NIR_MAX_VEC_COMPONENTS];
- unsigned in_elems = input0->num_components;
- unsigned total_mask = 2 * in_elems - 1;
- unsigned half_mask = in_elems - 1;
- if (mask->bit_size != 32)
- mask = nir_u2u32(&b->nb, mask);
- mask = nir_iand(&b->nb, mask, nir_imm_intN_t(&b->nb, total_mask, mask->bit_size));
- for (unsigned i = 0; i < out_elems; i++) {
- nir_ssa_def *this_mask = nir_channel(&b->nb, mask, i);
- nir_ssa_def *vmask = nir_iand(&b->nb, this_mask, nir_imm_intN_t(&b->nb, half_mask, mask->bit_size));
- nir_ssa_def *val0 = nir_vector_extract(&b->nb, input0, vmask);
- nir_ssa_def *val1 = nir_vector_extract(&b->nb, input1, vmask);
- nir_ssa_def *sel = nir_ilt(&b->nb, this_mask, nir_imm_intN_t(&b->nb, in_elems, mask->bit_size));
- outres[i] = nir_bcsel(&b->nb, sel, val0, val1);
- }
- return nir_vec(&b->nb, outres, out_elems);
-}
-
bool
vtn_handle_opencl_instruction(struct vtn_builder *b, SpvOp ext_opcode,
const uint32_t *w, unsigned count)
@@ -356,12 +288,6 @@ vtn_handle_opencl_instruction(struct vtn_builder *b, SpvOp ext_opcode,
return true;
case OpenCLstd_SAbs_diff:
case OpenCLstd_UAbs_diff:
- case OpenCLstd_SMad_hi:
- case OpenCLstd_UMad_hi:
- case OpenCLstd_SMad24:
- case OpenCLstd_UMad24:
- case OpenCLstd_SMul24:
- case OpenCLstd_UMul24:
case OpenCLstd_Bitselect:
case OpenCLstd_FClamp:
case OpenCLstd_SClamp:
@@ -388,7 +314,6 @@ vtn_handle_opencl_instruction(struct vtn_builder *b, SpvOp ext_opcode,
case OpenCLstd_Smoothstep:
case OpenCLstd_S_Upsample:
case OpenCLstd_U_Upsample:
- case OpenCLstd_Clz:
handle_instr(b, ext_opcode, w, count, handle_special);
return true;
case OpenCLstd_Vloadn:
@@ -397,12 +322,6 @@ vtn_handle_opencl_instruction(struct vtn_builder *b, SpvOp ext_opcode,
case OpenCLstd_Vstoren:
vtn_handle_opencl_vstore(b, ext_opcode, w, count);
return true;
- case OpenCLstd_Shuffle:
- handle_instr(b, ext_opcode, w, count, handle_shuffle);
- return true;
- case OpenCLstd_Shuffle2:
- handle_instr(b, ext_opcode, w, count, handle_shuffle2);
- return true;
case OpenCLstd_Printf:
handle_instr(b, ext_opcode, w, count, handle_printf);
return true;