diff options
author | Karol Herbst <[email protected]> | 2018-07-13 03:33:22 +0200 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2018-07-13 15:46:57 +0200 |
commit | cb65246ed2ac826285b6d6cc6e1994ff1299e531 (patch) | |
tree | 41b6f0180b5f5f41f7c96aed00e05f8917a3bdc3 /src/compiler/spirv | |
parent | 0288fe8d0417730bdd5b3477130dd1dc32bdbcd3 (diff) |
nir: cleanup oversized arrays in nir_swizzle calls
There are no fixed sized array arguments in C, those are simply pointers
to unsized arrays and as the size is passed in anyway, just rely on that.
where possible calls are replaced by nir_channel and nir_channels.
Reviewed-by: Jason Ekstrand <[email protected]>
Signed-off-by: Karol Herbst <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 3 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_glsl450.c | 10 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 235003e872a..48154303ff2 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2858,8 +2858,7 @@ vtn_ssa_transpose(struct vtn_builder *b, struct vtn_ssa_value *src) nir_ssa_def * vtn_vector_extract(struct vtn_builder *b, nir_ssa_def *src, unsigned index) { - unsigned swiz[4] = { index }; - return nir_swizzle(&b->nb, src, swiz, 1, false); + return nir_channel(&b->nb, src, index); } nir_ssa_def * diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c index 8393450f2f4..9ef066e8e6d 100644 --- a/src/compiler/spirv/vtn_glsl450.c +++ b/src/compiler/spirv/vtn_glsl450.c @@ -36,7 +36,7 @@ static nir_ssa_def * build_mat2_det(nir_builder *b, nir_ssa_def *col[2]) { - unsigned swiz[4] = {1, 0, 0, 0}; + unsigned swiz[2] = {1, 0 }; nir_ssa_def *p = nir_fmul(b, col[0], nir_swizzle(b, col[1], swiz, 2, true)); return nir_fsub(b, nir_channel(b, p, 0), nir_channel(b, p, 1)); } @@ -44,8 +44,8 @@ build_mat2_det(nir_builder *b, nir_ssa_def *col[2]) static nir_ssa_def * build_mat3_det(nir_builder *b, nir_ssa_def *col[3]) { - unsigned yzx[4] = {1, 2, 0, 0}; - unsigned zxy[4] = {2, 0, 1, 0}; + unsigned yzx[3] = {1, 2, 0 }; + unsigned zxy[3] = {2, 0, 1 }; nir_ssa_def *prod0 = nir_fmul(b, col[0], @@ -602,8 +602,8 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, return; case GLSLstd450Cross: { - unsigned yzx[4] = { 1, 2, 0, 0 }; - unsigned zxy[4] = { 2, 0, 1, 0 }; + unsigned yzx[3] = { 1, 2, 0 }; + unsigned zxy[3] = { 2, 0, 1 }; 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)), |