1
+ #include < stdint.h>
2
+
3
+ #define compute_shader __attribute__ ((annotate(" shady::entry_point::Compute" )))
4
+
5
+ #define location (i ) __attribute__((annotate(" shady::location::" #i)))
6
+
7
+ #define input __attribute__ ((address_space(389 )))
8
+ #define output __attribute__ ((address_space(390 )))
9
+ #define global __attribute__ ((address_space(1 )))
10
+
11
+ typedef uint32_t uvec4 __attribute__((ext_vector_type(4 )));
12
+ typedef float vec4 __attribute__ ((ext_vector_type(4 )));
13
+
14
+ typedef uint32_t uvec3 __attribute__ ((ext_vector_type(3 )));
15
+ typedef float vec3 __attribute__ ((ext_vector_type(3 )));
16
+
17
+ /* __attribute__((annotate("shady::builtin::FragCoord")))
18
+ input vec4 fragCoord;
19
+
20
+ location(0) input vec3 fragColor;
21
+ location(0) output vec4 outColor;*/
22
+
23
+ __attribute__ ((annotate(" shady::builtin::WorkgroupId" )))
24
+ input uvec3 workgroup_id;
25
+
26
+ __attribute__ ((annotate(" shady::builtin::GlobalInvocationId" )))
27
+ input uvec3 global_id;
28
+
29
+ float sqrtf (float ) __asm__(" shady::prim_op::sqrt" );
30
+ float sinf (float ) __asm__(" shady::prim_op::sin" );
31
+ float cosf (float ) __asm__(" shady::prim_op::cos" );
32
+ float fmodf (float , float ) __asm__(" shady::prim_op::mod" );
33
+ float fabsf (float ) __asm__(" shady::prim_op::abs" );
34
+ float floorf (float ) __asm__(" shady::prim_op::floor" );
35
+ #include " ao.c"
36
+
37
+ extern " C" __attribute__((annotate(" shady::workgroup_size::16::16::1" )))
38
+ compute_shader void aobench_kernel (global unsigned char * out) {
39
+ // outColor = (vec4) { fragColor[0], fragColor[1], fragColor[2], 1.0f };
40
+ // outColor = (vec4) { fragCoord[0] / 1024, fragCoord[1] / 1024, 1.0f, 1.0f };
41
+
42
+ Ctx ctx = get_init_context ();
43
+ init_scene (&ctx);
44
+
45
+ int x = global_id.x ;
46
+ int y = global_id.y ;
47
+ // int x = (int) fragCoord.x % 1024;
48
+ // int y = (int) fragCoord.y % 1024;
49
+
50
+ // unsigned int out[3]; // = { 55, 0, 0};
51
+ out[0 ] = 255 ;
52
+ out[1 ] = 255 ;
53
+ render_pixel (&ctx, x + 3 , y, WIDTH, HEIGHT, NSUBSAMPLES, (unsigned char *) out);
54
+ // out[2] = 155;
55
+ // out[0] = x / 4;
56
+ // out[1] = y / 4;
57
+ // outColor = (vec4) { ((int) out[0]) / 255.0f, ((int) out[1]) / 255.0f, ((int) out[2]) / 255.0f, 1.0f };
58
+ }
0 commit comments