77
88import python_shader
99from python_shader import python2shader , f32 , vec2 , vec4 , i32
10- from python_shader import RES_INPUT , RES_OUTPUT
1110import wgpu .backends .rs # noqa
1211from pytest import skip , mark
1312from testutils import can_use_wgpu_lib , get_default_device
2019
2120@python2shader
2221def vertex_shader (
23- index : (RES_INPUT , "VertexId" , i32 ),
24- pos : (RES_OUTPUT , "Position" , vec4 ),
25- tcoord : (RES_OUTPUT , 0 , vec2 ),
22+ index : ("input" , "VertexId" , i32 ),
23+ pos : ("output" , "Position" , vec4 ),
24+ tcoord : ("output" , 0 , vec2 ),
2625):
2726 positions = [
2827 vec2 (- 0.5 , - 0.5 ),
@@ -46,8 +45,8 @@ def test_render_textured_square_rgba8unorm():
4645 def fragment_shader (
4746 tex : ("texture" , 0 , "2d f32" ),
4847 sampler : ("sampler" , 1 , "" ),
49- tcoord : (RES_INPUT , 0 , vec2 ),
50- out_color : (RES_OUTPUT , 0 , vec4 ),
48+ tcoord : ("input" , 0 , vec2 ),
49+ out_color : ("output" , 0 , vec4 ),
5150 ):
5251 out_color = tex .sample (sampler , tcoord ) # noqa
5352
@@ -70,8 +69,8 @@ def test_render_textured_square_rgba8uint():
7069 def fragment_shader (
7170 tex : ("texture" , 0 , "2d i32" ),
7271 sampler : ("sampler" , 1 , "" ),
73- tcoord : (RES_INPUT , 0 , vec2 ),
74- out_color : (RES_OUTPUT , 0 , vec4 ),
72+ tcoord : ("input" , 0 , vec2 ),
73+ out_color : ("output" , 0 , vec4 ),
7574 ):
7675 out_color = vec4 (tex .sample (sampler , tcoord )) / 255.0 # noqa
7776
@@ -94,8 +93,8 @@ def test_render_textured_square_rgba16sint():
9493 def fragment_shader (
9594 tex : ("texture" , 0 , "2d i32" ),
9695 sampler : ("sampler" , 1 , "" ),
97- tcoord : (RES_INPUT , 0 , vec2 ),
98- out_color : (RES_OUTPUT , 0 , vec4 ),
96+ tcoord : ("input" , 0 , vec2 ),
97+ out_color : ("output" , 0 , vec4 ),
9998 ):
10099 out_color = vec4 (tex .sample (sampler , tcoord )) / 255.0 # noqa
101100
@@ -118,8 +117,8 @@ def test_render_textured_square_rgba32float():
118117 def fragment_shader (
119118 tex : ("texture" , 0 , "2d f32" ),
120119 sampler : ("sampler" , 1 , "" ),
121- tcoord : (RES_INPUT , 0 , vec2 ),
122- out_color : (RES_OUTPUT , 0 , vec4 ),
120+ tcoord : ("input" , 0 , vec2 ),
121+ out_color : ("output" , 0 , vec4 ),
123122 ):
124123 out_color = tex .sample (sampler , tcoord ) / 255.0 # noqa
125124
@@ -146,8 +145,8 @@ def test_render_textured_square_rg8unorm():
146145 def fragment_shader (
147146 tex : ("texture" , 0 , "2d f32" ),
148147 sampler : ("sampler" , 1 , "" ),
149- tcoord : (RES_INPUT , 0 , vec2 ),
150- out_color : (RES_OUTPUT , 0 , vec4 ),
148+ tcoord : ("input" , 0 , vec2 ),
149+ out_color : ("output" , 0 , vec4 ),
151150 ):
152151 out_color = tex .sample (sampler , tcoord ) # noqa
153152
@@ -171,8 +170,8 @@ def test_render_textured_square_rg8uint():
171170 def fragment_shader (
172171 tex : ("texture" , 0 , "2d i32" ),
173172 sampler : ("sampler" , 1 , "" ),
174- tcoord : (RES_INPUT , 0 , vec2 ),
175- out_color : (RES_OUTPUT , 0 , vec4 ),
173+ tcoord : ("input" , 0 , vec2 ),
174+ out_color : ("output" , 0 , vec4 ),
176175 ):
177176 val = vec2 (tex .sample (sampler , tcoord ).rg )
178177 out_color = vec4 (val .rg / 255.0 , 0 , 1.0 ) # noqa
@@ -197,8 +196,8 @@ def test_render_textured_square_rg16sint():
197196 def fragment_shader (
198197 tex : ("texture" , 0 , "2d i32" ),
199198 sampler : ("sampler" , 1 , "" ),
200- tcoord : (RES_INPUT , 0 , vec2 ),
201- out_color : (RES_OUTPUT , 0 , vec4 ),
199+ tcoord : ("input" , 0 , vec2 ),
200+ out_color : ("output" , 0 , vec4 ),
202201 ):
203202 val = vec2 (tex .sample (sampler , tcoord ).rg )
204203 out_color = vec4 (val .rg / 255.0 , 0.0 , 1.0 ) # noqa
@@ -223,8 +222,8 @@ def test_render_textured_square_rg32float():
223222 def fragment_shader (
224223 tex : ("texture" , 0 , "2d f32" ),
225224 sampler : ("sampler" , 1 , "" ),
226- tcoord : (RES_INPUT , 0 , vec2 ),
227- out_color : (RES_OUTPUT , 0 , vec4 ),
225+ tcoord : ("input" , 0 , vec2 ),
226+ out_color : ("output" , 0 , vec4 ),
228227 ):
229228 val = tex .sample (sampler , tcoord ).rg
230229 out_color = vec4 (val .rg / 255.0 , 0.0 , 1.0 ) # noqa
@@ -251,8 +250,8 @@ def test_render_textured_square_r8unorm():
251250 def fragment_shader (
252251 tex : ("texture" , 0 , "2d f32" ),
253252 sampler : ("sampler" , 1 , "" ),
254- tcoord : (RES_INPUT , 0 , vec2 ),
255- out_color : (RES_OUTPUT , 0 , vec4 ),
253+ tcoord : ("input" , 0 , vec2 ),
254+ out_color : ("output" , 0 , vec4 ),
256255 ):
257256 val = tex .sample (sampler , tcoord ).r
258257 out_color = vec4 (val , val , 0.0 , 1.0 ) # noqa
@@ -276,8 +275,8 @@ def test_render_textured_square_r8uint():
276275 def fragment_shader (
277276 tex : ("texture" , 0 , "2d i32" ),
278277 sampler : ("sampler" , 1 , "" ),
279- tcoord : (RES_INPUT , 0 , vec2 ),
280- out_color : (RES_OUTPUT , 0 , vec4 ),
278+ tcoord : ("input" , 0 , vec2 ),
279+ out_color : ("output" , 0 , vec4 ),
281280 ):
282281 val = f32 (tex .sample (sampler , tcoord ).r )
283282 out_color = vec4 (val / 255.0 , val / 255.0 , 0.0 , 1.0 ) # noqa
@@ -304,8 +303,8 @@ def test_render_textured_square_r16sint():
304303 def fragment_shader (
305304 tex : ("texture" , 0 , "2d r16i" ),
306305 sampler : ("sampler" , 1 , "" ),
307- tcoord : (RES_INPUT , 0 , vec2 ),
308- out_color : (RES_OUTPUT , 0 , vec4 ),
306+ tcoord : ("input" , 0 , vec2 ),
307+ out_color : ("output" , 0 , vec4 ),
309308 ):
310309 val = f32 (tex .sample (sampler , tcoord ).r )
311310 out_color = vec4 (val / 255.0 , val / 255.0 , 0.0 , 1.0 ) # noqa
@@ -332,8 +331,8 @@ def test_render_textured_square_r32sint():
332331 def fragment_shader (
333332 tex : ("texture" , 0 , "2d r32i" ),
334333 sampler : ("sampler" , 1 , "" ),
335- tcoord : (RES_INPUT , 0 , vec2 ),
336- out_color : (RES_OUTPUT , 0 , vec4 ),
334+ tcoord : ("input" , 0 , vec2 ),
335+ out_color : ("output" , 0 , vec4 ),
337336 ):
338337 val = f32 (tex .sample (sampler , tcoord ).r )
339338 out_color = vec4 (val / 255.0 , val / 255.0 , 0.0 , 1.0 ) # noqa
@@ -359,8 +358,8 @@ def test_render_textured_square_r32float():
359358 def fragment_shader (
360359 tex : ("texture" , 0 , "2d r32f" ),
361360 sampler : ("sampler" , 1 , "" ),
362- tcoord : (RES_INPUT , 0 , vec2 ),
363- out_color : (RES_OUTPUT , 0 , vec4 ),
361+ tcoord : ("input" , 0 , vec2 ),
362+ out_color : ("output" , 0 , vec4 ),
364363 ):
365364 val = f32 (tex .sample (sampler , tcoord ).r )
366365 out_color = vec4 (val / 255.0 , val / 255.0 , 0.0 , 1.0 ) # noqa
0 commit comments