From 652c7242fb47dfecf365c668c117dd984e2b40f2 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Sat, 28 Mar 2020 23:52:00 -0230 Subject: [PATCH] [rs] Avoid array indexing in hello-triangle --- wgpu/examples/hello-triangle/shader.vert | 9 ++------- wgpu/examples/hello-triangle/shader.vert.spv | Bin 904 -> 884 bytes 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/wgpu/examples/hello-triangle/shader.vert b/wgpu/examples/hello-triangle/shader.vert index ac6dcc7c32..2b9399e710 100644 --- a/wgpu/examples/hello-triangle/shader.vert +++ b/wgpu/examples/hello-triangle/shader.vert @@ -4,12 +4,7 @@ out gl_PerVertex { vec4 gl_Position; }; -const vec2 positions[3] = vec2[3]( - vec2(0.0, -0.5), - vec2(0.5, 0.5), - vec2(-0.5, 0.5) -); - void main() { - gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0); + vec2 position = vec2(gl_VertexIndex, (gl_VertexIndex & 1) * 2) - 1; + gl_Position = vec4(position, 0.0, 1.0); } diff --git a/wgpu/examples/hello-triangle/shader.vert.spv b/wgpu/examples/hello-triangle/shader.vert.spv index 9a3f5994b71471f4f282bdb2299e70ce2ebd9d62..ea22e0c6c8c517586dffef3e917584826c32602b 100644 GIT binary patch literal 884 zcmZ9JO-lk{6os$asAXwpYM(Y{Z3?7CMGzIOEO0Rqw2iM|PZI36t_TkY15k<>Hfy9)QiOdMk z5B&l9ys#l;^h@jgP@t!XzcHSeS@~XuOw?74{Ns?JXzbof*Gv6%^OKaOAgXD`X7K7M-D1hdx*`maiZQ&osB3vlfJ9&?qL=LSigW$EyNV%(iwZTN(%OXp7DEsk4}UKQ}2YXjzm zV;<@>1h^Z;Gp{eeAqm%%4wn)FWpSHr!58pxKYCuO2KU<$xH)&GCpPils&FFw0HeY$ Aw*UYD literal 904 zcmYk4OD}^_5QdLdTa;4wyN_alhy@}M8mp365Q(i++DH@Hgf1-oGl^eiBk?@nMV#i% z%)Il?oH^4kpR1KZ7zm{>6t+Whsv!pxLOB#;+qk~F-hb=2_79H^R8&Gf7OEMi(lZEN znw_rx2v`7lemU$H!UBr_ngYFt$UQwj+_Ycs+pqohJ0Wbs>znJnb^4uNm->9%SKeCt zlTQk-x-F{<{FdQ6hRw(4HvT1?_jt;Q2@QJ5Ia`CN>}75TOu@>p$I~a8S^Oeg1m@8D zVq@R4n)Z^5V1}`7$Nr~j>^|gXh`lEQtR(EF@hHB>-eXvMJA?WPHUb{?#^b<#%fu5{ zYvjyZTLqpho=n2eJ$9jX3aF9KG}HK;dZw8nkP{gUl{9v?Y@P@|gpa!UO+4Rg%`tCqH}2je{|!^XdY8TZ2GpJrJHsOI z{&UpkocV$Z?_C9QYScT!8j!z5<386@4)e!tq?~WM;WqE90k!7bZv?!@`L}@If&aC0 L7_0wbD<|L=@_;WL