[waffle] [GSOC2014] Current design/implementation + the infamous corruption

Emil Velikov emil.l.velikov at gmail.com
Wed Jun 4 19:19:40 PDT 2014


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


More information about the waffle mailing list