From c5a97eda32d37de7d1154288bf4298dff3542551 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 22 Apr 2009 15:12:22 -0600 Subject: gallium: license, copyright --- src/gallium/auxiliary/util/u_linear.c | 31 +++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_linear.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c index 6be365e53b..a1dce3f5cf 100644 --- a/src/gallium/auxiliary/util/u_linear.c +++ b/src/gallium/auxiliary/util/u_linear.c @@ -1,3 +1,34 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Functions for converting tiled data to linear and vice versa. + */ + #include "util/u_debug.h" #include "u_linear.h" diff --git a/src/gallium/auxiliary/util/u_linear.h b/src/gallium/auxiliary/util/u_linear.h index 1589f029bc..b74308ffa3 100644 --- a/src/gallium/auxiliary/util/u_linear.h +++ b/src/gallium/auxiliary/util/u_linear.h @@ -1,3 +1,34 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Functions for converting tiled data to linear and vice versa. + */ + #ifndef U_LINEAR_H #define U_LINEAR_H -- cgit v1.2.3 From 17ee25ba6f846d08521f22c5ec2a6e59a5383cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 23 Apr 2009 12:17:28 +0100 Subject: gallium: Fix up xorg state tracker build. --- src/gallium/state_trackers/xorg/xorg_dri2.c | 2 -- src/gallium/state_trackers/xorg/xorg_exa.c | 1 - 2 files changed, 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index d04204e1bf..0d29b1e572 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -85,7 +85,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count) memset(&template, 0, sizeof(template)); template.target = PIPE_TEXTURE_2D; - template.compressed = 0; template.format = PIPE_FORMAT_S8Z24_UNORM; pf_get_block(template.format, &template.block); template.width[0] = pDraw->width; @@ -98,7 +97,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count) struct pipe_texture template; memset(&template, 0, sizeof(template)); template.target = PIPE_TEXTURE_2D; - template.compressed = 0; template.format = PIPE_FORMAT_A8R8G8B8_UNORM; pf_get_block(template.format, &template.block); template.width[0] = pDraw->width; diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 56c8fdccb2..ee61de1ea7 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -425,7 +425,6 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, memset(&template, 0, sizeof(template)); template.target = PIPE_TEXTURE_2D; - template.compressed = 0; exa_get_pipe_format(depth, &template.format, &bitsPerPixel); pf_get_block(template.format, &template.block); template.width[0] = width; -- cgit v1.2.3 From 49ba80dff335226a54dae60477b256384005b393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 23 Apr 2009 12:20:22 +0100 Subject: gallium: Always include xorg-server.h before other X server headers. Various breakage otherwise, e.g. _XSERVER64 not being defined on 64 bit leading to inconsistent definitions of X server internal structs. --- src/gallium/state_trackers/xorg/xorg_dri2.c | 1 + src/gallium/state_trackers/xorg/xorg_exa.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 0d29b1e572..401bd39dac 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -28,6 +28,7 @@ * */ +#include "xorg-server.h" #include "xf86.h" #include "xf86_OSproc.h" diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index ee61de1ea7..d743e1e300 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -28,6 +28,7 @@ * */ +#include "xorg-server.h" #include "xf86.h" #include "xorg_tracker.h" -- cgit v1.2.3 From 13cb8264d81f09ce046c73fd751596572d13512e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 23 Apr 2009 12:57:46 +0100 Subject: gallium/intel/gem: Use softpipe rather than i915simple if INTEL_SOFTPIPE is set. --- src/gallium/drivers/softpipe/sp_texture.c | 19 +++++++++++++++++++ src/gallium/drivers/softpipe/sp_winsys.h | 6 ++++++ src/gallium/winsys/drm/intel/gem/intel_be_context.c | 14 ++++++++------ src/gallium/winsys/drm/intel/gem/intel_be_device.c | 7 ++++++- src/gallium/winsys/drm/intel/xorg/Makefile | 3 ++- 5 files changed, 41 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index c0113c47ad..9e19745889 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -399,3 +399,22 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) screen->transfer_map = softpipe_transfer_map; screen->transfer_unmap = softpipe_transfer_unmap; } + + +boolean +softpipe_get_texture_buffer( struct pipe_texture *texture, + struct pipe_buffer **buf, + unsigned *stride ) +{ + struct softpipe_texture *tex = (struct softpipe_texture *)texture; + + if (!tex) + return FALSE; + + pipe_buffer_reference(buf, tex->buffer); + + if (stride) + *stride = tex->stride[0]; + + return TRUE; +} diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h index cf91e7782b..9e571862b7 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.h +++ b/src/gallium/drivers/softpipe/sp_winsys.h @@ -52,6 +52,12 @@ struct pipe_screen * softpipe_create_screen(struct pipe_winsys *); +boolean +softpipe_get_texture_buffer( struct pipe_texture *texture, + struct pipe_buffer **buf, + unsigned *stride ); + + #ifdef __cplusplus } #endif diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.c b/src/gallium/winsys/drm/intel/gem/intel_be_context.c index bb6f1b916c..cfe8c88466 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_context.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.c @@ -1,6 +1,8 @@ #include "pipe/p_screen.h" +#include "softpipe/sp_winsys.h" + #include "intel_be_device.h" #include "intel_be_context.h" #include "intel_be_batchbuffer.h" @@ -106,13 +108,13 @@ intel_be_create_context(struct pipe_screen *screen) intel_be_init_context(intel, device); -#if 0 - pipe = intel_create_softpipe(intel, screen->winsys); -#else - pipe = i915_create_context(screen, &device->base, &intel->base); -#endif + if (getenv("INTEL_SOFTPIPE")) + pipe = softpipe_create(screen); + else + pipe = i915_create_context(screen, &device->base, &intel->base); - pipe->priv = intel; + if (pipe) + pipe->priv = intel; return pipe; } diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index 0f6300323b..8979f0ae15 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -10,6 +10,7 @@ #include "intel_be_fence.h" #include "i915simple/i915_winsys.h" +#include "softpipe/sp_winsys.h" #include "intel_be_api.h" @@ -302,7 +303,11 @@ intel_be_create_screen(int drmFD, int deviceID) intel_be_init_device(dev, drmFD, deviceID); - screen = i915_create_screen(&dev->base, deviceID); + if (getenv("INTEL_SOFTPIPE")) { + screen = softpipe_create_screen(&dev->base); + drm_api_hooks.buffer_from_texture = softpipe_get_texture_buffer; + } else + screen = i915_create_screen(&dev->base, deviceID); return screen; } diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile index a45ca570db..b1b6b9362b 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/winsys/drm/intel/xorg/Makefile @@ -21,6 +21,7 @@ LIBS = \ $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \ $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(GALLIUM_AUXILIARIES) ############################################# @@ -29,7 +30,7 @@ LIBS = \ all default: $(TARGET) -$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a +$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS) $(TOP)/bin/mklib -noprefix -o $@ \ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel -- cgit v1.2.3 From e0da812c5bdb7ffdd3450f614a4b73e44cd7feca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 23 Apr 2009 13:19:56 +0100 Subject: gallium: Make the intel xorg winsys start up with any Intel chipset. For unsupported devices the screen/context creation should fail cleanly later on. --- src/gallium/winsys/drm/intel/xorg/intel_xorg.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c index aea39247e5..46a7971f60 100644 --- a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c +++ b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c @@ -37,20 +37,17 @@ static Bool intel_xorg_pci_probe(DriverPtr driver, intptr_t match_data); static const struct pci_id_match intel_xorg_device_match[] = { - {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0}, - {0x8086, 0x27A2, 0xffff, 0xffff, 0, 0, 0}, + {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, {0, 0, 0}, }; static SymTabRec intel_xorg_chipsets[] = { - {0x2592, "Intel Graphics Device"}, - {0x27A2, "Intel Graphics Device"}, + {PCI_MATCH_ANY, "Intel Graphics Device"}, {-1, NULL} }; static PciChipsets intel_xorg_pci_devices[] = { - {0x2592, 0x2592, RES_SHARED_VGA}, - {0x27A2, 0x27A2, RES_SHARED_VGA}, + {PCI_MATCH_ANY, PCI_MATCH_ANY, RES_SHARED_VGA}, {-1, -1, RES_UNDEFINED} }; -- cgit v1.2.3 From f3c7d6ff866cdd96cdd55baee94f58698a9656a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 23 Apr 2009 14:47:31 +0100 Subject: gallium: Handle non-NULL data pointer in EXA ModifyPixmapHeader hook. Need to use the data pointed to for pixmap contents in that case. Fixes RENDER based text rendering. --- src/gallium/state_trackers/xorg/xorg_exa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index d743e1e300..7913174354 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -37,6 +37,8 @@ #include "pipe/p_state.h" #include "pipe/p_inlines.h" +#include "util/u_rect.h" + struct exa_entity { ExaDriverPtr pExa; @@ -436,6 +438,18 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, priv->tex = exa->scrn->texture_create(exa->scrn, &template); } + if (pPixData) { + struct pipe_transfer *transfer = + exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, width, height); + pipe_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer), + &priv->tex->block, transfer->stride, 0, 0, + width, height, pPixData, pPixmap->devKind, 0, 0); + exa->scrn->transfer_unmap(exa->scrn, transfer); + exa->scrn->tex_transfer_destroy(transfer); + } + return TRUE; } -- cgit v1.2.3 From f4a286e5f5ac11b2e5266ef39db5d1d1cb5f77ce Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 23 Apr 2009 05:42:26 +0200 Subject: util: Add more entry points for dumping to bmp --- src/gallium/auxiliary/util/u_debug.c | 56 ++++++++++++++++++++++++------------ src/gallium/auxiliary/util/u_debug.h | 5 ++++ 2 files changed, 43 insertions(+), 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index ae47a274a6..18597ef839 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -721,6 +721,7 @@ void debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface) { +#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT struct pipe_transfer *transfer; struct pipe_texture *texture = surface->texture; struct pipe_screen *screen = texture->screen; @@ -733,6 +734,7 @@ debug_dump_surface_bmp(const char *filename, debug_dump_transfer_bmp(filename, transfer); screen->tex_transfer_destroy(transfer); +#endif } void @@ -740,32 +742,56 @@ debug_dump_transfer_bmp(const char *filename, struct pipe_transfer *transfer) { #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT - struct util_stream *stream; - struct bmp_file_header bmfh; - struct bmp_info_header bmih; float *rgba; - unsigned x, y; if (!transfer) goto error1; rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float)); + if(!rgba) + goto error1; + + pipe_get_tile_rgba(transfer, 0, 0, + transfer->width, transfer->height, + rgba); + + debug_dump_float_rgba_bmp(filename, + transfer->width, transfer->height, + rgba, transfer->width); + + FREE(rgba); +error1: + ; +#endif +} + +void +debug_dump_float_rgba_bmp(const char *filename, + unsigned width, unsigned height, + float *rgba, unsigned stride) +{ +#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT + struct util_stream *stream; + struct bmp_file_header bmfh; + struct bmp_info_header bmih; + unsigned x, y; + if(!rgba) goto error1; bmfh.bfType = 0x4d42; - bmfh.bfSize = 14 + 40 + transfer->height*transfer->width*4; + bmfh.bfSize = 14 + 40 + height*width*4; bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfOffBits = 14 + 40; bmih.biSize = 40; - bmih.biWidth = transfer->width; - bmih.biHeight = transfer->height; + bmih.biWidth = width; + bmih.biHeight = height; bmih.biPlanes = 1; bmih.biBitCount = 32; bmih.biCompression = 0; - bmih.biSizeImage = transfer->height*transfer->width*4; + bmih.biSizeImage = height*width*4; bmih.biXPelsPerMeter = 0; bmih.biYPelsPerMeter = 0; bmih.biClrUsed = 0; @@ -773,19 +799,15 @@ debug_dump_transfer_bmp(const char *filename, stream = util_stream_create(filename, bmfh.bfSize); if(!stream) - goto error2; + goto error1; util_stream_write(stream, &bmfh, 14); util_stream_write(stream, &bmih, 40); - pipe_get_tile_rgba(transfer, 0, 0, - transfer->width, transfer->height, - rgba); - - y = transfer->height; + y = height; while(y--) { - float *ptr = rgba + (transfer->width * y * 4); - for(x = 0; x < transfer->width; ++x) + float *ptr = rgba + (stride * y * 4); + for(x = 0; x < width; ++x) { struct bmp_rgb_quad pixel; pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]); @@ -797,8 +819,6 @@ debug_dump_transfer_bmp(const char *filename, } util_stream_close(stream); -error2: - FREE(rgba); error1: ; #endif diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 8d703e47fc..bcd8f0f3cf 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -347,10 +347,15 @@ void debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface); void debug_dump_transfer_bmp(const char *filename, struct pipe_transfer *transfer); +void debug_dump_float_rgba_bmp(const char *filename, + unsigned width, unsigned height, + float *rgba, unsigned stride); #else #define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0) #define debug_dump_surface(prefix, surface) ((void)0) #define debug_dump_surface_bmp(filename, surface) ((void)0) +#define debug_dump_transfer_bmp(filename, transfer) ((void)0) +#define debug_dump_rgba_float_bmp(filename, width, height, rgba, stride) ((void)0) #endif -- cgit v1.2.3 From 29d9abf72d73c4ccd3ad605f68ab1adf5e13c67a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 24 Apr 2009 12:43:04 +0100 Subject: pipebuffer: don't fail when validating mapped buffers This can be almost impossible to avoid - hopefully we won't encounter a situation where this is a true requirement. Would probably require drivers to flush between hardware and software vertex processing. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 2cd0b8a8cd..044e8e1dd3 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -365,21 +365,22 @@ fenced_buffer_validate(struct pb_buffer *buf, if(fenced_buf->vl && fenced_buf->vl != vl) return PIPE_ERROR_RETRY; +#if 0 /* Do not validate if buffer is still mapped */ if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { /* TODO: wait for the thread that mapped the buffer to unmap it */ return PIPE_ERROR_RETRY; } + /* Final sanity checking */ + assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); + assert(!fenced_buf->mapcount); +#endif if(fenced_buf->vl == vl && (fenced_buf->validation_flags & flags) == flags) { /* Nothing to do -- buffer already validated */ return PIPE_OK; } - - /* Final sanity checking */ - assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); - assert(!fenced_buf->mapcount); ret = pb_validate(fenced_buf->buffer, vl, flags); if (ret != PIPE_OK) -- cgit v1.2.3 From 91eb8baaca21d24bfd3640c9f6b316610a7c5910 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 24 Apr 2009 17:08:59 -0600 Subject: tgis: SSE code generator doesn't yet support indirect addressing of temp regs Fall back to interpreter in this case. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 4b4e34b29e..ba2bfdef06 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1466,6 +1466,31 @@ emit_cmp( } } + +/** + * Check if inst src/dest regs use indirect addressing into temporary + * register file. + */ +static boolean +indirect_temp_reference(const struct tgsi_full_instruction *inst) +{ + uint i; + for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { + const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[i]; + if (reg->SrcRegister.File == TGSI_FILE_TEMPORARY && + reg->SrcRegister.Indirect) + return TRUE; + } + for (i = 0; i < inst->Instruction.NumDstRegs; i++) { + const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[i]; + if (reg->DstRegister.File == TGSI_FILE_TEMPORARY && + reg->DstRegister.Indirect) + return TRUE; + } + return FALSE; +} + + static int emit_instruction( struct x86_function *func, @@ -1473,6 +1498,10 @@ emit_instruction( { unsigned chan_index; + /* we can't handle indirect addressing into temp register file yet */ + if (indirect_temp_reference(inst)) + return FALSE; + switch (inst->Instruction.Opcode) { case TGSI_OPCODE_ARL: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { -- cgit v1.2.3 From f44f1155a9d1539bc5173928af20f5a2541ec6be Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 25 Apr 2009 12:52:04 +0100 Subject: gallium-intel: Link dri2 driver with softpipe --- src/gallium/winsys/drm/intel/dri2/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile index 1a02109274..e7c57afc34 100644 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ b/src/gallium/winsys/drm/intel/dri2/Makefile @@ -6,6 +6,7 @@ LIBNAME = i915_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a -- cgit v1.2.3 From 5f701f22f00ea17e0aba91c9995c9f559963d591 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 25 Apr 2009 12:55:21 +0100 Subject: gallium-intel: Cache software switch --- src/gallium/winsys/drm/intel/gem/intel_be_context.c | 2 +- src/gallium/winsys/drm/intel/gem/intel_be_device.c | 5 ++++- src/gallium/winsys/drm/intel/gem/intel_be_device.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.c b/src/gallium/winsys/drm/intel/gem/intel_be_context.c index cfe8c88466..fe0b138fbe 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_context.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.c @@ -108,7 +108,7 @@ intel_be_create_context(struct pipe_screen *screen) intel_be_init_context(intel, device); - if (getenv("INTEL_SOFTPIPE")) + if (device->softpipe) pipe = softpipe_create(screen); else pipe = i915_create_context(screen, &device->base, &intel->base); diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index 8979f0ae15..4fa7a5e1a2 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -6,6 +6,7 @@ #include "pipe/p_state.h" #include "pipe/p_inlines.h" #include "util/u_memory.h" +#include "util/u_debug.h" #include "intel_be_fence.h" @@ -286,6 +287,8 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id) dev->pools.gem = drm_intel_bufmgr_gem_init(dev->fd, dev->max_batch_size); + dev->softpipe = debug_get_bool_option("INTEL_SOFTPIPE", FALSE); + return true; } @@ -303,7 +306,7 @@ intel_be_create_screen(int drmFD, int deviceID) intel_be_init_device(dev, drmFD, deviceID); - if (getenv("INTEL_SOFTPIPE")) { + if (dev->softpipe) { screen = softpipe_create_screen(&dev->base); drm_api_hooks.buffer_from_texture = softpipe_get_texture_buffer; } else diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.h b/src/gallium/winsys/drm/intel/gem/intel_be_device.h index 47d2176cb4..b32637ece2 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h @@ -16,6 +16,8 @@ struct intel_be_device { struct pipe_winsys base; + boolean softpipe; + int fd; /**< Drm file discriptor */ unsigned id; -- cgit v1.2.3 From a098e6090319e618f71e2ff5ee9b6a993571fddf Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 25 Apr 2009 12:56:07 +0100 Subject: gallium-intel: Fix warning --- src/gallium/winsys/drm/intel/gem/intel_be_device.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index 4fa7a5e1a2..c866c2a2f1 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -177,8 +177,6 @@ intel_be_handle_from_buffer(struct pipe_screen *screen, struct pipe_buffer *buffer, unsigned *handle) { - drm_intel_bo *bo; - if (!buffer) return FALSE; -- cgit v1.2.3 From d9f2d0752b087b0d39748b005bc4f795a3d05404 Mon Sep 17 00:00:00 2001 From: Mathias Gottschlag Date: Sat, 25 Apr 2009 01:27:23 +0200 Subject: r300-gallium: Set framebuffer pitch on every framebuffer change. Signed-off-by: Corbin Simpson --- src/gallium/drivers/r300/r300_emit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 417d5f6307..cce5c591f1 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -160,7 +160,7 @@ void r300_emit_fb_state(struct r300_context* r300, struct r300_texture* tex; CS_LOCALS(r300); - BEGIN_CS((6 * fb->nr_cbufs) + (fb->zsbuf ? 6 : 0) + 4); + BEGIN_CS((7 * fb->nr_cbufs) + (fb->zsbuf ? 7 : 0) + 4); for (i = 0; i < fb->nr_cbufs; i++) { tex = (struct r300_texture*)fb->cbufs[i]->texture; OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1); @@ -168,6 +168,9 @@ void r300_emit_fb_state(struct r300_context* r300, OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), r300_translate_out_fmt(fb->cbufs[i]->format)); + unsigned pixpitch = tex->stride / tex->tex.block.size; + OUT_CS_REG(R300_RB3D_COLORPITCH0 + (4 * i), pixpitch | + r300_translate_colorformat(tex->tex.format)); } if (fb->zsbuf) { @@ -180,6 +183,8 @@ void r300_emit_fb_state(struct r300_context* r300, } else { OUT_CS_REG(R300_ZB_FORMAT, 0x0); } + unsigned pixpitch = tex->stride / tex->tex.block.size; + OUT_CS_REG(R300_ZB_DEPTHPITCH, pixpitch); } OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, -- cgit v1.2.3 From f45a7a1d1f8a576daf02e94ecabfd42f556dd9b4 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 24 Apr 2009 16:53:38 -0700 Subject: r300-gallium: Clean up FB state emit. --- src/gallium/drivers/r300/r300_emit.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index cce5c591f1..74d63ffe41 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -152,38 +152,38 @@ void r500_emit_fragment_shader(struct r300_context* r300, END_CS; } -/* XXX add pitch, stride, clean up */ void r300_emit_fb_state(struct r300_context* r300, struct pipe_framebuffer_state* fb) { - int i; struct r300_texture* tex; + unsigned pixpitch; + int i; CS_LOCALS(r300); - BEGIN_CS((7 * fb->nr_cbufs) + (fb->zsbuf ? 7 : 0) + 4); + BEGIN_CS((8 * fb->nr_cbufs) + (fb->zsbuf ? 8 : 0) + 4); for (i = 0; i < fb->nr_cbufs; i++) { tex = (struct r300_texture*)fb->cbufs[i]->texture; + pixpitch = tex->stride / tex->tex.block.size; + OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1); OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0); - OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), - r300_translate_out_fmt(fb->cbufs[i]->format)); - unsigned pixpitch = tex->stride / tex->tex.block.size; OUT_CS_REG(R300_RB3D_COLORPITCH0 + (4 * i), pixpitch | r300_translate_colorformat(tex->tex.format)); + + OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), + r300_translate_out_fmt(fb->cbufs[i]->format)); } if (fb->zsbuf) { tex = (struct r300_texture*)fb->zsbuf->texture; + pixpitch = (tex->stride / tex->tex.block.size); + OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1); OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0); - if (fb->zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) { - OUT_CS_REG(R300_ZB_FORMAT, - R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL); - } else { - OUT_CS_REG(R300_ZB_FORMAT, 0x0); - } - unsigned pixpitch = tex->stride / tex->tex.block.size; + + OUT_CS_REG(R300_ZB_FORMAT, r300_translate_zsformat(tex->tex.format)); + OUT_CS_REG(R300_ZB_DEPTHPITCH, pixpitch); } -- cgit v1.2.3 From 233c6fb694ebd946ae76cb48701adf4d2086b1c1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 25 Apr 2009 16:53:38 -0700 Subject: r300-gallium: Fix vertex shader OVM counting. Attribs must be packed: position, point size, colors, texcoords. Thanks to osiris for pointing it out. --- src/gallium/drivers/r300/r300_state_tcl.c | 38 ++++++++++++++++++++++++++++--- src/gallium/drivers/r300/r300_state_tcl.h | 12 +++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index bb96e2ad67..d84912de48 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -34,14 +34,20 @@ static void r300_vs_declare(struct r300_vs_asm* assembler, assembler->tab[decl->DeclarationRange.First] = 0; break; case TGSI_SEMANTIC_COLOR: - assembler->tab[decl->DeclarationRange.First] = 2; + assembler->tab[decl->DeclarationRange.First] = + (assembler->point_size ? 1 : 0) + + assembler->out_colors; break; + case TGSI_SEMANTIC_FOG: case TGSI_SEMANTIC_GENERIC: /* XXX multiple? */ - assembler->tab[decl->DeclarationRange.First] = 6; + assembler->tab[decl->DeclarationRange.First] = + (assembler->point_size ? 1 : 0) + + assembler->out_colors + + assembler->out_texcoords; break; case TGSI_SEMANTIC_PSIZE: - assembler->tab[decl->DeclarationRange.First] = 15; + assembler->tab[decl->DeclarationRange.First] = 1; break; default: debug_printf("r300: vs: Bad semantic declaration %d\n", @@ -252,6 +258,28 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, } } +static void r300_vs_init(struct r300_vertex_shader* vs, + struct r300_vs_asm* assembler) +{ + struct tgsi_shader_info* info = &vs->info; + int i; + + for (i = 0; i < info->num_outputs; i++) { + switch (info->output_semantic_name[i]) { + case TGSI_SEMANTIC_PSIZE: + assembler->point_size = TRUE; + break; + case TGSI_SEMANTIC_COLOR: + assembler->out_colors++; + break; + case TGSI_SEMANTIC_FOG: + case TGSI_SEMANTIC_GENERIC: + assembler->out_texcoords++; + break; + } + } +} + void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs) { @@ -264,6 +292,10 @@ void r300_translate_vertex_shader(struct r300_context* r300, if (assembler == NULL) { return; } + + /* Init assembler. */ + r300_vs_init(vs, assembler); + /* Setup starting offset for immediates. */ assembler->imm_offset = consts->user_count; diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index de944028ba..e2e1357d43 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -99,7 +99,13 @@ struct r300_vs_asm { unsigned imm_offset; /* Number of immediate constants. */ unsigned imm_count; - /* Offsets into vertex output memory. */ + /* Number of colors to write. */ + unsigned out_colors; + /* Number of texcoords to write. */ + unsigned out_texcoords; + /* Whether to emit point size. */ + boolean point_size; + /* Tab of declared outputs to OVM outputs. */ unsigned tab[16]; }; @@ -115,7 +121,7 @@ static struct r300_vertex_shader r300_passthrough_vertex_shader = { .instructions[0].inst3 = 0x0, .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | - R300_PVS_DST_OFFSET(2) | R300_PVS_DST_WE_XYZW, + R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW, .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW, .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, @@ -134,7 +140,7 @@ static struct r300_vertex_shader r300_texture_vertex_shader = { .instructions[0].inst3 = 0x0, .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | - R300_PVS_DST_OFFSET(6) | R300_PVS_DST_WE_XYZW, + R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW, .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW, .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, -- cgit v1.2.3 From 86d2144412915b0052a468806c4fba81d72a682d Mon Sep 17 00:00:00 2001 From: Mathias Gottschlag Date: Sun, 26 Apr 2009 12:04:35 +0200 Subject: r300-gallium: Add a draw_flush() to r300_flush(). This fixes some missing primitives which had been drawn right before the next glClear(). --- src/gallium/drivers/r300/r300_flush.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 20ca6905ad..89a5f2b20c 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -29,6 +29,8 @@ static void r300_flush(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); CS_LOCALS(r300); + draw_flush(r300->draw); + if (r300->dirty_hw) { FLUSH_CS; r300_emit_invariant_state(r300); -- cgit v1.2.3 From 904b563fd027c05a9755bc07719c55099ab5a9fd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 26 Apr 2009 10:06:02 -0700 Subject: r300-gallium: Correctly flush Draw. Should help with a few non-TCL bugs. --- src/gallium/drivers/r300/r300_state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index c9507ae193..184a23c9e6 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -421,6 +421,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) struct r300_context* r300 = r300_context(pipe); struct r300_rs_state* rs = (struct r300_rs_state*)state; + draw_flush(r300->draw); draw_set_rasterizer_state(r300->draw, &rs->rs); r300->rs_state = rs; @@ -528,7 +529,6 @@ static void r300_set_scissor_state(struct pipe_context* pipe, const struct pipe_scissor_state* state) { struct r300_context* r300 = r300_context(pipe); - draw_flush(r300->draw); if (r300_screen(r300->context.screen)->caps->is_r500) { r300->scissor_state->scissor_top_left = @@ -555,6 +555,8 @@ static void r300_set_viewport_state(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); + draw_flush(r300->draw); + if (r300_screen(r300->context.screen)->caps->has_tcl) { /* Do the transform in HW. */ r300->viewport_state->vte_control = R300_VTX_W0_FMT; @@ -642,6 +644,8 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) { struct r300_context* r300 = r300_context(pipe); + draw_flush(r300->draw); + if (r300_screen(pipe->screen)->caps->has_tcl) { struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; -- cgit v1.2.3 From b504721cc7fdfd9420e80c0f7ab78a3f92abeb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 23 Apr 2009 13:20:06 +0100 Subject: stw: Use a statically initiallized gl proc table. It doesn't change anyway. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 703 +++++++++++++-------------- 1 file changed, 347 insertions(+), 356 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index faf7f2f410..3711982fd2 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -38,9 +38,6 @@ #define DBG 0 -static GLCLTPROCTABLE cpt; -static boolean cpt_initialized = FALSE; - BOOL APIENTRY DrvCopyContext( @@ -165,351 +162,352 @@ DrvSetCallbackProcs( } -static void init_proc_table( GLCLTPROCTABLE *cpt ) -{ - GLDISPATCHTABLE *disp = &cpt->glDispatchTable; - - memset( cpt, 0, sizeof *cpt ); - cpt->cEntries = OPENGL_VERSION_110_ENTRIES; - -#define GPA_GL( NAME ) disp->NAME = gl##NAME - GPA_GL( NewList ); - GPA_GL( EndList ); - GPA_GL( CallList ); - GPA_GL( CallLists ); - GPA_GL( DeleteLists ); - GPA_GL( GenLists ); - GPA_GL( ListBase ); - GPA_GL( Begin ); - GPA_GL( Bitmap ); - GPA_GL( Color3b ); - GPA_GL( Color3bv ); - GPA_GL( Color3d ); - GPA_GL( Color3dv ); - GPA_GL( Color3f ); - GPA_GL( Color3fv ); - GPA_GL( Color3i ); - GPA_GL( Color3iv ); - GPA_GL( Color3s ); - GPA_GL( Color3sv ); - GPA_GL( Color3ub ); - GPA_GL( Color3ubv ); - GPA_GL( Color3ui ); - GPA_GL( Color3uiv ); - GPA_GL( Color3us ); - GPA_GL( Color3usv ); - GPA_GL( Color4b ); - GPA_GL( Color4bv ); - GPA_GL( Color4d ); - GPA_GL( Color4dv ); - GPA_GL( Color4f ); - GPA_GL( Color4fv ); - GPA_GL( Color4i ); - GPA_GL( Color4iv ); - GPA_GL( Color4s ); - GPA_GL( Color4sv ); - GPA_GL( Color4ub ); - GPA_GL( Color4ubv ); - GPA_GL( Color4ui ); - GPA_GL( Color4uiv ); - GPA_GL( Color4us ); - GPA_GL( Color4usv ); - GPA_GL( EdgeFlag ); - GPA_GL( EdgeFlagv ); - GPA_GL( End ); - GPA_GL( Indexd ); - GPA_GL( Indexdv ); - GPA_GL( Indexf ); - GPA_GL( Indexfv ); - GPA_GL( Indexi ); - GPA_GL( Indexiv ); - GPA_GL( Indexs ); - GPA_GL( Indexsv ); - GPA_GL( Normal3b ); - GPA_GL( Normal3bv ); - GPA_GL( Normal3d ); - GPA_GL( Normal3dv ); - GPA_GL( Normal3f ); - GPA_GL( Normal3fv ); - GPA_GL( Normal3i ); - GPA_GL( Normal3iv ); - GPA_GL( Normal3s ); - GPA_GL( Normal3sv ); - GPA_GL( RasterPos2d ); - GPA_GL( RasterPos2dv ); - GPA_GL( RasterPos2f ); - GPA_GL( RasterPos2fv ); - GPA_GL( RasterPos2i ); - GPA_GL( RasterPos2iv ); - GPA_GL( RasterPos2s ); - GPA_GL( RasterPos2sv ); - GPA_GL( RasterPos3d ); - GPA_GL( RasterPos3dv ); - GPA_GL( RasterPos3f ); - GPA_GL( RasterPos3fv ); - GPA_GL( RasterPos3i ); - GPA_GL( RasterPos3iv ); - GPA_GL( RasterPos3s ); - GPA_GL( RasterPos3sv ); - GPA_GL( RasterPos4d ); - GPA_GL( RasterPos4dv ); - GPA_GL( RasterPos4f ); - GPA_GL( RasterPos4fv ); - GPA_GL( RasterPos4i ); - GPA_GL( RasterPos4iv ); - GPA_GL( RasterPos4s ); - GPA_GL( RasterPos4sv ); - GPA_GL( Rectd ); - GPA_GL( Rectdv ); - GPA_GL( Rectf ); - GPA_GL( Rectfv ); - GPA_GL( Recti ); - GPA_GL( Rectiv ); - GPA_GL( Rects ); - GPA_GL( Rectsv ); - GPA_GL( TexCoord1d ); - GPA_GL( TexCoord1dv ); - GPA_GL( TexCoord1f ); - GPA_GL( TexCoord1fv ); - GPA_GL( TexCoord1i ); - GPA_GL( TexCoord1iv ); - GPA_GL( TexCoord1s ); - GPA_GL( TexCoord1sv ); - GPA_GL( TexCoord2d ); - GPA_GL( TexCoord2dv ); - GPA_GL( TexCoord2f ); - GPA_GL( TexCoord2fv ); - GPA_GL( TexCoord2i ); - GPA_GL( TexCoord2iv ); - GPA_GL( TexCoord2s ); - GPA_GL( TexCoord2sv ); - GPA_GL( TexCoord3d ); - GPA_GL( TexCoord3dv ); - GPA_GL( TexCoord3f ); - GPA_GL( TexCoord3fv ); - GPA_GL( TexCoord3i ); - GPA_GL( TexCoord3iv ); - GPA_GL( TexCoord3s ); - GPA_GL( TexCoord3sv ); - GPA_GL( TexCoord4d ); - GPA_GL( TexCoord4dv ); - GPA_GL( TexCoord4f ); - GPA_GL( TexCoord4fv ); - GPA_GL( TexCoord4i ); - GPA_GL( TexCoord4iv ); - GPA_GL( TexCoord4s ); - GPA_GL( TexCoord4sv ); - GPA_GL( Vertex2d ); - GPA_GL( Vertex2dv ); - GPA_GL( Vertex2f ); - GPA_GL( Vertex2fv ); - GPA_GL( Vertex2i ); - GPA_GL( Vertex2iv ); - GPA_GL( Vertex2s ); - GPA_GL( Vertex2sv ); - GPA_GL( Vertex3d ); - GPA_GL( Vertex3dv ); - GPA_GL( Vertex3f ); - GPA_GL( Vertex3fv ); - GPA_GL( Vertex3i ); - GPA_GL( Vertex3iv ); - GPA_GL( Vertex3s ); - GPA_GL( Vertex3sv ); - GPA_GL( Vertex4d ); - GPA_GL( Vertex4dv ); - GPA_GL( Vertex4f ); - GPA_GL( Vertex4fv ); - GPA_GL( Vertex4i ); - GPA_GL( Vertex4iv ); - GPA_GL( Vertex4s ); - GPA_GL( Vertex4sv ); - GPA_GL( ClipPlane ); - GPA_GL( ColorMaterial ); - GPA_GL( CullFace ); - GPA_GL( Fogf ); - GPA_GL( Fogfv ); - GPA_GL( Fogi ); - GPA_GL( Fogiv ); - GPA_GL( FrontFace ); - GPA_GL( Hint ); - GPA_GL( Lightf ); - GPA_GL( Lightfv ); - GPA_GL( Lighti ); - GPA_GL( Lightiv ); - GPA_GL( LightModelf ); - GPA_GL( LightModelfv ); - GPA_GL( LightModeli ); - GPA_GL( LightModeliv ); - GPA_GL( LineStipple ); - GPA_GL( LineWidth ); - GPA_GL( Materialf ); - GPA_GL( Materialfv ); - GPA_GL( Materiali ); - GPA_GL( Materialiv ); - GPA_GL( PointSize ); - GPA_GL( PolygonMode ); - GPA_GL( PolygonStipple ); - GPA_GL( Scissor ); - GPA_GL( ShadeModel ); - GPA_GL( TexParameterf ); - GPA_GL( TexParameterfv ); - GPA_GL( TexParameteri ); - GPA_GL( TexParameteriv ); - GPA_GL( TexImage1D ); - GPA_GL( TexImage2D ); - GPA_GL( TexEnvf ); - GPA_GL( TexEnvfv ); - GPA_GL( TexEnvi ); - GPA_GL( TexEnviv ); - GPA_GL( TexGend ); - GPA_GL( TexGendv ); - GPA_GL( TexGenf ); - GPA_GL( TexGenfv ); - GPA_GL( TexGeni ); - GPA_GL( TexGeniv ); - GPA_GL( FeedbackBuffer ); - GPA_GL( SelectBuffer ); - GPA_GL( RenderMode ); - GPA_GL( InitNames ); - GPA_GL( LoadName ); - GPA_GL( PassThrough ); - GPA_GL( PopName ); - GPA_GL( PushName ); - GPA_GL( DrawBuffer ); - GPA_GL( Clear ); - GPA_GL( ClearAccum ); - GPA_GL( ClearIndex ); - GPA_GL( ClearColor ); - GPA_GL( ClearStencil ); - GPA_GL( ClearDepth ); - GPA_GL( StencilMask ); - GPA_GL( ColorMask ); - GPA_GL( DepthMask ); - GPA_GL( IndexMask ); - GPA_GL( Accum ); - GPA_GL( Disable ); - GPA_GL( Enable ); - GPA_GL( Finish ); - GPA_GL( Flush ); - GPA_GL( PopAttrib ); - GPA_GL( PushAttrib ); - GPA_GL( Map1d ); - GPA_GL( Map1f ); - GPA_GL( Map2d ); - GPA_GL( Map2f ); - GPA_GL( MapGrid1d ); - GPA_GL( MapGrid1f ); - GPA_GL( MapGrid2d ); - GPA_GL( MapGrid2f ); - GPA_GL( EvalCoord1d ); - GPA_GL( EvalCoord1dv ); - GPA_GL( EvalCoord1f ); - GPA_GL( EvalCoord1fv ); - GPA_GL( EvalCoord2d ); - GPA_GL( EvalCoord2dv ); - GPA_GL( EvalCoord2f ); - GPA_GL( EvalCoord2fv ); - GPA_GL( EvalMesh1 ); - GPA_GL( EvalPoint1 ); - GPA_GL( EvalMesh2 ); - GPA_GL( EvalPoint2 ); - GPA_GL( AlphaFunc ); - GPA_GL( BlendFunc ); - GPA_GL( LogicOp ); - GPA_GL( StencilFunc ); - GPA_GL( StencilOp ); - GPA_GL( DepthFunc ); - GPA_GL( PixelZoom ); - GPA_GL( PixelTransferf ); - GPA_GL( PixelTransferi ); - GPA_GL( PixelStoref ); - GPA_GL( PixelStorei ); - GPA_GL( PixelMapfv ); - GPA_GL( PixelMapuiv ); - GPA_GL( PixelMapusv ); - GPA_GL( ReadBuffer ); - GPA_GL( CopyPixels ); - GPA_GL( ReadPixels ); - GPA_GL( DrawPixels ); - GPA_GL( GetBooleanv ); - GPA_GL( GetClipPlane ); - GPA_GL( GetDoublev ); - GPA_GL( GetError ); - GPA_GL( GetFloatv ); - GPA_GL( GetIntegerv ); - GPA_GL( GetLightfv ); - GPA_GL( GetLightiv ); - GPA_GL( GetMapdv ); - GPA_GL( GetMapfv ); - GPA_GL( GetMapiv ); - GPA_GL( GetMaterialfv ); - GPA_GL( GetMaterialiv ); - GPA_GL( GetPixelMapfv ); - GPA_GL( GetPixelMapuiv ); - GPA_GL( GetPixelMapusv ); - GPA_GL( GetPolygonStipple ); - GPA_GL( GetString ); - GPA_GL( GetTexEnvfv ); - GPA_GL( GetTexEnviv ); - GPA_GL( GetTexGendv ); - GPA_GL( GetTexGenfv ); - GPA_GL( GetTexGeniv ); - GPA_GL( GetTexImage ); - GPA_GL( GetTexParameterfv ); - GPA_GL( GetTexParameteriv ); - GPA_GL( GetTexLevelParameterfv ); - GPA_GL( GetTexLevelParameteriv ); - GPA_GL( IsEnabled ); - GPA_GL( IsList ); - GPA_GL( DepthRange ); - GPA_GL( Frustum ); - GPA_GL( LoadIdentity ); - GPA_GL( LoadMatrixf ); - GPA_GL( LoadMatrixd ); - GPA_GL( MatrixMode ); - GPA_GL( MultMatrixf ); - GPA_GL( MultMatrixd ); - GPA_GL( Ortho ); - GPA_GL( PopMatrix ); - GPA_GL( PushMatrix ); - GPA_GL( Rotated ); - GPA_GL( Rotatef ); - GPA_GL( Scaled ); - GPA_GL( Scalef ); - GPA_GL( Translated ); - GPA_GL( Translatef ); - GPA_GL( Viewport ); - GPA_GL( ArrayElement ); - GPA_GL( BindTexture ); - GPA_GL( ColorPointer ); - GPA_GL( DisableClientState ); - GPA_GL( DrawArrays ); - GPA_GL( DrawElements ); - GPA_GL( EdgeFlagPointer ); - GPA_GL( EnableClientState ); - GPA_GL( IndexPointer ); - GPA_GL( Indexub ); - GPA_GL( Indexubv ); - GPA_GL( InterleavedArrays ); - GPA_GL( NormalPointer ); - GPA_GL( PolygonOffset ); - GPA_GL( TexCoordPointer ); - GPA_GL( VertexPointer ); - GPA_GL( AreTexturesResident ); - GPA_GL( CopyTexImage1D ); - GPA_GL( CopyTexImage2D ); - GPA_GL( CopyTexSubImage1D ); - GPA_GL( CopyTexSubImage2D ); - GPA_GL( DeleteTextures ); - GPA_GL( GenTextures ); - GPA_GL( GetPointerv ); - GPA_GL( IsTexture ); - GPA_GL( PrioritizeTextures ); - GPA_GL( TexSubImage1D ); - GPA_GL( TexSubImage2D ); - GPA_GL( PopClientAttrib ); - GPA_GL( PushClientAttrib ); -} +/** + * Although WGL allows different dispatch entrypoints per context + */ +static const GLCLTPROCTABLE cpt = +{ + OPENGL_VERSION_110_ENTRIES, + { + &glNewList, + &glEndList, + &glCallList, + &glCallLists, + &glDeleteLists, + &glGenLists, + &glListBase, + &glBegin, + &glBitmap, + &glColor3b, + &glColor3bv, + &glColor3d, + &glColor3dv, + &glColor3f, + &glColor3fv, + &glColor3i, + &glColor3iv, + &glColor3s, + &glColor3sv, + &glColor3ub, + &glColor3ubv, + &glColor3ui, + &glColor3uiv, + &glColor3us, + &glColor3usv, + &glColor4b, + &glColor4bv, + &glColor4d, + &glColor4dv, + &glColor4f, + &glColor4fv, + &glColor4i, + &glColor4iv, + &glColor4s, + &glColor4sv, + &glColor4ub, + &glColor4ubv, + &glColor4ui, + &glColor4uiv, + &glColor4us, + &glColor4usv, + &glEdgeFlag, + &glEdgeFlagv, + &glEnd, + &glIndexd, + &glIndexdv, + &glIndexf, + &glIndexfv, + &glIndexi, + &glIndexiv, + &glIndexs, + &glIndexsv, + &glNormal3b, + &glNormal3bv, + &glNormal3d, + &glNormal3dv, + &glNormal3f, + &glNormal3fv, + &glNormal3i, + &glNormal3iv, + &glNormal3s, + &glNormal3sv, + &glRasterPos2d, + &glRasterPos2dv, + &glRasterPos2f, + &glRasterPos2fv, + &glRasterPos2i, + &glRasterPos2iv, + &glRasterPos2s, + &glRasterPos2sv, + &glRasterPos3d, + &glRasterPos3dv, + &glRasterPos3f, + &glRasterPos3fv, + &glRasterPos3i, + &glRasterPos3iv, + &glRasterPos3s, + &glRasterPos3sv, + &glRasterPos4d, + &glRasterPos4dv, + &glRasterPos4f, + &glRasterPos4fv, + &glRasterPos4i, + &glRasterPos4iv, + &glRasterPos4s, + &glRasterPos4sv, + &glRectd, + &glRectdv, + &glRectf, + &glRectfv, + &glRecti, + &glRectiv, + &glRects, + &glRectsv, + &glTexCoord1d, + &glTexCoord1dv, + &glTexCoord1f, + &glTexCoord1fv, + &glTexCoord1i, + &glTexCoord1iv, + &glTexCoord1s, + &glTexCoord1sv, + &glTexCoord2d, + &glTexCoord2dv, + &glTexCoord2f, + &glTexCoord2fv, + &glTexCoord2i, + &glTexCoord2iv, + &glTexCoord2s, + &glTexCoord2sv, + &glTexCoord3d, + &glTexCoord3dv, + &glTexCoord3f, + &glTexCoord3fv, + &glTexCoord3i, + &glTexCoord3iv, + &glTexCoord3s, + &glTexCoord3sv, + &glTexCoord4d, + &glTexCoord4dv, + &glTexCoord4f, + &glTexCoord4fv, + &glTexCoord4i, + &glTexCoord4iv, + &glTexCoord4s, + &glTexCoord4sv, + &glVertex2d, + &glVertex2dv, + &glVertex2f, + &glVertex2fv, + &glVertex2i, + &glVertex2iv, + &glVertex2s, + &glVertex2sv, + &glVertex3d, + &glVertex3dv, + &glVertex3f, + &glVertex3fv, + &glVertex3i, + &glVertex3iv, + &glVertex3s, + &glVertex3sv, + &glVertex4d, + &glVertex4dv, + &glVertex4f, + &glVertex4fv, + &glVertex4i, + &glVertex4iv, + &glVertex4s, + &glVertex4sv, + &glClipPlane, + &glColorMaterial, + &glCullFace, + &glFogf, + &glFogfv, + &glFogi, + &glFogiv, + &glFrontFace, + &glHint, + &glLightf, + &glLightfv, + &glLighti, + &glLightiv, + &glLightModelf, + &glLightModelfv, + &glLightModeli, + &glLightModeliv, + &glLineStipple, + &glLineWidth, + &glMaterialf, + &glMaterialfv, + &glMateriali, + &glMaterialiv, + &glPointSize, + &glPolygonMode, + &glPolygonStipple, + &glScissor, + &glShadeModel, + &glTexParameterf, + &glTexParameterfv, + &glTexParameteri, + &glTexParameteriv, + &glTexImage1D, + &glTexImage2D, + &glTexEnvf, + &glTexEnvfv, + &glTexEnvi, + &glTexEnviv, + &glTexGend, + &glTexGendv, + &glTexGenf, + &glTexGenfv, + &glTexGeni, + &glTexGeniv, + &glFeedbackBuffer, + &glSelectBuffer, + &glRenderMode, + &glInitNames, + &glLoadName, + &glPassThrough, + &glPopName, + &glPushName, + &glDrawBuffer, + &glClear, + &glClearAccum, + &glClearIndex, + &glClearColor, + &glClearStencil, + &glClearDepth, + &glStencilMask, + &glColorMask, + &glDepthMask, + &glIndexMask, + &glAccum, + &glDisable, + &glEnable, + &glFinish, + &glFlush, + &glPopAttrib, + &glPushAttrib, + &glMap1d, + &glMap1f, + &glMap2d, + &glMap2f, + &glMapGrid1d, + &glMapGrid1f, + &glMapGrid2d, + &glMapGrid2f, + &glEvalCoord1d, + &glEvalCoord1dv, + &glEvalCoord1f, + &glEvalCoord1fv, + &glEvalCoord2d, + &glEvalCoord2dv, + &glEvalCoord2f, + &glEvalCoord2fv, + &glEvalMesh1, + &glEvalPoint1, + &glEvalMesh2, + &glEvalPoint2, + &glAlphaFunc, + &glBlendFunc, + &glLogicOp, + &glStencilFunc, + &glStencilOp, + &glDepthFunc, + &glPixelZoom, + &glPixelTransferf, + &glPixelTransferi, + &glPixelStoref, + &glPixelStorei, + &glPixelMapfv, + &glPixelMapuiv, + &glPixelMapusv, + &glReadBuffer, + &glCopyPixels, + &glReadPixels, + &glDrawPixels, + &glGetBooleanv, + &glGetClipPlane, + &glGetDoublev, + &glGetError, + &glGetFloatv, + &glGetIntegerv, + &glGetLightfv, + &glGetLightiv, + &glGetMapdv, + &glGetMapfv, + &glGetMapiv, + &glGetMaterialfv, + &glGetMaterialiv, + &glGetPixelMapfv, + &glGetPixelMapuiv, + &glGetPixelMapusv, + &glGetPolygonStipple, + &glGetString, + &glGetTexEnvfv, + &glGetTexEnviv, + &glGetTexGendv, + &glGetTexGenfv, + &glGetTexGeniv, + &glGetTexImage, + &glGetTexParameterfv, + &glGetTexParameteriv, + &glGetTexLevelParameterfv, + &glGetTexLevelParameteriv, + &glIsEnabled, + &glIsList, + &glDepthRange, + &glFrustum, + &glLoadIdentity, + &glLoadMatrixf, + &glLoadMatrixd, + &glMatrixMode, + &glMultMatrixf, + &glMultMatrixd, + &glOrtho, + &glPopMatrix, + &glPushMatrix, + &glRotated, + &glRotatef, + &glScaled, + &glScalef, + &glTranslated, + &glTranslatef, + &glViewport, + &glArrayElement, + &glBindTexture, + &glColorPointer, + &glDisableClientState, + &glDrawArrays, + &glDrawElements, + &glEdgeFlagPointer, + &glEnableClientState, + &glIndexPointer, + &glIndexub, + &glIndexubv, + &glInterleavedArrays, + &glNormalPointer, + &glPolygonOffset, + &glTexCoordPointer, + &glVertexPointer, + &glAreTexturesResident, + &glCopyTexImage1D, + &glCopyTexImage2D, + &glCopyTexSubImage1D, + &glCopyTexSubImage2D, + &glDeleteTextures, + &glGenTextures, + &glGetPointerv, + &glIsTexture, + &glPrioritizeTextures, + &glTexSubImage1D, + &glTexSubImage2D, + &glPopClientAttrib, + &glPushClientAttrib + } +}; + PGLCLTPROCTABLE APIENTRY DrvSetContext( @@ -521,17 +519,10 @@ DrvSetContext( debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable ); - /* Although WGL allows different dispatch entrypoints per - */ - if (!cpt_initialized) { - init_proc_table( &cpt ); - cpt_initialized = TRUE; - } - if (!stw_make_current( hdc, dhglrc )) return NULL; - return &cpt; + return (GLCLTPROCTABLE *)&cpt; } int APIENTRY -- cgit v1.2.3 From b618827fac84ca12a354da5808f30e96bedbc92a Mon Sep 17 00:00:00 2001 From: Micah Dowty Date: Fri, 24 Apr 2009 23:45:16 +0200 Subject: util: Add debug_printf_once --- src/gallium/auxiliary/util/u_debug.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index bcd8f0f3cf..d42b65ce28 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -102,6 +102,22 @@ debug_printf(const char *format, ...) } +/* + * ... isn't portable so we need to pass arguments in parentheses. + * + * usage: + * debug_printf_once(("awnser: %i\n", 42)); + */ +#define debug_printf_once(args) \ + do { \ + static boolean once = TRUE; \ + if (once) { \ + once = FALSE; \ + debug_printf args; \ + } \ + } while (0) + + #ifdef DEBUG #define debug_vprintf(_format, _ap) _debug_vprintf(_format, _ap) #else -- cgit v1.2.3 From 5250eec652af46d20261624fd043992355a0b4ba Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 27 Apr 2009 14:43:31 +0100 Subject: util/time: add util_time_sleep() for windows userspace Somebody with a clue could probably do a better implemenation... --- src/gallium/auxiliary/util/u_time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index 8afe4fccf7..8e167d3c42 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -217,4 +217,13 @@ void util_time_sleep(unsigned usecs) } while(start <= curr && curr < end || end < start && (curr < end || start <= curr)); } +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#include +#include + + +void util_time_sleep(unsigned usecs) +{ + Sleep((usecs + 999)/ 1000); +} #endif -- cgit v1.2.3 From 3ebcf2dd7489ecaf19a7167892069c4d58c285d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 27 Apr 2009 17:13:40 +0100 Subject: util: Remove unix includes. --- src/gallium/auxiliary/util/u_time.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index 8e167d3c42..5268cbf79c 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -218,10 +218,6 @@ void util_time_sleep(unsigned usecs) end < start && (curr < end || start <= curr)); } #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) -#include -#include - - void util_time_sleep(unsigned usecs) { Sleep((usecs + 999)/ 1000); -- cgit v1.2.3 From c384ccb0c4f50f72bafdfb693d0aa36b4304a064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 27 Apr 2009 17:30:05 +0100 Subject: wgl: Implement WGL_EXT_extensions_string extension. --- src/gallium/state_trackers/wgl/SConscript | 2 +- .../wgl/shared/stw_arbextensionsstring.c | 46 ----------------- .../wgl/shared/stw_extensionsstring.c | 58 ++++++++++++++++++++++ .../state_trackers/wgl/shared/stw_getprocaddress.c | 3 ++ 4 files changed, 62 insertions(+), 47 deletions(-) delete mode 100644 src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c create mode 100644 src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index 61fd8bfc0c..5bbcc7175f 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -26,7 +26,7 @@ if env['platform'] in ['windows']: 'shared/stw_device.c', 'shared/stw_framebuffer.c', 'shared/stw_pixelformat.c', - 'shared/stw_arbextensionsstring.c', + 'shared/stw_extensionsstring.c', 'shared/stw_getprocaddress.c', 'shared/stw_arbpixelformat.c', 'shared/stw_tls.c', diff --git a/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c b/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c deleted file mode 100644 index cd9fe93eee..0000000000 --- a/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#define WGL_WGLEXT_PROTOTYPES - -#include -#include - - -WINGDIAPI const char * APIENTRY -wglGetExtensionsStringARB( - HDC hdc ) -{ - (void) hdc; - - return - "WGL_ARB_extensions_string " - "WGL_ARB_multisample " - "WGL_ARB_pixel_format"; -} diff --git a/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c b/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c new file mode 100644 index 0000000000..2660c591f9 --- /dev/null +++ b/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c @@ -0,0 +1,58 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include + +#define WGL_WGLEXT_PROTOTYPES + +#include +#include + + +static const char *stw_extension_string = + "WGL_ARB_extensions_string " + "WGL_ARB_multisample " + "WGL_ARB_pixel_format " + "WGL_EXT_extensions_string"; + + +WINGDIAPI const char * APIENTRY +wglGetExtensionsStringARB( + HDC hdc ) +{ + (void) hdc; + + return stw_extension_string; +} + + +WINGDIAPI const char * APIENTRY +wglGetExtensionsStringEXT( void ) +{ + return stw_extension_string; +} diff --git a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c index aa43120955..4070cbd5c0 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c +++ b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c @@ -53,6 +53,9 @@ static const struct stw_extension_entry stw_extension_entries[] = { STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ), STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ), + /* WGL_EXT_extensions_string */ + STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ), + { NULL, NULL } }; -- cgit v1.2.3 From 76b9da9e98bad4bf22fe6610394236203b620bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 27 Apr 2009 18:48:11 +0100 Subject: wgl: Cope with pre-existing threads. DllMain is called with DLL_THREAD_ATTACH only by threads created after the DLL is loaded by the process. --- src/gallium/state_trackers/wgl/shared/stw_tls.c | 39 ++++++++++++++++++++----- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c index e72bafb880..95863ca9cf 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.c +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.c @@ -44,6 +44,20 @@ stw_tls_init(void) return TRUE; } +static INLINE struct stw_tls_data * +stw_tls_data_create() +{ + struct stw_tls_data *data; + + data = CALLOC_STRUCT(stw_tls_data); + if (!data) + return NULL; + + data->currentPixelFormat = 0; + + return data; +} + boolean stw_tls_init_thread(void) { @@ -53,14 +67,9 @@ stw_tls_init_thread(void) return FALSE; } - data = MALLOC(sizeof(*data)); - if (!data) { + data = stw_tls_data_create(); + if(!data) return FALSE; - } - - data->currentPixelFormat = 0; - data->currentDC = NULL; - data->currentGLRC = 0; TlsSetValue(tlsIndex, data); @@ -93,9 +102,23 @@ stw_tls_cleanup(void) struct stw_tls_data * stw_tls_get_data(void) { + struct stw_tls_data *data; + if (tlsIndex == TLS_OUT_OF_INDEXES) { return NULL; } + + data = (struct stw_tls_data *) TlsGetValue(tlsIndex); + if(!data) { + /* DllMain is called with DLL_THREAD_ATTACH only by threads created after + * the DLL is loaded by the process */ + + data = stw_tls_data_create(); + if(!data) + return NULL; + + TlsSetValue(tlsIndex, data); + } - return (struct stw_tls_data *) TlsGetValue(tlsIndex); + return data; } -- cgit v1.2.3 From 638261b3530106b70819c2fe0c3cd613c0d85777 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:23:11 +0200 Subject: gallium: Update the drm_api. Make it possible to pass state-tracker-specific data to the init_screen function, and even open the door for device-specific state-tracker screen initialization. Signed-off-by: Thomas Hellstrom --- src/gallium/include/state_tracker/drm_api.h | 19 +++++++++++- src/gallium/state_trackers/dri2/dri_screen.c | 35 +--------------------- src/gallium/state_trackers/dri2/dri_screen.h | 2 -- src/gallium/state_trackers/egl/egl_tracker.c | 2 +- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- src/gallium/winsys/drm/intel/gem/intel_be_api.h | 3 +- src/gallium/winsys/drm/intel/gem/intel_be_device.c | 35 +++++++++++++++++++++- .../winsys/drm/nouveau/dri/nouveau_screen.c | 2 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 2 +- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 3 +- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 3 +- 11 files changed, 63 insertions(+), 45 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 435435da29..5790b2f6c7 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -10,13 +10,30 @@ struct pipe_buffer; struct pipe_context; struct pipe_texture; +enum drm_create_screen_mode { + DRM_CREATE_NORMAL = 0, + DRM_CREATE_DRI1, + DRM_CREATE_DRIVER = 1024, + DRM_CREATE_MAX +}; + +/** + * Modes other than DRM_CREATE_NORMAL derive from this struct. + */ +/*@{*/ +struct drm_create_screen_arg { + enum drm_create_screen_mode mode; +}; +/*@}*/ + struct drm_api { /** * Special buffer functions */ /*@{*/ - struct pipe_screen* (*create_screen)(int drmFB, int pciID); + struct pipe_screen* (*create_screen)(int drm_fd, + struct drm_create_screen_arg *arg); struct pipe_context* (*create_context)(struct pipe_screen *screen); /*@}*/ diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c index ab5878a4bc..ab33003f51 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.c +++ b/src/gallium/state_trackers/dri2/dri_screen.c @@ -67,37 +67,6 @@ static const __DRIextension *dri_screen_extensions[] = { NULL }; - -static void -dri_get_drm_minor(struct dri_screen *screen) -{ - /* TODO get the real minor */ - screen->minor = 0; -} - - -static void -dri_get_device_id(struct dri_screen *screen) -{ - char path[512]; - FILE *file; - - /* - * There must be a better way to get the deviceID. - * XXX this only works on Linux. - */ - snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", screen->minor); - file = fopen(path, "r"); - if (!file) { - return; - } - - fgets(path, sizeof(path), file); - sscanf(path, "%x", &screen->deviceID); - fclose(file); -} - - static const __DRIconfig ** dri_fill_in_modes(__DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, @@ -212,13 +181,11 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; - dri_get_drm_minor(screen); - dri_get_device_id(screen); sPriv->private = (void *) screen; sPriv->extensions = dri_screen_extensions; - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); goto fail; diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h index fe2676d0be..3751ec6121 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.h +++ b/src/gallium/state_trackers/dri2/dri_screen.h @@ -54,9 +54,7 @@ struct dri_screen struct dri_context *dummyContext; /* drm */ - int deviceID; int fd; - int minor; /* gallium */ struct pipe_winsys *pipe_winsys; diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index abdf84544f..8e62008461 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -146,7 +146,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) dev->drmFD = fd; drm_get_device_id(dev); - dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID); + dev->screen = drm_api_hooks.create_screen(dev->drmFD, NULL); if (!dev->screen) goto err_screen; dev->winsys = dev->screen->winsys; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 8a2711e70c..45e831f0c2 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -476,7 +476,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } if (!ms->screen) { - ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id); + ms->screen = drm_api_hooks.create_screen(ms->fd, NULL); if (!ms->screen) { FatalError("Could not init pipe_screen\n"); diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.h b/src/gallium/winsys/drm/intel/gem/intel_be_api.h index 73e458d4ba..1c622f3b97 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h @@ -8,7 +8,8 @@ #include "intel_be_device.h" -struct pipe_screen *intel_be_create_screen(int drmFD, int pciID); +struct pipe_screen *intel_be_create_screen(int drmFD, + struct drm_create_screen_arg *arg); struct pipe_context *intel_be_create_context(struct pipe_screen *screen); #endif diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index c866c2a2f1..907ac86637 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -14,6 +14,7 @@ #include "softpipe/sp_winsys.h" #include "intel_be_api.h" +#include /* * Buffer @@ -290,11 +291,42 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id) return true; } +static void +intel_be_get_device_id(unsigned int *device_id) +{ + char path[512]; + FILE *file; + + /* + * FIXME: Fix this up to use a drm ioctl or whatever. + */ + + snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device"); + file = fopen(path, "r"); + if (!file) { + return; + } + + fgets(path, sizeof(path), file); + sscanf(path, "%x", device_id); + fclose(file); +} + struct pipe_screen * -intel_be_create_screen(int drmFD, int deviceID) +intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg) { struct intel_be_device *dev; struct pipe_screen *screen; + unsigned int deviceID; + + if (arg != NULL) { + switch(arg->mode) { + case DRM_CREATE_NORMAL: + break; + default: + return NULL; + } + } /* Allocate the private area */ dev = malloc(sizeof(*dev)); @@ -302,6 +334,7 @@ intel_be_create_screen(int drmFD, int deviceID) return NULL; memset(dev, 0, sizeof(*dev)); + intel_be_get_device_id(&deviceID); intel_be_init_device(dev, drmFD, deviceID); if (dev->softpipe) { diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c index 0b45b1ff1f..4e9b76a909 100644 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c +++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c @@ -267,7 +267,7 @@ nouveau_screen_create(__DRIscreenPrivate *psp) nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0); - nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, 0); + nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, NULL); if (!nv_screen->pscreen) { FREE(nv_screen); return NULL; diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index c0127e803f..a558fda140 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -8,7 +8,7 @@ #include "nouveau_bo.h" static struct pipe_screen * -nouveau_drm_create_screen(int fd, int pciid) +nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct pipe_winsys *ws; struct nouveau_winsys *nvws; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 3446654e28..1f89d1b1d1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -31,7 +31,8 @@ #include "radeon_drm.h" /* Create a pipe_screen. */ -struct pipe_screen* radeon_create_screen(int drmFB, int pciID) +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg ) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index ca2d98ed1a..049f9984db 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -40,7 +40,8 @@ #include "radeon_r300.h" #include "radeon_winsys_softpipe.h" -struct pipe_screen* radeon_create_screen(int drmFB, int pciID); +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg); struct pipe_context* radeon_create_context(struct pipe_screen* screen); -- cgit v1.2.3 From 2e5acd24b0421f3824fbe441f4a7062c1f081109 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:32:59 +0200 Subject: gallium: Move the dri2 state tracker since we're about to extend it to dri1. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/Makefile | 28 ++ src/gallium/state_trackers/dri/dri_context.c | 170 ++++++++++++ src/gallium/state_trackers/dri/dri_context.h | 96 +++++++ src/gallium/state_trackers/dri/dri_drawable.c | 325 +++++++++++++++++++++++ src/gallium/state_trackers/dri/dri_drawable.h | 89 +++++++ src/gallium/state_trackers/dri/dri_extensions.c | 119 +++++++++ src/gallium/state_trackers/dri/dri_screen.c | 239 +++++++++++++++++ src/gallium/state_trackers/dri/dri_screen.h | 88 ++++++ src/gallium/state_trackers/dri2/Makefile | 28 -- src/gallium/state_trackers/dri2/dri_context.c | 170 ------------ src/gallium/state_trackers/dri2/dri_context.h | 96 ------- src/gallium/state_trackers/dri2/dri_drawable.c | 325 ----------------------- src/gallium/state_trackers/dri2/dri_drawable.h | 89 ------- src/gallium/state_trackers/dri2/dri_extensions.c | 119 --------- src/gallium/state_trackers/dri2/dri_screen.c | 239 ----------------- src/gallium/state_trackers/dri2/dri_screen.h | 88 ------ src/gallium/winsys/drm/intel/dri2/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri2/Makefile | 2 +- src/gallium/winsys/drm/radeon/dri2/Makefile | 2 +- 19 files changed, 1157 insertions(+), 1157 deletions(-) create mode 100644 src/gallium/state_trackers/dri/Makefile create mode 100644 src/gallium/state_trackers/dri/dri_context.c create mode 100644 src/gallium/state_trackers/dri/dri_context.h create mode 100644 src/gallium/state_trackers/dri/dri_drawable.c create mode 100644 src/gallium/state_trackers/dri/dri_drawable.h create mode 100644 src/gallium/state_trackers/dri/dri_extensions.c create mode 100644 src/gallium/state_trackers/dri/dri_screen.c create mode 100644 src/gallium/state_trackers/dri/dri_screen.h delete mode 100644 src/gallium/state_trackers/dri2/Makefile delete mode 100644 src/gallium/state_trackers/dri2/dri_context.c delete mode 100644 src/gallium/state_trackers/dri2/dri_context.h delete mode 100644 src/gallium/state_trackers/dri2/dri_drawable.c delete mode 100644 src/gallium/state_trackers/dri2/dri_drawable.h delete mode 100644 src/gallium/state_trackers/dri2/dri_extensions.c delete mode 100644 src/gallium/state_trackers/dri2/dri_screen.c delete mode 100644 src/gallium/state_trackers/dri2/dri_screen.h (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile new file mode 100644 index 0000000000..47750e997e --- /dev/null +++ b/src/gallium/state_trackers/dri/Makefile @@ -0,0 +1,28 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = dri2drm + +LIBRARY_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa/main \ + $(shell pkg-config --cflags-only-I libdrm) + + +C_SOURCES = \ + dri_context.c \ + dri_screen.c \ + dri_drawable.c \ + dri_extensions.c + +# $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/vblank.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ + $(TOP)/src/mesa/drivers/common/driverfuncs.c \ + $(TOP)/src/mesa/drivers/dri/common/texmem.c \ + $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c + +include ../../Makefile.template diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c new file mode 100644 index 0000000000..92c26ac70f --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -0,0 +1,170 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" + +#include "dri_drawable.h" + + +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "pipe/p_context.h" + +#include "dri_context.h" + +#include "util/u_memory.h" + + +GLboolean +dri_create_context(const __GLcontextModes *visual, + __DRIcontextPrivate *cPriv, + void *sharedContextPrivate) +{ + __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; + struct dri_screen *screen = dri_screen(sPriv); + struct dri_context *ctx = NULL; + struct st_context *st_share = NULL; + + if (sharedContextPrivate) { + st_share = ((struct dri_context *) sharedContextPrivate)->st; + } + + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto fail; + + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; + ctx->sPriv = sPriv; + + driParseConfigFiles(&ctx->optionCache, + &screen->optionCache, + sPriv->myNum, + "dri"); + + ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); + + if (ctx->pipe == NULL) + goto fail; + + /* used in dri_flush_frontbuffer */ + ctx->pipe->priv = ctx; + + ctx->st = st_create_context(ctx->pipe, visual, st_share); + if (ctx->st == NULL) + goto fail; + + dri_init_extensions(ctx); + + return GL_TRUE; + +fail: + if (ctx && ctx->st) + st_destroy_context(ctx->st); + + if (ctx && ctx->pipe) + ctx->pipe->destroy(ctx->pipe); + + FREE(ctx); + return FALSE; +} + + +void +dri_destroy_context(__DRIcontextPrivate *cPriv) +{ + struct dri_context *ctx = dri_context(cPriv); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + + /* No particular reason to wait for command completion before + * destroying a context, but it is probably worthwhile flushing it + * to avoid having to add code elsewhere to cope with flushing a + * partially destroyed context. + */ + st_flush(ctx->st, 0, NULL); + + if (screen->dummyContext == ctx) + screen->dummyContext = NULL; + + /* Also frees ctx->pipe? + */ + st_destroy_context(ctx->st); + + FREE(ctx); +} + + +GLboolean +dri_unbind_context(__DRIcontextPrivate *cPriv) +{ + struct dri_context *ctx = dri_context(cPriv); + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + /* XXX make_current(NULL)? */ + return GL_TRUE; +} + + +GLboolean +dri_make_current(__DRIcontextPrivate *cPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + struct dri_drawable *draw = dri_drawable(driDrawPriv); + struct dri_drawable *read = dri_drawable(driReadPriv); + + /* This is for situations in which we need a rendering context but + * there may not be any currently bound. + */ + screen->dummyContext = ctx; + + st_make_current(ctx->st, + draw->stfb, + read->stfb); + + /* used in dri_flush_frontbuffer */ + ctx->dPriv = driDrawPriv; + + if (driDrawPriv) + dri_get_buffers(driDrawPriv); + if (driDrawPriv != driReadPriv && driReadPriv) + dri_get_buffers(driReadPriv); + } else { + st_make_current(NULL, NULL, NULL); + } + + return GL_TRUE; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h new file mode 100644 index 0000000000..e910472700 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -0,0 +1,96 @@ +/************************************************************************** + * + * Copyright (C) 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_CONTEXT_H +#define DRI_CONTEXT_H + +#include "pipe/p_compiler.h" +#include "drm.h" +#include "dri_util.h" + + +struct pipe_context; +struct pipe_fence; +struct st_context; +struct dri_drawable; + + +struct dri_context +{ + /* dri */ + __DRIscreenPrivate *sPriv; + __DRIcontextPrivate *cPriv; + __DRIdrawablePrivate *dPriv; + + driOptionCache optionCache; + + /* gallium */ + struct st_context *st; + struct pipe_context *pipe; +}; + + +static INLINE struct dri_context * +dri_context(__DRIcontextPrivate *driContextPriv) +{ + return (struct dri_context *) driContextPriv->driverPrivate; +} + + +/*********************************************************************** + * dri_context.c + */ +void +dri_destroy_context(__DRIcontextPrivate * driContextPriv); + +boolean +dri_unbind_context(__DRIcontextPrivate * driContextPriv); + +boolean +dri_make_current(__DRIcontextPrivate * driContextPriv, + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv); + +boolean +dri_create_context(const __GLcontextModes * visual, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); + + +/*********************************************************************** + * dri_extensions.c + */ +void +dri_init_extensions(struct dri_context *ctx); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c new file mode 100644 index 0000000000..2e3f4099e2 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -0,0 +1,325 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "pipe/p_inlines.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_cb_fbo.h" + +#include "util/u_memory.h" + + +static void +dri_copy_to_front(__DRIdrawablePrivate *dPriv, + struct pipe_surface *from, + int x, int y, unsigned w, unsigned h) +{ + /* TODO send a message to the Xserver to copy to the real front buffer */ +} + + +static struct pipe_surface * +dri_surface_from_handle(struct pipe_screen *screen, + unsigned handle, + enum pipe_format format, + unsigned width, + unsigned height, + unsigned pitch) +{ + struct pipe_surface *surface = NULL; + struct pipe_texture *texture = NULL; + struct pipe_texture templat; + struct pipe_buffer *buf = NULL; + + buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle); + if (!buf) + return NULL; + + memset(&templat, 0, sizeof(templat)); + templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; + templat.target = PIPE_TEXTURE_2D; + templat.last_level = 0; + templat.depth[0] = 1; + templat.format = format; + templat.width[0] = width; + templat.height[0] = height; + pf_get_block(templat.format, &templat.block); + + texture = screen->texture_blanket(screen, + &templat, + &pitch, + buf); + + /* we don't need the buffer from this point on */ + pipe_buffer_reference(&buf, NULL); + + if (!texture) + return NULL; + + surface = screen->get_tex_surface(screen, texture, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + /* we don't need the texture from this point on */ + pipe_texture_reference(&texture, NULL); + return surface; +} + + +/** + * This will be called a drawable is known to have been resized. + */ +void +dri_get_buffers(__DRIdrawablePrivate *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_surface *surface = NULL; + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + __DRIbuffer *buffers = NULL; + __DRIscreen *dri_screen = drawable->sPriv; + __DRIdrawable *dri_drawable = drawable->dPriv; + boolean have_depth = FALSE; + int i, count; + + buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable, + &dri_drawable->w, + &dri_drawable->h, + drawable->attachments, + drawable->num_attachments, + &count, + dri_drawable->loaderPrivate); + + if (buffers == NULL) { + return; + } + + /* set one cliprect to cover the whole dri_drawable */ + dri_drawable->x = 0; + dri_drawable->y = 0; + dri_drawable->backX = 0; + dri_drawable->backY = 0; + dri_drawable->numClipRects = 1; + dri_drawable->pClipRects[0].x1 = 0; + dri_drawable->pClipRects[0].y1 = 0; + dri_drawable->pClipRects[0].x2 = dri_drawable->w; + dri_drawable->pClipRects[0].y2 = dri_drawable->h; + dri_drawable->numBackClipRects = 1; + dri_drawable->pBackClipRects[0].x1 = 0; + dri_drawable->pBackClipRects[0].y1 = 0; + dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; + dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; + + for (i = 0; i < count; i++) { + enum pipe_format format = 0; + int index = 0; + + switch (buffers[i].attachment) { + case __DRI_BUFFER_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_FAKE_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_BACK_LEFT: + index = ST_SURFACE_BACK_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_DEPTH: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_STENCIL: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_ACCUM: + default: + assert(0); + } + assert(buffers[i].cpp == 4); + + if (index == ST_SURFACE_DEPTH) { + if (have_depth) + continue; + else + have_depth = TRUE; + } + + surface = dri_surface_from_handle(screen, + buffers[i].name, + format, + dri_drawable->w, + dri_drawable->h, + buffers[i].pitch); + + st_set_framebuffer_surface(drawable->stfb, index, surface); + pipe_surface_reference(&surface, NULL); + } + /* this needed, or else the state tracker fails to pick the new buffers */ + st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); +} + + +void +dri_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private) +{ + struct dri_context *ctx = (struct dri_context *)context_private; + dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height); +} + + +void +dri_swap_buffers(__DRIdrawablePrivate * dPriv) +{ + /* not needed for dri2 */ + assert(0); +} + + +void +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) +{ + /* not needed for dri2 */ + assert(0); +} + + +/** + * This is called when we need to set up GL rendering to a new X window. + */ +boolean +dri_create_buffer(__DRIscreenPrivate *sPriv, + __DRIdrawablePrivate *dPriv, + const __GLcontextModes *visual, + boolean isPixmap) +{ + enum pipe_format colorFormat, depthFormat, stencilFormat; + struct dri_screen *screen = sPriv->private; + struct dri_drawable *drawable = NULL; + struct pipe_screen *pscreen = screen->pipe_screen; + int i; + + if (isPixmap) + goto fail; /* not implemented */ + + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto fail; + + /* XXX: todo: use the pipe_screen queries to figure out which + * render targets are supportable. + */ + assert(visual->redBits == 8); + assert(visual->depthBits == 24 || visual->depthBits == 0); + assert(visual->stencilBits == 8 || visual->stencilBits == 0); + + colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + + if (visual->depthBits) { + if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + depthFormat = PIPE_FORMAT_Z24S8_UNORM; + else + depthFormat = PIPE_FORMAT_S8Z24_UNORM; + } else + depthFormat = PIPE_FORMAT_NONE; + + if (visual->stencilBits) { + if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + stencilFormat = PIPE_FORMAT_Z24S8_UNORM; + else + stencilFormat = PIPE_FORMAT_S8Z24_UNORM; + } else + stencilFormat = PIPE_FORMAT_NONE; + + drawable->stfb = st_create_framebuffer(visual, + colorFormat, + depthFormat, + stencilFormat, + dPriv->w, + dPriv->h, + (void*) drawable); + if (drawable->stfb == NULL) + goto fail; + + drawable->sPriv = sPriv; + drawable->dPriv = dPriv; + dPriv->driverPrivate = (void *) drawable; + + /* setup dri2 buffers information */ + i = 0; + drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; +#if 0 + /* TODO incase of double buffer visual, delay fake creation */ + drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; +#endif + if (visual->doubleBufferMode) + drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; + if (visual->depthBits) + drawable->attachments[i++] = __DRI_BUFFER_DEPTH; + if (visual->stencilBits) + drawable->attachments[i++] = __DRI_BUFFER_STENCIL; + drawable->num_attachments = i; + + return GL_TRUE; +fail: + FREE(drawable); + return GL_FALSE; +} + + +void +dri_destroy_buffer(__DRIdrawablePrivate *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + + st_unreference_framebuffer(drawable->stfb); + + FREE(drawable); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h new file mode 100644 index 0000000000..185c657b35 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -0,0 +1,89 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef DRI_DRAWABLE_H +#define DRI_DRAWABLE_H + +#include "pipe/p_compiler.h" + +struct pipe_surface; +struct pipe_fence; +struct st_framebuffer; + + +struct dri_drawable +{ + /* dri */ + __DRIdrawablePrivate *dPriv; + __DRIscreenPrivate *sPriv; + + unsigned attachments[8]; + unsigned num_attachments; + + /* gallium */ + struct st_framebuffer *stfb; +}; + + +static INLINE struct dri_drawable * +dri_drawable(__DRIdrawablePrivate * driDrawPriv) +{ + return (struct dri_drawable *) driDrawPriv->driverPrivate; +} + + +/*********************************************************************** + * dri_drawable.c + */ +boolean +dri_create_buffer(__DRIscreenPrivate *sPriv, + __DRIdrawablePrivate *dPriv, + const __GLcontextModes *visual, + boolean isPixmap); + +void +dri_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private); + +void +dri_swap_buffers(__DRIdrawablePrivate * dPriv); + +void +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, + int x, int y, + int w, int h); + +void +dri_get_buffers(__DRIdrawablePrivate * dPriv); + +void +dri_destroy_buffer(__DRIdrawablePrivate *dPriv); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c new file mode 100644 index 0000000000..732d1e89b0 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -0,0 +1,119 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "state_tracker/st_context.h" + +#define need_GL_ARB_multisample +#define need_GL_ARB_occlusion_query +#define need_GL_ARB_point_parameters +#define need_GL_ARB_texture_compression +#define need_GL_ARB_vertex_buffer_object +#define need_GL_ARB_vertex_program +#define need_GL_ARB_window_pos +#define need_GL_EXT_blend_color +#define need_GL_EXT_blend_equation_separate +#define need_GL_EXT_blend_func_separate +#define need_GL_EXT_blend_minmax +#define need_GL_EXT_cull_vertex +#define need_GL_EXT_fog_coord +#define need_GL_EXT_framebuffer_object +#define need_GL_EXT_multi_draw_arrays +#define need_GL_EXT_secondary_color +#define need_GL_NV_vertex_program +#include "extension_helper.h" + + +/** + * Extension strings exported by the driver. + */ +const struct dri_extension card_extensions[] = { + {"GL_ARB_multisample", GL_ARB_multisample_functions}, + {"GL_ARB_multitexture", NULL}, + {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, + {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, + {"GL_ARB_texture_border_clamp", NULL}, + {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, + {"GL_ARB_texture_cube_map", NULL}, + {"GL_ARB_texture_env_add", NULL}, + {"GL_ARB_texture_env_combine", NULL}, + {"GL_ARB_texture_env_dot3", NULL}, + {"GL_ARB_texture_mirrored_repeat", NULL}, + {"GL_ARB_texture_rectangle", NULL}, + {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, + {"GL_ARB_pixel_buffer_object", NULL}, + {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, + {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, + {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, + {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, + {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, + {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, + {"GL_EXT_blend_subtract", NULL}, + {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, + {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, + {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, + {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, + {"GL_EXT_packed_depth_stencil", NULL}, + {"GL_EXT_pixel_buffer_object", NULL}, + {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, + {"GL_EXT_stencil_wrap", NULL}, + {"GL_EXT_texture_edge_clamp", NULL}, + {"GL_EXT_texture_env_combine", NULL}, + {"GL_EXT_texture_env_dot3", NULL}, + {"GL_EXT_texture_filter_anisotropic", NULL}, + {"GL_EXT_texture_lod_bias", NULL}, + {"GL_3DFX_texture_compression_FXT1", NULL}, + {"GL_APPLE_client_storage", NULL}, + {"GL_MESA_pack_invert", NULL}, + {"GL_MESA_ycbcr_texture", NULL}, + {"GL_NV_blend_square", NULL}, + {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, + {"GL_NV_vertex_program1_1", NULL}, + {"GL_SGIS_generate_mipmap", NULL }, + {NULL, NULL} +}; + + +void +dri_init_extensions(struct dri_context *ctx) +{ + /* The card_extensions list should be pruned according to the + * capabilities of the pipe_screen. This is actually something + * that can/should be done inside st_create_context(). + */ + if (ctx) + driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); + else + driInitExtensions(NULL, card_extensions, GL_FALSE); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c new file mode 100644 index 0000000000..ab33003f51 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -0,0 +1,239 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "utils.h" +#include "vblank.h" +#include "xmlpool.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "pipe/p_inlines.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_cb_fbo.h" + + +PUBLIC const char __driConfigOptions[] = + DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) + DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY + /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/ + DRI_CONF_ALLOW_LARGE_TEXTURES(1) + DRI_CONF_SECTION_END DRI_CONF_END; + + +const uint __driNConfigOptions = 3; + + +static const __DRIextension *dri_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL +}; + +static const __DRIconfig ** +dri_fill_in_modes(__DRIscreenPrivate *psp, + unsigned pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer) +{ + __DRIconfig **configs; + __GLcontextModes *m; + unsigned num_modes; + uint8_t depth_bits_array[3]; + uint8_t stencil_bits_array[3]; + uint8_t msaa_samples_array[1]; + unsigned depth_buffer_factor; + unsigned back_buffer_factor; + unsigned msaa_samples_factor; + GLenum fb_format; + GLenum fb_type; + int i; + + static const GLenum back_buffer_modes[] = { + GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML + }; + + /* TODO probe the hardware of what is supports */ + depth_bits_array[0] = 0; + depth_bits_array[1] = 24; + depth_bits_array[2] = 24; + + stencil_bits_array[0] = 0; /* no depth or stencil */ + stencil_bits_array[1] = 0; /* z24x8 */ + stencil_bits_array[2] = 8; /* z24s8 */ + + msaa_samples_array[0] = 0; + + depth_buffer_factor = 3; + back_buffer_factor = 3; + msaa_samples_factor = 1; + + num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; + + if (pixel_bits == 16) { + fb_format = GL_RGB; + fb_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + fb_format = GL_BGRA; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + } + + configs = driCreateConfigs(fb_format, fb_type, + depth_bits_array, + stencil_bits_array, depth_buffer_factor, + back_buffer_modes, back_buffer_factor, + msaa_samples_array, msaa_samples_factor); + if (configs == NULL) { + debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); + return NULL; + } + + for (i = 0; configs[i]; i++) { + m = &configs[i]->modes; + if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { + m->visualRating = GLX_SLOW_CONFIG; + } + } + + return (const const __DRIconfig **) configs; +} + + +/** + * Get information about previous buffer swaps. + */ +int +dri_get_swap_info(__DRIdrawablePrivate * dPriv, + __DRIswapInfo * sInfo) +{ + if (dPriv == NULL || + dPriv->driverPrivate == NULL || + sInfo == NULL) + return -1; + else + return 0; +} + + +/** + * NULL stub for old dri loaders + */ +const __DRIconfig ** +dri_init_screen(__DRIscreenPrivate *sPriv) +{ + return NULL; +} + + +/** + * This is the driver specific part of the createNewScreen entry point. + * + * Returns the __GLcontextModes supported by this driver. + */ +const __DRIconfig ** +dri_init_screen2(__DRIscreenPrivate *sPriv) +{ + struct dri_screen *screen; + + /* Set up dispatch table to cope with all known extensions */ + dri_init_extensions(NULL); + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + goto fail; + + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + sPriv->private = (void *) screen; + sPriv->extensions = dri_screen_extensions; + + + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); + if (!screen->pipe_screen) { + debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + goto fail; + } + + /* We need to hook in here */ + screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; + + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, + __driNConfigOptions); + + return dri_fill_in_modes(sPriv, + 4 * 8, + 24, + 8, + 1); +fail: + return NULL; +} + + +void +dri_destroy_screen(__DRIscreenPrivate * sPriv) +{ + struct dri_screen *screen = dri_screen(sPriv); + + screen->pipe_screen->destroy(screen->pipe_screen); + FREE(screen); + sPriv->private = NULL; +} + + +PUBLIC const struct __DriverAPIRec driDriverAPI = { + .InitScreen = dri_init_screen, /* not supported but exported */ + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .SwapBuffers = dri_swap_buffers, /* not supported but exported */ + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + .GetSwapInfo = dri_get_swap_info, + .GetDrawableMSC = driDrawableGetMSC32, + .WaitForMSC = driWaitForMSC32, + .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */ + .InitScreen2 = dri_init_screen2, +}; + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h new file mode 100644 index 0000000000..3751ec6121 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -0,0 +1,88 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_SCREEN_H +#define DRI_SCREEN_H + +#include "dri_util.h" +#include "xmlconfig.h" + +#include "pipe/p_compiler.h" + +struct dri_screen +{ + /* dri */ + __DRIscreenPrivate *sPriv; + + /** + * Configuration cache with default values for all contexts + */ + driOptionCache optionCache; + + /** + * Temporary(?) context to use for SwapBuffers or other situations in + * which we need a rendering context, but none is currently bound. + */ + struct dri_context *dummyContext; + + /* drm */ + int fd; + + /* gallium */ + struct pipe_winsys *pipe_winsys; + struct pipe_screen *pipe_screen; +}; + + +/** cast wrapper */ +static INLINE struct dri_screen * +dri_screen(__DRIscreenPrivate *sPriv) +{ + return (struct dri_screen *) sPriv->private; +} + + +/*********************************************************************** + * dri_screen.c + */ +const __DRIconfig ** +dri_init_screen2(__DRIscreenPrivate *sPriv); + +void +dri_destroy_screen(__DRIscreenPrivate * sPriv); + +int +dri_get_swap_info(__DRIdrawablePrivate * dPriv, + __DRIswapInfo * sInfo); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/Makefile b/src/gallium/state_trackers/dri2/Makefile deleted file mode 100644 index 47750e997e..0000000000 --- a/src/gallium/state_trackers/dri2/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = dri2drm - -LIBRARY_INCLUDES = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa/main \ - $(shell pkg-config --cflags-only-I libdrm) - - -C_SOURCES = \ - dri_context.c \ - dri_screen.c \ - dri_drawable.c \ - dri_extensions.c - -# $(TOP)/src/mesa/drivers/dri/common/utils.c \ - $(TOP)/src/mesa/drivers/dri/common/vblank.c \ - $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ - $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ - $(TOP)/src/mesa/drivers/common/driverfuncs.c \ - $(TOP)/src/mesa/drivers/dri/common/texmem.c \ - $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c - -include ../../Makefile.template diff --git a/src/gallium/state_trackers/dri2/dri_context.c b/src/gallium/state_trackers/dri2/dri_context.c deleted file mode 100644 index 92c26ac70f..0000000000 --- a/src/gallium/state_trackers/dri2/dri_context.c +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" - -#include "dri_drawable.h" - - -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" -#include "pipe/p_context.h" - -#include "dri_context.h" - -#include "util/u_memory.h" - - -GLboolean -dri_create_context(const __GLcontextModes *visual, - __DRIcontextPrivate *cPriv, - void *sharedContextPrivate) -{ - __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; - struct dri_screen *screen = dri_screen(sPriv); - struct dri_context *ctx = NULL; - struct st_context *st_share = NULL; - - if (sharedContextPrivate) { - st_share = ((struct dri_context *) sharedContextPrivate)->st; - } - - ctx = CALLOC_STRUCT(dri_context); - if (ctx == NULL) - goto fail; - - cPriv->driverPrivate = ctx; - ctx->cPriv = cPriv; - ctx->sPriv = sPriv; - - driParseConfigFiles(&ctx->optionCache, - &screen->optionCache, - sPriv->myNum, - "dri"); - - ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); - - if (ctx->pipe == NULL) - goto fail; - - /* used in dri_flush_frontbuffer */ - ctx->pipe->priv = ctx; - - ctx->st = st_create_context(ctx->pipe, visual, st_share); - if (ctx->st == NULL) - goto fail; - - dri_init_extensions(ctx); - - return GL_TRUE; - -fail: - if (ctx && ctx->st) - st_destroy_context(ctx->st); - - if (ctx && ctx->pipe) - ctx->pipe->destroy(ctx->pipe); - - FREE(ctx); - return FALSE; -} - - -void -dri_destroy_context(__DRIcontextPrivate *cPriv) -{ - struct dri_context *ctx = dri_context(cPriv); - struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); - - /* No particular reason to wait for command completion before - * destroying a context, but it is probably worthwhile flushing it - * to avoid having to add code elsewhere to cope with flushing a - * partially destroyed context. - */ - st_flush(ctx->st, 0, NULL); - - if (screen->dummyContext == ctx) - screen->dummyContext = NULL; - - /* Also frees ctx->pipe? - */ - st_destroy_context(ctx->st); - - FREE(ctx); -} - - -GLboolean -dri_unbind_context(__DRIcontextPrivate *cPriv) -{ - struct dri_context *ctx = dri_context(cPriv); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* XXX make_current(NULL)? */ - return GL_TRUE; -} - - -GLboolean -dri_make_current(__DRIcontextPrivate *cPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - if (cPriv) { - struct dri_context *ctx = dri_context(cPriv); - struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); - struct dri_drawable *draw = dri_drawable(driDrawPriv); - struct dri_drawable *read = dri_drawable(driReadPriv); - - /* This is for situations in which we need a rendering context but - * there may not be any currently bound. - */ - screen->dummyContext = ctx; - - st_make_current(ctx->st, - draw->stfb, - read->stfb); - - /* used in dri_flush_frontbuffer */ - ctx->dPriv = driDrawPriv; - - if (driDrawPriv) - dri_get_buffers(driDrawPriv); - if (driDrawPriv != driReadPriv && driReadPriv) - dri_get_buffers(driReadPriv); - } else { - st_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_context.h b/src/gallium/state_trackers/dri2/dri_context.h deleted file mode 100644 index e910472700..0000000000 --- a/src/gallium/state_trackers/dri2/dri_context.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** - * - * Copyright (C) 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_CONTEXT_H -#define DRI_CONTEXT_H - -#include "pipe/p_compiler.h" -#include "drm.h" -#include "dri_util.h" - - -struct pipe_context; -struct pipe_fence; -struct st_context; -struct dri_drawable; - - -struct dri_context -{ - /* dri */ - __DRIscreenPrivate *sPriv; - __DRIcontextPrivate *cPriv; - __DRIdrawablePrivate *dPriv; - - driOptionCache optionCache; - - /* gallium */ - struct st_context *st; - struct pipe_context *pipe; -}; - - -static INLINE struct dri_context * -dri_context(__DRIcontextPrivate *driContextPriv) -{ - return (struct dri_context *) driContextPriv->driverPrivate; -} - - -/*********************************************************************** - * dri_context.c - */ -void -dri_destroy_context(__DRIcontextPrivate * driContextPriv); - -boolean -dri_unbind_context(__DRIcontextPrivate * driContextPriv); - -boolean -dri_make_current(__DRIcontextPrivate * driContextPriv, - __DRIdrawablePrivate * driDrawPriv, - __DRIdrawablePrivate * driReadPriv); - -boolean -dri_create_context(const __GLcontextModes * visual, - __DRIcontextPrivate * driContextPriv, - void *sharedContextPrivate); - - -/*********************************************************************** - * dri_extensions.c - */ -void -dri_init_extensions(struct dri_context *ctx); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_drawable.c b/src/gallium/state_trackers/dri2/dri_drawable.c deleted file mode 100644 index 2e3f4099e2..0000000000 --- a/src/gallium/state_trackers/dri2/dri_drawable.c +++ /dev/null @@ -1,325 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_inlines.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_cb_fbo.h" - -#include "util/u_memory.h" - - -static void -dri_copy_to_front(__DRIdrawablePrivate *dPriv, - struct pipe_surface *from, - int x, int y, unsigned w, unsigned h) -{ - /* TODO send a message to the Xserver to copy to the real front buffer */ -} - - -static struct pipe_surface * -dri_surface_from_handle(struct pipe_screen *screen, - unsigned handle, - enum pipe_format format, - unsigned width, - unsigned height, - unsigned pitch) -{ - struct pipe_surface *surface = NULL; - struct pipe_texture *texture = NULL; - struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - - buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle); - if (!buf) - return NULL; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth[0] = 1; - templat.format = format; - templat.width[0] = width; - templat.height[0] = height; - pf_get_block(templat.format, &templat.block); - - texture = screen->texture_blanket(screen, - &templat, - &pitch, - buf); - - /* we don't need the buffer from this point on */ - pipe_buffer_reference(&buf, NULL); - - if (!texture) - return NULL; - - surface = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* we don't need the texture from this point on */ - pipe_texture_reference(&texture, NULL); - return surface; -} - - -/** - * This will be called a drawable is known to have been resized. - */ -void -dri_get_buffers(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *surface = NULL; - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; - __DRIbuffer *buffers = NULL; - __DRIscreen *dri_screen = drawable->sPriv; - __DRIdrawable *dri_drawable = drawable->dPriv; - boolean have_depth = FALSE; - int i, count; - - buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable, - &dri_drawable->w, - &dri_drawable->h, - drawable->attachments, - drawable->num_attachments, - &count, - dri_drawable->loaderPrivate); - - if (buffers == NULL) { - return; - } - - /* set one cliprect to cover the whole dri_drawable */ - dri_drawable->x = 0; - dri_drawable->y = 0; - dri_drawable->backX = 0; - dri_drawable->backY = 0; - dri_drawable->numClipRects = 1; - dri_drawable->pClipRects[0].x1 = 0; - dri_drawable->pClipRects[0].y1 = 0; - dri_drawable->pClipRects[0].x2 = dri_drawable->w; - dri_drawable->pClipRects[0].y2 = dri_drawable->h; - dri_drawable->numBackClipRects = 1; - dri_drawable->pBackClipRects[0].x1 = 0; - dri_drawable->pBackClipRects[0].y1 = 0; - dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; - dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; - - for (i = 0; i < count; i++) { - enum pipe_format format = 0; - int index = 0; - - switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_FAKE_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_BACK_LEFT: - index = ST_SURFACE_BACK_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_DEPTH: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_STENCIL: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_ACCUM: - default: - assert(0); - } - assert(buffers[i].cpp == 4); - - if (index == ST_SURFACE_DEPTH) { - if (have_depth) - continue; - else - have_depth = TRUE; - } - - surface = dri_surface_from_handle(screen, - buffers[i].name, - format, - dri_drawable->w, - dri_drawable->h, - buffers[i].pitch); - - st_set_framebuffer_surface(drawable->stfb, index, surface); - pipe_surface_reference(&surface, NULL); - } - /* this needed, or else the state tracker fails to pick the new buffers */ - st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); -} - - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private) -{ - struct dri_context *ctx = (struct dri_context *)context_private; - dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height); -} - - -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv) -{ - /* not needed for dri2 */ - assert(0); -} - - -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) -{ - /* not needed for dri2 */ - assert(0); -} - - -/** - * This is called when we need to set up GL rendering to a new X window. - */ -boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap) -{ - enum pipe_format colorFormat, depthFormat, stencilFormat; - struct dri_screen *screen = sPriv->private; - struct dri_drawable *drawable = NULL; - struct pipe_screen *pscreen = screen->pipe_screen; - int i; - - if (isPixmap) - goto fail; /* not implemented */ - - drawable = CALLOC_STRUCT(dri_drawable); - if (drawable == NULL) - goto fail; - - /* XXX: todo: use the pipe_screen queries to figure out which - * render targets are supportable. - */ - assert(visual->redBits == 8); - assert(visual->depthBits == 24 || visual->depthBits == 0); - assert(visual->stencilBits == 8 || visual->stencilBits == 0); - - colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; - - if (visual->depthBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - depthFormat = PIPE_FORMAT_Z24S8_UNORM; - else - depthFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - depthFormat = PIPE_FORMAT_NONE; - - if (visual->stencilBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - stencilFormat = PIPE_FORMAT_Z24S8_UNORM; - else - stencilFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - stencilFormat = PIPE_FORMAT_NONE; - - drawable->stfb = st_create_framebuffer(visual, - colorFormat, - depthFormat, - stencilFormat, - dPriv->w, - dPriv->h, - (void*) drawable); - if (drawable->stfb == NULL) - goto fail; - - drawable->sPriv = sPriv; - drawable->dPriv = dPriv; - dPriv->driverPrivate = (void *) drawable; - - /* setup dri2 buffers information */ - i = 0; - drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; -#if 0 - /* TODO incase of double buffer visual, delay fake creation */ - drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; -#endif - if (visual->doubleBufferMode) - drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; - if (visual->depthBits) - drawable->attachments[i++] = __DRI_BUFFER_DEPTH; - if (visual->stencilBits) - drawable->attachments[i++] = __DRI_BUFFER_STENCIL; - drawable->num_attachments = i; - - return GL_TRUE; -fail: - FREE(drawable); - return GL_FALSE; -} - - -void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - - st_unreference_framebuffer(drawable->stfb); - - FREE(drawable); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_drawable.h b/src/gallium/state_trackers/dri2/dri_drawable.h deleted file mode 100644 index 185c657b35..0000000000 --- a/src/gallium/state_trackers/dri2/dri_drawable.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef DRI_DRAWABLE_H -#define DRI_DRAWABLE_H - -#include "pipe/p_compiler.h" - -struct pipe_surface; -struct pipe_fence; -struct st_framebuffer; - - -struct dri_drawable -{ - /* dri */ - __DRIdrawablePrivate *dPriv; - __DRIscreenPrivate *sPriv; - - unsigned attachments[8]; - unsigned num_attachments; - - /* gallium */ - struct st_framebuffer *stfb; -}; - - -static INLINE struct dri_drawable * -dri_drawable(__DRIdrawablePrivate * driDrawPriv) -{ - return (struct dri_drawable *) driDrawPriv->driverPrivate; -} - - -/*********************************************************************** - * dri_drawable.c - */ -boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap); - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private); - -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv); - -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, - int x, int y, - int w, int h); - -void -dri_get_buffers(__DRIdrawablePrivate * dPriv); - -void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_extensions.c b/src/gallium/state_trackers/dri2/dri_extensions.c deleted file mode 100644 index 732d1e89b0..0000000000 --- a/src/gallium/state_trackers/dri2/dri_extensions.c +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "state_tracker/st_context.h" - -#define need_GL_ARB_multisample -#define need_GL_ARB_occlusion_query -#define need_GL_ARB_point_parameters -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_buffer_object -#define need_GL_ARB_vertex_program -#define need_GL_ARB_window_pos -#define need_GL_EXT_blend_color -#define need_GL_EXT_blend_equation_separate -#define need_GL_EXT_blend_func_separate -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_cull_vertex -#define need_GL_EXT_fog_coord -#define need_GL_EXT_framebuffer_object -#define need_GL_EXT_multi_draw_arrays -#define need_GL_EXT_secondary_color -#define need_GL_NV_vertex_program -#include "extension_helper.h" - - -/** - * Extension strings exported by the driver. - */ -const struct dri_extension card_extensions[] = { - {"GL_ARB_multisample", GL_ARB_multisample_functions}, - {"GL_ARB_multitexture", NULL}, - {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, - {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, - {"GL_ARB_texture_border_clamp", NULL}, - {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, - {"GL_ARB_texture_cube_map", NULL}, - {"GL_ARB_texture_env_add", NULL}, - {"GL_ARB_texture_env_combine", NULL}, - {"GL_ARB_texture_env_dot3", NULL}, - {"GL_ARB_texture_mirrored_repeat", NULL}, - {"GL_ARB_texture_rectangle", NULL}, - {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, - {"GL_ARB_pixel_buffer_object", NULL}, - {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, - {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, - {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, - {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, - {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, - {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, - {"GL_EXT_blend_subtract", NULL}, - {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, - {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, - {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, - {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, - {"GL_EXT_packed_depth_stencil", NULL}, - {"GL_EXT_pixel_buffer_object", NULL}, - {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, - {"GL_EXT_stencil_wrap", NULL}, - {"GL_EXT_texture_edge_clamp", NULL}, - {"GL_EXT_texture_env_combine", NULL}, - {"GL_EXT_texture_env_dot3", NULL}, - {"GL_EXT_texture_filter_anisotropic", NULL}, - {"GL_EXT_texture_lod_bias", NULL}, - {"GL_3DFX_texture_compression_FXT1", NULL}, - {"GL_APPLE_client_storage", NULL}, - {"GL_MESA_pack_invert", NULL}, - {"GL_MESA_ycbcr_texture", NULL}, - {"GL_NV_blend_square", NULL}, - {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, - {"GL_NV_vertex_program1_1", NULL}, - {"GL_SGIS_generate_mipmap", NULL }, - {NULL, NULL} -}; - - -void -dri_init_extensions(struct dri_context *ctx) -{ - /* The card_extensions list should be pruned according to the - * capabilities of the pipe_screen. This is actually something - * that can/should be done inside st_create_context(). - */ - if (ctx) - driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); - else - driInitExtensions(NULL, card_extensions, GL_FALSE); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c deleted file mode 100644 index ab33003f51..0000000000 --- a/src/gallium/state_trackers/dri2/dri_screen.c +++ /dev/null @@ -1,239 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "utils.h" -#include "vblank.h" -#include "xmlpool.h" - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_inlines.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_cb_fbo.h" - - -PUBLIC const char __driConfigOptions[] = - DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY - /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/ - DRI_CONF_ALLOW_LARGE_TEXTURES(1) - DRI_CONF_SECTION_END DRI_CONF_END; - - -const uint __driNConfigOptions = 3; - - -static const __DRIextension *dri_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; - -static const __DRIconfig ** -dri_fill_in_modes(__DRIscreenPrivate *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) -{ - __DRIconfig **configs; - __GLcontextModes *m; - unsigned num_modes; - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; - uint8_t msaa_samples_array[1]; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - unsigned msaa_samples_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML - }; - - /* TODO probe the hardware of what is supports */ - depth_bits_array[0] = 0; - depth_bits_array[1] = 24; - depth_bits_array[2] = 24; - - stencil_bits_array[0] = 0; /* no depth or stencil */ - stencil_bits_array[1] = 0; /* z24x8 */ - stencil_bits_array[2] = 8; /* z24s8 */ - - msaa_samples_array[0] = 0; - - depth_buffer_factor = 3; - back_buffer_factor = 3; - msaa_samples_factor = 1; - - num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, - stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, msaa_samples_factor); - if (configs == NULL) { - debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); - return NULL; - } - - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const const __DRIconfig **) configs; -} - - -/** - * Get information about previous buffer swaps. - */ -int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo) -{ - if (dPriv == NULL || - dPriv->driverPrivate == NULL || - sInfo == NULL) - return -1; - else - return 0; -} - - -/** - * NULL stub for old dri loaders - */ -const __DRIconfig ** -dri_init_screen(__DRIscreenPrivate *sPriv) -{ - return NULL; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * Returns the __GLcontextModes supported by this driver. - */ -const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv) -{ - struct dri_screen *screen; - - /* Set up dispatch table to cope with all known extensions */ - dri_init_extensions(NULL); - - screen = CALLOC_STRUCT(dri_screen); - if (!screen) - goto fail; - - screen->sPriv = sPriv; - screen->fd = sPriv->fd; - sPriv->private = (void *) screen; - sPriv->extensions = dri_screen_extensions; - - - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); - goto fail; - } - - /* We need to hook in here */ - screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, - __driNConfigOptions); - - return dri_fill_in_modes(sPriv, - 4 * 8, - 24, - 8, - 1); -fail: - return NULL; -} - - -void -dri_destroy_screen(__DRIscreenPrivate * sPriv) -{ - struct dri_screen *screen = dri_screen(sPriv); - - screen->pipe_screen->destroy(screen->pipe_screen); - FREE(screen); - sPriv->private = NULL; -} - - -PUBLIC const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, /* not supported but exported */ - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, /* not supported but exported */ - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .GetSwapInfo = dri_get_swap_info, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */ - .InitScreen2 = dri_init_screen2, -}; - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h deleted file mode 100644 index 3751ec6121..0000000000 --- a/src/gallium/state_trackers/dri2/dri_screen.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_SCREEN_H -#define DRI_SCREEN_H - -#include "dri_util.h" -#include "xmlconfig.h" - -#include "pipe/p_compiler.h" - -struct dri_screen -{ - /* dri */ - __DRIscreenPrivate *sPriv; - - /** - * Configuration cache with default values for all contexts - */ - driOptionCache optionCache; - - /** - * Temporary(?) context to use for SwapBuffers or other situations in - * which we need a rendering context, but none is currently bound. - */ - struct dri_context *dummyContext; - - /* drm */ - int fd; - - /* gallium */ - struct pipe_winsys *pipe_winsys; - struct pipe_screen *pipe_screen; -}; - - -/** cast wrapper */ -static INLINE struct dri_screen * -dri_screen(__DRIscreenPrivate *sPriv) -{ - return (struct dri_screen *) sPriv->private; -} - - -/*********************************************************************** - * dri_screen.c - */ -const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv); - -void -dri_destroy_screen(__DRIscreenPrivate * sPriv); - -int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile index e7c57afc34..286ef08d5b 100644 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ b/src/gallium/winsys/drm/intel/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile index 728870d2e1..5e5efbcb11 100644 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri2.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nv04/libnv04.a \ $(TOP)/src/gallium/drivers/nv10/libnv10.a \ diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile index f471c44349..58a87dae18 100644 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ b/src/gallium/winsys/drm/radeon/dri2/Makefile @@ -7,7 +7,7 @@ LIBNAME = radeon_dri.so MINIGLX_SOURCES = PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -- cgit v1.2.3 From a70c4f352e8e7aea0b130fd1285352bbf89503b5 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:43:06 +0200 Subject: gallium: Add a dri1 api that a driver needs to implement on top of the drm api to support dri1. Signed-off-by: Thomas Hellstrom --- src/gallium/include/state_tracker/dri1_api.h | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/gallium/include/state_tracker/dri1_api.h (limited to 'src/gallium') diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h new file mode 100644 index 0000000000..b173ba3683 --- /dev/null +++ b/src/gallium/include/state_tracker/dri1_api.h @@ -0,0 +1,82 @@ +#ifndef _DRI1_API_H_ +#define _DRI1_API_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_format.h" + +#include "state_tracker/drm_api.h" + +#include + +struct pipe_screen; +struct pipe_winsys; +struct pipe_buffer; +struct pipe_context; +struct pipe_texture; + +struct dri1_api_version +{ + int major; + int minor; + int patch_level; +}; + +/** + * This callback struct is intended for drivers that need to take + * the hardware lock on command submission. + */ + +struct dri1_api_lock_funcs +{ + void (*lock) (struct pipe_context * pipe); + void (*unlock) (struct pipe_context * locked_pipe); + boolean(*is_locked) (struct pipe_context * locked_pipe); + boolean(*is_lock_lost) (struct pipe_context * locked_pipe); + void (*clear_lost_lock) (struct pipe_context * locked_pipe); +}; + +struct dri1_api +{ + /** + * For flushing to the front buffer. A driver should implement one and only + * one of the functions below. The present_locked functions allows a dri1 + * driver to pageflip. + */ + + /*@{ */ + + struct pipe_surface *(*front_srf_locked) (struct pipe_context * + locked_pipe); + + void (*present_locked) (struct pipe_context * locked_pipe, + struct pipe_surface * surf, + const struct drm_clip_rect * rect, + unsigned int num_clip, + int x_draw, int y_draw, + const struct drm_clip_rect * src_bbox, + struct pipe_fence_handle ** fence); + /*@} */ +}; + +struct dri1_create_screen_arg +{ + struct drm_create_screen_arg base; + + struct dri1_api_lock_funcs *lf; + void *ddx_info; + int ddx_info_size; + void *sarea; + + struct dri1_api_version ddx_version; + struct dri1_api_version dri_version; + struct dri1_api_version drm_version; + + /* + * out parameters; + */ + + struct dri1_api *api; +}; + +#endif -- cgit v1.2.3 From ca1f5f7e6c05e34cfe8ef10f29aa19f5547311e6 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:49:39 +0200 Subject: gallium: Update the dri2 state tracker to support dri1. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_context.c | 91 ++++++-- src/gallium/state_trackers/dri/dri_context.h | 36 ++- src/gallium/state_trackers/dri/dri_drawable.c | 318 ++++++++++++++++++++++++-- src/gallium/state_trackers/dri/dri_drawable.h | 18 +- src/gallium/state_trackers/dri/dri_screen.c | 87 +++++-- src/gallium/state_trackers/dri/dri_screen.h | 12 +- 6 files changed, 507 insertions(+), 55 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 92c26ac70f..a45fb541fd 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -32,9 +32,8 @@ #include "dri_screen.h" #include "dri_drawable.h" - - #include "state_tracker/drm_api.h" +#include "state_tracker/dri1_api.h" #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "pipe/p_context.h" @@ -44,6 +43,7 @@ #include "util/u_memory.h" + GLboolean dri_create_context(const __GLcontextModes *visual, __DRIcontextPrivate *cPriv, @@ -65,6 +65,9 @@ dri_create_context(const __GLcontextModes *visual, cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; ctx->sPriv = sPriv; + ctx->lock = screen->drmLock; + ctx->d_stamp = -1; + ctx->r_stamp = -1; driParseConfigFiles(&ctx->optionCache, &screen->optionCache, @@ -126,13 +129,22 @@ dri_destroy_context(__DRIcontextPrivate *cPriv) GLboolean dri_unbind_context(__DRIcontextPrivate *cPriv) { - struct dri_context *ctx = dri_context(cPriv); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* XXX make_current(NULL)? */ + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + + if (--ctx->bind_count == 0) { + GET_CURRENT_CONTEXT(curGLCtx); + + if (ctx->st == curGLCtx->st) { + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_make_current(NULL, NULL, NULL); + } + } + } + return GL_TRUE; } - GLboolean dri_make_current(__DRIcontextPrivate *cPriv, __DRIdrawablePrivate *driDrawPriv, @@ -143,23 +155,32 @@ dri_make_current(__DRIcontextPrivate *cPriv, struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); struct dri_drawable *draw = dri_drawable(driDrawPriv); struct dri_drawable *read = dri_drawable(driReadPriv); + GET_CURRENT_CONTEXT(oldGLCtx); + + if (oldGLCtx && oldGLCtx->st != ctx->st) + st_flush(oldGLCtx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + ++ctx->bind_count; /* This is for situations in which we need a rendering context but * there may not be any currently bound. */ screen->dummyContext = ctx; - st_make_current(ctx->st, - draw->stfb, - read->stfb); - /* used in dri_flush_frontbuffer */ ctx->dPriv = driDrawPriv; - - if (driDrawPriv) - dri_get_buffers(driDrawPriv); - if (driDrawPriv != driReadPriv && driReadPriv) - dri_get_buffers(driReadPriv); + ctx->rPriv = driReadPriv; + + st_make_current(ctx->st, draw->stfb, read->stfb); + + if (__dri1_api_hooks) { + dri1_update_drawables(ctx, draw, read); + } else { + if (driDrawPriv) + dri_get_buffers(driDrawPriv); + if (driDrawPriv != driReadPriv && driReadPriv) + dri_get_buffers(driReadPriv); + } } else { st_make_current(NULL, NULL, NULL); } @@ -167,4 +188,44 @@ dri_make_current(__DRIcontextPrivate *cPriv, return GL_TRUE; } +static void +st_dri_lock(struct pipe_context *pipe) +{ + dri_lock((struct dri_context *) pipe->priv); +} + +static void +st_dri_unlock(struct pipe_context *pipe) +{ + dri_unlock((struct dri_context *) pipe->priv); +} + +static boolean +st_dri_is_locked(struct pipe_context *pipe) +{ + return ((struct dri_context *) pipe->priv)->isLocked; +} + +static boolean +st_dri_lost_lock(struct pipe_context *pipe) +{ + return ((struct dri_context *) pipe->priv)->wsLostLock; +} + +static void +st_dri_clear_lost_lock(struct pipe_context *pipe) +{ + ((struct dri_context *) pipe->priv)->wsLostLock = FALSE; +} + +struct dri1_api_lock_funcs dri1_lf = +{ + .lock = st_dri_lock, + .unlock = st_dri_unlock, + .is_locked = st_dri_is_locked, + .is_lock_lost = st_dri_lost_lock, + .clear_lost_lock = st_dri_clear_lost_lock +}; + + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h index e910472700..82a5916827 100644 --- a/src/gallium/state_trackers/dri/dri_context.h +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -42,32 +42,64 @@ struct pipe_fence; struct st_context; struct dri_drawable; - struct dri_context { /* dri */ __DRIscreenPrivate *sPriv; __DRIcontextPrivate *cPriv; __DRIdrawablePrivate *dPriv; + __DRIdrawablePrivate *rPriv; driOptionCache optionCache; + unsigned int d_stamp; + unsigned int r_stamp; + + drmLock *lock; + boolean isLocked; + boolean stLostLock; + boolean wsLostLock; + + unsigned int bind_count; + /* gallium */ struct st_context *st; struct pipe_context *pipe; }; - static INLINE struct dri_context * dri_context(__DRIcontextPrivate *driContextPriv) { return (struct dri_context *) driContextPriv->driverPrivate; } +static INLINE void +dri_lock(struct dri_context *ctx) +{ + drm_context_t hw_context = ctx->cPriv->hHWContext; + char ret = 0; + + DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret); + if (ret) { + drmGetLock(ctx->sPriv->fd, hw_context, 0); + ctx->stLostLock = TRUE; + ctx->wsLostLock = TRUE; + } + ctx->isLocked = TRUE; +} + +static INLINE void +dri_unlock(struct dri_context *ctx) +{ + ctx->isLocked = FALSE; + DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext); +} /*********************************************************************** * dri_context.c */ +extern struct dri1_api_lock_funcs dri1_lf; + void dri_destroy_context(__DRIcontextPrivate * driContextPriv); diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 2e3f4099e2..287617e9a9 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -37,6 +37,7 @@ #include "pipe/p_screen.h" #include "pipe/p_inlines.h" #include "state_tracker/drm_api.h" +#include "state_tracker/dri1_api.h" #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "state_tracker/st_cb_fbo.h" @@ -207,22 +208,6 @@ dri_flush_frontbuffer(struct pipe_screen *screen, } -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv) -{ - /* not needed for dri2 */ - assert(0); -} - - -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) -{ - /* not needed for dri2 */ - assert(0); -} - - /** * This is called when we need to set up GL rendering to a new X window. */ @@ -305,21 +290,322 @@ dri_create_buffer(__DRIscreenPrivate *sPriv, drawable->attachments[i++] = __DRI_BUFFER_STENCIL; drawable->num_attachments = i; + drawable->desired_fences = 2; + return GL_TRUE; fail: FREE(drawable); return GL_FALSE; } +static struct pipe_fence_handle * +dri_swap_fences_pop_front(struct dri_drawable *draw) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence = NULL; + + if (draw->cur_fences >= draw->desired_fences) { + screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); + screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); + --draw->cur_fences; + draw->tail &= DRI_SWAP_FENCES_MASK; + } + return fence; +} + +static void +dri_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + + if (!fence) + return; + + if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { + draw->cur_fences++; + screen->fence_reference(screen, &draw->swap_fences[draw->head++], fence); + draw->head &= DRI_SWAP_FENCES_MASK; + } +} void dri_destroy_buffer(__DRIdrawablePrivate *dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_fence_handle *fence; + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; st_unreference_framebuffer(drawable->stfb); + drawable->desired_fences = 0; + while(drawable->cur_fences) { + fence = dri_swap_fences_pop_front(drawable); + screen->fence_reference(screen, &fence, NULL); + } FREE(drawable); } +static void +dri1_update_drawables_locked(struct dri_context *ctx, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + if (ctx->stLostLock) { + ctx->stLostLock = FALSE; + if (driDrawPriv == driReadPriv) + DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv); + else + DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv, driReadPriv); + } +} + +/** + * This ensures all contexts which binds to a drawable picks up the + * drawable change and signals new buffer state. + * Calling st_resize_framebuffer for each context may seem like overkill, + * but no new buffers will actually be allocated if the dimensions doesn't + * change. + */ + +static void +dri1_propagate_drawable_change(struct dri_context *ctx) +{ + __DRIdrawablePrivate *dPriv = ctx->dPriv; + __DRIdrawablePrivate *rPriv = ctx->rPriv; + boolean flushed = FALSE; + + if (dPriv && ctx->d_stamp != dPriv->lastStamp) { + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + flushed = TRUE; + ctx->d_stamp = dPriv->lastStamp; + st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h); + + } + + if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) { + + if (!flushed) + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->r_stamp = rPriv->lastStamp; + st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h); + + } else if (rPriv && dPriv == rPriv) { + + ctx->r_stamp = ctx->d_stamp; + + } +} + +void +dri1_update_drawables(struct dri_context *ctx, + struct dri_drawable *draw, + struct dri_drawable *read) +{ + dri_lock(ctx); + dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); + dri_unlock(ctx); + + dri1_propagate_drawable_change(ctx); +} + +static INLINE boolean +dri1_intersect_src_bbox(struct drm_clip_rect *dst, + int dst_x, + int dst_y, + const struct drm_clip_rect *src, + const struct drm_clip_rect *bbox) +{ + int xy1; + int xy2; + + xy1 = ((int) src->x1 > (int) bbox->x1 + dst_x) ? src->x1 : + (int) bbox->x1 + dst_x; + xy2 = ((int) src->x2 < (int) bbox->x2 + dst_x) ? src->x2 : + (int) bbox->x2 + dst_x; + if (xy1 >= xy2 || xy1 < 0) + return FALSE; + + dst->x1 = xy1; + dst->x2 = xy2; + + xy1 = ((int) src->y1 > (int) bbox->y1 + dst_x) ? src->y1 : + (int) bbox->y1 + dst_x; + xy2 = ((int) src->y2 < (int) bbox->y2 + dst_x) ? src->y2 : + (int) bbox->y2 + dst_x; + if (xy1 >= xy2 || xy1 < 0) + return FALSE; + + dst->y1 = xy1; + dst->y2 = xy2; + return TRUE; +} + + +static void +dri1_swap_copy(struct dri_context *ctx, + struct pipe_surface *dst, + struct pipe_surface *src, + __DRIdrawablePrivate *dPriv, + const struct drm_clip_rect *bbox) +{ + struct pipe_context *pipe = ctx->pipe; + struct drm_clip_rect clip; + struct drm_clip_rect *cur; + int i; + + cur = dPriv->pClipRects; + + for (i=0; inumClipRects; ++i) { + if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) + pipe->surface_copy(pipe, dst, clip.x1, clip.y1, + src, + (int) clip.x1 - dPriv->x, + (int) clip.y1 - dPriv->y, + clip.x2 - clip.x1, + clip.y2 - clip.y1); + } +} + +static void +dri1_copy_to_front(struct dri_context *ctx, + struct pipe_surface *surf, + __DRIdrawablePrivate *dPriv, + const struct drm_clip_rect *sub_box, + struct pipe_fence_handle **fence) +{ + struct pipe_context *pipe = ctx->pipe; + boolean save_lost_lock; + uint cur_w; + uint cur_h; + struct drm_clip_rect bbox; + boolean visible = TRUE; + + *fence = NULL; + + dri_lock(ctx); + save_lost_lock = ctx->stLostLock; + dri1_update_drawables_locked(ctx, dPriv, dPriv); + st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h); + + bbox.x1 = 0; + bbox.x2 = cur_w; + bbox.y1 = 0; + bbox.y2 = cur_h; + + if (sub_box) + visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box); + + if (visible && __dri1_api_hooks->present_locked) { + + __dri1_api_hooks->present_locked(pipe, + surf, + dPriv->pClipRects, + dPriv->numClipRects, + dPriv->x, + dPriv->y, + &bbox, + fence); + + } else if (visible && __dri1_api_hooks->front_srf_locked) { + + struct pipe_surface *front = + __dri1_api_hooks->front_srf_locked(pipe); + + if (front) + dri1_swap_copy(ctx, front, surf, dPriv, &bbox); + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence); + } + + ctx->stLostLock = save_lost_lock; + + /** + * FIXME: Revisit this: Update drawables on copy_sub_buffer ? + */ + + if (!sub_box) + dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv); + + dri_unlock(ctx); + dri1_propagate_drawable_change(ctx); +} + +void +dri1_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private) +{ + struct dri_context *ctx = (struct dri_context *)context_private; + struct pipe_fence_handle *dummy_fence; + + dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence); + + /** + * FIXME: Do we need swap throttling here? + */ +} + +void +dri_swap_buffers(__DRIdrawablePrivate * dPriv) +{ + struct dri_context *ctx; + struct pipe_surface *back_surf; + struct dri_drawable *draw = dri_drawable(dPriv); + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence; + GET_CURRENT_CONTEXT(glCtx); + + assert(__dri1_api_hooks != NULL); + + if (!glCtx) + return; /* For now */ + + ctx = (struct dri_context *) glCtx->st->pipe->priv; + + st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); + if (back_surf) { + st_notify_swapbuffers(draw->stfb); + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + fence = dri_swap_fences_pop_front(draw); + if (fence) { + (void) screen->fence_finish(screen, fence, 0); + screen->fence_reference(screen, &fence, NULL); + } + dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence); + dri_swap_fences_push_back(draw, fence); + screen->fence_reference(screen, &fence, NULL); + } +} + +void +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) +{ + struct drm_clip_rect sub_bbox; + struct dri_context *ctx; + struct pipe_surface *back_surf; + struct dri_drawable *draw = dri_drawable(dPriv); + struct pipe_fence_handle *dummy_fence; + GET_CURRENT_CONTEXT(glCtx); + + assert(__dri1_api_hooks != NULL); + + if (!glCtx) + return; + + ctx = (struct dri_context *) glCtx->st->pipe->priv; + + sub_bbox.x1 = x; + sub_bbox.x2 = x + w; + sub_bbox.y1 = y; + sub_bbox.y2 = y + h; + + st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); + if (back_surf) { + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence); + } +} + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 185c657b35..c1341deb52 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -31,9 +31,11 @@ #include "pipe/p_compiler.h" struct pipe_surface; -struct pipe_fence; +struct pipe_fence_handle; struct st_framebuffer; +#define DRI_SWAP_FENCES_MAX 8 +#define DRI_SWAP_FENCES_MASK 7 struct dri_drawable { @@ -46,6 +48,11 @@ struct dri_drawable /* gallium */ struct st_framebuffer *stfb; + struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; + unsigned int head; + unsigned int tail; + unsigned int desired_fences; + unsigned int cur_fences; }; @@ -84,6 +91,15 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv); void dri_destroy_buffer(__DRIdrawablePrivate *dPriv); +void +dri1_update_drawables(struct dri_context *ctx, + struct dri_drawable *draw, + struct dri_drawable *read); + +void +dri1_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private); #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index ab33003f51..418bb90115 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -40,7 +40,9 @@ #include "pipe/p_context.h" #include "pipe/p_screen.h" #include "pipe/p_inlines.h" +#include "pipe/p_format.h" #include "state_tracker/drm_api.h" +#include "state_tracker/dri1_api.h" #include "state_tracker/st_public.h" #include "state_tracker/st_cb_fbo.h" @@ -57,7 +59,6 @@ PUBLIC const char __driConfigOptions[] = const uint __driNConfigOptions = 3; - static const __DRIextension *dri_screen_extensions[] = { &driReadDrawableExtension, &driCopySubBufferExtension.base, @@ -67,6 +68,8 @@ static const __DRIextension *dri_screen_extensions[] = { NULL }; +struct dri1_api *__dri1_api_hooks = NULL; + static const __DRIconfig ** dri_fill_in_modes(__DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, @@ -139,7 +142,7 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, /** * Get information about previous buffer swaps. */ -int +static int dri_get_swap_info(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo) { @@ -151,13 +154,69 @@ dri_get_swap_info(__DRIdrawablePrivate * dPriv, return 0; } +static INLINE void +dri_copy_version(struct dri1_api_version *dst, + const struct __DRIversionRec *src) +{ + dst->major = src->major; + dst->minor = src->minor; + dst->patch_level = src->patch; +} -/** - * NULL stub for old dri loaders - */ -const __DRIconfig ** +static const __DRIconfig ** dri_init_screen(__DRIscreenPrivate *sPriv) { + struct dri_screen *screen; + const __DRIconfig **configs; + struct dri1_create_screen_arg arg; + + dri_init_extensions(NULL); + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + return NULL; + + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + screen->drmLock = (drmLock *) &sPriv->pSAREA->lock; + + sPriv->private = (void *) screen; + sPriv->extensions = dri_screen_extensions; + + arg.base.mode = DRM_CREATE_DRI1; + arg.lf = &dri1_lf; + arg.ddx_info = sPriv->pDevPriv; + arg.ddx_info_size = sPriv->devPrivSize; + arg.sarea = sPriv->pSAREA; + dri_copy_version(&arg.ddx_version, &sPriv->ddx_version); + dri_copy_version(&arg.dri_version, &sPriv->dri_version); + dri_copy_version(&arg.drm_version, &sPriv->drm_version); + arg.api = NULL; + + screen->pipe_screen = drm_api_hooks.create_screen + (screen->fd, &arg.base); + + if (!screen->pipe_screen || !arg.api) { + debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); + goto out_no_screen; + } + + __dri1_api_hooks = arg.api; + + screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer; + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, + __driNConfigOptions); + + configs = dri_fill_in_modes(sPriv, sPriv->fbBPP, 24, 8, 1); + if (!configs) + goto out_no_configs; + + return configs; + out_no_configs: + screen->pipe_screen->destroy(screen->pipe_screen); + out_no_screen: + FREE(screen); return NULL; } @@ -167,10 +226,11 @@ dri_init_screen(__DRIscreenPrivate *sPriv) * * Returns the __GLcontextModes supported by this driver. */ -const __DRIconfig ** +static const __DRIconfig ** dri_init_screen2(__DRIscreenPrivate *sPriv) { struct dri_screen *screen; + struct drm_create_screen_arg arg; /* Set up dispatch table to cope with all known extensions */ dri_init_extensions(NULL); @@ -183,9 +243,9 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->fd = sPriv->fd; sPriv->private = (void *) screen; sPriv->extensions = dri_screen_extensions; + arg.mode = DRM_CREATE_NORMAL; - - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg); if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); goto fail; @@ -208,7 +268,7 @@ fail: } -void +static void dri_destroy_screen(__DRIscreenPrivate * sPriv) { struct dri_screen *screen = dri_screen(sPriv); @@ -220,19 +280,20 @@ dri_destroy_screen(__DRIscreenPrivate * sPriv) PUBLIC const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, /* not supported but exported */ + .InitScreen = dri_init_screen, .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, .DestroyContext = dri_destroy_context, .CreateBuffer = dri_create_buffer, .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, /* not supported but exported */ + .SwapBuffers = dri_swap_buffers, .MakeCurrent = dri_make_current, .UnbindContext = dri_unbind_context, .GetSwapInfo = dri_get_swap_info, .GetDrawableMSC = driDrawableGetMSC32, .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */ + .CopySubBuffer = dri_copy_sub_buffer, + .InitScreen = dri_init_screen, .InitScreen2 = dri_init_screen2, }; diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 3751ec6121..c358c35168 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -37,6 +37,8 @@ #include "pipe/p_compiler.h" +#include "state_tracker/dri1_api.h" + struct dri_screen { /* dri */ @@ -55,6 +57,7 @@ struct dri_screen /* drm */ int fd; + drmLock *drmLock; /* gallium */ struct pipe_winsys *pipe_winsys; @@ -73,15 +76,8 @@ dri_screen(__DRIscreenPrivate *sPriv) /*********************************************************************** * dri_screen.c */ -const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv); - -void -dri_destroy_screen(__DRIscreenPrivate * sPriv); -int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo); +extern struct dri1_api *__dri1_api_hooks; #endif -- cgit v1.2.3 From 0929b2bf3cdb54d94da8dee5797878e2ee582b41 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:54:25 +0200 Subject: gallium: indent and cleanfile the dri state-tracker. --- src/gallium/state_trackers/dri/dri_context.c | 42 ++--- src/gallium/state_trackers/dri/dri_context.h | 23 +-- src/gallium/state_trackers/dri/dri_drawable.c | 227 +++++++++++------------- src/gallium/state_trackers/dri/dri_drawable.h | 33 ++-- src/gallium/state_trackers/dri/dri_extensions.c | 7 +- src/gallium/state_trackers/dri/dri_screen.c | 164 ++++++++--------- src/gallium/state_trackers/dri/dri_screen.h | 6 +- 7 files changed, 221 insertions(+), 281 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index a45fb541fd..7f38671126 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -42,12 +42,9 @@ #include "util/u_memory.h" - - GLboolean -dri_create_context(const __GLcontextModes *visual, - __DRIcontextPrivate *cPriv, - void *sharedContextPrivate) +dri_create_context(const __GLcontextModes * visual, + __DRIcontextPrivate * cPriv, void *sharedContextPrivate) { __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; struct dri_screen *screen = dri_screen(sPriv); @@ -55,7 +52,7 @@ dri_create_context(const __GLcontextModes *visual, struct st_context *st_share = NULL; if (sharedContextPrivate) { - st_share = ((struct dri_context *) sharedContextPrivate)->st; + st_share = ((struct dri_context *)sharedContextPrivate)->st; } ctx = CALLOC_STRUCT(dri_context); @@ -70,9 +67,7 @@ dri_create_context(const __GLcontextModes *visual, ctx->r_stamp = -1; driParseConfigFiles(&ctx->optionCache, - &screen->optionCache, - sPriv->myNum, - "dri"); + &screen->optionCache, sPriv->myNum, "dri"); ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); @@ -90,7 +85,7 @@ dri_create_context(const __GLcontextModes *visual, return GL_TRUE; -fail: + fail: if (ctx && ctx->st) st_destroy_context(ctx->st); @@ -101,9 +96,8 @@ fail: return FALSE; } - void -dri_destroy_context(__DRIcontextPrivate *cPriv) +dri_destroy_context(__DRIcontextPrivate * cPriv) { struct dri_context *ctx = dri_context(cPriv); struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); @@ -125,9 +119,8 @@ dri_destroy_context(__DRIcontextPrivate *cPriv) FREE(ctx); } - GLboolean -dri_unbind_context(__DRIcontextPrivate *cPriv) +dri_unbind_context(__DRIcontextPrivate * cPriv) { if (cPriv) { struct dri_context *ctx = dri_context(cPriv); @@ -146,15 +139,16 @@ dri_unbind_context(__DRIcontextPrivate *cPriv) } GLboolean -dri_make_current(__DRIcontextPrivate *cPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) +dri_make_current(__DRIcontextPrivate * cPriv, + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv) { if (cPriv) { struct dri_context *ctx = dri_context(cPriv); struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); struct dri_drawable *draw = dri_drawable(driDrawPriv); struct dri_drawable *read = dri_drawable(driReadPriv); + GET_CURRENT_CONTEXT(oldGLCtx); if (oldGLCtx && oldGLCtx->st != ctx->st) @@ -191,35 +185,34 @@ dri_make_current(__DRIcontextPrivate *cPriv, static void st_dri_lock(struct pipe_context *pipe) { - dri_lock((struct dri_context *) pipe->priv); + dri_lock((struct dri_context *)pipe->priv); } static void st_dri_unlock(struct pipe_context *pipe) { - dri_unlock((struct dri_context *) pipe->priv); + dri_unlock((struct dri_context *)pipe->priv); } static boolean st_dri_is_locked(struct pipe_context *pipe) { - return ((struct dri_context *) pipe->priv)->isLocked; + return ((struct dri_context *)pipe->priv)->isLocked; } static boolean st_dri_lost_lock(struct pipe_context *pipe) { - return ((struct dri_context *) pipe->priv)->wsLostLock; + return ((struct dri_context *)pipe->priv)->wsLostLock; } static void st_dri_clear_lost_lock(struct pipe_context *pipe) { - ((struct dri_context *) pipe->priv)->wsLostLock = FALSE; + ((struct dri_context *)pipe->priv)->wsLostLock = FALSE; } -struct dri1_api_lock_funcs dri1_lf = -{ +struct dri1_api_lock_funcs dri1_lf = { .lock = st_dri_lock, .unlock = st_dri_unlock, .is_locked = st_dri_is_locked, @@ -227,5 +220,4 @@ struct dri1_api_lock_funcs dri1_lf = .clear_lost_lock = st_dri_clear_lost_lock }; - /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h index 82a5916827..4650178734 100644 --- a/src/gallium/state_trackers/dri/dri_context.h +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -36,7 +36,6 @@ #include "drm.h" #include "dri_util.h" - struct pipe_context; struct pipe_fence; struct st_context; @@ -68,9 +67,9 @@ struct dri_context }; static INLINE struct dri_context * -dri_context(__DRIcontextPrivate *driContextPriv) +dri_context(__DRIcontextPrivate * driContextPriv) { - return (struct dri_context *) driContextPriv->driverPrivate; + return (struct dri_context *)driContextPriv->driverPrivate; } static INLINE void @@ -100,28 +99,24 @@ dri_unlock(struct dri_context *ctx) */ extern struct dri1_api_lock_funcs dri1_lf; -void -dri_destroy_context(__DRIcontextPrivate * driContextPriv); +void dri_destroy_context(__DRIcontextPrivate * driContextPriv); -boolean -dri_unbind_context(__DRIcontextPrivate * driContextPriv); +boolean dri_unbind_context(__DRIcontextPrivate * driContextPriv); boolean dri_make_current(__DRIcontextPrivate * driContextPriv, - __DRIdrawablePrivate * driDrawPriv, - __DRIdrawablePrivate * driReadPriv); + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv); boolean dri_create_context(const __GLcontextModes * visual, - __DRIcontextPrivate * driContextPriv, - void *sharedContextPrivate); - + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); /*********************************************************************** * dri_extensions.c */ -void -dri_init_extensions(struct dri_context *ctx); +void dri_init_extensions(struct dri_context *ctx); #endif diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 287617e9a9..abda4ff17e 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -44,23 +44,19 @@ #include "util/u_memory.h" - static void -dri_copy_to_front(__DRIdrawablePrivate *dPriv, - struct pipe_surface *from, - int x, int y, unsigned w, unsigned h) +dri_copy_to_front(__DRIdrawablePrivate * dPriv, + struct pipe_surface *from, + int x, int y, unsigned w, unsigned h) { /* TODO send a message to the Xserver to copy to the real front buffer */ } - static struct pipe_surface * dri_surface_from_handle(struct pipe_screen *screen, - unsigned handle, - enum pipe_format format, - unsigned width, - unsigned height, - unsigned pitch) + unsigned handle, + enum pipe_format format, + unsigned width, unsigned height, unsigned pitch) { struct pipe_surface *surface = NULL; struct pipe_texture *texture = NULL; @@ -81,10 +77,7 @@ dri_surface_from_handle(struct pipe_screen *screen, templat.height[0] = height; pf_get_block(templat.format, &templat.block); - texture = screen->texture_blanket(screen, - &templat, - &pitch, - buf); + texture = screen->texture_blanket(screen, &templat, &pitch, buf); /* we don't need the buffer from this point on */ pipe_buffer_reference(&buf, NULL); @@ -93,20 +86,19 @@ dri_surface_from_handle(struct pipe_screen *screen, return NULL; surface = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); /* we don't need the texture from this point on */ pipe_texture_reference(&texture, NULL); return surface; } - /** * This will be called a drawable is known to have been resized. */ void -dri_get_buffers(__DRIdrawablePrivate *dPriv) +dri_get_buffers(__DRIdrawablePrivate * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_surface *surface = NULL; @@ -117,13 +109,14 @@ dri_get_buffers(__DRIdrawablePrivate *dPriv) boolean have_depth = FALSE; int i, count; - buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable, - &dri_drawable->w, - &dri_drawable->h, - drawable->attachments, - drawable->num_attachments, - &count, - dri_drawable->loaderPrivate); + buffers = (*dri_screen->dri2.loader->getBuffers) (dri_drawable, + &dri_drawable->w, + &dri_drawable->h, + drawable->attachments, + drawable-> + num_attachments, &count, + dri_drawable-> + loaderPrivate); if (buffers == NULL) { return; @@ -150,45 +143,44 @@ dri_get_buffers(__DRIdrawablePrivate *dPriv) int index = 0; switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_FAKE_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_BACK_LEFT: - index = ST_SURFACE_BACK_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_DEPTH: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_STENCIL: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_ACCUM: - default: - assert(0); + case __DRI_BUFFER_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_FAKE_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_BACK_LEFT: + index = ST_SURFACE_BACK_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_DEPTH: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_STENCIL: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_ACCUM: + default: + assert(0); } assert(buffers[i].cpp == 4); if (index == ST_SURFACE_DEPTH) { - if (have_depth) - continue; - else - have_depth = TRUE; + if (have_depth) + continue; + else + have_depth = TRUE; } surface = dri_surface_from_handle(screen, - buffers[i].name, - format, - dri_drawable->w, - dri_drawable->h, - buffers[i].pitch); + buffers[i].name, + format, + dri_drawable->w, + dri_drawable->h, buffers[i].pitch); st_set_framebuffer_surface(drawable->stfb, index, surface); pipe_surface_reference(&surface, NULL); @@ -197,25 +189,22 @@ dri_get_buffers(__DRIdrawablePrivate *dPriv) st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); } - void dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private) + struct pipe_surface *surf, void *context_private) { struct dri_context *ctx = (struct dri_context *)context_private; + dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height); } - /** * This is called when we need to set up GL rendering to a new X window. */ boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap) +dri_create_buffer(__DRIscreenPrivate * sPriv, + __DRIdrawablePrivate * dPriv, + const __GLcontextModes * visual, boolean isPixmap) { enum pipe_format colorFormat, depthFormat, stencilFormat; struct dri_screen *screen = sPriv->private; @@ -224,7 +213,7 @@ dri_create_buffer(__DRIscreenPrivate *sPriv, int i; if (isPixmap) - goto fail; /* not implemented */ + goto fail; /* not implemented */ drawable = CALLOC_STRUCT(dri_drawable); if (drawable == NULL) @@ -241,39 +230,38 @@ dri_create_buffer(__DRIscreenPrivate *sPriv, if (visual->depthBits) { if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - depthFormat = PIPE_FORMAT_Z24S8_UNORM; + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + depthFormat = PIPE_FORMAT_Z24S8_UNORM; else - depthFormat = PIPE_FORMAT_S8Z24_UNORM; + depthFormat = PIPE_FORMAT_S8Z24_UNORM; } else depthFormat = PIPE_FORMAT_NONE; if (visual->stencilBits) { if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - stencilFormat = PIPE_FORMAT_Z24S8_UNORM; + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + stencilFormat = PIPE_FORMAT_Z24S8_UNORM; else - stencilFormat = PIPE_FORMAT_S8Z24_UNORM; + stencilFormat = PIPE_FORMAT_S8Z24_UNORM; } else stencilFormat = PIPE_FORMAT_NONE; drawable->stfb = st_create_framebuffer(visual, - colorFormat, - depthFormat, - stencilFormat, - dPriv->w, - dPriv->h, - (void*) drawable); + colorFormat, + depthFormat, + stencilFormat, + dPriv->w, + dPriv->h, (void *)drawable); if (drawable->stfb == NULL) goto fail; drawable->sPriv = sPriv; drawable->dPriv = dPriv; - dPriv->driverPrivate = (void *) drawable; + dPriv->driverPrivate = (void *)drawable; /* setup dri2 buffers information */ i = 0; @@ -293,7 +281,7 @@ dri_create_buffer(__DRIscreenPrivate *sPriv, drawable->desired_fences = 2; return GL_TRUE; -fail: + fail: FREE(drawable); return GL_FALSE; } @@ -324,13 +312,14 @@ dri_swap_fences_push_back(struct dri_drawable *draw, if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { draw->cur_fences++; - screen->fence_reference(screen, &draw->swap_fences[draw->head++], fence); + screen->fence_reference(screen, &draw->swap_fences[draw->head++], + fence); draw->head &= DRI_SWAP_FENCES_MASK; } } void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv) +dri_destroy_buffer(__DRIdrawablePrivate * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_fence_handle *fence; @@ -338,7 +327,7 @@ dri_destroy_buffer(__DRIdrawablePrivate *dPriv) st_unreference_framebuffer(drawable->stfb); drawable->desired_fences = 0; - while(drawable->cur_fences) { + while (drawable->cur_fences) { fence = dri_swap_fences_pop_front(drawable); screen->fence_reference(screen, &fence, NULL); } @@ -348,15 +337,16 @@ dri_destroy_buffer(__DRIdrawablePrivate *dPriv) static void dri1_update_drawables_locked(struct dri_context *ctx, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv) { if (ctx->stLostLock) { ctx->stLostLock = FALSE; if (driDrawPriv == driReadPriv) DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv); else - DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv, driReadPriv); + DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv, + driReadPriv); } } @@ -387,7 +377,7 @@ dri1_propagate_drawable_change(struct dri_context *ctx) if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) { if (!flushed) - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); ctx->r_stamp = rPriv->lastStamp; st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h); @@ -400,8 +390,7 @@ dri1_propagate_drawable_change(struct dri_context *ctx) void dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, - struct dri_drawable *read) + struct dri_drawable *draw, struct dri_drawable *read) { dri_lock(ctx); dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); @@ -420,20 +409,20 @@ dri1_intersect_src_bbox(struct drm_clip_rect *dst, int xy1; int xy2; - xy1 = ((int) src->x1 > (int) bbox->x1 + dst_x) ? src->x1 : - (int) bbox->x1 + dst_x; - xy2 = ((int) src->x2 < (int) bbox->x2 + dst_x) ? src->x2 : - (int) bbox->x2 + dst_x; + xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 : + (int)bbox->x1 + dst_x; + xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 : + (int)bbox->x2 + dst_x; if (xy1 >= xy2 || xy1 < 0) return FALSE; dst->x1 = xy1; dst->x2 = xy2; - xy1 = ((int) src->y1 > (int) bbox->y1 + dst_x) ? src->y1 : - (int) bbox->y1 + dst_x; - xy2 = ((int) src->y2 < (int) bbox->y2 + dst_x) ? src->y2 : - (int) bbox->y2 + dst_x; + xy1 = ((int)src->y1 > (int)bbox->y1 + dst_x) ? src->y1 : + (int)bbox->y1 + dst_x; + xy2 = ((int)src->y2 < (int)bbox->y2 + dst_x) ? src->y2 : + (int)bbox->y2 + dst_x; if (xy1 >= xy2 || xy1 < 0) return FALSE; @@ -442,13 +431,11 @@ dri1_intersect_src_bbox(struct drm_clip_rect *dst, return TRUE; } - static void dri1_swap_copy(struct dri_context *ctx, struct pipe_surface *dst, struct pipe_surface *src, - __DRIdrawablePrivate *dPriv, - const struct drm_clip_rect *bbox) + __DRIdrawablePrivate * dPriv, const struct drm_clip_rect *bbox) { struct pipe_context *pipe = ctx->pipe; struct drm_clip_rect clip; @@ -457,21 +444,20 @@ dri1_swap_copy(struct dri_context *ctx, cur = dPriv->pClipRects; - for (i=0; inumClipRects; ++i) { + for (i = 0; i < dPriv->numClipRects; ++i) { if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) pipe->surface_copy(pipe, dst, clip.x1, clip.y1, src, - (int) clip.x1 - dPriv->x, - (int) clip.y1 - dPriv->y, - clip.x2 - clip.x1, - clip.y2 - clip.y1); + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, + clip.x2 - clip.x1, clip.y2 - clip.y1); } } static void dri1_copy_to_front(struct dri_context *ctx, struct pipe_surface *surf, - __DRIdrawablePrivate *dPriv, + __DRIdrawablePrivate * dPriv, const struct drm_clip_rect *sub_box, struct pipe_fence_handle **fence) { @@ -503,15 +489,11 @@ dri1_copy_to_front(struct dri_context *ctx, surf, dPriv->pClipRects, dPriv->numClipRects, - dPriv->x, - dPriv->y, - &bbox, - fence); + dPriv->x, dPriv->y, &bbox, fence); } else if (visible && __dri1_api_hooks->front_srf_locked) { - struct pipe_surface *front = - __dri1_api_hooks->front_srf_locked(pipe); + struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe); if (front) dri1_swap_copy(ctx, front, surf, dPriv, &bbox); @@ -534,8 +516,7 @@ dri1_copy_to_front(struct dri_context *ctx, void dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private) + struct pipe_surface *surf, void *context_private) { struct dri_context *ctx = (struct dri_context *)context_private; struct pipe_fence_handle *dummy_fence; @@ -555,14 +536,15 @@ dri_swap_buffers(__DRIdrawablePrivate * dPriv) struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; struct pipe_fence_handle *fence; + GET_CURRENT_CONTEXT(glCtx); assert(__dri1_api_hooks != NULL); if (!glCtx) - return; /* For now */ + return; /* For now */ - ctx = (struct dri_context *) glCtx->st->pipe->priv; + ctx = (struct dri_context *)glCtx->st->pipe->priv; st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); if (back_surf) { @@ -570,7 +552,7 @@ dri_swap_buffers(__DRIdrawablePrivate * dPriv) st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); fence = dri_swap_fences_pop_front(draw); if (fence) { - (void) screen->fence_finish(screen, fence, 0); + (void)screen->fence_finish(screen, fence, 0); screen->fence_reference(screen, &fence, NULL); } dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence); @@ -587,6 +569,7 @@ dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) struct pipe_surface *back_surf; struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_fence_handle *dummy_fence; + GET_CURRENT_CONTEXT(glCtx); assert(__dri1_api_hooks != NULL); @@ -594,7 +577,7 @@ dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) if (!glCtx) return; - ctx = (struct dri_context *) glCtx->st->pipe->priv; + ctx = (struct dri_context *)glCtx->st->pipe->priv; sub_bbox.x1 = x; sub_bbox.x2 = x + w; diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index c1341deb52..78a66624aa 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -55,51 +55,40 @@ struct dri_drawable unsigned int cur_fences; }; - static INLINE struct dri_drawable * dri_drawable(__DRIdrawablePrivate * driDrawPriv) { - return (struct dri_drawable *) driDrawPriv->driverPrivate; + return (struct dri_drawable *)driDrawPriv->driverPrivate; } - /*********************************************************************** * dri_drawable.c */ boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap); +dri_create_buffer(__DRIscreenPrivate * sPriv, + __DRIdrawablePrivate * dPriv, + const __GLcontextModes * visual, boolean isPixmap); void dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private); + struct pipe_surface *surf, void *context_private); -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv); +void dri_swap_buffers(__DRIdrawablePrivate * dPriv); void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, - int x, int y, - int w, int h); +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h); -void -dri_get_buffers(__DRIdrawablePrivate * dPriv); +void dri_get_buffers(__DRIdrawablePrivate * dPriv); -void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv); +void dri_destroy_buffer(__DRIdrawablePrivate * dPriv); void dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, - struct dri_drawable *read); + struct dri_drawable *draw, struct dri_drawable *read); void dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private); + struct pipe_surface *surf, void *context_private); #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 732d1e89b0..0c59d42d5c 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -52,7 +52,6 @@ #define need_GL_NV_vertex_program #include "extension_helper.h" - /** * Extension strings exported by the driver. */ @@ -74,7 +73,8 @@ const struct dri_extension card_extensions[] = { {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, - {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, + {"GL_EXT_blend_equation_separate", + GL_EXT_blend_equation_separate_functions}, {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, {"GL_EXT_blend_subtract", NULL}, @@ -98,11 +98,10 @@ const struct dri_extension card_extensions[] = { {"GL_NV_blend_square", NULL}, {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, {"GL_NV_vertex_program1_1", NULL}, - {"GL_SGIS_generate_mipmap", NULL }, + {"GL_SGIS_generate_mipmap", NULL}, {NULL, NULL} }; - void dri_init_extensions(struct dri_context *ctx) { diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 418bb90115..d3392ee690 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -46,34 +46,32 @@ #include "state_tracker/st_public.h" #include "state_tracker/st_cb_fbo.h" - PUBLIC const char __driConfigOptions[] = DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) + DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY - /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/ - DRI_CONF_ALLOW_LARGE_TEXTURES(1) + /*DRI_CONF_FORCE_S3TC_ENABLE(false) */ + DRI_CONF_ALLOW_LARGE_TEXTURES(1) DRI_CONF_SECTION_END DRI_CONF_END; + const uint __driNConfigOptions = 3; -const uint __driNConfigOptions = 3; - -static const __DRIextension *dri_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; + static const __DRIextension *dri_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL + }; struct dri1_api *__dri1_api_hooks = NULL; static const __DRIconfig ** -dri_fill_in_modes(__DRIscreenPrivate *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) +dri_fill_in_modes(__DRIscreenPrivate * psp, + unsigned pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer) { __DRIconfig **configs; __GLcontextModes *m; @@ -97,9 +95,9 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, depth_bits_array[1] = 24; depth_bits_array[2] = 24; - stencil_bits_array[0] = 0; /* no depth or stencil */ - stencil_bits_array[1] = 0; /* z24x8 */ - stencil_bits_array[2] = 8; /* z24s8 */ + stencil_bits_array[0] = 0; /* no depth or stencil */ + stencil_bits_array[1] = 0; /* z24x8 */ + stencil_bits_array[2] = 8; /* z24s8 */ msaa_samples_array[0] = 0; @@ -107,22 +105,22 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, back_buffer_factor = 3; msaa_samples_factor = 1; - num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; + num_modes = + depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; if (pixel_bits == 16) { fb_format = GL_RGB; fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { + } else { fb_format = GL_BGRA; fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; } configs = driCreateConfigs(fb_format, fb_type, depth_bits_array, - stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, msaa_samples_factor); + stencil_bits_array, depth_buffer_factor, + back_buffer_modes, back_buffer_factor, + msaa_samples_array, msaa_samples_factor); if (configs == NULL) { debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); return NULL; @@ -131,24 +129,20 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, for (i = 0; configs[i]; i++) { m = &configs[i]->modes; if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; + m->visualRating = GLX_SLOW_CONFIG; } } - return (const const __DRIconfig **) configs; + return (const const __DRIconfig **)configs; } - /** * Get information about previous buffer swaps. */ static int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo) +dri_get_swap_info(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo) { - if (dPriv == NULL || - dPriv->driverPrivate == NULL || - sInfo == NULL) + if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL) return -1; else return 0; @@ -164,37 +158,36 @@ dri_copy_version(struct dri1_api_version *dst, } static const __DRIconfig ** -dri_init_screen(__DRIscreenPrivate *sPriv) +dri_init_screen(__DRIscreenPrivate * sPriv) { - struct dri_screen *screen; - const __DRIconfig **configs; - struct dri1_create_screen_arg arg; + struct dri_screen *screen; + const __DRIconfig **configs; + struct dri1_create_screen_arg arg; - dri_init_extensions(NULL); + dri_init_extensions(NULL); - screen = CALLOC_STRUCT(dri_screen); - if (!screen) - return NULL; + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + return NULL; - screen->sPriv = sPriv; - screen->fd = sPriv->fd; - screen->drmLock = (drmLock *) &sPriv->pSAREA->lock; + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; - sPriv->private = (void *) screen; - sPriv->extensions = dri_screen_extensions; + sPriv->private = (void *)screen; + sPriv->extensions = dri_screen_extensions; - arg.base.mode = DRM_CREATE_DRI1; - arg.lf = &dri1_lf; - arg.ddx_info = sPriv->pDevPriv; - arg.ddx_info_size = sPriv->devPrivSize; - arg.sarea = sPriv->pSAREA; - dri_copy_version(&arg.ddx_version, &sPriv->ddx_version); - dri_copy_version(&arg.dri_version, &sPriv->dri_version); - dri_copy_version(&arg.drm_version, &sPriv->drm_version); - arg.api = NULL; + arg.base.mode = DRM_CREATE_DRI1; + arg.lf = &dri1_lf; + arg.ddx_info = sPriv->pDevPriv; + arg.ddx_info_size = sPriv->devPrivSize; + arg.sarea = sPriv->pSAREA; + dri_copy_version(&arg.ddx_version, &sPriv->ddx_version); + dri_copy_version(&arg.dri_version, &sPriv->dri_version); + dri_copy_version(&arg.drm_version, &sPriv->drm_version); + arg.api = NULL; - screen->pipe_screen = drm_api_hooks.create_screen - (screen->fd, &arg.base); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg.base); if (!screen->pipe_screen || !arg.api) { debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); @@ -205,8 +198,7 @@ dri_init_screen(__DRIscreenPrivate *sPriv) screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer; driParseOptionInfo(&screen->optionCache, - __driConfigOptions, - __driNConfigOptions); + __driConfigOptions, __driNConfigOptions); configs = dri_fill_in_modes(sPriv, sPriv->fbBPP, 24, 8, 1); if (!configs) @@ -220,14 +212,13 @@ dri_init_screen(__DRIscreenPrivate *sPriv) return NULL; } - /** * This is the driver specific part of the createNewScreen entry point. * * Returns the __GLcontextModes supported by this driver. */ static const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv) +dri_init_screen2(__DRIscreenPrivate * sPriv) { struct dri_screen *screen; struct drm_create_screen_arg arg; @@ -241,7 +232,7 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; - sPriv->private = (void *) screen; + sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; arg.mode = DRM_CREATE_NORMAL; @@ -255,19 +246,13 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; driParseOptionInfo(&screen->optionCache, - __driConfigOptions, - __driNConfigOptions); - - return dri_fill_in_modes(sPriv, - 4 * 8, - 24, - 8, - 1); -fail: + __driConfigOptions, __driNConfigOptions); + + return dri_fill_in_modes(sPriv, 4 * 8, 24, 8, 1); + fail: return NULL; } - static void dri_destroy_screen(__DRIscreenPrivate * sPriv) { @@ -278,23 +263,22 @@ dri_destroy_screen(__DRIscreenPrivate * sPriv) sPriv->private = NULL; } - PUBLIC const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .GetSwapInfo = dri_get_swap_info, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, - .InitScreen = dri_init_screen, - .InitScreen2 = dri_init_screen2, + .InitScreen = dri_init_screen, + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .SwapBuffers = dri_swap_buffers, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + .GetSwapInfo = dri_get_swap_info, + .GetDrawableMSC = driDrawableGetMSC32, + .WaitForMSC = driWaitForMSC32, + .CopySubBuffer = dri_copy_sub_buffer, + .InitScreen = dri_init_screen, + .InitScreen2 = dri_init_screen2, }; /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index c358c35168..100d9e50e0 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -64,15 +64,13 @@ struct dri_screen struct pipe_screen *pipe_screen; }; - /** cast wrapper */ static INLINE struct dri_screen * -dri_screen(__DRIscreenPrivate *sPriv) +dri_screen(__DRIscreenPrivate * sPriv) { - return (struct dri_screen *) sPriv->private; + return (struct dri_screen *)sPriv->private; } - /*********************************************************************** * dri_screen.c */ -- cgit v1.2.3 From 05af5a7f593ac6451cff9e6923d4a969d5358bcb Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:58:27 +0200 Subject: gallium: Rename the dri state tracker lib to libdridrm.a --- src/gallium/state_trackers/dri/Makefile | 2 +- src/gallium/winsys/drm/intel/dri2/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri2/Makefile | 2 +- src/gallium/winsys/drm/radeon/dri2/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index 47750e997e..ef8f19709a 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -1,7 +1,7 @@ TOP = ../../../.. include $(TOP)/configs/current -LIBNAME = dri2drm +LIBNAME = dridrm LIBRARY_INCLUDES = \ -I$(TOP)/include \ diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile index 286ef08d5b..125e79e0ed 100644 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ b/src/gallium/winsys/drm/intel/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile index 5e5efbcb11..377a80d518 100644 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri2.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nv04/libnv04.a \ $(TOP)/src/gallium/drivers/nv10/libnv10.a \ diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile index 58a87dae18..c218ee9d01 100644 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ b/src/gallium/winsys/drm/radeon/dri2/Makefile @@ -7,7 +7,7 @@ LIBNAME = radeon_dri.so MINIGLX_SOURCES = PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -- cgit v1.2.3 From 1ae877d95adbc19cb0a8d4fe07f46ac4d46c8147 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 03:28:37 -0700 Subject: radeon: Use PCI_MATCH_ANY for xorg driver. Might as well. --- src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c index 6f77fbe5de..36824251f0 100644 --- a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c +++ b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c @@ -38,20 +38,17 @@ static Bool radeon_xorg_pci_probe(DriverPtr driver, intptr_t match_data); static const struct pci_id_match radeon_xorg_device_match[] = { - {0x1002, 0x5E4D, 0xffff, 0xffff, 0, 0, 0}, - {0x1002, 0x7249, 0xffff, 0xffff, 0, 0, 0}, + {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, {0, 0, 0}, }; static SymTabRec radeon_xorg_chipsets[] = { - {0x5E4D, "Radeon RV410 PCIE (X700)"}, - {0x7249, "Radeon R580 PCIE (X1900 XT)"}, + {PCI_MATCH_ANY, "ATI/AMD Radeon Graphics Chipset"}, {-1, NULL} }; static PciChipsets radeon_xorg_pci_devices[] = { - {0x5E4D, 0x5E4D, RES_SHARED_VGA}, - {0x7249, 0x7249, RES_SHARED_VGA}, + {PCI_MATCH_ANY, PCI_MATCH_ANY, RES_SHARED_VGA}, {-1, -1, RES_UNDEFINED} }; -- cgit v1.2.3 From 81ded8092a4068ec289e6c7207078f076bfee5fd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 03:28:57 -0700 Subject: radeon-r300: Fix a bit of breakage. Not really sure why reordering the ioctls makes them work again. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 19 +++++++++--------- src/gallium/winsys/drm/radeon/dri/Makefile | 25 ++++++++++++++++++++++++ src/gallium/winsys/drm/radeon/dri/SConscript | 14 +++++++++++++ src/gallium/winsys/drm/radeon/dri2/Makefile | 25 ------------------------ src/gallium/winsys/drm/radeon/dri2/SConscript | 14 ------------- 5 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 src/gallium/winsys/drm/radeon/dri/Makefile create mode 100644 src/gallium/winsys/drm/radeon/dri/SConscript delete mode 100644 src/gallium/winsys/drm/radeon/dri2/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/dri2/SConscript (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 293b6c2d38..3302d623bf 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -53,32 +53,31 @@ static void radeon_r300_flush_cs(struct radeon_cs* cs) static void do_ioctls(struct r300_winsys* winsys, int fd) { drm_radeon_getparam_t gp; - uint32_t target; + int target; int retval; /* XXX is this cast safe? */ gp.value = (int*)⌖ - /* First, get PCI ID */ - gp.param = RADEON_PARAM_DEVICE_ID; + /* First, get the number of pixel pipes */ + gp.param = RADEON_PARAM_NUM_GB_PIPES; retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); if (retval) { - fprintf(stderr, "%s: Failed to get PCI ID, error number %d", + fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n", __FUNCTION__, retval); exit(1); } - winsys->pci_id = target; + winsys->gb_pipes = target; - /* Then, get the number of pixel pipes */ - gp.param = RADEON_PARAM_NUM_GB_PIPES; + /* Then, get PCI ID */ + gp.param = RADEON_PARAM_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); if (retval) { - fprintf(stderr, "%s: Failed to get GB pipe count, error number %d", + fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n", __FUNCTION__, retval); exit(1); } - winsys->gb_pipes = target; - + winsys->pci_id = target; } struct r300_winsys* diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile new file mode 100644 index 0000000000..c218ee9d01 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -0,0 +1,25 @@ + +TOP = ../../../../../.. +include $(TOP)/configs/current + +LIBNAME = radeon_dri.so + +MINIGLX_SOURCES = + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/r300/libr300.a + +C_SOURCES = \ + $(COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +ASM_SOURCES = + +include ../../Makefile.template + +DRI_LIB_DEPS += -ldrm_radeon + +symlinks: diff --git a/src/gallium/winsys/drm/radeon/dri/SConscript b/src/gallium/winsys/drm/radeon/dri/SConscript new file mode 100644 index 0000000000..f2cdee97d9 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/dri/SConscript @@ -0,0 +1,14 @@ +Import('*') + +env = drienv.Clone() + +drivers = [ + softpipe, + r300 +] + +env.SharedLibrary( + target ='radeon_dri.so', + source = COMMON_GALLIUM_SOURCES, + LIBS = drivers + mesa + auxiliaries + env['LIBS'], +) diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile deleted file mode 100644 index c218ee9d01..0000000000 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ /dev/null @@ -1,25 +0,0 @@ - -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = radeon_dri.so - -MINIGLX_SOURCES = - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../../Makefile.template - -DRI_LIB_DEPS += -ldrm_radeon - -symlinks: diff --git a/src/gallium/winsys/drm/radeon/dri2/SConscript b/src/gallium/winsys/drm/radeon/dri2/SConscript deleted file mode 100644 index f2cdee97d9..0000000000 --- a/src/gallium/winsys/drm/radeon/dri2/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -Import('*') - -env = drienv.Clone() - -drivers = [ - softpipe, - r300 -] - -env.SharedLibrary( - target ='radeon_dri.so', - source = COMMON_GALLIUM_SOURCES, - LIBS = drivers + mesa + auxiliaries + env['LIBS'], -) -- cgit v1.2.3 From 171c7f91cd3dcb41bf7abb333d725b3b3a3e9b1a Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 13:03:22 +0200 Subject: gallium dri st: Fix up some comments and minor bugs. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_context.c | 2 +- src/gallium/state_trackers/dri/dri_drawable.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 7f38671126..8e6299c540 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -128,7 +128,7 @@ dri_unbind_context(__DRIcontextPrivate * cPriv) if (--ctx->bind_count == 0) { GET_CURRENT_CONTEXT(curGLCtx); - if (ctx->st == curGLCtx->st) { + if (curGLCtx && ctx->st == curGLCtx->st) { st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); st_make_current(NULL, NULL, NULL); } diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index abda4ff17e..fd4bae5aea 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -351,10 +351,10 @@ dri1_update_drawables_locked(struct dri_context *ctx, } /** - * This ensures all contexts which binds to a drawable picks up the - * drawable change and signals new buffer state. + * This ensures all contexts which bind to a drawable pick up the + * drawable change and signal new buffer state. * Calling st_resize_framebuffer for each context may seem like overkill, - * but no new buffers will actually be allocated if the dimensions doesn't + * but no new buffers will actually be allocated if the dimensions don't * change. */ @@ -419,10 +419,10 @@ dri1_intersect_src_bbox(struct drm_clip_rect *dst, dst->x1 = xy1; dst->x2 = xy2; - xy1 = ((int)src->y1 > (int)bbox->y1 + dst_x) ? src->y1 : - (int)bbox->y1 + dst_x; - xy2 = ((int)src->y2 < (int)bbox->y2 + dst_x) ? src->y2 : - (int)bbox->y2 + dst_x; + xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 : + (int)bbox->y1 + dst_y; + xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 : + (int)bbox->y2 + dst_y; if (xy1 >= xy2 || xy1 < 0) return FALSE; @@ -522,6 +522,7 @@ dri1_flush_frontbuffer(struct pipe_screen *screen, struct pipe_fence_handle *dummy_fence; dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence); + screen->fence_reference(screen, &dummy_fence, NULL); /** * FIXME: Do we need swap throttling here? @@ -564,6 +565,7 @@ dri_swap_buffers(__DRIdrawablePrivate * dPriv) void dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) { + struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen; struct drm_clip_rect sub_bbox; struct dri_context *ctx; struct pipe_surface *back_surf; @@ -588,6 +590,7 @@ dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) if (back_surf) { st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence); + screen->fence_reference(screen, &dummy_fence, NULL); } } -- cgit v1.2.3 From c9b336bc936a733b1273170fc5e2ecc4980116b2 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 28 Apr 2009 01:00:51 +0200 Subject: gallium-intel: Fix build of dri driver --- src/gallium/winsys/drm/intel/dri/Makefile | 23 +++++++++++++++++++++++ src/gallium/winsys/drm/intel/dri2/Makefile | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 src/gallium/winsys/drm/intel/dri/Makefile delete mode 100644 src/gallium/winsys/drm/intel/dri2/Makefile (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile new file mode 100644 index 0000000000..125e79e0ed --- /dev/null +++ b/src/gallium/winsys/drm/intel/dri/Makefile @@ -0,0 +1,23 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +LIBNAME = i915_dri.so + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/i915simple/libi915simple.a + + +DRIVER_SOURCES = + +C_SOURCES = \ + $(COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +include ../../Makefile.template + +DRI_LIB_DEPS += -ldrm_intel + +symlinks: diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile deleted file mode 100644 index 125e79e0ed..0000000000 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = i915_dri.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/i915simple/libi915simple.a - - -DRIVER_SOURCES = - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -include ../../Makefile.template - -DRI_LIB_DEPS += -ldrm_intel - -symlinks: -- cgit v1.2.3 From aef3bccbdaf20f7e0e1fdab0084f60556a12d55d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 28 Apr 2009 12:56:21 +0100 Subject: gallium-intel: Create a i965_dri.so symlink This is only used for debuging the gem backend on i965 chipset using the softpipe pipe driver. Usage: "export INTEL_SOFTPIPE=y" and point LIBGL_DRIVERS_PATH to "$MESA/lib/gallium" where $MESA is the mesa root. --- src/gallium/winsys/drm/intel/dri/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile index 125e79e0ed..a4704bc050 100644 --- a/src/gallium/winsys/drm/intel/dri/Makefile +++ b/src/gallium/winsys/drm/intel/dri/Makefile @@ -20,4 +20,6 @@ include ../../Makefile.template DRI_LIB_DEPS += -ldrm_intel -symlinks: +symlinks: $(TOP)/$(LIB_DIR)/gallium + @rm -f $(TOP)/lib/gallium/i965_dri.so + ln -s i915_dri.so $(TOP)/lib/gallium/i965_dri.so -- cgit v1.2.3 From 8cfa6546c9aa25edad3e7bc3cf6f1a9399052b79 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 14:20:45 +0200 Subject: gallium dri st: Use st_get_current() instead of GET_CURRENT_CONTEXT() Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_context.c | 11 ++++------- src/gallium/state_trackers/dri/dri_drawable.c | 14 ++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 8e6299c540..54d2a56356 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -126,9 +126,7 @@ dri_unbind_context(__DRIcontextPrivate * cPriv) struct dri_context *ctx = dri_context(cPriv); if (--ctx->bind_count == 0) { - GET_CURRENT_CONTEXT(curGLCtx); - - if (curGLCtx && ctx->st == curGLCtx->st) { + if (ctx->st && ctx->st == st_get_current()) { st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); st_make_current(NULL, NULL, NULL); } @@ -148,11 +146,10 @@ dri_make_current(__DRIcontextPrivate * cPriv, struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); struct dri_drawable *draw = dri_drawable(driDrawPriv); struct dri_drawable *read = dri_drawable(driReadPriv); + struct st_context *old_st = st_get_current(); - GET_CURRENT_CONTEXT(oldGLCtx); - - if (oldGLCtx && oldGLCtx->st != ctx->st) - st_flush(oldGLCtx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + if (old_st && old_st != ctx->st) + st_flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL); ++ctx->bind_count; diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index fd4bae5aea..15a2088df5 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -537,15 +537,14 @@ dri_swap_buffers(__DRIdrawablePrivate * dPriv) struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; struct pipe_fence_handle *fence; - - GET_CURRENT_CONTEXT(glCtx); + struct st_context *st = st_get_current(); assert(__dri1_api_hooks != NULL); - if (!glCtx) + if (!st) return; /* For now */ - ctx = (struct dri_context *)glCtx->st->pipe->priv; + ctx = (struct dri_context *)st->pipe->priv; st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); if (back_surf) { @@ -571,15 +570,14 @@ dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) struct pipe_surface *back_surf; struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_fence_handle *dummy_fence; - - GET_CURRENT_CONTEXT(glCtx); + struct st_context *st = st_get_current(); assert(__dri1_api_hooks != NULL); - if (!glCtx) + if (!st) return; - ctx = (struct dri_context *)glCtx->st->pipe->priv; + ctx = (struct dri_context *)st->pipe->priv; sub_bbox.x1 = x; sub_bbox.x2 = x + w; -- cgit v1.2.3 From 2c994ad3cb91288966bdc028b0afa9935a51a971 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 14:43:41 +0200 Subject: gallium dri st: Propagate the drawable info when we bind to new drawables. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_context.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 54d2a56356..45eaec4ed3 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -158,9 +158,14 @@ dri_make_current(__DRIcontextPrivate * cPriv, */ screen->dummyContext = ctx; - /* used in dri_flush_frontbuffer */ - ctx->dPriv = driDrawPriv; - ctx->rPriv = driReadPriv; + if (ctx->dPriv != driDrawPriv) { + ctx->dPriv = driDrawPriv; + ctx->d_stamp = driDrawPriv->lastStamp - 1; + } + if (ctx->rPriv != driReadPriv) { + ctx->rPriv = driReadPriv; + ctx->r_stamp = driReadPriv->lastStamp - 1; + } st_make_current(ctx->st, draw->stfb, read->stfb); -- cgit v1.2.3 From 43e24a5928aaf6a00f7d9e55e92abfb1b3e20166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 27 Apr 2009 20:24:55 +0100 Subject: wgl: Store current HDC/HGLRC in stw_context. Less TLS lookups. --- .../state_trackers/wgl/shared/stw_context.c | 66 ++++++++++++++-------- .../state_trackers/wgl/shared/stw_context.h | 1 + src/gallium/state_trackers/wgl/shared/stw_tls.h | 2 - 3 files changed, 44 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index f3c7af93f5..0b5dd78ec6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -101,7 +101,7 @@ stw_create_layer_context( ctx = CALLOC_STRUCT( stw_context ); if (ctx == NULL) - return 0; + goto no_ctx; ctx->hdc = hdc; ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL ); @@ -125,7 +125,7 @@ stw_create_layer_context( pf->pfd.cAccumAlphaBits, pf->numSamples ); if (visual == NULL) - goto fail; + goto no_visual; screen = stw_dev->screen; @@ -137,7 +137,7 @@ stw_create_layer_context( pipe = stw_dev->stw_winsys->create_context( screen ); if (pipe == NULL) - goto fail; + goto no_pipe; #ifdef DEBUG /* Wrap context */ @@ -150,28 +150,29 @@ stw_create_layer_context( ctx->st = st_create_context( pipe, visual, NULL ); if (ctx->st == NULL) - goto fail; + goto no_st_ctx; ctx->st->ctx->DriverCtx = ctx; ctx->pfi = pf; pipe_mutex_lock( stw_dev->mutex ); - hglrc = handle_table_add(stw_dev->ctx_table, ctx); + ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx); pipe_mutex_unlock( stw_dev->mutex ); - - /* Success? - */ - if (hglrc != 0) - return hglrc; - -fail: - if (visual) - _mesa_destroy_visual( visual ); - - if (pipe) - pipe->destroy( pipe ); - + if (!ctx->hglrc) + goto no_hglrc; + + return ctx->hglrc; + +no_hglrc: + st_destroy_context(ctx->st); + goto no_pipe; /* st_context_destroy already destroys pipe */ +no_st_ctx: + pipe->destroy( pipe ); +no_pipe: + _mesa_destroy_visual( visual ); +no_visual: FREE( ctx ); +no_ctx: return 0; } @@ -271,13 +272,35 @@ stw_get_window_size( HDC hdc, GLuint *width, GLuint *height ) UINT_PTR stw_get_current_context( void ) { - return stw_tls_get_data()->currentGLRC; + GET_CURRENT_CONTEXT( glcurctx ); + struct stw_context *ctx; + + if(!glcurctx) + return NULL; + + ctx = (struct stw_context *)glcurctx->DriverCtx; + assert(ctx); + if(!ctx) + return NULL; + + return ctx->hglrc; } HDC stw_get_current_dc( void ) { - return stw_tls_get_data()->currentDC; + GET_CURRENT_CONTEXT( glcurctx ); + struct stw_context *ctx; + + if(!glcurctx) + return NULL; + + ctx = (struct stw_context *)glcurctx->DriverCtx; + assert(ctx); + if(!ctx) + return NULL; + + return ctx->hdc; } BOOL @@ -299,9 +322,6 @@ stw_make_current( ctx = stw_lookup_context_locked( hglrc ); pipe_mutex_unlock( stw_dev->mutex ); - stw_tls_get_data()->currentDC = hdc; - stw_tls_get_data()->currentGLRC = hglrc; - if (glcurctx != NULL) { curctx = (struct stw_context *) glcurctx->DriverCtx; diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index bc3b1dc880..e276737e85 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -36,6 +36,7 @@ struct stw_pixelformat_info; struct stw_context { struct st_context *st; + UINT_PTR hglrc; HDC hdc; DWORD color_bits; const struct stw_pixelformat_info *pfi; diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h index f5a6bdf4b1..6cfb0899f2 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.h +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h @@ -33,8 +33,6 @@ struct stw_tls_data { uint currentPixelFormat; - HDC currentDC; - UINT_PTR currentGLRC; HHOOK hCallWndProcHook; }; -- cgit v1.2.3 From b91e5f8e197793feac016242140bf489bd16071c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 27 Apr 2009 19:36:42 +0100 Subject: util/indices: remove debug prints --- src/gallium/auxiliary/indices/u_unfilled_gen.c | 160 ------------------------ src/gallium/auxiliary/indices/u_unfilled_gen.py | 1 - 2 files changed, 161 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c index fd082ebbb3..93897c98de 100644 --- a/src/gallium/auxiliary/indices/u_unfilled_gen.c +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.c @@ -71,13 +71,10 @@ static void generate_tris_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (ushort)(i); (out+j)[1] = (ushort)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)(i+1); (out+j+2)[1] = (ushort)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (ushort)(i+2); (out+j+4)[1] = (ushort)(i); } @@ -90,13 +87,10 @@ static void generate_tristrip_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (ushort)(i); (out+j)[1] = (ushort)(i+1/*+(i&1)*/); - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/); (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/); - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (ushort)(i+2/*-(i&1)*/); (out+j+4)[1] = (ushort)(i); } @@ -109,13 +103,10 @@ static void generate_trifan_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)(0); (out+j)[1] = (ushort)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)(i+1); (out+j+2)[1] = (ushort)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)(i+2); (out+j+4)[1] = (ushort)(0); } @@ -128,16 +119,12 @@ static void generate_quads_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (ushort)(i+0); (out+j)[1] = (ushort)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)(i+1); (out+j+2)[1] = (ushort)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (ushort)(i+2); (out+j+4)[1] = (ushort)(i+3); - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (ushort)(i+3); (out+j+6)[1] = (ushort)(i+0); } @@ -150,16 +137,12 @@ static void generate_quadstrip_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (ushort)(i+2); (out+j)[1] = (ushort)(i+0); - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (ushort)(i+0); (out+j+2)[1] = (ushort)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (ushort)(i+1); (out+j+4)[1] = (ushort)(i+3); - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (ushort)(i+3); (out+j+6)[1] = (ushort)(i+2); } @@ -172,13 +155,10 @@ static void generate_polygon_ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)(0); (out+j)[1] = (ushort)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)(i+1); (out+j+2)[1] = (ushort)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)(i+2); (out+j+4)[1] = (ushort)(0); } @@ -191,13 +171,10 @@ static void generate_tris_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (uint)(i); (out+j)[1] = (uint)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)(i+1); (out+j+2)[1] = (uint)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (uint)(i+2); (out+j+4)[1] = (uint)(i); } @@ -210,13 +187,10 @@ static void generate_tristrip_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (uint)(i); (out+j)[1] = (uint)(i+1/*+(i&1)*/); - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (uint)(i+1/*+(i&1)*/); (out+j+2)[1] = (uint)(i+2/*-(i&1)*/); - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (uint)(i+2/*-(i&1)*/); (out+j+4)[1] = (uint)(i); } @@ -229,13 +203,10 @@ static void generate_trifan_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)(0); (out+j)[1] = (uint)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)(i+1); (out+j+2)[1] = (uint)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)(i+2); (out+j+4)[1] = (uint)(0); } @@ -248,16 +219,12 @@ static void generate_quads_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (uint)(i+0); (out+j)[1] = (uint)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)(i+1); (out+j+2)[1] = (uint)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (uint)(i+2); (out+j+4)[1] = (uint)(i+3); - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (uint)(i+3); (out+j+6)[1] = (uint)(i+0); } @@ -270,16 +237,12 @@ static void generate_quadstrip_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (uint)(i+2); (out+j)[1] = (uint)(i+0); - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (uint)(i+0); (out+j+2)[1] = (uint)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (uint)(i+1); (out+j+4)[1] = (uint)(i+3); - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (uint)(i+3); (out+j+6)[1] = (uint)(i+2); } @@ -292,13 +255,10 @@ static void generate_polygon_uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)(0); (out+j)[1] = (uint)(i+1); - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)(i+1); (out+j+2)[1] = (uint)(i+2); - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)(i+2); (out+j+4)[1] = (uint)(0); } @@ -313,13 +273,10 @@ static void translate_tris_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i]; } @@ -334,13 +291,10 @@ static void translate_tristrip_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (ushort)in[i]; } @@ -355,13 +309,10 @@ static void translate_trifan_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -376,16 +327,12 @@ static void translate_quads_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (ushort)in[i+0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+0]; } @@ -400,16 +347,12 @@ static void translate_quadstrip_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (ushort)in[i+2]; (out+j)[1] = (ushort)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (ushort)in[i+0]; (out+j+2)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (ushort)in[i+1]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+2]; } @@ -424,13 +367,10 @@ static void translate_polygon_ubyte2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -445,13 +385,10 @@ static void translate_tris_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i]; } @@ -466,13 +403,10 @@ static void translate_tristrip_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (uint)in[i]; } @@ -487,13 +421,10 @@ static void translate_trifan_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } @@ -508,16 +439,12 @@ static void translate_quads_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (uint)in[i+0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+0]; } @@ -532,16 +459,12 @@ static void translate_quadstrip_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (uint)in[i+2]; (out+j)[1] = (uint)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (uint)in[i+0]; (out+j+2)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (uint)in[i+1]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+2]; } @@ -556,13 +479,10 @@ static void translate_polygon_ubyte2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } @@ -577,13 +497,10 @@ static void translate_tris_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i]; } @@ -598,13 +515,10 @@ static void translate_tristrip_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (ushort)in[i]; } @@ -619,13 +533,10 @@ static void translate_trifan_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -640,16 +551,12 @@ static void translate_quads_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (ushort)in[i+0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+0]; } @@ -664,16 +571,12 @@ static void translate_quadstrip_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (ushort)in[i+2]; (out+j)[1] = (ushort)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (ushort)in[i+0]; (out+j+2)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (ushort)in[i+1]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+2]; } @@ -688,13 +591,10 @@ static void translate_polygon_ushort2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -709,13 +609,10 @@ static void translate_tris_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i]; } @@ -730,13 +627,10 @@ static void translate_tristrip_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (uint)in[i]; } @@ -751,13 +645,10 @@ static void translate_trifan_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } @@ -772,16 +663,12 @@ static void translate_quads_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (uint)in[i+0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+0]; } @@ -796,16 +683,12 @@ static void translate_quadstrip_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (uint)in[i+2]; (out+j)[1] = (uint)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (uint)in[i+0]; (out+j+2)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (uint)in[i+1]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+2]; } @@ -820,13 +703,10 @@ static void translate_polygon_ushort2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } @@ -841,13 +721,10 @@ static void translate_tris_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i]; } @@ -862,13 +739,10 @@ static void translate_tristrip_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (ushort)in[i]; (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (ushort)in[i]; } @@ -883,13 +757,10 @@ static void translate_trifan_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -904,16 +775,12 @@ static void translate_quads_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (ushort)in[i+0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+0]; } @@ -928,16 +795,12 @@ static void translate_quadstrip_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (ushort)in[i+2]; (out+j)[1] = (ushort)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (ushort)in[i+0]; (out+j+2)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (ushort)in[i+1]; (out+j+4)[1] = (ushort)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (ushort)in[i+3]; (out+j+6)[1] = (ushort)in[i+2]; } @@ -952,13 +815,10 @@ static void translate_polygon_uint2ushort( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (ushort)in[0]; (out+j)[1] = (ushort)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (ushort)in[i+1]; (out+j+2)[1] = (ushort)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (ushort)in[i+2]; (out+j+4)[1] = (ushort)in[0]; } @@ -973,13 +833,10 @@ static void translate_tris_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i+=3) { - debug_printf(" line %d %d\n", (int)i, (int)i+1); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i]; } @@ -994,13 +851,10 @@ static void translate_tristrip_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/); (out+j)[0] = (uint)in[i]; (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/); (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i); (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; (out+j+4)[1] = (uint)in[i]; } @@ -1015,13 +869,10 @@ static void translate_trifan_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } @@ -1036,16 +887,12 @@ static void translate_quads_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=4) { - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j)[0] = (uint)in[i+0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)i+3); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+0); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+0]; } @@ -1060,16 +907,12 @@ static void translate_quadstrip_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=8, i+=2) { - debug_printf(" line %d %d\n", (int)i+2, (int)i+0); (out+j)[0] = (uint)in[i+2]; (out+j)[1] = (uint)in[i+0]; - debug_printf(" line %d %d\n", (int)i+0, (int)i+1); (out+j+2)[0] = (uint)in[i+0]; (out+j+2)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+3); (out+j+4)[0] = (uint)in[i+1]; (out+j+4)[1] = (uint)in[i+3]; - debug_printf(" line %d %d\n", (int)i+3, (int)i+2); (out+j+6)[0] = (uint)in[i+3]; (out+j+6)[1] = (uint)in[i+2]; } @@ -1084,13 +927,10 @@ static void translate_polygon_uint2uint( unsigned i, j; (void)j; for (j = i = 0; j < nr; j+=6, i++) { - debug_printf(" line %d %d\n", (int)0, (int)i+1); (out+j)[0] = (uint)in[0]; (out+j)[1] = (uint)in[i+1]; - debug_printf(" line %d %d\n", (int)i+1, (int)i+2); (out+j+2)[0] = (uint)in[i+1]; (out+j+2)[1] = (uint)in[i+2]; - debug_printf(" line %d %d\n", (int)i+2, (int)0); (out+j+4)[0] = (uint)in[i+2]; (out+j+4)[1] = (uint)in[0]; } diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py index d0344fe313..36896ce605 100644 --- a/src/gallium/auxiliary/indices/u_unfilled_gen.py +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py @@ -99,7 +99,6 @@ def vert( intype, outtype, v0 ): return '(' + outtype + ')in[' + v0 + ']' def line( intype, outtype, ptr, v0, v1 ): - print ' debug_printf(" line %d %d\\n", (int)' + v0 + ', (int)' + v1 + ');' print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' -- cgit v1.2.3 From eb979cef8535914f428d2462e78f713da558fc18 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 28 Apr 2009 14:50:05 +0100 Subject: gallium/draw: add ability to print out active pipeline stages --- src/gallium/auxiliary/draw/draw_pipe.h | 1 + src/gallium/auxiliary/draw/draw_pipe_aaline.c | 1 + src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 1 + src/gallium/auxiliary/draw/draw_pipe_clip.c | 1 + src/gallium/auxiliary/draw/draw_pipe_cull.c | 1 + src/gallium/auxiliary/draw/draw_pipe_flatshade.c | 1 + src/gallium/auxiliary/draw/draw_pipe_offset.c | 1 + src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 1 + src/gallium/auxiliary/draw/draw_pipe_stipple.c | 1 + src/gallium/auxiliary/draw/draw_pipe_twoside.c | 1 + src/gallium/auxiliary/draw/draw_pipe_unfilled.c | 1 + src/gallium/auxiliary/draw/draw_pipe_validate.c | 11 ++++++++++- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_line.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 1 + 15 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h index dbad8f98ac..479250729f 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.h +++ b/src/gallium/auxiliary/draw/draw_pipe.h @@ -57,6 +57,7 @@ struct draw_stage struct draw_context *draw; /**< parent context */ struct draw_stage *next; /**< next stage in pipeline */ + const char *name; /**< for debugging */ struct vertex_header **tmp; /**< temp vert storage, such as for clipping */ unsigned nr_tmps; diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index ca69f0b95e..9fedeef2d3 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -746,6 +746,7 @@ draw_aaline_stage(struct draw_context *draw) goto fail; aaline->stage.draw = draw; + aaline->stage.name = "aaline"; aaline->stage.next = NULL; aaline->stage.point = draw_pipe_passthrough_point; aaline->stage.line = aaline_first_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 3133abe5dc..66839f7873 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -757,6 +757,7 @@ draw_aapoint_stage(struct draw_context *draw) goto fail; aapoint->stage.draw = draw; + aapoint->stage.name = "aapoint"; aapoint->stage.next = NULL; aapoint->stage.point = aapoint_first_point; aapoint->stage.line = draw_pipe_passthrough_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index 3265dcd154..0670268a19 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -496,6 +496,7 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw ) goto fail; clipper->stage.draw = draw; + clipper->stage.name = "clipper"; clipper->stage.point = clip_point; clipper->stage.line = clip_first_line; clipper->stage.tri = clip_first_tri; diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c index 053be5f050..0a70483858 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_cull.c +++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c @@ -129,6 +129,7 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw ) goto fail; cull->stage.draw = draw; + cull->stage.name = "cull"; cull->stage.next = NULL; cull->stage.point = draw_pipe_passthrough_point; cull->stage.line = draw_pipe_passthrough_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c index 43d1fecc4d..34afb1a0b6 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c +++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c @@ -261,6 +261,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) goto fail; flatshade->stage.draw = draw; + flatshade->stage.name = "flatshade"; flatshade->stage.next = NULL; flatshade->stage.point = draw_pipe_passthrough_point; flatshade->stage.line = flatshade_first_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c index 62c31532d0..40798a5d6e 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_offset.c +++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c @@ -166,6 +166,7 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw ) draw_alloc_temp_verts( &offset->stage, 3 ); offset->stage.draw = draw; + offset->stage.name = "offset"; offset->stage.next = NULL; offset->stage.point = draw_pipe_passthrough_point; offset->stage.line = draw_pipe_passthrough_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 04e59152c5..9287fc130e 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -586,6 +586,7 @@ draw_pstip_stage(struct draw_context *draw) draw_alloc_temp_verts( &pstip->stage, 8 ); pstip->stage.draw = draw; + pstip->stage.name = "pstip"; pstip->stage.next = NULL; pstip->stage.point = draw_pipe_passthrough_point; pstip->stage.line = draw_pipe_passthrough_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c index b65e2aa102..6e921bac27 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c @@ -238,6 +238,7 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw ) draw_alloc_temp_verts( &stipple->stage, 2 ); stipple->stage.draw = draw; + stipple->stage.name = "stipple"; stipple->stage.next = NULL; stipple->stage.point = stipple_reset_point; stipple->stage.line = stipple_first_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c index c329d92339..eef0238b15 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c +++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c @@ -181,6 +181,7 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw ) goto fail; twoside->stage.draw = draw; + twoside->stage.name = "twoside"; twoside->stage.next = NULL; twoside->stage.point = draw_pipe_passthrough_point; twoside->stage.line = draw_pipe_passthrough_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c index 68835fd1a5..03bb842e20 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c +++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c @@ -184,6 +184,7 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw ) goto fail; unfilled->stage.draw = draw; + unfilled->stage.name = "unfilled"; unfilled->stage.next = NULL; unfilled->stage.tmp = NULL; unfilled->stage.point = draw_pipe_passthrough_point; diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index 03e842ce08..bea90e50d3 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -262,7 +262,15 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) draw->pipeline.first = next; - return next; + + if (0) { + debug_printf("draw pipeline:\n"); + for (next = draw->pipeline.first; next ; next = next->next ) + debug_printf(" %s\n", next->name); + debug_printf("\n"); + } + + return draw->pipeline.first; } static void validate_tri( struct draw_stage *stage, @@ -318,6 +326,7 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw ) return NULL; stage->draw = draw; + stage->name = "validate"; stage->next = NULL; stage->point = validate_point; stage->line = validate_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 12325d30d6..a5d840b96e 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -446,6 +446,7 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw, goto fail; vbuf->stage.draw = draw; + vbuf->stage.name = "vbuf"; vbuf->stage.point = vbuf_first_point; vbuf->stage.line = vbuf_first_line; vbuf->stage.tri = vbuf_first_tri; diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c index 184e363594..f32cbef983 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c @@ -168,6 +168,7 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw ) draw_alloc_temp_verts( &wide->stage, 4 ); wide->stage.draw = draw; + wide->stage.name = "wide-line"; wide->stage.next = NULL; wide->stage.point = draw_pipe_passthrough_point; wide->stage.line = wideline_line; diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index e1af9e56a2..49034ae86a 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -279,6 +279,7 @@ struct draw_stage *draw_wide_point_stage( struct draw_context *draw ) goto fail; wide->stage.draw = draw; + wide->stage.name = "wide-point"; wide->stage.next = NULL; wide->stage.point = widepoint_first_point; wide->stage.line = draw_pipe_passthrough_line; -- cgit v1.2.3 From 46ddcbc1a9e70d5dba257e6421eb69ed942dd1da Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 28 Apr 2009 14:29:27 -0600 Subject: softpipe: return PIPE_UNREFERENCED in softpipe_is_buffer/texture_referenced() This allows the engine demo to run again (avoid crash in VBO code). This stuff still needs to be revisited someday though... --- src/gallium/drivers/softpipe/sp_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 11aff81479..62e8d99cfd 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -126,14 +126,14 @@ softpipe_is_texture_referenced( struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level) { - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; + return PIPE_UNREFERENCED; } static unsigned int softpipe_is_buffer_referenced( struct pipe_context *pipe, struct pipe_buffer *buf) { - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; + return PIPE_UNREFERENCED; } struct pipe_context * -- cgit v1.2.3 From 8fa6c1ac9299402c1faf75b264cf70b1b83d1eff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 29 Apr 2009 11:56:57 -0600 Subject: tgsi: added tgsi_check_soa_dependencies() and related debug code (disabled) The TGSI interpeter operates in SOA style. We need to check for data dependencies in instructions which read from and write to the same register. For now just adding some debug code to detect that condition. Actual fixes to follow. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index e8bd7cda3b..aba7a3f937 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -53,6 +53,7 @@ #include "pipe/p_compiler.h" #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" +#include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_util.h" #include "tgsi_exec.h" @@ -169,6 +170,56 @@ print_temp(const struct tgsi_exec_machine *mach, uint index) #endif +/** + * Check if there's a potential src/dst register data dependency when + * using SOA execution. + * Example: + * MOV T, T.yxwz; + * This would expand into: + * MOV t0, t1; + * MOV t1, t0; + * MOV t2, t3; + * MOV t3, t2; + * The second instruction will have the wrong value for t0 if executed as-is. + */ +static boolean +tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst) +{ + uint i, chan; + + uint writemask = inst->FullDstRegisters[0].DstRegister.WriteMask; + if (writemask == TGSI_WRITEMASK_X || + writemask == TGSI_WRITEMASK_Y || + writemask == TGSI_WRITEMASK_Z || + writemask == TGSI_WRITEMASK_W || + writemask == TGSI_WRITEMASK_NONE) { + /* no chance of data dependency */ + return FALSE; + } + + /* loop over src regs */ + for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { + if ((inst->FullSrcRegisters[i].SrcRegister.File == + inst->FullDstRegisters[0].DstRegister.File) && + (inst->FullSrcRegisters[i].SrcRegister.Index == + inst->FullDstRegisters[0].DstRegister.Index)) { + /* loop over dest channels */ + uint channelsWritten = 0x0; + FOR_EACH_ENABLED_CHANNEL(*inst, chan) { + /* check if we're reading a channel that's been written */ + uint swizzle = tgsi_util_get_full_src_register_extswizzle(&inst->FullSrcRegisters[i], chan); + if (swizzle <= TGSI_SWIZZLE_W && + (channelsWritten & (1 << swizzle))) { + return TRUE; + } + + channelsWritten |= (1 << chan); + } + } + } + return FALSE; +} + /** * Initialize machine state by expanding tokens to full instructions, @@ -280,6 +331,17 @@ tgsi_exec_machine_bind_shader( memcpy(instructions + numInstructions, &parse.FullToken.FullInstruction, sizeof(instructions[0])); + +#if 0 + if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) { + debug_printf("SOA dependency in instruction:\n"); + tgsi_dump_instruction(&parse.FullToken.FullInstruction, + numInstructions); + } +#else + (void) tgsi_check_soa_dependencies; +#endif + numInstructions++; break; -- cgit v1.2.3 From ba27fe3710af4933a16278a3e97162bef1737b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 30 Apr 2009 09:39:29 +0200 Subject: gallium: Add SCons build support for the DRI state tracker. --- src/gallium/SConscript | 1 + src/gallium/state_trackers/dri/SConscript | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/gallium/state_trackers/dri/SConscript (limited to 'src/gallium') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index 0c632ac2b8..b6ceaf3edf 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -29,6 +29,7 @@ for driver in env['drivers']: SConscript('state_trackers/python/SConscript') SConscript('state_trackers/glx/xlib/SConscript') +SConscript('state_trackers/dri/SConscript') if platform == 'windows': SConscript('state_trackers/wgl/SConscript') diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript new file mode 100644 index 0000000000..ce2c273597 --- /dev/null +++ b/src/gallium/state_trackers/dri/SConscript @@ -0,0 +1,23 @@ +####################################################################### +# SConscript for dri state_tracker + +Import('*') + +if env['dri']: + + env = env.Clone() + + env.Append(CPPPATH = [ + '#/src/mesa', + '#/src/mesa/drivers/dri/common', + ]) + + st_dri = env.ConvenienceLibrary( + target = 'st_dri', + source = [ 'dri_context.c', + 'dri_drawable.c', + 'dri_extensions.c', + 'dri_screen.c', + ] + ) + Export('st_dri') -- cgit v1.2.3 From 60927f97f7b0df9ce352d0c8b4b973e97d53f20a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 30 Apr 2009 16:52:02 -0600 Subject: i915simple: remove duplicated i915_context.c in C_SOURCES --- src/gallium/drivers/i915simple/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile index 12821c5a76..8870b39866 100644 --- a/src/gallium/drivers/i915simple/Makefile +++ b/src/gallium/drivers/i915simple/Makefile @@ -8,7 +8,6 @@ C_SOURCES = \ i915_clear.c \ i915_flush.c \ i915_context.c \ - i915_context.c \ i915_debug.c \ i915_debug_fp.c \ i915_state.c \ -- cgit v1.2.3 From 9cb3cdec76b679f15c591955084bd48e91a32142 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Thu, 30 Apr 2009 16:52:56 -0600 Subject: mesa: Prepend "-Wl," to linking options Let mklib ignore -Wl options inside the object list when building static libraries --- src/gallium/winsys/egl_xlib/Makefile | 2 +- src/gallium/winsys/xlib/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 02ac47caa4..8646ee3b52 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -60,7 +60,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS) -noprefix \ -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) \ - --whole-archive $(LIBS) --no-whole-archive + -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive depend: $(ALL_SOURCES) diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index bb187cc14a..04309e67ee 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -74,7 +74,7 @@ $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefil -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ -install $(TOP)/$(LIB_DIR)/gallium \ $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \ - --start-group $(LIBS) --end-group $(GL_LIB_DEPS) + -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS) depend: $(XLIB_WINSYS_SOURCES) -- cgit v1.2.3 From 1f43cc1d841d3be04433224842f89ff03ba28a02 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 04:37:56 -0700 Subject: radeon: Fix cast and comment. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 3302d623bf..adbf23ab51 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -56,8 +56,7 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) int target; int retval; - /* XXX is this cast safe? */ - gp.value = (int*)⌖ + gp.value = ⌖ /* First, get the number of pixel pipes */ gp.param = RADEON_PARAM_NUM_GB_PIPES; -- cgit v1.2.3 From a609f78cf688c97eda8cde3d876397e042fdb60d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 04:47:50 -0700 Subject: r300-gallium: Don't bother with conditional double define. We'll just forever leave it in r300_winsys.h since it's needed for whichever winsys is hosting the pipe. --- src/gallium/drivers/r300/r300_context.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 4c695c1195..6f62998b35 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -314,11 +314,4 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300); void r300_init_state_functions(struct r300_context* r300); void r300_init_surface_functions(struct r300_context* r300); -/* Fun with includes: r300_winsys also declares this prototype. - * We'll just step out in that case... */ -#ifndef R300_WINSYS_H -struct pipe_context* r300_create_context(struct pipe_screen* screen, - struct r300_winsys* r300_winsys); -#endif - #endif /* R300_CONTEXT_H */ -- cgit v1.2.3 From d7f4ac9f34a72efe53a1a140557f1822afbadf16 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 05:03:56 -0700 Subject: r300-gallium, radeon-winsys: Reorganize r300_winsys header, break ABI. Make things more consistent, prepare for more function hooks. --- src/gallium/drivers/r300/r300_cs.h | 18 ++++---- src/gallium/drivers/r300/r300_winsys.h | 46 ++++++++++---------- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 53 +++++++++++++++++------- 3 files changed, 70 insertions(+), 47 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 5d9799dd72..82a3942248 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -49,27 +49,27 @@ #define CS_LOCALS(context) \ struct r300_winsys* cs_winsys = context->winsys; \ - struct radeon_cs* cs = cs_winsys->cs; \ int cs_count = 0; #define CHECK_CS(size) \ - cs_winsys->check_cs(cs, (size)) + cs_winsys->check_cs(cs_winsys, (size)) #define BEGIN_CS(size) do { \ CHECK_CS(size); \ debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \ size, __FUNCTION__, __FILE__, __LINE__); \ - cs_winsys->begin_cs(cs, (size), __FILE__, __FUNCTION__, __LINE__); \ + cs_winsys->begin_cs(cs_winsys, (size), \ + __FILE__, __FUNCTION__, __LINE__); \ cs_count = size; \ } while (0) #define OUT_CS(value) do { \ - cs_winsys->write_cs_dword(cs, (value)); \ + cs_winsys->write_cs_dword(cs_winsys, (value)); \ cs_count--; \ } while (0) #define OUT_CS_32F(value) do { \ - cs_winsys->write_cs_dword(cs, fui(value)); \ + cs_winsys->write_cs_dword(cs_winsys, fui(value)); \ cs_count--; \ } while (0) @@ -97,7 +97,7 @@ bo, offset); \ assert(bo); \ OUT_CS(offset); \ - cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \ + cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ cs_count -= 2; \ } while (0) @@ -106,13 +106,13 @@ __LINE__); \ if (cs_count != 0) \ debug_printf("r300: Warning: cs_count off by %d\n", cs_count); \ - cs_winsys->end_cs(cs, __FILE__, __FUNCTION__, __LINE__); \ + cs_winsys->end_cs(cs_winsys, __FILE__, __FUNCTION__, __LINE__); \ } while (0) #define FLUSH_CS do { \ debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, __FILE__, \ __LINE__); \ - cs_winsys->flush_cs(cs); \ + cs_winsys->flush_cs(cs_winsys); \ } while (0) #define RADEON_ONE_REG_WR (1 << 15) @@ -138,7 +138,7 @@ assert(bo); \ OUT_CS(offset); \ OUT_CS(count); \ - cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \ + cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ cs_count -= 2; \ } while (0) diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index baa95282c3..393ba07012 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -35,8 +35,6 @@ extern "C" { #include "pipe/p_state.h" #include "pipe/internal/p_winsys_screen.h" -struct radeon_cs; - struct r300_winsys { /* Parent class */ struct pipe_winsys base; @@ -44,45 +42,45 @@ struct r300_winsys { /* Opaque Radeon-specific winsys object. */ void* radeon_winsys; + /* CS object. This is very much like Intel's batchbuffer. + * Fill it full of dwords and relocs and then submit. + * Repeat as needed. */ + struct radeon_cs* cs; + /* PCI ID */ uint32_t pci_id; /* GB pipe count */ uint32_t gb_pipes; - /* CS object. This is very much like Intel's batchbuffer. - * Fill it full of dwords and relocs and then submit. - * Repeat as needed. */ - struct radeon_cs* cs; - /* Check to see if there's room for commands. */ - boolean (*check_cs)(struct radeon_cs* cs, int size); + boolean (*check_cs)(struct r300_winsys* winsys, int size); /* Start a command emit. */ - void (*begin_cs)(struct radeon_cs* cs, - int size, - const char* file, - const char* function, - int line); + void (*begin_cs)(struct r300_winsys* winsys, + int size, + const char* file, + const char* function, + int line); /* Write a dword to the command buffer. */ - void (*write_cs_dword)(struct radeon_cs* cs, uint32_t dword); + void (*write_cs_dword)(struct r300_winsys* winsys, uint32_t dword); /* Write a relocated dword to the command buffer. */ - void (*write_cs_reloc)(struct radeon_cs* cs, - struct pipe_buffer* bo, - uint32_t rd, - uint32_t wd, - uint32_t flags); + void (*write_cs_reloc)(struct r300_winsys* winsys, + struct pipe_buffer* bo, + uint32_t rd, + uint32_t wd, + uint32_t flags); /* Finish a command emit. */ - void (*end_cs)(struct radeon_cs* cs, - const char* file, - const char* function, - int line); + void (*end_cs)(struct r300_winsys* winsys, + const char* file, + const char* function, + int line); /* Flush the CS. */ - void (*flush_cs)(struct radeon_cs* cs); + void (*flush_cs)(struct r300_winsys* winsys); }; struct pipe_context* r300_create_context(struct pipe_screen* screen, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index adbf23ab51..929e4842cc 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,31 +22,56 @@ #include "radeon_r300.h" -static boolean radeon_r300_check_cs(struct radeon_cs* cs, int size) +static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size) { /* XXX check size here, lazy ass! */ + /* XXX also validate buffers */ return TRUE; } -static void radeon_r300_write_cs_reloc(struct radeon_cs* cs, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd, - uint32_t flags) +static void radeon_r300_begin_cs(struct r300_winsys* winsys, + int size, + const char* file, + const char* function, + int line) { - radeon_cs_write_reloc(cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + radeon_cs_begin(winsys->cs, size, file, function, line); } -static void radeon_r300_flush_cs(struct radeon_cs* cs) +static void radeon_r300_write_cs_dword(struct r300_winsys* winsys, + uint32_t dword) +{ + radeon_cs_write_dword(winsys->cs, dword); +} + +static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd, + uint32_t flags) +{ + radeon_cs_write_reloc(winsys->cs, + ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); +} + +static void radeon_r300_end_cs(struct r300_winsys* winsys, + const char* file, + const char* function, + int line) +{ + radeon_cs_end(winsys->cs, file, function, line); +} + +static void radeon_r300_flush_cs(struct r300_winsys* winsys) { int retval = 0; - retval = radeon_cs_emit(cs); + retval = radeon_cs_emit(winsys->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); - radeon_cs_print(cs, stderr); + radeon_cs_print(winsys->cs, stderr); } - radeon_cs_erase(cs); + radeon_cs_erase(winsys->cs); } /* Helper function to do the ioctls needed for setup and init. */ @@ -96,10 +121,10 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); winsys->check_cs = radeon_r300_check_cs; - winsys->begin_cs = radeon_cs_begin; - winsys->write_cs_dword = radeon_cs_write_dword; + winsys->begin_cs = radeon_r300_begin_cs; + winsys->write_cs_dword = radeon_r300_write_cs_dword; winsys->write_cs_reloc = radeon_r300_write_cs_reloc; - winsys->end_cs = radeon_cs_end; + winsys->end_cs = radeon_r300_end_cs; winsys->flush_cs = radeon_r300_flush_cs; memcpy(winsys, old_winsys, sizeof(struct radeon_winsys)); -- cgit v1.2.3 From c11ad489e7432f3ed2fcaf5b15b8fe3538ae6d30 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 05:54:53 -0700 Subject: r300-gallium, radeon-winsys: Space accounting. It is no longer optional in current libdrm, so it was time to actually start counting our BOs. --- src/gallium/drivers/r300/r300_emit.c | 10 +++- src/gallium/drivers/r300/r300_surface.c | 7 +++ src/gallium/drivers/r300/r300_winsys.h | 16 +++++ src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 12 +++- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 18 +++++- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 4 +- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 68 ++++++++++++++++++++++ 7 files changed, 126 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 74d63ffe41..01bac5f759 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -424,13 +424,21 @@ void r300_emit_dirty_state(struct r300_context* r300) int i; int dirty_tex = 0; - if (!(r300->dirty_state) && !(r300->dirty_hw)) { + if (!(r300->dirty_hw)) { return; } r300_update_derived_state(r300); /* XXX check size */ + struct r300_texture* fb_tex = + (struct r300_texture*)r300->framebuffer_state.cbufs[0]; + r300->winsys->add_buffer(r300->winsys, fb_tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + /* XXX */ + r300->context.flush(&r300->context, 0, NULL); + } if (r300->dirty_state & R300_NEW_BLEND) { r300_emit_blend_state(r300, r300->blend_state); diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 79bed03253..4dd5b8af99 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -34,6 +34,13 @@ static void r300_surface_setup(struct pipe_context* pipe, unsigned pixpitch = tex->stride / tex->tex.block.size; CS_LOCALS(r300); + /* Make sure our target BO is okay. */ + r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + r300->context.flush(&r300->context, 0, NULL); + } + r300_emit_blend_state(r300, &blend_clear_state); r300_emit_blend_color_state(r300, &blend_color_clear_state); r300_emit_dsa_state(r300, &dsa_clear_state); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 393ba07012..761aedebfc 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -53,6 +53,22 @@ struct r300_winsys { /* GB pipe count */ uint32_t gb_pipes; + /* GART size. */ + uint32_t gart_size; + + /* VRAM size. */ + uint32_t vram_size; + + /* Add a pipe_buffer to the list of buffer objects to validate. */ + void (*add_buffer)(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd); + + /* Revalidate all currently setup pipe_buffers. + * Returns TRUE if a flush is required. */ + boolean (*validate)(struct r300_winsys* winsys); + /* Check to see if there's room for commands. */ boolean (*check_cs)(struct r300_winsys* winsys, int size); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 611ee68da6..6313eb219e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -68,8 +68,8 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, domain |= RADEON_GEM_DOMAIN_GTT; } - radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment, - domain, 0); + radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, + alignment, domain, 0); if (radeon_buffer->bo == NULL) { FREE(radeon_buffer); } @@ -169,8 +169,14 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) return NULL; } + radeon_ws->priv = CALLOC_STRUCT(radeon_winsys_priv); + if (radeon_ws->priv == NULL) { + FREE(radeon_ws); + return NULL; + } + bom = radeon_bo_manager_gem_ctor(fd); - radeon_ws->bom = bom; + radeon_ws->priv->bom = bom; radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index 163422f296..73fa362aca 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -41,6 +41,7 @@ #include "util/u_memory.h" #include "radeon_bo.h" +#include "radeon_cs.h" #include "radeon_drm.h" @@ -49,13 +50,24 @@ struct radeon_pipe_buffer { struct radeon_bo *bo; }; +#define RADEON_MAX_BOS 24 + +struct radeon_winsys_priv { + /* Radeon BO manager. */ + struct radeon_bo_manager* bom; + + /* Radeon BO space checker. */ + struct radeon_cs_space_check sc[RADEON_MAX_BOS]; + /* Current BO count. */ + unsigned bo_count; +}; + struct radeon_winsys { /* Parent class. */ struct pipe_winsys base; - /* Radeon BO manager. - * This corresponds to void* radeon_winsys in r300_winsys. */ - struct radeon_bo_manager* bom; + /* This corresponds to void* radeon_winsys in r300_winsys. */ + struct radeon_winsys_priv* priv; }; struct radeon_winsys* radeon_pipe_winsys(int fb); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 1f89d1b1d1..428d3f65a1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -32,7 +32,7 @@ /* Create a pipe_screen. */ struct pipe_screen* radeon_create_screen(int drmFB, - struct drm_create_screen_arg *arg ) + struct drm_create_screen_arg *arg) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); @@ -69,7 +69,7 @@ struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, unsigned handle) { struct radeon_bo_manager* bom = - ((struct radeon_winsys*)screen->winsys)->bom; + ((struct radeon_winsys*)screen->winsys)->priv->bom; struct radeon_pipe_buffer* radeon_buffer; struct radeon_bo* bo = NULL; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 929e4842cc..b172107432 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,6 +22,54 @@ #include "radeon_r300.h" +static void radeon_r300_add_buffer(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd) +{ + int i; + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + struct radeon_cs_space_check* sc = priv->sc; + struct radeon_bo* bo = ((struct radeon_pipe_buffer*)pbuffer)->bo; + + /* Check to see if this BO is already in line for validation; + * find a slot for it otherwise. */ + for (i = 0; i < RADEON_MAX_BOS; i++) { + if (sc[i].bo == bo) { + return; + } else if (sc[i].bo == NULL) { + sc[i].bo = bo; + sc[i].read_domains = rd; + sc[i].write_domain = wd; + priv->bo_count = i + 1; + return; + } + } + + assert(FALSE && "Oh God too many BOs!"); +} + +static boolean radeon_r300_validate(struct r300_winsys* winsys) +{ + int retval; + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + struct radeon_cs_space_check* sc = priv->sc; + + retval = radeon_cs_space_check(winsys->cs, sc, priv->bo_count); + + if (retval == RADEON_CS_SPACE_OP_TO_BIG) { + /* XXX we need to failover here */ + } else if (retval == RADEON_CS_SPACE_FLUSH) { + /* We must flush before more rendering can commence. */ + return TRUE; + } + + /* Things are fine, we can proceed as normal. */ + return FALSE; +} + static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size) { /* XXX check size here, lazy ass! */ @@ -77,6 +125,7 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(struct r300_winsys* winsys, int fd) { + struct drm_radeon_gem_info info; drm_radeon_getparam_t gp; int target; int retval; @@ -102,6 +151,18 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) exit(1); } winsys->pci_id = target; + + /* Finally, retrieve MM info */ + retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO, + &info, sizeof(info)); + if (retval) { + fprintf(stderr, "%s: Failed to get MM info, error number %d\n", + __FUNCTION__, retval); + exit(1); + } + winsys->gart_size = info.gart_size; + /* XXX */ + winsys->vram_size = info.vram_visible; } struct r300_winsys* @@ -119,6 +180,13 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) csm = radeon_cs_manager_gem_ctor(fd); winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); + radeon_cs_set_limit(winsys->cs, + RADEON_GEM_DOMAIN_GTT, winsys->gart_size); + radeon_cs_set_limit(winsys->cs, + RADEON_GEM_DOMAIN_VRAM, winsys->vram_size); + + winsys->add_buffer = radeon_r300_add_buffer; + winsys->validate = radeon_r300_validate; winsys->check_cs = radeon_r300_check_cs; winsys->begin_cs = radeon_r300_begin_cs; -- cgit v1.2.3 From 5b15cc312f16c6147e1f8f3d25c6ed34076aa3a1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 06:01:52 -0700 Subject: r300-gallium, radeon-winsys: Hide radeon_cs from r300 pipe. --- src/gallium/drivers/r300/r300_winsys.h | 5 --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 3 +- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 6 ++++ src/gallium/winsys/drm/radeon/core/radeon_r300.c | 42 +++++++++++++++------- 4 files changed, 36 insertions(+), 20 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 761aedebfc..a833bb0399 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -42,11 +42,6 @@ struct r300_winsys { /* Opaque Radeon-specific winsys object. */ void* radeon_winsys; - /* CS object. This is very much like Intel's batchbuffer. - * Fill it full of dwords and relocs and then submit. - * Repeat as needed. */ - struct radeon_cs* cs; - /* PCI ID */ uint32_t pci_id; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 6313eb219e..a15487352b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -175,8 +175,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) return NULL; } - bom = radeon_bo_manager_gem_ctor(fd); - radeon_ws->priv->bom = bom; + radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd); radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index 73fa362aca..ca8bbb3c11 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -60,6 +60,12 @@ struct radeon_winsys_priv { struct radeon_cs_space_check sc[RADEON_MAX_BOS]; /* Current BO count. */ unsigned bo_count; + + /* Radeon CS manager. */ + struct radeon_cs_manager* csm; + + /* Current CS. */ + struct radeon_cs* cs; }; struct radeon_winsys { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index b172107432..ac6cca36bf 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -57,7 +57,7 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) (struct radeon_winsys_priv*)winsys->radeon_winsys; struct radeon_cs_space_check* sc = priv->sc; - retval = radeon_cs_space_check(winsys->cs, sc, priv->bo_count); + retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { /* XXX we need to failover here */ @@ -83,13 +83,19 @@ static void radeon_r300_begin_cs(struct r300_winsys* winsys, const char* function, int line) { - radeon_cs_begin(winsys->cs, size, file, function, line); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_begin(priv->cs, size, file, function, line); } static void radeon_r300_write_cs_dword(struct r300_winsys* winsys, uint32_t dword) { - radeon_cs_write_dword(winsys->cs, dword); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_write_dword(priv->cs, dword); } static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, @@ -98,7 +104,10 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, uint32_t wd, uint32_t flags) { - radeon_cs_write_reloc(winsys->cs, + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_write_reloc(priv->cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); } @@ -107,19 +116,24 @@ static void radeon_r300_end_cs(struct r300_winsys* winsys, const char* function, int line) { - radeon_cs_end(winsys->cs, file, function, line); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_end(priv->cs, file, function, line); } static void radeon_r300_flush_cs(struct r300_winsys* winsys) { + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; int retval = 0; - retval = radeon_cs_emit(winsys->cs); + retval = radeon_cs_emit(priv->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); - radeon_cs_print(winsys->cs, stderr); + radeon_cs_print(priv->cs, stderr); } - radeon_cs_erase(winsys->cs); + radeon_cs_erase(priv->cs); } /* Helper function to do the ioctls needed for setup and init. */ @@ -169,20 +183,22 @@ struct r300_winsys* radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) { struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys); - struct radeon_cs_manager* csm; + struct radeon_winsys_priv* priv; if (winsys == NULL) { return NULL; } + priv = old_winsys->priv; + do_ioctls(winsys, fd); - csm = radeon_cs_manager_gem_ctor(fd); + priv->csm = radeon_cs_manager_gem_ctor(fd); - winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); - radeon_cs_set_limit(winsys->cs, + priv->cs = radeon_cs_create(priv->csm, 1024 * 64 / 4); + radeon_cs_set_limit(priv->cs, RADEON_GEM_DOMAIN_GTT, winsys->gart_size); - radeon_cs_set_limit(winsys->cs, + radeon_cs_set_limit(priv->cs, RADEON_GEM_DOMAIN_VRAM, winsys->vram_size); winsys->add_buffer = radeon_r300_add_buffer; -- cgit v1.2.3 From 2953b180044df602fbbf5882715774a779ff2123 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 07:29:14 -0700 Subject: radeon: Don't even bother with things too big to fit into our card. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index ac6cca36bf..da233203d7 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -60,7 +60,9 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { - /* XXX we need to failover here */ + /* We might as well HCF, since this is not going to fit in the card, + * period. */ + exit(1); } else if (retval == RADEON_CS_SPACE_FLUSH) { /* We must flush before more rendering can commence. */ return TRUE; -- cgit v1.2.3 From 293f576db7cf3f411c2eeb0a72232d25b631dcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 24 Mar 2009 19:18:06 +0000 Subject: egl_xlib: Pass RTLD_LAZY to dlopen. dlopen manpage mandates that either RTLD_LAZY or RTLD_NOW flags must be passed. Not doing so was causing a NULL return on debian unstable x86-64. --- src/gallium/winsys/egl_xlib/egl_xlib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index b52f427e4a..c10e3c00ff 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -588,7 +588,9 @@ find_supported_apis(void) EGLint mask = 0; void *handle; - handle = dlopen(NULL, 0); + handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + if(!handle) + return mask; if (dlsym(handle, "st_api_OpenGL_ES1")) mask |= EGL_OPENGL_ES_BIT; -- cgit v1.2.3 From b57b6c2d2c83aee96f945ce3385a1ab8337335cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 12:28:57 -0600 Subject: xlib winsys: use new st_swapbuffers() function The front/back buffer pointers are truly swapped (when there is an actual front buffer). This fixes some issues seen with apps/tests that draw to both the front and back color buffers. The true swap allows us to avoid the (potentially) slow surface_copy() call in update_framebuffer_state() and is cleaner overall. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index a3d1651653..79c2230588 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1100,26 +1100,19 @@ XMesaContext XMesaGetCurrentContext( void ) - - - -/* - * Copy the back buffer to the front buffer. If there's no back buffer - * this is a no-op. +/** + * Swap front and back color buffers and have winsys display front buffer. + * If there's no front color buffer no swap actually occurs. */ PUBLIC void XMesaSwapBuffers( XMesaBuffer b ) { - struct pipe_surface *surf; + struct pipe_surface *frontLeftSurf; - /* If we're swapping the buffer associated with the current context - * we have to flush any pending rendering commands first. - */ - st_notify_swapbuffers(b->stfb); + st_swapbuffers(b->stfb, &frontLeftSurf, NULL); - st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf); - if (surf) { - driver.display_surface(b, surf); + if (frontLeftSurf) { + driver.display_surface(b, frontLeftSurf); } xmesa_check_and_update_buffer_size(NULL, b); -- cgit v1.2.3 From 08bc3d175069988dd41433fdb7362863bcf67573 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 23 Apr 2009 10:24:19 -0600 Subject: gallium/glx: say we're direct rendering --- src/gallium/state_trackers/glx/xlib/fakeglx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c index 65e7048188..85e7ecfb9e 100644 --- a/src/gallium/state_trackers/glx/xlib/fakeglx.c +++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c @@ -97,6 +97,9 @@ struct fake_glx_context { +#define DEFAULT_DIRECT GL_TRUE + + /**********************************************************************/ /*** GLX Visual Code ***/ /**********************************************************************/ @@ -1059,7 +1062,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ @@ -1296,9 +1299,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) static Bool Fake_glXIsDirect( Display *dpy, GLXContext ctx ) { - (void) dpy; + struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; (void) ctx; - return False; + return glxCtx->glxContext.isDirect; } @@ -2055,7 +2058,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config, return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ @@ -2277,7 +2280,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ -- cgit v1.2.3 From 986d4a9ec60ee52067b2d6f81c05f8ec3b8dc8b1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 17:52:23 -0600 Subject: draw: added some inf/nan debug code (disabled) --- src/gallium/auxiliary/draw/draw_vs_exec.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index dbbc33fffa..f2368dde5c 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -114,6 +114,12 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, #endif for (slot = 0; slot < shader->info.num_inputs; slot++) { +#if 0 + assert(!util_is_inf_or_nan(input[slot][0])); + assert(!util_is_inf_or_nan(input[slot][1])); + assert(!util_is_inf_or_nan(input[slot][2])); + assert(!util_is_inf_or_nan(input[slot][3])); +#endif machine->Inputs[slot].xyzw[0].f[j] = input[slot][0]; machine->Inputs[slot].xyzw[1].f[j] = input[slot][1]; machine->Inputs[slot].xyzw[2].f[j] = input[slot][2]; -- cgit v1.2.3 From 39ebeead56bddfd339b6b6b31dd1b52d96859d65 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 5 May 2009 11:29:58 +0200 Subject: Fix an nv04 bug (thanks Mhopf). --- src/gallium/drivers/nv04/nv04_state.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_state.h b/src/gallium/drivers/nv04/nv04_state.h index 0d51439e3f..399f750dbe 100644 --- a/src/gallium/drivers/nv04/nv04_state.h +++ b/src/gallium/drivers/nv04/nv04_state.h @@ -37,7 +37,7 @@ struct nv04_miptree { struct { uint pitch; - uint image_offset; + uint *image_offset; } level[PIPE_MAX_TEXTURE_LEVELS]; }; -- cgit v1.2.3 From 8edb50ff1e87f9bb00ceeaa2fe13df212a91eb11 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 5 May 2009 12:03:38 +0200 Subject: nv04: small fix again --- src/gallium/drivers/nv04/nv04_miptree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c index 4da833c25e..93f752faec 100644 --- a/src/gallium/drivers/nv04/nv04_miptree.c +++ b/src/gallium/drivers/nv04/nv04_miptree.c @@ -31,7 +31,8 @@ nv04_miptree_layout(struct nv04_miptree *nv04mt) for (l = 0; l <= pt->last_level; l++) { - nv04mt->level[l].image_offset = offset; + nv04mt->level[l].image_offset = + CALLOC(nr_faces, sizeof(unsigned)); offset += nv04mt->level[l].pitch * pt->height[l]; } -- cgit v1.2.3 From 4fd6f296f8d3416472ec83374d459ecb12db60f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 28 Apr 2009 17:07:01 +0100 Subject: pb: Dump the fenced buffer sizes. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 044e8e1dd3..4698efa69c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -531,16 +531,17 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) pipe_mutex_lock(fenced_list->mutex); - debug_printf("%10s %7s %10s %s\n", - "buffer", "reference.count", "fence", "signalled"); + debug_printf("%10s %7s %7s %10s %s\n", + "buffer", "size", "refcount", "fence", "signalled"); curr = fenced_list->unfenced.next; next = curr->next; while(curr != &fenced_list->unfenced) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); assert(!fenced_buf->fence); - debug_printf("%10p %7u\n", + debug_printf("%10p %7u %7u\n", fenced_buf, + fenced_buf->base.base.size, fenced_buf->base.base.reference.count); curr = next; next = curr->next; @@ -552,8 +553,9 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) int signaled; fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %10p %s\n", + debug_printf("%10p %7u %7u %10p %s\n", fenced_buf, + fenced_buf->base.base.size, fenced_buf->base.base.reference.count, fenced_buf->fence, signaled == 0 ? "y" : "n"); -- cgit v1.2.3 From a47f15ba1da4c7f8649d7064dfc23cf571df705c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 28 Apr 2009 18:53:52 +0100 Subject: pb: Save the stack backtrace when creating/mapping a debug buffer. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 102 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index f1a05be46e..cedf745bda 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -40,6 +40,7 @@ #include "util/u_memory.h" #include "util/u_double_list.h" #include "util/u_time.h" +#include "util/u_debug_stack.h" #include "pb_buffer.h" #include "pb_bufmgr.h" @@ -48,6 +49,10 @@ #ifdef DEBUG +#define PB_DEBUG_CREATE_BACKTRACE 8 +#define PB_DEBUG_MAP_BACKTRACE 8 + + /** * Convenience macro (type safe). */ @@ -69,6 +74,14 @@ struct pb_debug_buffer size_t underflow_size; size_t overflow_size; + + struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE]; + + pipe_mutex mutex; + unsigned map_count; + struct debug_stack_frame map_backtrace[PB_DEBUG_MAP_BACKTRACE]; + + struct list_head head; }; @@ -80,6 +93,9 @@ struct pb_debug_manager size_t underflow_size; size_t overflow_size; + + pipe_mutex mutex; + struct list_head list; }; @@ -189,6 +205,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) max_ofs == buf->overflow_size - 1 ? "+" : ""); } + if(underflow || overflow) + debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE); + debug_assert(!underflow && !overflow); /* re-fill if not aborted */ @@ -207,11 +226,18 @@ static void pb_debug_buffer_destroy(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + struct pb_debug_manager *mgr = buf->mgr; assert(!pipe_is_referenced(&buf->base.base.reference)); pb_debug_buffer_check(buf); + pipe_mutex_lock(mgr->mutex); + LIST_DEL(&buf->head); + pipe_mutex_unlock(mgr->mutex); + + pipe_mutex_destroy(buf->mutex); + pb_reference(&buf->buffer, NULL); FREE(buf); } @@ -230,6 +256,13 @@ pb_debug_buffer_map(struct pb_buffer *_buf, if(!map) return NULL; + if(map) { + pipe_mutex_lock(buf->mutex); + ++buf->map_count; + debug_backtrace_capture(buf->map_backtrace, 1, PB_DEBUG_MAP_BACKTRACE); + pipe_mutex_unlock(buf->mutex); + } + return (uint8_t *)map + buf->underflow_size; } @@ -238,6 +271,13 @@ static void pb_debug_buffer_unmap(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + + pipe_mutex_lock(buf->mutex); + assert(buf->map_count); + if(buf->map_count) + --buf->map_count; + pipe_mutex_unlock(buf->mutex); + pb_unmap(buf->buffer); pb_debug_buffer_check(buf); @@ -262,6 +302,14 @@ pb_debug_buffer_validate(struct pb_buffer *_buf, { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + pipe_mutex_lock(buf->mutex); + if(buf->map_count) { + debug_printf("%s: attempting to validate a mapped buffer\n", __FUNCTION__); + debug_printf("last map backtrace is\n"); + debug_backtrace_dump(buf->map_backtrace, PB_DEBUG_MAP_BACKTRACE); + } + pipe_mutex_unlock(buf->mutex); + pb_debug_buffer_check(buf); return pb_validate(buf->buffer, vl, flags); @@ -288,6 +336,31 @@ pb_debug_buffer_vtbl = { }; +static void +pb_debug_manager_dump(struct pb_debug_manager *mgr) +{ + struct list_head *curr, *next; + struct pb_debug_buffer *buf; + + pipe_mutex_lock(mgr->mutex); + + curr = mgr->list.next; + next = curr->next; + while(curr != &mgr->list) { + buf = LIST_ENTRY(struct pb_debug_buffer, curr, head); + + debug_printf("buffer = %p\n", buf); + debug_printf(" .size = %p\n", buf->base.base.size); + debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE); + + curr = next; + next = curr->next; + } + + pipe_mutex_unlock(mgr->mutex); +} + + static struct pb_buffer * pb_debug_manager_create_buffer(struct pb_manager *_mgr, size_t size, @@ -312,6 +385,13 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, &real_desc); if(!buf->buffer) { FREE(buf); +#if 0 + pipe_mutex_lock(mgr->mutex); + debug_printf("%s: failed to create buffer\n", __FUNCTION__); + if(!LIST_IS_EMPTY(&mgr->list)) + pb_debug_manager_dump(mgr); + pipe_mutex_unlock(mgr->mutex); +#endif return NULL; } @@ -331,8 +411,16 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, buf->underflow_size = mgr->underflow_size; buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size; + debug_backtrace_capture(buf->create_backtrace, 1, PB_DEBUG_CREATE_BACKTRACE); + pb_debug_buffer_fill(buf); + pipe_mutex_init(buf->mutex); + + pipe_mutex_lock(mgr->mutex); + LIST_ADDTAIL(&buf->head, &mgr->list); + pipe_mutex_unlock(mgr->mutex); + return &buf->base; } @@ -351,6 +439,15 @@ static void pb_debug_manager_destroy(struct pb_manager *_mgr) { struct pb_debug_manager *mgr = pb_debug_manager(_mgr); + + pipe_mutex_lock(mgr->mutex); + if(!LIST_IS_EMPTY(&mgr->list)) { + debug_printf("%s: unfreed buffers\n", __FUNCTION__); + pb_debug_manager_dump(mgr); + } + pipe_mutex_unlock(mgr->mutex); + + pipe_mutex_destroy(mgr->mutex); mgr->provider->destroy(mgr->provider); FREE(mgr); } @@ -375,7 +472,10 @@ pb_debug_manager_create(struct pb_manager *provider, mgr->provider = provider; mgr->underflow_size = underflow_size; mgr->overflow_size = overflow_size; - + + pipe_mutex_init(mgr->mutex); + LIST_INITHEAD(&mgr->list); + return &mgr->base; } -- cgit v1.2.3 From ccec9f76d5ed032b627f5893f733ea0576311d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 28 Apr 2009 19:46:56 +0100 Subject: wgl: UINT_PTR null value is an integral type, so return 0 instead of NULL. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 0b5dd78ec6..473e3308c6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -276,12 +276,12 @@ stw_get_current_context( void ) struct stw_context *ctx; if(!glcurctx) - return NULL; + return 0; ctx = (struct stw_context *)glcurctx->DriverCtx; assert(ctx); if(!ctx) - return NULL; + return 0; return ctx->hglrc; } -- cgit v1.2.3 From c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 10:59:19 +0100 Subject: gallium/draw: cope with unused vertex_elements --- src/gallium/auxiliary/draw/draw_pt.h | 1 + src/gallium/auxiliary/draw/draw_pt_fetch.c | 8 +++++++- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index 6f3e1e0289..8ef0ea8011 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -187,6 +187,7 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw ); struct pt_fetch; void draw_pt_fetch_prepare( struct pt_fetch *fetch, + unsigned vertex_input_count, unsigned vertex_size ); void draw_pt_fetch_run( struct pt_fetch *fetch, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 505d32f2c3..65c3a34c34 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "util/u_memory.h" +#include "util/u_math.h" #include "draw/draw_context.h" #include "draw/draw_private.h" #include "draw/draw_vbuf.h" @@ -56,9 +57,11 @@ struct pt_fetch { * */ void draw_pt_fetch_prepare( struct pt_fetch *fetch, + unsigned vs_input_count, unsigned vertex_size ) { struct draw_context *draw = fetch->draw; + unsigned nr_inputs; unsigned i, nr = 0; unsigned dst_offset = 0; struct translate_key key; @@ -89,8 +92,11 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, dst_offset += 4 * sizeof(float); } + assert( draw->pt.nr_vertex_elements >= vs_input_count ); - for (i = 0; i < draw->pt.nr_vertex_elements; i++) { + nr_inputs = MIN2( vs_input_count, draw->pt.nr_vertex_elements ); + + for (i = 0; i < nr_inputs; i++) { key.element[nr].input_format = draw->pt.vertex_element[i].src_format; key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index; key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 11ac90fc56..df6c265b7e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -77,8 +77,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, draw_pt_fetch_prepare( fpme->fetch, + vs->info.num_inputs, fpme->vertex_size ); - /* XXX: it's not really gl rasterization rules we care about here, * but gl vs dx9 clip spaces. */ -- cgit v1.2.3 From 6b89c35c9f6557a160c8fc0c97a110d3afe4c82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 30 Apr 2009 12:24:08 +0100 Subject: wgl: Include alpha bits in pixel format's cColorBits field. --- src/gallium/state_trackers/wgl/shared/stw_pixelformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 9e642cbdd4..8d6955f390 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -158,7 +158,7 @@ stw_pixelformat_add( pfi->pfd.iPixelType = PFD_TYPE_RGBA; - pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue; + pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha; pfi->pfd.cRedBits = color->bits.red; pfi->pfd.cRedShift = color->shift.red; pfi->pfd.cGreenBits = color->bits.green; -- cgit v1.2.3 From b865501bda8f2f99bfa8ee365aa4a3da64291e6e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 13:09:34 +0100 Subject: gallium/tgsi: hack around linker/archiver breakage Add a dummy function which exists only so that tgsi_text_translate() doesn't get magic-ed out of the libtgsi.a archive by the build system. Don't remove unless you know this has been fixed - check on mingw/scons builds as well. --- src/gallium/auxiliary/tgsi/tgsi_transform.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c index 062c1be938..bc9c18fd4a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.c +++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c @@ -198,3 +198,30 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in, return ctx->ti; } + + +#include "tgsi_text.h" + +extern int tgsi_transform_foo( struct tgsi_token *tokens_out, + uint max_tokens_out ); + +/* This function exists only so that tgsi_text_translate() doesn't get + * magic-ed out of the libtgsi.a archive by the build system. Don't + * remove unless you know this has been fixed - check on mingw/scons + * builds as well. + */ +int +tgsi_transform_foo( struct tgsi_token *tokens_out, + uint max_tokens_out ) +{ + const char *text = + "FRAG1.1\n" + "DCL IN[0], COLOR, CONSTANT\n" + "DCL OUT[0], COLOR\n" + " 0: MOV OUT[0], IN[0]\n" + " 1: END"; + + return tgsi_text_translate( text, + tokens_out, + max_tokens_out ); +} -- cgit v1.2.3 From 3537c3420d0887ed22565b9e4469952b99f1b76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 30 Apr 2009 13:10:58 +0100 Subject: util: Limit the stack walk to avoid referencing undefined memory. --- src/gallium/auxiliary/util/u_debug_stack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index e9891fde8a..528a1c394b 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -62,6 +62,8 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace, #ifdef PIPE_ARCH_X86 while(nr_frames) { + const void **next_frame_pointer; + if(!frame_pointer) break; @@ -72,7 +74,14 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace, --nr_frames; } - frame_pointer = (const void **)frame_pointer[0]; + next_frame_pointer = (const void **)frame_pointer[0]; + + /* Limit the stack walk to avoid referencing undefined memory */ + if((uintptr_t)next_frame_pointer <= (uintptr_t)frame_pointer || + (uintptr_t)next_frame_pointer > (uintptr_t)frame_pointer + 64*1024) + break; + + frame_pointer = next_frame_pointer; } #endif -- cgit v1.2.3 From c6bfb4c55963937f715a5e6a806be23e940b30d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 1 May 2009 16:30:08 +0100 Subject: wgl: Implemente SwapLayerBuffers. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 2 +- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 12 ++++++++++++ src/gallium/state_trackers/wgl/shared/stw_public.h | 3 +++ src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 5 +---- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 3711982fd2..b259ea91f5 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -583,7 +583,7 @@ DrvSwapLayerBuffers( if (DBG) debug_printf( "%s\n", __FUNCTION__ ); - return FALSE; + return stw_swap_layer_buffers( hdc, fuPlanes ); } BOOL APIENTRY diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 4348b8f326..f66f429542 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -237,6 +237,18 @@ stw_swap_buffers( } +BOOL +stw_swap_layer_buffers( + HDC hdc, + UINT fuPlanes ) +{ + if(fuPlanes & WGL_SWAP_MAIN_PLANE) + return stw_swap_buffers(hdc); + + return FALSE; +} + + boolean stw_framebuffer_init_thread(void) { diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h index 39d377c16b..59d709a6d4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_public.h +++ b/src/gallium/state_trackers/wgl/shared/stw_public.h @@ -50,6 +50,9 @@ BOOL stw_make_current( HDC hdc, UINT_PTR hglrc ); BOOL stw_swap_buffers( HDC hdc ); +BOOL +stw_swap_layer_buffers( HDC hdc, UINT fuPlanes ); + PROC stw_get_proc_address( LPCSTR lpszProc ); int stw_pixelformat_describe( HDC hdc, diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index e06d2640b4..30e42e0ec5 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -100,10 +100,7 @@ wglSwapLayerBuffers( HDC hdc, UINT fuPlanes ) { - (void) hdc; - (void) fuPlanes; - - return FALSE; + return stw_swap_layer_buffers( hdc, fuPlanes ); } WINGDIAPI PROC APIENTRY -- cgit v1.2.3 From 79ada8c6331a801a0475f38a540670b14e168f19 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 May 2009 10:11:51 -0600 Subject: gallium: fix texcoords for cubemap mipmap generation We need to use (s,t,r) cubemap coords when sampling from the cubemap texture so the rendered quad gets texture samples from the correct cube face. --- src/gallium/auxiliary/util/u_gen_mipmap.c | 96 +++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 690412ae7d..6fa13a8ce1 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1316,7 +1316,6 @@ util_create_gen_mipmap(struct pipe_context *pipe, for (i = 0; i < 4; i++) { ctx->vertices[i][0][2] = 0.0f; /* z */ ctx->vertices[i][0][3] = 1.0f; /* w */ - ctx->vertices[i][1][2] = 0.0f; /* r */ ctx->vertices[i][1][3] = 1.0f; /* q */ } @@ -1350,29 +1349,104 @@ get_next_slot(struct gen_mipmap_state *ctx) static unsigned -set_vertex_data(struct gen_mipmap_state *ctx, float width, float height) +set_vertex_data(struct gen_mipmap_state *ctx, + enum pipe_texture_target tex_target, + uint face, float width, float height) { unsigned offset; + /* vert[0].position */ ctx->vertices[0][0][0] = 0.0f; /*x*/ ctx->vertices[0][0][1] = 0.0f; /*y*/ - ctx->vertices[0][1][0] = 0.0f; /*s*/ - ctx->vertices[0][1][1] = 0.0f; /*t*/ + /* vert[1].position */ ctx->vertices[1][0][0] = width; ctx->vertices[1][0][1] = 0.0f; - ctx->vertices[1][1][0] = 1.0f; - ctx->vertices[1][1][1] = 0.0f; + /* vert[2].position */ ctx->vertices[2][0][0] = width; ctx->vertices[2][0][1] = height; - ctx->vertices[2][1][0] = 1.0f; - ctx->vertices[2][1][1] = 1.0f; + /* vert[3].position */ ctx->vertices[3][0][0] = 0.0f; ctx->vertices[3][0][1] = height; - ctx->vertices[3][1][0] = 0.0f; - ctx->vertices[3][1][1] = 1.0f; + + /* Setup vertex texcoords. This is a little tricky for cube maps. */ + if (tex_target == PIPE_TEXTURE_CUBE) { + static const float st[4][2] = { + {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f} + }; + float rx, ry, rz; + uint i; + + /* loop over quad verts */ + for (i = 0; i < 4; i++) { + /* Compute sc = +/-scale and tc = +/-scale. + * Not +/-1 to avoid cube face selection ambiguity near the edges, + * though that can still sometimes happen with this scale factor... + */ + const float scale = 0.9999; + const float sc = (2.0f * st[i][0] - 1.0f) * scale; + const float tc = (2.0f * st[i][1] - 1.0f) * scale; + + switch (face) { + case PIPE_TEX_FACE_POS_X: + rx = 1.0f; + ry = -tc; + rz = -sc; + break; + case PIPE_TEX_FACE_NEG_X: + rx = -1.0f; + ry = -tc; + rz = sc; + break; + case PIPE_TEX_FACE_POS_Y: + rx = sc; + ry = 1.0f; + rz = tc; + break; + case PIPE_TEX_FACE_NEG_Y: + rx = sc; + ry = -1.0f; + rz = -tc; + break; + case PIPE_TEX_FACE_POS_Z: + rx = sc; + ry = -tc; + rz = 1.0f; + break; + case PIPE_TEX_FACE_NEG_Z: + rx = -sc; + ry = -tc; + rz = -1.0f; + break; + default: + assert(0); + } + + ctx->vertices[i][1][0] = rx; /*s*/ + ctx->vertices[i][1][1] = ry; /*t*/ + ctx->vertices[i][1][2] = rz; /*r*/ + } + } + else { + /* 1D/2D */ + ctx->vertices[0][1][0] = 0.0f; /*s*/ + ctx->vertices[0][1][1] = 0.0f; /*t*/ + ctx->vertices[0][1][2] = 0.0f; /*r*/ + + ctx->vertices[1][1][0] = 1.0f; + ctx->vertices[1][1][1] = 0.0f; + ctx->vertices[1][1][2] = 0.0f; + + ctx->vertices[2][1][0] = 1.0f; + ctx->vertices[2][1][1] = 1.0f; + ctx->vertices[2][1][2] = 0.0f; + + ctx->vertices[3][1][0] = 0.0f; + ctx->vertices[3][1][1] = 1.0f; + ctx->vertices[3][1][2] = 0.0f; + } offset = get_next_slot( ctx ); @@ -1503,6 +1577,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, /* quad coords in window coords (bypassing vs, clip and viewport) */ offset = set_vertex_data(ctx, + pt->target, + face, (float) pt->width[dstLevel], (float) pt->height[dstLevel]); -- cgit v1.2.3 From 95b7771ea705b71bbd8185cd8e39b546e18e09a9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 May 2009 09:39:39 -0600 Subject: gallium: remove redundant cube face #defines --- src/gallium/include/pipe/p_defines.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 82e23c413c..47c24f3086 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -132,6 +132,7 @@ enum pipe_texture_target { #define PIPE_TEX_FACE_NEG_Y 3 #define PIPE_TEX_FACE_POS_Z 4 #define PIPE_TEX_FACE_NEG_Z 5 +#define PIPE_TEX_FACE_MAX 6 #define PIPE_TEX_WRAP_REPEAT 0 #define PIPE_TEX_WRAP_CLAMP 1 @@ -158,14 +159,6 @@ enum pipe_texture_target { #define PIPE_TEX_COMPARE_NONE 0 #define PIPE_TEX_COMPARE_R_TO_TEXTURE 1 -#define PIPE_TEX_FACE_POS_X 0 -#define PIPE_TEX_FACE_NEG_X 1 -#define PIPE_TEX_FACE_POS_Y 2 -#define PIPE_TEX_FACE_NEG_Y 3 -#define PIPE_TEX_FACE_POS_Z 4 -#define PIPE_TEX_FACE_NEG_Z 5 -#define PIPE_TEX_FACE_MAX 6 - #define PIPE_TEXTURE_USAGE_RENDER_TARGET 0x1 #define PIPE_TEXTURE_USAGE_DISPLAY_TARGET 0x2 /* ie a backbuffer */ #define PIPE_TEXTURE_USAGE_PRIMARY 0x4 /* ie a frontbuffer */ -- cgit v1.2.3 From b7f2b7e93609836260ca7eef635776073b8f7069 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 8 May 2009 09:04:10 +1000 Subject: nouveau: use dri state tracker for dri1 --- src/gallium/winsys/drm/nouveau/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h | 28 ------- src/gallium/winsys/drm/nouveau/dri2/Makefile | 2 +- src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h | 28 +++++++ .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 86 ++++++++++++++++++++++ .../winsys/drm/nouveau/drm/nouveau_drm_api.h | 2 + .../winsys/drm/nouveau/drm/nouveau_winsys_pipe.h | 2 + 7 files changed, 120 insertions(+), 30 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h create mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile index f8c8135854..be4cad6f9e 100644 --- a/src/gallium/winsys/drm/nouveau/Makefile +++ b/src/gallium/winsys/drm/nouveau/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../.. include $(TOP)/configs/current -SUBDIRS = drm dri dri2 +SUBDIRS = drm dri2 default install clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h deleted file mode 100644 index 1207c2d609..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _NOUVEAU_DRI_ -#define _NOUVEAU_DRI_ - -#include "xf86drm.h" -#include "drm.h" -#include "nouveau_drm.h" - -struct nouveau_dri { - uint32_t device_id; /**< \brief PCI device ID */ - uint32_t width; /**< \brief width in pixels of display */ - uint32_t height; /**< \brief height in scanlines of display */ - uint32_t depth; /**< \brief depth of display (8, 15, 16, 24) */ - uint32_t bpp; /**< \brief bit depth of display (8, 16, 24, 32) */ - - uint32_t bus_type; /**< \brief ths bus type */ - uint32_t bus_mode; /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */ - - uint32_t front_offset; /**< \brief front buffer offset */ - uint32_t front_pitch; /**< \brief front buffer pitch */ - uint32_t back_offset; /**< \brief private back buffer offset */ - uint32_t back_pitch; /**< \brief private back buffer pitch */ - uint32_t depth_offset; /**< \brief private depth buffer offset */ - uint32_t depth_pitch; /**< \brief private depth buffer pitch */ - -}; - -#endif - diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile index 377a80d518..024ab150cb 100644 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile @@ -1,7 +1,7 @@ TOP = ../../../../../.. include $(TOP)/configs/current -LIBNAME = nouveau_dri2.so +LIBNAME = nouveau_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h new file mode 100644 index 0000000000..1207c2d609 --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h @@ -0,0 +1,28 @@ +#ifndef _NOUVEAU_DRI_ +#define _NOUVEAU_DRI_ + +#include "xf86drm.h" +#include "drm.h" +#include "nouveau_drm.h" + +struct nouveau_dri { + uint32_t device_id; /**< \brief PCI device ID */ + uint32_t width; /**< \brief width in pixels of display */ + uint32_t height; /**< \brief height in scanlines of display */ + uint32_t depth; /**< \brief depth of display (8, 15, 16, 24) */ + uint32_t bpp; /**< \brief bit depth of display (8, 16, 24, 32) */ + + uint32_t bus_type; /**< \brief ths bus type */ + uint32_t bus_mode; /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */ + + uint32_t front_offset; /**< \brief front buffer offset */ + uint32_t front_pitch; /**< \brief front buffer pitch */ + uint32_t back_offset; /**< \brief private back buffer offset */ + uint32_t back_pitch; /**< \brief private back buffer pitch */ + uint32_t depth_offset; /**< \brief private depth buffer offset */ + uint32_t depth_pitch; /**< \brief private depth buffer pitch */ + +}; + +#endif + diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index a558fda140..b355a1391d 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -7,9 +7,68 @@ #include "nouveau_channel.h" #include "nouveau_bo.h" +static struct pipe_surface * +dri_surface_from_handle(struct pipe_screen *screen, + unsigned handle, + enum pipe_format format, + unsigned width, + unsigned height, + unsigned pitch) +{ + struct pipe_surface *surface = NULL; + struct pipe_texture *texture = NULL; + struct pipe_texture templat; + struct pipe_buffer *buf = NULL; + + buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle); + if (!buf) + return NULL; + + memset(&templat, 0, sizeof(templat)); + templat.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY | + NOUVEAU_TEXTURE_USAGE_LINEAR; + templat.target = PIPE_TEXTURE_2D; + templat.last_level = 0; + templat.depth[0] = 1; + templat.format = format; + templat.width[0] = width; + templat.height[0] = height; + pf_get_block(templat.format, &templat.block); + + texture = screen->texture_blanket(screen, + &templat, + &pitch, + buf); + + /* we don't need the buffer from this point on */ + pipe_buffer_reference(&buf, NULL); + + if (!texture) + return NULL; + + surface = screen->get_tex_surface(screen, texture, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + /* we don't need the texture from this point on */ + pipe_texture_reference(&texture, NULL); + return surface; +} + +static struct pipe_surface * +nouveau_dri1_front_surface(struct pipe_context *pipe) +{ + return nouveau_screen(pipe->screen)->front; +} + +static struct dri1_api nouveau_dri1_api = { + nouveau_dri1_front_surface, +}; + static struct pipe_screen * nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { + struct dri1_create_screen_arg *dri1 = (void *)arg; struct pipe_winsys *ws; struct nouveau_winsys *nvws; struct nouveau_device *dev = NULL; @@ -67,6 +126,33 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) return NULL; } + if (arg->mode == DRM_CREATE_DRI1) { + struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); + struct nouveau_dri *nvdri = dri1->ddx_info; + enum pipe_format format; + + if (nvdri->bpp == 16) + format = PIPE_FORMAT_R5G6B5_UNORM; + else + format = PIPE_FORMAT_A8R8G8B8_UNORM; + + nvpws->front = dri_surface_from_handle(nvpws->pscreen, + nvdri->front_offset, + format, + nvdri->width, + nvdri->height, + nvdri->front_pitch * + (nvdri->bpp / 8)); + if (!nvpws->front) { + debug_printf("%s: error referencing front buffer\n", + __func__); + ws->destroy(ws); + return NULL; + } + + dri1->api = &nouveau_dri1_api; + } + return nouveau_pipe_winsys(ws)->pscreen; } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h index 2782c83c0e..cc237bfc13 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h @@ -1,5 +1,7 @@ #ifndef __NOUVEAU_DRM_API_H__ #define __NOUVEAU_DRM_API_H__ #include "state_tracker/drm_api.h" +#include "state_tracker/dri1_api.h" +#include "nouveau_dri.h" #endif diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h index 10e1e269e8..ec10f1e00c 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h @@ -29,6 +29,8 @@ struct nouveau_pipe_winsys { unsigned nr_pctx; struct pipe_context **pctx; + + struct pipe_surface *front; }; static INLINE struct nouveau_pipe_winsys * -- cgit v1.2.3 From 9e02fa45320c724c69839dae5aaa47034eae5125 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 8 May 2009 09:11:17 +1000 Subject: nouveau: remove dri1 code now we're using the dri state tracker --- src/gallium/winsys/drm/nouveau/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri/Makefile | 16 +- .../winsys/drm/nouveau/dri/nouveau_context.c | 118 -------- .../winsys/drm/nouveau/dri/nouveau_context.h | 53 ---- src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c | 73 ----- .../winsys/drm/nouveau/dri/nouveau_screen.c | 330 --------------------- .../winsys/drm/nouveau/dri/nouveau_screen.h | 16 - .../winsys/drm/nouveau/dri/nouveau_swapbuffers.c | 115 ------- .../winsys/drm/nouveau/dri/nouveau_swapbuffers.h | 11 - src/gallium/winsys/drm/nouveau/dri2/Makefile | 26 -- 10 files changed, 5 insertions(+), 755 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_context.c delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_context.h delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c delete mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h delete mode 100644 src/gallium/winsys/drm/nouveau/dri2/Makefile (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile index be4cad6f9e..e275b2d9e7 100644 --- a/src/gallium/winsys/drm/nouveau/Makefile +++ b/src/gallium/winsys/drm/nouveau/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../.. include $(TOP)/configs/current -SUBDIRS = drm dri2 +SUBDIRS = drm dri default install clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile index f7db6201fe..024ab150cb 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile @@ -3,9 +3,8 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri.so -MINIGLX_SOURCES = - PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nv04/libnv04.a \ $(TOP)/src/gallium/drivers/nv10/libnv10.a \ @@ -13,22 +12,15 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a - -DRIVER_SOURCES = \ - nouveau_context.c \ - nouveau_screen.c \ - nouveau_swapbuffers.c \ - nouveau_lock.c + +DRIVER_SOURCES = C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) \ $(DRIVER_SOURCES) -ASM_SOURCES = +include ../../Makefile.template -DRIVER_DEFINES = $(shell pkg-config libdrm_nouveau --cflags) DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs) -include ../../Makefile.template - symlinks: diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c deleted file mode 100644 index deb6ffcff1..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c +++ /dev/null @@ -1,118 +0,0 @@ -#include
-#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nouveau_context.h" -#include "nouveau_screen.h" - -#include "nouveau_drmif.h" - -GLboolean -nouveau_context_create(const __GLcontextModes *glVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) -{ - __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; - struct nouveau_screen *nv_screen = driScrnPriv->private; - struct nouveau_context *nv; - struct pipe_context *pipe; - struct st_context *st_share = NULL; - - if (sharedContextPrivate) - st_share = ((struct nouveau_context *)sharedContextPrivate)->st; - - nv = CALLOC_STRUCT(nouveau_context); - if (!nv) - return GL_FALSE; - - { - struct nouveau_device_priv *nvdev = - nouveau_device(nv_screen->device); - - nvdev->ctx = driContextPriv->hHWContext; - nvdev->lock = (drmLock *)&driScrnPriv->pSAREA->lock; - } - - pipe = drm_api_hooks.create_context(nv_screen->pscreen); - if (!pipe) { - FREE(nv); - return GL_FALSE; - } - pipe->priv = nv; - - driContextPriv->driverPrivate = nv; - nv->dri_screen = driScrnPriv; - - driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache, - nv->dri_screen->myNum, "nouveau"); - - nv->st = st_create_context(pipe, glVis, st_share); - return GL_TRUE; -} - -void -nouveau_context_destroy(__DRIcontextPrivate *driContextPriv) -{ - struct nouveau_context *nv = driContextPriv->driverPrivate; - - assert(nv); - - st_finish(nv->st); - st_destroy_context(nv->st); - - FREE(nv); -} - -GLboolean -nouveau_context_bind(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - struct nouveau_context *nv; - struct nouveau_framebuffer *draw, *read; - - if (!driContextPriv) { - st_make_current(NULL, NULL, NULL); - return GL_TRUE; - } - - nv = driContextPriv->driverPrivate; - draw = driDrawPriv->driverPrivate; - read = driReadPriv->driverPrivate; - - st_make_current(nv->st, draw->stfb, read->stfb); - - if ((nv->dri_drawable != driDrawPriv) || - (nv->last_stamp != driDrawPriv->lastStamp)) { - nv->dri_drawable = driDrawPriv; - st_resize_framebuffer(draw->stfb, driDrawPriv->w, - driDrawPriv->h); - nv->last_stamp = driDrawPriv->lastStamp; - } - - if (driDrawPriv != driReadPriv) { - st_resize_framebuffer(read->stfb, driReadPriv->w, - driReadPriv->h); - } - - return GL_TRUE; -} - -GLboolean -nouveau_context_unbind(__DRIcontextPrivate *driContextPriv) -{ - struct nouveau_context *nv = driContextPriv->driverPrivate; - (void)nv; - - st_flush(nv->st, 0, NULL); - return GL_TRUE; -} - diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h deleted file mode 100644 index 2779b092e6..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __NOUVEAU_CONTEXT_DRI_H__ -#define __NOUVEAU_CONTEXT_DRI_H__ - -#include -#include - -#include "nouveau/nouveau_winsys.h" - -#define NOUVEAU_ERR(fmt, args...) debug_printf("%s: "fmt, __func__, ##args) - -struct nouveau_framebuffer { - struct st_framebuffer *stfb; -}; - -struct nouveau_context { - struct st_context *st; - - /* DRI stuff */ - __DRIscreenPrivate *dri_screen; - __DRIdrawablePrivate *dri_drawable; - unsigned int last_stamp; - driOptionCache dri_option_cache; - drm_context_t drm_context; - drmLock drm_lock; - int locked; -}; - -extern GLboolean nouveau_context_create(const __GLcontextModes *, - __DRIcontextPrivate *, void *); -extern void nouveau_context_destroy(__DRIcontextPrivate *); -extern GLboolean nouveau_context_bind(__DRIcontextPrivate *, - __DRIdrawablePrivate *draw, - __DRIdrawablePrivate *read); -extern GLboolean nouveau_context_unbind(__DRIcontextPrivate *); - -extern void nouveau_contended_lock(struct nouveau_context *nv); -extern void LOCK_HARDWARE(struct nouveau_context *nv); -extern void UNLOCK_HARDWARE(struct nouveau_context *nv); - -#ifdef DEBUG -extern int __nouveau_debug; - -#define DEBUG_BO (1 << 0) - -#define DBG(flag, ...) do { \ - if (__nouveau_debug & (DEBUG_##flag)) \ - NOUVEAU_ERR(__VA_ARGS__); \ -} while(0) -#else -#define DBG(flag, ...) -#endif - -#endif diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c deleted file mode 100644 index 92f5bd09c9..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include -#include "nouveau_context.h" -#include "nouveau_screen.h" -#include "nouveau_drmif.h" - -pipe_static_mutex(lockMutex); - -/* Lock the hardware and validate our state. - */ -void -LOCK_HARDWARE(struct nouveau_context *nv) -{ - struct nouveau_screen *nv_screen = nv->dri_screen->private; - struct nouveau_device *dev = nv_screen->device; - struct nouveau_device_priv *nvdev = nouveau_device(dev); - char __ret=0; - - assert(!nv->locked); - pipe_mutex_lock(lockMutex); - - DRM_CAS(nvdev->lock, nvdev->ctx, - (DRM_LOCK_HELD | nvdev->ctx), __ret); - - if (__ret) { - drmGetLock(nvdev->fd, nvdev->ctx, 0); - nouveau_contended_lock(nv); - } - nv->locked = 1; -} - -/* Unlock the hardware using the global current context - */ -void -UNLOCK_HARDWARE(struct nouveau_context *nv) -{ - struct nouveau_screen *nv_screen = nv->dri_screen->private; - struct nouveau_device *dev = nv_screen->device; - struct nouveau_device_priv *nvdev = nouveau_device(dev); - - assert(nv->locked); - nv->locked = 0; - - DRM_UNLOCK(nvdev->fd, nvdev->lock, nvdev->ctx); - - pipe_mutex_unlock(lockMutex); -} diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c deleted file mode 100644 index 4e9b76a909..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c +++ /dev/null @@ -1,330 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -#include "nouveau_context.h" -#include "nouveau_screen.h" -#include "nouveau_swapbuffers.h" -#include "nouveau_dri.h" - -#include "nouveau_drm.h" -#include "nouveau_drmif.h" - -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12 -#error nouveau_drm.h version does not match expected version -#endif - -/* Extension stuff, enabling of extensions handled by Gallium's GL state - * tracker. But, we still need to define the entry points we want. - */ -#define need_GL_ARB_fragment_program -#define need_GL_ARB_multisample -#define need_GL_ARB_occlusion_query -#define need_GL_ARB_point_parameters -#define need_GL_ARB_shader_objects -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_program -#define need_GL_ARB_vertex_shader -#define need_GL_ARB_vertex_buffer_object -#define need_GL_EXT_compiled_vertex_array -#define need_GL_EXT_fog_coord -#define need_GL_EXT_secondary_color -#define need_GL_EXT_framebuffer_object -#define need_GL_VERSION_2_0 -#define need_GL_VERSION_2_1 -#include "extension_helper.h" - -const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multisample", GL_ARB_multisample_functions }, - { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, - { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, - { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions }, - { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, - { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, - { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, - { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, - { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, - { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, - { "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { NULL, 0 } -}; - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN -DRI_CONF_END; -static const GLuint __driNConfigOptions = 0; - -extern const struct dri_extension common_extensions[]; -extern const struct dri_extension nv40_extensions[]; - -static GLboolean -nouveau_create_buffer(__DRIscreenPrivate * driScrnPriv, - __DRIdrawablePrivate * driDrawPriv, - const __GLcontextModes *glVis, GLboolean pixmapBuffer) -{ - struct nouveau_framebuffer *nvfb; - enum pipe_format colour, depth, stencil; - - if (pixmapBuffer) - return GL_FALSE; - - nvfb = CALLOC_STRUCT(nouveau_framebuffer); - if (!nvfb) - return GL_FALSE; - - if (glVis->redBits == 5) - colour = PIPE_FORMAT_R5G6B5_UNORM; - else - colour = PIPE_FORMAT_A8R8G8B8_UNORM; - - if (glVis->depthBits == 16) - depth = PIPE_FORMAT_Z16_UNORM; - else if (glVis->depthBits == 24) - depth = PIPE_FORMAT_Z24S8_UNORM; - else - depth = PIPE_FORMAT_NONE; - - if (glVis->stencilBits == 8) - stencil = PIPE_FORMAT_Z24S8_UNORM; - else - stencil = PIPE_FORMAT_NONE; - - nvfb->stfb = st_create_framebuffer(glVis, colour, depth, stencil, - driDrawPriv->w, driDrawPriv->h, - (void*)nvfb); - if (!nvfb->stfb) { - free(nvfb); - return GL_FALSE; - } - - driDrawPriv->driverPrivate = (void *)nvfb; - return GL_TRUE; -} - -static void -nouveau_destroy_buffer(__DRIdrawablePrivate * driDrawPriv) -{ - struct nouveau_framebuffer *nvfb; - - nvfb = (struct nouveau_framebuffer *)driDrawPriv->driverPrivate; - st_unreference_framebuffer(nvfb->stfb); - free(nvfb); -} - -static __DRIconfig ** -nouveau_fill_in_modes(__DRIscreenPrivate *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) -{ - __DRIconfig **configs; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, - }; - - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = 0; - depth_bits_array[1] = depth_bits; - depth_bits_array[2] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = 0; - if (depth_bits == 24) - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = - ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1; - back_buffer_factor = (have_back_buffer) ? 3 : 1; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, msaa_samples_array, 1); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return NULL; - } - - return configs; -} - -static struct pipe_surface * -dri_surface_from_handle(struct pipe_screen *screen, - unsigned handle, - enum pipe_format format, - unsigned width, - unsigned height, - unsigned pitch) -{ - struct pipe_surface *surface = NULL; - struct pipe_texture *texture = NULL; - struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - - buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle); - if (!buf) - return NULL; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY | - NOUVEAU_TEXTURE_USAGE_LINEAR; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth[0] = 1; - templat.format = format; - templat.width[0] = width; - templat.height[0] = height; - pf_get_block(templat.format, &templat.block); - - texture = screen->texture_blanket(screen, - &templat, - &pitch, - buf); - - /* we don't need the buffer from this point on */ - pipe_buffer_reference(&buf, NULL); - - if (!texture) - return NULL; - - surface = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* we don't need the texture from this point on */ - pipe_texture_reference(&texture, NULL); - return surface; -} - -static const __DRIconfig ** -nouveau_screen_create(__DRIscreenPrivate *psp) -{ - struct nouveau_dri *nv_dri = psp->pDevPriv; - struct nouveau_screen *nv_screen; - static const __DRIversion ddx_expected = - { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = - { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; - - if (!driCheckDriDdxDrmVersions2("nouveau", - &psp->dri_version, &dri_expected, - &psp->ddx_version, &ddx_expected, - &psp->drm_version, &drm_expected)) { - return NULL; - } - - if (drm_expected.patch != psp->drm_version.patch) { - fprintf(stderr, "Incompatible DRM patch level.\n" - "Expected: %d\n" "Current : %d\n", - drm_expected.patch, psp->drm_version.patch); - return NULL; - } - - driInitExtensions(NULL, card_extensions, GL_FALSE); - - if (psp->devPrivSize != sizeof(struct nouveau_dri)) { - NOUVEAU_ERR("DRI struct mismatch between DDX/DRI\n"); - return NULL; - } - - nv_screen = CALLOC_STRUCT(nouveau_screen); - if (!nv_screen) - return NULL; - - nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0); - - nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, NULL); - if (!nv_screen->pscreen) { - FREE(nv_screen); - return NULL; - } - nv_screen->pscreen->flush_frontbuffer = nouveau_flush_frontbuffer; - - { - enum pipe_format format; - - if (nv_dri->bpp == 16) - format = PIPE_FORMAT_R5G6B5_UNORM; - else - format = PIPE_FORMAT_A8R8G8B8_UNORM; - - nv_screen->fb = dri_surface_from_handle(nv_screen->pscreen, - nv_dri->front_offset, - format, - nv_dri->width, - nv_dri->height, - nv_dri->front_pitch * - nv_dri->bpp / 8); - } - - driParseOptionInfo(&nv_screen->option_cache, - __driConfigOptions, __driNConfigOptions); - - nv_screen->driScrnPriv = psp; - psp->private = (void *)nv_screen; - - return (const __DRIconfig **) - nouveau_fill_in_modes(psp, nv_dri->bpp, - (nv_dri->bpp == 16) ? 16 : 24, - (nv_dri->bpp == 16) ? 0 : 8, 1); -} - -static void -nouveau_screen_destroy(__DRIscreenPrivate *driScrnPriv) -{ - struct nouveau_screen *nv_screen = driScrnPriv->private; - - driScrnPriv->private = NULL; - FREE(nv_screen); -} - -const struct __DriverAPIRec -driDriverAPI = { - .InitScreen = nouveau_screen_create, - .DestroyScreen = nouveau_screen_destroy, - .CreateContext = nouveau_context_create, - .DestroyContext = nouveau_context_destroy, - .CreateBuffer = nouveau_create_buffer, - .DestroyBuffer = nouveau_destroy_buffer, - .SwapBuffers = nouveau_swap_buffers, - .MakeCurrent = nouveau_context_bind, - .UnbindContext = nouveau_context_unbind, - .CopySubBuffer = nouveau_copy_sub_buffer, - - .InitScreen2 = NULL, /* one day, I promise! */ -}; - diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h deleted file mode 100644 index ac078f3c63..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __NOUVEAU_SCREEN_DRI_H__ -#define __NOUVEAU_SCREEN_DRI_H__ - -#include "xmlconfig.h" - -struct nouveau_screen { - __DRIscreenPrivate *driScrnPriv; - driOptionCache option_cache; - - struct nouveau_device *device; - - struct pipe_screen *pscreen; - struct pipe_surface *fb; -}; - -#endif diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c deleted file mode 100644 index 9c841a0b2d..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c +++ /dev/null @@ -1,115 +0,0 @@ -#include
-#include -#include - -#include -#include -#include -#include - -#include "nouveau_context.h" -#include "nouveau_screen.h" -#include "nouveau_swapbuffers.h" - -#include "nouveau_pushbuf.h" - -void -nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf, - const drm_clip_rect_t *rect) -{ - struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate; - struct nouveau_screen *nv_screen = nv->dri_screen->private; - struct pipe_context *pipe = nv->st->pipe; - drm_clip_rect_t *pbox; - int nbox, i; - - LOCK_HARDWARE(nv); - if (!dPriv->numClipRects) { - UNLOCK_HARDWARE(nv); - return; - } - pbox = dPriv->pClipRects; - nbox = dPriv->numClipRects; - - for (i = 0; i < nbox; i++, pbox++) { - int sx, sy, dx, dy, w, h; - - sx = pbox->x1 - dPriv->x; - sy = pbox->y1 - dPriv->y; - dx = pbox->x1; - dy = pbox->y1; - w = pbox->x2 - pbox->x1; - h = pbox->y2 - pbox->y1; - - pipe->surface_copy(pipe, nv_screen->fb, dx, dy, surf, - sx, sy, w, h); - } - - pipe->flush(pipe, 0, NULL); - UNLOCK_HARDWARE(nv); - - if (nv->last_stamp != dPriv->lastStamp) { - struct nouveau_framebuffer *nvfb = dPriv->driverPrivate; - st_resize_framebuffer(nvfb->stfb, dPriv->w, dPriv->h); - nv->last_stamp = dPriv->lastStamp; - } -} - -void -nouveau_copy_sub_buffer(__DRIdrawablePrivate *dPriv, int x, int y, int w, int h) -{ - struct nouveau_framebuffer *nvfb = dPriv->driverPrivate; - struct pipe_surface *surf; - - st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf); - if (surf) { - drm_clip_rect_t rect; - rect.x1 = x; - rect.y1 = y; - rect.x2 = x + w; - rect.y2 = y + h; - - st_notify_swapbuffers(nvfb->stfb); - nouveau_copy_buffer(dPriv, surf, &rect); - } -} - -void -nouveau_swap_buffers(__DRIdrawablePrivate *dPriv) -{ - struct nouveau_framebuffer *nvfb = dPriv->driverPrivate; - struct pipe_surface *surf; - - st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf); - if (surf) { - st_notify_swapbuffers(nvfb->stfb); - nouveau_copy_buffer(dPriv, surf, NULL); - } -} - -void -nouveau_flush_frontbuffer(struct pipe_screen *pscreen, struct pipe_surface *ps, - void *context_private) -{ - struct nouveau_context *nv = context_private; - __DRIdrawablePrivate *dPriv = nv->dri_drawable; - - nouveau_copy_buffer(dPriv, ps, NULL); -} - -void -nouveau_contended_lock(struct nouveau_context *nv) -{ - struct nouveau_context *nv_sub = (struct nouveau_context*)nv; - __DRIdrawablePrivate *dPriv = nv_sub->dri_drawable; - __DRIscreenPrivate *sPriv = nv_sub->dri_screen; - - /* If the window moved, may need to set a new cliprect now. - * - * NOTE: This releases and regains the hw lock, so all state - * checking must be done *after* this call: - */ - if (dPriv) - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); -} - diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h deleted file mode 100644 index 4ca9cc2283..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __NOUVEAU_SWAPBUFFERS_H__ -#define __NOUVEAU_SWAPBUFFERS_H__ - -void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *, - const drm_clip_rect_t *); -void nouveau_copy_sub_buffer(__DRIdrawablePrivate *, int x, int y, int w, int h); -void nouveau_swap_buffers(__DRIdrawablePrivate *); -void nouveau_flush_frontbuffer(struct pipe_screen *, struct pipe_surface *, - void *context_private); - -#endif diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile deleted file mode 100644 index 024ab150cb..0000000000 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = nouveau_dri.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ - $(TOP)/src/gallium/drivers/nv30/libnv30.a \ - $(TOP)/src/gallium/drivers/nv40/libnv40.a \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a - -DRIVER_SOURCES = - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -include ../../Makefile.template - -DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs) - -symlinks: -- cgit v1.2.3 From 71b1c92405de2848de4b7effdbc236da1a4815bd Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 8 May 2009 09:22:16 +1000 Subject: nouveau: respect GALLIUM_STATE_TRACKERS_DIRS --- src/gallium/winsys/drm/nouveau/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile index e275b2d9e7..6c9cbef26d 100644 --- a/src/gallium/winsys/drm/nouveau/Makefile +++ b/src/gallium/winsys/drm/nouveau/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../.. include $(TOP)/configs/current -SUBDIRS = drm dri +SUBDIRS = drm $(GALLIUM_STATE_TRACKERS_DIRS) default install clean: @for dir in $(SUBDIRS) ; do \ -- cgit v1.2.3 From 25a4156a8b0bc59f7d3f077526b7e3e350b072ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 1 May 2009 18:49:22 +0100 Subject: wgl: Implement ShareLists. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 2 +- .../state_trackers/wgl/shared/stw_context.c | 24 ++++++++++++++++++++++ src/gallium/state_trackers/wgl/shared/stw_public.h | 2 ++ src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 7 +------ 4 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index b259ea91f5..62af765211 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -562,7 +562,7 @@ DrvShareLists( if (DBG) debug_printf( "%s\n", __FUNCTION__ ); - return FALSE; + return stw_share_lists(dhglrc1, dhglrc2); } BOOL APIENTRY diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 473e3308c6..e172f09bdf 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -74,6 +74,30 @@ stw_copy_context( return ret; } +BOOL +stw_share_lists( + UINT_PTR hglrc1, + UINT_PTR hglrc2 ) +{ + struct stw_context *ctx1; + struct stw_context *ctx2; + BOOL ret = FALSE; + + pipe_mutex_lock( stw_dev->mutex ); + + ctx1 = stw_lookup_context_locked( hglrc1 ); + ctx2 = stw_lookup_context_locked( hglrc2 ); + + if (ctx1 && ctx2 && + ctx1->pfi == ctx2->pfi) { + ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx); + } + + pipe_mutex_unlock( stw_dev->mutex ); + + return ret; +} + UINT_PTR stw_create_layer_context( HDC hdc, diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h index 59d709a6d4..7fe9cfb356 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_public.h +++ b/src/gallium/state_trackers/wgl/shared/stw_public.h @@ -37,6 +37,8 @@ BOOL stw_copy_context( UINT_PTR hglrcSrc, UINT_PTR stw_create_layer_context( HDC hdc, int iLayerPlane ); +BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 ); + BOOL stw_delete_context( UINT_PTR hglrc ); BOOL diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index 30e42e0ec5..a131292f7a 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -186,12 +186,7 @@ wglShareLists( HGLRC hglrc1, HGLRC hglrc2 ) { - (void) hglrc1; - (void) hglrc2; - - assert( 0 ); - - return FALSE; + return stw_share_lists( (UINT_PTR)hglrc1, (UINT_PTR)hglrc2);; } WINGDIAPI BOOL APIENTRY -- cgit v1.2.3 From 082a086e9dffb78b73269ac3524f899e9f780ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 1 May 2009 18:53:17 +0100 Subject: wgl: Remove unused variable. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index e172f09bdf..336eccef71 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -109,7 +109,6 @@ stw_create_layer_context( GLvisual *visual = NULL; struct pipe_screen *screen = NULL; struct pipe_context *pipe = NULL; - UINT_PTR hglrc = 0; if(!stw_dev) return 0; -- cgit v1.2.3 From 3a43ea4946bc5965267f9b689378697fcab020c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 1 May 2009 18:53:51 +0100 Subject: wgl: Add assertion for missing function. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 336eccef71..d532b1563b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -64,6 +64,7 @@ stw_copy_context( if (src && dst) { /* FIXME */ + assert(0); (void) src; (void) dst; (void) mask; -- cgit v1.2.3 From 26ffd445861f405e295644df1cbac29458a6054f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 6 May 2009 19:58:08 +0100 Subject: wgl: Enforce a minimum 1x1 framebuffer size. --- .../state_trackers/wgl/shared/stw_context.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index d532b1563b..b61f74f69b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -278,19 +278,30 @@ stw_release_context( /* Find the width and height of the window named by hdc. */ static void -stw_get_window_size( HDC hdc, GLuint *width, GLuint *height ) +stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight ) { - if (WindowFromDC( hdc )) { - RECT rect; + GLuint width, height; + HWND hwnd; - GetClientRect( WindowFromDC( hdc ), &rect ); - *width = rect.right - rect.left; - *height = rect.bottom - rect.top; + hwnd = WindowFromDC( hdc ); + if (hwnd) { + RECT rect; + GetClientRect( hwnd, &rect ); + width = rect.right - rect.left; + height = rect.bottom - rect.top; } else { - *width = GetDeviceCaps( hdc, HORZRES ); - *height = GetDeviceCaps( hdc, VERTRES ); + width = GetDeviceCaps( hdc, HORZRES ); + height = GetDeviceCaps( hdc, VERTRES ); } + + if(width < 1) + width = 1; + if(height < 1) + height = 1; + + *pwidth = width; + *pheight = height; } UINT_PTR -- cgit v1.2.3 From 48c7aa2648877efab4aac45b50ee2a4c79178536 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 6 May 2009 20:41:17 +0100 Subject: stw: fix potential uninitialized use of curctx --- src/gallium/state_trackers/wgl/shared/stw_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index b61f74f69b..dd97e48b14 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -348,7 +348,7 @@ stw_make_current( struct stw_framebuffer *fb; GLuint width = 0; GLuint height = 0; - struct stw_context *curctx; + struct stw_context *curctx = NULL; if (!stw_dev) return FALSE; -- cgit v1.2.3 From 4a333c64faf78dd39f07574bb94f62ba48995e7d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 09:24:37 +0100 Subject: util/upload: catch failures to map_range and return error Caller may be able to do something about this - eg flush and retry. --- src/gallium/auxiliary/util/u_upload_mgr.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index d9c0d7afa8..2eb98068c8 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -70,7 +70,7 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, } -static INLINE void +static INLINE enum pipe_error my_buffer_write(struct pipe_screen *screen, struct pipe_buffer *buf, unsigned offset, unsigned size, unsigned dirty_size, @@ -84,12 +84,14 @@ my_buffer_write(struct pipe_screen *screen, assert(size); map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE); - assert(map); - if(map) { - memcpy(map + offset, data, size); - pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); - pipe_buffer_unmap(screen, buf); - } + if (map == NULL) + return PIPE_ERROR_OUT_OF_MEMORY; + + memcpy(map + offset, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); + pipe_buffer_unmap(screen, buf); + + return PIPE_OK; } /* Release old buffer. @@ -162,12 +164,14 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, /* Copy the data, using map_range if available: */ - my_buffer_write( upload->screen, - upload->buffer, - upload->offset, - size, - alloc_size, - data ); + ret = my_buffer_write( upload->screen, + upload->buffer, + upload->offset, + size, + alloc_size, + data ); + if (ret) + return ret; /* Emit the return values: */ -- cgit v1.2.3 From 626b6f37eaf81eeb0eb069f18c98c6ffa463647e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 7 May 2009 18:21:56 +0100 Subject: wgl: Export pixelformats with accumulation bits. --- src/gallium/state_trackers/wgl/shared/stw_pixelformat.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 8d6955f390..b81d2b59a4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -119,6 +119,7 @@ stw_pixelformat_add( struct stw_device *stw_dev, const struct stw_pf_color_info *color, const struct stw_pf_depth_info *depth, + unsigned accum, boolean doublebuffer, unsigned samples ) { @@ -167,11 +168,11 @@ stw_pixelformat_add( pfi->pfd.cBlueShift = color->shift.blue; pfi->pfd.cAlphaBits = color->bits.alpha; pfi->pfd.cAlphaShift = color->shift.alpha; - pfi->pfd.cAccumBits = 0; - pfi->pfd.cAccumRedBits = 0; - pfi->pfd.cAccumGreenBits = 0; - pfi->pfd.cAccumBlueBits = 0; - pfi->pfd.cAccumAlphaBits = 0; + pfi->pfd.cAccumBits = 4*accum; + pfi->pfd.cAccumRedBits = accum; + pfi->pfd.cAccumGreenBits = accum; + pfi->pfd.cAccumBlueBits = accum; + pfi->pfd.cAccumAlphaBits = accum; pfi->pfd.cDepthBits = depth->bits.depth; pfi->pfd.cStencilBits = depth->bits.stencil; pfi->pfd.cAuxBuffers = 0; @@ -228,7 +229,8 @@ stw_pixelformat_init( void ) PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) continue; - stw_pixelformat_add( stw_dev, color, depth, doublebuffer, samples ); + stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples ); + stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples ); } } } -- cgit v1.2.3 From 4816764777485b46f360eb6f86dea243d1809221 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 15:28:09 -0700 Subject: r300-gallium: Finish space accounting. Still broken... --- src/gallium/drivers/r300/r300_context.h | 7 +++- src/gallium/drivers/r300/r300_emit.c | 60 ++++++++++++++++++++++++++++++--- src/gallium/drivers/r300/r300_emit.h | 2 ++ src/gallium/drivers/r300/r300_render.c | 23 ++----------- 4 files changed, 66 insertions(+), 26 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 6f62998b35..96f1f11246 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -264,6 +264,11 @@ struct r300_context { /* Draw module. Used mostly for SW TCL. */ struct draw_context* draw; + /* Vertex buffer for rendering. */ + struct pipe_buffer* vbo; + /* Offset into the VBO. */ + size_t vbo_offset; + /* Various CSO state objects. */ /* Blend state. */ struct r300_blend_state* blend_state; @@ -289,7 +294,7 @@ struct r300_context { /* Texture states. */ struct r300_texture* textures[8]; int texture_count; - /* Vertex buffers. */ + /* Vertex buffers for Gallium. */ struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; /* Vertex information. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 01bac5f759..ab17af799b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -296,6 +296,30 @@ void r300_emit_texture(struct r300_context* r300, END_CS; } +void r300_emit_vertex_buffer(struct r300_context* r300) +{ + CS_LOCALS(r300); + + debug_printf("r300: Preparing vertex buffer %p for render, " + "vertex size %d\n", r300->vbo, + r300->vertex_info.vinfo.size); + /* Set the pointer to our vertex buffer. The emitted values are this: + * PACKET3 [3D_LOAD_VBPNTR] + * COUNT [1] + * FORMAT [size | stride << 8] + * OFFSET [offset into BO] + * VBPNTR [relocated BO] + */ + BEGIN_CS(7); + OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); + OUT_CS(1); + OUT_CS(r300->vertex_info.vinfo.size | + (r300->vertex_info.vinfo.size << 8)); + OUT_CS(r300->vbo_offset); + OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + END_CS; +} + void r300_emit_vertex_format_state(struct r300_context* r300) { int i; @@ -421,20 +445,41 @@ void r300_flush_textures(struct r300_context* r300) void r300_emit_dirty_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_texture* tex; int i; int dirty_tex = 0; - if (!(r300->dirty_hw)) { + if (!(r300->dirty_state)) { return; } r300_update_derived_state(r300); /* XXX check size */ - struct r300_texture* fb_tex = - (struct r300_texture*)r300->framebuffer_state.cbufs[0]; - r300->winsys->add_buffer(r300->winsys, fb_tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + /* Color buffers... */ + for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { + tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]; + //assert(tex && tex->buffer && "cbuf is marked, but NULL!"); + if (!tex->buffer) return; + r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + } + /* ...depth buffer... */ + if (r300->framebuffer_state.zsbuf) { + tex = (struct r300_texture*)r300->framebuffer_state.zsbuf; + //assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); + if (!tex->buffer) return; + r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + } + /* ...and vertex buffer. */ + if (r300->vbo) { + r300->winsys->add_buffer(r300->winsys, r300->vbo, + RADEON_GEM_DOMAIN_GTT, 0); + } else { + debug_printf("No VBO while emitting dirty state!\n"); + } + if (r300->winsys->validate(r300->winsys)) { /* XXX */ r300->context.flush(&r300->context, 0, NULL); @@ -519,4 +564,9 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_emit_vertex_format_state(r300); r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT; } + + /* Finally, emit the VBO. */ + r300_emit_vertex_buffer(r300); + + r300->dirty_hw++; } diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 31dbc7ab85..36e14f69f7 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -62,6 +62,8 @@ void r300_emit_scissor_state(struct r300_context* r300, void r300_emit_texture(struct r300_context* r300, struct r300_texture* tex, unsigned offset); +void r300_emit_vertex_buffer(struct r300_context* r300); + void r300_emit_vertex_format_state(struct r300_context* r300); void r300_emit_vertex_shader(struct r300_context* r300, diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index cbd84d7c56..29b66cee7e 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -180,27 +180,10 @@ static void prepare_render(struct r300_render* render, unsigned count) CS_LOCALS(r300); - /* Make sure that all possible state is emitted. */ - r300_emit_dirty_state(r300); + r300->vbo = render->vbo; + r300->vbo_offset = render->vbo_offset; - debug_printf("r300: Preparing vertex buffer %p for render, " - "vertex size %d, vertex count %d\n", render->vbo, - r300->vertex_info.vinfo.size, count); - /* Set the pointer to our vertex buffer. The emitted values are this: - * PACKET3 [3D_LOAD_VBPNTR] - * COUNT [1] - * FORMAT [size | stride << 8] - * OFFSET [0] - * VBPNTR [relocated BO] - */ - BEGIN_CS(7); - OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); - OUT_CS(1); - OUT_CS(r300->vertex_info.vinfo.size | - (r300->vertex_info.vinfo.size << 8)); - OUT_CS(render->vbo_offset); - OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); - END_CS; + r300_emit_dirty_state(r300); } static void r300_render_draw_arrays(struct vbuf_render* render, -- cgit v1.2.3 From cd59933d9f70c6acea63013f1b773b545026bf81 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 16:50:42 -0700 Subject: r300-gallium, radeon: A couple cleanups. Trying to track down goddamn bugs. :C --- src/gallium/drivers/r300/r300_context.c | 4 ---- src/gallium/drivers/r300/r300_state.c | 3 +++ src/gallium/drivers/r300/r300_texture.c | 1 + src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +++++++- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 6bdf544a05..a4e89c37d1 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -34,10 +34,6 @@ static boolean r300_draw_range_elements(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); int i; - if (r300->dirty_state) { - r300_emit_dirty_state(r300); - } - for (i = 0; i < r300->vertex_buffer_count; i++) { void* buf = pipe_buffer_map(pipe->screen, r300->vertex_buffers[i].buffer, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 184a23c9e6..0143e228c4 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -562,14 +562,17 @@ static void r300_set_viewport_state(struct pipe_context* pipe, r300->viewport_state->vte_control = R300_VTX_W0_FMT; if (state->scale[0] != 1.0f) { + assert(state->scale[0] != 0.0f); r300->viewport_state->xscale = state->scale[0]; r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA; } if (state->scale[1] != 1.0f) { + assert(state->scale[1] != 0.0f); r300->viewport_state->yscale = state->scale[1]; r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA; } if (state->scale[2] != 1.0f) { + assert(state->scale[2] != 0.0f); r300->viewport_state->zscale = state->scale[2]; r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA; } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index fe91f4e184..6c9d3b7412 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -187,6 +187,7 @@ static struct pipe_texture* tex->stride); pipe_buffer_reference(&tex->buffer, buffer); + debug_printf("%p is the buffer\n", tex->buffer); return (struct pipe_texture*)tex; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index da233203d7..5dcce20cd5 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -62,6 +62,7 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) if (retval == RADEON_CS_SPACE_OP_TO_BIG) { /* We might as well HCF, since this is not going to fit in the card, * period. */ + /* XXX just drop it on the floor instead */ exit(1); } else if (retval == RADEON_CS_SPACE_FLUSH) { /* We must flush before more rendering can commence. */ @@ -128,14 +129,19 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) { struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; - int retval = 0; + struct radeon_cs_space_check* sc = priv->sc; + int retval = 1; + /* Emit the CS. */ retval = radeon_cs_emit(priv->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); radeon_cs_print(priv->cs, stderr); } radeon_cs_erase(priv->cs); + + /* Clean out BOs. */ + memset(sc, 0, sizeof(struct radeon_cs_space_check) * RADEON_MAX_BOS); } /* Helper function to do the ioctls needed for setup and init. */ -- cgit v1.2.3 From bed917641cfde06b9ff609760ba20b498a65cefa Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 17:09:32 -0700 Subject: radeon-gallium: Shut up Valgrind. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 5dcce20cd5..556f1d9b87 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -147,9 +147,9 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(struct r300_winsys* winsys, int fd) { - struct drm_radeon_gem_info info; - drm_radeon_getparam_t gp; - int target; + struct drm_radeon_gem_info info = {0}; + drm_radeon_getparam_t gp = {0}; + int target = 0; int retval; gp.value = ⌖ -- cgit v1.2.3 From 1b26c2bbaefe3608b96d9351c0f2eac80274891c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 19:40:38 -0700 Subject: r300-gallium, radeon: BO handling fixes, some useful asserts. --- src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index ab17af799b..38b1682415 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -459,7 +459,7 @@ void r300_emit_dirty_state(struct r300_context* r300) /* Color buffers... */ for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]; - //assert(tex && tex->buffer && "cbuf is marked, but NULL!"); + assert(tex && tex->buffer && "cbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM); @@ -467,7 +467,7 @@ void r300_emit_dirty_state(struct r300_context* r300) /* ...depth buffer... */ if (r300->framebuffer_state.zsbuf) { tex = (struct r300_texture*)r300->framebuffer_state.zsbuf; - //assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); + assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 556f1d9b87..cbe1652302 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -37,6 +37,8 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, * find a slot for it otherwise. */ for (i = 0; i < RADEON_MAX_BOS; i++) { if (sc[i].bo == bo) { + sc[i].read_domains |= rd; + sc[i].write_domain |= wd; return; } else if (sc[i].bo == NULL) { sc[i].bo = bo; @@ -52,11 +54,15 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, static boolean radeon_r300_validate(struct r300_winsys* winsys) { - int retval; + int retval, i; struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; struct radeon_cs_space_check* sc = priv->sc; + debug_printf("Validation count: %d\n", priv->bo_count); + for (i = 0; i < priv->bo_count; i++) { + debug_printf("BO %d: %p rd: %d wd: %d\n", i, sc[i].bo, sc[i].read_domains, sc[i].write_domain); + } retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { -- cgit v1.2.3 From ce758a21b9984cce14db4234fbe353d06a3a2d32 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 22:05:18 -0700 Subject: r300-gallium: Fix bad cast. Space accounting completely works now. Boy, is my face red. :C --- src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/drivers/r300/r300_texture.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 38b1682415..c73d5a0b44 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -458,7 +458,7 @@ void r300_emit_dirty_state(struct r300_context* r300) /* XXX check size */ /* Color buffers... */ for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { - tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]; + tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture; assert(tex && tex->buffer && "cbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, @@ -466,7 +466,7 @@ void r300_emit_dirty_state(struct r300_context* r300) } /* ...depth buffer... */ if (r300->framebuffer_state.zsbuf) { - tex = (struct r300_texture*)r300->framebuffer_state.zsbuf; + tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture; assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 6c9d3b7412..5ea9f56247 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -86,8 +86,6 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen, const struct pipe_texture* template) { - /* XXX struct r300_screen* r300screen = r300_screen(screen); */ - struct r300_texture* tex = CALLOC_STRUCT(r300_texture); if (!tex) { @@ -187,7 +185,6 @@ static struct pipe_texture* tex->stride); pipe_buffer_reference(&tex->buffer, buffer); - debug_printf("%p is the buffer\n", tex->buffer); return (struct pipe_texture*)tex; } -- cgit v1.2.3 From c6d2b4a495affbaf0fbc53cf54159a7b2b4f6085 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 22:45:56 -0700 Subject: r300-gallium: vs: Add writemasks. --- src/gallium/drivers/r300/r300_state_tcl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index d84912de48..c52ce258c2 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -169,7 +169,7 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(r300_vs_op(op)) | R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) | R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister)) | - R300_PVS_DST_WE_XYZW; + R300_PVS_DST_WE(dst->DstRegister.WriteMask); switch (count) { case 3: vs->instructions[i].inst3 = -- cgit v1.2.3 From e669ce01d4ee1e785671c811140e4e95e9a7548e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 22:46:12 -0700 Subject: r300-gallium: vs: Add scalar setup, RSQ. Icky icky icky icky. Icky icky, icky icky. Icky. --- src/gallium/drivers/r300/r300_state_tcl.c | 39 ++++++++++++++++++++++++++----- src/gallium/drivers/r300/r300_state_tcl.h | 2 ++ 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index c52ce258c2..a3b9277cf7 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -135,6 +135,8 @@ static uint32_t r300_vs_op(unsigned op) case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: return R300_VE_ADD; + case TGSI_OPCODE_RSQ: + return R300_PVS_DST_MATH_INST | R300_ME_RECIP_DX; case TGSI_OPCODE_MAD: return R300_PVS_DST_MACRO_INST | R300_PVS_MACRO_OP_2CLK_MADD; default: @@ -158,12 +160,30 @@ static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) } } +/* XXX icky icky icky icky */ +static uint32_t r300_vs_scalar_swiz(struct tgsi_full_src_register* reg) +{ + if (reg->SrcRegister.Extended) { + return reg->SrcRegisterExtSwz.ExtSwizzleX | + (reg->SrcRegisterExtSwz.ExtSwizzleX << 3) | + (reg->SrcRegisterExtSwz.ExtSwizzleX << 6) | + (reg->SrcRegisterExtSwz.ExtSwizzleX << 9); + } else { + return reg->SrcRegister.SwizzleX | + (reg->SrcRegister.SwizzleX << 3) | + (reg->SrcRegister.SwizzleX << 6) | + (reg->SrcRegister.SwizzleX << 9); + } +} + +/* XXX scalar stupidity */ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, struct r300_vs_asm* assembler, struct tgsi_full_src_register* src, struct tgsi_full_dst_register* dst, unsigned op, - unsigned count) + unsigned count, + boolean is_scalar) { int i = vs->instruction_count; vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(r300_vs_op(op)) | @@ -190,7 +210,9 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[0].SrcRegister)) | R300_PVS_SRC_OFFSET(src[0].SrcRegister.Index) | - R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[0])); + /* XXX the icky, it burns */ + R300_PVS_SRC_SWIZZLE(is_scalar ? r300_vs_scalar_swiz(&src[0]) + : r300_vs_swiz(&src[0])); break; } vs->instruction_count++; @@ -201,11 +223,16 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, struct tgsi_full_instruction* inst) { switch (inst->Instruction.Opcode) { + case TGSI_OPCODE_RSQ: + r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], inst->Instruction.Opcode, + 1, TRUE); + break; case TGSI_OPCODE_ADD: case TGSI_OPCODE_MUL: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, - 2); + 2, FALSE); break; case TGSI_OPCODE_DP3: /* Set alpha swizzle to zero for src0 and src1 */ @@ -235,19 +262,19 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, case TGSI_OPCODE_DP4: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, - 2); + 2, FALSE); break; case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: inst->FullSrcRegisters[1] = r300_constant_zero; r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, - 2); + 2, FALSE); break; case TGSI_OPCODE_MAD: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, - 3); + 3, FALSE); break; case TGSI_OPCODE_END: break; diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index e2e1357d43..94d8baa503 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -35,6 +35,8 @@ # define R300_VE_DOT_PRODUCT 1 # define R300_VE_MULTIPLY 2 # define R300_VE_ADD 3 +#define R300_PVS_DST_MATH_INST (1 << 6) +# define R300_ME_RECIP_DX 6 #define R300_PVS_DST_MACRO_INST (1 << 7) # define R300_PVS_MACRO_OP_2CLK_MADD 0 #define R300_PVS_DST_REG_TYPE(x) ((x) << 8) -- cgit v1.2.3 From 9b1077714889a5c331c0e208f36233767d39d875 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 22:52:32 -0700 Subject: r300-gallium: vs: Add MAX. --- src/gallium/drivers/r300/r300_state_tcl.c | 7 +++++++ src/gallium/drivers/r300/r300_state_tcl.h | 1 + 2 files changed, 8 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index a3b9277cf7..b8a1dd45d5 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -135,6 +135,8 @@ static uint32_t r300_vs_op(unsigned op) case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: return R300_VE_ADD; + case TGSI_OPCODE_MAX: + return R300_VE_MAXIMUM; case TGSI_OPCODE_RSQ: return R300_PVS_DST_MATH_INST | R300_ME_RECIP_DX; case TGSI_OPCODE_MAD: @@ -271,6 +273,11 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2, FALSE); break; + case TGSI_OPCODE_MAX: + r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], inst->Instruction.Opcode, + 2, FALSE); + break; case TGSI_OPCODE_MAD: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 94d8baa503..204e1d31c3 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -35,6 +35,7 @@ # define R300_VE_DOT_PRODUCT 1 # define R300_VE_MULTIPLY 2 # define R300_VE_ADD 3 +# define R300_VE_MAXIMUM 7 #define R300_PVS_DST_MATH_INST (1 << 6) # define R300_ME_RECIP_DX 6 #define R300_PVS_DST_MACRO_INST (1 << 7) -- cgit v1.2.3 From 7e347a0f49bd737f1a219fe8001c8ddb4f8c3d85 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 22:54:52 -0700 Subject: r300-gallium: vs: Add SLT, clean up MAX. This should be all the opcodes for basic TCL. --- src/gallium/drivers/r300/r300_state_tcl.c | 9 ++++----- src/gallium/drivers/r300/r300_state_tcl.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index b8a1dd45d5..410a756773 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -137,6 +137,8 @@ static uint32_t r300_vs_op(unsigned op) return R300_VE_ADD; case TGSI_OPCODE_MAX: return R300_VE_MAXIMUM; + case TGSI_OPCODE_SLT: + return R300_VE_SET_LESS_THAN; case TGSI_OPCODE_RSQ: return R300_PVS_DST_MATH_INST | R300_ME_RECIP_DX; case TGSI_OPCODE_MAD: @@ -232,6 +234,8 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, break; case TGSI_OPCODE_ADD: case TGSI_OPCODE_MUL: + case TGSI_OPCODE_MAX: + case TGSI_OPCODE_SLT: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2, FALSE); @@ -273,11 +277,6 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2, FALSE); break; - case TGSI_OPCODE_MAX: - r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, - &inst->FullDstRegisters[0], inst->Instruction.Opcode, - 2, FALSE); - break; case TGSI_OPCODE_MAD: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 204e1d31c3..d5d425e9d6 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -36,6 +36,7 @@ # define R300_VE_MULTIPLY 2 # define R300_VE_ADD 3 # define R300_VE_MAXIMUM 7 +# define R300_VE_SET_LESS_THAN 10 #define R300_PVS_DST_MATH_INST (1 << 6) # define R300_ME_RECIP_DX 6 #define R300_PVS_DST_MACRO_INST (1 << 7) -- cgit v1.2.3 From c4c5bf31a743bc53a9dbdef7807928dacae7958a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 9 May 2009 00:28:49 -0700 Subject: r300-gallium: Start VS dumper. --- src/gallium/drivers/r300/r300_debug.c | 90 ++++----------------- src/gallium/drivers/r300/r300_debug.h | 146 ++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 76 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index dd63136c9d..1ff72172eb 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -30,81 +30,6 @@ static void r300_dump_fs(struct r300_fragment_shader* fs) } } -static char* r500_fs_swiz[] = { - " R", - " G", - " B", - " A", - " 0", - ".5", - " 1", - " U", -}; - -static char* r500_fs_op_rgb[] = { - "MAD", - "DP3", - "DP4", - "D2A", - "MIN", - "MAX", - "---", - "CND", - "CMP", - "FRC", - "SOP", - "MDH", - "MDV", -}; - -static char* r500_fs_op_alpha[] = { - "MAD", - " DP", - "MIN", - "MAX", - "---", - "CND", - "CMP", - "FRC", - "EX2", - "LN2", - "RCP", - "RSQ", - "SIN", - "COS", - "MDH", - "MDV", -}; - -static char* r500_fs_mask[] = { - "NONE", - "R ", - " G ", - "RG ", - " B ", - "R B ", - " GB ", - "RGB ", - " A", - "R A", - " G A", - "RG A", - " BA", - "R BA", - " GBA", - "RGBA", -}; - -static char* r500_fs_tex[] = { - " NOP", - " LD", - "TEXKILL", - " PROJ", - "LODBIAS", - " LOD", - " DXDY", -}; - void r500_fs_dump(struct r500_fragment_shader* fs) { int i; @@ -225,12 +150,25 @@ void r500_fs_dump(struct r500_fragment_shader* fs) } } +static void r300_vs_op_dump(uint32_t op) +{ + if (op & 0x81) { + debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n"); + } else if (op & 0x80) { + debug_printf(" PVS_MACRO_OP_2CLK_MADD\n"); + } else if (op & 0x40) { + debug_printf("%s\n", r300_vs_me_ops[op & 0x1f]); + } else { + debug_printf("%s\n", r300_vs_ve_ops[op & 0x1f]); + } +} + void r300_vs_dump(struct r300_vertex_shader* vs) { int i; for (i = 0; i < vs->instruction_count; i++) { - debug_printf("inst0: 0x%x\n", vs->instructions[i].inst0); + r300_vs_op_dump(vs->instructions[i].inst0); debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1); debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2); debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3); diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h index a1f873656d..6306594099 100644 --- a/src/gallium/drivers/r300/r300_debug.h +++ b/src/gallium/drivers/r300/r300_debug.h @@ -27,6 +27,152 @@ #include "r300_state_shader.h" #include "r300_state_tcl.h" +static char* r500_fs_swiz[] = { + " R", + " G", + " B", + " A", + " 0", + ".5", + " 1", + " U", +}; + +static char* r500_fs_op_rgb[] = { + "MAD", + "DP3", + "DP4", + "D2A", + "MIN", + "MAX", + "---", + "CND", + "CMP", + "FRC", + "SOP", + "MDH", + "MDV", +}; + +static char* r500_fs_op_alpha[] = { + "MAD", + " DP", + "MIN", + "MAX", + "---", + "CND", + "CMP", + "FRC", + "EX2", + "LN2", + "RCP", + "RSQ", + "SIN", + "COS", + "MDH", + "MDV", +}; + +static char* r500_fs_mask[] = { + "NONE", + "R ", + " G ", + "RG ", + " B ", + "R B ", + " GB ", + "RGB ", + " A", + "R A", + " G A", + "RG A", + " BA", + "R BA", + " GBA", + "RGBA", +}; + +static char* r500_fs_tex[] = { + " NOP", + " LD", + "TEXKILL", + " PROJ", + "LODBIAS", + " LOD", + " DXDY", +}; + +static char* r300_vs_ve_ops[] = { + /* R300 vector ops */ + " VE_NO_OP", + " VE_DOT_PRODUCT", + " VE_MULTIPLY", + " VE_ADD", + " VE_MULTIPLY_ADD", + " VE_DISTANCE_FACTOR", + " VE_FRACTION", + " VE_MAXIMUM", + " VE_MINIMUM", + "VE_SET_GREATER_THAN_EQUAL", + " VE_SET_LESS_THAN", + " VE_MULTIPLYX2_ADD", + " VE_MULTIPLY_CLAMP", + " VE_FLT2FIX_DX", + " VE_FLT2FIX_DX_RND", + /* R500 vector ops */ + " VE_PRED_SET_EQ_PUSH", + " VE_PRED_SET_GT_PUSH", + " VE_PRED_SET_GTE_PUSH", + " VE_PRED_SET_NEQ_PUSH", + " VE_COND_WRITE_EQ", + " VE_COND_WRITE_GT", + " VE_COND_WRITE_GTE", + " VE_COND_WRITE_NEQ", + " VE_SET_GREATER_THAN", + " VE_SET_EQUAL", + " VE_SET_NOT_EQUAL", + " (reserved)", + " (reserved)", + " (reserved)", +}; + +static char* r300_vs_me_ops[] = { + /* R300 math ops */ + " ME_NO_OP", + " ME_EXP_BASE2_DX", + " ME_LOG_BASE2_DX", + " ME_EXP_BASEE_FF", + " ME_LIGHT_COEFF_DX", + " ME_POWER_FUNC_FF", + " ME_RECIP_DX", + " ME_RECIP_FF", + " ME_RECIP_SQRT_DX", + " ME_RECIP_SQRT_FF", + " ME_MULTIPLY", + " ME_EXP_BASE2_FULL_DX", + " ME_LOG_BASE2_FULL_DX", + " ME_POWER_FUNC_FF_CLAMP_B", + "ME_POWER_FUNC_FF_CLAMP_B1", + "ME_POWER_FUNC_FF_CLAMP_01", + " ME_SIN", + " ME_COS", + /* R500 math ops */ + " ME_LOG_BASE2_IEEE", + " ME_RECIP_IEEE", + " ME_RECIP_SQRT_IEEE", + " ME_PRED_SET_EQ", + " ME_PRED_SET_GT", + " ME_PRED_SET_GTE", + " ME_PRED_SET_NEQ", + " ME_PRED_SET_CLR", + " ME_PRED_SET_INV", + " ME_PRED_SET_POP", + " ME_PRED_SET_RESTORE", + " (reserved)", + " (reserved)", + " (reserved)", +}; + void r500_fs_dump(struct r500_fragment_shader* fs); void r300_vs_dump(struct r300_vertex_shader* vs); -- cgit v1.2.3 From a738d2b4c2979d7d54064f2ad08da401b28a473b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 9 May 2009 00:38:07 -0700 Subject: r300-gallium: vs: Make imms work, cleanup some of the switches. --- src/gallium/drivers/r300/r300_state_tcl.c | 38 +++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 410a756773..ed9164db49 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -71,16 +71,13 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, { switch (src->File) { case TGSI_FILE_NULL: - /* Probably a zero or one swizzle */ - return R300_PVS_SRC_REG_INPUT; - break; case TGSI_FILE_INPUT: + /* Probably a zero or one swizzle */ return R300_PVS_SRC_REG_INPUT; - break; case TGSI_FILE_TEMPORARY: return R300_PVS_SRC_REG_TEMPORARY; - break; case TGSI_FILE_CONSTANT: + case TGSI_FILE_IMMEDIATE: return R300_PVS_SRC_REG_CONSTANT; default: debug_printf("r300: vs: Unimplemented src type %d\n", src->File); @@ -89,16 +86,32 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, return 0; } +static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler, + struct tgsi_src_register* src) +{ + switch (src->File) { + case TGSI_FILE_NULL: + case TGSI_FILE_INPUT: + case TGSI_FILE_TEMPORARY: + case TGSI_FILE_CONSTANT: + return src->Index; + case TGSI_FILE_IMMEDIATE: + return src->Index + assembler->imm_offset; + default: + debug_printf("r300: vs: Unimplemented src type %d\n", src->File); + break; + } + return 0; +} + static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler, struct tgsi_dst_register* dst) { switch (dst->File) { case TGSI_FILE_TEMPORARY: return R300_PVS_DST_REG_TEMPORARY; - break; case TGSI_FILE_OUTPUT: return R300_PVS_DST_REG_OUT; - break; default: debug_printf("r300: vs: Unimplemented dst type %d\n", dst->File); break; @@ -112,10 +125,8 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, switch (dst->File) { case TGSI_FILE_TEMPORARY: return dst->Index; - break; case TGSI_FILE_OUTPUT: return assembler->tab[dst->Index]; - break; default: debug_printf("r300: vs: Unimplemented dst %d\n", dst->File); break; @@ -199,21 +210,24 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, vs->instructions[i].inst3 = R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[2].SrcRegister)) | - R300_PVS_SRC_OFFSET(src[2].SrcRegister.Index) | + R300_PVS_SRC_OFFSET(r300_vs_src(assembler, + &src[2].SrcRegister)) | R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[2])); /* Fall through */ case 2: vs->instructions[i].inst2 = R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[1].SrcRegister)) | - R300_PVS_SRC_OFFSET(src[1].SrcRegister.Index) | + R300_PVS_SRC_OFFSET(r300_vs_src(assembler, + &src[1].SrcRegister)) | R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[1])); /* Fall through */ case 1: vs->instructions[i].inst1 = R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[0].SrcRegister)) | - R300_PVS_SRC_OFFSET(src[0].SrcRegister.Index) | + R300_PVS_SRC_OFFSET(r300_vs_src(assembler, + &src[0].SrcRegister)) | /* XXX the icky, it burns */ R300_PVS_SRC_SWIZZLE(is_scalar ? r300_vs_scalar_swiz(&src[0]) : r300_vs_swiz(&src[0])); -- cgit v1.2.3 From 53c2cc8fefa07723fc456d94eda292e201c41dae Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 9 May 2009 00:43:05 -0700 Subject: radeon-gallium: Clean up some of the BO counting logic. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index cbe1652302..be70ead68d 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -35,21 +35,19 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, /* Check to see if this BO is already in line for validation; * find a slot for it otherwise. */ - for (i = 0; i < RADEON_MAX_BOS; i++) { + assert(priv->bo_count <= RADEON_MAX_BOS); + for (i = 0; i < priv->bo_count; i++) { if (sc[i].bo == bo) { sc[i].read_domains |= rd; sc[i].write_domain |= wd; return; - } else if (sc[i].bo == NULL) { - sc[i].bo = bo; - sc[i].read_domains = rd; - sc[i].write_domain = wd; - priv->bo_count = i + 1; - return; } } - assert(FALSE && "Oh God too many BOs!"); + sc[priv->bo_count].bo = bo; + sc[priv->bo_count].read_domains = rd; + sc[priv->bo_count].write_domain = wd; + priv->bo_count++; } static boolean radeon_r300_validate(struct r300_winsys* winsys) @@ -148,6 +146,7 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Clean out BOs. */ memset(sc, 0, sizeof(struct radeon_cs_space_check) * RADEON_MAX_BOS); + priv->bo_count = 0; } /* Helper function to do the ioctls needed for setup and init. */ -- cgit v1.2.3