1 #ifndef HALIDE_HALIDERUNTIMEOPENGLCOMPUTE_H
2 #define HALIDE_HALIDERUNTIMEOPENGLCOMPUTE_H
3 
4 // Don't include HalideRuntime.h if the contents of it were already pasted into a generated header above this one
5 #ifndef HALIDE_HALIDERUNTIME_H
6 
7 #include "HalideRuntime.h"
8 
9 #endif
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /** \file
16  *  Routines specific to the Halide OpenGL Compute runtime.
17  */
18 
19 #define HALIDE_RUNTIME_OPENGLCOMPUTE
20 
21 extern const struct halide_device_interface_t *halide_openglcompute_device_interface();
22 
23 /** These are forward declared here to allow clients to override the
24  *  Halide Glsl runtime. Do not call them. */
25 // @{
26 
27 /** This function sets up OpenGL context, loads relevant GL functions, then
28  *  compiles src OpenGL compute shader into OpenGL program and stores it for future use.
29  */
30 extern int halide_openglcompute_initialize_kernels(void *user_context, void **state_ptr,
31                                                    const char *src, int size);
32 
33 /** This function triggers execution of OpenGL program built around compute shader.
34  *  Execution of the shader is parallelized into given number of blocks and threads.
35  *
36  *  This function doesn't wait for the completion of the shader, but it sets memory
37  *  barrier which forces successive retrieval of output data to wait until shader is done.
38  */
39 extern int halide_openglcompute_run(void *user_context,
40                                     void *state_ptr,
41                                     const char *entry_name,
42                                     int blocksX, int blocksY, int blocksZ,
43                                     int threadsX, int threadsY, int threadsZ,
44                                     int shared_mem_bytes,
45                                     struct halide_type_t arg_types[],
46                                     void *args[],
47                                     int8_t is_buffer[],
48                                     int num_attributes,
49                                     float *vertex_buffer,
50                                     int num_coords_dim0,
51                                     int num_coords_dim1);
52 // @}
53 
54 /** This function retrieves pointers to OpenGL API functions.
55  *
56  *  You may have to implement this yourself. Halide only provides implementations
57  *  for some platforms."
58  */
59 void *halide_opengl_get_proc_address(void *user_context, const char *name);
60 
61 /** This function creates an OpenGL context for use by the OpenGL backend.
62  *
63  *  You may have to implement this yourself as well. Halide only provides
64 *   implementations for some platforms."
65  */
66 int halide_opengl_create_context(void *user_context);
67 
68 #ifdef __cplusplus
69 }  // End extern "C"
70 #endif
71 
72 #endif  // HALIDE_HALIDERUNTIMEOPENGLCOMPUTE_H
73