Re: [waffle] [GSOC2014] Current design/implementation + the infamous corruption
On Thu, Jun 05, 2014 at 05:49:04PM +0100, Emil Velikov wrote: On 05/06/14 03:19, Emil Velikov wrote: waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? There is no use case in piglit + waffle{examples/utils} where one would create multiple windows for a single config. I might just add a lovely assert and don't worry about this too much. Don't worry too much about getting mutliple windows to work. Last I checked, multiple window support was broken in the Android backend too. It's perfectly ok to aim for imperfect good-enough during Waffle's initial Windows support. ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [GSOC2014] Current design/implementation + the infamous corruption
On Fri, June 6, 2014 9:45 am, Chad Versace wrote: On Thu, Jun 05, 2014 at 05:49:04PM +0100, Emil Velikov wrote: On 05/06/14 03:19, Emil Velikov wrote: waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? There is no use case in piglit + waffle{examples/utils} where one would create multiple windows for a single config. I might just add a lovely assert and don't worry about this too much. Don't worry too much about getting mutliple windows to work. Last I checked, multiple window support was broken in the Android backend too. It's perfectly ok to aim for imperfect good-enough during Waffle's initial Windows support. When making Android version of Waffle on top of Ice Cream Sandwich I saw process becoming unstable when asking for second surface control object (read: window) within same process. The problem was on Android SurfaceFlinger side thus I decided just to ignore the problem of multiple windows. On Android Waffle does what is asked from it and if the process segfaults because of this I left it up to the programmer to figure how to behave on chosen OS. Though, asserting this might be good idea to highlight what went wrong. /Juha-Pekka ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [GSOC2014] Current design/implementation + the infamous corruption
- Original Message - On 05/06/14 03:19, Emil Velikov wrote: Hi all, Over the last few days I have been though some head-scratching and re-writing things, in order to resolve an interesting memory corruption to no avail :'( Before explaining more about the issue here is some info about the current design + where to get the patches. Let me know if you would like me to send them to the ML. Branch GSOC2014 over at https://urldefense.proofpoint.com/v1/url?u=https://github.com/evelikov/wafflek=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=a2j0YKhUfDCeKnrHMRWtbX2GGkBhvFdRuL%2BmYYiIN7g%3D%0As=653132e086e89788df300b121854441a78291782135936411a4a6254e6959c6a Archlinux users can use the pkgbuild script in pkg/archlinux/mingw-w64-waffle. Design by example - gl_sample.c (i.e. how to use waffle) waffle_init() waffle_display_connect() + RegisterClass()// Registers the window class used as a template // by Windows to create the window // Create a default/root window, config and context // as wglGetProcAddress needs to be executed under // current context. Missed case: waffle_get_proc_address() // if (wglGetCurrentContext() == NULL) { // using_display_context = true; // wglMakeCurrent(display-hdc, display-hglrc) // } // ok = wglGetProcAddress() // if (using_display_context == true) // wglMakeCurrent(NULL, NULL) // return ok; // Unbinding the current context may be an // overkill although will help with unintentional // misuse of waffle's API. // NOTE: Will need to change waffle's internals // in order to get access to wcore_display. // The API will need a change to include the // display waffle_get_proc_address(dpy, glHam) waffle_config_choose(dpy...) + CreateWindow() // Create a window and prepend it to the // wgl_display::windows list. Now that I look at it, I'm not entirely sure why I needed a list of all windows in wgl_display. Seems like I can drop that. + ChoosePixelFormat() + SetPixelFormat() // Set the pixelformat and link the current window // to the wgl_config waffle_context_create(config...) + CreateContext(hDC... ) // At this point we need access to the wgl_window, // as hWnd/hDC (window_handle/device_context handle) // is essential. // This is where wgl_config::window comes into play. waffle_window_create(config, w, h) + wgl_window_resize()// Reuse the window, adjusting it's dimensions, as // w, h used at creation time are include the window // border. AFAICK there is no way to determine the // correct window dimensions prior to creation. ... waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? There is no use case in piglit + waffle{examples/utils} where one would create multiple windows for a single config. I might just add a lovely assert and don't worry about this too much. With the above resolved I will take a look at handling gl profiles and alike. And now back to the memory corruption: Resolved, thanks to Jon Turney. The functions obtained by waffle_dl_sym() are part of the Windows API, which uses different calling convention (stdcall vs cdecl) which causes the heap corruption. Good catch. Annotating properly makes the gl_basic test work like a charm. That's great progres! AFAICS waffle_get_proc_address is in the same boat. Will need to test. Cheers, Emil Jose ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [GSOC2014] Current design/implementation + the infamous corruption
On 06/06/14 14:00, Jose Fonseca wrote: - Original Message - On 05/06/14 03:19, Emil Velikov wrote: Hi all, Over the last few days I have been though some head-scratching and re-writing things, in order to resolve an interesting memory corruption to no avail :'( Before explaining more about the issue here is some info about the current design + where to get the patches. Let me know if you would like me to send them to the ML. Branch GSOC2014 over at https://urldefense.proofpoint.com/v1/url?u=https://github.com/evelikov/wafflek=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=a2j0YKhUfDCeKnrHMRWtbX2GGkBhvFdRuL%2BmYYiIN7g%3D%0As=653132e086e89788df300b121854441a78291782135936411a4a6254e6959c6a Archlinux users can use the pkgbuild script in pkg/archlinux/mingw-w64-waffle. Design by example - gl_sample.c (i.e. how to use waffle) waffle_init() waffle_display_connect() + RegisterClass()// Registers the window class used as a template // by Windows to create the window // Create a default/root window, config and context // as wglGetProcAddress needs to be executed under // current context. Missed case: waffle_get_proc_address() // if (wglGetCurrentContext() == NULL) { // using_display_context = true; // wglMakeCurrent(display-hdc, display-hglrc) // } // ok = wglGetProcAddress() // if (using_display_context == true) // wglMakeCurrent(NULL, NULL) // return ok; // Unbinding the current context may be an // overkill although will help with unintentional // misuse of waffle's API. // NOTE: Will need to change waffle's internals // in order to get access to wcore_display. // The API will need a change to include the // display waffle_get_proc_address(dpy, glHam) waffle_config_choose(dpy...) + CreateWindow() // Create a window and prepend it to the // wgl_display::windows list. Now that I look at it, I'm not entirely sure why I needed a list of all windows in wgl_display. Seems like I can drop that. + ChoosePixelFormat() + SetPixelFormat() // Set the pixelformat and link the current window // to the wgl_config waffle_context_create(config...) + CreateContext(hDC... ) // At this point we need access to the wgl_window, // as hWnd/hDC (window_handle/device_context handle) // is essential. // This is where wgl_config::window comes into play. waffle_window_create(config, w, h) + wgl_window_resize()// Reuse the window, adjusting it's dimensions, as // w, h used at creation time are include the window // border. AFAICK there is no way to determine the // correct window dimensions prior to creation. ... waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? There is no use case in piglit + waffle{examples/utils} where one would create multiple windows for a single config. I might just add a lovely assert and don't worry about this too much. With the above resolved I will take a look at handling gl profiles and alike. And now back to the memory corruption: Resolved, thanks to Jon Turney. The functions obtained by waffle_dl_sym() are part of the Windows API, which uses different calling convention (stdcall vs cdecl) which causes the heap corruption. Good catch. The mess was so deep that I've managed to bring the whole Windows down on two occasions :) Annotating properly makes the gl_basic test work like a charm. That's great progres! Indeed I was over the moon when I saw the window contents flip through the different colors. Kind of stuck at the next step though :\ Jose, gents, Would you know how to convert redsize [1] to redBits/redShift [2] ? The former format is used by ChoosePixelFormat under glx, egl and cgl which do a lot of dancing at libGL/libEGL level, while windows delegates that to the caller and expects the latter format. I've been through mesa/src/glx and it's kind of making my head spin. I'm going to see if I can make more
Re: [waffle] [GSOC2014] Current design/implementation + the infamous corruption
On 05/06/14 03:19, Emil Velikov wrote: Hi all, Over the last few days I have been though some head-scratching and re-writing things, in order to resolve an interesting memory corruption to no avail :'( Before explaining more about the issue here is some info about the current design + where to get the patches. Let me know if you would like me to send them to the ML. Branch GSOC2014 over at https://github.com/evelikov/waffle Archlinux users can use the pkgbuild script in pkg/archlinux/mingw-w64-waffle. Design by example - gl_sample.c (i.e. how to use waffle) waffle_init() waffle_display_connect() + RegisterClass()// Registers the window class used as a template // by Windows to create the window // Create a default/root window, config and context // as wglGetProcAddress needs to be executed under // current context. Missed case: waffle_get_proc_address() // if (wglGetCurrentContext() == NULL) { // using_display_context = true; // wglMakeCurrent(display-hdc, display-hglrc) // } // ok = wglGetProcAddress() // if (using_display_context == true) // wglMakeCurrent(NULL, NULL) // return ok; // Unbinding the current context may be an // overkill although will help with unintentional // misuse of waffle's API. // NOTE: Will need to change waffle's internals // in order to get access to wcore_display. // The API will need a change to include the // display waffle_get_proc_address(dpy, glHam) waffle_config_choose(dpy...) + CreateWindow() // Create a window and prepend it to the // wgl_display::windows list. Now that I look at it, I'm not entirely sure why I needed a list of all windows in wgl_display. Seems like I can drop that. + ChoosePixelFormat() + SetPixelFormat() // Set the pixelformat and link the current window // to the wgl_config waffle_context_create(config...) + CreateContext(hDC... ) // At this point we need access to the wgl_window, // as hWnd/hDC (window_handle/device_context handle) // is essential. // This is where wgl_config::window comes into play. waffle_window_create(config, w, h) + wgl_window_resize()// Reuse the window, adjusting it's dimensions, as // w, h used at creation time are include the window // border. AFAICK there is no way to determine the // correct window dimensions prior to creation. ... waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? There is no use case in piglit + waffle{examples/utils} where one would create multiple windows for a single config. I might just add a lovely assert and don't worry about this too much. With the above resolved I will take a look at handling gl profiles and alike. And now back to the memory corruption: Resolved, thanks to Jon Turney. The functions obtained by waffle_dl_sym() are part of the Windows API, which uses different calling convention (stdcall vs cdecl) which causes the heap corruption. Annotating properly makes the gl_basic test work like a charm. AFAICS waffle_get_proc_address is in the same boat. Will need to test. Cheers, Emil ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [GSOC2014] Current design/implementation + the infamous corruption
Hi all, Over the last few days I have been though some head-scratching and re-writing things, in order to resolve an interesting memory corruption to no avail :'( Before explaining more about the issue here is some info about the current design + where to get the patches. Let me know if you would like me to send them to the ML. Branch GSOC2014 over at https://github.com/evelikov/waffle Archlinux users can use the pkgbuild script in pkg/archlinux/mingw-w64-waffle. Design by example - gl_sample.c (i.e. how to use waffle) waffle_init() waffle_display_connect() + RegisterClass()// Registers the window class used as a template // by Windows to create the window waffle_config_choose(dpy...) + CreateWindow() // Create a window and prepend it to the // wgl_display::windows list. + ChoosePixelFormat() + SetPixelFormat() // Set the pixelformat and link the current window // to the wgl_config waffle_context_create(config...) + CreateContext(hDC... ) // At this point we need access to the wgl_window, // as hWnd/hDC (window_handle/device_context handle) // is essential. // This is where wgl_config::window comes into play. waffle_window_create(config, w, h) + wgl_window_resize()// Reuse the window, adjusting it's dimensions, as // w, h used at creation time are include the window // border. AFAICK there is no way to determine the // correct window dimensions prior to creation. ... waffle_window_create(config, w, h) + waffle_window_resize() // Reuse the window... and boom. Any suggestions on // how to resolve this, or should we mandate that // this is not a valid usage of waffle ? And now back to the memory corruption: When compiling the branch and running the gl_example demo, the resize, colors and possibly other variables gets (async) modified whenever gl calls are executed. gl_basic.exe --platform=wgl --api=gl DEBUG: draw:395 resize 0 DEBUG: draw:397 resize 0 DEBUG: draw:407 resize 0 DEBUG: draw:419 resize 0 DEBUG: draw:421 colors 9e90048 size 307200 DEBUG: draw:429 colors 9e90048 glReadPixels returned unexpected result DEBUG: draw:436 resize 0 DEBUG: draw:444 resize 0 DEBUG: draw:450 resize 0 DEBUG: draw:454 resize 0 DEBUG: draw:456 resize 0 DEBUG: draw:397 resize 0 DEBUG: draw:407 resize 0 DEBUG: draw:411 resize 151 Interesting DEBUG: draw:413 resize 120 ... DEBUG: draw:419 resize 216 ... DEBUG: draw:421 colors 9e90048 size 57600 DEBUG: draw:429 colors 411859 ... glReadPixels returned unexpected result DEBUG: draw:436 resize 3 DEBUG: draw:450 resize 255 gl_basic: error: WAFFLE_NO_ERROR The values that resize is set to are obviously related to the rgba arguments of glClearColor. Omitting calls results in a seemingly ok execution. Any suggestions as to what I'm doing wrong and/or what may be causing this corruption are greatly appreciated. Many thanks Emil ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle