From fc0de0aa30abc5f8f9ec1ed3d9a5dfd12ab4bd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 30 Sep 2019 22:39:56 +0200 Subject: [PATCH] increase worksize again and print debug outputs --- src/main.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index 88ea71d..569ba4c 100644 --- a/src/main.c +++ b/src/main.c @@ -6,28 +6,30 @@ #include #include #include - +#include static const char * const vertex_shader = "#version 330 core\n \ layout (location = 0) in vec3 aPos;\n \ layout (location = 1) in vec2 aTexCoord;\n\ - out vec2 texCoord;\n \ + out vec2 texCoord;\n\ + out vec3 vertPos;\n \ void main()\n \ {\n \ gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n \ texCoord = aTexCoord;\n\ + vertPos = aPos;\n\ }\n"; static const char * const orange_framgment_shader = " \ #version 330 core\n \ out vec4 FragColor;\n \ - in vec4 vertexColor;\n \ + in vec3 vertPos;\n \ in vec2 texCoord;\n \ uniform sampler2D ourTexture;\n \ \n \ void main()\n \ {\n \ - FragColor = texture(ourTexture, texCoord);\n \ + FragColor = texture(ourTexture, texCoord); //+ vec4(vertPos.x, -vertPos.x, vertPos.y, 0.0);\n \ }"; struct canvas_buffer { @@ -147,7 +149,7 @@ static int calculate_mandelbrot(struct canvas_buffer *buff) char *source_code = NULL; char temp_buff[100]; size_t data_size; - size_t work_size = 10; + size_t work_size = 64; data_size = buff->width*buff->height; @@ -377,8 +379,8 @@ int main(int argc, char **argv) GtkGLArea *gl_area; GtkWindow *window; GtkBuilder *builder; - GtkWidget *temp; static struct canvas_buffer mandelbrot_buff; + clock_t start, end; gtk_init(&argc, &argv); @@ -388,17 +390,20 @@ int main(int argc, char **argv) g_signal_connect(window, "delete-event", G_CALLBACK(on_main_window_close), NULL); - mandelbrot_buff.x_span = 0.075;//2.8; mandelbrot_buff.y_span = 0.075;//2.25; mandelbrot_buff.center_x = -0.6; mandelbrot_buff.center_y = 0.45; - mandelbrot_buff.width = 3000; - mandelbrot_buff.height = 3000; - mandelbrot_buff.iterations = 200; + mandelbrot_buff.width = 2000; + mandelbrot_buff.height = 2000; + mandelbrot_buff.iterations = 400; mandelbrot_buff.mandelbrot_buffer = NULL; - calculate_mandelbrot(&mandelbrot_buff); + printf("Compile and run Mandelbrot on OpenCL HW\n"); + start = clock(); + calculate_mandelbrot(&mandelbrot_buff); + end = clock(); + printf("Calculation finished. Time needed: %lf ms\n", ((double) (end - start)) / CLOCKS_PER_SEC * 1000.0); gl_area = GTK_GL_AREA(gtk_gl_area_new()); @@ -415,6 +420,7 @@ int main(int argc, char **argv) gtk_gl_area_make_current(gl_area); + printf("Gui will be displayed\n"); gtk_main();