From c68f659be3850c5e099311be7c58f8930954631d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 15 Jul 2009 15:37:04 +0100 Subject: python/samples: Use PIPE_FORMAT_Z16_UNORM instead of PIPE_FORMAT_Z32_UNORM. More common. True fix would be to use whatever the screen supports though. --- src/gallium/state_trackers/python/samples/tri.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index 4b9659861d..b721e0b575 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -139,7 +139,7 @@ def test(dev): tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() zbuf = dev.texture_create( - PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z16_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL, ).get_surface() -- cgit v1.2.3 From 0474b5cb2ac4cefa12e7080aba397013325fb9a6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 15 Jul 2009 15:37:27 +0100 Subject: python/retrace: Interpret surface_copy. --- src/gallium/state_trackers/python/retrace/interpreter.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 5885e162c2..e018a6e96b 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -591,6 +591,10 @@ class Context(Object): self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) self._set_dirty() + def surface_copy(self, dest, destx, desty, src, srcx, srcy, width, height): + if dest is not None and src is not None: + self.real.surface_copy(dest, destx, desty, src, srcx, srcy, width, height) + def is_texture_referenced(self, texture, face, level): #return self.real.is_texture_referenced(format, texture, face, level) pass -- cgit v1.2.3 From 3ab3209a1f1af7bfd8e09598fbc3586f35169fb2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 16 Jul 2009 11:19:06 +0100 Subject: python: Obtain pipe_screen/pipe_context from the system's OpenGL driver. --- src/gallium/state_trackers/python/SConscript | 13 ++ .../state_trackers/python/st_hardpipe_winsys.c | 181 ++++++++++++++++++++- 2 files changed, 191 insertions(+), 3 deletions(-) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 1581182aec..ec385e7c44 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -15,6 +15,19 @@ if 'python' in env['statetrackers']: env.Append(CPPPATH = '.') + if env['platform'] == 'windows': + env.Append(LIBS = [ + 'opengl32', + 'gdi32', + 'user32', + 'kernel32', + ]) + else: + env.Append(LIBS = [ + 'GL', + 'X11', + ]) + pyst = env.ConvenienceLibrary( target = 'pyst', source = [ diff --git a/src/gallium/state_trackers/python/st_hardpipe_winsys.c b/src/gallium/state_trackers/python/st_hardpipe_winsys.c index 8b33c70fd7..43aaaabf2a 100644 --- a/src/gallium/state_trackers/python/st_hardpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_hardpipe_winsys.c @@ -28,31 +28,206 @@ /** * @file - * Stub for hardware pipe driver support. + * Get a hardware accelerated Gallium screen/context from the OpenGL driver. */ #include "pipe/p_compiler.h" +#ifdef PIPE_OS_WINDOWS +#include +#include +#else +#include +#include +#include +#include +#endif + #include "st_winsys.h" +typedef struct pipe_screen * (GLAPIENTRY *PFNGETGALLIUMSCREENMESAPROC) (void); +typedef struct pipe_context * (GLAPIENTRY* PFNCREATEGALLIUMCONTEXTMESAPROC) (void); + +static PFNGETGALLIUMSCREENMESAPROC pfnGetGalliumScreenMESA = NULL; +static PFNCREATEGALLIUMCONTEXTMESAPROC pfnCreateGalliumContextMESA = NULL; + + /* XXX: Force init_gallium symbol to be linked */ extern void init_gallium(void); void (*force_init_gallium_linkage)(void) = &init_gallium; +#ifdef PIPE_OS_WINDOWS + +static INLINE boolean +st_hardpipe_load(void) +{ + WNDCLASS wc; + HWND hwnd; + HGLRC hglrc; + HDC hdc; + PIXELFORMATDESCRIPTOR pfd; + int iPixelFormat; + + if(pfnGetGalliumScreenMESA && pfnCreateGalliumContextMESA) + return TRUE; + + memset(&wc, 0, sizeof wc); + wc.lpfnWndProc = DefWindowProc; + wc.lpszClassName = "gallium"; + wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + + hwnd = CreateWindow(wc.lpszClassName, "gallium", 0, 0, 0, 0, 0, NULL, 0, wc.hInstance, NULL); + if (!hwnd) + return FALSE; + + hdc = GetDC(hwnd); + if (!hdc) + return FALSE; + + pfd.cColorBits = 3; + pfd.cRedBits = 1; + pfd.cGreenBits = 1; + pfd.cBlueBits = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + pfd.iLayerType = PFD_MAIN_PLANE; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + + iPixelFormat = ChoosePixelFormat(hdc, &pfd); + if (!iPixelFormat) { + pfd.dwFlags |= PFD_DOUBLEBUFFER; + iPixelFormat = ChoosePixelFormat(hdc, &pfd); + } + if (!iPixelFormat) + return FALSE; + + SetPixelFormat(hdc, iPixelFormat, &pfd); + hglrc = wglCreateContext(hdc); + if (!hglrc) + return FALSE; + + if (!wglMakeCurrent(hdc, hglrc)) + return FALSE; + + pfnGetGalliumScreenMESA = (PFNGETGALLIUMSCREENMESAPROC)wglGetProcAddress("wglGetGalliumScreenMESA"); + if(!pfnGetGalliumScreenMESA) + return FALSE; + + pfnCreateGalliumContextMESA = (PFNCREATEGALLIUMCONTEXTMESAPROC)wglGetProcAddress("wglCreateGalliumContextMESA"); + if(!pfnCreateGalliumContextMESA) + return FALSE; + + DestroyWindow(hwnd); + + return TRUE; +} + +#else + +static INLINE boolean +st_hardpipe_load(void) +{ + Display *dpy; + int scrnum; + Window root; + int attribSingle[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + None }; + int attribDouble[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + None }; + XVisualInfo *visinfo; + GLXContext ctx = NULL; + XSetWindowAttributes attr; + unsigned long mask; + int width = 100, height = 100; + Window win; + + dpy = XOpenDisplay(NULL); + if (!dpy) + return FALSE; + + scrnum = 0; + + root = RootWindow(dpy, scrnum); + + visinfo = glXChooseVisual(dpy, scrnum, attribSingle); + if (!visinfo) + visinfo = glXChooseVisual(dpy, scrnum, attribDouble); + if (!visinfo) + return FALSE; + + ctx = glXCreateContext( dpy, visinfo, NULL, True ); + + if (!ctx) + return FALSE; + + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask; + + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow(dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr); + + if (!glXMakeCurrent(dpy, win, ctx)) + return FALSE; + + pfnGetGalliumScreenMESA = (PFNGETGALLIUMSCREENMESAPROC)glXGetProcAddressARB((const GLubyte *)"glXGetGalliumScreenMESA"); + if(!pfnGetGalliumScreenMESA) + return FALSE; + + pfnCreateGalliumContextMESA = (PFNCREATEGALLIUMCONTEXTMESAPROC)glXGetProcAddressARB((const GLubyte *)"glXCreateGalliumContextMESA"); + if(!pfnCreateGalliumContextMESA) + return FALSE; + + glXDestroyContext(dpy, ctx); + XFree(visinfo); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return TRUE; +} + +#endif + + static struct pipe_screen * st_hardpipe_screen_create(void) { - return st_softpipe_winsys.screen_create(); + if(st_hardpipe_load()) + return pfnGetGalliumScreenMESA(); + else + return st_softpipe_winsys.screen_create(); } static struct pipe_context * st_hardpipe_context_create(struct pipe_screen *screen) { - return st_softpipe_winsys.context_create(screen); + if(st_hardpipe_load()) { + if(screen == pfnGetGalliumScreenMESA()) + return pfnCreateGalliumContextMESA(); + else + return NULL; + } + else + return st_softpipe_winsys.context_create(screen); } -- cgit v1.2.3 From 0c4350790ac0639996cbefcf2556ca5748d39454 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 16 Jul 2009 11:21:12 +0100 Subject: python: Hack to prevent segmentation faults when python exits. --- src/gallium/state_trackers/python/st_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 8246b378ce..ea7d18738f 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -44,8 +44,14 @@ static void st_device_really_destroy(struct st_device *st_dev) { - if(st_dev->screen) + if(st_dev->screen) { + /* FIXME: Don't really destroy until we keep track of every single + * reference or we end up causing a segmentation fault every time + * python exits. */ +#if 0 st_dev->screen->destroy(st_dev->screen); +#endif + } FREE(st_dev); } -- cgit v1.2.3 From 5807ccb41b14890a1cdab4cc06806a9cf6c11ecc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 16 Jul 2009 19:31:36 +0100 Subject: python/retrace: Flush stdout before calling the pipe driver. So that messages are in sync with stderr. --- src/gallium/state_trackers/python/retrace/interpreter.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index e018a6e96b..69515da218 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -456,6 +456,7 @@ class Context(Object): x, y, z, w = unpack_from(format, data, offset) sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w)) index += 1 + sys.stdout.flush() def set_constant_buffer(self, shader, index, buffer): if buffer is not None: @@ -537,6 +538,7 @@ class Context(Object): sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n') assert len(values) == velem.nr_components sys.stdout.write('\t},\n') + sys.stdout.flush() def dump_indices(self, ibuf, isize, start, count): if not self.interpreter.verbosity(2): @@ -564,6 +566,7 @@ class Context(Object): minindex = min(minindex, index) maxindex = max(maxindex, index) sys.stdout.write('\t},\n') + sys.stdout.flush() return minindex, maxindex @@ -674,6 +677,7 @@ class Interpreter(parser.TraceDumper): if self.verbosity(1): parser.TraceDumper.handle_call(self, call) + sys.stdout.flush() args = [(str(name), self.interpret_arg(arg)) for name, arg in call.args] -- cgit v1.2.3 From cf7e8fbc2ea2739f1955d83751b631c5444a3c91 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 16 Jul 2009 19:32:40 +0100 Subject: python/retrace: Dump the surface copy contents. --- src/gallium/state_trackers/python/retrace/interpreter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 69515da218..bc06429b77 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -596,7 +596,17 @@ class Context(Object): def surface_copy(self, dest, destx, desty, src, srcx, srcy, width, height): if dest is not None and src is not None: + if self.interpreter.options.all: + self.interpreter.present(src, 'surface_copy_src', srcx, srcy, width, height) self.real.surface_copy(dest, destx, desty, src, srcx, srcy, width, height) + if dest in self.cbufs: + self._set_dirty() + flags = gallium.PIPE_FLUSH_FRAME + else: + flags = 0 + self.flush(flags) + if self.interpreter.options.all: + self.interpreter.present(dest, 'surface_copy_dest', destx, desty, width, height) def is_texture_referenced(self, texture, face, level): #return self.real.is_texture_referenced(format, texture, face, level) -- cgit v1.2.3 From 2ba98efdf6653a4cb885d576d2e6f349c69679d4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 16 Jul 2009 19:34:44 +0100 Subject: python/retrace: Process the call no passed to --to option inclusively. --- src/gallium/state_trackers/python/retrace/interpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/python') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index bc06429b77..6f0bd6ae52 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -677,7 +677,7 @@ class Interpreter(parser.TraceDumper): self.interpret_call(call) def handle_call(self, call): - if self.options.stop and call.no >= self.options.stop: + if self.options.stop and call.no > self.options.stop: sys.exit(0) if (call.klass, call.method) in self.ignore_calls: -- cgit v1.2.3