From 6a0fa2d758bc67041f2b66c3b7520a0ca041817e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 28 Dec 2015 23:39:14 -0800 Subject: [PATCH] nir/spirv/glsl450: Implement Cross built-in. --- src/glsl/nir/spirv/vtn_glsl450.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/glsl/nir/spirv/vtn_glsl450.c b/src/glsl/nir/spirv/vtn_glsl450.c index 2d5faa7d574..cec7592a5e8 100644 --- a/src/glsl/nir/spirv/vtn_glsl450.c +++ b/src/glsl/nir/spirv/vtn_glsl450.c @@ -165,6 +165,17 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, val->ssa->def = nir_imin(nb, nir_imax(nb, src[0], src[1]), src[2]); return; + case GLSLstd450Cross: { + unsigned yzx[4] = { 1, 2, 0, 0 }; + unsigned zxy[4] = { 2, 0, 1, 0 }; + val->ssa->def = + nir_fsub(nb, nir_fmul(nb, nir_swizzle(nb, src[0], yzx, 3, true), + nir_swizzle(nb, src[1], zxy, 3, true)), + nir_fmul(nb, nir_swizzle(nb, src[0], zxy, 3, true), + nir_swizzle(nb, src[1], yzx, 3, true))); + return; + } + case GLSLstd450Asin: case GLSLstd450Acos: case GLSLstd450Atan: @@ -179,7 +190,6 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, case GLSLstd450Frexp: case GLSLstd450PackDouble2x32: case GLSLstd450UnpackDouble2x32: - case GLSLstd450Cross: case GLSLstd450FaceForward: case GLSLstd450Reflect: case GLSLstd450Refract: -- 2.30.2