Пример #1
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     if index < 5:
         val = f32(index - 3) and 99.0
     else:
         val = f32(index - 6) and 99.0
     data2[index] = val
Пример #2
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     a = 4
     b = 5
     if index == 1:
         data2[index] = f32(a == 4 and b == 5)
     elif index == 2:
         data2[index] = f32(a == 1 and b == 5)
     elif index == 3:
         data2[index] = f32(a == 4 and b == 1)
     elif index == 4:
         data2[index] = f32(a == 4 or b == 1)
     elif index == 5:
         data2[index] = f32(a == 1 or b == 5)
     elif index == 6:
         data2[index] = f32(a == 1 or b == 1)
     if index == 7:
         data2[index] = f32(a == 1 or a == 4 or a == 5)
     if index == 8:
         data2[index] = f32(a == 1 and a == 4 and b == 5)
     if index == 9:
         data2[index] = f32(a == 1 or a == 4 and b == 5)
Пример #3
0
 def compute_shader(
         index: ("input", "GlobalInvocationId", ivec3),
         data1: ("buffer", 0, Array(f32)),
         data2: ("buffer", 1, Array(f32)),
 ):
     i = index.x
     data2[i] = f32(data1[i])
Пример #4
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, Array(f32)),
 ):
     ed2pl = [[0, 4], [0, 3], [0, 5], [0, 2], [1, 5], [1, 3], [1, 4],
              [1, 2]]
     intersect_flag = [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]
     i = 1
     plane_index = ed2pl[i][0]
     vertices = [i, 0, 0, 0, 0, 0]
     i_start = i
     i_last = i
     max_iter = 6
     for iter in range(1, max_iter):
         for i in range(12):
             if i != i_last and intersect_flag[i] == 1:
                 if ed2pl[i][0] == plane_index:
                     vertices[iter] = i
                     plane_index = ed2pl[i][1]
                     i_last = i
                     break
                 elif ed2pl[i][1] == plane_index:
                     vertices[iter] = i
                     plane_index = ed2pl[i][0]
                     i_last = i
                     break
         if i_last == i_start:
             max_iter = iter
             break
     index = index_xyz.x
     data2[index] = f32(vertices[index])
Пример #5
0
 def fragment_shader(
         tex: ("texture", 0, "2d r32f"),
         sampler: ("sampler", 1, ""),
         tcoord: ("input", 0, vec2),
         out_color: ("output", 0, vec4),
 ):
     val = f32(tex.sample(sampler, tcoord).r)
     out_color = vec4(val / 255.0, val / 255.0, 0.0, 1.0)  # noqa
Пример #6
0
 def compute_shader(
         index: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, "Array(vec2)"),
 ):
     i = f32(index.x)
     a, b = 1.0, 2.0  # Cover Python storing this as a tuple const
     c, d = a + i, b + 1.0
     data2[index.x] = vec2(c, d)
Пример #7
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     val = 0.0
     while val < f32(index):
         val = val + 2.0
     data2[index] = val
Пример #8
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data1: ("buffer", 0, Array(f32)),
         data2: ("buffer", 1, Array(i32)),
         data3: ("buffer", 2, Array(vec2)),
 ):
     index = index_xyz.x
     v1 = abs(data1[index])  # float
     v2 = abs(data2[index])  # int
     data3[index] = vec2(f32(v1), v2)
Пример #9
0
 def compute_shader(
         index_xyz=("input", "GlobalInvocationId", ivec3),
         data2=("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     index = index_xyz.x
     if index < 2:
         a = 3 + 4
         b = a + 5
         c = a + b + 6
         d = a + b + c + 7
         e = a + b + c + d + 8 - 3  # 100
         data2[index] = f32(e - 60)
     elif index < 4:
         a = 3 + 4
         b = a + 5
         c = a + b + 6
         d = a + b + c + 7
         e = a + b + c + d + 8 - 3  # 100
         data2[index] = f32(e - 59)
     elif index < 8:
         a = 3 + 4
         b = a + 5
         c = a + b + 6
         d = a + b + c + 7
         e = a + b + c + d + 8 - 3  # 100
         data2[index] = f32(e - 58)
     else:
         a = 3 + 4
         b = a + 5
         c = a + b + 6
         d = a + b + c + 7
         e = a + b + c + d + 8 - 3  # 100
         data2[index] = f32(e - 57)
     # This loop has not effect on the output, but it does touch on
     # compiler code. In particular code related to control flow in
     # the situation where the byte addresses are larger than 255
     # so that EXTENDED_ARG instructions are used.
     for i in range(12):
         if i > index:
             break
Пример #10
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data2: ("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     val = 0.0
     while True:
         if val == 999.0:
             continue
         if val >= f32(index):
             break
         i = 0
         while True:
             i = i + 1
             if i == 999:
                 continue
             if i > 3:
                 break
             val = val + 1.0
     data2[index] = val
Пример #11
0
 def compute_shader(
         index_xyz: ("input", "GlobalInvocationId", ivec3),
         data1: ("buffer", 0, Array(f32)),
         data2: ("buffer", 1, Array(f32)),
 ):
     index = index_xyz.x
     a = f32(index)
     if index < 2:
         a = 100.0
     elif index < 8:
         a = a + 10.0
         if index < 6:
             a = a + 1.0
         else:
             a = a + 2.0
     else:
         a = 200.0
         if index < 9:
             a = a + 1.0
     data2[index] = a