summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/allegro/amesa.c2
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c4
-rw-r--r--src/mesa/drivers/dri/fb/fb_dri.c6
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_xmesa.c2
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_xmesa.c2
-rw-r--r--src/mesa/drivers/dri/i810/i810screen.c2
-rw-r--r--src/mesa/drivers/dri/i915/intel_screen.c2
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_tex_layout.c23
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c9
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_regions.c5
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_regions.h2
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_screen.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c1
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c2
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_screen.c2
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c6
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_object.c68
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_object.h13
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c8
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.c7
-rw-r--r--src/mesa/drivers/dri/r128/r128_screen.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_maos_arrays.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c18
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h1
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c314
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c183
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h16
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c20
-rw-r--r--src/mesa/drivers/dri/r300/radeon_context.c7
-rw-r--r--src/mesa/drivers/dri/r300/radeon_lock.c1
-rw-r--r--src/mesa/drivers/dri/r300/radeon_mm.c2
-rw-r--r--src/mesa/drivers/dri/r300/radeon_state.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.c2
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_xmesa.c2
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c2
-rw-r--r--src/mesa/drivers/dri/sis/sis_screen.c2
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_screen.c2
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.c2
-rw-r--r--src/mesa/drivers/dri/unichrome/via_screen.c2
-rw-r--r--src/mesa/drivers/glide/fxapi.c4
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c3
-rw-r--r--src/mesa/drivers/svga/svgamesa.c1
-rw-r--r--src/mesa/drivers/x11/xm_api.c106
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c79
-rw-r--r--src/mesa/drivers/x11/xmesaP.h7
-rw-r--r--src/mesa/glapi/gl_API.xml2
-rw-r--r--src/mesa/glapi/gl_table.py6
-rw-r--r--src/mesa/glapi/glapitable.h6
-rw-r--r--src/mesa/main/context.c23
-rw-r--r--src/mesa/main/enums.c4
-rw-r--r--src/mesa/main/fbobject.c32
-rw-r--r--src/mesa/main/framebuffer.c108
-rw-r--r--src/mesa/main/framebuffer.h6
-rw-r--r--src/mesa/main/image.c19
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/rastpos.c67
-rw-r--r--src/mesa/main/rbadaptors.c6
-rw-r--r--src/mesa/main/renderbuffer.c23
-rw-r--r--src/mesa/main/renderbuffer.h2
-rw-r--r--src/mesa/main/texstore.c2
-rw-r--r--src/mesa/shader/arbprogparse.c1
-rw-r--r--src/mesa/swrast/s_readpix.c26
-rw-r--r--src/mesa/vbo/descrip.mms60
-rw-r--r--src/mesa/vbo/vbo_context.c1
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c2
-rw-r--r--src/mesa/vbo/vbo_save_draw.c2
68 files changed, 684 insertions, 672 deletions
diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c
index 594668affda..518211ccf46 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 cc3dcf9d8db..07ac4c7cd5f 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 08b52b4d8f7..a6d7590eff7 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 215aaf8ffba..4c5323d230e 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 e8922b15036..f41682cea71 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 d0e58f667c2..f64c10a9ae0 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 107cf137ff6..67e176a1c6f 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 333fefef859..2e1600cfdfa 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;
@@ -182,6 +190,9 @@ i945_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 */
/* Depending on the size of the largest images, pitch can be
* determined either by the old-style packing of cubemap faces,
@@ -196,11 +207,13 @@ i945_miptree_layout(struct intel_mipmap_tree * mt)
/* Set all the levels to effectively occupy the whole rectangular region.
*/
- 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);
-
+ lvlWidth, lvlHeight, 1);
+ lvlWidth /= 2;
+ lvlHeight /= 2;
+ }
for (face = 0; face < 6; face++) {
diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
index 2b1077aee0d..93372f4dcc8 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 1205b180ca6..a114bdf8965 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 1415bace690..d938c107a46 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 efa1b014a61..ac83254593b 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 092c6bafc2d..4eb2eedd422 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 08f0bb340f7..5dac50df32c 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 1014b8acd52..4e9e216e7db 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 f024f73eb6a..67a6f8bdf09 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 6f1b57d74ed..627679a1479 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 f61fcbb48c0..f79a8675f44 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 302009c8b17..468b18e6d90 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 daad281029f..0be9b4309c6 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 881b20149f0..e00080fce1e 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 c47ff3a985d..428b19b46ea 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 4f1b20aadd7..880dee85c25 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 6a6c30a2b0d..3162b508c23 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 ace9b667240..2c7b5aa011f 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 48b50bca653..a339b2f9c16 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 9330ec5b95d..f18a982debe 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -1215,8 +1215,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);
@@ -1228,7 +1228,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};
@@ -1278,70 +1278,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]);
@@ -1364,15 +1357,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],
@@ -1409,17 +1402,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]);
@@ -1451,44 +1444,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,
@@ -1496,7 +1489,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]);
@@ -1507,14 +1500,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]);
@@ -1555,17 +1548,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]);
@@ -1581,107 +1574,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:
/*
@@ -1691,73 +1668,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]);
@@ -1778,9 +1756,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,
@@ -1791,10 +1769,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 0774a2af6b4..6fa34ee482a 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 9f636ec1d2e..69bc994cf66 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 62bbc965441..50dcee47559 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -330,24 +330,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;
}
}
@@ -1772,9 +1772,7 @@ void r300UpdateShaderStates(r300ContextPtr rmesa)
GLcontext *ctx;
ctx = rmesa->radeon.glCtx;
-#ifdef CB_DPATH
r300UpdateTextureState(ctx);
-#endif
r300SetupPixelShader(rmesa);
r300_setup_textures(ctx);
@@ -1899,10 +1897,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 3a6bde8fc31..66d1b153b3c 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"
@@ -272,11 +273,13 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
&radeon->vbl_seq);
}
+ radeon->dri.readable = driReadPriv;
+
if (radeon->dri.drawable != driDrawPriv ||
- radeon->dri.readable != driReadPriv) {
+ radeon->lastStamp != driDrawPriv->lastStamp) {
radeon->dri.drawable = driDrawPriv;
- radeon->dri.readable = driReadPriv;
+ radeonSetCliprects(radeon);
r300UpdateWindow(radeon->glCtx);
r300UpdateViewportOffset(radeon->glCtx);
}
diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c
index a00da6c8bc3..1a2dfca7b0d 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 f86a1b4e72e..32ed1f43939 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 ddadf83a003..902e9583a63 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 fc5aa114621..abb14faaa13 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 c451f7452bf..c66fd6dac31 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 ad79b9235c1..f859217069c 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 8f52cfe098e..89d734ba786 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 646f5126eb0..1f9ff4e30ca 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 dbbd1ac0c69..8dc7f0dc781 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 28e1f9451e6..90f76be44d4 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 e535e739b31..00b9d29fac1 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 c4fc8821e50..96b9b5c1741 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 0dd9a144fe8..d1385875690 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 b0ef422de2e..776928dec4d 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,12 +378,12 @@ 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
*/
- b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_FALSE);
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE);
if (!b->frontxrb) {
_mesa_free(b);
return NULL;
@@ -398,8 +398,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
* Back renderbuffer
*/
if (vis->mesa_visual.doubleBufferMode) {
- b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_TRUE);
+ b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE);
if (!b->backxrb) {
/* XXX free front xrb too */
_mesa_free(b);
@@ -451,8 +450,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 +464,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 +492,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 +674,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 +763,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 +1654,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 +1775,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 +1809,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 +1822,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 +2386,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 490c4796767..747971a6c30 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,83 @@ 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 );
+ }
+
+ /* Note that XMesaBuffer renderbuffers normally have a refcount of 2
+ * (creation + binding) so we need to explicitly delete/unbind them here.
+ */
+ if (b->frontxrb) {
+ _mesa_unreference_renderbuffer((struct gl_renderbuffer **) &b->frontxrb);
+ ASSERT(b->frontxrb == NULL);
+ }
+ if (b->backxrb) {
+ _mesa_unreference_renderbuffer((struct gl_renderbuffer **) &b->backxrb);
+ ASSERT(b->backxrb == NULL);
+ }
+
+ _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 e332fb5480c..5516031ffe7 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_API.xml b/src/mesa/glapi/gl_API.xml
index bd31e8871b0..282150349fa 100644
--- a/src/mesa/glapi/gl_API.xml
+++ b/src/mesa/glapi/gl_API.xml
@@ -6091,7 +6091,7 @@
<size name="GetTexLevelParameterfv" mode="get"/>
<size name="GetTexLevelParameteriv" mode="get"/>
</enum>
- <enum name="NUM_TEXTURE_COMPRESSED_FORMATS_ARB" count="1" value="0x86A2">
+ <enum name="NUM_COMPRESSED_TEXTURE_FORMATS_ARB" count="1" value="0x86A2">
<size name="Get" mode="get"/>
</enum>
<enum name="TEXTURE_COMPRESSED_FORMATS_ARB" value="0x86A3"/>
diff --git a/src/mesa/glapi/gl_table.py b/src/mesa/glapi/gl_table.py
index 52b4be1d2b5..69f7bd7c7b5 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 55548adcd3b..4af0c2d43b8 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 9b043488068..0cff90c77a6 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"
@@ -1423,6 +1424,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 );
@@ -1682,9 +1690,7 @@ void
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
-#if 0
GET_CURRENT_CONTEXT(oldCtx);
-#endif
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(newCtx, "_mesa_make_current()\n");
@@ -1734,6 +1740,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 */
}
@@ -1745,18 +1756,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/enums.c b/src/mesa/main/enums.c
index 8c1b785aab3..bad33f7f642 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -1003,7 +1003,7 @@ LONGSTRING static const char enum_string_table[] =
"GL_NOTEQUAL\0"
"GL_NO_ERROR\0"
"GL_NUM_COMPRESSED_TEXTURE_FORMATS\0"
- "GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB\0"
+ "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0"
"GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0"
"GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0"
"GL_OBJECT_ACTIVE_UNIFORMS_ARB\0"
@@ -2744,7 +2744,7 @@ static const enum_elt all_enums[1737] =
{ 20205, 0x00000205 }, /* GL_NOTEQUAL */
{ 20217, 0x00000000 }, /* GL_NO_ERROR */
{ 20229, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
- { 20263, 0x000086A2 }, /* GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB */
+ { 20263, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
{ 20301, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
{ 20333, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
{ 20375, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index cf8de1e0cbe..f7e870b49cd 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,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
*/
if (bindReadBuf) {
- oldFb = ctx->ReadBuffer;
- if (oldFb && oldFb->Name != 0) {
- _mesa_dereference_framebuffer(&oldFb);
- }
- ctx->ReadBuffer = newFb;
+ _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_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 +1069,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 465197401b7..3136a950e08 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,51 @@ _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);
+ if (*ptr == fb) {
+ /* no change */
+ return;
+ }
+ if (*ptr) {
+ _mesa_unreference_framebuffer(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 +639,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 +673,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 7f3254fe8ea..4d76f3a90f7 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/image.c b/src/mesa/main/image.c
index fc8e1f0f574..eb91ebb6110 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1182,15 +1182,24 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
/* compute luminance values */
- if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
+ if (transferOps & IMAGE_RED_TO_LUMINANCE) {
+ /* Luminance = Red (glGetTexImage) */
for (i = 0; i < n; i++) {
- GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
- luminance[i] = CLAMP(sum, 0.0F, 1.0F);
+ luminance[i] = rgba[i][RCOMP];
}
}
else {
- for (i = 0; i < n; i++) {
- luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ /* Luminance = Red + Green + Blue (glReadPixels) */
+ if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
+ for (i = 0; i < n; i++) {
+ GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ luminance[i] = CLAMP(sum, 0.0F, 1.0F);
+ }
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ }
}
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 410d2d3144f..b08e77ea880 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2316,6 +2316,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.
@@ -2612,6 +2613,7 @@ struct gl_matrix_stack
#define IMAGE_HISTOGRAM_BIT 0x200
#define IMAGE_MIN_MAX_BIT 0x400
#define IMAGE_CLAMP_BIT 0x800 /* extra */
+#define IMAGE_RED_TO_LUMINANCE 0x1000
/** Pixel Transfer ops up to convolution */
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index ddf2ac51d3b..4a0c24fdbcc 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,13 +128,12 @@ 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 );
+ _mesa_validate_all_lighting_tables( ctx );
COPY_3V(diffuseColor, base[0]);
diffuseColor[3] = CLAMP(
@@ -144,28 +141,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 +196,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 +240,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 +265,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 313c8d43d62..60f4948becf 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 6b18d60baff..1cc95a7d3b4 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 74ca43c57ab..e1a0a559792 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/main/texstore.c b/src/mesa/main/texstore.c
index 87f8fa7a0d4..994fb167306 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3611,7 +3611,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
}
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
format, type, dest,
- &ctx->Pack, 0x0 /*image xfer ops*/);
+ &ctx->Pack, IMAGE_RED_TO_LUMINANCE);
} /* format */
} /* row */
} /* img */
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 7d34bfbc808..5027264f031 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3863,6 +3863,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
program->Base.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 a7b25a46339..383d61ce06e 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/descrip.mms b/src/mesa/vbo/descrip.mms
new file mode 100644
index 00000000000..4ab22e4005b
--- /dev/null
+++ b/src/mesa/vbo/descrip.mms
@@ -0,0 +1,60 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen [email protected]
+# Last revision : 7 March 2007
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define vbo [-.vbo]
+ define tnl [-.tnl]
+ define shader [-.shader]
+ define swrast [-.swrast]
+ define swrast_setup [-.swrast_setup]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader],[-.shader.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES =vbo_context.c,vbo_exec.c,vbo_exec_api.c,vbo_exec_array.c,\
+ vbo_exec_draw.c,vbo_exec_eval.c,vbo_rebase.c,vbo_save.c,\
+ vbo_save_api.c,vbo_save_draw.c,vbo_save_loopback.c,\
+ vbo_split.c,vbo_split_copy.c,vbo_split_inplace.c
+
+OBJECTS =vbo_context.obj,vbo_exec.obj,vbo_exec_api.obj,vbo_exec_array.obj,\
+ vbo_exec_draw.obj,vbo_exec_eval.obj,vbo_rebase.obj,vbo_save.obj,\
+ vbo_save_api.obj,vbo_save_draw.obj,vbo_save_loopback.obj,\
+ vbo_split.obj,vbo_split_copy.obj,vbo_split_inplace.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+vbo_context.obj : vbo_context.c
+vbo_exec.obj : vbo_exec.c
+vbo_exec_api.obj : vbo_exec_api.c
+vbo_exec_array.obj : vbo_exec_array.c
+vbo_exec_draw.obj : vbo_exec_draw.c
+vbo_exec_eval.obj : vbo_exec_eval.c
+vbo_rebase.obj : vbo_rebase.c
+vbo_save.obj : vbo_save.c
+vbo_save_api.obj : vbo_save_api.c
+vbo_save_draw.obj : vbo_save_draw.c
+vbo_save_loopback.obj : vbo_save_loopback.c
+vbo_split.obj : vbo_split.c
+vbo_split_copy.obj : vbo_split_copy.c
+vbo_split_inplace.obj : vbo_split_inplace.c
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 65998e7ff75..f64f59d11ec 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 2b52d7a1fff..d8f167b3577 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 8be258d5aa2..75cbf020d7d 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -219,7 +219,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?