diff options
69 files changed, 632 insertions, 710 deletions
diff --git a/docs/repository.html b/docs/repository.html index d09fc1800a..39f5da4bbe 100644 --- a/docs/repository.html +++ b/docs/repository.html @@ -96,8 +96,12 @@ code while a branch has the latest stable code. </p> <p> -Questions about active Mesa development branches should be posted to -the mesa3d-dev mailing list. +The command <code>git-branch</code> will list all available branches. +</p> + +<p> +Questions about branch status/activity should be posted to the +mesa3d-dev mailing list. </p> diff --git a/include/GL/glext.h b/include/GL/glext.h index 4e45387ecc..2519a6cc5e 100644 --- a/include/GL/glext.h +++ b/include/GL/glext.h @@ -6,32 +6,26 @@ extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** Copyright (c) 2007 The Khronos Group Inc. ** -** http://oss.sgi.com/projects/FreeB +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: ** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** THE MATERIALS ARE 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 NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) diff --git a/include/GL/glxext.h b/include/GL/glxext.h index 8aa563f180..d239badd74 100644 --- a/include/GL/glxext.h +++ b/include/GL/glxext.h @@ -6,32 +6,26 @@ extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** Copyright (c) 2007 The Khronos Group Inc. ** -** http://oss.sgi.com/projects/FreeB +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: ** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** THE MATERIALS ARE 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 NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c index 2ee1df69fb..3a1a19ecdb 100644 --- a/progs/demos/winpos.c +++ b/progs/demos/winpos.c @@ -77,7 +77,7 @@ static void init( void ) WindowPosFunc = &glWindowPos2fARB; } else -#elif defined(GL_ARB_window_pos) +#elif defined(GL_MESA_window_pos) if (glutExtensionSupported("GL_MESA_window_pos")) { printf("Using GL_MESA_window_pos\n"); WindowPosFunc = &glWindowPos2fMESA; diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c index ebe73f19f4..7be90d67f5 100644 --- a/progs/tests/sharedtex.c +++ b/progs/tests/sharedtex.c @@ -368,7 +368,7 @@ Resize(const struct window *h, unsigned int width, unsigned int height) glFrustum(-1, 1, -1, 1, 2, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(0, 0, -3.5); + glTranslatef(0, 0, -4.5); } @@ -408,28 +408,30 @@ EventLoop(void) } - +#if 0 static void PrintInfo(const struct window *h) { printf("Name: %s\n", h->DisplayName); - printf(" Display: 0x%x\n", h->Dpy); - printf(" Window: 0x%x\n", h->Win); - printf(" Context: 0x%x\n", h->Context); + printf(" Display: %p\n", (void *) h->Dpy); + printf(" Window: 0x%x\n", (int) h->Win); + printf(" Context: 0x%x\n", (int) h->Context); } +#endif int main(int argc, char *argv[]) { - int i; + const char *dpyName = XDisplayName(NULL); + struct window *h0, *h1, *h2, *h3; /* four windows and contexts sharing display lists and texture objects */ - h0 = AddWindow(":0", 10, 10, NULL); - h1 = AddWindow(":0", 330, 10, h0); - h2 = AddWindow(":0", 10, 350, h0); - h3 = AddWindow(":0", 330, 350, h0); + h0 = AddWindow(dpyName, 10, 10, NULL); + h1 = AddWindow(dpyName, 330, 10, h0); + h2 = AddWindow(dpyName, 10, 350, h0); + h3 = AddWindow(dpyName, 330, 350, h0); InitGLstuff(h0); diff --git a/progs/tools/trace/gltrace_support.cc b/progs/tools/trace/gltrace_support.cc index fb0404c450..b188e73f29 100644 --- a/progs/tools/trace/gltrace_support.cc +++ b/progs/tools/trace/gltrace_support.cc @@ -20,6 +20,7 @@ */ #include "gltrace_support.h" +#include <assert.h> #include <sstream> #include <fstream> #include <iomanip> @@ -34,7 +35,7 @@ namespace { { static char buf[4096]; int status; - unsigned int length = sizeof(buf)-1; + size_t length = sizeof(buf)-1; memset (buf, 0, sizeof(buf)); diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c index 594668affd..518211ccf4 100644 --- a/src/mesa/drivers/allegro/amesa.c +++ b/src/mesa/drivers/allegro/amesa.c @@ -338,7 +338,7 @@ void AMesaDestroyBuffer(AMesaBuffer buffer) {
if (buffer->Screen) destroy_bitmap(buffer->Screen);
if (buffer->Background) destroy_bitmap(buffer->Background);
- _mesa_destroy_framebuffer(buffer->GLBuffer);
+ _mesa_unreference_framebuffer(&buffer->GLBuffer);
free(buffer);
}
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index cc3dcf9d8d..07ac4c7cd5 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -340,7 +340,7 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy, DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); } - if ((pdp != prp) && (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp)) { + if ((pdp != prp) && (!prp->pStamp || *prp->pStamp != prp->lastStamp)) { DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); __driUtilUpdateDrawableInfo(prp); DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); @@ -420,7 +420,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) psp = pdp->driScreenPriv; if (!psp) { /* ERROR!!! */ - _mesa_problem("Warning! Possible infinite loop due to bug " + _mesa_problem(NULL, "Warning! Possible infinite loop due to bug " "in file %s, line %d\n", __FILE__, __LINE__); return; diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c index 08b52b4d8f..a6d7590eff 100644 --- a/src/mesa/drivers/dri/fb/fb_dri.c +++ b/src/mesa/drivers/dri/fb/fb_dri.c @@ -480,11 +480,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)driDrawPriv->driverPrivate; - - _mesa_free(mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data); - _mesa_destroy_framebuffer(mesa_framebuffer); - driDrawPriv->driverPrivate = NULL; + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c index 215aaf8ffb..4c5323d230 100644 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c +++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c @@ -392,7 +392,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv, static void ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/gamma/gamma_xmesa.c b/src/mesa/drivers/dri/gamma/gamma_xmesa.c index e8922b1503..f41682cea7 100644 --- a/src/mesa/drivers/dri/gamma/gamma_xmesa.c +++ b/src/mesa/drivers/dri/gamma/gamma_xmesa.c @@ -97,7 +97,7 @@ gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static void diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c index d0e58f667c..f64c10a9ae 100644 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ b/src/mesa/drivers/dri/i810/i810screen.c @@ -398,7 +398,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv, static void i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 107cf137ff..67e176a1c6 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -449,7 +449,7 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void intelDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c index 333fefef85..c844f5351d 100644 --- a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c @@ -62,15 +62,23 @@ i915_miptree_layout(struct intel_mipmap_tree * mt) case GL_TEXTURE_CUBE_MAP:{ const GLuint dim = mt->width0; GLuint face; + GLuint lvlWidth = mt->width0, lvlHeight = mt->height0; + + assert(lvlWidth == lvlHeight); /* cubemap images are square */ /* double pitch for cube layouts */ mt->pitch = ((dim * mt->cpp * 2 + 3) & ~3) / mt->cpp; mt->total_height = dim * 4; - for (level = mt->first_level; level <= mt->last_level; level++) + for (level = mt->first_level; level <= mt->last_level; level++) { intel_miptree_set_level_info(mt, level, 6, 0, 0, - mt->pitch, mt->total_height, 1); + /*OLD: mt->pitch, mt->total_height,*/ + lvlWidth, lvlHeight, + 1); + lvlWidth /= 2; + lvlHeight /= 2; + } for (face = 0; face < 6; face++) { GLuint x = initial_offsets[face][0] * dim; diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c index 2b1077aee0..93372f4dcc 100644 --- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c @@ -309,8 +309,13 @@ intel_miptree_image_data(struct intel_context *intel, height = dst->level[level].height; if(dst->compressed) height /= 4; - intel_region_data(intel->intelScreen, dst->region, dst_offset + dst_depth_offset[i], 0, 0, src, src_row_pitch, 0, 0, /* source x,y */ - dst->level[level].width, height); + intel_region_data(intel->intelScreen, dst->region, + dst_offset + dst_depth_offset[i], /* dst_offset */ + 0, 0, /* dstx, dsty */ + src, + src_row_pitch, + 0, 0, /* source x, y */ + dst->level[level].width, height); /* width, height */ src += src_image_pitch; } diff --git a/src/mesa/drivers/dri/i915tex/intel_regions.c b/src/mesa/drivers/dri/i915tex/intel_regions.c index 1205b180ca..a114bdf896 100644 --- a/src/mesa/drivers/dri/i915tex/intel_regions.c +++ b/src/mesa/drivers/dri/i915tex/intel_regions.c @@ -217,7 +217,8 @@ _mesa_copy_rect(GLubyte * dst, GLuint dst_y, GLuint width, GLuint height, - GLubyte * src, GLuint src_pitch, GLuint src_x, GLuint src_y) + const GLubyte * src, + GLuint src_pitch, GLuint src_x, GLuint src_y) { GLuint i; @@ -253,7 +254,7 @@ intel_region_data(intelScreenPrivate *intelScreen, struct intel_region *dst, GLuint dst_offset, GLuint dstx, GLuint dsty, - void *src, GLuint src_pitch, + const void *src, GLuint src_pitch, GLuint srcx, GLuint srcy, GLuint width, GLuint height) { struct intel_context *intel = intelScreenContext(intelScreen); diff --git a/src/mesa/drivers/dri/i915tex/intel_regions.h b/src/mesa/drivers/dri/i915tex/intel_regions.h index 1415bace69..d938c107a4 100644 --- a/src/mesa/drivers/dri/i915tex/intel_regions.h +++ b/src/mesa/drivers/dri/i915tex/intel_regions.h @@ -103,7 +103,7 @@ void intel_region_data(intelScreenPrivate *intelScreen, struct intel_region *dest, GLuint dest_offset, GLuint destx, GLuint desty, - void *src, GLuint src_stride, + const void *src, GLuint src_stride, GLuint srcx, GLuint srcy, GLuint width, GLuint height); /* Copy rectangular sub-regions diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c index efa1b014a6..ac83254593 100644 --- a/src/mesa/drivers/dri/i915tex/intel_screen.c +++ b/src/mesa/drivers/dri/i915tex/intel_screen.c @@ -609,7 +609,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, static void intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 092c6bafc2..4eb2eedd42 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -458,6 +458,7 @@ void brw_draw_prims( GLcontext *ctx, * swrast to do the drawing. */ if (!retval) { + _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 08f0bb340f..5dac50df32 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -457,7 +457,7 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void intelDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 1014b8acd5..4e9e216e7d 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -435,7 +435,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv, static void mach64DestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index f024f73eb6..67a6f8bdf0 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -831,7 +831,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static void diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index f811dc1b72..aec7b19771 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -141,9 +141,15 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_PHYSICAL, &nmesa->vram_phys)) return GL_FALSE; + if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_SIZE, + &nmesa->vram_size)) + return GL_FALSE; if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL, &nmesa->agp_phys)) return GL_FALSE; + if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE, + &nmesa->agp_size)) + return GL_FALSE; if (!nouveauFifoInit(nmesa)) return GL_FALSE; nouveauObjectInit(nmesa); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index f61fcbb48c..f79a8675f4 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -100,7 +100,9 @@ typedef struct nouveau_context { /* Physical addresses of AGP/VRAM apertures */ uint64_t vram_phys; + uint64_t vram_size; uint64_t agp_phys; + uint64_t agp_size; /* Channel synchronisation */ nouveau_notifier *syncNotifier; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index 302009c8b1..468b18e6d9 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -4,17 +4,14 @@ #include "nouveau_reg.h" -GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, int handle, int class, uint32_t flags, uint32_t dma_in, uint32_t dma_out, uint32_t dma_notifier) +GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, + uint32_t handle, int class) { drm_nouveau_object_init_t cto; int ret; cto.handle = handle; cto.class = class; - cto.flags = flags; - cto.dma0= dma_in; - cto.dma1= dma_out; - cto.dma_notifier = dma_notifier; ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_OBJECT_INIT, &cto, sizeof(cto)); return ret == 0; @@ -22,6 +19,7 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, int handle, int cl GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, uint32_t handle, + int class, uint32_t offset, uint32_t size, int target, @@ -30,6 +28,7 @@ GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, drm_nouveau_dma_object_init_t dma; int ret; + dma.class = class; dma.handle = handle; dma.target = target; dma.access = access; @@ -40,6 +39,27 @@ GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, return ret == 0; } +GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, + uint32_t handle, int class, + nouveau_mem *mem, + int access) +{ + uint32_t offset = mem->offset; + int target = mem->type & (NOUVEAU_MEM_FB | NOUVEAU_MEM_AGP); + + if (!target) + return GL_FALSE; + + if (target & NOUVEAU_MEM_FB) + offset -= nmesa->vram_phys; + else if (target & NOUVEAU_MEM_AGP) + offset -= nmesa->agp_phys; + + return nouveauCreateDmaObject(nmesa, handle, class, + offset, mem->size, + target, access); +} + void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle) { BEGIN_RING_SIZE(subchannel, 0, 1); @@ -53,31 +73,25 @@ void nouveauObjectInit(nouveauContextPtr nmesa) #endif /* We need to know vram size.. and AGP size (and even if the card is AGP..) */ - nouveauCreateDmaObject( nmesa, NvDmaFB, - 0, (256*1024*1024), - 0 /*NV_DMA_TARGET_FB*/, 0 /*NV_DMA_ACCESS_RW*/); - nouveauCreateDmaObject( nmesa, NvDmaAGP, - nmesa->agp_phys, (128*1024*1024), - 3 /* AGP */, 0 /* RW */); - - nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d, - 0, 0, 0, 0); + nouveauCreateDmaObject( nmesa, NvDmaFB, NV_DMA_IN_MEMORY, + 0, nmesa->vram_size, + NOUVEAU_MEM_FB, + NOUVEAU_MEM_ACCESS_RW); + nouveauCreateDmaObject( nmesa, NvDmaAGP, NV_DMA_IN_MEMORY, + 0, nmesa->agp_size, + NOUVEAU_MEM_AGP, + NOUVEAU_MEM_ACCESS_RW); + + nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d); if (nmesa->screen->card->type>=NV_10) { - nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D, - 0, 0, 0, 0); - nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT, - NV_DMA_CONTEXT_FLAGS_PATCH_SRCCOPY, 0, 0, 0); + nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D); + nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); } else { - nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D, - 0, 0, 0, 0); - nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D, - 0, 0, 0, 0); - nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT, - NV_DMA_CONTEXT_FLAGS_PATCH_SRCCOPY, 0, 0, 0); + nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D); + nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D); + nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT); } - nouveauCreateContextObject(nmesa, NvMemFormat, - NV_MEMORY_TO_MEMORY_FORMAT, - 0, 0, 0, 0); + nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT); #ifdef ALLOW_MULTI_SUBCHANNEL nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.h b/src/mesa/drivers/dri/nouveau/nouveau_object.h index daad281029..0be9b4309c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.h @@ -30,15 +30,18 @@ enum DMASubchannel { extern void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle); extern GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, - int handle, int class, - uint32_t flags, - uint32_t dma_in, - uint32_t dma_out, - uint32_t dma_notifier); + uint32_t handle, int class); extern GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, uint32_t handle, + int class, uint32_t offset, uint32_t size, int target, int access); +extern GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, + uint32_t handle, + int class, + nouveau_mem *mem, + int access); + #endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 881b20149f..e00080fce1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -202,7 +202,7 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv, static void nouveauDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static int @@ -327,8 +327,10 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 0, 0, 3 }; - + static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 4 +#error nouveau_drm.h version doesn't match expected version +#endif dri_interface = interface; if (!driCheckDriDdxDrmVersions2("nouveau", diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index c47ff3a985..428b19b46e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -58,10 +58,9 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) return NULL; } - if (!nouveauCreateDmaObject(nmesa, handle, notifier->mem->offset, - notifier->mem->size, - 0 /* NV_DMA_TARGET_FB */, - 0 /* NV_DMA_ACCESS_RW */)) { + if (!nouveauCreateDmaObjectFromMem(nmesa, handle, NV_DMA_IN_MEMORY, + notifier->mem, + NOUVEAU_MEM_ACCESS_RW)) { nouveau_mem_free(ctx, notifier->mem); FREE(notifier); return NULL; diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 4f1b20aadd..880dee85c2 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -357,7 +357,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv, static void r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index 6a6c30a2b0..3162b508c2 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -420,14 +420,14 @@ void r200EmitArrays( GLcontext *ctx, GLubyte *vimap_rev ) if (!rmesa->tcl.vertex_data[i].buf) { if (ctx->VertexProgram._Enabled) emit_vector( ctx, - &(rmesa->tcl.vertex_data[attrib]), + &(rmesa->tcl.vertex_data[i]), (char *)VB->AttribPtr[attrib]->data, 1, VB->AttribPtr[attrib]->stride, count); else emit_vecfog( ctx, - &(rmesa->tcl.vertex_data[attrib]), + &(rmesa->tcl.vertex_data[i]), (char *)VB->AttribPtr[attrib]->data, VB->AttribPtr[attrib]->stride, count); diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index ace9b66724..2c7b5aa011 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -292,13 +292,13 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 ); r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6); ALLOC_STATE( unk2080, always, 2, "unk2080", 0 ); - r300->hw.unk2080.cmd[0] = cmdpacket0(0x2080, 1); + r300->hw.unk2080.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1); ALLOC_STATE( vte, always, 3, "vte", 0 ); r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2); ALLOC_STATE( unk2134, always, 3, "unk2134", 0 ); r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2); ALLOC_STATE( unk2140, always, 2, "unk2140", 0 ); - r300->hw.unk2140.cmd[0] = cmdpacket0(0x2140, 1); + r300->hw.unk2140.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1); ALLOC_STATE( vir[0], variable, R300_VIR_CMDSIZE, "vir/0", 0 ); r300->hw.vir[0].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1); ALLOC_STATE( vir[1], variable, R300_VIR_CMDSIZE, "vir/1", 1 ); @@ -308,11 +308,11 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( unk21DC, always, 2, "unk21DC", 0 ); r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1); ALLOC_STATE( unk221C, always, 2, "unk221C", 0 ); - r300->hw.unk221C.cmd[0] = cmdpacket0(0x221C, 1); + r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1); ALLOC_STATE( unk2220, always, 5, "unk2220", 0 ); r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4); ALLOC_STATE( unk2288, always, 2, "unk2288", 0 ); - r300->hw.unk2288.cmd[0] = cmdpacket0(0x2288, 1); + r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1); ALLOC_STATE( vof, always, R300_VOF_CMDSIZE, "vof", 0 ); r300->hw.vof.cmd[R300_VOF_CMD_0] = cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2); ALLOC_STATE( pvs, always, R300_PVS_CMDSIZE, "pvs", 0 ); @@ -336,9 +336,9 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( unk4260, always, 4, "unk4260", 0 ); r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3); ALLOC_STATE( unk4274, always, 5, "unk4274", 0 ); - r300->hw.unk4274.cmd[0] = cmdpacket0(0x4274, 4); + r300->hw.unk4274.cmd[0] = cmdpacket0(R300_RE_SHADE, 4); ALLOC_STATE( unk4288, always, 4, "unk4288", 0 ); - r300->hw.unk4288.cmd[0] = cmdpacket0(0x4288, 3); + r300->hw.unk4288.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3); ALLOC_STATE( fogp, always, 3, "fogp", 0 ); r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2); ALLOC_STATE( unk42A0, always, 2, "unk42A0", 0 ); @@ -346,7 +346,7 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 ); r300->hw.zbs.cmd[R300_ZBS_CMD_0] = cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4); ALLOC_STATE( unk42B4, always, 2, "unk42B4", 0 ); - r300->hw.unk42B4.cmd[0] = cmdpacket0(0x42B4, 1); + r300->hw.unk42B4.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1); ALLOC_STATE( cul, always, R300_CUL_CMDSIZE, "cul", 0 ); r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1); ALLOC_STATE( unk42C0, always, 3, "unk42C0", 0 ); @@ -393,7 +393,7 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( cmk, always, R300_CMK_CMDSIZE, "cmk", 0 ); r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1); ALLOC_STATE( unk4E10, always, 4, "unk4E10", 0 ); - r300->hw.unk4E10.cmd[0] = cmdpacket0(0x4E10, 3); + r300->hw.unk4E10.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3); ALLOC_STATE( cb, always, R300_CB_CMDSIZE, "cb", 0 ); r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1); r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1); @@ -406,7 +406,7 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( zs, always, R300_ZS_CMDSIZE, "zstencil", 0 ); r300->hw.zs.cmd[R300_ZS_CMD_0] = cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3); ALLOC_STATE( unk4F10, always, 5, "unk4F10", 0 ); - r300->hw.unk4F10.cmd[0] = cmdpacket0(0x4F10, 4); + r300->hw.unk4F10.cmd[0] = cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4); ALLOC_STATE( zb, always, R300_ZB_CMDSIZE, "zb", 0 ); r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2); ALLOC_STATE( unk4F28, always, 2, "unk4F28", 0 ); diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 48b50bca65..a339b2f9c1 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -60,7 +60,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif //#define OPTIMIZE_ELTS -#define CB_DPATH struct r300_context; typedef struct r300_context r300ContextRec; diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index 8e45bd5403..a1c634a54d 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog.c @@ -1214,8 +1214,8 @@ static void make_sin_const(struct r300_fragment_program *rp) cnstv[3] = 0.2225; // weight rp->const_sin[0] = emit_const4fv(rp, cnstv); - cnstv[0] = 0.5; - cnstv[1] = -1.5; + cnstv[0] = 0.75; + cnstv[1] = 0.0; cnstv[2] = 0.159154943; // 1/(2*PI) cnstv[3] = 6.283185307; // 2*PI rp->const_sin[1] = emit_const4fv(rp, cnstv); @@ -1227,7 +1227,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp) struct gl_fragment_program *mp = &rp->mesa_program; const struct prog_instruction *inst = mp->Base.Instructions; struct prog_instruction *fpi; - GLuint src[3], dest, temp; + GLuint src[3], dest, temp[2]; GLuint cnst; int flags, mask = 0; GLfloat cnstv[4] = {0.0, 0.0, 0.0, 0.0}; @@ -1277,70 +1277,63 @@ static GLboolean parse_program(struct r300_fragment_program *rp) /* * cos using a parabola (see SIN): * cos(x): - * x += PI/2 - * x = (x/(2*PI))+0.5 + * x = (x/(2*PI))+0.75 * x = frac(x) * x = (x*2*PI)-PI * result = sin(x) */ - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); make_sin_const(rp); src[0] = t_scalar_src(rp, fpi->SrcReg[0]); /* add 0.5*PI and do range reduction */ - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI - pfs_half, - swizzle(keep(src[0]), X, X, X, X), - 0); - - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X, + swizzle(src[0], X, X, X, X), swizzle(rp->const_sin[1], Z, Z, Z, Z), - pfs_half, + swizzle(rp->const_sin[1], X, X, X, X), 0); - emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X, - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X, + swizzle(temp[0], X, X, X, X), undef, undef, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z, - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z, + swizzle(temp[0], X, X, X, X), swizzle(rp->const_sin[1], W, W, W, W), //2*PI negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //-PI 0); /* SIN */ - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y, - swizzle(temp, Z, Z, Z, Z), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y, + swizzle(temp[0], Z, Z, Z, Z), rp->const_sin[0], pfs_zero, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - swizzle(temp, Y, Y, Y, Y), - absolute(swizzle(temp, Z, Z, Z, Z)), - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X, + swizzle(temp[0], Y, Y, Y, Y), + absolute(swizzle(temp[0], Z, Z, Z, Z)), + swizzle(temp[0], X, X, X, X), 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y, - swizzle(temp, X, X, X, X), - absolute(swizzle(temp, X, X, X, X)), - negate(swizzle(temp, X, X, X, X)), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y, + swizzle(temp[0], X, X, X, X), + absolute(swizzle(temp[0], X, X, X, X)), + negate(swizzle(temp[0], X, X, X, X)), 0); emit_arith(rp, PFS_OP_MAD, dest, mask, - swizzle(temp, Y, Y, Y, Y), + swizzle(temp[0], Y, Y, Y, Y), swizzle(rp->const_sin[0], W, W, W, W), - swizzle(temp, X, X, X, X), + swizzle(temp[0], X, X, X, X), flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_DP3: src[0] = t_src(rp, fpi->SrcReg[0]); @@ -1363,15 +1356,15 @@ static GLboolean parse_program(struct r300_fragment_program *rp) * DP4 dest, temp, src1 */ #if 0 - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); src[0].s_swz = SWIZZLE_ONE; - emit_arith(rp, PFS_OP_MAD, temp, mask, + emit_arith(rp, PFS_OP_MAD, temp[0], mask, src[0], pfs_one, pfs_zero, 0); emit_arith(rp, PFS_OP_DP4, dest, mask, - temp, src[1], undef, + temp[0], src[1], undef, flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); #else emit_arith(rp, PFS_OP_DP4, dest, mask, swizzle(src[0], X, Y, Z, ONE), src[1], @@ -1408,17 +1401,17 @@ static GLboolean parse_program(struct r300_fragment_program *rp) break; case OPCODE_FLR: src[0] = t_src(rp, fpi->SrcReg[0]); - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); /* FRC temp, src0 * MAD dest, src0, 1.0, -temp */ - emit_arith(rp, PFS_OP_FRC, temp, mask, + emit_arith(rp, PFS_OP_FRC, temp[0], mask, keep(src[0]), undef, undef, 0); emit_arith(rp, PFS_OP_MAD, dest, mask, - src[0], pfs_one, negate(temp), + src[0], pfs_one, negate(temp[0]), flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_FRC: src[0] = t_src(rp, fpi->SrcReg[0]); @@ -1450,44 +1443,44 @@ static GLboolean parse_program(struct r300_fragment_program *rp) */ cnstv[0] = cnstv[1] = cnstv[2] = cnstv[3] = 0.50001; src[0] = t_src(rp, fpi->SrcReg[0]); - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); cnst = emit_const4fv(rp, cnstv); - emit_arith(rp, PFS_OP_CMP, temp, + emit_arith(rp, PFS_OP_CMP, temp[0], WRITEMASK_X | WRITEMASK_Y, src[0], pfs_zero, src[0], flags); - emit_arith(rp, PFS_OP_MIN, temp, WRITEMASK_Z, + emit_arith(rp, PFS_OP_MIN, temp[0], WRITEMASK_Z, swizzle(keep(src[0]), W, W, W, W), cnst, undef, flags); - emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W, - swizzle(temp, Y, Y, Y, Y), + emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W, + swizzle(temp[0], Y, Y, Y, Y), undef, undef, flags); - emit_arith(rp, PFS_OP_MAX, temp, WRITEMASK_Z, - temp, negate(cnst), undef, flags); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W, - temp, swizzle(temp, Z, Z, Z, Z), + emit_arith(rp, PFS_OP_MAX, temp[0], WRITEMASK_Z, + temp[0], negate(cnst), undef, flags); + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W, + temp[0], swizzle(temp[0], Z, Z, Z, Z), pfs_zero, flags); - emit_arith(rp, PFS_OP_EX2, temp, WRITEMASK_W, - temp, undef, undef, flags); + emit_arith(rp, PFS_OP_EX2, temp[0], WRITEMASK_W, + temp[0], undef, undef, flags); emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y, - swizzle(keep(temp), X, X, X, X), + swizzle(keep(temp[0]), X, X, X, X), pfs_one, pfs_zero, flags); #if 0 - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - temp, pfs_one, pfs_half, flags); - emit_arith(rp, PFS_OP_CMPH, temp, WRITEMASK_Z, - swizzle(keep(temp), W, W, W, W), - pfs_zero, swizzle(keep(temp), X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X, + temp[0], pfs_one, pfs_half, flags); + emit_arith(rp, PFS_OP_CMPH, temp[0], WRITEMASK_Z, + swizzle(keep(temp[0]), W, W, W, W), + pfs_zero, swizzle(keep(temp[0]), X, X, X, X), flags); #else - emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z, + emit_arith(rp, PFS_OP_CMP, temp[0], WRITEMASK_Z, pfs_zero, - swizzle(keep(temp), W, W, W, W), - negate(swizzle(keep(temp), X, X, X, X)), + swizzle(keep(temp[0]), W, W, W, W), + negate(swizzle(keep(temp[0]), X, X, X, X)), flags); #endif emit_arith(rp, PFS_OP_CMP, dest, WRITEMASK_Z, - pfs_zero, temp, - negate(swizzle(keep(temp), Y, Y, Y, Y)), + pfs_zero, temp[0], + negate(swizzle(keep(temp[0]), Y, Y, Y, Y)), flags); emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_X | WRITEMASK_W, @@ -1495,7 +1488,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp) pfs_one, pfs_zero, flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_LRP: src[0] = t_src(rp, fpi->SrcReg[0]); @@ -1506,14 +1499,14 @@ static GLboolean parse_program(struct r300_fragment_program *rp) * MAD temp, -tmp0, tmp2, tmp2 * MAD result, tmp0, tmp1, temp */ - temp = get_temp_reg(rp); - emit_arith(rp, PFS_OP_MAD, temp, mask, + temp[0] = get_temp_reg(rp); + emit_arith(rp, PFS_OP_MAD, temp[0], mask, negate(keep(src[0])), keep(src[2]), src[2], 0); emit_arith(rp, PFS_OP_MAD, dest, mask, - src[0], src[1], temp, + src[0], src[1], temp[0], flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_MAD: src[0] = t_src(rp, fpi->SrcReg[0]); @@ -1554,17 +1547,17 @@ static GLboolean parse_program(struct r300_fragment_program *rp) case OPCODE_POW: src[0] = t_scalar_src(rp, fpi->SrcReg[0]); src[1] = t_scalar_src(rp, fpi->SrcReg[1]); - temp = get_temp_reg(rp); - emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W, + temp[0] = get_temp_reg(rp); + emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W, src[0], undef, undef, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W, - temp, src[1], pfs_zero, + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W, + temp[0], src[1], pfs_zero, 0); emit_arith(rp, PFS_OP_EX2, dest, fpi->DstReg.WriteMask, - temp, undef, undef, + temp[0], undef, undef, 0); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_RCP: src[0] = t_scalar_src(rp, fpi->SrcReg[0]); @@ -1580,107 +1573,91 @@ static GLboolean parse_program(struct r300_fragment_program *rp) break; case OPCODE_SCS: /* - * cos using a parabola (see SIN): - * cos(x): - * x += PI/2 - * x = (x/(2*PI))+0.5 - * x = frac(x) - * x = (x*2*PI)-PI - * result = sin(x) + * scs using a parabola : + * scs(x): + * result.x = sin(-abs(x)+0.5*PI) (cos) + * result.y = sin(x) (sin) + * */ - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); + temp[1] = get_temp_reg(rp); make_sin_const(rp); src[0] = t_scalar_src(rp, fpi->SrcReg[0]); - /* add 0.5*PI and do range reduction */ + /* x = -abs(x)+0.5*PI */ + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z, + swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI + pfs_half, + negate(abs(swizzle(keep(src[0]), X, X, X, X))), + 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X|WRITEMASK_Y, - swizzle(rp->const_sin[0], Z, Z, Z, Z), - rp->const_sin[1], + /* C*x (sin) */ + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W, + swizzle(rp->const_sin[0], Y, Y, Y, Y), swizzle(keep(src[0]), X, X, X, X), + pfs_zero, 0); - emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_W, - swizzle(rp->const_sin[0], Z, Z, Z, Z), - negate(pfs_half), - swizzle(keep(src[0]), X, X, X, X), + /* B*x, C*x (cos) */ + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y, + swizzle(temp[0], Z, Z, Z, Z), + rp->const_sin[0], + pfs_zero, 0); - emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z, - swizzle(temp, X, X, X, X), - swizzle(temp, Y, Y, Y, Y), - swizzle(temp, W, W, W, W), + /* B*x (sin) */ + emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W, + swizzle(rp->const_sin[0], X, X, X, X), + keep(src[0]), + pfs_zero, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y, - swizzle(temp, Z, Z, Z, Z), - rp->const_sin[0], - pfs_zero, + /* y = B*x + C*x*abs(x) (sin)*/ + emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_Z, + absolute(src[0]), + swizzle(temp[0], W, W, W, W), + swizzle(temp[1], W, W, W, W), 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W, - swizzle(temp, Y, Y, Y, Y), - absolute(swizzle(temp, Z, Z, Z, Z)), - swizzle(temp, X, X, X, X), + /* y = B*x + C*x*abs(x) (cos)*/ + emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W, + swizzle(temp[0], Y, Y, Y, Y), + absolute(swizzle(temp[0], Z, Z, Z, Z)), + swizzle(temp[0], X, X, X, X), 0); - if(mask & WRITEMASK_Y) - { - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y, - swizzle(keep(src[0]), X, X, X, X), - rp->const_sin[0], - pfs_zero, - 0); - - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - swizzle(temp, Y, Y, Y, Y), - absolute(swizzle(keep(src[0]), X, X, X, X)), - swizzle(temp, X, X, X, X), - 0); - } + /* y*abs(y) - y (cos), y*abs(y) - y (sin) */ + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y, + swizzle(temp[1], W, Z, Y, X), + absolute(swizzle(temp[1], W, Z, Y, X)), + negate(swizzle(temp[1], W, Z, Y, X)), - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z, - swizzle(temp, W, W, W, W), - absolute(swizzle(temp, W, W, W, W)), - negate(swizzle(temp, W, W, W, W)), 0); - emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_X, - swizzle(temp, Z, Z, Z, Z), + /* dest.xy = mad(temp.xy, P, temp2.wz) */ + emit_arith(rp, PFS_OP_MAD, dest, mask & (WRITEMASK_X | WRITEMASK_Y), + temp[0], swizzle(rp->const_sin[0], W, W, W, W), - swizzle(temp, W, W, W, W), + swizzle(temp[1], W, Z, Y, X), flags); - if(mask & WRITEMASK_Y) - { - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W, - swizzle(temp, X, X, X, X), - absolute(swizzle(temp, X, X, X, X)), - negate(swizzle(temp, X, X, X, X)), - 0); - - emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y, - swizzle(temp, W, W, W, W), - swizzle(rp->const_sin[0], W, W, W, W), - swizzle(temp, X, X, X, X), - flags); - } - free_temp(rp, temp); + free_temp(rp, temp[0]); + free_temp(rp, temp[1]); break; case OPCODE_SGE: src[0] = t_src(rp, fpi->SrcReg[0]); src[1] = t_src(rp, fpi->SrcReg[1]); - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); /* temp = src0 - src1 * dest.c = (temp.c < 0.0) ? 0 : 1 */ - emit_arith(rp, PFS_OP_MAD, temp, mask, + emit_arith(rp, PFS_OP_MAD, temp[0], mask, src[0], pfs_one, negate(src[1]), 0); emit_arith(rp, PFS_OP_CMP, dest, mask, - pfs_one, pfs_zero, temp, + pfs_one, pfs_zero, temp[0], 0); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_SIN: /* @@ -1690,73 +1667,74 @@ static GLboolean parse_program(struct r300_fragment_program *rp) * itself squared. */ - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); make_sin_const(rp); src[0] = t_scalar_src(rp, fpi->SrcReg[0]); + /* do range reduction */ - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X, swizzle(keep(src[0]), X, X, X, X), swizzle(rp->const_sin[1], Z, Z, Z, Z), pfs_half, 0); - emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X, - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X, + swizzle(temp[0], X, X, X, X), undef, undef, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z, - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z, + swizzle(temp[0], X, X, X, X), swizzle(rp->const_sin[1], W, W, W, W), //2*PI negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //PI 0); /* SIN */ - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y, - swizzle(temp, Z, Z, Z, Z), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y, + swizzle(temp[0], Z, Z, Z, Z), rp->const_sin[0], pfs_zero, 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X, - swizzle(temp, Y, Y, Y, Y), - absolute(swizzle(temp, Z, Z, Z, Z)), - swizzle(temp, X, X, X, X), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X, + swizzle(temp[0], Y, Y, Y, Y), + absolute(swizzle(temp[0], Z, Z, Z, Z)), + swizzle(temp[0], X, X, X, X), 0); - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y, - swizzle(temp, X, X, X, X), - absolute(swizzle(temp, X, X, X, X)), - negate(swizzle(temp, X, X, X, X)), + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y, + swizzle(temp[0], X, X, X, X), + absolute(swizzle(temp[0], X, X, X, X)), + negate(swizzle(temp[0], X, X, X, X)), 0); emit_arith(rp, PFS_OP_MAD, dest, mask, - swizzle(temp, Y, Y, Y, Y), + swizzle(temp[0], Y, Y, Y, Y), swizzle(rp->const_sin[0], W, W, W, W), - swizzle(temp, X, X, X, X), + swizzle(temp[0], X, X, X, X), flags); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_SLT: src[0] = t_src(rp, fpi->SrcReg[0]); src[1] = t_src(rp, fpi->SrcReg[1]); - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); /* temp = src0 - src1 * dest.c = (temp.c < 0.0) ? 1 : 0 */ - emit_arith(rp, PFS_OP_MAD, temp, mask, + emit_arith(rp, PFS_OP_MAD, temp[0], mask, src[0], pfs_one, negate(src[1]), 0); emit_arith(rp, PFS_OP_CMP, dest, mask, - pfs_zero, pfs_one, temp, + pfs_zero, pfs_one, temp[0], 0); - free_temp(rp, temp); + free_temp(rp, temp[0]); break; case OPCODE_SUB: src[0] = t_src(rp, fpi->SrcReg[0]); @@ -1777,9 +1755,9 @@ static GLboolean parse_program(struct r300_fragment_program *rp) case OPCODE_XPD: { src[0] = t_src(rp, fpi->SrcReg[0]); src[1] = t_src(rp, fpi->SrcReg[1]); - temp = get_temp_reg(rp); + temp[0] = get_temp_reg(rp); /* temp = src0.zxy * src1.yzx */ - emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_XYZ, + emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_XYZ, swizzle(keep(src[0]), Z, X, Y, W), swizzle(keep(src[1]), Y, Z, X, W), pfs_zero, @@ -1790,10 +1768,10 @@ static GLboolean parse_program(struct r300_fragment_program *rp) emit_arith(rp, PFS_OP_MAD, dest, mask & WRITEMASK_XYZ, swizzle(src[0], Y, Z, X, W), swizzle(src[1], Z, X, Y, W), - negate(temp), + negate(temp[0]), flags); /* cleanup */ - free_temp(rp, temp); + free_temp(rp, temp[0]); break; } default: diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 0774a2af6b..6fa34ee482 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -70,10 +70,6 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) drm_radeon_cmd_header_t *cmd = NULL; r300ContextPtr rmesa=r300; -#ifndef CB_DPATH - int i; -#endif - if (RADEON_DEBUG & DEBUG_IOCTL) fprintf(stderr, "%s: %s buffer (%i,%i %ix%i)\n", __FUNCTION__, buffer ? "back" : "front", @@ -89,168 +85,8 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) cboffset += r300->radeon.radeonScreen->fbLocation; -#ifndef CB_DPATH - R300_STATECHANGE(r300, vir[0]); - ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = 1; - r300->hw.vir[0].cmd[1] = 0x21030003; - - R300_STATECHANGE(r300, vir[1]); - ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count = 1; - r300->hw.vir[1].cmd[1] = 0xF688F688; - - R300_STATECHANGE(r300, vic); - r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x00000001; - r300->hw.vic.cmd[R300_VIC_CNTL_1] = 0x00000405; - - R300_STATECHANGE(r300, vof); - r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT - | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; - r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */ - - R300_STATECHANGE(r300, txe); - r300->hw.txe.cmd[R300_TXE_ENABLE] = 0; - - R300_STATECHANGE(r300, vpt); - r300->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(1.0); - r300->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(dPriv->x); - r300->hw.vpt.cmd[R300_VPT_YSCALE] = r300PackFloat32(1.0); - r300->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(dPriv->y); - r300->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(1.0); - r300->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(0.0); - - R300_STATECHANGE(r300, at); - r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0; - - R300_STATECHANGE(r300, bld); - r300->hw.bld.cmd[R300_BLD_CBLEND] = 0; - r300->hw.bld.cmd[R300_BLD_ABLEND] = 0; - - if (r300->radeon.radeonScreen->cpp == 4) - cbpitch |= R300_COLOR_FORMAT_ARGB8888; - else - cbpitch |= R300_COLOR_FORMAT_RGB565; - - if (r300->radeon.sarea->tiling_enabled) - cbpitch |= R300_COLOR_TILE_ENABLE; - - R300_STATECHANGE(r300, cb); - r300->hw.cb.cmd[R300_CB_OFFSET] = cboffset; - r300->hw.cb.cmd[R300_CB_PITCH] = cbpitch; - - R300_STATECHANGE(r300, unk221C); - r300->hw.unk221C.cmd[1] = R300_221C_CLEAR; - - R300_STATECHANGE(r300, ps); - r300->hw.ps.cmd[R300_PS_POINTSIZE] = - ((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) | - ((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT); - - R300_STATECHANGE(r300, ri); - for(i = 1; i <= 8; ++i) - r300->hw.ri.cmd[i] = R300_RS_INTERP_USED; - - R300_STATECHANGE(r300, rc); - /* The second constant is needed to get glxgears display anything .. */ - r300->hw.rc.cmd[1] = (1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18; - r300->hw.rc.cmd[2] = 0; - - R300_STATECHANGE(r300, rr); - ((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->packet0.count = 1; - r300->hw.rr.cmd[1] = 0x00004000; - - R300_STATECHANGE(r300, cmk); - if (flags & CLEARBUFFER_COLOR) { - r300->hw.cmk.cmd[R300_CMK_COLORMASK] = - (ctx->Color.ColorMask[BCOMP] ? R300_COLORMASK0_B : 0) | - (ctx->Color.ColorMask[GCOMP] ? R300_COLORMASK0_G : 0) | - (ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) | - (ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0); - } else { - r300->hw.cmk.cmd[R300_CMK_COLORMASK] = 0; - } - - R300_STATECHANGE(r300, fp); - r300->hw.fp.cmd[R300_FP_CNTL0] = 0; /* 1 pass, no textures */ - r300->hw.fp.cmd[R300_FP_CNTL1] = 0; /* no temporaries */ - r300->hw.fp.cmd[R300_FP_CNTL2] = 0; /* no offset, one ALU instr */ - r300->hw.fp.cmd[R300_FP_NODE0] = 0; - r300->hw.fp.cmd[R300_FP_NODE1] = 0; - r300->hw.fp.cmd[R300_FP_NODE2] = 0; - r300->hw.fp.cmd[R300_FP_NODE3] = R300_PFS_NODE_OUTPUT_COLOR; - - R300_STATECHANGE(r300, fpi[0]); - R300_STATECHANGE(r300, fpi[1]); - R300_STATECHANGE(r300, fpi[2]); - R300_STATECHANGE(r300, fpi[3]); - ((drm_r300_cmd_header_t*)r300->hw.fpi[0].cmd)->packet0.count = 1; - ((drm_r300_cmd_header_t*)r300->hw.fpi[1].cmd)->packet0.count = 1; - ((drm_r300_cmd_header_t*)r300->hw.fpi[2].cmd)->packet0.count = 1; - ((drm_r300_cmd_header_t*)r300->hw.fpi[3].cmd)->packet0.count = 1; - - /* MOV o0, t0 */ - r300->hw.fpi[0].cmd[1] = FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)); - r300->hw.fpi[1].cmd[1] = FP_SELC(0,NO,XYZ,FP_TMP(0),0,0); - r300->hw.fpi[2].cmd[1] = FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)); - r300->hw.fpi[3].cmd[1] = FP_SELA(0,NO,W,FP_TMP(0),0,0); - - R300_STATECHANGE(r300, pvs); - r300->hw.pvs.cmd[R300_PVS_CNTL_1] = - (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (0 << R300_PVS_CNTL_1_POS_END_SHIFT) | - (1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); - r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0; /* no parameters */ - r300->hw.pvs.cmd[R300_PVS_CNTL_3] = - (1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT); - - R300_STATECHANGE(r300, vpi); - ((drm_r300_cmd_header_t*)r300->hw.vpi.cmd)->packet0.count = 8; - - /* MOV o0, i0; */ - r300->hw.vpi.cmd[1] = VP_OUT(ADD,OUT,0,XYZW); - r300->hw.vpi.cmd[2] = VP_IN(IN,0); - r300->hw.vpi.cmd[3] = VP_ZERO(); - r300->hw.vpi.cmd[4] = 0; - - /* MOV o1, i1; */ - r300->hw.vpi.cmd[5] = VP_OUT(ADD,OUT,1,XYZW); - r300->hw.vpi.cmd[6] = VP_IN(IN,1); - r300->hw.vpi.cmd[7] = VP_ZERO(); - r300->hw.vpi.cmd[8] = 0; - - R300_STATECHANGE(r300, zs); - r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0; - r300->hw.zs.cmd[R300_ZS_CNTL_1] = 0; - if (flags & CLEARBUFFER_DEPTH) { - r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_WRITE_ONLY; - r300->hw.zs.cmd[R300_ZS_CNTL_1] |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT); - } else { - r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1; // disable - } - - R300_STATECHANGE(r300, zs); - if (flags & CLEARBUFFER_STENCIL) { - r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_STENCIL_ENABLE; - r300->hw.zs.cmd[R300_ZS_CNTL_1] |= - (R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) | - (R300_ZS_ALWAYS<<R300_RB3D_ZS1_BACK_FUNC_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) | - (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT) ; - r300->hw.zs.cmd[R300_ZS_CNTL_2] = r300->state.stencil.clear; - } - - /* Make sure we have enough space */ - r300EnsureCmdBufSpace(r300, r300->hw.max_state_size + 9+8, __FUNCTION__); - - r300EmitState(r300); -#else -#if 1 cp_wait(r300, R300_WAIT_3D | R300_WAIT_3D_CLEAN); end_3d(rmesa); -#endif R300_STATECHANGE(r300, cb); reg_start(R300_RB3D_COLOROFFSET0, 0); @@ -313,8 +149,6 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) e32(r300->state.stencil.clear); } -#endif - cmd2 = (drm_r300_cmd_header_t*)r300AllocCmdBuf(r300, 9, __FUNCTION__); cmd2[0].packet3.cmd_type = R300_CMD_PACKET3; cmd2[0].packet3.packet = R300_CMD_PACKET3_CLEAR; @@ -327,7 +161,6 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]); cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]); -#if 1 reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); e32(0x0000000a); @@ -335,10 +168,8 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) reg_start(0x4f18,0); e32(0x00000003); cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN); -#endif } -#ifdef CB_DPATH static void r300EmitClearState(GLcontext * ctx) { r300ContextPtr r300 = R300_CONTEXT(ctx); @@ -397,7 +228,7 @@ static void r300EmitClearState(GLcontext * ctx) e32(0); R300_STATECHANGE(r300, unk221C); - reg_start(0x221C, 0); + reg_start(R300_VAP_UNKNOWN_221C, 0); e32(R300_221C_CLEAR); R300_STATECHANGE(r300, ps); @@ -472,7 +303,6 @@ static void r300EmitClearState(GLcontext * ctx) /*reg_start(0x4500,0); e32(2560-1);*/ } -#endif /** * Buffer clear @@ -524,12 +354,10 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask) swapped = r300->radeon.doPageFlip && (r300->radeon.sarea->pfCurrentPage == 1); -#ifdef CB_DPATH /* Make sure it fits there. */ r300EnsureCmdBufSpace(r300, 421*3, __FUNCTION__); if(flags || bits) r300EmitClearState(ctx); -#endif if (flags & BUFFER_BIT_FRONT_LEFT) { r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, swapped); @@ -544,15 +372,6 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask) if (bits) r300ClearBuffer(r300, bits, 0); -#ifndef CB_DPATH - /* Recalculate the hardware state. This could be done more efficiently, - * but do keep it like this for now. - */ - r300ResetHwState(r300); - - /* r300ClearBuffer has trampled all over the hardware state.. */ - r300->hw.all_dirty=GL_TRUE; -#endif } diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index 9f636ec1d2..69bc994cf6 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -63,6 +63,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define R300_SE_VPORT_ZOFFSET 0x1DAC +/* + * Vertex Array Processing (VAP) Control + * Stolen from r200 code from Christoph Brill (It's a guess!) + */ +#define R300_VAP_CNTL 0x2080 + /* This register is written directly and also starts data section * in many 3d CP_PACKET3's */ @@ -135,7 +141,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* gap */ -#define R300_VAP_CNTL 0x2140 +#define R300_VAP_CNTL_STATUS 0x2140 # define R300_VC_NO_SWAP (0 << 0) # define R300_VC_16BIT_SWAP (1 << 0) # define R300_VC_32BIT_SWAP (2 << 0) @@ -538,6 +544,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* Some sort of scale or clamp value for texcoordless textures. */ #define R300_RE_UNK4238 0x4238 +/* Something shade related */ +#define R300_RE_SHADE 0x4274 + #define R300_RE_SHADE_MODEL 0x4278 # define R300_RE_SHADE_MODEL_SMOOTH 0x3aaaa # define R300_RE_SHADE_MODEL_FLAT 0x39595 @@ -1273,6 +1282,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_BLEND_MASK (63) # define R300_SRC_BLEND_SHIFT (16) # define R300_DST_BLEND_SHIFT (24) +#define R300_RB3D_BLEND_COLOR 0x4E10 #define R300_RB3D_COLORMASK 0x4E0C # define R300_COLORMASK0_B (1<<0) # define R300_COLORMASK0_G (1<<1) @@ -1378,6 +1388,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* 16 bit format or some aditional bit ? */ # define R300_DEPTH_FORMAT_UNK32 (32 << 0) +#define R300_RB3D_EARLY_Z 0x4F14 +# define R300_EARLY_Z_DISABLE (0 << 0) +# define R300_EARLY_Z_ENABLE (1 << 0) + /* gap */ #define R300_RB3D_DEPTHOFFSET 0x4F20 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 906dfceb48..0e33e51ef3 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -328,24 +328,24 @@ static void r300UpdateCulling(GLcontext* ctx) static void update_early_z(GLcontext *ctx) { - /* updates register 0x4f14 - if depth test is not enabled it should be 0x00000000 - if depth is enabled and alpha not it should be 0x00000001 - if depth and alpha is enabled it should be 0x00000000 + /* updates register R300_RB3D_EARLY_Z (0x4F14) + if depth test is not enabled it should be R300_EARLY_Z_DISABLE + if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE + if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE */ r300ContextPtr r300 = R300_CONTEXT(ctx); R300_STATECHANGE(r300, unk4F10); if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS) /* disable early Z */ - r300->hw.unk4F10.cmd[2] = 0x00000000; + r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE; else { if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER) /* enable early Z */ - r300->hw.unk4F10.cmd[2] = 0x00000001; + r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_ENABLE; else /* disable early Z */ - r300->hw.unk4F10.cmd[2] = 0x00000000; + r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE; } } @@ -1768,9 +1768,7 @@ void r300UpdateShaderStates(r300ContextPtr rmesa) GLcontext *ctx; ctx = rmesa->radeon.glCtx; -#ifdef CB_DPATH r300UpdateTextureState(ctx); -#endif r300SetupPixelShader(rmesa); r300_setup_textures(ctx); @@ -1895,10 +1893,6 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state) r300UpdateStateParameters(ctx, new_state); -#ifndef CB_DPATH - /* Go inefficiency! */ - r300ResetHwState(r300); -#endif #ifdef HW_VBOS if(new_state & _NEW_ARRAY) r300->state.VB.lock_uptodate = GL_FALSE; diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c index 3a6bde8fc3..d66f1dc49e 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.c +++ b/src/mesa/drivers/dri/r300/radeon_context.c @@ -51,6 +51,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_macros.h" #include "radeon_reg.h" +#include "radeon_state.h" #include "r300_state.h" #include "utils.h" @@ -279,6 +280,8 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv, r300UpdateWindow(radeon->glCtx); r300UpdateViewportOffset(radeon->glCtx); + + radeonSetCliprects(radeon); } _mesa_make_current(radeon->glCtx, diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c index a00da6c8bc..1a2dfca7b0 100644 --- a/src/mesa/drivers/dri/r300/radeon_lock.c +++ b/src/mesa/drivers/dri/r300/radeon_lock.c @@ -90,7 +90,6 @@ static void r300RegainedLock(radeonContextPtr radeon) #else radeonUpdateScissor(radeon->glCtx); #endif - radeon->lastStamp = drawable->lastStamp; } if (sarea->ctx_owner != radeon->dri.hwContext) { diff --git a/src/mesa/drivers/dri/r300/radeon_mm.c b/src/mesa/drivers/dri/r300/radeon_mm.c index f86a1b4e72..32ed1f4393 100644 --- a/src/mesa/drivers/dri/r300/radeon_mm.c +++ b/src/mesa/drivers/dri/r300/radeon_mm.c @@ -283,7 +283,7 @@ static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long s size -= cp_size; } - reg_start(0x4e4c,0); + reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); e32(0x0000000a); reg_start(0x342c,0); diff --git a/src/mesa/drivers/dri/r300/radeon_state.c b/src/mesa/drivers/dri/r300/radeon_state.c index ddadf83a00..902e9583a6 100644 --- a/src/mesa/drivers/dri/r300/radeon_state.c +++ b/src/mesa/drivers/dri/r300/radeon_state.c @@ -185,6 +185,8 @@ void radeonSetCliprects(radeonContextPtr radeon) if (radeon->state.scissor.enabled) radeonRecalcScissorRects(radeon); + + radeon->lastStamp = drawable->lastStamp; } diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index fc5aa11462..abb14faaa1 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -901,7 +901,7 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) diff --git a/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/src/mesa/drivers/dri/s3v/s3v_xmesa.c index c451f7452b..c66fd6dac3 100644 --- a/src/mesa/drivers/dri/s3v/s3v_xmesa.c +++ b/src/mesa/drivers/dri/s3v/s3v_xmesa.c @@ -131,7 +131,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void s3vDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static void diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index ad79b9235c..f859217069 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -710,7 +710,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void savageDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } #if 0 diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c index 8f52cfe098..89d734ba78 100644 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ b/src/mesa/drivers/dri/sis/sis_screen.c @@ -233,7 +233,7 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void sisDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static void sisCopyBuffer( __DRIdrawablePrivate *dPriv ) diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index 646f5126eb..1f9ff4e30c 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -233,7 +233,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c index dbbd1ac0c6..8dc7f0dc78 100644 --- a/src/mesa/drivers/dri/trident/trident_context.c +++ b/src/mesa/drivers/dri/trident/trident_context.c @@ -279,7 +279,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv, static void tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } static void diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 28e1f9451e..90f76be44d 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -320,7 +320,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv, static void viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) { - _mesa_destroy_framebuffer((GLframebuffer *)(driDrawPriv->driverPrivate)); + _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate))); } diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c index e535e739b3..00b9d29fac 100644 --- a/src/mesa/drivers/glide/fxapi.c +++ b/src/mesa/drivers/glide/fxapi.c @@ -728,7 +728,7 @@ errorhandler: FREE(fxMesa->fogTable); } if (fxMesa->glBuffer) { - _mesa_destroy_framebuffer(fxMesa->glBuffer); + _mesa_unreference_framebuffer(&fxMesa->glBuffer); } if (fxMesa->glVis) { _mesa_destroy_visual(fxMesa->glVis); @@ -828,7 +828,7 @@ fxMesaDestroyContext(fxMesaContext fxMesa) fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */ _mesa_destroy_visual(fxMesa->glVis); _mesa_destroy_context(fxMesa->glCtx); - _mesa_destroy_framebuffer(fxMesa->glBuffer); + _mesa_unreference_framebuffer(&fxMesa->glBuffer); fxTMClose(fxMesa); /* must be after _mesa_destroy_context */ FREE(fxMesa); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index c4fc8821e5..96b9b5c174 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1303,7 +1303,8 @@ OSMesaDestroyContext( OSMesaContext osmesa ) _swrast_DestroyContext( &osmesa->mesa ); _mesa_destroy_visual( osmesa->gl_visual ); - _mesa_destroy_framebuffer( osmesa->gl_buffer ); + _mesa_unreference_framebuffer( &osmesa->gl_buffer ); + _mesa_free_context_data( &osmesa->mesa ); _mesa_free( osmesa ); } diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c index 0dd9a144fe..d138587569 100644 --- a/src/mesa/drivers/svga/svgamesa.c +++ b/src/mesa/drivers/svga/svgamesa.c @@ -433,7 +433,6 @@ void SVGAMesaDestroyContext( SVGAMesaContext ctx ) if (ctx) { _mesa_destroy_visual( ctx->gl_vis ); _mesa_destroy_context( ctx->gl_ctx ); - _mesa_destroy_framebuffer( ctx->gl_buffer ); free( ctx ); if (ctx==SVGAMesa) { SVGAMesa = NULL; diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index b0ef422de2..a42de72827 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -345,7 +345,7 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b, /***** Linked list of XMesaBuffers *****/ /**********************************************************************/ -static XMesaBuffer XMesaBufferList = NULL; +XMesaBuffer XMesaBufferList = NULL; /** @@ -378,6 +378,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->cmap = cmap; _mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual); + b->mesa_buffer.Delete = xmesa_delete_framebuffer; /* * Front renderbuffer @@ -451,8 +452,8 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, * Find an XMesaBuffer by matching X display and colormap but NOT matching * the notThis buffer. */ -static XMesaBuffer -find_xmesa_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis) +XMesaBuffer +xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis) { XMesaBuffer b; for (b=XMesaBufferList; b; b=b->Next) { @@ -465,38 +466,27 @@ find_xmesa_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis) /** - * Free an XMesaBuffer, remove from linked list, perhaps free X colormap - * entries. + * Remove buffer from linked list, delete if no longer referenced. */ static void -free_xmesa_buffer(int client, XMesaBuffer buffer) +xmesa_free_buffer(XMesaBuffer buffer) { XMesaBuffer prev = NULL, b; - (void) client; - for (b=XMesaBufferList; b; b=b->Next) { - if (b==buffer) { - /* unlink bufer from list */ + + for (b = XMesaBufferList; b; b = b->Next) { + if (b == buffer) { + struct gl_framebuffer *fb = &buffer->mesa_buffer; + + /* unlink buffer from list */ if (prev) prev->Next = buffer->Next; else XMesaBufferList = buffer->Next; - /* Check to free X colors */ - if (buffer->num_alloced>0) { - /* If no other buffer uses this X colormap then free the colors. */ - if (!find_xmesa_buffer(buffer->display, buffer->cmap, buffer)) { -#ifdef XFree86Server - (void)FreeColors(buffer->cmap, client, - buffer->num_alloced, buffer->alloced_colors, - 0); -#else - XFreeColors(buffer->display, buffer->cmap, - buffer->alloced_colors, buffer->num_alloced, 0); -#endif - } - } - _mesa_free_framebuffer_data(&buffer->mesa_buffer); - _mesa_free(buffer); + /* mark as delete pending */ + fb->DeletePending = GL_TRUE; + /* Unreference. If count = zero we'll really delete the buffer */ + _mesa_unreference_framebuffer(&fb); return; } @@ -504,7 +494,7 @@ free_xmesa_buffer(int client, XMesaBuffer buffer) prev = b; } /* buffer not found in XMesaBufferList */ - _mesa_problem(NULL,"free_xmesa_buffer() - buffer not found\n"); + _mesa_problem(NULL,"xmesa_free_buffer() - buffer not found\n"); } @@ -686,7 +676,7 @@ setup_grayscale(int client, XMesaVisual v, return GL_FALSE; } - prevBuffer = find_xmesa_buffer(v->display, cmap, buffer); + prevBuffer = xmesa_find_buffer(v->display, cmap, buffer); if (prevBuffer && (buffer->xm_visual->mesa_visual.rgbMode == prevBuffer->xm_visual->mesa_visual.rgbMode)) { @@ -775,7 +765,7 @@ setup_dithered_color(int client, XMesaVisual v, return GL_FALSE; } - prevBuffer = find_xmesa_buffer(v->display, cmap, buffer); + prevBuffer = xmesa_find_buffer(v->display, cmap, buffer); if (prevBuffer && (buffer->xm_visual->mesa_visual.rgbMode == prevBuffer->xm_visual->mesa_visual.rgbMode)) { @@ -1666,7 +1656,7 @@ XMesaCreateWindowBuffer2(XMesaVisual v, XMesaWindow w, XMesaContext c) if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode, (XMesaDrawable) w, cmap )) { - free_xmesa_buffer(client, b); + xmesa_free_buffer(b); return NULL; } @@ -1787,7 +1777,7 @@ XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap) if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode, (XMesaDrawable) p, cmap)) { - free_xmesa_buffer(client, b); + xmesa_free_buffer(b); return NULL; } @@ -1821,7 +1811,7 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode, drawable, cmap)) { - free_xmesa_buffer(client, b); + xmesa_free_buffer(b); return NULL; } @@ -1834,48 +1824,10 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, /* * Deallocate an XMesaBuffer structure and all related info. */ -void XMesaDestroyBuffer( XMesaBuffer b ) +void +XMesaDestroyBuffer(XMesaBuffer b) { - int client = 0; - -#ifdef XFree86Server - if (b->frontxrb->drawable) - client = CLIENT_ID(b->frontxrb->drawable->id); -#endif - - if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc ); - if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc ); - if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc ); - - if (b->xm_visual->mesa_visual.doubleBufferMode) - { - if (b->backxrb->ximage) { -#if defined(USE_XSHM) && !defined(XFree86Server) - if (b->shm) { - XShmDetach( b->xm_visual->display, &b->shminfo ); - XDestroyImage( b->backxrb->ximage ); - shmdt( b->shminfo.shmaddr ); - } - else -#endif - XMesaDestroyImage( b->backxrb->ximage ); - } - if (b->backxrb->pixmap) { - XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap ); - if (b->xm_visual->hpcr_clear_flag) { - XMesaFreePixmap( b->xm_visual->display, - b->xm_visual->hpcr_clear_pixmap ); - XMesaDestroyImage( b->xm_visual->hpcr_clear_ximage ); - } - } - } - if (b->rowimage) { - _mesa_free( b->rowimage->data ); - b->rowimage->data = NULL; - XMesaDestroyImage( b->rowimage ); - } - - free_xmesa_buffer(client, b); + xmesa_free_buffer(b); } @@ -2436,7 +2388,7 @@ void xmesa_destroy_buffers_on_display(XMesaDisplay *dpy) for (b = XMesaBufferList; b; b = next) { next = b->Next; if (b->display == dpy) { - free_xmesa_buffer(0, b); + xmesa_free_buffer(b); } } } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 490c479676..a358ec25ae 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -33,6 +33,7 @@ #include "GL/xmesa.h" #include "xmesaP.h" #include "imports.h" +#include "framebuffer.h" #include "renderbuffer.h" @@ -352,5 +353,71 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, } +/** + * Called via gl_framebuffer::Delete() method when this buffer + * is _really_ being deleted. + */ +void +xmesa_delete_framebuffer(struct gl_framebuffer *fb) +{ + XMesaBuffer b = XMESA_BUFFER(fb); +#ifdef XFree86Server + int client = 0; + if (b->frontxrb->drawable) + client = CLIENT_ID(b->frontxrb->drawable->id); +#endif + if (b->num_alloced > 0) { + /* If no other buffer uses this X colormap then free the colors. */ + if (!xmesa_find_buffer(b->display, b->cmap, b)) { +#ifdef XFree86Server + (void)FreeColors(b->cmap, client, + b->num_alloced, b->alloced_colors, 0); +#else + XFreeColors(b->display, b->cmap, + b->alloced_colors, b->num_alloced, 0); +#endif + } + } + + if (b->gc) + XMesaFreeGC(b->xm_visual->display, b->gc); + if (b->cleargc) + XMesaFreeGC(b->xm_visual->display, b->cleargc); + if (b->swapgc) + XMesaFreeGC(b->xm_visual->display, b->swapgc); + + if (b->xm_visual->mesa_visual.doubleBufferMode) { + /* free back ximage/pixmap/shmregion */ + if (b->backxrb->ximage) { +#if defined(USE_XSHM) && !defined(XFree86Server) + if (b->shm) { + XShmDetach( b->xm_visual->display, &b->shminfo ); + XDestroyImage( b->backxrb->ximage ); + shmdt( b->shminfo.shmaddr ); + } + else +#endif + XMesaDestroyImage( b->backxrb->ximage ); + b->backxrb->ximage = NULL; + } + if (b->backxrb->pixmap) { + XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap ); + if (b->xm_visual->hpcr_clear_flag) { + XMesaFreePixmap( b->xm_visual->display, + b->xm_visual->hpcr_clear_pixmap ); + XMesaDestroyImage( b->xm_visual->hpcr_clear_ximage ); + } + } + } + + if (b->rowimage) { + _mesa_free( b->rowimage->data ); + b->rowimage->data = NULL; + XMesaDestroyImage( b->rowimage ); + } + + _mesa_free_framebuffer_data(fb); + _mesa_free(fb); +} diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index e332fb5480..5516031ffe 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -42,6 +42,7 @@ extern _glthread_Mutex _xmesa_lock; +extern XMesaBuffer XMesaBufferList; /* for PF_8R8G8B24 pixel format */ typedef struct { @@ -489,6 +490,12 @@ extern struct xmesa_renderbuffer * xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, GLboolean backBuffer); +extern void +xmesa_delete_framebuffer(struct gl_framebuffer *fb); + +extern XMesaBuffer +xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis); + extern unsigned long xmesa_color_to_pixel( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a, diff --git a/src/mesa/glapi/gl_table.py b/src/mesa/glapi/gl_table.py index 52b4be1d2b..69f7bd7c7b 100644 --- a/src/mesa/glapi/gl_table.py +++ b/src/mesa/glapi/gl_table.py @@ -49,7 +49,11 @@ class PrintGlTable(gl_XML.gl_print_base): def printRealHeader(self): print '#ifndef GLAPIENTRYP' - print '#define GLAPIENTRYP' + print '# ifndef GLAPIENTRY' + print '# define GLAPIENTRY' + print '# endif' + print '' + print '# define GLAPIENTRYP GLAPIENTRY *' print '#endif' print '' print 'typedef void (*_glapi_proc)(void); /* generic function pointer */' diff --git a/src/mesa/glapi/glapitable.h b/src/mesa/glapi/glapitable.h index 55548adcd3..4af0c2d43b 100644 --- a/src/mesa/glapi/glapitable.h +++ b/src/mesa/glapi/glapitable.h @@ -30,7 +30,11 @@ # define _GLAPI_TABLE_H_ #ifndef GLAPIENTRYP -#define GLAPIENTRYP +# ifndef GLAPIENTRY +# define GLAPIENTRY +# endif + +# define GLAPIENTRYP GLAPIENTRY * #endif typedef void (*_glapi_proc)(void); /* generic function pointer */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 9b3759b6c8..135c814c0a 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -95,6 +95,7 @@ #include "fbobject.h" #include "feedback.h" #include "fog.h" +#include "framebuffer.h" #include "get.h" #include "glthread.h" #include "glapioffsets.h" @@ -1407,6 +1408,13 @@ _mesa_free_context_data( GLcontext *ctx ) if (ctx == _mesa_get_current_context()) { _mesa_make_current(NULL, NULL, NULL); } + else { + /* unreference WinSysDraw/Read buffers */ + _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + } _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); @@ -1666,6 +1674,8 @@ void _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ) { + GET_CURRENT_CONTEXT(oldCtx); + if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(newCtx, "_mesa_make_current()\n"); @@ -1690,6 +1700,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, _glapi_set_context((void *) newCtx); ASSERT(_mesa_get_current_context() == newCtx); + if (oldCtx) { + _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer); + } + if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ } @@ -1701,18 +1716,18 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(drawBuffer->Name == 0); ASSERT(readBuffer->Name == 0); - newCtx->WinSysDrawBuffer = drawBuffer; - newCtx->WinSysReadBuffer = readBuffer; + _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); + _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); /* * Only set the context's Draw/ReadBuffer fields if they're NULL * or not bound to a user-created FBO. */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { - newCtx->DrawBuffer = drawBuffer; + _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { - newCtx->ReadBuffer = readBuffer; + _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); } newCtx->NewState |= _NEW_BUFFERS; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index cf8de1e0cb..6608eefc6c 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -602,7 +602,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) oldRb = ctx->CurrentRenderbuffer; if (oldRb) { - _mesa_dereference_renderbuffer(&oldRb); + _mesa_unreference_renderbuffer(&oldRb); } ASSERT(newRb != &DummyRenderbuffer); @@ -639,7 +639,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&rb); } } } @@ -938,7 +938,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { - struct gl_framebuffer *newFb, *oldFb; + struct gl_framebuffer *newFb; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); @@ -998,12 +998,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } - _glthread_LOCK_MUTEX(newFb->Mutex); - if (bindReadBuf) - newFb->RefCount++; - if (bindDrawBuf) - newFb->RefCount++; - _glthread_UNLOCK_MUTEX(newFb->Mutex); } else { /* Binding the window system framebuffer (which was originally set @@ -1020,22 +1014,16 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - oldFb = ctx->ReadBuffer; - if (oldFb && oldFb->Name != 0) { - _mesa_dereference_framebuffer(&oldFb); - } - ctx->ReadBuffer = newFb; + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); } if (bindDrawBuf) { - oldFb = ctx->DrawBuffer; - if (oldFb && oldFb->Name != 0) { - /* check if old FB had any texture attachments */ - check_end_texture_render(ctx, oldFb); - /* check if time to delete this framebuffer */ - _mesa_dereference_framebuffer(&oldFb); - } - ctx->DrawBuffer = newFb; + /* check if old FB had any texture attachments */ + check_end_texture_render(ctx, ctx->DrawBuffer); + /* check if time to delete this framebuffer */ + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); @@ -1083,7 +1071,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_framebuffer(&fb); + _mesa_unreference_framebuffer(&fb); } } } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 465197401b..c97d2f0077 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -78,7 +78,7 @@ set_depth_renderbuffer(struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { if (fb->_DepthBuffer) { - _mesa_dereference_renderbuffer(&fb->_DepthBuffer); + _mesa_unreference_renderbuffer(&fb->_DepthBuffer); } fb->_DepthBuffer = rb; if (rb) { @@ -96,7 +96,7 @@ set_stencil_renderbuffer(struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { if (fb->_StencilBuffer) { - _mesa_dereference_renderbuffer(&fb->_StencilBuffer); + _mesa_unreference_renderbuffer(&fb->_StencilBuffer); } fb->_StencilBuffer = rb; if (rb) { @@ -166,6 +166,8 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual) _glthread_INIT_MUTEX(fb->Mutex); + fb->RefCount = 1; + /* save the visual */ fb->Visual = *visual; @@ -198,7 +200,6 @@ void _mesa_destroy_framebuffer(struct gl_framebuffer *fb) { if (fb) { - _glthread_DESTROY_MUTEX(fb->Mutex); _mesa_free_framebuffer_data(fb); _mesa_free(fb); } @@ -215,20 +216,27 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) GLuint i; assert(fb); + assert(fb->RefCount == 0); + + _glthread_DESTROY_MUTEX(fb->Mutex); for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; if (att->Renderbuffer) { - struct gl_renderbuffer *rb = att->Renderbuffer; - /* remove framebuffer's reference to renderbuffer */ - _mesa_dereference_renderbuffer(&rb); - if (rb && rb->Name == 0) { - /* delete window system renderbuffer */ - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&att->Renderbuffer); + } + if (att->Texture) { + /* render to texture */ + att->Texture->RefCount--; + if (att->Texture->RefCount == 0) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) { + ctx->Driver.DeleteTexture(ctx, att->Texture); + } } } att->Type = GL_NONE; - att->Renderbuffer = NULL; + att->Texture = NULL; } /* unbind depth/stencil to decr ref counts */ @@ -238,25 +246,44 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) /** - * Decrement the reference count on a framebuffer and delete it when + * Set *ptr to point to fb, with refcounting and locking. + */ +void +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb) +{ + assert(ptr); + assert(!*ptr); + assert(fb); + _glthread_LOCK_MUTEX(fb->Mutex); + fb->RefCount++; + _glthread_UNLOCK_MUTEX(fb->Mutex); + *ptr = fb; +} + + +/** + * Undo/remove a reference to a framebuffer object. + * Decrement the framebuffer object's reference count and delete it when * the refcount hits zero. - * Note: we pass the address of a pointer and set it to NULL if we delete it. + * Note: we pass the address of a pointer and set it to NULL. */ void -_mesa_dereference_framebuffer(struct gl_framebuffer **fb) +_mesa_unreference_framebuffer(struct gl_framebuffer **fb) { - GLboolean deleteFlag = GL_FALSE; + assert(fb); + if (*fb) { + GLboolean deleteFlag = GL_FALSE; - _glthread_LOCK_MUTEX((*fb)->Mutex); - { + _glthread_LOCK_MUTEX((*fb)->Mutex); ASSERT((*fb)->RefCount > 0); (*fb)->RefCount--; deleteFlag = ((*fb)->RefCount == 0); - } - _glthread_UNLOCK_MUTEX((*fb)->Mutex); + _glthread_UNLOCK_MUTEX((*fb)->Mutex); + + if (deleteFlag) + (*fb)->Delete(*fb); - if (deleteFlag) { - (*fb)->Delete(*fb); *fb = NULL; } } @@ -605,21 +632,25 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) GLbitfield bufferMask = fb->_ColorDrawBufferMask[output]; GLuint count = 0; GLuint i; - /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK) - * can specify writing to two or four color buffers (for example). - */ - for (i = 0; bufferMask && i < BUFFER_COUNT; i++) { - const GLuint bufferBit = 1 << i; - if (bufferBit & bufferMask) { - struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - if (rb) { - fb->_ColorDrawBuffers[output][count] = rb; - count++; - } - else { - /*_mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");*/ + if (!fb->DeletePending) { + /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK) + * can specify writing to two or four color buffers (for example). + */ + for (i = 0; bufferMask && i < BUFFER_COUNT; i++) { + const GLuint bufferBit = 1 << i; + if (bufferBit & bufferMask) { + struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + if (rb) { + fb->_ColorDrawBuffers[output][count] = rb; + count++; + } + else { + /* + _mesa_warning(ctx, "DrawBuffer names a missing buffer!\n"); + */ + } + bufferMask &= ~bufferBit; } - bufferMask &= ~bufferBit; } } fb->_NumColorDrawBuffers[output] = count; @@ -635,7 +666,7 @@ static void update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) { (void) ctx; - if (fb->_ColorReadBufferIndex == -1) { + if (fb->_ColorReadBufferIndex == -1 || fb->DeletePending) { fb->_ColorReadBuffer = NULL; /* legal! */ } else { diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h index 7f3254fe8e..4d76f3a90f 100644 --- a/src/mesa/main/framebuffer.h +++ b/src/mesa/main/framebuffer.h @@ -43,7 +43,11 @@ extern void _mesa_free_framebuffer_data(struct gl_framebuffer *buffer); extern void -_mesa_dereference_framebuffer(struct gl_framebuffer **fb); +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb); + +extern void +_mesa_unreference_framebuffer(struct gl_framebuffer **fb); extern void _mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e8f0f45d39..422d176c25 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2243,6 +2243,7 @@ struct gl_framebuffer _glthread_Mutex Mutex; /**< for thread safety */ GLuint Name; /* if zero, this is a window system framebuffer */ GLint RefCount; + GLboolean DeletePending; GLvisual Visual; /**< The framebuffer's visual. Immutable if this is a window system buffer. diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index ddf2ac51d3..d4f0fa2a71 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul 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"), @@ -112,9 +112,7 @@ userclip_point( GLcontext *ctx, const GLfloat v[] ) /** - * This has been split off to allow the normal shade routines to - * get a little closer to the vertex buffer, and to use the - * GLvector objects directly. + * Compute lighting for the raster position. Both RGB and CI modes computed. * \param ctx the context * \param vertex vertex location * \param normal normal vector @@ -130,10 +128,10 @@ shade_rastpos(GLcontext *ctx, GLfloat Rspec[4], GLfloat *Rindex) { - GLfloat (*base)[3] = ctx->Light._BaseColor; - struct gl_light *light; - GLfloat diffuseColor[4], specularColor[4]; - GLfloat diffuse = 0, specular = 0; + /*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor; + const struct gl_light *light; + GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */ + GLfloat diffuseCI = 0.0, specularCI = 0.0; /* for CI mode only */ if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1]) _mesa_validate_all_lighting_tables( ctx ); @@ -144,28 +142,31 @@ shade_rastpos(GLcontext *ctx, ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0); foreach (light, &ctx->Light.EnabledList) { - GLfloat n_dot_h; GLfloat attenuation = 1.0; - GLfloat VP[3]; + GLfloat VP[3]; /* vector from vertex to light pos */ GLfloat n_dot_VP; - GLfloat *h; GLfloat diffuseContrib[3], specularContrib[3]; - GLboolean normalized; if (!(light->_Flags & LIGHT_POSITIONAL)) { + /* light at infinity */ COPY_3V(VP, light->_VP_inf_norm); attenuation = light->_VP_inf_spot_attenuation; } else { + /* local/positional light */ GLfloat d; + /* VP = vector from vertex pos to light[i].pos */ SUB_3V(VP, light->_Position, vertex); + /* d = length(VP) */ d = (GLfloat) LEN_3FV( VP ); - - if ( d > 1e-6) { + if (d > 1.0e-6) { + /* normalize VP */ GLfloat invd = 1.0F / d; SELF_SCALE_SCALAR_3V(VP, invd); } + + /* atti */ attenuation = 1.0F / (light->ConstantAttenuation + d * (light->LinearAttenuation + d * light->QuadraticAttenuation)); @@ -196,43 +197,39 @@ shade_rastpos(GLcontext *ctx, continue; } + /* Ambient + diffuse */ COPY_3V(diffuseContrib, light->_MatAmbient[0]); ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]); - diffuse += n_dot_VP * light->_dli * attenuation; - ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0); + diffuseCI += n_dot_VP * light->_dli * attenuation; + /* Specular */ { + const GLfloat *h; + GLfloat n_dot_h; + + ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0); + if (ctx->Light.Model.LocalViewer) { GLfloat v[3]; COPY_3V(v, vertex); NORMALIZE_3FV(v); SUB_3V(VP, VP, v); + NORMALIZE_3FV(VP); h = VP; - normalized = 0; } else if (light->_Flags & LIGHT_POSITIONAL) { + ACC_3V(VP, ctx->_EyeZDir); + NORMALIZE_3FV(VP); h = VP; - ACC_3V(h, ctx->_EyeZDir); - normalized = 0; } else { h = light->_h_inf_norm; - normalized = 1; } n_dot_h = DOT3(normal, h); if (n_dot_h > 0.0F) { - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; GLfloat spec_coef; - GLfloat shininess = mat[MAT_ATTRIB_FRONT_SHININESS][0]; - - if (!normalized) { - n_dot_h *= n_dot_h; - n_dot_h /= LEN_SQUARED_3FV( h ); - shininess *= .5; - } - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef ); if (spec_coef > 1.0e-10) { @@ -244,7 +241,8 @@ shade_rastpos(GLcontext *ctx, ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef, light->_MatSpecular[0]); } - specular += spec_coef * light->_sli * attenuation; + /*assert(light->_sli > 0.0);*/ + specularCI += spec_coef * light->_sli * attenuation; } } } @@ -268,8 +266,8 @@ shade_rastpos(GLcontext *ctx, GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT]; GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT]; GLfloat i = (ind[MAT_INDEX_AMBIENT] - + diffuse * (1.0F-specular) * d_a - + specular * s_a); + + diffuseCI * (1.0F-specularCI) * d_a + + specularCI * s_a); if (i > ind[MAT_INDEX_SPECULAR]) { i = ind[MAT_INDEX_SPECULAR]; } diff --git a/src/mesa/main/rbadaptors.c b/src/mesa/main/rbadaptors.c index 313c8d43d6..60f4948bec 100644 --- a/src/mesa/main/rbadaptors.c +++ b/src/mesa/main/rbadaptors.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul 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"), @@ -45,7 +45,7 @@ Delete_wrapper(struct gl_renderbuffer *rb) /* Decrement reference count on the buffer we're wrapping and delete * it if refcount hits zero. */ - _mesa_dereference_renderbuffer(&rb->Wrapped); + _mesa_unreference_renderbuffer(&rb->Wrapped); /* delete myself */ _mesa_delete_renderbuffer(rb); diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 6b18d60baf..1cc95a7d3b 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -2089,32 +2089,33 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName) if (!rb) return; - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&rb); fb->Attachment[bufferName].Renderbuffer = NULL; } /** - * Decrement the reference count on a renderbuffer and delete it when + * Decrement a renderbuffer object's reference count and delete it when * the refcount hits zero. - * Note: we pass the address of a pointer and set it to NULL if we delete it. + * Note: we pass the address of a pointer. */ void -_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb) +_mesa_unreference_renderbuffer(struct gl_renderbuffer **rb) { - GLboolean deleteFlag = GL_FALSE; + assert(rb); + if (*rb) { + GLboolean deleteFlag = GL_FALSE; - _glthread_LOCK_MUTEX((*rb)->Mutex); - { + _glthread_LOCK_MUTEX((*rb)->Mutex); ASSERT((*rb)->RefCount > 0); (*rb)->RefCount--; deleteFlag = ((*rb)->RefCount == 0); - } - _glthread_UNLOCK_MUTEX((*rb)->Mutex); + _glthread_UNLOCK_MUTEX((*rb)->Mutex); + + if (deleteFlag) + (*rb)->Delete(*rb); - if (deleteFlag) { - (*rb)->Delete(*rb); *rb = NULL; } } diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h index 74ca43c57a..e1a0a55979 100644 --- a/src/mesa/main/renderbuffer.h +++ b/src/mesa/main/renderbuffer.h @@ -99,7 +99,7 @@ extern void _mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName); extern void -_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb); +_mesa_unreference_renderbuffer(struct gl_renderbuffer **rb); extern struct gl_renderbuffer * _mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name); diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index b9ff08de5f..c6ea5c4f97 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -4038,6 +4038,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) program->TexturesUsed[i] = ap.TexturesUsed[i]; program->FogOption = ap.FogOption; + program->UsesKill = ap.UsesKill; if (program->Base.Instructions) _mesa_free(program->Base.Instructions); diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 27f4736c39..15dc8106b4 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul 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"), @@ -54,7 +54,8 @@ read_index_pixels( GLcontext *ctx, struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; GLint i; - ASSERT(rb); + if (!rb) + return; /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); @@ -91,6 +92,9 @@ read_depth_pixels( GLcontext *ctx, const GLboolean biasOrScale = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; + if (!rb) + return; + /* clipping should have been done already */ ASSERT(x >= 0); ASSERT(y >= 0); @@ -99,8 +103,6 @@ read_depth_pixels( GLcontext *ctx, /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); - ASSERT(rb); - if (type == GL_UNSIGNED_SHORT && fb->Visual.depthBits == 16 && !biasOrScale && !packing->SwapBytes) { /* Special case: directly read 16-bit unsigned depth values. */ @@ -171,7 +173,8 @@ read_stencil_pixels( GLcontext *ctx, struct gl_renderbuffer *rb = fb->_StencilBuffer; GLint j; - ASSERT(rb); + if (!rb) + return; /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); @@ -195,6 +198,7 @@ read_stencil_pixels( GLcontext *ctx, /** * Optimized glReadPixels for particular pixel formats when pixel * scaling, biasing, mapping, etc. are disabled. + * \return GL_TRUE if success, GL_FALSE if unable to do the readpixels */ static GLboolean fast_read_rgba_pixels( GLcontext *ctx, @@ -207,6 +211,9 @@ fast_read_rgba_pixels( GLcontext *ctx, { struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + if (!rb) + return GL_FALSE; + ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB); /* clipping should have already been done */ @@ -316,7 +323,8 @@ read_rgba_pixels( GLcontext *ctx, struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_renderbuffer *rb = fb->_ColorReadBuffer; - ASSERT(rb); + if (!rb) + return; if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) || (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB && @@ -457,8 +465,8 @@ read_depth_stencil_pixels(GLcontext *ctx, depthRb = ctx->ReadBuffer->_DepthBuffer; stencilRb = ctx->ReadBuffer->_StencilBuffer; - ASSERT(depthRb); - ASSERT(stencilRb); + if (!depthRb || !stencilRb) + return; depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 65998e7ff7..f64f59d11e 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -241,6 +241,7 @@ void _vbo_DestroyContext( GLcontext *ctx ) ctx->aelt_context = NULL; } + vbo_exec_destroy(ctx); FREE(vbo_context(ctx)); ctx->swtnl_im = NULL; } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 2b52d7a1ff..d8f167b357 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -218,7 +218,7 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) exec->vtx.prim_count, NULL, 0, - exec->vtx.vert_count ); + exec->vtx.vert_count - 1); } } diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index a50d1cd904..bc59a0d821 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -218,7 +218,7 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ) node->prim_count, NULL, 0, /* Node is a VBO, so this is ok */ - node->count ); + node->count - 1); } /* Copy to current? |