From 4f39d22c298d9b7b7dc620cda1079b41c0e2edab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Date: Tue, 12 Sep 2006 14:13:36 +0000 Subject: [PATCH] texmem_0_3_branch with adaptations to the drm-ttm-0-2 branch. Indent the i915 driver directory. --- src/mesa/drivers/dri/Makefile.template | 5 +- src/mesa/drivers/dri/common/dri_bufmgr.c | 466 ++++++ src/mesa/drivers/dri/common/dri_bufmgr.h | 96 ++ src/mesa/drivers/dri/common/dri_bufpool.h | 84 ++ src/mesa/drivers/dri/common/dri_drmpool.c | 211 +++ src/mesa/drivers/dri/i915/Makefile | 3 +- src/mesa/drivers/dri/i915/i830_context.c | 51 +- src/mesa/drivers/dri/i915/i830_context.h | 69 +- src/mesa/drivers/dri/i915/i830_metaops.c | 239 ++-- src/mesa/drivers/dri/i915/i830_reg.h | 16 +- src/mesa/drivers/dri/i915/i830_state.c | 793 ++++++----- src/mesa/drivers/dri/i915/i830_tex.c | 35 +- src/mesa/drivers/dri/i915/i830_texblend.c | 362 +++-- src/mesa/drivers/dri/i915/i830_texstate.c | 211 ++- src/mesa/drivers/dri/i915/i830_vtbl.c | 434 +++--- src/mesa/drivers/dri/i915/i915_context.c | 103 +- src/mesa/drivers/dri/i915/i915_context.h | 108 +- src/mesa/drivers/dri/i915/i915_debug.c | 187 ++- src/mesa/drivers/dri/i915/i915_fragprog.c | 1266 ++++++++--------- src/mesa/drivers/dri/i915/i915_metaops.c | 210 ++- src/mesa/drivers/dri/i915/i915_program.c | 296 ++-- src/mesa/drivers/dri/i915/i915_program.h | 97 +- src/mesa/drivers/dri/i915/i915_reg.h | 160 +-- src/mesa/drivers/dri/i915/i915_state.c | 629 ++++---- src/mesa/drivers/dri/i915/i915_tex.c | 42 +- src/mesa/drivers/dri/i915/i915_tex_layout.c | 515 ++++--- src/mesa/drivers/dri/i915/i915_texstate.c | 215 +-- src/mesa/drivers/dri/i915/i915_vtbl.c | 326 +++-- src/mesa/drivers/dri/i915/intel_batchbuffer.c | 262 ++-- src/mesa/drivers/dri/i915/intel_batchbuffer.h | 73 +- src/mesa/drivers/dri/i915/intel_batchpool.c | 406 ++++++ src/mesa/drivers/dri/i915/intel_blit.c | 405 +++--- src/mesa/drivers/dri/i915/intel_blit.h | 47 +- .../drivers/dri/i915/intel_buffer_objects.c | 118 +- .../drivers/dri/i915/intel_buffer_objects.h | 31 +- src/mesa/drivers/dri/i915/intel_buffers.c | 434 +++--- src/mesa/drivers/dri/i915/intel_buffers.h | 35 +- src/mesa/drivers/dri/i915/intel_bufmgr.c | 467 ------ src/mesa/drivers/dri/i915/intel_bufmgr.h | 126 -- src/mesa/drivers/dri/i915/intel_context.c | 460 +++--- src/mesa/drivers/dri/i915/intel_context.h | 204 +-- .../drivers/dri/i915/intel_depthstencil.c | 13 +- .../drivers/dri/i915/intel_depthstencil.h | 5 +- src/mesa/drivers/dri/i915/intel_fbo.c | 100 +- src/mesa/drivers/dri/i915/intel_fbo.h | 31 +- src/mesa/drivers/dri/i915/intel_ioctl.c | 93 +- src/mesa/drivers/dri/i915/intel_ioctl.h | 13 +- src/mesa/drivers/dri/i915/intel_mipmap_tree.c | 190 ++- src/mesa/drivers/dri/i915/intel_mipmap_tree.h | 107 +- src/mesa/drivers/dri/i915/intel_pixel.c | 65 +- src/mesa/drivers/dri/i915/intel_pixel.h | 45 +- src/mesa/drivers/dri/i915/intel_pixel_copy.c | 193 ++- src/mesa/drivers/dri/i915/intel_pixel_draw.c | 195 ++- src/mesa/drivers/dri/i915/intel_pixel_read.c | 172 ++- src/mesa/drivers/dri/i915/intel_regions.c | 280 ++-- src/mesa/drivers/dri/i915/intel_regions.h | 103 +- src/mesa/drivers/dri/i915/intel_render.c | 95 +- src/mesa/drivers/dri/i915/intel_rotate.c | 56 +- src/mesa/drivers/dri/i915/intel_rotate.h | 6 +- src/mesa/drivers/dri/i915/intel_screen.c | 400 +++--- src/mesa/drivers/dri/i915/intel_screen.h | 65 +- src/mesa/drivers/dri/i915/intel_span.c | 40 +- src/mesa/drivers/dri/i915/intel_span.h | 9 +- src/mesa/drivers/dri/i915/intel_state.c | 361 ++--- src/mesa/drivers/dri/i915/intel_tex.c | 77 +- src/mesa/drivers/dri/i915/intel_tex.h | 163 ++- src/mesa/drivers/dri/i915/intel_tex_copy.c | 209 ++- src/mesa/drivers/dri/i915/intel_tex_format.c | 51 +- src/mesa/drivers/dri/i915/intel_tex_image.c | 409 +++--- .../drivers/dri/i915/intel_tex_subimage.c | 150 +- .../drivers/dri/i915/intel_tex_validate.c | 156 +- src/mesa/drivers/dri/i915/intel_tris.c | 491 ++++--- src/mesa/drivers/dri/i915/intel_tris.h | 36 +- 73 files changed, 7787 insertions(+), 6889 deletions(-) create mode 100644 src/mesa/drivers/dri/common/dri_bufmgr.c create mode 100644 src/mesa/drivers/dri/common/dri_bufmgr.h create mode 100644 src/mesa/drivers/dri/common/dri_bufpool.h create mode 100644 src/mesa/drivers/dri/common/dri_drmpool.c create mode 100644 src/mesa/drivers/dri/i915/intel_batchpool.c delete mode 100644 src/mesa/drivers/dri/i915/intel_bufmgr.c delete mode 100644 src/mesa/drivers/dri/i915/intel_bufmgr.h diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 58912730fdd..cb8013a57f2 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -9,7 +9,10 @@ COMMON_SOURCES = \ ../common/vblank.c \ ../common/dri_util.c \ ../common/xmlconfig.c \ - ../common/drirenderbuffer.c + ../common/drirenderbuffer.c \ + ../common/dri_bufmgr.c \ + ../common/dri_drmpool.c + ifeq ($(WINDOW_SYSTEM),dri) WINOBJ= diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.c b/src/mesa/drivers/dri/common/dri_bufmgr.c new file mode 100644 index 00000000000..f244b666991 --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_bufmgr.c @@ -0,0 +1,466 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström + * Keith Whitwell + */ + +#include +#include +#include "glthread.h" +#include "errno.h" +#include "dri_bufmgr.h" +#include "string.h" +#include "imports.h" +#include "dri_bufpool.h" + +_glthread_DECLARE_STATIC_MUTEX(bmMutex); + +/* + * TODO: Introduce fence pools in the same way as + * buffer object pools. + */ + + + +typedef struct _DriFenceObject +{ + int fd; + _glthread_Mutex mutex; + int refCount; + const char *name; + drmFence fence; +} DriFenceObject; + +typedef struct _DriBufferObject +{ + DriBufferPool *pool; + _glthread_Mutex mutex; + int refCount; + const char *name; + unsigned flags; + unsigned hint; + unsigned alignment; + void *private; +} DriBufferObject; + + +void +bmError(int val, const char *file, const char *function, int line) +{ + _mesa_printf("Fatal video memory manager error \"%s\".\n" + "Check kernel logs or set the LIBGL_DEBUG\n" + "environment variable to \"verbose\" for more info.\n" + "Detected in file %s, line %d, function %s.\n", + strerror(-val), file, line, function); +#ifndef NDEBUG + exit(-1); +#else + abort(); +#endif +} + +DriFenceObject * +driFenceBuffers(int fd, char *name, int shareable) +{ + DriFenceObject *fence = (DriFenceObject *) malloc(sizeof(*fence)); + int ret; + + if (!fence) + BM_CKFATAL(-EINVAL); + + _glthread_LOCK_MUTEX(bmMutex); + fence->refCount = 1; + fence->name = name; + fence->fd = fd; + _glthread_INIT_MUTEX(fence->mutex); + ret = drmFenceBuffers(fd, shareable, &fence->fence); + _glthread_UNLOCK_MUTEX(bmMutex); + if (ret) { + free(fence); + BM_CKFATAL(ret); + } + return fence; +} + + +void +driFenceReference(DriFenceObject * fence) +{ + _glthread_LOCK_MUTEX(bmMutex); + ++fence->refCount; + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driFenceUnReference(DriFenceObject * fence) +{ + if (!fence) + return; + + _glthread_LOCK_MUTEX(bmMutex); + if (--fence->refCount == 0) { + drmFenceDestroy(fence->fd, &fence->fence); + free(fence); + } + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driFenceFinish(DriFenceObject * fence, unsigned type, int lazy) +{ + int ret; + + _glthread_LOCK_MUTEX(fence->mutex); + ret = drmFenceWait(fence->fd, &fence->fence, type, lazy, GL_FALSE); + _glthread_UNLOCK_MUTEX(fence->mutex); + BM_CKFATAL(ret); +} + +int +driFenceSignaled(DriFenceObject * fence, unsigned type) +{ + int signaled; + int ret; + + if (fence == NULL) + return GL_TRUE; + + _glthread_LOCK_MUTEX(fence->mutex); + ret = drmFenceSignaled(fence->fd, &fence->fence, type, &signaled); + _glthread_UNLOCK_MUTEX(fence->mutex); + BM_CKFATAL(ret); + return signaled; +} + +extern drmBO * +driBOKernel(struct _DriBufferObject *buf) +{ + drmBO *ret; + + assert(buf->private != NULL); + ret = buf->pool->kernel(buf->pool, buf->private); + if (!ret) + BM_CKFATAL(-EINVAL); + + return ret; +} + +void * +driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint) +{ + void *virtual; + + assert(buf->private != NULL); + + _glthread_LOCK_MUTEX(buf->mutex); + BM_CKFATAL(buf->pool->map(buf->pool, buf->private, flags, hint, &virtual)); + _glthread_UNLOCK_MUTEX(buf->mutex); + return virtual; +} + +void +driBOUnmap(struct _DriBufferObject *buf) +{ + assert(buf->private != NULL); + + buf->pool->unmap(buf->pool, buf->private); +} + +unsigned long +driBOOffset(struct _DriBufferObject *buf) +{ + unsigned long ret; + + assert(buf->private != NULL); + + _glthread_LOCK_MUTEX(buf->mutex); + ret = buf->pool->offset(buf->pool, buf->private); + _glthread_UNLOCK_MUTEX(buf->mutex); + return ret; +} + +unsigned +driBOFlags(struct _DriBufferObject *buf) +{ + unsigned ret; + + assert(buf->private != NULL); + + _glthread_LOCK_MUTEX(buf->mutex); + ret = buf->pool->flags(buf->pool, buf->private); + _glthread_UNLOCK_MUTEX(buf->mutex); + return ret; +} + +void +driBOReference(struct _DriBufferObject *buf) +{ + _glthread_LOCK_MUTEX(bmMutex); + if (++buf->refCount == 1) { + BM_CKFATAL(-EINVAL); + } + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driBOUnReference(struct _DriBufferObject *buf) +{ + int tmp; + + if (!buf) + return; + + _glthread_LOCK_MUTEX(bmMutex); + tmp = --buf->refCount; + _glthread_UNLOCK_MUTEX(bmMutex); + if (!tmp) { + buf->pool->destroy(buf->pool, buf->private); + free(buf); + } +} + +void +driBOData(struct _DriBufferObject *buf, + unsigned size, const void *data, unsigned flags) +{ + void *virtual; + int newBuffer; + struct _DriBufferPool *pool; + + _glthread_LOCK_MUTEX(buf->mutex); + pool = buf->pool; + if (!pool->create) { + _mesa_error(NULL, GL_INVALID_OPERATION, + "driBOData called on invalid buffer\n"); + BM_CKFATAL(-EINVAL); + } + newBuffer = !buf->private || (pool->size(pool, buf->private) < size) || + pool->map(pool, buf->private, DRM_BO_FLAG_WRITE, + DRM_BO_HINT_DONT_BLOCK, &virtual); + + if (newBuffer) { + if (buf->private) + pool->destroy(pool, buf->private); + if (!flags) + flags = buf->flags; + buf->private = pool->create(pool, size, flags, 0, buf->alignment); + if (!buf->private) + BM_CKFATAL(-ENOMEM); + BM_CKFATAL(pool->map(pool, buf->private, + DRM_BO_FLAG_WRITE, + DRM_BO_HINT_DONT_BLOCK, &virtual)); + } + + if (data != NULL) + memcpy(virtual, data, size); + + BM_CKFATAL(pool->unmap(pool, buf->private)); + _glthread_UNLOCK_MUTEX(buf->mutex); +} + +void +driBOSubData(struct _DriBufferObject *buf, + unsigned long offset, unsigned long size, const void *data) +{ + void *virtual; + + _glthread_LOCK_MUTEX(buf->mutex); + if (size && data) { + BM_CKFATAL(buf->pool->map(buf->pool, buf->private, + DRM_BO_FLAG_WRITE, 0, &virtual)); + memcpy((unsigned char *) virtual + offset, data, size); + BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private)); + } + _glthread_UNLOCK_MUTEX(buf->mutex); +} + +void +driBOGetSubData(struct _DriBufferObject *buf, + unsigned long offset, unsigned long size, void *data) +{ + void *virtual; + + _glthread_LOCK_MUTEX(buf->mutex); + if (size && data) { + BM_CKFATAL(buf->pool->map(buf->pool, buf->private, + DRM_BO_FLAG_READ, 0, &virtual)); + memcpy(data, (unsigned char *) virtual + offset, size); + BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private)); + } + _glthread_UNLOCK_MUTEX(buf->mutex); +} + +void +driBOSetStatic(struct _DriBufferObject *buf, + unsigned long offset, + unsigned long size, void *virtual, unsigned flags) +{ + _glthread_LOCK_MUTEX(buf->mutex); + if (buf->private != NULL) { + _mesa_error(NULL, GL_INVALID_OPERATION, + "Invalid buffer for setStatic\n"); + BM_CKFATAL(-EINVAL); + } + if (buf->pool->setstatic == NULL) { + _mesa_error(NULL, GL_INVALID_OPERATION, + "Invalid buffer pool for setStatic\n"); + BM_CKFATAL(-EINVAL); + } + + if (!flags) + flags = buf->flags; + + buf->private = buf->pool->setstatic(buf->pool, offset, size, + virtual, flags); + if (!buf->private) { + _mesa_error(NULL, GL_OUT_OF_MEMORY, + "Invalid buffer pool for setStatic\n"); + BM_CKFATAL(-ENOMEM); + } + _glthread_UNLOCK_MUTEX(buf->mutex); +} + + + +void +driGenBuffers(struct _DriBufferPool *pool, + const char *name, + unsigned n, + struct _DriBufferObject *buffers[], + unsigned alignment, unsigned flags, unsigned hint) +{ + struct _DriBufferObject *buf; + int i; + + flags = (flags) ? flags : DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_MEM_VRAM | + DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE; + + + for (i = 0; i < n; ++i) { + buf = (struct _DriBufferObject *) calloc(1, sizeof(*buf)); + if (!buf) + BM_CKFATAL(-ENOMEM); + + _glthread_INIT_MUTEX(buf->mutex); + _glthread_LOCK_MUTEX(buf->mutex); + _glthread_LOCK_MUTEX(bmMutex); + buf->refCount = 1; + _glthread_UNLOCK_MUTEX(bmMutex); + buf->flags = flags; + buf->hint = hint; + buf->name = name; + buf->alignment = alignment; + buf->pool = pool; + _glthread_UNLOCK_MUTEX(buf->mutex); + buffers[i] = buf; + } +} + +void +driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]) +{ + int i; + + for (i = 0; i < n; ++i) { + driBOUnReference(buffers[i]); + } +} + + +void +driInitBufMgr(int fd) +{ + ; +} + + +void +driBOCreateList(int target, drmBOList * list) +{ + _glthread_LOCK_MUTEX(bmMutex); + BM_CKFATAL(drmBOCreateList(20, list)); + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driBOResetList(drmBOList * list) +{ + _glthread_LOCK_MUTEX(bmMutex); + BM_CKFATAL(drmBOResetList(list)); + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf, + unsigned flags, unsigned mask) +{ + int newItem; + + _glthread_LOCK_MUTEX(buf->mutex); + _glthread_LOCK_MUTEX(bmMutex); + BM_CKFATAL(drmAddValidateItem(list, driBOKernel(buf), + flags, mask, &newItem)); + _glthread_UNLOCK_MUTEX(bmMutex); + + /* + * Tell userspace pools to validate the buffer. This should be a + * noop if the pool is already validated. + * FIXME: We should have a list for this as well. + */ + + if (buf->pool->validate) { + BM_CKFATAL(buf->pool->validate(buf->pool, buf->private)); + } + + _glthread_UNLOCK_MUTEX(buf->mutex); +} + +void +driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence) +{ + _glthread_LOCK_MUTEX(buf->mutex); + BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence)); + _glthread_UNLOCK_MUTEX(buf->mutex); + +} + +void +driBOValidateList(int fd, drmBOList * list) +{ + _glthread_LOCK_MUTEX(bmMutex); + BM_CKFATAL(drmBOValidateList(fd, list)); + _glthread_UNLOCK_MUTEX(bmMutex); +} + +void +driPoolTakeDown(struct _DriBufferPool *pool) +{ + pool->takeDown(pool); + +} diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.h b/src/mesa/drivers/dri/common/dri_bufmgr.h new file mode 100644 index 00000000000..426b4c8331c --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_bufmgr.h @@ -0,0 +1,96 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström + * Keith Whitwell + */ + +#ifndef _DRI_BUFMGR_H_ +#define _DRI_BUFMGR_H_ +#include + + +struct _DriFenceObject; +struct _DriBufferObject; +struct _DriBufferPool; + +extern struct _DriFenceObject *driFenceBuffers(int fd, char *name, + int shareable); + +extern void driFenceReference(struct _DriFenceObject *fence); + +extern void driFenceUnReference(struct _DriFenceObject *fence); + +extern void +driFenceFinish(struct _DriFenceObject *fence, unsigned type, int lazy); + +extern int driFenceSignaled(struct _DriFenceObject *fence, unsigned type); + +/* + * Return a pointer to the libdrm buffer object this DriBufferObject + * uses. + */ + +extern drmBO *driBOKernel(struct _DriBufferObject *buf); +extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags, + unsigned hint); +extern void driBOUnmap(struct _DriBufferObject *buf); +extern unsigned long driBOOffset(struct _DriBufferObject *buf); +extern unsigned driBOFlags(struct _DriBufferObject *buf); +extern void driBOReference(struct _DriBufferObject *buf); +extern void driBOUnReference(struct _DriBufferObject *buf); +extern void driBOData(struct _DriBufferObject *r_buf, + unsigned size, const void *data, unsigned flags); +extern void driBOSubData(struct _DriBufferObject *buf, + unsigned long offset, unsigned long size, + const void *data); +extern void driBOGetSubData(struct _DriBufferObject *buf, + unsigned long offset, unsigned long size, + void *data); +extern void driGenBuffers(struct _DriBufferPool *pool, + const char *name, + unsigned n, + struct _DriBufferObject *buffers[], + unsigned alignment, unsigned flags, unsigned hint); +extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]); +extern void driInitBufMgr(int fd); +extern void driBOCreateList(int target, drmBOList * list); +extern void driBOResetList(drmBOList * list); +extern void driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf, + unsigned flags, unsigned mask); +extern void driBOValidateList(int fd, drmBOList * list); + +extern void driBOFence(struct _DriBufferObject *buf, + struct _DriFenceObject *fence); + +extern void driPoolTakeDown(struct _DriBufferPool *pool); +extern void driBOSetStatic(struct _DriBufferObject *buf, + unsigned long offset, + unsigned long size, void *virtual, unsigned flags); + +#endif diff --git a/src/mesa/drivers/dri/common/dri_bufpool.h b/src/mesa/drivers/dri/common/dri_bufpool.h new file mode 100644 index 00000000000..98b0d031b54 --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_bufpool.h @@ -0,0 +1,84 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström + */ + +#ifndef _DRI_BUFPOOL_H_ +#define _DRI_BUFPOOL_H_ + +#include +struct _DriFenceObject; + +typedef struct _DriBufferPool +{ + int fd; + int (*map) (struct _DriBufferPool * pool, void *private, + unsigned flags, int hint, void **virtual); + int (*unmap) (struct _DriBufferPool * pool, void *private); + int (*destroy) (struct _DriBufferPool * pool, void *private); + unsigned long (*offset) (struct _DriBufferPool * pool, void *private); + unsigned (*flags) (struct _DriBufferPool * pool, void *private); + unsigned long (*size) (struct _DriBufferPool * pool, void *private); + void *(*create) (struct _DriBufferPool * pool, unsigned long size, + unsigned flags, unsigned hint, unsigned alignment); + int (*fence) (struct _DriBufferPool * pool, void *private, + struct _DriFenceObject * fence); + drmBO *(*kernel) (struct _DriBufferPool * pool, void *private); + int (*validate) (struct _DriBufferPool * pool, void *private); + void *(*setstatic) (struct _DriBufferPool * pool, unsigned long offset, + unsigned long size, void *virtual, unsigned flags); + void (*takeDown) (struct _DriBufferPool * pool); + void *data; +} DriBufferPool; + +extern void bmError(int val, const char *file, const char *function, + int line); +#define BM_CKFATAL(val) \ + do{ \ + int tstVal = (val); \ + if (tstVal) \ + bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \ + } while(0); + + + + + +/* + * Builtin pools. + */ + +/* + * Kernel buffer objects. Size in multiples of page size. Page size aligned. + */ + +extern struct _DriBufferPool *driDRMPoolInit(int fd); +extern struct _DriBufferPool *driDRMStaticPoolInit(int fd); + +#endif diff --git a/src/mesa/drivers/dri/common/dri_drmpool.c b/src/mesa/drivers/dri/common/dri_drmpool.c new file mode 100644 index 00000000000..845b604784d --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_drmpool.c @@ -0,0 +1,211 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström + */ + +#include +#include +#include "dri_bufpool.h" + +/* + * Buffer pool implementation using DRM buffer objects as DRI buffer objects. + */ + +static void * +pool_create(struct _DriBufferPool *pool, + unsigned long size, unsigned flags, unsigned hint, + unsigned alignment) +{ + drmBO *buf = (drmBO *) malloc(sizeof(*buf)); + int ret; + + if (!buf) + return NULL; + + if (alignment && ((4096 % alignment) != 0)) + return NULL; + + ret = drmBOCreate(pool->fd, NULL, 0, size, NULL, drm_bo_type_dc, + flags, hint, buf); + + if (ret) { + free(buf); + return NULL; + } + + return (void *) buf; +} + +static int +pool_destroy(struct _DriBufferPool *pool, void *private) +{ + drmBO *buf = (drmBO *) private; + return drmBODestroy(pool->fd, buf); +} + +static int +pool_map(struct _DriBufferPool *pool, void *private, unsigned flags, + int hint, void **virtual) +{ + drmBO *buf = (drmBO *) private; + + return drmBOMap(pool->fd, buf, flags, hint, virtual); +} + +static int +pool_unmap(struct _DriBufferPool *pool, void *private) +{ + drmBO *buf = (drmBO *) private; + return drmBOUnmap(pool->fd, buf); +} + +static unsigned long +pool_offset(struct _DriBufferPool *pool, void *private) +{ + drmBO *buf = (drmBO *) private; + return buf->offset; +} + +static unsigned +pool_flags(struct _DriBufferPool *pool, void *private) +{ + drmBO *buf = (drmBO *) private; + return buf->flags; +} + + +static unsigned long +pool_size(struct _DriBufferPool *pool, void *private) +{ + drmBO *buf = (drmBO *) private; + return buf->size; +} + +static int +pool_fence(struct _DriBufferPool *pool, void *private, + struct _DriFenceObject *fence) +{ + /* + * Noop. The kernel handles all fencing. + */ + + return 0; +} + +static drmBO * +pool_kernel(struct _DriBufferPool *pool, void *private) +{ + return (drmBO *) private; +} + +void +pool_takedown(struct _DriBufferPool *pool) +{ + free(pool); +} + + +struct _DriBufferPool * +driDRMPoolInit(int fd) +{ + struct _DriBufferPool *pool; + + pool = (struct _DriBufferPool *) malloc(sizeof(*pool)); + + if (!pool) + return NULL; + + pool->fd = fd; + pool->map = &pool_map; + pool->unmap = &pool_unmap; + pool->destroy = &pool_destroy; + pool->offset = &pool_offset; + pool->flags = &pool_flags; + pool->size = &pool_size; + pool->create = &pool_create; + pool->fence = &pool_fence; + pool->kernel = &pool_kernel; + pool->validate = NULL; + pool->setstatic = NULL; + pool->takeDown = &pool_takedown; + pool->data = NULL; + return pool; +} + + +static void * +pool_setstatic(struct _DriBufferPool *pool, unsigned long offset, + unsigned long size, void *virtual, unsigned flags) +{ + drmBO *buf = (drmBO *) malloc(sizeof(*buf)); + int ret; + + if (!buf) + return NULL; + + ret = drmBOCreate(pool->fd, NULL, offset, size, NULL, drm_bo_type_fake, + flags, 0, buf); + + if (ret) { + free(buf); + return NULL; + } + + buf->virtual = virtual; + + return (void *) buf; +} + + +struct _DriBufferPool * +driDRMStaticPoolInit(int fd) +{ + struct _DriBufferPool *pool; + + pool = (struct _DriBufferPool *) malloc(sizeof(*pool)); + + if (!pool) + return NULL; + + pool->fd = fd; + pool->map = &pool_map; + pool->unmap = &pool_unmap; + pool->destroy = &pool_destroy; + pool->offset = &pool_offset; + pool->flags = &pool_flags; + pool->size = &pool_size; + pool->create = NULL; + pool->fence = &pool_fence; + pool->kernel = &pool_kernel; + pool->validate = NULL; + pool->setstatic = &pool_setstatic; + pool->takeDown = &pool_takedown; + pool->data = NULL; + return pool; +} diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 64f54441de2..f73363bd811 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -50,8 +50,7 @@ DRIVER_SOURCES = \ intel_tris.c \ intel_fbo.c \ intel_depthstencil.c \ - intel_bufmgr.c - + intel_batchpool.c C_SOURCES = \ $(COMMON_SOURCES) \ $(DRIVER_SOURCES) diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index b66ca310592..2ff8621c42f 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -38,36 +38,38 @@ * Mesa's Driver Functions ***************************************/ -static const struct dri_extension i830_extensions[] = -{ - { "GL_ARB_texture_env_crossbar", NULL }, - { NULL, NULL } +static const struct dri_extension i830_extensions[] = { + {"GL_ARB_texture_env_crossbar", NULL}, + {NULL, NULL} }; -static void i830InitDriverFunctions( struct dd_function_table *functions ) +static void +i830InitDriverFunctions(struct dd_function_table *functions) { - intelInitDriverFunctions( functions ); - i830InitStateFuncs( functions ); - i830InitTextureFuncs( functions ); + intelInitDriverFunctions(functions); + i830InitStateFuncs(functions); + i830InitTextureFuncs(functions); } -GLboolean i830CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) +GLboolean +i830CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate) { struct dd_function_table functions; struct i830_context *i830 = CALLOC_STRUCT(i830_context); struct intel_context *intel = &i830->intel; GLcontext *ctx = &intel->ctx; - if (!i830) return GL_FALSE; + if (!i830) + return GL_FALSE; - i830InitVtbl( i830 ); - i830InitDriverFunctions( &functions ); + i830InitVtbl(i830); + i830InitDriverFunctions(&functions); - if (!intelInitContext( intel, mesaVis, driContextPriv, - sharedContextPrivate, &functions )) { + if (!intelInitContext(intel, mesaVis, driContextPriv, + sharedContextPrivate, &functions)) { FREE(i830); return GL_FALSE; } @@ -82,22 +84,21 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis, ctx->Const.MaxTextureLevels = 12; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 11; - ctx->Const.MaxTextureRectSize = (1<<11); + ctx->Const.MaxTextureRectSize = (1 << 11); ctx->Const.MaxTextureUnits = I830_TEX_UNITS; - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - 18 * sizeof(GLfloat) ); + _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, + 18 * sizeof(GLfloat)); intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; - driInitExtensions( ctx, i830_extensions, GL_FALSE ); + driInitExtensions(ctx, i830_extensions, GL_FALSE); - i830InitState( i830 ); - i830InitMetaFuncs( i830 ); + i830InitState(i830); + i830InitMetaFuncs(i830); - _tnl_allow_vertex_fog( ctx, 1 ); - _tnl_allow_pixel_fog( ctx, 0 ); + _tnl_allow_vertex_fog(ctx, 1); + _tnl_allow_pixel_fog(ctx, 0); return GL_TRUE; } - diff --git a/src/mesa/drivers/dri/i915/i830_context.h b/src/mesa/drivers/dri/i915/i830_context.h index fa4ec222cd3..e5377b300aa 100644 --- a/src/mesa/drivers/dri/i915/i830_context.h +++ b/src/mesa/drivers/dri/i915/i830_context.h @@ -71,7 +71,7 @@ #define I830_CTXREG_AA 9 #define I830_CTXREG_FOGCOLOR 10 #define I830_CTXREG_BLENDCOLOR0 11 -#define I830_CTXREG_BLENDCOLOR1 12 +#define I830_CTXREG_BLENDCOLOR1 12 #define I830_CTXREG_VF 13 #define I830_CTXREG_VF2 14 #define I830_CTXREG_MCSB0 15 @@ -82,16 +82,16 @@ #define I830_STPREG_ST1 1 #define I830_STP_SETUP_SIZE 2 -#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */ +#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */ #define I830_TEXREG_TM0S1 1 #define I830_TEXREG_TM0S2 2 #define I830_TEXREG_TM0S3 3 #define I830_TEXREG_TM0S4 4 -#define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */ -#define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */ +#define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */ +#define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */ #define I830_TEX_SETUP_SIZE 7 -#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */ +#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */ struct i830_texture_object { @@ -101,7 +101,8 @@ struct i830_texture_object #define I830_TEX_UNITS 4 -struct i830_hw_state { +struct i830_hw_state +{ GLuint Ctx[I830_CTX_SETUP_SIZE]; GLuint Buffer[I830_DEST_SETUP_SIZE]; GLuint Stipple[I830_STP_SETUP_SIZE]; @@ -116,19 +117,19 @@ struct i830_hw_state { * be from a PBO or FBO. Just use the buffer id. Will have to do * this for draw and depth for FBO's... */ - struct buffer *tex_buffer[I830_TEX_UNITS]; + struct _DriBufferObject *tex_buffer[I830_TEX_UNITS]; GLuint tex_offset[I830_TEX_UNITS]; - - GLuint emitted; /* I810_UPLOAD_* */ + + GLuint emitted; /* I810_UPLOAD_* */ GLuint active; }; -struct i830_context +struct i830_context { struct intel_context intel; - + GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS]; - DECLARE_RENDERINPUTS(last_index_bitset); + DECLARE_RENDERINPUTS(last_index_bitset); struct i830_hw_state meta, initial, state, *current; }; @@ -153,52 +154,45 @@ do { \ /* i830_vtbl.c */ -extern void -i830InitVtbl( struct i830_context *i830 ); +extern void i830InitVtbl(struct i830_context *i830); /* i830_context.c */ -extern GLboolean -i830CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate); +extern GLboolean +i830CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); /* i830_tex.c, i830_texstate.c */ -extern void -i830UpdateTextureState( struct intel_context *intel ); +extern void i830UpdateTextureState(struct intel_context *intel); -extern void -i830InitTextureFuncs( struct dd_function_table *functions ); +extern void i830InitTextureFuncs(struct dd_function_table *functions); /* i830_texblend.c */ extern GLuint i830SetTexEnvCombine(struct i830_context *i830, - const struct gl_tex_env_combine_state * combine, GLint blendUnit, - GLuint texel_op, GLuint *state, const GLfloat *factor ); + const struct gl_tex_env_combine_state + *combine, GLint blendUnit, GLuint texel_op, + GLuint * state, const GLfloat * factor); -extern void -i830EmitTextureBlend( struct i830_context *i830 ); +extern void i830EmitTextureBlend(struct i830_context *i830); /* i830_state.c */ -extern void -i830InitStateFuncs( struct dd_function_table *functions ); +extern void i830InitStateFuncs(struct dd_function_table *functions); -extern void -i830EmitState( struct i830_context *i830 ); +extern void i830EmitState(struct i830_context *i830); -extern void -i830InitState( struct i830_context *i830 ); +extern void i830InitState(struct i830_context *i830); /* i830_metaops.c */ -extern void -i830InitMetaFuncs( struct i830_context *i830 ); +extern void i830InitMetaFuncs(struct i830_context *i830); extern void -i830RotateWindow(struct intel_context *intel, __DRIdrawablePrivate *dPriv, +i830RotateWindow(struct intel_context *intel, __DRIdrawablePrivate * dPriv, GLuint srcBuf); /*====================================================================== @@ -206,10 +200,9 @@ i830RotateWindow(struct intel_context *intel, __DRIdrawablePrivate *dPriv, * macros used previously: */ static INLINE struct i830_context * -i830_context( GLcontext *ctx ) +i830_context(GLcontext * ctx) { - return (struct i830_context *)ctx; + return (struct i830_context *) ctx; } #endif - diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c index 5297ef6da20..e499b86bef8 100644 --- a/src/mesa/drivers/dri/i915/i830_metaops.c +++ b/src/mesa/drivers/dri/i915/i830_metaops.c @@ -46,7 +46,7 @@ I830_UPLOAD_BUFFERS | \ I830_UPLOAD_STIPPLE | \ I830_UPLOAD_TEXBLEND(0) | \ - I830_UPLOAD_TEX(0)) + I830_UPLOAD_TEX(0)) #define SET_STATE( i830, STATE ) \ @@ -57,7 +57,8 @@ do { \ } while (0) -static void set_no_stencil_write( struct intel_context *intel ) +static void +set_no_stencil_write(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -71,7 +72,8 @@ static void set_no_stencil_write( struct intel_context *intel ) i830->meta.emitted &= ~I830_UPLOAD_CTX; } -static void set_no_depth_write( struct intel_context *intel ) +static void +set_no_depth_write(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -87,7 +89,8 @@ static void set_no_depth_write( struct intel_context *intel ) /* Set depth unit to replace. */ -static void set_depth_replace( struct intel_context *intel ) +static void +set_depth_replace(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -103,7 +106,8 @@ static void set_depth_replace( struct intel_context *intel ) */ i830->meta.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK; i830->meta.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC | - DEPTH_TEST_FUNC(COMPAREFUNC_ALWAYS)); + DEPTH_TEST_FUNC + (COMPAREFUNC_ALWAYS)); i830->meta.emitted &= ~I830_UPLOAD_CTX; } @@ -111,9 +115,9 @@ static void set_depth_replace( struct intel_context *intel ) /* Set stencil unit to replace always with the reference value. */ -static void set_stencil_replace( struct intel_context *intel, - GLuint s_mask, - GLuint s_clear) +static void +set_stencil_replace(struct intel_context *intel, + GLuint s_mask, GLuint s_clear) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -126,12 +130,13 @@ static void set_stencil_replace( struct intel_context *intel, */ i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK((s_mask&0xff))); + STENCIL_WRITE_MASK((s_mask & + 0xff))); /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE ) */ i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK); - i830->meta.Ctx[I830_CTXREG_STENCILTST] |= + i830->meta.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_PARMS | STENCIL_FAIL_OP(STENCILOP_REPLACE) | STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) | @@ -141,14 +146,14 @@ static void set_stencil_replace( struct intel_context *intel, */ i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff)); + STENCIL_TEST_MASK(0xff)); i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK | - ENABLE_STENCIL_TEST_FUNC_MASK); - i830->meta.Ctx[I830_CTXREG_STENCILTST] |= + ENABLE_STENCIL_TEST_FUNC_MASK); + i830->meta.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE | ENABLE_STENCIL_TEST_FUNC | - STENCIL_REF_VALUE((s_clear&0xff)) | + STENCIL_REF_VALUE((s_clear & 0xff)) | STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS)); @@ -157,41 +162,43 @@ static void set_stencil_replace( struct intel_context *intel, } -static void set_color_mask( struct intel_context *intel, GLboolean state ) +static void +set_color_mask(struct intel_context *intel, GLboolean state) { struct i830_context *i830 = i830_context(&intel->ctx); const GLuint mask = ((1 << WRITEMASK_RED_SHIFT) | - (1 << WRITEMASK_GREEN_SHIFT) | - (1 << WRITEMASK_BLUE_SHIFT) | - (1 << WRITEMASK_ALPHA_SHIFT)); + (1 << WRITEMASK_GREEN_SHIFT) | + (1 << WRITEMASK_BLUE_SHIFT) | + (1 << WRITEMASK_ALPHA_SHIFT)); i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~mask; if (state) { - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= - (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask); + i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= + (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask); } - + i830->meta.emitted &= ~I830_UPLOAD_CTX; } /* Installs a one-stage passthrough texture blend pipeline. Is there * more that can be done to turn off texturing? */ -static void set_no_texture( struct intel_context *intel ) +static void +set_no_texture(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); static const struct gl_tex_env_combine_state comb = { GL_NONE, GL_NONE, - { GL_TEXTURE, 0, 0, }, { GL_TEXTURE, 0, 0, }, - { GL_SRC_COLOR, 0, 0 }, { GL_SRC_ALPHA, 0, 0 }, + {GL_TEXTURE, 0, 0,}, {GL_TEXTURE, 0, 0,}, + {GL_SRC_COLOR, 0, 0}, {GL_SRC_ALPHA, 0, 0}, 0, 0, 0, 0 }; i830->meta.TexBlendWordsUsed[0] = - i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0, - i830->meta.TexBlend[0], NULL); + i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0, + i830->meta.TexBlend[0], NULL); i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE; i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0); @@ -200,19 +207,22 @@ static void set_no_texture( struct intel_context *intel ) /* Set up a single element blend stage for 'replace' texturing with no * funny ops. */ -static void set_texture_blend_replace( struct intel_context *intel ) +static void +set_texture_blend_replace(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); static const struct gl_tex_env_combine_state comb = { GL_REPLACE, GL_REPLACE, - { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, }, { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, }, - { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR }, { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, + {GL_TEXTURE, GL_TEXTURE, GL_TEXTURE,}, {GL_TEXTURE, GL_TEXTURE, + GL_TEXTURE,}, + {GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR}, {GL_SRC_ALPHA, GL_SRC_ALPHA, + GL_SRC_ALPHA}, 0, 0, 1, 1 }; i830->meta.TexBlendWordsUsed[0] = - i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0, - i830->meta.TexBlend[0], NULL); + i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0, + i830->meta.TexBlend[0], NULL); i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE; i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0); @@ -226,13 +236,11 @@ static void set_texture_blend_replace( struct intel_context *intel ) /* Set up an arbitary piece of memory as a rectangular texture * (including the front or back buffer). */ -static GLboolean set_tex_rect_source( struct intel_context *intel, - struct buffer *buffer, - GLuint offset, - GLuint pitch, - GLuint height, - GLenum format, - GLenum type) +static GLboolean +set_tex_rect_source(struct intel_context *intel, + struct _DriBufferObject *buffer, + GLuint offset, + GLuint pitch, GLuint height, GLenum format, GLenum type) { struct i830_context *i830 = i830_context(&intel->ctx); GLuint *setup = i830->meta.Tex[0]; @@ -250,42 +258,42 @@ static GLboolean set_tex_rect_source( struct intel_context *intel, switch (type) { case GL_UNSIGNED_INT_8_8_8_8_REV: case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); - cpp = 4; - break; + textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); + cpp = 4; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_RGBA: switch (type) { case GL_UNSIGNED_INT_8_8_8_8_REV: case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); - cpp = 4; - break; + textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); + cpp = 4; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_BGR: switch (type) { case GL_UNSIGNED_SHORT_5_6_5_REV: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; + textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); + cpp = 2; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_RGB: switch (type) { case GL_UNSIGNED_SHORT_5_6_5: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; + textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); + cpp = 2; + break; default: - return GL_FALSE; + return GL_FALSE; } break; @@ -296,53 +304,58 @@ static GLboolean set_tex_rect_source( struct intel_context *intel, i830->meta.tex_buffer[0] = buffer; i830->meta.tex_offset[0] = offset; - setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - (LOAD_TEXTURE_MAP0 << 0) | 4); + setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + (LOAD_TEXTURE_MAP0 << 0) | 4); setup[I830_TEXREG_TM0S1] = (((height - 1) << TM0S1_HEIGHT_SHIFT) | - ((pitch - 1) << TM0S1_WIDTH_SHIFT) | - textureFormat); - setup[I830_TEXREG_TM0S2] = (((((pitch * cpp) / 4) - 1) << TM0S2_PITCH_SHIFT) | - TM0S2_CUBE_FACE_ENA_MASK); + ((pitch - 1) << TM0S1_WIDTH_SHIFT) | + textureFormat); + setup[I830_TEXREG_TM0S2] = + (((((pitch * cpp) / 4) - + 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK); - setup[I830_TEXREG_TM0S3] = ( (((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT) | - (FILTER_NEAREST << TM0S3_MIN_FILTER_SHIFT) | - (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT) | - (FILTER_NEAREST << TM0S3_MAG_FILTER_SHIFT)); + setup[I830_TEXREG_TM0S3] = + ((((numLevels - + 1) * + 4) << TM0S3_MIN_MIP_SHIFT) | (FILTER_NEAREST << + TM0S3_MIN_FILTER_SHIFT) | + (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT) | (FILTER_NEAREST << + TM0S3_MAG_FILTER_SHIFT)); setup[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(0)); setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD | - MAP_UNIT(0) | - ENABLE_TEXCOORD_PARAMS | - TEXCOORDS_ARE_IN_TEXELUNITS | - TEXCOORDTYPE_CARTESIAN | - ENABLE_ADDR_V_CNTL | - TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) | - ENABLE_ADDR_U_CNTL | - TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP)); + MAP_UNIT(0) | + ENABLE_TEXCOORD_PARAMS | + TEXCOORDS_ARE_IN_TEXELUNITS | + TEXCOORDTYPE_CARTESIAN | + ENABLE_ADDR_V_CNTL | + TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) | + ENABLE_ADDR_U_CNTL | + TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP)); i830->meta.emitted &= ~I830_UPLOAD_TEX(0); return GL_TRUE; } -static void set_vertex_format( struct intel_context *intel ) +static void +set_vertex_format(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); - i830->meta.Ctx[I830_CTXREG_VF] = (_3DSTATE_VFT0_CMD | - VFT0_TEX_COUNT(1) | - VFT0_DIFFUSE | - VFT0_XYZ); + i830->meta.Ctx[I830_CTXREG_VF] = (_3DSTATE_VFT0_CMD | + VFT0_TEX_COUNT(1) | + VFT0_DIFFUSE | VFT0_XYZ); i830->meta.Ctx[I830_CTXREG_VF2] = (_3DSTATE_VFT1_CMD | - VFT1_TEX0_FMT(TEXCOORDFMT_2D) | - VFT1_TEX1_FMT(TEXCOORDFMT_2D) | - VFT1_TEX2_FMT(TEXCOORDFMT_2D) | - VFT1_TEX3_FMT(TEXCOORDFMT_2D)); + VFT1_TEX0_FMT(TEXCOORDFMT_2D) | + VFT1_TEX1_FMT(TEXCOORDFMT_2D) | + VFT1_TEX2_FMT(TEXCOORDFMT_2D) | + VFT1_TEX3_FMT(TEXCOORDFMT_2D)); i830->meta.emitted &= ~I830_UPLOAD_CTX; } -static void meta_import_pixel_state( struct intel_context *intel ) +static void +meta_import_pixel_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -352,23 +365,30 @@ static void meta_import_pixel_state( struct intel_context *intel ) i830->meta.Ctx[I830_CTXREG_STATE4] = i830->state.Ctx[I830_CTXREG_STATE4]; i830->meta.Ctx[I830_CTXREG_STATE5] = i830->state.Ctx[I830_CTXREG_STATE5]; i830->meta.Ctx[I830_CTXREG_IALPHAB] = i830->state.Ctx[I830_CTXREG_IALPHAB]; - i830->meta.Ctx[I830_CTXREG_STENCILTST] = i830->state.Ctx[I830_CTXREG_STENCILTST]; - i830->meta.Ctx[I830_CTXREG_ENABLES_1] = i830->state.Ctx[I830_CTXREG_ENABLES_1]; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] = i830->state.Ctx[I830_CTXREG_ENABLES_2]; + i830->meta.Ctx[I830_CTXREG_STENCILTST] = + i830->state.Ctx[I830_CTXREG_STENCILTST]; + i830->meta.Ctx[I830_CTXREG_ENABLES_1] = + i830->state.Ctx[I830_CTXREG_ENABLES_1]; + i830->meta.Ctx[I830_CTXREG_ENABLES_2] = + i830->state.Ctx[I830_CTXREG_ENABLES_2]; i830->meta.Ctx[I830_CTXREG_AA] = i830->state.Ctx[I830_CTXREG_AA]; - i830->meta.Ctx[I830_CTXREG_FOGCOLOR] = i830->state.Ctx[I830_CTXREG_FOGCOLOR]; - i830->meta.Ctx[I830_CTXREG_BLENDCOLOR0] = i830->state.Ctx[I830_CTXREG_BLENDCOLOR0]; - i830->meta.Ctx[I830_CTXREG_BLENDCOLOR1] = i830->state.Ctx[I830_CTXREG_BLENDCOLOR1]; + i830->meta.Ctx[I830_CTXREG_FOGCOLOR] = + i830->state.Ctx[I830_CTXREG_FOGCOLOR]; + i830->meta.Ctx[I830_CTXREG_BLENDCOLOR0] = + i830->state.Ctx[I830_CTXREG_BLENDCOLOR0]; + i830->meta.Ctx[I830_CTXREG_BLENDCOLOR1] = + i830->state.Ctx[I830_CTXREG_BLENDCOLOR1]; i830->meta.Ctx[I830_CTXREG_MCSB0] = i830->state.Ctx[I830_CTXREG_MCSB0]; i830->meta.Ctx[I830_CTXREG_MCSB1] = i830->state.Ctx[I830_CTXREG_MCSB1]; - + i830->meta.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK; i830->meta.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; i830->meta.emitted &= ~I830_UPLOAD_CTX; - i830->meta.Buffer[I830_DESTREG_SENABLE] = i830->state.Buffer[I830_DESTREG_SENABLE]; + i830->meta.Buffer[I830_DESTREG_SENABLE] = + i830->state.Buffer[I830_DESTREG_SENABLE]; i830->meta.Buffer[I830_DESTREG_SR1] = i830->state.Buffer[I830_DESTREG_SR1]; i830->meta.Buffer[I830_DESTREG_SR2] = i830->state.Buffer[I830_DESTREG_SR2]; i830->meta.emitted &= ~I830_UPLOAD_BUFFERS; @@ -378,9 +398,10 @@ static void meta_import_pixel_state( struct intel_context *intel ) /* Select between front and back draw buffers. */ -static void meta_draw_region( struct intel_context *intel, - struct intel_region *draw_region, - struct intel_region *depth_region ) +static void +meta_draw_region(struct intel_context *intel, + struct intel_region *draw_region, + struct intel_region *depth_region) { struct i830_context *i830 = i830_context(&intel->ctx); GLuint format; @@ -388,8 +409,8 @@ static void meta_draw_region( struct intel_context *intel, intel_region_release(intel, &i830->meta.draw_region); intel_region_reference(&i830->meta.draw_region, draw_region); - - intel_region_release(intel, &i830->meta.depth_region); + + intel_region_release(intel, &i830->meta.depth_region); intel_region_reference(&i830->meta.depth_region, depth_region); /* XXX FBO: grab code from i915 meta_draw_region */ @@ -403,16 +424,14 @@ static void meta_draw_region( struct intel_context *intel, if (depth_region) { if (depth_region->cpp == 2) - depth_format = DEPTH_FRMT_16_FIXED; + depth_format = DEPTH_FRMT_16_FIXED; else - depth_format = DEPTH_FRMT_24_FIXED_8_OTHER; + depth_format = DEPTH_FRMT_24_FIXED_8_OTHER; } - i830->meta.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - format | - DEPTH_IS_Z | - depth_format); + i830->meta.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + format | DEPTH_IS_Z | depth_format); i830->meta.emitted &= ~I830_UPLOAD_BUFFERS; } @@ -422,10 +441,11 @@ static void meta_draw_region( struct intel_context *intel, * current GL state and used for other purposes than simply rendering * incoming triangles. */ -static void install_meta_state( struct intel_context *intel ) +static void +install_meta_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); - memcpy(&i830->meta, &i830->initial, sizeof(i830->meta) ); + memcpy(&i830->meta, &i830->initial, sizeof(i830->meta)); i830->meta.active = ACTIVE; i830->meta.emitted = 0; @@ -435,7 +455,8 @@ static void install_meta_state( struct intel_context *intel ) set_no_texture(intel); } -static void leave_meta_state( struct intel_context *intel ) +static void +leave_meta_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); intel_region_release(intel, &i830->meta.draw_region); @@ -446,7 +467,8 @@ static void leave_meta_state( struct intel_context *intel ) -void i830InitMetaFuncs( struct i830_context *i830 ) +void +i830InitMetaFuncs(struct i830_context *i830) { i830->intel.vtbl.install_meta_state = install_meta_state; i830->intel.vtbl.leave_meta_state = leave_meta_state; @@ -461,8 +483,3 @@ void i830InitMetaFuncs( struct i830_context *i830 ) i830->intel.vtbl.meta_draw_region = meta_draw_region; i830->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state; } - - - - - diff --git a/src/mesa/drivers/dri/i915/i830_reg.h b/src/mesa/drivers/dri/i915/i830_reg.h index ff08683d7e3..24ac5245005 100644 --- a/src/mesa/drivers/dri/i915/i830_reg.h +++ b/src/mesa/drivers/dri/i915/i830_reg.h @@ -554,8 +554,8 @@ #define MAPSURF_4BIT_INDEXED (7<<6) #define TM0S1_MT_FORMAT_MASK (0x7 << 3) #define TM0S1_MT_FORMAT_SHIFT 3 -#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */ -#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */ +#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */ +#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */ #define MT_8BIT_IDX_ARGB1555 (1<<3) #define MT_8BIT_IDX_ARGB4444 (2<<3) #define MT_8BIT_IDX_AY88 (3<<3) @@ -563,9 +563,9 @@ #define MT_8BIT_IDX_BUMP_88DVDU (5<<3) #define MT_8BIT_IDX_BUMP_655LDVDU (6<<3) #define MT_8BIT_IDX_ARGB8888 (7<<3) -#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */ +#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */ #define MT_8BIT_L8 (1<<3) -#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */ +#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */ #define MT_16BIT_ARGB1555 (1<<3) #define MT_16BIT_ARGB4444 (2<<3) #define MT_16BIT_AY88 (3<<3) @@ -573,16 +573,16 @@ #define MT_16BIT_BUMP_88DVDU (5<<3) #define MT_16BIT_BUMP_655LDVDU (6<<3) #define MT_16BIT_DIB_RGB565_8888 (7<<3) -#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */ +#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */ #define MT_32BIT_ABGR8888 (1<<3) #define MT_32BIT_BUMP_XLDVDU_8888 (6<<3) #define MT_32BIT_DIB_8888 (7<<3) -#define MT_411_YUV411 (0<<3) /* SURFACE_411 */ -#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */ +#define MT_411_YUV411 (0<<3) /* SURFACE_411 */ +#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */ #define MT_422_YCRCB_NORMAL (1<<3) #define MT_422_YCRCB_SWAPUV (2<<3) #define MT_422_YCRCB_SWAPUVY (3<<3) -#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */ +#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */ #define MT_COMPRESS_DXT2_3 (1<<3) #define MT_COMPRESS_DXT4_5 (2<<3) #define MT_COMPRESS_FXT1 (3<<3) diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index 5c0a3bffc24..743c25c6301 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -42,7 +42,7 @@ #include "i830_reg.h" static void -i830StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref, +i830StencilFuncSeparate(GLcontext * ctx, GLenum face, GLenum func, GLint ref, GLuint mask) { struct i830_context *i830 = i830_context(ctx); @@ -50,29 +50,29 @@ i830StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref, mask = mask & 0xff; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(func), ref, mask); + _mesa_lookup_enum_by_nr(func), ref, mask); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(mask)); + STENCIL_TEST_MASK(mask)); i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK | - ENABLE_STENCIL_TEST_FUNC_MASK); + ENABLE_STENCIL_TEST_FUNC_MASK); i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE | - ENABLE_STENCIL_TEST_FUNC | - STENCIL_REF_VALUE(ref) | - STENCIL_TEST_FUNC(test)); + ENABLE_STENCIL_TEST_FUNC | + STENCIL_REF_VALUE(ref) | + STENCIL_TEST_FUNC(test)); } static void -i830StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) +i830StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask) { struct i830_context *i830 = i830_context(ctx); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask); mask = mask & 0xff; @@ -80,106 +80,107 @@ i830StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(mask)); + STENCIL_WRITE_MASK(mask)); } static void -i830StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail, +i830StencilOpSeparate(GLcontext * ctx, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { struct i830_context *i830 = i830_context(ctx); int fop, dfop, dpop; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(fail), - _mesa_lookup_enum_by_nr(zfail), - _mesa_lookup_enum_by_nr(zpass)); + _mesa_lookup_enum_by_nr(fail), + _mesa_lookup_enum_by_nr(zfail), _mesa_lookup_enum_by_nr(zpass)); - fop = 0; dfop = 0; dpop = 0; + fop = 0; + dfop = 0; + dpop = 0; - switch(fail) { - case GL_KEEP: - fop = STENCILOP_KEEP; + switch (fail) { + case GL_KEEP: + fop = STENCILOP_KEEP; break; - case GL_ZERO: - fop = STENCILOP_ZERO; + case GL_ZERO: + fop = STENCILOP_ZERO; break; - case GL_REPLACE: - fop = STENCILOP_REPLACE; + case GL_REPLACE: + fop = STENCILOP_REPLACE; break; - case GL_INCR: + case GL_INCR: fop = STENCILOP_INCRSAT; break; - case GL_DECR: + case GL_DECR: fop = STENCILOP_DECRSAT; break; case GL_INCR_WRAP: - fop = STENCILOP_INCR; + fop = STENCILOP_INCR; break; case GL_DECR_WRAP: - fop = STENCILOP_DECR; + fop = STENCILOP_DECR; break; - case GL_INVERT: - fop = STENCILOP_INVERT; + case GL_INVERT: + fop = STENCILOP_INVERT; break; - default: + default: break; } - switch(zfail) { - case GL_KEEP: - dfop = STENCILOP_KEEP; + switch (zfail) { + case GL_KEEP: + dfop = STENCILOP_KEEP; break; - case GL_ZERO: - dfop = STENCILOP_ZERO; + case GL_ZERO: + dfop = STENCILOP_ZERO; break; - case GL_REPLACE: - dfop = STENCILOP_REPLACE; + case GL_REPLACE: + dfop = STENCILOP_REPLACE; break; - case GL_INCR: + case GL_INCR: dfop = STENCILOP_INCRSAT; break; - case GL_DECR: + case GL_DECR: dfop = STENCILOP_DECRSAT; break; case GL_INCR_WRAP: - dfop = STENCILOP_INCR; + dfop = STENCILOP_INCR; break; case GL_DECR_WRAP: - dfop = STENCILOP_DECR; + dfop = STENCILOP_DECR; break; - case GL_INVERT: - dfop = STENCILOP_INVERT; + case GL_INVERT: + dfop = STENCILOP_INVERT; break; - default: + default: break; } - switch(zpass) { - case GL_KEEP: - dpop = STENCILOP_KEEP; + switch (zpass) { + case GL_KEEP: + dpop = STENCILOP_KEEP; break; - case GL_ZERO: - dpop = STENCILOP_ZERO; + case GL_ZERO: + dpop = STENCILOP_ZERO; break; - case GL_REPLACE: - dpop = STENCILOP_REPLACE; + case GL_REPLACE: + dpop = STENCILOP_REPLACE; break; - case GL_INCR: + case GL_INCR: dpop = STENCILOP_INCRSAT; break; - case GL_DECR: + case GL_DECR: dpop = STENCILOP_DECRSAT; break; case GL_INCR_WRAP: - dpop = STENCILOP_INCR; + dpop = STENCILOP_INCR; break; case GL_DECR_WRAP: - dpop = STENCILOP_DECR; + dpop = STENCILOP_DECR; break; - case GL_INVERT: - dpop = STENCILOP_INVERT; + case GL_INVERT: + dpop = STENCILOP_INVERT; break; - default: + default: break; } @@ -187,12 +188,15 @@ i830StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail, I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK); i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_PARMS | - STENCIL_FAIL_OP(fop) | - STENCIL_PASS_DEPTH_FAIL_OP(dfop) | - STENCIL_PASS_DEPTH_PASS_OP(dpop)); + STENCIL_FAIL_OP(fop) | + STENCIL_PASS_DEPTH_FAIL_OP + (dfop) | + STENCIL_PASS_DEPTH_PASS_OP + (dpop)); } -static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) +static void +i830AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref) { struct i830_context *i830 = i830_context(ctx); int test = intel_translate_compare_func(func); @@ -200,14 +204,14 @@ static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) GLuint refInt; UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref); - refInt = (GLuint)refByte; + refInt = (GLuint) refByte; I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE2] &= ~ALPHA_TEST_REF_MASK; i830->state.Ctx[I830_CTXREG_STATE2] |= (ENABLE_ALPHA_TEST_FUNC | - ENABLE_ALPHA_REF_VALUE | - ALPHA_TEST_FUNC(test) | - ALPHA_REF_VALUE(refInt)); + ENABLE_ALPHA_REF_VALUE | + ALPHA_TEST_FUNC(test) | + ALPHA_REF_VALUE(refInt)); } /** @@ -220,7 +224,8 @@ static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) * This function is substantially different from the old i830-specific driver. * I'm not sure which is correct. */ -static void i830EvalLogicOpBlendState(GLcontext *ctx) +static void +i830EvalLogicOpBlendState(GLcontext * ctx) { struct i830_context *i830 = i830_context(ctx); @@ -228,28 +233,31 @@ static void i830EvalLogicOpBlendState(GLcontext *ctx) if (ctx->Color._LogicOpEnabled) { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | - ENABLE_LOGIC_OP_MASK); + ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND | - ENABLE_LOGIC_OP); - } else if (ctx->Color.BlendEnabled) { + ENABLE_LOGIC_OP); + } + else if (ctx->Color.BlendEnabled) { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | - ENABLE_LOGIC_OP_MASK); + ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND | - DISABLE_LOGIC_OP); - } else { + DISABLE_LOGIC_OP); + } + else { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | - ENABLE_LOGIC_OP_MASK); + ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND | - DISABLE_LOGIC_OP); + DISABLE_LOGIC_OP); } } -static void i830BlendColor(GLcontext *ctx, const GLfloat color[4]) +static void +i830BlendColor(GLcontext * ctx, const GLfloat color[4]) { struct i830_context *i830 = i830_context(ctx); GLubyte r, g, b, a; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]); @@ -258,7 +266,8 @@ static void i830BlendColor(GLcontext *ctx, const GLfloat color[4]) UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]); I830_STATECHANGE(i830, I830_UPLOAD_CTX); - i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b; + i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = + (a << 24) | (r << 16) | (g << 8) | b; } /** @@ -267,7 +276,8 @@ static void i830BlendColor(GLcontext *ctx, const GLfloat color[4]) * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX) * change the interpretation of the blend function. */ -static void i830_set_blend_state( GLcontext * ctx ) +static void +i830_set_blend_state(GLcontext * ctx) { struct i830_context *i830 = i830_context(ctx); int funcA; @@ -278,71 +288,72 @@ static void i830_set_blend_state( GLcontext * ctx ) int s1; - funcRGB = SRC_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendSrcRGB ) ) - | DST_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendDstRGB ) ); + funcRGB = + SRC_BLND_FACT(intel_translate_blend_factor(ctx->Color.BlendSrcRGB)) + | DST_BLND_FACT(intel_translate_blend_factor(ctx->Color.BlendDstRGB)); - switch(ctx->Color.BlendEquationRGB) { + switch (ctx->Color.BlendEquationRGB) { case GL_FUNC_ADD: - eqnRGB = BLENDFUNC_ADD; + eqnRGB = BLENDFUNC_ADD; break; case GL_MIN: eqnRGB = BLENDFUNC_MIN; funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE); break; - case GL_MAX: + case GL_MAX: eqnRGB = BLENDFUNC_MAX; funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE); break; - case GL_FUNC_SUBTRACT: - eqnRGB = BLENDFUNC_SUB; + case GL_FUNC_SUBTRACT: + eqnRGB = BLENDFUNC_SUB; break; case GL_FUNC_REVERSE_SUBTRACT: - eqnRGB = BLENDFUNC_RVRSE_SUB; + eqnRGB = BLENDFUNC_RVRSE_SUB; break; default: - fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n", - __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB ); + fprintf(stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n", + __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB); return; } - funcA = SRC_ABLEND_FACT( intel_translate_blend_factor( ctx->Color.BlendSrcA ) ) - | DST_ABLEND_FACT( intel_translate_blend_factor( ctx->Color.BlendDstA ) ); + funcA = SRC_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.BlendSrcA)) + | DST_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.BlendDstA)); - switch(ctx->Color.BlendEquationA) { + switch (ctx->Color.BlendEquationA) { case GL_FUNC_ADD: - eqnA = BLENDFUNC_ADD; + eqnA = BLENDFUNC_ADD; break; - case GL_MIN: + case GL_MIN: eqnA = BLENDFUNC_MIN; funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE); break; - case GL_MAX: + case GL_MAX: eqnA = BLENDFUNC_MAX; funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE); break; - case GL_FUNC_SUBTRACT: - eqnA = BLENDFUNC_SUB; + case GL_FUNC_SUBTRACT: + eqnA = BLENDFUNC_SUB; break; case GL_FUNC_REVERSE_SUBTRACT: - eqnA = BLENDFUNC_RVRSE_SUB; + eqnA = BLENDFUNC_RVRSE_SUB; break; default: - fprintf( stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n", - __FUNCTION__, __LINE__, ctx->Color.BlendEquationA ); + fprintf(stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n", + __FUNCTION__, __LINE__, ctx->Color.BlendEquationA); return; } iab = eqnA | funcA - | _3DSTATE_INDPT_ALPHA_BLEND_CMD - | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR - | ENABLE_ALPHA_BLENDFUNC; + | _3DSTATE_INDPT_ALPHA_BLEND_CMD + | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR + | ENABLE_ALPHA_BLENDFUNC; s1 = eqnRGB | funcRGB - | _3DSTATE_MODES_1_CMD - | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR - | ENABLE_COLR_BLND_FUNC; + | _3DSTATE_MODES_1_CMD + | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR + | ENABLE_COLR_BLND_FUNC; - if ( (eqnA | funcA) != (eqnRGB | funcRGB) ) + if ((eqnA | funcA) != (eqnRGB | funcRGB)) iab |= ENABLE_INDPT_ALPHA_BLEND; else iab |= DISABLE_INDPT_ALPHA_BLEND; @@ -362,68 +373,70 @@ static void i830_set_blend_state( GLcontext * ctx ) i830EvalLogicOpBlendState(ctx); if (0) { - fprintf(stderr, "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n", - __FUNCTION__, __LINE__, - i830->state.Ctx[I830_CTXREG_STATE1], - i830->state.Ctx[I830_CTXREG_IALPHAB], - (ctx->Color.BlendEnabled) ? "en" : "dis"); + fprintf(stderr, + "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n", + __FUNCTION__, __LINE__, i830->state.Ctx[I830_CTXREG_STATE1], + i830->state.Ctx[I830_CTXREG_IALPHAB], + (ctx->Color.BlendEnabled) ? "en" : "dis"); } } -static void i830BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, - GLenum modeA) +static void +i830BlendEquationSeparate(GLcontext * ctx, GLenum modeRGB, GLenum modeA) { - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s -> %s, %s\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(modeRGB), - _mesa_lookup_enum_by_nr(modeA)); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s -> %s, %s\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(modeRGB), + _mesa_lookup_enum_by_nr(modeA)); (void) modeRGB; (void) modeA; - i830_set_blend_state( ctx ); + i830_set_blend_state(ctx); } -static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA ) +static void +i830BlendFuncSeparate(GLcontext * ctx, GLenum sfactorRGB, + GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA) { - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(sfactorRGB), - _mesa_lookup_enum_by_nr(dfactorRGB), - _mesa_lookup_enum_by_nr(sfactorA), - _mesa_lookup_enum_by_nr(dfactorA)); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(sfactorRGB), + _mesa_lookup_enum_by_nr(dfactorRGB), + _mesa_lookup_enum_by_nr(sfactorA), + _mesa_lookup_enum_by_nr(dfactorA)); (void) sfactorRGB; (void) dfactorRGB; (void) sfactorA; (void) dfactorA; - i830_set_blend_state( ctx ); + i830_set_blend_state(ctx); } -static void i830DepthFunc(GLcontext *ctx, GLenum func) +static void +i830DepthFunc(GLcontext * ctx, GLenum func) { struct i830_context *i830 = i830_context(ctx); int test = intel_translate_compare_func(func); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK; i830->state.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC | - DEPTH_TEST_FUNC(test)); + DEPTH_TEST_FUNC(test)); } -static void i830DepthMask(GLcontext *ctx, GLboolean flag) +static void +i830DepthMask(GLcontext * ctx, GLboolean flag) { struct i830_context *i830 = i830_context(ctx); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag); I830_STATECHANGE(i830, I830_UPLOAD_CTX); @@ -442,14 +455,15 @@ static void i830DepthMask(GLcontext *ctx, GLboolean flag) * The i830 supports a 4x4 stipple natively, GL wants 32x32. * Fortunately stipple is usually a repeating pattern. */ -static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask ) +static void +i830PolygonStipple(GLcontext * ctx, const GLubyte * mask) { struct i830_context *i830 = i830_context(ctx); const GLubyte *m = mask; GLubyte p[4]; - int i,j,k; + int i, j, k; int active = (ctx->Polygon.StippleFlag && - i830->intel.reduced_primitive == GL_TRIANGLES); + i830->intel.reduced_primitive == GL_TRIANGLES); GLuint newMask; if (active) { @@ -457,23 +471,26 @@ static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask ) i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; } - p[0] = mask[12] & 0xf; p[0] |= p[0] << 4; - p[1] = mask[8] & 0xf; p[1] |= p[1] << 4; - p[2] = mask[4] & 0xf; p[2] |= p[2] << 4; - p[3] = mask[0] & 0xf; p[3] |= p[3] << 4; + p[0] = mask[12] & 0xf; + p[0] |= p[0] << 4; + p[1] = mask[8] & 0xf; + p[1] |= p[1] << 4; + p[2] = mask[4] & 0xf; + p[2] |= p[2] << 4; + p[3] = mask[0] & 0xf; + p[3] |= p[3] << 4; - for (k = 0 ; k < 8 ; k++) - for (j = 3 ; j >= 0; j--) - for (i = 0 ; i < 4 ; i++, m++) - if (*m != p[j]) { - i830->intel.hw_stipple = 0; - return; - } + for (k = 0; k < 8; k++) + for (j = 3; j >= 0; j--) + for (i = 0; i < 4; i++, m++) + if (*m != p[j]) { + i830->intel.hw_stipple = 0; + return; + } newMask = (((p[0] & 0xf) << 0) | - ((p[1] & 0xf) << 4) | - ((p[2] & 0xf) << 8) | - ((p[3] & 0xf) << 12)); + ((p[1] & 0xf) << 4) | + ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12)); if (newMask == 0xffff || newMask == 0x0) { @@ -494,8 +511,8 @@ static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask ) /* ============================================================= * Hardware clipping */ -static void i830Scissor(GLcontext *ctx, GLint x, GLint y, - GLsizei w, GLsizei h) +static void +i830Scissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) { struct i830_context *i830 = i830_context(ctx); int x1, y1, x2, y2; @@ -508,9 +525,9 @@ static void i830Scissor(GLcontext *ctx, GLint x, GLint y, x2 = x + w - 1; y2 = y1 + h - 1; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__, - x, y, w, h); + x, y, w, h); x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1); y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1); @@ -522,12 +539,13 @@ static void i830Scissor(GLcontext *ctx, GLint x, GLint y, i830->state.Buffer[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff); } -static void i830LogicOp(GLcontext *ctx, GLenum opcode) +static void +i830LogicOp(GLcontext * ctx, GLenum opcode) { struct i830_context *i830 = i830_context(ctx); - int tmp = intel_translate_logic_op( opcode ); + int tmp = intel_translate_logic_op(opcode); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); @@ -537,12 +555,13 @@ static void i830LogicOp(GLcontext *ctx, GLenum opcode) -static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused) +static void +i830CullFaceFrontFace(GLcontext * ctx, GLenum unused) { struct i830_context *i830 = i830_context(ctx); GLuint mode; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); if (!ctx->Polygon.CullFlag) { @@ -552,9 +571,9 @@ static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused) mode = CULLMODE_CW; if (ctx->Polygon.CullFaceMode == GL_FRONT) - mode ^= (CULLMODE_CW ^ CULLMODE_CCW); + mode ^= (CULLMODE_CW ^ CULLMODE_CCW); if (ctx->Polygon.FrontFace != GL_CCW) - mode ^= (CULLMODE_CW ^ CULLMODE_CCW); + mode ^= (CULLMODE_CW ^ CULLMODE_CCW); } else { mode = CULLMODE_BOTH; @@ -565,18 +584,19 @@ static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused) i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode; } -static void i830LineWidth( GLcontext *ctx, GLfloat widthf ) +static void +i830LineWidth(GLcontext * ctx, GLfloat widthf) { - struct i830_context *i830 = i830_context( ctx ); + struct i830_context *i830 = i830_context(ctx); int width; int state5; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); - width = (int)(widthf * 2); + width = (int) (widthf * 2); CLAMP_SELF(width, 1, 15); - + state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK; state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width)); @@ -586,19 +606,20 @@ static void i830LineWidth( GLcontext *ctx, GLfloat widthf ) } } -static void i830PointSize(GLcontext *ctx, GLfloat size) +static void +i830PointSize(GLcontext * ctx, GLfloat size) { struct i830_context *i830 = i830_context(ctx); - GLint point_size = (int)size; + GLint point_size = (int) size; - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s\n", __FUNCTION__); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s\n", __FUNCTION__); CLAMP_SELF(point_size, 1, 256); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK; i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH | - FIXED_POINT_WIDTH(point_size)); + FIXED_POINT_WIDTH(point_size)); } @@ -606,23 +627,23 @@ static void i830PointSize(GLcontext *ctx, GLfloat size) * Color masks */ -static void i830ColorMask(GLcontext *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a) +static void +i830ColorMask(GLcontext * ctx, + GLboolean r, GLboolean g, GLboolean b, GLboolean a) { - struct i830_context *i830 = i830_context( ctx ); + struct i830_context *i830 = i830_context(ctx); GLuint tmp = 0; - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, + a); tmp = ((i830->state.Ctx[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) | - ENABLE_COLOR_MASK | - ENABLE_COLOR_WRITE | - ((!r) << WRITEMASK_RED_SHIFT) | - ((!g) << WRITEMASK_GREEN_SHIFT) | - ((!b) << WRITEMASK_BLUE_SHIFT) | - ((!a) << WRITEMASK_ALPHA_SHIFT)); + ENABLE_COLOR_MASK | + ENABLE_COLOR_WRITE | + ((!r) << WRITEMASK_RED_SHIFT) | + ((!g) << WRITEMASK_GREEN_SHIFT) | + ((!b) << WRITEMASK_BLUE_SHIFT) | ((!a) << WRITEMASK_ALPHA_SHIFT)); if (tmp != i830->state.Ctx[I830_CTXREG_ENABLES_2]) { I830_STATECHANGE(i830, I830_UPLOAD_CTX); @@ -630,9 +651,10 @@ static void i830ColorMask(GLcontext *ctx, } } -static void update_specular( GLcontext *ctx ) +static void +update_specular(GLcontext * ctx) { - struct i830_context *i830 = i830_context( ctx ); + struct i830_context *i830 = i830_context(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; @@ -643,20 +665,21 @@ static void update_specular( GLcontext *ctx ) i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD; } -static void i830LightModelfv(GLcontext *ctx, GLenum pname, - const GLfloat *param) +static void +i830LightModelfv(GLcontext * ctx, GLenum pname, const GLfloat * param) { - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { - update_specular( ctx ); + update_specular(ctx); } } /* In Mesa 3.5 we can reliably do native flatshading. */ -static void i830ShadeModel(GLcontext *ctx, GLenum mode) +static void +i830ShadeModel(GLcontext * ctx, GLenum mode) { struct i830_context *i830 = i830_context(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX); @@ -667,58 +690,63 @@ static void i830ShadeModel(GLcontext *ctx, GLenum mode) i830->state.Ctx[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK; if (mode == GL_FLAT) { - i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) | - FOG_SHADE_MODE(SHADE_MODE_FLAT) | - SPEC_SHADE_MODE(SHADE_MODE_FLAT) | - COLOR_SHADE_MODE(SHADE_MODE_FLAT)); - } else { - i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) | - FOG_SHADE_MODE(SHADE_MODE_LINEAR) | - SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | - COLOR_SHADE_MODE(SHADE_MODE_LINEAR)); + i830->state.Ctx[I830_CTXREG_STATE3] |= + (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) | FOG_SHADE_MODE(SHADE_MODE_FLAT) + | SPEC_SHADE_MODE(SHADE_MODE_FLAT) | + COLOR_SHADE_MODE(SHADE_MODE_FLAT)); + } + else { + i830->state.Ctx[I830_CTXREG_STATE3] |= + (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) | + FOG_SHADE_MODE(SHADE_MODE_LINEAR) | + SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | + COLOR_SHADE_MODE(SHADE_MODE_LINEAR)); } } /* ============================================================= * Fog */ -static void i830Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) +static void +i830Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param) { struct i830_context *i830 = i830_context(ctx); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); - if (pname == GL_FOG_COLOR) { - GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) | - ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) | - ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0)); + if (pname == GL_FOG_COLOR) { + GLuint color = (((GLubyte) (ctx->Fog.Color[0] * 255.0F) << 16) | + ((GLubyte) (ctx->Fog.Color[1] * 255.0F) << 8) | + ((GLubyte) (ctx->Fog.Color[2] * 255.0F) << 0)); I830_STATECHANGE(i830, I830_UPLOAD_CTX); - i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD | color); + i830->state.Ctx[I830_CTXREG_FOGCOLOR] = + (_3DSTATE_FOG_COLOR_CMD | color); } } /* ============================================================= */ -static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) +static void +i830Enable(GLcontext * ctx, GLenum cap, GLboolean state) { struct i830_context *i830 = i830_context(ctx); - switch(cap) { + switch (cap) { case GL_LIGHTING: case GL_COLOR_SUM: - update_specular( ctx ); + update_specular(ctx); break; case GL_ALPHA_TEST: I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_ALPHA_TEST_MASK; if (state) - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST; else - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST; break; @@ -732,17 +760,17 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) /* Logicop doesn't seem to work at 16bpp: */ if (i830->intel.intelScreen->cpp == 2) - FALLBACK( &i830->intel, I830_FALLBACK_LOGICOP, state ); + FALLBACK(&i830->intel, I830_FALLBACK_LOGICOP, state); break; - + case GL_DITHER: I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DITHER; if (state) - i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER; + i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER; else - i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER; + i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER; break; case GL_DEPTH_TEST: @@ -750,46 +778,44 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK; if (state) - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST; else - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST; /* Also turn off depth writes when GL_DEPTH_TEST is disabled: */ - i830DepthMask( ctx, ctx->Depth.Mask ); + i830DepthMask(ctx, ctx->Depth.Mask); break; case GL_SCISSOR_TEST: I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); - + if (state) - i830->state.Buffer[I830_DESTREG_SENABLE] = - (_3DSTATE_SCISSOR_ENABLE_CMD | - ENABLE_SCISSOR_RECT); + i830->state.Buffer[I830_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT); else - i830->state.Buffer[I830_DESTREG_SENABLE] = - (_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + i830->state.Buffer[I830_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); break; case GL_LINE_SMOOTH: I830_STATECHANGE(i830, I830_UPLOAD_CTX); - + i830->state.Ctx[I830_CTXREG_AA] &= ~AA_LINE_ENABLE; if (state) - i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_ENABLE; + i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_ENABLE; else - i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_DISABLE; + i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_DISABLE; break; case GL_FOG: I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_FOG_MASK; if (state) - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_FOG; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_FOG; else - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG; break; case GL_CULL_FACE: @@ -813,14 +839,18 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) if (state) { i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST; i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE; - } else { - i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST; - i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE; - i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST; - i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE; } - } else { - FALLBACK( &i830->intel, I830_FALLBACK_STENCIL, state ); + else { + i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_2] &= + ~ENABLE_STENCIL_WRITE; + i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST; + i830->state.Ctx[I830_CTXREG_ENABLES_2] |= + DISABLE_STENCIL_WRITE; + } + } + else { + FALLBACK(&i830->intel, I830_FALLBACK_STENCIL, state); } } break; @@ -830,13 +860,12 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) * I'll do more testing later to find out exactly which hardware * supports it. Disabled for now. */ - if (i830->intel.hw_stipple && - i830->intel.reduced_primitive == GL_TRIANGLES) - { - I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); - i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; - if (state) - i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE; + if (i830->intel.hw_stipple && + i830->intel.reduced_primitive == GL_TRIANGLES) { + I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); + i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; + if (state) + i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE; } break; @@ -846,7 +875,8 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state) } -static void i830_init_packets( struct i830_context *i830 ) +static void +i830_init_packets(struct i830_context *i830) { intelScreenPrivate *screen = i830->intel.intelScreen; @@ -855,197 +885,191 @@ static void i830_init_packets( struct i830_context *i830 ) /* Set default blend state */ i830->state.TexBlend[0][0] = (_3DSTATE_MAP_BLEND_OP_CMD(0) | - TEXPIPE_COLOR | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - DISABLE_TEX_CNTRL_STAGE | - TEXOP_SCALE_1X | - TEXOP_MODIFY_PARMS | - TEXOP_LAST_STAGE | - TEXBLENDOP_ARG1); + TEXPIPE_COLOR | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | + DISABLE_TEX_CNTRL_STAGE | + TEXOP_SCALE_1X | + TEXOP_MODIFY_PARMS | + TEXOP_LAST_STAGE | TEXBLENDOP_ARG1); i830->state.TexBlend[0][1] = (_3DSTATE_MAP_BLEND_OP_CMD(0) | - TEXPIPE_ALPHA | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - TEXOP_SCALE_1X | - TEXOP_MODIFY_PARMS | - TEXBLENDOP_ARG1); + TEXPIPE_ALPHA | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | + TEXOP_SCALE_1X | + TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1); i830->state.TexBlend[0][2] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) | - TEXPIPE_COLOR | - TEXBLEND_ARG1 | - TEXBLENDARG_MODIFY_PARMS | - TEXBLENDARG_DIFFUSE); + TEXPIPE_COLOR | + TEXBLEND_ARG1 | + TEXBLENDARG_MODIFY_PARMS | + TEXBLENDARG_DIFFUSE); i830->state.TexBlend[0][3] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) | - TEXPIPE_ALPHA | - TEXBLEND_ARG1 | - TEXBLENDARG_MODIFY_PARMS | - TEXBLENDARG_DIFFUSE); + TEXPIPE_ALPHA | + TEXBLEND_ARG1 | + TEXBLENDARG_MODIFY_PARMS | + TEXBLENDARG_DIFFUSE); i830->state.TexBlendWordsUsed[0] = 4; - i830->state.Ctx[I830_CTXREG_VF] = 0; + i830->state.Ctx[I830_CTXREG_VF] = 0; i830->state.Ctx[I830_CTXREG_VF2] = 0; i830->state.Ctx[I830_CTXREG_AA] = (_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | - AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | - AA_LINE_REGION_WIDTH_1_0 | - AA_LINE_DISABLE); + AA_LINE_ECAAR_WIDTH_ENABLE | + AA_LINE_ECAAR_WIDTH_1_0 | + AA_LINE_REGION_WIDTH_ENABLE | + AA_LINE_REGION_WIDTH_1_0 | + AA_LINE_DISABLE); i830->state.Ctx[I830_CTXREG_ENABLES_1] = (_3DSTATE_ENABLES_1_CMD | - DISABLE_LOGIC_OP | - DISABLE_STENCIL_TEST | - DISABLE_DEPTH_BIAS | - DISABLE_SPEC_ADD | - DISABLE_FOG | - DISABLE_ALPHA_TEST | - DISABLE_COLOR_BLEND | - DISABLE_DEPTH_TEST); + DISABLE_LOGIC_OP | + DISABLE_STENCIL_TEST | + DISABLE_DEPTH_BIAS | + DISABLE_SPEC_ADD | + DISABLE_FOG | + DISABLE_ALPHA_TEST | + DISABLE_COLOR_BLEND | + DISABLE_DEPTH_TEST); -#if 000 /* XXX all the stencil enable state is set in i830Enable(), right? */ +#if 000 /* XXX all the stencil enable state is set in i830Enable(), right? */ if (i830->intel.hw_stencil) { i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD | - ENABLE_STENCIL_WRITE | - ENABLE_TEX_CACHE | - ENABLE_DITHER | - ENABLE_COLOR_MASK | - /* set no color comps disabled */ - ENABLE_COLOR_WRITE | - ENABLE_DEPTH_WRITE); - } else + ENABLE_STENCIL_WRITE | + ENABLE_TEX_CACHE | + ENABLE_DITHER | + ENABLE_COLOR_MASK | + /* set no color comps disabled */ + ENABLE_COLOR_WRITE | + ENABLE_DEPTH_WRITE); + } + else #endif { i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD | - DISABLE_STENCIL_WRITE | - ENABLE_TEX_CACHE | - ENABLE_DITHER | - ENABLE_COLOR_MASK | - /* set no color comps disabled */ - ENABLE_COLOR_WRITE | - ENABLE_DEPTH_WRITE); + DISABLE_STENCIL_WRITE | + ENABLE_TEX_CACHE | + ENABLE_DITHER | + ENABLE_COLOR_MASK | + /* set no color comps disabled */ + ENABLE_COLOR_WRITE | + ENABLE_DEPTH_WRITE); } i830->state.Ctx[I830_CTXREG_STATE1] = (_3DSTATE_MODES_1_CMD | - ENABLE_COLR_BLND_FUNC | - BLENDFUNC_ADD | - ENABLE_SRC_BLND_FACTOR | - SRC_BLND_FACT(BLENDFACT_ONE) | - ENABLE_DST_BLND_FACTOR | - DST_BLND_FACT(BLENDFACT_ZERO) ); + ENABLE_COLR_BLND_FUNC | + BLENDFUNC_ADD | + ENABLE_SRC_BLND_FACTOR | + SRC_BLND_FACT(BLENDFACT_ONE) | + ENABLE_DST_BLND_FACTOR | + DST_BLND_FACT(BLENDFACT_ZERO)); i830->state.Ctx[I830_CTXREG_STATE2] = (_3DSTATE_MODES_2_CMD | - ENABLE_GLOBAL_DEPTH_BIAS | - GLOBAL_DEPTH_BIAS(0) | - ENABLE_ALPHA_TEST_FUNC | - ALPHA_TEST_FUNC(COMPAREFUNC_ALWAYS) | - ALPHA_REF_VALUE(0) ); + ENABLE_GLOBAL_DEPTH_BIAS | + GLOBAL_DEPTH_BIAS(0) | + ENABLE_ALPHA_TEST_FUNC | + ALPHA_TEST_FUNC(COMPAREFUNC_ALWAYS) + | ALPHA_REF_VALUE(0)); i830->state.Ctx[I830_CTXREG_STATE3] = (_3DSTATE_MODES_3_CMD | - ENABLE_DEPTH_TEST_FUNC | - DEPTH_TEST_FUNC(COMPAREFUNC_LESS) | - ENABLE_ALPHA_SHADE_MODE | - ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) | - ENABLE_FOG_SHADE_MODE | - FOG_SHADE_MODE(SHADE_MODE_LINEAR) | - ENABLE_SPEC_SHADE_MODE | - SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | - ENABLE_COLOR_SHADE_MODE | - COLOR_SHADE_MODE(SHADE_MODE_LINEAR) | - ENABLE_CULL_MODE | - CULLMODE_NONE); + ENABLE_DEPTH_TEST_FUNC | + DEPTH_TEST_FUNC(COMPAREFUNC_LESS) | + ENABLE_ALPHA_SHADE_MODE | + ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) + | ENABLE_FOG_SHADE_MODE | + FOG_SHADE_MODE(SHADE_MODE_LINEAR) | + ENABLE_SPEC_SHADE_MODE | + SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | + ENABLE_COLOR_SHADE_MODE | + COLOR_SHADE_MODE(SHADE_MODE_LINEAR) + | ENABLE_CULL_MODE | CULLMODE_NONE); i830->state.Ctx[I830_CTXREG_STATE4] = (_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | - LOGIC_OP_FUNC(LOGICOP_COPY) | - ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff) | - ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(0xff)); + ENABLE_LOGIC_OP_FUNC | + LOGIC_OP_FUNC(LOGICOP_COPY) | + ENABLE_STENCIL_TEST_MASK | + STENCIL_TEST_MASK(0xff) | + ENABLE_STENCIL_WRITE_MASK | + STENCIL_WRITE_MASK(0xff)); i830->state.Ctx[I830_CTXREG_STENCILTST] = (_3DSTATE_STENCIL_TEST_CMD | - ENABLE_STENCIL_PARMS | - STENCIL_FAIL_OP(STENCILOP_KEEP) | - STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_KEEP) | - STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_KEEP) | - ENABLE_STENCIL_TEST_FUNC | - STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS) | - ENABLE_STENCIL_REF_VALUE | - STENCIL_REF_VALUE(0) ); + ENABLE_STENCIL_PARMS | + STENCIL_FAIL_OP(STENCILOP_KEEP) + | + STENCIL_PASS_DEPTH_FAIL_OP + (STENCILOP_KEEP) | + STENCIL_PASS_DEPTH_PASS_OP + (STENCILOP_KEEP) | + ENABLE_STENCIL_TEST_FUNC | + STENCIL_TEST_FUNC + (COMPAREFUNC_ALWAYS) | + ENABLE_STENCIL_REF_VALUE | + STENCIL_REF_VALUE(0)); - i830->state.Ctx[I830_CTXREG_STATE5] = (_3DSTATE_MODES_5_CMD | - FLUSH_TEXTURE_CACHE | - ENABLE_SPRITE_POINT_TEX | - SPRITE_POINT_TEX_OFF | - ENABLE_FIXED_LINE_WIDTH | - FIXED_LINE_WIDTH(0x2) | /* 1.0 */ - ENABLE_FIXED_POINT_WIDTH | - FIXED_POINT_WIDTH(1) ); + i830->state.Ctx[I830_CTXREG_STATE5] = (_3DSTATE_MODES_5_CMD | FLUSH_TEXTURE_CACHE | ENABLE_SPRITE_POINT_TEX | SPRITE_POINT_TEX_OFF | ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(0x2) | /* 1.0 */ + ENABLE_FIXED_POINT_WIDTH | + FIXED_POINT_WIDTH(1)); i830->state.Ctx[I830_CTXREG_IALPHAB] = (_3DSTATE_INDPT_ALPHA_BLEND_CMD | - DISABLE_INDPT_ALPHA_BLEND | - ENABLE_ALPHA_BLENDFUNC | - ABLENDFUNC_ADD); + DISABLE_INDPT_ALPHA_BLEND | + ENABLE_ALPHA_BLENDFUNC | + ABLENDFUNC_ADD); i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD | - FOG_COLOR_RED(0) | - FOG_COLOR_GREEN(0) | - FOG_COLOR_BLUE(0)); + FOG_COLOR_RED(0) | + FOG_COLOR_GREEN(0) | + FOG_COLOR_BLUE(0)); i830->state.Ctx[I830_CTXREG_BLENDCOLOR0] = _3DSTATE_CONST_BLEND_COLOR_CMD; i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = 0; i830->state.Ctx[I830_CTXREG_MCSB0] = _3DSTATE_MAP_COORD_SETBIND_CMD; i830->state.Ctx[I830_CTXREG_MCSB1] = (TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) | - TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) | - TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | - TEXBIND_SET0(TEXCOORDSRC_VTXSET_0)); - + TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) | + TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | + TEXBIND_SET0(TEXCOORDSRC_VTXSET_0)); + i830->state.Stipple[I830_STPREG_ST0] = _3DSTATE_STIPPLE; i830->state.Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i830->state.Buffer[I830_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | - BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); + i830->state.Buffer[I830_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ + BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - i830->state.Buffer[I830_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | - BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); + i830->state.Buffer[I830_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ + BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; switch (screen->fbFormat) { case DV_PF_565: - i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - screen->fbFormat | - DEPTH_IS_Z | - DEPTH_FRMT_16_FIXED); + i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + screen->fbFormat | + DEPTH_IS_Z | + DEPTH_FRMT_16_FIXED); break; case DV_PF_8888: - i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - screen->fbFormat | - DEPTH_IS_Z | - DEPTH_FRMT_24_FIXED_8_OTHER); + i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + screen->fbFormat | + DEPTH_IS_Z | + DEPTH_FRMT_24_FIXED_8_OTHER); break; } i830->state.Buffer[I830_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + DISABLE_SCISSOR_RECT); i830->state.Buffer[I830_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD; i830->state.Buffer[I830_DESTREG_SR1] = 0; i830->state.Buffer[I830_DESTREG_SR2] = 0; } -void i830InitStateFuncs( struct dd_function_table *functions ) +void +i830InitStateFuncs(struct dd_function_table *functions) { functions->AlphaFunc = i830AlphaFunc; functions->BlendColor = i830BlendColor; @@ -1070,26 +1094,21 @@ void i830InitStateFuncs( struct dd_function_table *functions ) functions->StencilOpSeparate = i830StencilOpSeparate; } -void i830InitState( struct i830_context *i830 ) +void +i830InitState(struct i830_context *i830) { GLcontext *ctx = &i830->intel.ctx; - i830_init_packets( i830 ); + i830_init_packets(i830); - intelInitState( ctx ); + intelInitState(ctx); - memcpy( &i830->initial, &i830->state, sizeof(i830->state) ); + memcpy(&i830->initial, &i830->state, sizeof(i830->state)); i830->current = &i830->state; i830->state.emitted = 0; i830->state.active = (I830_UPLOAD_INVARIENT | - I830_UPLOAD_TEXBLEND(0) | - I830_UPLOAD_STIPPLE | - I830_UPLOAD_CTX | - I830_UPLOAD_BUFFERS); + I830_UPLOAD_TEXBLEND(0) | + I830_UPLOAD_STIPPLE | + I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS); } - - - - - diff --git a/src/mesa/drivers/dri/i915/i830_tex.c b/src/mesa/drivers/dri/i915/i830_tex.c index a230eb2e46e..fed464d1aac 100644 --- a/src/mesa/drivers/dri/i915/i830_tex.c +++ b/src/mesa/drivers/dri/i915/i830_tex.c @@ -45,12 +45,13 @@ -static void i830TexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) +static void +i830TexEnv(GLcontext * ctx, GLenum target, + GLenum pname, const GLfloat * param) { switch (pname) { - case GL_TEXTURE_ENV_COLOR: + case GL_TEXTURE_ENV_COLOR: case GL_TEXTURE_ENV_MODE: case GL_COMBINE_RGB: case GL_COMBINE_ALPHA: @@ -70,16 +71,19 @@ static void i830TexEnv( GLcontext *ctx, GLenum target, case GL_ALPHA_SCALE: break; - case GL_TEXTURE_LOD_BIAS: { - struct i830_context *i830 = i830_context( ctx ); - GLuint unit = ctx->Texture.CurrentUnit; - int b = (int) ((*param) * 16.0); - if (b > 63) b = 63; - if (b < -64) b = -64; - I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit)); - i830->lodbias_tm0s3[unit] = ((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK); - break; - } + case GL_TEXTURE_LOD_BIAS:{ + struct i830_context *i830 = i830_context(ctx); + GLuint unit = ctx->Texture.CurrentUnit; + int b = (int) ((*param) * 16.0); + if (b > 63) + b = 63; + if (b < -64) + b = -64; + I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit)); + i830->lodbias_tm0s3[unit] = + ((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK); + break; + } default: break; @@ -89,7 +93,8 @@ static void i830TexEnv( GLcontext *ctx, GLenum target, -void i830InitTextureFuncs( struct dd_function_table *functions ) +void +i830InitTextureFuncs(struct dd_function_table *functions) { - functions->TexEnv = i830TexEnv; + functions->TexEnv = i830TexEnv; } diff --git a/src/mesa/drivers/dri/i915/i830_texblend.c b/src/mesa/drivers/dri/i915/i830_texblend.c index 4c1bee58d8e..58f220eb7ce 100644 --- a/src/mesa/drivers/dri/i915/i830_texblend.c +++ b/src/mesa/drivers/dri/i915/i830_texblend.c @@ -46,46 +46,42 @@ /* ================================================================ * Texture combine functions */ -static GLuint pass_through( GLuint *state, GLuint blendUnit ) +static GLuint +pass_through(GLuint * state, GLuint blendUnit) { state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) | - TEXPIPE_COLOR | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - DISABLE_TEX_CNTRL_STAGE | - TEXOP_SCALE_1X | - TEXOP_MODIFY_PARMS | - TEXBLENDOP_ARG1); + TEXPIPE_COLOR | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | + DISABLE_TEX_CNTRL_STAGE | + TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1); state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) | - TEXPIPE_ALPHA | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - TEXOP_SCALE_1X | - TEXOP_MODIFY_PARMS | - TEXBLENDOP_ARG1); + TEXPIPE_ALPHA | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | + TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1); state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) | - TEXPIPE_COLOR | - TEXBLEND_ARG1 | - TEXBLENDARG_MODIFY_PARMS | - TEXBLENDARG_CURRENT); + TEXPIPE_COLOR | + TEXBLEND_ARG1 | + TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_CURRENT); state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) | - TEXPIPE_ALPHA | - TEXBLEND_ARG1 | - TEXBLENDARG_MODIFY_PARMS | - TEXBLENDARG_CURRENT); + TEXPIPE_ALPHA | + TEXBLEND_ARG1 | + TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_CURRENT); return 4; } -static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count, - const GLfloat *factor ) +static GLuint +emit_factor(GLuint blendUnit, GLuint * state, GLuint count, + const GLfloat * factor) { GLubyte r, g, b, a; GLuint col; - + if (0) fprintf(stderr, "emit constant %d: %.2f %.2f %.2f %.2f\n", - blendUnit, factor[0], factor[1], factor[2], factor[3]); + blendUnit, factor[0], factor[1], factor[2], factor[3]); UNCLAMPED_FLOAT_TO_UBYTE(r, factor[0]); UNCLAMPED_FLOAT_TO_UBYTE(g, factor[1]); @@ -94,21 +90,27 @@ static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count, col = ((a << 24) | (r << 16) | (g << 8) | b); - state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit); + state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit); state[count++] = col; return count; } -static INLINE GLuint GetTexelOp(GLint unit) +static INLINE GLuint +GetTexelOp(GLint unit) { - switch(unit) { - case 0: return TEXBLENDARG_TEXEL0; - case 1: return TEXBLENDARG_TEXEL1; - case 2: return TEXBLENDARG_TEXEL2; - case 3: return TEXBLENDARG_TEXEL3; - default: return TEXBLENDARG_TEXEL0; + switch (unit) { + case 0: + return TEXBLENDARG_TEXEL0; + case 1: + return TEXBLENDARG_TEXEL1; + case 2: + return TEXBLENDARG_TEXEL2; + case 3: + return TEXBLENDARG_TEXEL3; + default: + return TEXBLENDARG_TEXEL0; } } @@ -132,12 +134,10 @@ static INLINE GLuint GetTexelOp(GLint unit) * partial support for the extension? */ GLuint -i830SetTexEnvCombine(struct i830_context *i830, - const struct gl_tex_env_combine_state * combine, - GLint blendUnit, - GLuint texel_op, - GLuint *state, - const GLfloat *factor ) +i830SetTexEnvCombine(struct i830_context * i830, + const struct gl_tex_env_combine_state * combine, + GLint blendUnit, + GLuint texel_op, GLuint * state, const GLfloat * factor) { const GLuint numColorArgs = combine->_NumArgsRGB; const GLuint numAlphaArgs = combine->_NumArgsA; @@ -162,7 +162,7 @@ i830SetTexEnvCombine(struct i830_context *i830, TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS, }; - if(INTEL_DEBUG&DEBUG_TEXTURE) + if (INTEL_DEBUG & DEBUG_TEXTURE) fprintf(stderr, "%s\n", __FUNCTION__); @@ -188,23 +188,23 @@ i830SetTexEnvCombine(struct i830_context *i830, } - switch(combine->ModeRGB) { - case GL_REPLACE: + switch (combine->ModeRGB) { + case GL_REPLACE: blendop = TEXBLENDOP_ARG1; break; - case GL_MODULATE: + case GL_MODULATE: blendop = TEXBLENDOP_MODULATE; break; - case GL_ADD: + case GL_ADD: blendop = TEXBLENDOP_ADD; break; case GL_ADD_SIGNED: - blendop = TEXBLENDOP_ADDSIGNED; + blendop = TEXBLENDOP_ADDSIGNED; break; case GL_INTERPOLATE: - blendop = TEXBLENDOP_BLEND; + blendop = TEXBLENDOP_BLEND; break; - case GL_SUBTRACT: + case GL_SUBTRACT: blendop = TEXBLENDOP_SUBTRACT; break; case GL_DOT3_RGB_EXT: @@ -215,55 +215,54 @@ i830SetTexEnvCombine(struct i830_context *i830, case GL_DOT3_RGBA: blendop = TEXBLENDOP_DOT3; break; - default: - return pass_through( state, blendUnit ); + default: + return pass_through(state, blendUnit); } blendop |= (rgb_shift << TEXOP_SCALE_SHIFT); /* Handle RGB args */ - for(i = 0; i < 3; i++) { - switch(combine->SourceRGB[i]) { - case GL_TEXTURE: - args_RGB[i] = texel_op; - break; + for (i = 0; i < 3; i++) { + switch (combine->SourceRGB[i]) { + case GL_TEXTURE: + args_RGB[i] = texel_op; + break; case GL_TEXTURE0: case GL_TEXTURE1: case GL_TEXTURE2: case GL_TEXTURE3: - args_RGB[i] = GetTexelOp( combine->SourceRGB[i] - GL_TEXTURE0 ); - break; + args_RGB[i] = GetTexelOp(combine->SourceRGB[i] - GL_TEXTURE0); + break; case GL_CONSTANT: - args_RGB[i] = TEXBLENDARG_FACTOR_N; - need_factor = 1; - break; + args_RGB[i] = TEXBLENDARG_FACTOR_N; + need_factor = 1; + break; case GL_PRIMARY_COLOR: - args_RGB[i] = TEXBLENDARG_DIFFUSE; - break; + args_RGB[i] = TEXBLENDARG_DIFFUSE; + break; case GL_PREVIOUS: - args_RGB[i] = TEXBLENDARG_CURRENT; - break; - default: - return pass_through( state, blendUnit ); + args_RGB[i] = TEXBLENDARG_CURRENT; + break; + default: + return pass_through(state, blendUnit); } - switch(combine->OperandRGB[i]) { - case GL_SRC_COLOR: - args_RGB[i] |= 0; - break; - case GL_ONE_MINUS_SRC_COLOR: - args_RGB[i] |= TEXBLENDARG_INV_ARG; - break; - case GL_SRC_ALPHA: - args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA | - TEXBLENDARG_INV_ARG); - break; - default: - return pass_through( state, blendUnit ); + switch (combine->OperandRGB[i]) { + case GL_SRC_COLOR: + args_RGB[i] |= 0; + break; + case GL_ONE_MINUS_SRC_COLOR: + args_RGB[i] |= TEXBLENDARG_INV_ARG; + break; + case GL_SRC_ALPHA: + args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: + args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA | TEXBLENDARG_INV_ARG); + break; + default: + return pass_through(state, blendUnit); } } @@ -275,76 +274,76 @@ i830SetTexEnvCombine(struct i830_context *i830, * Note - the global factor is set up with alpha == .5, so * the alpha part of the DOT4 calculation should be zero. */ - if ( combine->ModeRGB == GL_DOT3_RGBA_EXT || - combine->ModeRGB == GL_DOT3_RGBA ) { + if (combine->ModeRGB == GL_DOT3_RGBA_EXT || + combine->ModeRGB == GL_DOT3_RGBA) { ablendop = TEXBLENDOP_DOT4; - args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */ + args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */ args_A[1] = TEXBLENDARG_FACTOR; args_A[2] = TEXBLENDARG_FACTOR; } else { - switch(combine->ModeA) { - case GL_REPLACE: - ablendop = TEXBLENDOP_ARG1; - break; - case GL_MODULATE: - ablendop = TEXBLENDOP_MODULATE; - break; - case GL_ADD: - ablendop = TEXBLENDOP_ADD; - break; + switch (combine->ModeA) { + case GL_REPLACE: + ablendop = TEXBLENDOP_ARG1; + break; + case GL_MODULATE: + ablendop = TEXBLENDOP_MODULATE; + break; + case GL_ADD: + ablendop = TEXBLENDOP_ADD; + break; case GL_ADD_SIGNED: - ablendop = TEXBLENDOP_ADDSIGNED; - break; + ablendop = TEXBLENDOP_ADDSIGNED; + break; case GL_INTERPOLATE: - ablendop = TEXBLENDOP_BLEND; - break; - case GL_SUBTRACT: - ablendop = TEXBLENDOP_SUBTRACT; - break; + ablendop = TEXBLENDOP_BLEND; + break; + case GL_SUBTRACT: + ablendop = TEXBLENDOP_SUBTRACT; + break; default: - return pass_through( state, blendUnit ); + return pass_through(state, blendUnit); } ablendop |= (alpha_shift << TEXOP_SCALE_SHIFT); /* Handle A args */ - for(i = 0; i < 3; i++) { - switch(combine->SourceA[i]) { - case GL_TEXTURE: - args_A[i] = texel_op; - break; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - args_A[i] = GetTexelOp( combine->SourceA[i] - GL_TEXTURE0 ); - break; - case GL_CONSTANT: - args_A[i] = TEXBLENDARG_FACTOR_N; - need_factor = 1; - break; - case GL_PRIMARY_COLOR: - args_A[i] = TEXBLENDARG_DIFFUSE; - break; - case GL_PREVIOUS: - args_A[i] = TEXBLENDARG_CURRENT; - break; - default: - return pass_through( state, blendUnit ); - } + for (i = 0; i < 3; i++) { + switch (combine->SourceA[i]) { + case GL_TEXTURE: + args_A[i] = texel_op; + break; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + args_A[i] = GetTexelOp(combine->SourceA[i] - GL_TEXTURE0); + break; + case GL_CONSTANT: + args_A[i] = TEXBLENDARG_FACTOR_N; + need_factor = 1; + break; + case GL_PRIMARY_COLOR: + args_A[i] = TEXBLENDARG_DIFFUSE; + break; + case GL_PREVIOUS: + args_A[i] = TEXBLENDARG_CURRENT; + break; + default: + return pass_through(state, blendUnit); + } - switch(combine->OperandA[i]) { - case GL_SRC_ALPHA: - args_A[i] |= 0; - break; - case GL_ONE_MINUS_SRC_ALPHA: - args_A[i] |= TEXBLENDARG_INV_ARG; - break; - default: - return pass_through( state, blendUnit ); - } + switch (combine->OperandA[i]) { + case GL_SRC_ALPHA: + args_A[i] |= 0; + break; + case GL_ONE_MINUS_SRC_ALPHA: + args_A[i] |= TEXBLENDARG_INV_ARG; + break; + default: + return pass_through(state, blendUnit); + } } } @@ -363,86 +362,86 @@ i830SetTexEnvCombine(struct i830_context *i830, used = 0; state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) | - TEXPIPE_COLOR | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - DISABLE_TEX_CNTRL_STAGE | - TEXOP_MODIFY_PARMS | - blendop); + TEXPIPE_COLOR | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | + DISABLE_TEX_CNTRL_STAGE | TEXOP_MODIFY_PARMS | blendop); state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) | - TEXPIPE_ALPHA | - ENABLE_TEXOUTPUT_WRT_SEL | - TEXOP_OUTPUT_CURRENT | - TEXOP_MODIFY_PARMS | - ablendop); + TEXPIPE_ALPHA | + ENABLE_TEXOUTPUT_WRT_SEL | + TEXOP_OUTPUT_CURRENT | TEXOP_MODIFY_PARMS | ablendop); - for ( i = 0 ; i < numColorArgs ; i++ ) { + for (i = 0; i < numColorArgs; i++) { state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) | - tex_blend_rgb[i] | args_RGB[i]); + tex_blend_rgb[i] | args_RGB[i]); } - for ( i = 0 ; i < numAlphaArgs ; i++ ) { + for (i = 0; i < numAlphaArgs; i++) { state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) | - tex_blend_a[i] | args_A[i]); + tex_blend_a[i] | args_A[i]); } - if (need_factor) - return emit_factor( blendUnit, state, used, factor ); - else + if (need_factor) + return emit_factor(blendUnit, state, used, factor); + else return used; } -static void emit_texblend( struct i830_context *i830, GLuint unit, GLuint blendUnit, - GLboolean last_stage ) +static void +emit_texblend(struct i830_context *i830, GLuint unit, GLuint blendUnit, + GLboolean last_stage) { struct gl_texture_unit *texUnit = &i830->intel.ctx.Texture.Unit[unit]; GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz; - if (0) fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit); + if (0) + fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit); /* Update i830->state.TexBlend - */ - tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit, - GetTexelOp(unit), tmp, - texUnit->EnvColor ); + */ + tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit, + GetTexelOp(unit), tmp, texUnit->EnvColor); - if (last_stage) + if (last_stage) tmp[0] |= TEXOP_LAST_STAGE; if (tmp_sz != i830->state.TexBlendWordsUsed[blendUnit] || - memcmp( tmp, i830->state.TexBlend[blendUnit], tmp_sz * sizeof(GLuint))) { - - I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(blendUnit) ); - memcpy( i830->state.TexBlend[blendUnit], tmp, tmp_sz * sizeof(GLuint)); + memcmp(tmp, i830->state.TexBlend[blendUnit], + tmp_sz * sizeof(GLuint))) { + + I830_STATECHANGE(i830, I830_UPLOAD_TEXBLEND(blendUnit)); + memcpy(i830->state.TexBlend[blendUnit], tmp, tmp_sz * sizeof(GLuint)); i830->state.TexBlendWordsUsed[blendUnit] = tmp_sz; } I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(blendUnit), GL_TRUE); } -static void emit_passthrough( struct i830_context *i830 ) +static void +emit_passthrough(struct i830_context *i830) { GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz; GLuint unit = 0; - tmp_sz = pass_through( tmp, unit ); + tmp_sz = pass_through(tmp, unit); tmp[0] |= TEXOP_LAST_STAGE; if (tmp_sz != i830->state.TexBlendWordsUsed[unit] || - memcmp( tmp, i830->state.TexBlend[unit], tmp_sz * sizeof(GLuint))) { - - I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(unit) ); - memcpy( i830->state.TexBlend[unit], tmp, tmp_sz * sizeof(GLuint)); + memcmp(tmp, i830->state.TexBlend[unit], tmp_sz * sizeof(GLuint))) { + + I830_STATECHANGE(i830, I830_UPLOAD_TEXBLEND(unit)); + memcpy(i830->state.TexBlend[unit], tmp, tmp_sz * sizeof(GLuint)); i830->state.TexBlendWordsUsed[unit] = tmp_sz; } I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(unit), GL_TRUE); } -void i830EmitTextureBlend( struct i830_context *i830 ) +void +i830EmitTextureBlend(struct i830_context *i830) { GLcontext *ctx = &i830->intel.ctx; GLuint unit, last_stage = 0, blendunit = 0; @@ -450,16 +449,15 @@ void i830EmitTextureBlend( struct i830_context *i830 ) I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND_ALL, GL_FALSE); if (ctx->Texture._EnabledUnits) { - for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++) - if (ctx->Texture.Unit[unit]._ReallyEnabled) - last_stage = unit; + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) + if (ctx->Texture.Unit[unit]._ReallyEnabled) + last_stage = unit; - for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++) - if (ctx->Texture.Unit[unit]._ReallyEnabled) - emit_texblend( i830, unit, blendunit++, last_stage == unit ); + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) + if (ctx->Texture.Unit[unit]._ReallyEnabled) + emit_texblend(i830, unit, blendunit++, last_stage == unit); } else { - emit_passthrough( i830 ); + emit_passthrough(i830); } } - diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index dc9aca80fa9..ba79cf94599 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -46,7 +46,8 @@ -static GLuint translate_texture_format( GLuint mesa_format ) +static GLuint +translate_texture_format(GLuint mesa_format) { switch (mesa_format) { case MESA_FORMAT_L8: @@ -80,8 +81,7 @@ static GLuint translate_texture_format( GLuint mesa_format ) case MESA_FORMAT_RGBA_DXT5: return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); default: - fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, - mesa_format); + fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format); abort(); return 0; } @@ -94,19 +94,20 @@ static GLuint translate_texture_format( GLuint mesa_format ) * Intel drivers for "other operating systems" implement GL_CLAMP as * GL_CLAMP_TO_EDGE, so the same is done here. */ -static GLuint translate_wrap_mode( GLenum wrap ) +static GLuint +translate_wrap_mode(GLenum wrap) { - switch( wrap ) { - case GL_REPEAT: + switch (wrap) { + case GL_REPEAT: return TEXCOORDMODE_WRAP; - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - return TEXCOORDMODE_CLAMP; /* not really correct */ - case GL_CLAMP_TO_BORDER: + case GL_CLAMP: + case GL_CLAMP_TO_EDGE: + return TEXCOORDMODE_CLAMP; /* not really correct */ + case GL_CLAMP_TO_BORDER: return TEXCOORDMODE_CLAMP_BORDER; - case GL_MIRRORED_REPEAT: + case GL_MIRRORED_REPEAT: return TEXCOORDMODE_MIRROR; - default: + default: return TEXCOORDMODE_WRAP; } } @@ -116,9 +117,8 @@ static GLuint translate_wrap_mode( GLenum wrap ) * efficient, but this has gotten complex enough that we need * something which is understandable and reliable. */ -static GLboolean i830_update_tex_unit( struct intel_context *intel, - GLuint unit, - GLuint ss3 ) +static GLboolean +i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) { GLcontext *ctx = &intel->ctx; struct i830_context *i830 = i830_context(ctx); @@ -130,7 +130,7 @@ static GLboolean i830_update_tex_unit( struct intel_context *intel, memset(state, 0, sizeof(state)); if (!intel_finalize_mipmap_tree(intel, unit)) - return GL_FALSE; + return GL_FALSE; /* Get first image here, since intelObj->firstLevel will get set in * the intel_finalize_mipmap_tree() call above. @@ -139,36 +139,36 @@ static GLboolean i830_update_tex_unit( struct intel_context *intel, i830->state.tex_buffer[unit] = intelObj->mt->region->buffer; i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0, - intelObj->firstLevel); + intelObj-> + firstLevel); - state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - (LOAD_TEXTURE_MAP0 << unit) | 4); + state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + (LOAD_TEXTURE_MAP0 << unit) | 4); /* state[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | */ /* t->intel.TextureOffset); */ - state[I830_TEXREG_TM0S1] = + state[I830_TEXREG_TM0S1] = (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) | ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | - translate_texture_format( firstImage->TexFormat->MesaFormat)); + translate_texture_format(firstImage->TexFormat->MesaFormat)); - state[I830_TEXREG_TM0S2] = - (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) - 1) << TM0S2_PITCH_SHIFT) | - TM0S2_CUBE_FACE_ENA_MASK); + state[I830_TEXREG_TM0S2] = + (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) - + 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK); { if (tObj->Target == GL_TEXTURE_CUBE_MAP) - state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) | - CUBE_NEGX_ENABLE | - CUBE_POSX_ENABLE | - CUBE_NEGY_ENABLE | - CUBE_POSY_ENABLE | - CUBE_NEGZ_ENABLE | - CUBE_POSZ_ENABLE); + state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) | + CUBE_NEGX_ENABLE | + CUBE_POSX_ENABLE | + CUBE_NEGY_ENABLE | + CUBE_POSY_ENABLE | + CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE); else - state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit)); + state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit)); } @@ -179,143 +179,138 @@ static GLboolean i830_update_tex_unit( struct intel_context *intel, switch (tObj->MinFilter) { case GL_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NONE; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NONE; + break; case GL_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NONE; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NONE; + break; case GL_NEAREST_MIPMAP_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NEAREST; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NEAREST; + break; case GL_LINEAR_MIPMAP_NEAREST: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NEAREST; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NEAREST; + break; case GL_NEAREST_MIPMAP_LINEAR: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_LINEAR; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_LINEAR; + break; case GL_LINEAR_MIPMAP_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_LINEAR; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_LINEAR; + break; default: - return GL_FALSE; + return GL_FALSE; } - if ( tObj->MaxAnisotropy > 1.0 ) { - minFilt = FILTER_ANISOTROPIC; - magFilt = FILTER_ANISOTROPIC; + if (tObj->MaxAnisotropy > 1.0) { + minFilt = FILTER_ANISOTROPIC; + magFilt = FILTER_ANISOTROPIC; } else { - switch (tObj->MagFilter) { - case GL_NEAREST: - magFilt = FILTER_NEAREST; - break; - case GL_LINEAR: - magFilt = FILTER_LINEAR; - break; - default: - return GL_FALSE; - } + switch (tObj->MagFilter) { + case GL_NEAREST: + magFilt = FILTER_NEAREST; + break; + case GL_LINEAR: + magFilt = FILTER_LINEAR; + break; + default: + return GL_FALSE; + } } state[I830_TEXREG_TM0S3] = i830->lodbias_tm0s3[unit]; -#if 0 +#if 0 /* YUV conversion: */ if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR || - firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV) - state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION; + firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV) + state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION; #endif - state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel - - intelObj->firstLevel)*4) << TM0S3_MIN_MIP_SHIFT; + state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel - + intelObj->firstLevel) * + 4) << TM0S3_MIN_MIP_SHIFT; state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) | - (mipFilt << TM0S3_MIP_FILTER_SHIFT) | - (magFilt << TM0S3_MAG_FILTER_SHIFT)); + (mipFilt << TM0S3_MIP_FILTER_SHIFT) | + (magFilt << TM0S3_MAG_FILTER_SHIFT)); } { GLenum ws = tObj->WrapS; GLenum wt = tObj->WrapT; - + /* 3D textures not available on i830 */ if (tObj->Target == GL_TEXTURE_3D) - return GL_FALSE; - + return GL_FALSE; + state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD | - MAP_UNIT(unit) | - ENABLE_TEXCOORD_PARAMS | - ss3 | - ENABLE_ADDR_V_CNTL | - TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt)) | - ENABLE_ADDR_U_CNTL | - TEXCOORD_ADDR_U_MODE(translate_wrap_mode(ws))); + MAP_UNIT(unit) | + ENABLE_TEXCOORD_PARAMS | + ss3 | + ENABLE_ADDR_V_CNTL | + TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt)) + | ENABLE_ADDR_U_CNTL | + TEXCOORD_ADDR_U_MODE(translate_wrap_mode + (ws))); } state[I830_TEXREG_TM0S4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0], - tObj->_BorderChan[1], - tObj->_BorderChan[2], - tObj->_BorderChan[3]); - + tObj->_BorderChan[1], + tObj->_BorderChan[2], + tObj->_BorderChan[3]); + I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE); /* memcmp was already disabled, but definitely won't work as the * region might now change and that wouldn't be detected: */ - I830_STATECHANGE( i830, I830_UPLOAD_TEX(unit) ); + I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit)); return GL_TRUE; } -void i830UpdateTextureState( struct intel_context *intel ) +void +i830UpdateTextureState(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); GLboolean ok = GL_TRUE; GLuint i; - for (i = 0 ; i < I830_TEX_UNITS && ok ; i++) { + for (i = 0; i < I830_TEX_UNITS && ok; i++) { switch (intel->ctx.Texture.Unit[i]._ReallyEnabled) { case TEXTURE_1D_BIT: case TEXTURE_2D_BIT: case TEXTURE_CUBE_BIT: - ok = i830_update_tex_unit( intel, i, TEXCOORDS_ARE_NORMAL ); - break; + ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_NORMAL); + break; case TEXTURE_RECT_BIT: - ok = i830_update_tex_unit( intel, i, TEXCOORDS_ARE_IN_TEXELUNITS ); - break; - case 0: - if (i830->state.active & I830_UPLOAD_TEX(i)) - I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE); - break; + ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_IN_TEXELUNITS); + break; + case 0: + if (i830->state.active & I830_UPLOAD_TEX(i)) + I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE); + break; case TEXTURE_3D_BIT: default: - ok = GL_FALSE; - break; + ok = GL_FALSE; + break; } } - FALLBACK( intel, I830_FALLBACK_TEXTURE, !ok ); + FALLBACK(intel, I830_FALLBACK_TEXTURE, !ok); if (ok) - i830EmitTextureBlend( i830 ); + i830EmitTextureBlend(i830); } - - - - - - - - diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 2a95970cb63..2bf958509b5 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -35,8 +35,8 @@ #define FILE_DEBUG_FLAG DEBUG_STATE -static GLboolean i830_check_vertex_size( struct intel_context *intel, - GLuint expected ); +static GLboolean i830_check_vertex_size(struct intel_context *intel, + GLuint expected); #define SZ_TO_HW(sz) ((sz-2)&0x3) #define EMIT_SZ(sz) (EMIT_1F + (sz) - 1) @@ -60,7 +60,8 @@ do { \ #define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2)) #define TEXBIND_SET(n, x) ((x)<<((n)*4)) -static void i830_render_start( struct intel_context *intel ) +static void +i830_render_start(struct intel_context *intel) { GLcontext *ctx = &intel->ctx; struct i830_context *i830 = i830_context(ctx); @@ -71,7 +72,7 @@ static void i830_render_start( struct intel_context *intel ) GLuint v2 = _3DSTATE_VFT1_CMD; GLuint mcsb1 = 0; - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); + RENDERINPUTS_COPY(index_bitset, tnl->render_inputs_bitset); /* Important: */ @@ -81,150 +82,149 @@ static void i830_render_start( struct intel_context *intel ) /* EMIT_ATTR's must be in order as they tell t_vertex.c how to * build up a hardware vertex. */ - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW ); + if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) { + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW); intel->coloroffset = 4; } else { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ ); + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ); intel->coloroffset = 3; } - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { - EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH ); + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_POINTSIZE)) { + EMIT_ATTR(_TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH); } - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE ); - + EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE); + intel->specoffset = 0; - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1) || + RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG)) { + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1)) { intel->specoffset = intel->coloroffset + 1; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC ); + EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC); } else - EMIT_PAD( 3 ); + EMIT_PAD(3); - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC ); + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG)) + EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC); else - EMIT_PAD( 1 ); + EMIT_PAD(1); } - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { + if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) { int i, count = 0; for (i = 0; i < I830_TEX_UNITS; i++) { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_TEX(i))) { GLuint sz = VB->TexCoordPtr[i]->size; GLuint emit; - GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] & + GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] & ~TEXCOORDTYPE_MASK); - switch (sz) { - case 1: - case 2: - emit = EMIT_2F; - sz = 2; - mcs |= TEXCOORDTYPE_CARTESIAN; - break; - case 3: - emit = EMIT_3F; - sz = 3; - mcs |= TEXCOORDTYPE_VECTOR; - break; - case 4: - emit = EMIT_3F_XYW; - sz = 3; - mcs |= TEXCOORDTYPE_HOMOGENEOUS; - break; - default: - continue; - }; - + switch (sz) { + case 1: + case 2: + emit = EMIT_2F; + sz = 2; + mcs |= TEXCOORDTYPE_CARTESIAN; + break; + case 3: + emit = EMIT_3F; + sz = 3; + mcs |= TEXCOORDTYPE_VECTOR; + break; + case 4: + emit = EMIT_3F_XYW; + sz = 3; + mcs |= TEXCOORDTYPE_HOMOGENEOUS; + break; + default: + continue; + }; - EMIT_ATTR( _TNL_ATTRIB_TEX0+i, emit, 0 ); - v2 |= VRTX_TEX_SET_FMT(count, SZ_TO_HW(sz)); - mcsb1 |= (count+8)<<(i*4); - if (mcs != i830->state.Tex[i][I830_TEXREG_MCS]) { - I830_STATECHANGE(i830, I830_UPLOAD_TEX(i)); - i830->state.Tex[i][I830_TEXREG_MCS] = mcs; - } + EMIT_ATTR(_TNL_ATTRIB_TEX0 + i, emit, 0); + v2 |= VRTX_TEX_SET_FMT(count, SZ_TO_HW(sz)); + mcsb1 |= (count + 8) << (i * 4); - count++; - } + if (mcs != i830->state.Tex[i][I830_TEXREG_MCS]) { + I830_STATECHANGE(i830, I830_UPLOAD_TEX(i)); + i830->state.Tex[i][I830_TEXREG_MCS] = mcs; + } + + count++; + } } v0 |= VFT0_TEX_COUNT(count); } - + /* Only need to change the vertex emit code if there has been a * statechange to a new hardware vertex format: */ if (v0 != i830->state.Ctx[I830_CTXREG_VF] || v2 != i830->state.Ctx[I830_CTXREG_VF2] || mcsb1 != i830->state.Ctx[I830_CTXREG_MCSB1] || - !RENDERINPUTS_EQUAL( index_bitset, i830->last_index_bitset )) { + !RENDERINPUTS_EQUAL(index_bitset, i830->last_index_bitset)) { int k; - - I830_STATECHANGE( i830, I830_UPLOAD_CTX ); + + I830_STATECHANGE(i830, I830_UPLOAD_CTX); /* Must do this *after* statechange, so as not to affect * buffered vertices reliant on the old state: */ - intel->vertex_size = - _tnl_install_attrs( ctx, - intel->vertex_attrs, - intel->vertex_attr_count, - intel->ViewportMatrix.m, 0 ); + intel->vertex_size = + _tnl_install_attrs(ctx, + intel->vertex_attrs, + intel->vertex_attr_count, + intel->ViewportMatrix.m, 0); intel->vertex_size >>= 2; i830->state.Ctx[I830_CTXREG_VF] = v0; i830->state.Ctx[I830_CTXREG_VF2] = v2; i830->state.Ctx[I830_CTXREG_MCSB1] = mcsb1; - RENDERINPUTS_COPY( i830->last_index_bitset, index_bitset ); + RENDERINPUTS_COPY(i830->last_index_bitset, index_bitset); - k = i830_check_vertex_size( intel, intel->vertex_size ); + k = i830_check_vertex_size(intel, intel->vertex_size); assert(k); } } -static void i830_reduced_primitive_state( struct intel_context *intel, - GLenum rprim ) +static void +i830_reduced_primitive_state(struct intel_context *intel, GLenum rprim) { - struct i830_context *i830 = i830_context(&intel->ctx); - GLuint st1 = i830->state.Stipple[I830_STPREG_ST1]; + struct i830_context *i830 = i830_context(&intel->ctx); + GLuint st1 = i830->state.Stipple[I830_STPREG_ST1]; - st1 &= ~ST1_ENABLE; + st1 &= ~ST1_ENABLE; - switch (rprim) { - case GL_TRIANGLES: - if (intel->ctx.Polygon.StippleFlag && - intel->hw_stipple) - st1 |= ST1_ENABLE; - break; - case GL_LINES: - case GL_POINTS: - default: - break; - } + switch (rprim) { + case GL_TRIANGLES: + if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) + st1 |= ST1_ENABLE; + break; + case GL_LINES: + case GL_POINTS: + default: + break; + } - i830->intel.reduced_primitive = rprim; + i830->intel.reduced_primitive = rprim; - if (st1 != i830->state.Stipple[I830_STPREG_ST1]) { - I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); - i830->state.Stipple[I830_STPREG_ST1] = st1; - } + if (st1 != i830->state.Stipple[I830_STPREG_ST1]) { + I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); + i830->state.Stipple[I830_STPREG_ST1] = st1; + } } /* Pull apart the vertex format registers and figure out how large a * vertex is supposed to be. */ -static GLboolean i830_check_vertex_size( struct intel_context *intel, - GLuint expected ) +static GLboolean +i830_check_vertex_size(struct intel_context *intel, GLuint expected) { struct i830_context *i830 = i830_context(&intel->ctx); int vft0 = i830->current->Ctx[I830_CTXREG_VF]; @@ -233,37 +233,58 @@ static GLboolean i830_check_vertex_size( struct intel_context *intel, int i, sz = 0; switch (vft0 & VFT0_XYZW_MASK) { - case VFT0_XY: sz = 2; break; - case VFT0_XYZ: sz = 3; break; - case VFT0_XYW: sz = 3; break; - case VFT0_XYZW: sz = 4; break; - default: + case VFT0_XY: + sz = 2; + break; + case VFT0_XYZ: + sz = 3; + break; + case VFT0_XYW: + sz = 3; + break; + case VFT0_XYZW: + sz = 4; + break; + default: fprintf(stderr, "no xyzw specified\n"); return 0; } - if (vft0 & VFT0_SPEC) sz++; - if (vft0 & VFT0_DIFFUSE) sz++; - if (vft0 & VFT0_DEPTH_OFFSET) sz++; - if (vft0 & VFT0_POINT_WIDTH) sz++; - - for (i = 0 ; i < nrtex ; i++) { + if (vft0 & VFT0_SPEC) + sz++; + if (vft0 & VFT0_DIFFUSE) + sz++; + if (vft0 & VFT0_DEPTH_OFFSET) + sz++; + if (vft0 & VFT0_POINT_WIDTH) + sz++; + + for (i = 0; i < nrtex; i++) { switch (vft1 & VFT1_TEX0_MASK) { - case TEXCOORDFMT_2D: sz += 2; break; - case TEXCOORDFMT_3D: sz += 3; break; - case TEXCOORDFMT_4D: sz += 4; break; - case TEXCOORDFMT_1D: sz += 1; break; + case TEXCOORDFMT_2D: + sz += 2; + break; + case TEXCOORDFMT_3D: + sz += 3; + break; + case TEXCOORDFMT_4D: + sz += 4; + break; + case TEXCOORDFMT_1D: + sz += 1; + break; } vft1 >>= VFT1_TEX1_SHIFT; } - - if (sz != expected) + + if (sz != expected) fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected); - + return sz == expected; } -static void i830_emit_invarient_state( struct intel_context *intel ) +static void +i830_emit_invarient_state(struct intel_context *intel) { BATCH_LOCALS; @@ -280,37 +301,35 @@ static void i830_emit_invarient_state( struct intel_context *intel ) OUT_BATCH(_3DSTATE_FOG_MODE_CMD); OUT_BATCH(FOGFUNC_ENABLE | - FOG_LINEAR_CONST | - FOGSRC_INDEX_Z | - ENABLE_FOG_DENSITY); + FOG_LINEAR_CONST | FOGSRC_INDEX_Z | ENABLE_FOG_DENSITY); OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | - MAP_UNIT(0) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | - TEX_STREAM_COORD_SET(0) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0)); + MAP_UNIT(0) | + DISABLE_TEX_STREAM_BUMP | + ENABLE_TEX_STREAM_COORD_SET | + TEX_STREAM_COORD_SET(0) | + ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0)); OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | - MAP_UNIT(1) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | - TEX_STREAM_COORD_SET(1) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1)); + MAP_UNIT(1) | + DISABLE_TEX_STREAM_BUMP | + ENABLE_TEX_STREAM_COORD_SET | + TEX_STREAM_COORD_SET(1) | + ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1)); OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | - MAP_UNIT(2) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | - TEX_STREAM_COORD_SET(2) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2)); + MAP_UNIT(2) | + DISABLE_TEX_STREAM_BUMP | + ENABLE_TEX_STREAM_COORD_SET | + TEX_STREAM_COORD_SET(2) | + ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2)); OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | - MAP_UNIT(3) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | - TEX_STREAM_COORD_SET(3) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3)); + MAP_UNIT(3) | + DISABLE_TEX_STREAM_BUMP | + ENABLE_TEX_STREAM_COORD_SET | + TEX_STREAM_COORD_SET(3) | + ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3)); OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM); OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0)); @@ -322,14 +341,13 @@ static void i830_emit_invarient_state( struct intel_context *intel ) OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3)); OUT_BATCH(_3DSTATE_RASTER_RULES_CMD | - ENABLE_POINT_RASTER_RULE | - OGL_POINT_RASTER_RULE | - ENABLE_LINE_STRIP_PROVOKE_VRTX | - ENABLE_TRI_FAN_PROVOKE_VRTX | - ENABLE_TRI_STRIP_PROVOKE_VRTX | - LINE_STRIP_PROVOKE_VRTX(1) | - TRI_FAN_PROVOKE_VRTX(2) | - TRI_STRIP_PROVOKE_VRTX(2)); + ENABLE_POINT_RASTER_RULE | + OGL_POINT_RASTER_RULE | + ENABLE_LINE_STRIP_PROVOKE_VRTX | + ENABLE_TRI_FAN_PROVOKE_VRTX | + ENABLE_TRI_STRIP_PROVOKE_VRTX | + LINE_STRIP_PROVOKE_VRTX(1) | + TRI_FAN_PROVOKE_VRTX(2) | TRI_STRIP_PROVOKE_VRTX(2)); OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM); OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE); @@ -340,7 +358,7 @@ static void i830_emit_invarient_state( struct intel_context *intel ) OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD); - OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */ + OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */ ADVANCE_BATCH(); } @@ -357,30 +375,31 @@ do { \ ADVANCE_BATCH(); \ } while (0) -static GLuint get_state_size( struct i830_hw_state *state ) +static GLuint +get_state_size(struct i830_hw_state *state) { GLuint dirty = state->active & ~state->emitted; GLuint sz = 0; GLuint i; - if (dirty & I830_UPLOAD_INVARIENT) + if (dirty & I830_UPLOAD_INVARIENT) sz += 40 * sizeof(int); - if (dirty & I830_UPLOAD_CTX) + if (dirty & I830_UPLOAD_CTX) sz += sizeof(state->Ctx); - if (dirty & I830_UPLOAD_BUFFERS) + if (dirty & I830_UPLOAD_BUFFERS) sz += sizeof(state->Buffer); - if (dirty & I830_UPLOAD_STIPPLE) + if (dirty & I830_UPLOAD_STIPPLE) sz += sizeof(state->Stipple); for (i = 0; i < I830_TEX_UNITS; i++) { - if ((dirty & I830_UPLOAD_TEX(i))) - sz += sizeof(state->Tex[i]); + if ((dirty & I830_UPLOAD_TEX(i))) + sz += sizeof(state->Tex[i]); - if (dirty & I830_UPLOAD_TEXBLEND(i)) - sz += state->TexBlendWordsUsed[i] * 4; + if (dirty & I830_UPLOAD_TEXBLEND(i)) + sz += state->TexBlendWordsUsed[i] * 4; } return sz; @@ -389,7 +408,8 @@ static GLuint get_state_size( struct i830_hw_state *state ) /* Push the state into the sarea and/or texture memory. */ -static void i830_emit_state( struct intel_context *intel ) +static void +i830_emit_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); struct i830_hw_state *state = i830->current; @@ -404,32 +424,34 @@ static void i830_emit_state( struct intel_context *intel ) * scheduling is allowed, rather than assume that it is whenever a * batchbuffer fills up. */ - intel_batchbuffer_require_space(intel->batch, - get_state_size(state), - 0); + intel_batchbuffer_require_space(intel->batch, get_state_size(state), 0); if (dirty & I830_UPLOAD_INVARIENT) { - DBG("I830_UPLOAD_INVARIENT:\n"); - i830_emit_invarient_state( intel ); + DBG("I830_UPLOAD_INVARIENT:\n"); + i830_emit_invarient_state(intel); } if (dirty & I830_UPLOAD_CTX) { - DBG("I830_UPLOAD_CTX:\n"); - emit( i830, state->Ctx, sizeof(state->Ctx) ); + DBG("I830_UPLOAD_CTX:\n"); + emit(i830, state->Ctx, sizeof(state->Ctx)); } if (dirty & I830_UPLOAD_BUFFERS) { - DBG("I830_UPLOAD_BUFFERS:\n"); - BEGIN_BATCH(I830_DEST_SETUP_SIZE+2, 0); + DBG("I830_UPLOAD_BUFFERS:\n"); + BEGIN_BATCH(I830_DEST_SETUP_SIZE + 2, 0); OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR0]); OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR1]); - OUT_RELOC(state->draw_region->buffer, DRM_MM_TT|DRM_MM_WRITE, 0); + OUT_RELOC(state->draw_region->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); if (state->depth_region) { - OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR0]); - OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR1]); - OUT_RELOC(state->depth_region->buffer, DRM_MM_TT |DRM_MM_WRITE, 0); + OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR0]); + OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR1]); + OUT_RELOC(state->depth_region->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); } OUT_BATCH(state->Buffer[I830_DESTREG_DV0]); @@ -442,55 +464,57 @@ static void i830_emit_state( struct intel_context *intel ) } if (dirty & I830_UPLOAD_STIPPLE) { - DBG("I830_UPLOAD_STIPPLE:\n"); - emit( i830, state->Stipple, sizeof(state->Stipple) ); + DBG("I830_UPLOAD_STIPPLE:\n"); + emit(i830, state->Stipple, sizeof(state->Stipple)); } for (i = 0; i < I830_TEX_UNITS; i++) { - if ((dirty & I830_UPLOAD_TEX(i))) { - DBG("I830_UPLOAD_TEX(%d):\n", i); + if ((dirty & I830_UPLOAD_TEX(i))) { + DBG("I830_UPLOAD_TEX(%d):\n", i); - BEGIN_BATCH(I830_TEX_SETUP_SIZE+1, 0); - OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]); + BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1, 0); + OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]); - if (state->tex_buffer[i]) { - OUT_RELOC(state->tex_buffer[i], - DRM_MM_TT|DRM_MM_READ, - state->tex_offset[i] | TM0S0_USE_FENCE); - } - else { - assert(i == 0); - assert(state == &i830->meta); - OUT_BATCH(0); - } + if (state->tex_buffer[i]) { + OUT_RELOC(state->tex_buffer[i], + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, + state->tex_offset[i] | TM0S0_USE_FENCE); + } + else { + assert(i == 0); + assert(state == &i830->meta); + OUT_BATCH(0); + } - OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S1]); - OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S2]); - OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S3]); - OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S4]); - OUT_BATCH(state->Tex[i][I830_TEXREG_MCS]); - OUT_BATCH(state->Tex[i][I830_TEXREG_CUBE]); - } + OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S1]); + OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S2]); + OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S3]); + OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S4]); + OUT_BATCH(state->Tex[i][I830_TEXREG_MCS]); + OUT_BATCH(state->Tex[i][I830_TEXREG_CUBE]); + } if (dirty & I830_UPLOAD_TEXBLEND(i)) { - DBG("I830_UPLOAD_TEXBLEND(%d): %d words\n", i, - state->TexBlendWordsUsed[i]); - emit( i830, state->TexBlend[i], - state->TexBlendWordsUsed[i] * 4 ); + DBG("I830_UPLOAD_TEXBLEND(%d): %d words\n", i, + state->TexBlendWordsUsed[i]); + emit(i830, state->TexBlend[i], state->TexBlendWordsUsed[i] * 4); } } state->emitted |= dirty; } -static void i830_destroy_context( struct intel_context *intel ) +static void +i830_destroy_context(struct intel_context *intel) { _tnl_free_vertices(&intel->ctx); } -static void i830_set_draw_region( struct intel_context *intel, - struct intel_region *draw_region, - struct intel_region *depth_region) +static void +i830_set_draw_region(struct intel_context *intel, + struct intel_region *draw_region, + struct intel_region *depth_region) { struct i830_context *i830 = i830_context(&intel->ctx); @@ -501,24 +525,27 @@ static void i830_set_draw_region( struct intel_context *intel, /* XXX FBO: Need code from i915_set_draw_region() */ - I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS ); - I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS ); + I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); + I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); i830->state.Buffer[I830_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(draw_region->pitch) | BUF_3D_USE_FENCE); + (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(draw_region->pitch) | + BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch) | BUF_3D_USE_FENCE); + (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch) | + BUF_3D_USE_FENCE); } #if 0 static void i830_update_color_z_regions(intelContextPtr intel, - const intelRegion *colorRegion, - const intelRegion *depthRegion) + const intelRegion * colorRegion, + const intelRegion * depthRegion) { i830ContextPtr i830 = I830_CONTEXT(intel); i830->state.Buffer[I830_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | BUF_3D_USE_FENCE); + (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | + BUF_3D_USE_FENCE); i830->state.Buffer[I830_DESTREG_CBUFADDR2] = colorRegion->offset; i830->state.Buffer[I830_DESTREG_DBUFADDR1] = @@ -530,7 +557,8 @@ i830_update_color_z_regions(intelContextPtr intel, /* This isn't really handled at the moment. */ -static void i830_lost_hardware( struct intel_context *intel ) +static void +i830_lost_hardware(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); i830->state.emitted = 0; @@ -538,15 +566,17 @@ static void i830_lost_hardware( struct intel_context *intel ) -static GLuint i830_flush_cmd( void ) +static GLuint +i830_flush_cmd(void) { - return MI_FLUSH | FLUSH_MAP_CACHE; + return MI_FLUSH | FLUSH_MAP_CACHE; } -void i830InitVtbl( struct i830_context *i830 ) +void +i830InitVtbl(struct i830_context *i830) { i830->intel.vtbl.check_vertex_size = i830_check_vertex_size; i830->intel.vtbl.destroy = i830_destroy_context; diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 7ebb2137341..1709da87338 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -41,7 +41,6 @@ #include "utils.h" #include "i915_reg.h" -#include "intel_bufmgr.h" #include "intel_regions.h" #include "intel_batchbuffer.h" @@ -49,28 +48,28 @@ * Mesa's Driver Functions ***************************************/ -static const struct dri_extension i915_extensions[] = -{ - { "GL_ARB_depth_texture", NULL }, - { "GL_ARB_fragment_program", NULL }, - { "GL_ARB_shadow", NULL }, - { "GL_ARB_texture_env_crossbar", NULL }, - { "GL_ARB_texture_non_power_of_two", NULL }, - { "GL_EXT_shadow_funcs", NULL }, - /* ARB extn won't work if not enabled */ - { "GL_SGIX_depth_texture", NULL }, - { NULL, NULL } +static const struct dri_extension i915_extensions[] = { + {"GL_ARB_depth_texture", NULL}, + {"GL_ARB_fragment_program", NULL}, + {"GL_ARB_shadow", NULL}, + {"GL_ARB_texture_env_crossbar", NULL}, + {"GL_ARB_texture_non_power_of_two", NULL}, + {"GL_EXT_shadow_funcs", NULL}, + /* ARB extn won't work if not enabled */ + {"GL_SGIX_depth_texture", NULL}, + {NULL, NULL} }; /* Override intel default. */ -static void i915InvalidateState( GLcontext *ctx, GLuint new_state ) +static void +i915InvalidateState(GLcontext * ctx, GLuint new_state) { - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _ac_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - _tnl_invalidate_vertex_state( ctx, new_state ); + _swrast_InvalidateState(ctx, new_state); + _swsetup_InvalidateState(ctx, new_state); + _ac_InvalidateState(ctx, new_state); + _tnl_InvalidateState(ctx, new_state); + _tnl_invalidate_vertex_state(ctx, new_state); intel_context(ctx)->NewGLState |= new_state; /* Todo: gather state values under which tracked parameters become @@ -78,48 +77,52 @@ static void i915InvalidateState( GLcontext *ctx, GLuint new_state ) * ProgramLocalParameters, etc. */ { - struct i915_fragment_program *p = - (struct i915_fragment_program *)ctx->FragmentProgram._Current; + struct i915_fragment_program *p = + (struct i915_fragment_program *) ctx->FragmentProgram._Current; if (p && p->nr_params) - p->params_uptodate = 0; + p->params_uptodate = 0; } - if (new_state & (_NEW_FOG|_NEW_HINT|_NEW_PROGRAM)) + if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM)) i915_update_fog(ctx); } -static void i915InitDriverFunctions( struct dd_function_table *functions ) +static void +i915InitDriverFunctions(struct dd_function_table *functions) { - intelInitDriverFunctions( functions ); - i915InitStateFunctions( functions ); - i915InitTextureFuncs( functions ); - i915InitFragProgFuncs( functions ); + intelInitDriverFunctions(functions); + i915InitStateFunctions(functions); + i915InitTextureFuncs(functions); + i915InitFragProgFuncs(functions); functions->UpdateState = i915InvalidateState; } -GLboolean i915CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) +GLboolean +i915CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate) { struct dd_function_table functions; - struct i915_context *i915 = (struct i915_context *) CALLOC_STRUCT(i915_context); + struct i915_context *i915 = + (struct i915_context *) CALLOC_STRUCT(i915_context); struct intel_context *intel = &i915->intel; GLcontext *ctx = &intel->ctx; - if (!i915) return GL_FALSE; + if (!i915) + return GL_FALSE; - _mesa_printf( "\ntexmem branch (i915, drop3)\n\n"); - - i915InitVtbl( i915 ); - i915InitMetaFuncs( i915 ); + _mesa_printf("\ntexmem branch (i915, drop3)\n\n"); - i915InitDriverFunctions( &functions ); + i915InitVtbl(i915); + i915InitMetaFuncs(i915); - if (!intelInitContext( intel, mesaVis, driContextPriv, - sharedContextPrivate, &functions )) { + i915InitDriverFunctions(&functions); + + if (!intelInitContext(intel, mesaVis, driContextPriv, + sharedContextPrivate, &functions)) { FREE(i915); return GL_FALSE; } @@ -135,37 +138,37 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis, ctx->Const.MaxTextureLevels = 12; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 12; - ctx->Const.MaxTextureRectSize = (1<<11); + ctx->Const.MaxTextureRectSize = (1 << 11); ctx->Const.MaxTextureUnits = I915_TEX_UNITS; /* GL_ARB_fragment_program limits - don't think Mesa actually * validates programs against these, and in any case one ARB * instruction can translate to more than one HW instruction, so * we'll still have to check and fallback each time. - */ + */ ctx->Const.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY; - ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */ + ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */ ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT; ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN; ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN; - ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN + - I915_MAX_TEX_INSN); - ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT; + ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN + + I915_MAX_TEX_INSN); + ctx->Const.FragmentProgram.MaxNativeTexIndirections = + I915_MAX_TEX_INDIRECT; ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */ ctx->_MaintainTexEnvProgram = 1; ctx->_UseTexEnvProgram = 1; - driInitExtensions( ctx, i915_extensions, GL_FALSE ); + driInitExtensions(ctx, i915_extensions, GL_FALSE); - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - 36 * sizeof(GLfloat) ); + _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, + 36 * sizeof(GLfloat)); intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; - i915InitState( i915 ); + i915InitState(i915); return GL_TRUE; } - diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index c04232ec6af..5ae76fcd185 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -114,13 +114,14 @@ /* Hardware version of a parsed fragment program. "Derived" from the * mesa fragment_program struct. */ -struct i915_fragment_program { +struct i915_fragment_program +{ struct gl_fragment_program FragProg; GLboolean translated; GLboolean params_uptodate; GLboolean on_hardware; - GLboolean error; /* If program is malformed for any reason. */ + GLboolean error; /* If program is malformed for any reason. */ GLuint nr_tex_indirect; GLuint nr_tex_insn; @@ -142,22 +143,22 @@ struct i915_fragment_program { GLuint constant_flags[I915_MAX_CONSTANT]; GLuint nr_constants; - GLuint *csr; /* Cursor, points into program. - */ + GLuint *csr; /* Cursor, points into program. + */ - GLuint *decl; /* Cursor, points into declarations. - */ - - GLuint decl_s; /* flags for which s regs need to be decl'd */ - GLuint decl_t; /* flags for which t regs need to be decl'd */ + GLuint *decl; /* Cursor, points into declarations. + */ - GLuint temp_flag; /* Tracks temporary regs which are in - * use. - */ + GLuint decl_s; /* flags for which s regs need to be decl'd */ + GLuint decl_t; /* flags for which t regs need to be decl'd */ - GLuint utemp_flag; /* Tracks TYPE_U temporary regs which are in - * use. - */ + GLuint temp_flag; /* Tracks temporary regs which are in + * use. + */ + + GLuint utemp_flag; /* Tracks TYPE_U temporary regs which are in + * use. + */ @@ -166,24 +167,25 @@ struct i915_fragment_program { GLuint wpos_tex; GLboolean depth_written; - struct { - GLuint reg; /* Hardware constant idx */ - const GLfloat *values; /* Pointer to tracked values */ + struct + { + GLuint reg; /* Hardware constant idx */ + const GLfloat *values; /* Pointer to tracked values */ } param[I915_MAX_CONSTANT]; GLuint nr_params; - + /* Helpers for i915_texprog.c: */ - GLuint src_texture; /* Reg containing sampled texture color, - * else UREG_BAD. - */ + GLuint src_texture; /* Reg containing sampled texture color, + * else UREG_BAD. + */ - GLuint src_previous; /* Reg containing color from previous - * stage. May need to be decl'd. - */ + GLuint src_previous; /* Reg containing color from previous + * stage. May need to be decl'd. + */ - GLuint last_tex_stage; /* Number of last enabled texture unit */ + GLuint last_tex_stage; /* Number of last enabled texture unit */ struct vertex_buffer *VB; }; @@ -197,7 +199,8 @@ struct i915_fragment_program { #define I915_TEX_UNITS 8 -struct i915_hw_state { +struct i915_hw_state +{ GLuint Ctx[I915_CTX_SETUP_SIZE]; GLuint Buffer[I915_DEST_SETUP_SIZE]; GLuint Stipple[I915_STP_SETUP_SIZE]; @@ -208,7 +211,7 @@ struct i915_hw_state { GLuint ConstantSize; GLuint Program[I915_PROGRAM_SIZE]; GLuint ProgramSize; - + /* Region pointers for relocation: */ struct intel_region *draw_region; @@ -219,19 +222,19 @@ struct i915_hw_state { * be from a PBO or FBO. Just use the buffer id. Will have to do * this for draw and depth for FBO's... */ - struct buffer *tex_buffer[I915_TEX_UNITS]; + struct _DriBufferObject *tex_buffer[I915_TEX_UNITS]; GLuint tex_offset[I915_TEX_UNITS]; - - GLuint active; /* I915_UPLOAD_* */ - GLuint emitted; /* I915_UPLOAD_* */ + + GLuint active; /* I915_UPLOAD_* */ + GLuint emitted; /* I915_UPLOAD_* */ }; #define I915_FOG_PIXEL 2 #define I915_FOG_VERTEX 1 #define I915_FOG_NONE 0 -struct i915_context +struct i915_context { struct intel_context intel; @@ -266,10 +269,10 @@ do { \ /*====================================================================== * i915_vtbl.c */ -extern void i915InitVtbl( struct i915_context *i915 ); +extern void i915InitVtbl(struct i915_context *i915); extern void -i915_state_draw_region(struct intel_context *intel, +i915_state_draw_region(struct intel_context *intel, struct i915_hw_state *state, struct intel_region *color_region, struct intel_region *depth_region); @@ -301,58 +304,58 @@ do { \ /*====================================================================== * i915_context.c */ -extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate); +extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); /*====================================================================== * i915_texprog.c */ -extern void i915ValidateTextureProgram( struct i915_context *i915 ); +extern void i915ValidateTextureProgram(struct i915_context *i915); /*====================================================================== * i915_debug.c */ -extern void i915_disassemble_program( const GLuint *program, GLuint sz ); -extern void i915_print_ureg( const char *msg, GLuint ureg ); +extern void i915_disassemble_program(const GLuint * program, GLuint sz); +extern void i915_print_ureg(const char *msg, GLuint ureg); /*====================================================================== * i915_state.c */ -extern void i915InitStateFunctions( struct dd_function_table *functions ); -extern void i915InitState( struct i915_context *i915 ); -extern void i915_update_fog( GLcontext *ctx ); +extern void i915InitStateFunctions(struct dd_function_table *functions); +extern void i915InitState(struct i915_context *i915); +extern void i915_update_fog(GLcontext * ctx); /*====================================================================== * i915_tex.c */ -extern void i915UpdateTextureState( struct intel_context *intel ); -extern void i915InitTextureFuncs( struct dd_function_table *functions ); +extern void i915UpdateTextureState(struct intel_context *intel); +extern void i915InitTextureFuncs(struct dd_function_table *functions); /*====================================================================== * i915_metaops.c */ -void i915InitMetaFuncs( struct i915_context *i915 ); +void i915InitMetaFuncs(struct i915_context *i915); /*====================================================================== * i915_fragprog.c */ -extern void i915ValidateFragmentProgram( struct i915_context *i915 ); -extern void i915InitFragProgFuncs( struct dd_function_table *functions ); +extern void i915ValidateFragmentProgram(struct i915_context *i915); +extern void i915InitFragProgFuncs(struct dd_function_table *functions); /*====================================================================== * Inline conversion functions. These are better-typed than the * macros used previously: */ static INLINE struct i915_context * -i915_context( GLcontext *ctx ) +i915_context(GLcontext * ctx) { - return (struct i915_context *)ctx; + return (struct i915_context *) ctx; } @@ -360,6 +363,5 @@ i915_context( GLcontext *ctx ) #define I915_CONTEXT(ctx) i915_context(ctx) - -#endif +#endif diff --git a/src/mesa/drivers/dri/i915/i915_debug.c b/src/mesa/drivers/dri/i915/i915_debug.c index 054b561605a..974527e14cc 100644 --- a/src/mesa/drivers/dri/i915/i915_debug.c +++ b/src/mesa/drivers/dri/i915/i915_debug.c @@ -67,27 +67,27 @@ static const char *opcodes[0x20] = { static const int args[0x20] = { - 0, /* 0 nop */ - 2, /* 1 add */ - 1, /* 2 mov */ - 2, /* 3 m ul */ - 3, /* 4 mad */ - 3, /* 5 dp2add */ - 2, /* 6 dp3 */ - 2, /* 7 dp4 */ - 1, /* 8 frc */ - 1, /* 9 rcp */ - 1, /* a rsq */ - 1, /* b exp */ - 1, /* c log */ - 3, /* d cmp */ - 2, /* e min */ - 2, /* f max */ - 1, /* 10 flr */ - 1, /* 11 mod */ - 1, /* 12 trc */ - 2, /* 13 sge */ - 2, /* 14 slt */ + 0, /* 0 nop */ + 2, /* 1 add */ + 1, /* 2 mov */ + 2, /* 3 m ul */ + 3, /* 4 mad */ + 3, /* 5 dp2add */ + 2, /* 6 dp3 */ + 2, /* 7 dp4 */ + 1, /* 8 frc */ + 1, /* 9 rcp */ + 1, /* a rsq */ + 1, /* b exp */ + 1, /* c log */ + 3, /* d cmp */ + 2, /* e min */ + 2, /* f max */ + 1, /* 10 flr */ + 1, /* 11 mod */ + 1, /* 12 trc */ + 2, /* 13 sge */ + 2, /* 14 slt */ 1, 1, 1, @@ -113,26 +113,35 @@ static const char *regname[0x8] = { "UNKNOWN", }; -static void print_reg_type_nr( GLuint type, GLuint nr ) +static void +print_reg_type_nr(GLuint type, GLuint nr) { switch (type) { case REG_TYPE_T: switch (nr) { - case T_DIFFUSE: fprintf(stderr, "T_DIFFUSE"); return; - case T_SPECULAR: fprintf(stderr, "T_SPECULAR"); return; - case T_FOG_W: fprintf(stderr, "T_FOG_W"); return; - default: fprintf(stderr, "T_TEX%d", nr); return; + case T_DIFFUSE: + fprintf(stderr, "T_DIFFUSE"); + return; + case T_SPECULAR: + fprintf(stderr, "T_SPECULAR"); + return; + case T_FOG_W: + fprintf(stderr, "T_FOG_W"); + return; + default: + fprintf(stderr, "T_TEX%d", nr); + return; } case REG_TYPE_OC: if (nr == 0) { - fprintf(stderr, "oC"); - return; + fprintf(stderr, "oC"); + return; } break; case REG_TYPE_OD: if (nr == 0) { - fprintf(stderr, "oD"); - return; + fprintf(stderr, "oD"); + return; } break; default: @@ -151,7 +160,8 @@ static void print_reg_type_nr( GLuint type, GLuint nr ) (SRC_W << A2_SRC2_CHANNEL_W_SHIFT)) -static void print_reg_neg_swizzle( GLuint reg ) +static void +print_reg_neg_swizzle(GLuint reg) { int i; @@ -161,50 +171,71 @@ static void print_reg_neg_swizzle( GLuint reg ) fprintf(stderr, "."); - for (i = 3 ; i >= 0; i--) { - if (reg & (1<<((i*4)+3))) - fprintf(stderr, "-"); - - switch ((reg>>(i*4)) & 0x7) { - case 0: fprintf(stderr, "x"); break; - case 1: fprintf(stderr, "y"); break; - case 2: fprintf(stderr, "z"); break; - case 3: fprintf(stderr, "w"); break; - case 4: fprintf(stderr, "0"); break; - case 5: fprintf(stderr, "1"); break; - default: fprintf(stderr, "?"); break; + for (i = 3; i >= 0; i--) { + if (reg & (1 << ((i * 4) + 3))) + fprintf(stderr, "-"); + + switch ((reg >> (i * 4)) & 0x7) { + case 0: + fprintf(stderr, "x"); + break; + case 1: + fprintf(stderr, "y"); + break; + case 2: + fprintf(stderr, "z"); + break; + case 3: + fprintf(stderr, "w"); + break; + case 4: + fprintf(stderr, "0"); + break; + case 5: + fprintf(stderr, "1"); + break; + default: + fprintf(stderr, "?"); + break; } } } -static void print_src_reg( GLuint dword ) +static void +print_src_reg(GLuint dword) { GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr( type, nr ); - print_reg_neg_swizzle( dword ); + print_reg_type_nr(type, nr); + print_reg_neg_swizzle(dword); } -void i915_print_ureg( const char *msg, GLuint ureg ) +void +i915_print_ureg(const char *msg, GLuint ureg) { fprintf(stderr, "%s: ", msg); - print_src_reg( ureg >> 8 ); + print_src_reg(ureg >> 8); fprintf(stderr, "\n"); } -static void print_dest_reg( GLuint dword ) +static void +print_dest_reg(GLuint dword) { GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr( type, nr ); + print_reg_type_nr(type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; fprintf(stderr, "."); - if (dword & A0_DEST_CHANNEL_X) fprintf(stderr, "x"); - if (dword & A0_DEST_CHANNEL_Y) fprintf(stderr, "y"); - if (dword & A0_DEST_CHANNEL_Z) fprintf(stderr, "z"); - if (dword & A0_DEST_CHANNEL_W) fprintf(stderr, "w"); + if (dword & A0_DEST_CHANNEL_X) + fprintf(stderr, "x"); + if (dword & A0_DEST_CHANNEL_Y) + fprintf(stderr, "y"); + if (dword & A0_DEST_CHANNEL_Z) + fprintf(stderr, "z"); + if (dword & A0_DEST_CHANNEL_W) + fprintf(stderr, "w"); } @@ -213,14 +244,15 @@ static void print_dest_reg( GLuint dword ) #define GET_SRC2_REG(r) (r) -static void print_arith_op( GLuint opcode, const GLuint *program ) +static void +print_arith_op(GLuint opcode, const GLuint * program) { if (opcode != A0_NOP) { print_dest_reg(program[0]); if (program[0] & A0_DEST_SATURATE) - fprintf(stderr, " = SATURATE "); + fprintf(stderr, " = SATURATE "); else - fprintf(stderr, " = "); + fprintf(stderr, " = "); } fprintf(stderr, "%s ", opcodes[opcode]); @@ -233,7 +265,7 @@ static void print_arith_op( GLuint opcode, const GLuint *program ) fprintf(stderr, ", "); print_src_reg(GET_SRC1_REG(program[1], program[2])); - if (args[opcode] == 2) { + if (args[opcode] == 2) { fprintf(stderr, "\n"); return; } @@ -245,22 +277,24 @@ static void print_arith_op( GLuint opcode, const GLuint *program ) } -static void print_tex_op( GLuint opcode, const GLuint *program ) +static void +print_tex_op(GLuint opcode, const GLuint * program) { print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); fprintf(stderr, " = "); fprintf(stderr, "%s ", opcodes[opcode]); - fprintf(stderr, "S[%d],", - program[0] & T0_SAMPLER_NR_MASK); + fprintf(stderr, "S[%d],", program[0] & T0_SAMPLER_NR_MASK); - print_reg_type_nr( (program[1]>>T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, - (program[1]>>T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK ); + print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & + REG_TYPE_MASK, + (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); fprintf(stderr, "\n"); } -static void print_dcl_op( GLuint opcode, const GLuint *program ) +static void +print_dcl_op(GLuint opcode, const GLuint * program) { fprintf(stderr, "%s ", opcodes[opcode]); print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); @@ -268,31 +302,32 @@ static void print_dcl_op( GLuint opcode, const GLuint *program ) } -void i915_disassemble_program( const GLuint *program, GLuint sz ) +void +i915_disassemble_program(const GLuint * program, GLuint sz) { GLuint size = program[0] & 0x1ff; GLint i; - + fprintf(stderr, "BEGIN\n"); - if (size+2 != sz) { + if (size + 2 != sz) { fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__, - size+2, sz); + size + 2, sz); exit(1); } - program ++; - for (i = 1 ; i < sz ; i+=3, program+=3) { - GLuint opcode = program[0] & (0x1f<<24); + program++; + for (i = 1; i < sz; i += 3, program += 3) { + GLuint opcode = program[0] & (0x1f << 24); if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) - print_arith_op(opcode >> 24, program); + print_arith_op(opcode >> 24, program); else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) - print_tex_op(opcode >> 24, program); + print_tex_op(opcode >> 24, program); else if (opcode == D0_DCL) - print_dcl_op(opcode >> 24, program); - else - fprintf(stderr, "Unknown opcode 0x%x\n", opcode); + print_dcl_op(opcode >> 24, program); + else + fprintf(stderr, "Unknown opcode 0x%x\n", opcode); } fprintf(stderr, "END\n\n"); diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index c5f28dccbbb..ac5cf2ead28 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -42,24 +42,27 @@ /* 1, -1/3!, 1/5!, -1/7! */ -static const GLfloat sin_constants[4] = { 1.0, - -1.0/(3*2*1), - 1.0/(5*4*3*2*1), - -1.0/(7*6*5*4*3*2*1) }; +static const GLfloat sin_constants[4] = { 1.0, + -1.0 / (3 * 2 * 1), + 1.0 / (5 * 4 * 3 * 2 * 1), + -1.0 / (7 * 6 * 5 * 4 * 3 * 2 * 1) +}; /* 1, -1/2!, 1/4!, -1/6! */ -static const GLfloat cos_constants[4] = { 1.0, - -1.0/(2*1), - 1.0/(4*3*2*1), - -1.0/(6*5*4*3*2*1) }; +static const GLfloat cos_constants[4] = { 1.0, + -1.0 / (2 * 1), + 1.0 / (4 * 3 * 2 * 1), + -1.0 / (6 * 5 * 4 * 3 * 2 * 1) +}; /** * Retrieve a ureg for the given source register. Will emit * constants, apply swizzling and negation as needed. */ -static GLuint src_vector( struct i915_fragment_program *p, - const struct prog_src_register *source, - const struct gl_fragment_program *program ) +static GLuint +src_vector(struct i915_fragment_program *p, + const struct prog_src_register *source, + const struct gl_fragment_program *program) { GLuint src; @@ -67,135 +70,151 @@ static GLuint src_vector( struct i915_fragment_program *p, /* Registers: */ - case PROGRAM_TEMPORARY: - if (source->Index >= I915_MAX_TEMPORARY) { - i915_program_error( p, "Exceeded max temporary reg" ); - return 0; - } - src = UREG( REG_TYPE_R, source->Index ); + case PROGRAM_TEMPORARY: + if (source->Index >= I915_MAX_TEMPORARY) { + i915_program_error(p, "Exceeded max temporary reg"); + return 0; + } + src = UREG(REG_TYPE_R, source->Index); + break; + case PROGRAM_INPUT: + switch (source->Index) { + case FRAG_ATTRIB_WPOS: + src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); break; - case PROGRAM_INPUT: - switch (source->Index) { - case FRAG_ATTRIB_WPOS: - src = i915_emit_decl( p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL ); - break; - case FRAG_ATTRIB_COL0: - src = i915_emit_decl( p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL ); - break; - case FRAG_ATTRIB_COL1: - src = i915_emit_decl( p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ ); - src = swizzle( src, X, Y, Z, ONE ); - break; - case FRAG_ATTRIB_FOGC: - src = i915_emit_decl( p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W ); - src = swizzle( src, W, W, W, W ); - break; - case FRAG_ATTRIB_TEX0: - case FRAG_ATTRIB_TEX1: - case FRAG_ATTRIB_TEX2: - case FRAG_ATTRIB_TEX3: - case FRAG_ATTRIB_TEX4: - case FRAG_ATTRIB_TEX5: - case FRAG_ATTRIB_TEX6: - case FRAG_ATTRIB_TEX7: - src = i915_emit_decl( p, REG_TYPE_T, - T_TEX0 + (source->Index - FRAG_ATTRIB_TEX0), - D0_CHANNEL_ALL ); - break; - - default: - i915_program_error( p, "Bad source->Index" ); - return 0; - } + case FRAG_ATTRIB_COL0: + src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); + break; + case FRAG_ATTRIB_COL1: + src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); + src = swizzle(src, X, Y, Z, ONE); + break; + case FRAG_ATTRIB_FOGC: + src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); + src = swizzle(src, W, W, W, W); + break; + case FRAG_ATTRIB_TEX0: + case FRAG_ATTRIB_TEX1: + case FRAG_ATTRIB_TEX2: + case FRAG_ATTRIB_TEX3: + case FRAG_ATTRIB_TEX4: + case FRAG_ATTRIB_TEX5: + case FRAG_ATTRIB_TEX6: + case FRAG_ATTRIB_TEX7: + src = i915_emit_decl(p, REG_TYPE_T, + T_TEX0 + (source->Index - FRAG_ATTRIB_TEX0), + D0_CHANNEL_ALL); break; - - /* Various paramters and env values. All emitted to - * hardware as program constants. - */ - case PROGRAM_LOCAL_PARAM: - src = i915_emit_param4fv( - p, program->Base.LocalParams[source->Index]); - break; - - case PROGRAM_ENV_PARAM: - src = i915_emit_param4fv( - p, p->ctx->FragmentProgram.Parameters[source->Index]); - break; - - case PROGRAM_STATE_VAR: - case PROGRAM_NAMED_PARAM: - src = i915_emit_param4fv( - p, program->Base.Parameters->ParameterValues[source->Index] ); - break; default: - i915_program_error( p, "Bad source->File" ); - return 0; + i915_program_error(p, "Bad source->Index"); + return 0; + } + break; + + /* Various paramters and env values. All emitted to + * hardware as program constants. + */ + case PROGRAM_LOCAL_PARAM: + src = i915_emit_param4fv(p, program->Base.LocalParams[source->Index]); + break; + + case PROGRAM_ENV_PARAM: + src = + i915_emit_param4fv(p, + p->ctx->FragmentProgram.Parameters[source-> + Index]); + break; + + case PROGRAM_STATE_VAR: + case PROGRAM_NAMED_PARAM: + src = + i915_emit_param4fv(p, + program->Base.Parameters->ParameterValues[source-> + Index]); + break; + + default: + i915_program_error(p, "Bad source->File"); + return 0; } - src = swizzle(src, - GET_SWZ(source->Swizzle, 0), - GET_SWZ(source->Swizzle, 1), - GET_SWZ(source->Swizzle, 2), - GET_SWZ(source->Swizzle, 3)); + src = swizzle(src, + GET_SWZ(source->Swizzle, 0), + GET_SWZ(source->Swizzle, 1), + GET_SWZ(source->Swizzle, 2), GET_SWZ(source->Swizzle, 3)); if (source->NegateBase) - src = negate( src, - GET_BIT(source->NegateBase, 0), - GET_BIT(source->NegateBase, 1), - GET_BIT(source->NegateBase, 2), - GET_BIT(source->NegateBase, 3)); + src = negate(src, + GET_BIT(source->NegateBase, 0), + GET_BIT(source->NegateBase, 1), + GET_BIT(source->NegateBase, 2), + GET_BIT(source->NegateBase, 3)); return src; } -static GLuint get_result_vector( struct i915_fragment_program *p, - const struct prog_instruction *inst ) +static GLuint +get_result_vector(struct i915_fragment_program *p, + const struct prog_instruction *inst) { switch (inst->DstReg.File) { case PROGRAM_OUTPUT: switch (inst->DstReg.Index) { - case FRAG_RESULT_COLR: - return UREG(REG_TYPE_OC, 0); - case FRAG_RESULT_DEPR: - p->depth_written = 1; - return UREG(REG_TYPE_OD, 0); - default: - i915_program_error( p, "Bad inst->DstReg.Index" ); - return 0; + case FRAG_RESULT_COLR: + return UREG(REG_TYPE_OC, 0); + case FRAG_RESULT_DEPR: + p->depth_written = 1; + return UREG(REG_TYPE_OD, 0); + default: + i915_program_error(p, "Bad inst->DstReg.Index"); + return 0; } case PROGRAM_TEMPORARY: return UREG(REG_TYPE_R, inst->DstReg.Index); default: - i915_program_error( p, "Bad inst->DstReg.File" ); + i915_program_error(p, "Bad inst->DstReg.File"); return 0; } } - -static GLuint get_result_flags( const struct prog_instruction *inst ) + +static GLuint +get_result_flags(const struct prog_instruction *inst) { GLuint flags = 0; - if (inst->SaturateMode == SATURATE_ZERO_ONE) flags |= A0_DEST_SATURATE; - if (inst->DstReg.WriteMask & WRITEMASK_X) flags |= A0_DEST_CHANNEL_X; - if (inst->DstReg.WriteMask & WRITEMASK_Y) flags |= A0_DEST_CHANNEL_Y; - if (inst->DstReg.WriteMask & WRITEMASK_Z) flags |= A0_DEST_CHANNEL_Z; - if (inst->DstReg.WriteMask & WRITEMASK_W) flags |= A0_DEST_CHANNEL_W; + if (inst->SaturateMode == SATURATE_ZERO_ONE) + flags |= A0_DEST_SATURATE; + if (inst->DstReg.WriteMask & WRITEMASK_X) + flags |= A0_DEST_CHANNEL_X; + if (inst->DstReg.WriteMask & WRITEMASK_Y) + flags |= A0_DEST_CHANNEL_Y; + if (inst->DstReg.WriteMask & WRITEMASK_Z) + flags |= A0_DEST_CHANNEL_Z; + if (inst->DstReg.WriteMask & WRITEMASK_W) + flags |= A0_DEST_CHANNEL_W; return flags; } -static GLuint translate_tex_src_target( struct i915_fragment_program *p, - GLubyte bit ) +static GLuint +translate_tex_src_target(struct i915_fragment_program *p, GLubyte bit) { switch (bit) { - case TEXTURE_1D_INDEX: return D0_SAMPLE_TYPE_2D; - case TEXTURE_2D_INDEX: return D0_SAMPLE_TYPE_2D; - case TEXTURE_RECT_INDEX: return D0_SAMPLE_TYPE_2D; - case TEXTURE_3D_INDEX: return D0_SAMPLE_TYPE_VOLUME; - case TEXTURE_CUBE_INDEX: return D0_SAMPLE_TYPE_CUBE; - default: i915_program_error(p, "TexSrcBit"); return 0; + case TEXTURE_1D_INDEX: + return D0_SAMPLE_TYPE_2D; + case TEXTURE_2D_INDEX: + return D0_SAMPLE_TYPE_2D; + case TEXTURE_RECT_INDEX: + return D0_SAMPLE_TYPE_2D; + case TEXTURE_3D_INDEX: + return D0_SAMPLE_TYPE_VOLUME; + case TEXTURE_CUBE_INDEX: + return D0_SAMPLE_TYPE_CUBE; + default: + i915_program_error(p, "TexSrcBit"); + return 0; } } @@ -242,9 +261,11 @@ do { \ * can lead to confusion -- hopefully we cope with it ok now. * */ -static void upload_program( struct i915_fragment_program *p ) +static void +upload_program(struct i915_fragment_program *p) { - const struct gl_fragment_program *program = p->ctx->FragmentProgram._Current; + const struct gl_fragment_program *program = + p->ctx->FragmentProgram._Current; const struct prog_instruction *inst = program->Base.Instructions; /* _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */ @@ -254,12 +275,12 @@ static void upload_program( struct i915_fragment_program *p ) * this being uploaded to hardware. */ if (inst[0].Opcode == OPCODE_END) { - GLuint tmp = i915_get_utemp( p ); - i915_emit_arith( p, - A0_MOV, - UREG(REG_TYPE_OC, 0), - A0_DEST_CHANNEL_ALL, 0, - swizzle(tmp,ONE,ZERO,ONE,ONE), 0, 0); + GLuint tmp = i915_get_utemp(p); + i915_emit_arith(p, + A0_MOV, + UREG(REG_TYPE_OC, 0), + A0_DEST_CHANNEL_ALL, 0, + swizzle(tmp, ONE, ZERO, ONE, ONE), 0, 0); return; } @@ -268,496 +289,465 @@ static void upload_program( struct i915_fragment_program *p ) GLuint tmp = 0; switch (inst->Opcode) { - case OPCODE_ABS: - src0 = src_vector( p, &inst->SrcReg[0], program); - i915_emit_arith( p, - A0_MAX, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - src0, negate(src0, 1,1,1,1), 0); - break; + case OPCODE_ABS: + src0 = src_vector(p, &inst->SrcReg[0], program); + i915_emit_arith(p, + A0_MAX, + get_result_vector(p, inst), + get_result_flags(inst), 0, + src0, negate(src0, 1, 1, 1, 1), 0); + break; - case OPCODE_ADD: - EMIT_2ARG_ARITH( A0_ADD ); - break; + case OPCODE_ADD: + EMIT_2ARG_ARITH(A0_ADD); + break; - case OPCODE_CMP: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); - src2 = src_vector( p, &inst->SrcReg[2], program); - i915_emit_arith( p, - A0_CMP, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - src0, src2, src1); /* NOTE: order of src2, src1 */ - break; + case OPCODE_CMP: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); + src2 = src_vector(p, &inst->SrcReg[2], program); + i915_emit_arith(p, A0_CMP, get_result_vector(p, inst), get_result_flags(inst), 0, src0, src2, src1); /* NOTE: order of src2, src1 */ + break; case OPCODE_COS: - src0 = src_vector( p, &inst->SrcReg[0], program); - tmp = i915_get_utemp( p ); + src0 = src_vector(p, &inst->SrcReg[0], program); + tmp = i915_get_utemp(p); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_X, 0, - src0, - i915_emit_const1f(p, 1.0/(M_PI * 2)), - 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_X, 0, + src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); - i915_emit_arith( p, - A0_MOD, - tmp, A0_DEST_CHANNEL_X, 0, - tmp, - 0, 0 ); + i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); - /* By choosing different taylor constants, could get rid of this mul: - */ - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_X, 0, - tmp, - i915_emit_const1f(p, (M_PI * 2)), - 0); + /* By choosing different taylor constants, could get rid of this mul: + */ + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, i915_emit_const1f(p, (M_PI * 2)), 0); - /* - * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 - * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1 - * t0 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1 - * result = DP4 t0, cos_constants - */ - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XY, 0, - swizzle(tmp, X,X,ONE,ONE), - swizzle(tmp, X,ONE,ONE,ONE), 0); + /* + * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 + * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1 + * t0 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1 + * result = DP4 t0, cos_constants + */ + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XY, 0, + swizzle(tmp, X, X, ONE, ONE), + swizzle(tmp, X, ONE, ONE, ONE), 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XYZ, 0, - swizzle(tmp, X,Y,X,ONE), - swizzle(tmp, X,X,ONE,ONE), 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XYZ, 0, + swizzle(tmp, X, Y, X, ONE), + swizzle(tmp, X, X, ONE, ONE), 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XYZ, 0, - swizzle(tmp, X,X,Z,ONE), - swizzle(tmp, Z,ONE,ONE,ONE), 0); - - i915_emit_arith( p, - A0_DP4, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(tmp, ONE,Z,Y,X), - i915_emit_const4fv( p, cos_constants ), 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XYZ, 0, + swizzle(tmp, X, X, Z, ONE), + swizzle(tmp, Z, ONE, ONE, ONE), 0); - break; + i915_emit_arith(p, + A0_DP4, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(tmp, ONE, Z, Y, X), + i915_emit_const4fv(p, cos_constants), 0); - case OPCODE_DP3: - EMIT_2ARG_ARITH( A0_DP3 ); - break; + break; - case OPCODE_DP4: - EMIT_2ARG_ARITH( A0_DP4 ); - break; + case OPCODE_DP3: + EMIT_2ARG_ARITH(A0_DP3); + break; - case OPCODE_DPH: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); + case OPCODE_DP4: + EMIT_2ARG_ARITH(A0_DP4); + break; - i915_emit_arith( p, - A0_DP4, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0, X,Y,Z,ONE), src1, 0); - break; + case OPCODE_DPH: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); - case OPCODE_DST: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); + i915_emit_arith(p, + A0_DP4, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, X, Y, Z, ONE), src1, 0); + break; - /* result[0] = 1 * 1; - * result[1] = a[1] * b[1]; - * result[2] = a[2] * 1; - * result[3] = 1 * b[3]; - */ - i915_emit_arith( p, - A0_MUL, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0, ONE, Y, Z, ONE), - swizzle(src1, ONE, Y, ONE, W ), - 0); - break; + case OPCODE_DST: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); - case OPCODE_EX2: - src0 = src_vector( p, &inst->SrcReg[0], program); + /* result[0] = 1 * 1; + * result[1] = a[1] * b[1]; + * result[2] = a[2] * 1; + * result[3] = 1 * b[3]; + */ + i915_emit_arith(p, + A0_MUL, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, ONE, Y, Z, ONE), + swizzle(src1, ONE, Y, ONE, W), 0); + break; - i915_emit_arith( p, - A0_EXP, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0,X,X,X,X), 0, 0); - break; + case OPCODE_EX2: + src0 = src_vector(p, &inst->SrcReg[0], program); - case OPCODE_FLR: - EMIT_1ARG_ARITH( A0_FLR ); - break; + i915_emit_arith(p, + A0_EXP, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, X, X, X, X), 0, 0); + break; - case OPCODE_FRC: - EMIT_1ARG_ARITH( A0_FRC ); - break; + case OPCODE_FLR: + EMIT_1ARG_ARITH(A0_FLR); + break; + + case OPCODE_FRC: + EMIT_1ARG_ARITH(A0_FRC); + break; case OPCODE_KIL: - src0 = src_vector( p, &inst->SrcReg[0], program); - tmp = i915_get_utemp( p ); + src0 = src_vector(p, &inst->SrcReg[0], program); + tmp = i915_get_utemp(p); - i915_emit_texld( p, - tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */ - 0, - src0, - T0_TEXKILL ); - break; + i915_emit_texld(p, tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */ + 0, src0, T0_TEXKILL); + break; - case OPCODE_LG2: - src0 = src_vector( p, &inst->SrcReg[0], program); + case OPCODE_LG2: + src0 = src_vector(p, &inst->SrcReg[0], program); - i915_emit_arith( p, - A0_LOG, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0,X,X,X,X), 0, 0); - break; + i915_emit_arith(p, + A0_LOG, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, X, X, X, X), 0, 0); + break; - case OPCODE_LIT: - src0 = src_vector( p, &inst->SrcReg[0], program); - tmp = i915_get_utemp( p ); + case OPCODE_LIT: + src0 = src_vector(p, &inst->SrcReg[0], program); + tmp = i915_get_utemp(p); - /* tmp = max( a.xyzw, a.00zw ) - * XXX: Clamp tmp.w to -128..128 - * tmp.y = log(tmp.y) - * tmp.y = tmp.w * tmp.y - * tmp.y = exp(tmp.y) - * result = cmp (a.11-x1, a.1x01, a.1xy1 ) - */ - i915_emit_arith( p, A0_MAX, tmp, A0_DEST_CHANNEL_ALL, 0, - src0, swizzle(src0, ZERO, ZERO, Z, W), 0 ); + /* tmp = max( a.xyzw, a.00zw ) + * XXX: Clamp tmp.w to -128..128 + * tmp.y = log(tmp.y) + * tmp.y = tmp.w * tmp.y + * tmp.y = exp(tmp.y) + * result = cmp (a.11-x1, a.1x01, a.1xy1 ) + */ + i915_emit_arith(p, A0_MAX, tmp, A0_DEST_CHANNEL_ALL, 0, + src0, swizzle(src0, ZERO, ZERO, Z, W), 0); - i915_emit_arith( p, A0_LOG, tmp, A0_DEST_CHANNEL_Y, 0, - swizzle(tmp, Y, Y, Y, Y), 0, 0 ); + i915_emit_arith(p, A0_LOG, tmp, A0_DEST_CHANNEL_Y, 0, + swizzle(tmp, Y, Y, Y, Y), 0, 0); - i915_emit_arith( p, A0_MUL, tmp, A0_DEST_CHANNEL_Y, 0, - swizzle(tmp, ZERO, Y, ZERO, ZERO), - swizzle(tmp, ZERO, W, ZERO, ZERO), 0 ); + i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_Y, 0, + swizzle(tmp, ZERO, Y, ZERO, ZERO), + swizzle(tmp, ZERO, W, ZERO, ZERO), 0); - i915_emit_arith( p, A0_EXP, tmp, A0_DEST_CHANNEL_Y, 0, - swizzle(tmp, Y, Y, Y, Y), 0, 0 ); + i915_emit_arith(p, A0_EXP, tmp, A0_DEST_CHANNEL_Y, 0, + swizzle(tmp, Y, Y, Y, Y), 0, 0); - i915_emit_arith( p, A0_CMP, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - negate(swizzle(tmp, ONE, ONE, X, ONE),0,0,1,0), - swizzle(tmp, ONE, X, ZERO, ONE), - swizzle(tmp, ONE, X, Y, ONE)); - - break; + i915_emit_arith(p, A0_CMP, + get_result_vector(p, inst), + get_result_flags(inst), 0, + negate(swizzle(tmp, ONE, ONE, X, ONE), 0, 0, 1, 0), + swizzle(tmp, ONE, X, ZERO, ONE), + swizzle(tmp, ONE, X, Y, ONE)); - case OPCODE_LRP: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); - src2 = src_vector( p, &inst->SrcReg[2], program); - flags = get_result_flags( inst ); - tmp = i915_get_utemp( p ); + break; - /* b*a + c*(1-a) - * - * b*a + c - ca - * - * tmp = b*a + c, - * result = (-c)*a + tmp - */ - i915_emit_arith( p, A0_MAD, tmp, - flags & A0_DEST_CHANNEL_ALL, 0, - src1, src0, src2 ); + case OPCODE_LRP: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); + src2 = src_vector(p, &inst->SrcReg[2], program); + flags = get_result_flags(inst); + tmp = i915_get_utemp(p); - i915_emit_arith( p, A0_MAD, - get_result_vector( p, inst ), - flags, 0, - negate(src2, 1,1,1,1), src0, tmp ); - break; + /* b*a + c*(1-a) + * + * b*a + c - ca + * + * tmp = b*a + c, + * result = (-c)*a + tmp + */ + i915_emit_arith(p, A0_MAD, tmp, + flags & A0_DEST_CHANNEL_ALL, 0, src1, src0, src2); + + i915_emit_arith(p, A0_MAD, + get_result_vector(p, inst), + flags, 0, negate(src2, 1, 1, 1, 1), src0, tmp); + break; case OPCODE_MAD: - EMIT_3ARG_ARITH( A0_MAD ); - break; + EMIT_3ARG_ARITH(A0_MAD); + break; case OPCODE_MAX: - EMIT_2ARG_ARITH( A0_MAX ); - break; + EMIT_2ARG_ARITH(A0_MAX); + break; - case OPCODE_MIN: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); - tmp = i915_get_utemp( p ); - flags = get_result_flags( inst ); + case OPCODE_MIN: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); + tmp = i915_get_utemp(p); + flags = get_result_flags(inst); - i915_emit_arith( p, - A0_MAX, - tmp, flags & A0_DEST_CHANNEL_ALL, 0, - negate(src0,1,1,1,1), - negate(src1,1,1,1,1), 0); + i915_emit_arith(p, + A0_MAX, + tmp, flags & A0_DEST_CHANNEL_ALL, 0, + negate(src0, 1, 1, 1, 1), + negate(src1, 1, 1, 1, 1), 0); - i915_emit_arith( p, - A0_MOV, - get_result_vector( p, inst ), - flags, 0, - negate(tmp, 1,1,1,1), 0, 0); - break; + i915_emit_arith(p, + A0_MOV, + get_result_vector(p, inst), + flags, 0, negate(tmp, 1, 1, 1, 1), 0, 0); + break; - case OPCODE_MOV: - EMIT_1ARG_ARITH( A0_MOV ); - break; + case OPCODE_MOV: + EMIT_1ARG_ARITH(A0_MOV); + break; - case OPCODE_MUL: - EMIT_2ARG_ARITH( A0_MUL ); - break; + case OPCODE_MUL: + EMIT_2ARG_ARITH(A0_MUL); + break; - case OPCODE_POW: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); - tmp = i915_get_utemp( p ); - flags = get_result_flags( inst ); + case OPCODE_POW: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); + tmp = i915_get_utemp(p); + flags = get_result_flags(inst); - /* XXX: masking on intermediate values, here and elsewhere. - */ - i915_emit_arith( p, - A0_LOG, - tmp, A0_DEST_CHANNEL_X, 0, - swizzle(src0,X,X,X,X), 0, 0); + /* XXX: masking on intermediate values, here and elsewhere. + */ + i915_emit_arith(p, + A0_LOG, + tmp, A0_DEST_CHANNEL_X, 0, + swizzle(src0, X, X, X, X), 0, 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_X, 0, - tmp, src1, 0); + i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, src1, 0); - i915_emit_arith( p, - A0_EXP, - get_result_vector( p, inst ), - flags, 0, - swizzle(tmp,X,X,X,X), 0, 0); + i915_emit_arith(p, + A0_EXP, + get_result_vector(p, inst), + flags, 0, swizzle(tmp, X, X, X, X), 0, 0); - break; + break; - case OPCODE_RCP: - src0 = src_vector( p, &inst->SrcReg[0], program); + case OPCODE_RCP: + src0 = src_vector(p, &inst->SrcReg[0], program); - i915_emit_arith( p, - A0_RCP, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0,X,X,X,X), 0, 0); - break; + i915_emit_arith(p, + A0_RCP, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, X, X, X, X), 0, 0); + break; - case OPCODE_RSQ: + case OPCODE_RSQ: - src0 = src_vector( p, &inst->SrcReg[0], program); + src0 = src_vector(p, &inst->SrcReg[0], program); + + i915_emit_arith(p, + A0_RSQ, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, X, X, X, X), 0, 0); + break; - i915_emit_arith( p, - A0_RSQ, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0,X,X,X,X), 0, 0); - break; - case OPCODE_SCS: - src0 = src_vector( p, &inst->SrcReg[0], program); - tmp = i915_get_utemp( p ); + src0 = src_vector(p, &inst->SrcReg[0], program); + tmp = i915_get_utemp(p); - /* - * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 - * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x - * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x - * scs.x = DP4 t1, sin_constants - * t1 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1 - * scs.y = DP4 t1, cos_constants - */ - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XY, 0, - swizzle(src0, X,X,ONE,ONE), - swizzle(src0, X,ONE,ONE,ONE), 0); + /* + * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 + * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x + * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x + * scs.x = DP4 t1, sin_constants + * t1 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1 + * scs.y = DP4 t1, cos_constants + */ + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XY, 0, + swizzle(src0, X, X, ONE, ONE), + swizzle(src0, X, ONE, ONE, ONE), 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_ALL, 0, - swizzle(tmp, X,Y,X,Y), - swizzle(tmp, X,X,ONE,ONE), 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_ALL, 0, + swizzle(tmp, X, Y, X, Y), + swizzle(tmp, X, X, ONE, ONE), 0); - if (inst->DstReg.WriteMask & WRITEMASK_Y) { - GLuint tmp1; - - if (inst->DstReg.WriteMask & WRITEMASK_X) - tmp1 = i915_get_utemp( p ); - else - tmp1 = tmp; + if (inst->DstReg.WriteMask & WRITEMASK_Y) { + GLuint tmp1; - i915_emit_arith( p, - A0_MUL, - tmp1, A0_DEST_CHANNEL_ALL, 0, - swizzle(tmp, X,Y,Y,W), - swizzle(tmp, X,Z,ONE,ONE), 0); - - i915_emit_arith( p, - A0_DP4, - get_result_vector( p, inst ), - A0_DEST_CHANNEL_Y, 0, - swizzle(tmp1, W,Z,Y,X), - i915_emit_const4fv( p, sin_constants ), 0); - } + if (inst->DstReg.WriteMask & WRITEMASK_X) + tmp1 = i915_get_utemp(p); + else + tmp1 = tmp; - if (inst->DstReg.WriteMask & WRITEMASK_X) { - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XYZ, 0, - swizzle(tmp, X,X,Z,ONE), - swizzle(tmp, Z,ONE,ONE,ONE), 0); - - i915_emit_arith( p, - A0_DP4, - get_result_vector( p, inst ), - A0_DEST_CHANNEL_X, 0, - swizzle(tmp, ONE,Z,Y,X), - i915_emit_const4fv( p, cos_constants ), 0); - } - break; + i915_emit_arith(p, + A0_MUL, + tmp1, A0_DEST_CHANNEL_ALL, 0, + swizzle(tmp, X, Y, Y, W), + swizzle(tmp, X, Z, ONE, ONE), 0); - case OPCODE_SGE: - EMIT_2ARG_ARITH( A0_SGE ); - break; + i915_emit_arith(p, + A0_DP4, + get_result_vector(p, inst), + A0_DEST_CHANNEL_Y, 0, + swizzle(tmp1, W, Z, Y, X), + i915_emit_const4fv(p, sin_constants), 0); + } + + if (inst->DstReg.WriteMask & WRITEMASK_X) { + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XYZ, 0, + swizzle(tmp, X, X, Z, ONE), + swizzle(tmp, Z, ONE, ONE, ONE), 0); + + i915_emit_arith(p, + A0_DP4, + get_result_vector(p, inst), + A0_DEST_CHANNEL_X, 0, + swizzle(tmp, ONE, Z, Y, X), + i915_emit_const4fv(p, cos_constants), 0); + } + break; + + case OPCODE_SGE: + EMIT_2ARG_ARITH(A0_SGE); + break; case OPCODE_SIN: - src0 = src_vector( p, &inst->SrcReg[0], program); - tmp = i915_get_utemp( p ); + src0 = src_vector(p, &inst->SrcReg[0], program); + tmp = i915_get_utemp(p); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_X, 0, - src0, - i915_emit_const1f(p, 1.0/(M_PI * 2)), - 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_X, 0, + src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); - i915_emit_arith( p, - A0_MOD, - tmp, A0_DEST_CHANNEL_X, 0, - tmp, - 0, 0 ); + i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); - /* By choosing different taylor constants, could get rid of this mul: - */ - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_X, 0, - tmp, - i915_emit_const1f(p, (M_PI * 2)), - 0); + /* By choosing different taylor constants, could get rid of this mul: + */ + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, i915_emit_const1f(p, (M_PI * 2)), 0); - /* - * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 - * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x - * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x - * result = DP4 t1.wzyx, sin_constants - */ - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_XY, 0, - swizzle(tmp, X,X,ONE,ONE), - swizzle(tmp, X,ONE,ONE,ONE), 0); + /* + * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 + * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x + * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x + * result = DP4 t1.wzyx, sin_constants + */ + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_XY, 0, + swizzle(tmp, X, X, ONE, ONE), + swizzle(tmp, X, ONE, ONE, ONE), 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_ALL, 0, - swizzle(tmp, X,Y,X,Y), - swizzle(tmp, X,X,ONE,ONE), 0); + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_ALL, 0, + swizzle(tmp, X, Y, X, Y), + swizzle(tmp, X, X, ONE, ONE), 0); - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_ALL, 0, - swizzle(tmp, X,Y,Y,W), - swizzle(tmp, X,Z,ONE,ONE), 0); - - i915_emit_arith( p, - A0_DP4, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(tmp, W, Z, Y, X ), - i915_emit_const4fv( p, sin_constants ), 0); - break; + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_ALL, 0, + swizzle(tmp, X, Y, Y, W), + swizzle(tmp, X, Z, ONE, ONE), 0); - case OPCODE_SLT: - EMIT_2ARG_ARITH( A0_SLT ); - break; + i915_emit_arith(p, + A0_DP4, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(tmp, W, Z, Y, X), + i915_emit_const4fv(p, sin_constants), 0); + break; - case OPCODE_SUB: - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); + case OPCODE_SLT: + EMIT_2ARG_ARITH(A0_SLT); + break; - i915_emit_arith( p, - A0_ADD, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - src0, negate(src1, 1,1,1,1), 0); - break; + case OPCODE_SUB: + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); - case OPCODE_SWZ: - EMIT_1ARG_ARITH( A0_MOV ); /* extended swizzle handled natively */ - break; + i915_emit_arith(p, + A0_ADD, + get_result_vector(p, inst), + get_result_flags(inst), 0, + src0, negate(src1, 1, 1, 1, 1), 0); + break; - case OPCODE_TEX: - EMIT_TEX( T0_TEXLD ); - break; + case OPCODE_SWZ: + EMIT_1ARG_ARITH(A0_MOV); /* extended swizzle handled natively */ + break; + + case OPCODE_TEX: + EMIT_TEX(T0_TEXLD); + break; case OPCODE_TXB: - EMIT_TEX( T0_TEXLDB ); - break; + EMIT_TEX(T0_TEXLDB); + break; case OPCODE_TXP: - EMIT_TEX( T0_TEXLDP ); - break; + EMIT_TEX(T0_TEXLDP); + break; case OPCODE_XPD: - /* Cross product: - * result.x = src0.y * src1.z - src0.z * src1.y; - * result.y = src0.z * src1.x - src0.x * src1.z; - * result.z = src0.x * src1.y - src0.y * src1.x; - * result.w = undef; - */ - src0 = src_vector( p, &inst->SrcReg[0], program); - src1 = src_vector( p, &inst->SrcReg[1], program); - tmp = i915_get_utemp( p ); - - i915_emit_arith( p, - A0_MUL, - tmp, A0_DEST_CHANNEL_ALL, 0, - swizzle(src0,Z,X,Y,ONE), - swizzle(src1,Y,Z,X,ONE), 0); + /* Cross product: + * result.x = src0.y * src1.z - src0.z * src1.y; + * result.y = src0.z * src1.x - src0.x * src1.z; + * result.z = src0.x * src1.y - src0.y * src1.x; + * result.w = undef; + */ + src0 = src_vector(p, &inst->SrcReg[0], program); + src1 = src_vector(p, &inst->SrcReg[1], program); + tmp = i915_get_utemp(p); - i915_emit_arith( p, - A0_MAD, - get_result_vector( p, inst ), - get_result_flags( inst ), 0, - swizzle(src0,Y,Z,X,ONE), - swizzle(src1,Z,X,Y,ONE), - negate(tmp,1,1,1,0)); - break; + i915_emit_arith(p, + A0_MUL, + tmp, A0_DEST_CHANNEL_ALL, 0, + swizzle(src0, Z, X, Y, ONE), + swizzle(src1, Y, Z, X, ONE), 0); + + i915_emit_arith(p, + A0_MAD, + get_result_vector(p, inst), + get_result_flags(inst), 0, + swizzle(src0, Y, Z, X, ONE), + swizzle(src1, Z, X, Y, ONE), + negate(tmp, 1, 1, 1, 0)); + break; case OPCODE_END: - return; - + return; + default: - i915_program_error( p, "bad opcode" ); - return; + i915_program_error(p, "bad opcode"); + return; } inst++; - i915_release_utemps( p ); + i915_release_utemps(p); } } @@ -765,16 +755,16 @@ static void upload_program( struct i915_fragment_program *p ) * emit, just move the value into its correct position at the end of * the program: */ -static void fixup_depth_write( struct i915_fragment_program *p ) +static void +fixup_depth_write(struct i915_fragment_program *p) { if (p->depth_written) { GLuint depth = UREG(REG_TYPE_OD, 0); - i915_emit_arith( p, - A0_MOV, - depth, A0_DEST_CHANNEL_W, 0, - swizzle(depth,X,Y,Z,Z), - 0, 0); + i915_emit_arith(p, + A0_MOV, + depth, A0_DEST_CHANNEL_W, 0, + swizzle(depth, X, Y, Z, Z), 0, 0); } } @@ -782,7 +772,8 @@ static void fixup_depth_write( struct i915_fragment_program *p ) #define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n)) -static void check_wpos( struct i915_fragment_program *p ) +static void +check_wpos(struct i915_fragment_program *p) { GLuint inputs = p->FragProg.Base.InputsRead; GLint i; @@ -790,12 +781,12 @@ static void check_wpos( struct i915_fragment_program *p ) p->wpos_tex = -1; for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) { - if (inputs & FRAG_BIT_TEX(i)) - continue; + if (inputs & FRAG_BIT_TEX(i)) + continue; else if (inputs & FRAG_BIT_WPOS) { - p->wpos_tex = i; - inputs &= ~FRAG_BIT_WPOS; - } + p->wpos_tex = i; + inputs &= ~FRAG_BIT_WPOS; + } } if (inputs & FRAG_BIT_WPOS) { @@ -804,53 +795,54 @@ static void check_wpos( struct i915_fragment_program *p ) } -static void translate_program( struct i915_fragment_program *p ) +static void +translate_program(struct i915_fragment_program *p) { struct i915_context *i915 = I915_CONTEXT(p->ctx); - - i915_init_program( i915, p ); - check_wpos( p ); - upload_program( p ); - fixup_depth_write( p ); - i915_fini_program( p ); - + + i915_init_program(i915, p); + check_wpos(p); + upload_program(p); + fixup_depth_write(p); + i915_fini_program(p); + p->translated = 1; } -static void track_params( struct i915_fragment_program *p ) +static void +track_params(struct i915_fragment_program *p) { GLint i; if (p->nr_params) - _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters); + _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters); for (i = 0; i < p->nr_params; i++) { GLint reg = p->param[i].reg; - COPY_4V( p->constant[reg], p->param[i].values ); + COPY_4V(p->constant[reg], p->param[i].values); } - + p->params_uptodate = 1; - p->on_hardware = 0; /* overkill */ + p->on_hardware = 0; /* overkill */ } -static void i915BindProgram( GLcontext *ctx, - GLenum target, - struct gl_program *prog ) +static void +i915BindProgram(GLcontext * ctx, GLenum target, struct gl_program *prog) { if (target == GL_FRAGMENT_PROGRAM_ARB) { struct i915_context *i915 = I915_CONTEXT(ctx); - struct i915_fragment_program *p = (struct i915_fragment_program *)prog; + struct i915_fragment_program *p = (struct i915_fragment_program *) prog; + + if (i915->current_program == p) + return; - if (i915->current_program == p) - return; - if (i915->current_program) { - i915->current_program->on_hardware = 0; - i915->current_program->params_uptodate = 0; + i915->current_program->on_hardware = 0; + i915->current_program->params_uptodate = 0; } - + i915->current_program = p; assert(p->on_hardware == 0); @@ -859,109 +851,108 @@ static void i915BindProgram( GLcontext *ctx, /* Hack: make sure fog is correctly enabled according to this * fragment program's fog options. */ - ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB, - ctx->FragmentProgram.Enabled ); + ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB, + ctx->FragmentProgram.Enabled); } } -static struct gl_program *i915NewProgram( GLcontext *ctx, - GLenum target, - GLuint id ) +static struct gl_program * +i915NewProgram(GLcontext * ctx, GLenum target, GLuint id) { switch (target) { case GL_VERTEX_PROGRAM_ARB: - return _mesa_init_vertex_program( ctx, CALLOC_STRUCT(gl_vertex_program), - target, id ); + return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), + target, id); - case GL_FRAGMENT_PROGRAM_ARB: { - struct i915_fragment_program *prog = CALLOC_STRUCT(i915_fragment_program); - if (prog) { - i915_init_program( I915_CONTEXT(ctx), prog ); + case GL_FRAGMENT_PROGRAM_ARB:{ + struct i915_fragment_program *prog = + CALLOC_STRUCT(i915_fragment_program); + if (prog) { + i915_init_program(I915_CONTEXT(ctx), prog); - return _mesa_init_fragment_program( ctx, &prog->FragProg, - target, id ); + return _mesa_init_fragment_program(ctx, &prog->FragProg, + target, id); + } + else + return NULL; } - else - return NULL; - } default: /* Just fallback: */ - return _mesa_new_program( ctx, target, id ); + return _mesa_new_program(ctx, target, id); } } -static void i915DeleteProgram( GLcontext *ctx, - struct gl_program *prog ) +static void +i915DeleteProgram(GLcontext * ctx, struct gl_program *prog) { if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) { struct i915_context *i915 = I915_CONTEXT(ctx); - struct i915_fragment_program *p = (struct i915_fragment_program *)prog; - - if (i915->current_program == p) - i915->current_program = 0; + struct i915_fragment_program *p = (struct i915_fragment_program *) prog; + + if (i915->current_program == p) + i915->current_program = 0; } - _mesa_delete_program( ctx, prog ); + _mesa_delete_program(ctx, prog); } -static GLboolean i915IsProgramNative( GLcontext *ctx, - GLenum target, - struct gl_program *prog ) +static GLboolean +i915IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog) { if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct i915_fragment_program *p = (struct i915_fragment_program *)prog; + struct i915_fragment_program *p = (struct i915_fragment_program *) prog; if (!p->translated) - translate_program( p ); - + translate_program(p); + return !p->error; } else return GL_TRUE; } -static void i915ProgramStringNotify( GLcontext *ctx, - GLenum target, - struct gl_program *prog ) +static void +i915ProgramStringNotify(GLcontext * ctx, + GLenum target, struct gl_program *prog) { if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct i915_fragment_program *p = (struct i915_fragment_program *)prog; + struct i915_fragment_program *p = (struct i915_fragment_program *) prog; p->translated = 0; /* Hack: make sure fog is correctly enabled according to this * fragment program's fog options. */ - ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB, - ctx->FragmentProgram.Enabled ); + ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB, + ctx->FragmentProgram.Enabled); } } -void i915ValidateFragmentProgram( struct i915_context *i915 ) +void +i915ValidateFragmentProgram(struct i915_context *i915) { GLcontext *ctx = &i915->intel.ctx; struct intel_context *intel = intel_context(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - struct i915_fragment_program *p = - (struct i915_fragment_program *)ctx->FragmentProgram._Current; + struct i915_fragment_program *p = + (struct i915_fragment_program *) ctx->FragmentProgram._Current; const GLuint inputsRead = p->FragProg.Base.InputsRead; GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK; GLuint s2 = S2_TEXCOORD_NONE; int i, offset = 0; - if (i915->current_program != p) - { + if (i915->current_program != p) { if (i915->current_program) { - i915->current_program->on_hardware = 0; - i915->current_program->params_uptodate = 0; + i915->current_program->on_hardware = 0; + i915->current_program->params_uptodate = 0; } - + i915->current_program = p; } @@ -970,8 +961,8 @@ void i915ValidateFragmentProgram( struct i915_context *i915 ) */ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - if (!p->translated) - translate_program( p ); + if (!p->translated) + translate_program(p); intel->vertex_attr_count = 0; intel->wpos_offset = 0; @@ -980,94 +971,95 @@ void i915ValidateFragmentProgram( struct i915_context *i915 ) intel->specoffset = 0; if (inputsRead & FRAG_BITS_TEX_ANY) { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 ); + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16); } else { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12 ); + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12); } if (inputsRead & FRAG_BIT_COL0) { intel->coloroffset = offset / 4; - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4 ); + EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4); } - - if ((inputsRead & (FRAG_BIT_COL1|FRAG_BIT_FOGC)) || + + if ((inputsRead & (FRAG_BIT_COL1 | FRAG_BIT_FOGC)) || i915->vertex_fog != I915_FOG_NONE) { if (inputsRead & FRAG_BIT_COL1) { - intel->specoffset = offset / 4; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3 ); + intel->specoffset = offset / 4; + EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3); } else - EMIT_PAD(3); + EMIT_PAD(3); - if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1 ); + if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) + EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1); else - EMIT_PAD( 1 ); + EMIT_PAD(1); } #if 0 if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4 ); + EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4); } #endif for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) { if (inputsRead & FRAG_BIT_TEX(i)) { - int sz = VB->TexCoordPtr[i]->size; - - s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); - s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz)); + int sz = VB->TexCoordPtr[i]->size; - EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0, sz * 4 ); + s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); + s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz)); + + EMIT_ATTR(_TNL_ATTRIB_TEX0 + i, EMIT_SZ(sz), 0, sz * 4); } else if (i == p->wpos_tex) { - - /* If WPOS is required, duplicate the XYZ position data in an - * unused texture coordinate: - */ - s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); - s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(3)); - intel->wpos_offset = offset; - intel->wpos_size = 3 * sizeof(GLuint); + /* If WPOS is required, duplicate the XYZ position data in an + * unused texture coordinate: + */ + s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); + s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(3)); - EMIT_PAD( intel->wpos_size ); - } + intel->wpos_offset = offset; + intel->wpos_size = 3 * sizeof(GLuint); + + EMIT_PAD(intel->wpos_size); + } } if (s2 != i915->state.Ctx[I915_CTXREG_LIS2] || s4 != i915->state.Ctx[I915_CTXREG_LIS4]) { int k; - - I915_STATECHANGE( i915, I915_UPLOAD_CTX ); + + I915_STATECHANGE(i915, I915_UPLOAD_CTX); /* Must do this *after* statechange, so as not to affect * buffered vertices reliant on the old state: */ - intel->vertex_size = _tnl_install_attrs( &intel->ctx, - intel->vertex_attrs, - intel->vertex_attr_count, - intel->ViewportMatrix.m, 0 ); + intel->vertex_size = _tnl_install_attrs(&intel->ctx, + intel->vertex_attrs, + intel->vertex_attr_count, + intel->ViewportMatrix.m, 0); intel->vertex_size >>= 2; i915->state.Ctx[I915_CTXREG_LIS2] = s2; i915->state.Ctx[I915_CTXREG_LIS4] = s4; - k = intel->vtbl.check_vertex_size( intel, intel->vertex_size ); + k = intel->vtbl.check_vertex_size(intel, intel->vertex_size); assert(k); } - if (!p->params_uptodate) - track_params( p ); + if (!p->params_uptodate) + track_params(p); - if (!p->on_hardware) - i915_upload_program( i915, p ); + if (!p->on_hardware) + i915_upload_program(i915, p); } -void i915InitFragProgFuncs( struct dd_function_table *functions ) +void +i915InitFragProgFuncs(struct dd_function_table *functions) { functions->BindProgram = i915BindProgram; functions->NewProgram = i915NewProgram; diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c index 7921ebf4f17..ea0ff44d4d1 100644 --- a/src/mesa/drivers/dri/i915/i915_metaops.c +++ b/src/mesa/drivers/dri/i915/i915_metaops.c @@ -48,7 +48,7 @@ I915_UPLOAD_STIPPLE | \ I915_UPLOAD_PROGRAM | \ I915_UPLOAD_FOG | \ - I915_UPLOAD_TEX(0)) + I915_UPLOAD_TEX(0)) #define SET_STATE( i915, STATE ) \ do { \ @@ -58,31 +58,34 @@ do { \ } while (0) -static void meta_no_stencil_write( struct intel_context *intel ) +static void +meta_no_stencil_write(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE ) */ - i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); + i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | + S5_STENCIL_WRITE_ENABLE); i915->meta.emitted &= ~I915_UPLOAD_CTX; } -static void meta_no_depth_write( struct intel_context *intel ) +static void +meta_no_depth_write(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE ) */ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE | - S6_DEPTH_WRITE_ENABLE); + S6_DEPTH_WRITE_ENABLE); i915->meta.emitted &= ~I915_UPLOAD_CTX; } -static void meta_depth_replace( struct intel_context *intel ) +static void +meta_depth_replace(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); @@ -90,12 +93,12 @@ static void meta_depth_replace( struct intel_context *intel ) * ctx->Driver.DepthMask( ctx, GL_TRUE ) */ i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE | - S6_DEPTH_WRITE_ENABLE); + S6_DEPTH_WRITE_ENABLE); /* ctx->Driver.DepthFunc( ctx, GL_REPLACE ) */ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK; - i915->meta.Ctx[I915_CTXREG_LIS6] |= + i915->meta.Ctx[I915_CTXREG_LIS6] |= COMPAREFUNC_ALWAYS << S6_DEPTH_TEST_FUNC_SHIFT; i915->meta.emitted &= ~I915_UPLOAD_CTX; @@ -104,9 +107,9 @@ static void meta_depth_replace( struct intel_context *intel ) /* Set stencil unit to replace always with the reference value. */ -static void meta_stencil_replace( struct intel_context *intel, - GLuint s_mask, - GLuint s_clear) +static void +meta_stencil_replace(struct intel_context *intel, + GLuint s_mask, GLuint s_clear) { struct i915_context *i915 = i915_context(&intel->ctx); GLuint op = STENCILOP_REPLACE; @@ -114,79 +117,82 @@ static void meta_stencil_replace( struct intel_context *intel, /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE ) */ - i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); + i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE | + S5_STENCIL_WRITE_ENABLE); /* ctx->Driver.StencilMask( ctx, s_mask ) */ i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(s_mask)); + STENCIL_WRITE_MASK(s_mask)); /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE ) */ i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK | - S5_STENCIL_PASS_Z_FAIL_MASK | - S5_STENCIL_PASS_Z_PASS_MASK); + S5_STENCIL_PASS_Z_FAIL_MASK | + S5_STENCIL_PASS_Z_PASS_MASK); i915->meta.Ctx[I915_CTXREG_LIS5] |= ((op << S5_STENCIL_FAIL_SHIFT) | - (op << S5_STENCIL_PASS_Z_FAIL_SHIFT) | - (op << S5_STENCIL_PASS_Z_PASS_SHIFT)); + (op << S5_STENCIL_PASS_Z_FAIL_SHIFT) | + (op << S5_STENCIL_PASS_Z_PASS_SHIFT)); /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_ref, ~0 ) */ i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff)); + STENCIL_TEST_MASK(0xff)); i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK | - S5_STENCIL_TEST_FUNC_MASK); - - i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) | - (func << S5_STENCIL_TEST_FUNC_SHIFT)); + S5_STENCIL_TEST_FUNC_MASK); + + i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) | + (func << S5_STENCIL_TEST_FUNC_SHIFT)); i915->meta.emitted &= ~I915_UPLOAD_CTX; } -static void meta_color_mask( struct intel_context *intel, GLboolean state ) +static void +meta_color_mask(struct intel_context *intel, GLboolean state) { struct i915_context *i915 = i915_context(&intel->ctx); const GLuint mask = (S5_WRITEDISABLE_RED | - S5_WRITEDISABLE_GREEN | - S5_WRITEDISABLE_BLUE | - S5_WRITEDISABLE_ALPHA); + S5_WRITEDISABLE_GREEN | + S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA); /* Copy colormask state from "regular" hw context. */ if (state) { i915->meta.Ctx[I915_CTXREG_LIS5] &= ~mask; - i915->meta.Ctx[I915_CTXREG_LIS5] |= - (i915->state.Ctx[I915_CTXREG_LIS5] & mask); + i915->meta.Ctx[I915_CTXREG_LIS5] |= + (i915->state.Ctx[I915_CTXREG_LIS5] & mask); } - else + else i915->meta.Ctx[I915_CTXREG_LIS5] |= mask; - + i915->meta.emitted &= ~I915_UPLOAD_CTX; } -static void meta_import_pixel_state( struct intel_context *intel ) +static void +meta_import_pixel_state(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); memcpy(i915->meta.Fog, i915->state.Fog, I915_FOG_SETUP_SIZE * 4); - + i915->meta.Ctx[I915_CTXREG_LIS5] = i915->state.Ctx[I915_CTXREG_LIS5]; i915->meta.Ctx[I915_CTXREG_LIS6] = i915->state.Ctx[I915_CTXREG_LIS6]; i915->meta.Ctx[I915_CTXREG_STATE4] = i915->state.Ctx[I915_CTXREG_STATE4]; - i915->meta.Ctx[I915_CTXREG_BLENDCOLOR1] = i915->state.Ctx[I915_CTXREG_BLENDCOLOR1]; + i915->meta.Ctx[I915_CTXREG_BLENDCOLOR1] = + i915->state.Ctx[I915_CTXREG_BLENDCOLOR1]; i915->meta.Ctx[I915_CTXREG_IAB] = i915->state.Ctx[I915_CTXREG_IAB]; - i915->meta.Buffer[I915_DESTREG_SENABLE] = i915->state.Buffer[I915_DESTREG_SENABLE]; + i915->meta.Buffer[I915_DESTREG_SENABLE] = + i915->state.Buffer[I915_DESTREG_SENABLE]; i915->meta.Buffer[I915_DESTREG_SR1] = i915->state.Buffer[I915_DESTREG_SR1]; i915->meta.Buffer[I915_DESTREG_SR2] = i915->state.Buffer[I915_DESTREG_SR2]; @@ -248,7 +254,8 @@ static void meta_import_pixel_state( struct intel_context *intel ) -static void meta_no_texture( struct intel_context *intel ) +static void +meta_no_texture(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); @@ -257,30 +264,28 @@ static void meta_no_texture( struct intel_context *intel ) /* Declare incoming diffuse color: */ - (D0_DCL | - D0_DECL_REG( REG_T_DIFFUSE ) | - D0_CHANNEL_ALL), + (D0_DCL | D0_DECL_REG(REG_T_DIFFUSE) | D0_CHANNEL_ALL), D1_MBZ, D2_MBZ, /* output-color = mov(t_diffuse) */ (A0_MOV | - A0_DEST_REG( REG_OC ) | - A0_DEST_CHANNEL_ALL | - A0_SRC0_REG( REG_T_DIFFUSE )), + A0_DEST_REG(REG_OC) | + A0_DEST_CHANNEL_ALL | A0_SRC0_REG(REG_T_DIFFUSE)), (A1_SRC0_XYZW), 0, }; - - memcpy( i915->meta.Program, prog, sizeof(prog) ); + + memcpy(i915->meta.Program, prog, sizeof(prog)); i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog); i915->meta.Program[0] |= i915->meta.ProgramSize - 2; i915->meta.emitted &= ~I915_UPLOAD_PROGRAM; } -static void meta_texture_blend_replace( struct intel_context *intel ) +static void +meta_texture_blend_replace(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); @@ -289,31 +294,24 @@ static void meta_texture_blend_replace( struct intel_context *intel ) /* Declare the sampler: */ - (D0_DCL | - D0_DECL_REG( REG_S(0) ) | - D0_SAMPLE_TYPE_2D | - D0_CHANNEL_NONE), + (D0_DCL | D0_DECL_REG(REG_S(0)) | D0_SAMPLE_TYPE_2D | D0_CHANNEL_NONE), D1_MBZ, D2_MBZ, /* Declare the interpolated texture coordinate: */ - (D0_DCL | - D0_DECL_REG( REG_T_TEX(0) ) | - D0_CHANNEL_ALL), + (D0_DCL | D0_DECL_REG(REG_T_TEX(0)) | D0_CHANNEL_ALL), D1_MBZ, D2_MBZ, /* output-color = texld(sample0, texcoord0) */ - (T0_TEXLD | - T0_DEST_REG( REG_OC ) | - T0_SAMPLER( 0 )), + (T0_TEXLD | T0_DEST_REG(REG_OC) | T0_SAMPLER(0)), T1_ADDRESS_REG(REG_TYPE_T, 0), T2_MBZ }; - memcpy( i915->meta.Program, prog, sizeof(prog) ); + memcpy(i915->meta.Program, prog, sizeof(prog)); i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog); i915->meta.Program[0] |= i915->meta.ProgramSize - 2; i915->meta.emitted &= ~I915_UPLOAD_PROGRAM; @@ -326,13 +324,11 @@ static void meta_texture_blend_replace( struct intel_context *intel ) /* Set up an arbitary piece of memory as a rectangular texture * (including the front or back buffer). */ -static GLboolean meta_tex_rect_source( struct intel_context *intel, - struct buffer *buffer, - GLuint offset, - GLuint pitch, - GLuint height, - GLenum format, - GLenum type) +static GLboolean +meta_tex_rect_source(struct intel_context *intel, + struct _DriBufferObject *buffer, + GLuint offset, + GLuint pitch, GLuint height, GLenum format, GLenum type) { struct i915_context *i915 = i915_context(&intel->ctx); GLuint unit = 0; @@ -351,42 +347,42 @@ static GLboolean meta_tex_rect_source( struct intel_context *intel, switch (type) { case GL_UNSIGNED_INT_8_8_8_8_REV: case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); - cpp = 4; - break; + textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); + cpp = 4; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_RGBA: switch (type) { case GL_UNSIGNED_INT_8_8_8_8_REV: case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); - cpp = 4; - break; + textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); + cpp = 4; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_BGR: switch (type) { case GL_UNSIGNED_SHORT_5_6_5_REV: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; + textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); + cpp = 2; + break; default: - return GL_FALSE; + return GL_FALSE; } break; case GL_RGB: switch (type) { case GL_UNSIGNED_SHORT_5_6_5: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; + textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); + cpp = 2; + break; default: - return GL_FALSE; + return GL_FALSE; } break; @@ -406,22 +402,21 @@ static GLboolean meta_tex_rect_source( struct intel_context *intel, i915->meta.tex_offset[0] = offset; state[I915_TEXREG_MS3] = (((height - 1) << MS3_HEIGHT_SHIFT) | - ((pitch - 1) << MS3_WIDTH_SHIFT) | - textureFormat | - MS3_USE_FENCE_REGS); + ((pitch - 1) << MS3_WIDTH_SHIFT) | + textureFormat | MS3_USE_FENCE_REGS); - state[I915_TEXREG_MS4] = (((((pitch * cpp) / 4) - 1) << MS4_PITCH_SHIFT) | - MS4_CUBE_FACE_ENA_MASK | - ((((numLevels-1) * 4)) << MS4_MAX_LOD_SHIFT)); + state[I915_TEXREG_MS4] = (((((pitch * cpp) / 4) - 1) << MS4_PITCH_SHIFT) | + MS4_CUBE_FACE_ENA_MASK | + ((((numLevels - 1) * 4)) << MS4_MAX_LOD_SHIFT)); state[I915_TEXREG_SS2] = ((FILTER_NEAREST << SS2_MIN_FILTER_SHIFT) | - (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) | - (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT)); + (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) | + (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT)); state[I915_TEXREG_SS3] = ((TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT) | - (TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT) | - (TEXCOORDMODE_WRAP << SS3_TCZ_ADDR_MODE_SHIFT) | - (unit<ctx); i915_state_draw_region(intel, &i915->meta, color_region, depth_region); } -static void set_vertex_format( struct intel_context *intel ) +static void +set_vertex_format(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); - i915->meta.Ctx[I915_CTXREG_LIS2] = + i915->meta.Ctx[I915_CTXREG_LIS2] = (S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | - S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT)); i915->meta.Ctx[I915_CTXREG_LIS4] &= ~S4_VFMT_MASK; - i915->meta.Ctx[I915_CTXREG_LIS4] |= - (S4_VFMT_COLOR | - S4_VFMT_XYZ); + i915->meta.Ctx[I915_CTXREG_LIS4] |= (S4_VFMT_COLOR | S4_VFMT_XYZ); i915->meta.emitted &= ~I915_UPLOAD_CTX; } @@ -471,10 +466,11 @@ static void set_vertex_format( struct intel_context *intel ) * current GL state and used for other purposes than simply rendering * incoming triangles. */ -static void install_meta_state( struct intel_context *intel ) +static void +install_meta_state(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); - memcpy(&i915->meta, &i915->initial, sizeof(i915->meta) ); + memcpy(&i915->meta, &i915->initial, sizeof(i915->meta)); i915->meta.active = ACTIVE; i915->meta.emitted = 0; @@ -483,7 +479,8 @@ static void install_meta_state( struct intel_context *intel ) meta_no_texture(intel); } -static void leave_meta_state( struct intel_context *intel ) +static void +leave_meta_state(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); intel_region_release(intel, &i915->meta.draw_region); @@ -494,7 +491,8 @@ static void leave_meta_state( struct intel_context *intel ) -void i915InitMetaFuncs( struct i915_context *i915 ) +void +i915InitMetaFuncs(struct i915_context *i915) { i915->intel.vtbl.install_meta_state = install_meta_state; i915->intel.vtbl.leave_meta_state = leave_meta_state; @@ -509,5 +507,3 @@ void i915InitMetaFuncs( struct i915_context *i915 ) i915->intel.vtbl.meta_draw_region = meta_draw_region; i915->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state; } - - diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c index 07ac8f09bb3..55f60880e37 100644 --- a/src/mesa/drivers/dri/i915/i915_program.c +++ b/src/mesa/drivers/dri/i915/i915_program.c @@ -72,58 +72,62 @@ #define I915_CONSTFLAG_PARAM 0x1f -GLuint i915_get_temp( struct i915_fragment_program *p ) +GLuint +i915_get_temp(struct i915_fragment_program *p) { - int bit = ffs( ~p->temp_flag ); + int bit = ffs(~p->temp_flag); if (!bit) { fprintf(stderr, "%s: out of temporaries\n", __FILE__); exit(1); } - p->temp_flag |= 1<<(bit-1); - return UREG(REG_TYPE_R, (bit-1)); + p->temp_flag |= 1 << (bit - 1); + return UREG(REG_TYPE_R, (bit - 1)); } -GLuint i915_get_utemp( struct i915_fragment_program *p ) +GLuint +i915_get_utemp(struct i915_fragment_program * p) { - int bit = ffs( ~p->utemp_flag ); + int bit = ffs(~p->utemp_flag); if (!bit) { fprintf(stderr, "%s: out of temporaries\n", __FILE__); exit(1); } - p->utemp_flag |= 1<<(bit-1); - return UREG(REG_TYPE_U, (bit-1)); + p->utemp_flag |= 1 << (bit - 1); + return UREG(REG_TYPE_U, (bit - 1)); } -void i915_release_utemps( struct i915_fragment_program *p ) +void +i915_release_utemps(struct i915_fragment_program *p) { p->utemp_flag = ~0x7; } -GLuint i915_emit_decl( struct i915_fragment_program *p, - GLuint type, GLuint nr, GLuint d0_flags ) +GLuint +i915_emit_decl(struct i915_fragment_program *p, + GLuint type, GLuint nr, GLuint d0_flags) { GLuint reg = UREG(type, nr); if (type == REG_TYPE_T) { - if (p->decl_t & (1<decl_t & (1 << nr)) + return reg; - p->decl_t |= (1<decl_t |= (1 << nr); } else if (type == REG_TYPE_S) { - if (p->decl_s & (1<decl_s & (1 << nr)) + return reg; - p->decl_s |= (1<decl_s |= (1 << nr); } - else + else return reg; - *(p->decl++) = (D0_DCL | D0_DEST( reg ) | d0_flags); + *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags); *(p->decl++) = D1_MBZ; *(p->decl++) = D2_MBZ; @@ -131,14 +135,12 @@ GLuint i915_emit_decl( struct i915_fragment_program *p, return reg; } -GLuint i915_emit_arith( struct i915_fragment_program *p, - GLuint op, - GLuint dest, - GLuint mask, - GLuint saturate, - GLuint src0, - GLuint src1, - GLuint src2 ) +GLuint +i915_emit_arith(struct i915_fragment_program * p, + GLuint op, + GLuint dest, + GLuint mask, + GLuint saturate, GLuint src0, GLuint src1, GLuint src2) { GLuint c[3]; GLuint nr_const = 0; @@ -147,9 +149,12 @@ GLuint i915_emit_arith( struct i915_fragment_program *p, dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)); assert(dest); - if (GET_UREG_TYPE(src0) == REG_TYPE_CONST) c[nr_const++] = 0; - if (GET_UREG_TYPE(src1) == REG_TYPE_CONST) c[nr_const++] = 1; - if (GET_UREG_TYPE(src2) == REG_TYPE_CONST) c[nr_const++] = 2; + if (GET_UREG_TYPE(src0) == REG_TYPE_CONST) + c[nr_const++] = 0; + if (GET_UREG_TYPE(src1) == REG_TYPE_CONST) + c[nr_const++] = 1; + if (GET_UREG_TYPE(src2) == REG_TYPE_CONST) + c[nr_const++] = 2; /* Recursively call this function to MOV additional const values * into temporary registers. Use utemp registers for this - @@ -165,42 +170,34 @@ GLuint i915_emit_arith( struct i915_fragment_program *p, old_utemp_flag = p->utemp_flag; first = GET_UREG_NR(s[c[0]]); - for (i = 1 ; i < nr_const ; i++) { - if (GET_UREG_NR(s[c[i]]) != first) { - GLuint tmp = i915_get_utemp(p); + for (i = 1; i < nr_const; i++) { + if (GET_UREG_NR(s[c[i]]) != first) { + GLuint tmp = i915_get_utemp(p); - i915_emit_arith( p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0, - s[c[i]], 0, 0 ); - s[c[i]] = tmp; - } + i915_emit_arith(p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0, + s[c[i]], 0, 0); + s[c[i]] = tmp; + } } src0 = s[0]; src1 = s[1]; src2 = s[2]; - p->utemp_flag = old_utemp_flag; /* restore */ + p->utemp_flag = old_utemp_flag; /* restore */ } - *(p->csr++) = (op | - A0_DEST( dest ) | - mask | - saturate | - A0_SRC0( src0 )); - *(p->csr++) = (A1_SRC0( src0 ) | - A1_SRC1( src1 )); - *(p->csr++) = (A2_SRC1( src1 ) | - A2_SRC2( src2 )); + *(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0)); + *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1)); + *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2)); p->nr_alu_insn++; return dest; } -GLuint i915_emit_texld( struct i915_fragment_program *p, - GLuint dest, - GLuint destmask, - GLuint sampler, - GLuint coord, - GLuint op ) +GLuint +i915_emit_texld(struct i915_fragment_program * p, + GLuint dest, + GLuint destmask, GLuint sampler, GLuint coord, GLuint op) { assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST); dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)); @@ -210,12 +207,9 @@ GLuint i915_emit_texld( struct i915_fragment_program *p, p->nr_tex_indirect++; } - *(p->csr++) = (op | - T0_DEST( dest ) | - destmask | - T0_SAMPLER( sampler )); + *(p->csr++) = (op | T0_DEST(dest) | destmask | T0_SAMPLER(sampler)); - *(p->csr++) = T1_ADDRESS_REG( coord ); + *(p->csr++) = T1_ADDRESS_REG(coord); *(p->csr++) = T2_MBZ; p->nr_tex_insn++; @@ -223,24 +217,28 @@ GLuint i915_emit_texld( struct i915_fragment_program *p, } -GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 ) +GLuint +i915_emit_const1f(struct i915_fragment_program * p, GLfloat c0) { GLint reg, idx; - if (c0 == 0.0) return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO); - if (c0 == 1.0) return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE ); + if (c0 == 0.0) + return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO); + if (c0 == 1.0) + return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE); for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == I915_CONSTFLAG_PARAM) - continue; + continue; for (idx = 0; idx < 4; idx++) { - if (!(p->constant_flags[reg] & (1<constant[reg][idx] == c0) { - p->constant[reg][idx] = c0; - p->constant_flags[reg] |= 1< p->nr_constants) p->nr_constants = reg+1; - return swizzle(UREG(REG_TYPE_CONST, reg),idx,ZERO,ZERO,ONE); - } + if (!(p->constant_flags[reg] & (1 << idx)) || + p->constant[reg][idx] == c0) { + p->constant[reg][idx] = c0; + p->constant_flags[reg] |= 1 << idx; + if (reg + 1 > p->nr_constants) + p->nr_constants = reg + 1; + return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE); + } } } @@ -249,29 +247,35 @@ GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 ) return 0; } -GLuint i915_emit_const2f( struct i915_fragment_program *p, - GLfloat c0, GLfloat c1 ) +GLuint +i915_emit_const2f(struct i915_fragment_program * p, GLfloat c0, GLfloat c1) { GLint reg, idx; - if (c0 == 0.0) return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W); - if (c0 == 1.0) return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W); + if (c0 == 0.0) + return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W); + if (c0 == 1.0) + return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W); - if (c1 == 0.0) return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W); - if (c1 == 1.0) return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W); + if (c1 == 0.0) + return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W); + if (c1 == 1.0) + return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W); for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == 0xf || - p->constant_flags[reg] == I915_CONSTFLAG_PARAM) - continue; + p->constant_flags[reg] == I915_CONSTFLAG_PARAM) + continue; for (idx = 0; idx < 3; idx++) { - if (!(p->constant_flags[reg] & (3<constant[reg][idx] = c0; - p->constant[reg][idx+1] = c1; - p->constant_flags[reg] |= 3< p->nr_constants) p->nr_constants = reg+1; - return swizzle(UREG(REG_TYPE_CONST, reg),idx,idx+1,ZERO,ONE); - } + if (!(p->constant_flags[reg] & (3 << idx))) { + p->constant[reg][idx] = c0; + p->constant[reg][idx + 1] = c1; + p->constant_flags[reg] |= 3 << idx; + if (reg + 1 > p->nr_constants) + p->nr_constants = reg + 1; + return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO, + ONE); + } } } @@ -282,27 +286,28 @@ GLuint i915_emit_const2f( struct i915_fragment_program *p, -GLuint i915_emit_const4f( struct i915_fragment_program *p, - GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3 ) +GLuint +i915_emit_const4f(struct i915_fragment_program * p, + GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3) { GLint reg; for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == 0xf && - p->constant[reg][0] == c0 && - p->constant[reg][1] == c1 && - p->constant[reg][2] == c2 && - p->constant[reg][3] == c3) { - return UREG(REG_TYPE_CONST, reg); + p->constant[reg][0] == c0 && + p->constant[reg][1] == c1 && + p->constant[reg][2] == c2 && p->constant[reg][3] == c3) { + return UREG(REG_TYPE_CONST, reg); } else if (p->constant_flags[reg] == 0) { - p->constant[reg][0] = c0; - p->constant[reg][1] = c1; - p->constant[reg][2] = c2; - p->constant[reg][3] = c3; - p->constant_flags[reg] = 0xf; - if (reg+1 > p->nr_constants) p->nr_constants = reg+1; - return UREG(REG_TYPE_CONST, reg); + p->constant[reg][0] = c0; + p->constant[reg][1] = c1; + p->constant[reg][2] = c2; + p->constant[reg][3] = c3; + p->constant_flags[reg] = 0xf; + if (reg + 1 > p->nr_constants) + p->nr_constants = reg + 1; + return UREG(REG_TYPE_CONST, reg); } } @@ -312,34 +317,36 @@ GLuint i915_emit_const4f( struct i915_fragment_program *p, } -GLuint i915_emit_const4fv( struct i915_fragment_program *p, const GLfloat *c ) +GLuint +i915_emit_const4fv(struct i915_fragment_program * p, const GLfloat * c) { - return i915_emit_const4f( p, c[0], c[1], c[2], c[3] ); + return i915_emit_const4f(p, c[0], c[1], c[2], c[3]); } -GLuint i915_emit_param4fv( struct i915_fragment_program *p, - const GLfloat *values ) +GLuint +i915_emit_param4fv(struct i915_fragment_program * p, const GLfloat * values) { GLint reg, i; for (i = 0; i < p->nr_params; i++) { if (p->param[i].values == values) - return UREG(REG_TYPE_CONST, p->param[i].reg); + return UREG(REG_TYPE_CONST, p->param[i].reg); } for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == 0) { - p->constant_flags[reg] = I915_CONSTFLAG_PARAM; - i = p->nr_params++; + p->constant_flags[reg] = I915_CONSTFLAG_PARAM; + i = p->nr_params++; - p->param[i].values = values; - p->param[i].reg = reg; - p->params_uptodate = 0; + p->param[i].values = values; + p->param[i].reg = reg; + p->params_uptodate = 0; - if (reg+1 > p->nr_constants) p->nr_constants = reg+1; - return UREG(REG_TYPE_CONST, reg); + if (reg + 1 > p->nr_constants) + p->nr_constants = reg + 1; + return UREG(REG_TYPE_CONST, reg); } } @@ -351,7 +358,8 @@ GLuint i915_emit_param4fv( struct i915_fragment_program *p, -void i915_program_error( struct i915_fragment_program *p, const char *msg ) +void +i915_program_error(struct i915_fragment_program *p, const char *msg) { /* XXX we shouldn't print anything to stdout, record GL error or * call _mesa_problem() @@ -360,23 +368,24 @@ void i915_program_error( struct i915_fragment_program *p, const char *msg ) p->error = 1; } -void i915_init_program( struct i915_context *i915, struct i915_fragment_program *p ) +void +i915_init_program(struct i915_context *i915, struct i915_fragment_program *p) { GLcontext *ctx = &i915->intel.ctx; - TNLcontext *tnl = TNL_CONTEXT( ctx ); - + TNLcontext *tnl = TNL_CONTEXT(ctx); + p->translated = 0; p->params_uptodate = 0; p->on_hardware = 0; p->error = 0; - p->nr_tex_indirect = 1; /* correct? */ + p->nr_tex_indirect = 1; /* correct? */ p->nr_tex_insn = 0; p->nr_alu_insn = 0; p->nr_decl_insn = 0; - p->ctx = ctx; - memset( p->constant_flags, 0, sizeof(p->constant_flags) ); + p->ctx = ctx; + memset(p->constant_flags, 0, sizeof(p->constant_flags)); p->nr_constants = 0; p->csr = p->program; @@ -398,12 +407,13 @@ void i915_init_program( struct i915_context *i915, struct i915_fragment_program } -void i915_fini_program( struct i915_fragment_program *p ) +void +i915_fini_program(struct i915_fragment_program *p) { GLuint program_size = p->csr - p->program; GLuint decl_size = p->decl - p->declarations; - - if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT) + + if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT) i915_program_error(p, "Exceeded max nr indirect texture lookups"); if (p->nr_tex_insn > I915_MAX_TEX_INSN) @@ -433,22 +443,24 @@ void i915_fini_program( struct i915_fragment_program *p ) p->declarations[0] |= program_size + decl_size - 2; } -void i915_upload_program( struct i915_context *i915, struct i915_fragment_program *p ) +void +i915_upload_program(struct i915_context *i915, + struct i915_fragment_program *p) { GLuint program_size = p->csr - p->program; GLuint decl_size = p->decl - p->declarations; - FALLBACK( &i915->intel, I915_FALLBACK_PROGRAM, p->error ); + FALLBACK(&i915->intel, I915_FALLBACK_PROGRAM, p->error); /* Could just go straight to the batchbuffer from here: */ if (i915->state.ProgramSize != (program_size + decl_size) || - memcmp(i915->state.Program + decl_size, p->program, - program_size*sizeof(int)) != 0) { - I915_STATECHANGE( i915, I915_UPLOAD_PROGRAM ); - memcpy(i915->state.Program, p->declarations, decl_size*sizeof(int)); + memcmp(i915->state.Program + decl_size, p->program, + program_size * sizeof(int)) != 0) { + I915_STATECHANGE(i915, I915_UPLOAD_PROGRAM); + memcpy(i915->state.Program, p->declarations, decl_size * sizeof(int)); memcpy(i915->state.Program + decl_size, p->program, - program_size*sizeof(int)); + program_size * sizeof(int)); i915->state.ProgramSize = decl_size + program_size; } @@ -457,30 +469,28 @@ void i915_upload_program( struct i915_context *i915, struct i915_fragment_progra */ if (p->nr_constants) { GLuint nr = p->nr_constants; - - I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 1 ); - I915_STATECHANGE( i915, I915_UPLOAD_CONSTANTS ); + + I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1); + I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS); i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4); - i915->state.Constant[1] = (1<<(nr-1)) | ((1<<(nr-1))-1); - - memcpy(&i915->state.Constant[2], p->constant, 4*sizeof(int)*(nr)); + i915->state.Constant[1] = (1 << (nr - 1)) | ((1 << (nr - 1)) - 1); + + memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * (nr)); i915->state.ConstantSize = 2 + (nr) * 4; if (0) { - GLuint i; - for (i = 0; i < nr; i++) { - fprintf(stderr, "const[%d]: %f %f %f %f\n", i, - p->constant[i][0], - p->constant[i][1], - p->constant[i][2], - p->constant[i][3]); - } + GLuint i; + for (i = 0; i < nr; i++) { + fprintf(stderr, "const[%d]: %f %f %f %f\n", i, + p->constant[i][0], + p->constant[i][1], p->constant[i][2], p->constant[i][3]); + } } } else { - I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 0 ); - } + I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0); + } p->on_hardware = 1; } diff --git a/src/mesa/drivers/dri/i915/i915_program.h b/src/mesa/drivers/dri/i915/i915_program.h index a0d2530ed52..3c12b34f163 100644 --- a/src/mesa/drivers/dri/i915/i915_program.h +++ b/src/mesa/drivers/dri/i915/i915_program.h @@ -48,11 +48,11 @@ #define UREG_CHANNEL_W_NEGATE_SHIFT 11 #define UREG_CHANNEL_W_SHIFT 8 #define UREG_CHANNEL_ZERO_NEGATE_MBZ 5 -#define UREG_CHANNEL_ZERO_SHIFT 4 +#define UREG_CHANNEL_ZERO_SHIFT 4 #define UREG_CHANNEL_ONE_NEGATE_MBZ 1 -#define UREG_CHANNEL_ONE_SHIFT 0 +#define UREG_CHANNEL_ONE_SHIFT 0 -#define UREG_BAD 0xffffffff /* not a valid ureg */ +#define UREG_BAD 0xffffffff /* not a valid ureg */ #define X SRC_X #define Y SRC_Y @@ -84,78 +84,75 @@ /* One neat thing about the UREG representation: */ -static INLINE int swizzle( int reg, int x, int y, int z, int w ) +static INLINE int +swizzle(int reg, int x, int y, int z, int w) { return ((reg & ~UREG_XYZW_CHANNEL_MASK) | - CHANNEL_SRC( GET_CHANNEL_SRC( reg, x ), 0 ) | - CHANNEL_SRC( GET_CHANNEL_SRC( reg, y ), 1 ) | - CHANNEL_SRC( GET_CHANNEL_SRC( reg, z ), 2 ) | - CHANNEL_SRC( GET_CHANNEL_SRC( reg, w ), 3 )); + CHANNEL_SRC(GET_CHANNEL_SRC(reg, x), 0) | + CHANNEL_SRC(GET_CHANNEL_SRC(reg, y), 1) | + CHANNEL_SRC(GET_CHANNEL_SRC(reg, z), 2) | + CHANNEL_SRC(GET_CHANNEL_SRC(reg, w), 3)); } /* Another neat thing about the UREG representation: */ -static INLINE int negate( int reg, int x, int y, int z, int w ) +static INLINE int +negate(int reg, int x, int y, int z, int w) { - return reg ^ (((x&1)<= 0.0) ? src1 : src2 */ -#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */ -#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */ -#define A0_FLR (0x10<<24) /* dst = floor(src0) */ -#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */ -#define A0_TRC (0x12<<24) /* dst = int(src0) */ -#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */ -#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */ +#define A0_NOP (0x0<<24) /* no operation */ +#define A0_ADD (0x1<<24) /* dst = src0 + src1 */ +#define A0_MOV (0x2<<24) /* dst = src0 */ +#define A0_MUL (0x3<<24) /* dst = src0 * src1 */ +#define A0_MAD (0x4<<24) /* dst = src0 * src1 + src2 */ +#define A0_DP2ADD (0x5<<24) /* dst.xyzw = src0.xy dot src1.xy + src2.replicate_swizzle */ +#define A0_DP3 (0x6<<24) /* dst.xyzw = src0.xyz dot src1.xyz */ +#define A0_DP4 (0x7<<24) /* dst.xyzw = src0.xyzw dot src1.xyzw */ +#define A0_FRC (0x8<<24) /* dst = src0 - floor(src0) */ +#define A0_RCP (0x9<<24) /* dst.xyzw = 1/(src0.replicate_swizzle) */ +#define A0_RSQ (0xa<<24) /* dst.xyzw = 1/(sqrt(abs(src0.replicate_swizzle))) */ +#define A0_EXP (0xb<<24) /* dst.xyzw = exp2(src0.replicate_swizzle) */ +#define A0_LOG (0xc<<24) /* dst.xyzw = log2(abs(src0.replicate_swizzle)) */ +#define A0_CMP (0xd<<24) /* dst = (src0 >= 0.0) ? src1 : src2 */ +#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */ +#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */ +#define A0_FLR (0x10<<24) /* dst = floor(src0) */ +#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */ +#define A0_TRC (0x12<<24) /* dst = int(src0) */ +#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */ +#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */ #define A0_DEST_SATURATE (1<<22) #define A0_DEST_TYPE_SHIFT 19 /* Allow: R, OC, OD, U */ @@ -601,23 +601,23 @@ /* Texture instructions */ -#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared - * sampler and address, and output - * filtered texel data to destination - * register */ -#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a - * perspective divide of the texture - * coordinate .xyz values by .w before - * sampling. */ -#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the - * computed LOD by w. Only S4.6 two's - * comp is used. This implies that a - * float to fixed conversion is - * done. */ -#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling - * operation. Simply kills the pixel - * if any channel of the address - * register is < 0.0. */ +#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared + * sampler and address, and output + * filtered texel data to destination + * register */ +#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a + * perspective divide of the texture + * coordinate .xyz values by .w before + * sampling. */ +#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the + * computed LOD by w. Only S4.6 two's + * comp is used. This implies that a + * float to fixed conversion is + * done. */ +#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling + * operation. Simply kills the pixel + * if any channel of the address + * register is < 0.0. */ #define T0_DEST_TYPE_SHIFT 19 /* Allow: R, OC, OD, U */ /* Note: U (unpreserved) regs do not retain their values between @@ -629,18 +629,18 @@ */ #define T0_DEST_NR_SHIFT 14 /* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */ -#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */ +#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */ #define T0_SAMPLER_NR_MASK (0xf<<0) -#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */ +#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */ /* Allow R, T, OC, OD -- R, OC, OD are 'dependent' reads, new program phase */ #define T1_ADDRESS_REG_NR_SHIFT 17 #define T2_MBZ 0 /* Declaration instructions */ -#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib) - * register or an s (sampler) - * register. */ +#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib) + * register or an s (sampler) + * register. */ #define D0_SAMPLE_TYPE_SHIFT 22 #define D0_SAMPLE_TYPE_2D (0x0<<22) #define D0_SAMPLE_TYPE_CUBE (0x1<<22) @@ -697,12 +697,12 @@ #define MAPSURF_4BIT_INDEXED (7<<7) #define MS3_MT_FORMAT_MASK (0x7 << 3) #define MS3_MT_FORMAT_SHIFT 3 -#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */ -#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */ +#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */ +#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */ #define MT_8BIT_L8 (1<<3) #define MT_8BIT_A8 (4<<3) #define MT_8BIT_MONO8 (5<<3) -#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */ +#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */ #define MT_16BIT_ARGB1555 (1<<3) #define MT_16BIT_ARGB4444 (2<<3) #define MT_16BIT_AY88 (3<<3) @@ -711,7 +711,7 @@ #define MT_16BIT_I16 (7<<3) #define MT_16BIT_L16 (8<<3) #define MT_16BIT_A16 (9<<3) -#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */ +#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */ #define MT_32BIT_ABGR8888 (1<<3) #define MT_32BIT_XRGB8888 (2<<3) #define MT_32BIT_XBGR8888 (3<<3) @@ -727,11 +727,11 @@ #define MT_32BIT_xI824 (0xD<<3) #define MT_32BIT_xA824 (0xE<<3) #define MT_32BIT_xL824 (0xF<<3) -#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */ +#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */ #define MT_422_YCRCB_NORMAL (1<<3) #define MT_422_YCRCB_SWAPUV (2<<3) #define MT_422_YCRCB_SWAPUVY (3<<3) -#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */ +#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */ #define MT_COMPRESS_DXT2_3 (1<<3) #define MT_COMPRESS_DXT4_5 (2<<3) #define MT_COMPRESS_FXT1 (3<<3) @@ -753,7 +753,7 @@ #define MS4_MIP_LAYOUT_LEGACY (0<<8) #define MS4_MIP_LAYOUT_BELOW_LPT (0<<8) #define MS4_MIP_LAYOUT_RIGHT_LPT (1<<8) -#define MS4_VOLUME_DEPTH_SHIFT 0 +#define MS4_VOLUME_DEPTH_SHIFT 0 #define MS4_VOLUME_DEPTH_MASK (0xff<<0) /* p244 */ @@ -781,7 +781,7 @@ #define FILTER_4X4_1 3 #define FILTER_4X4_2 4 #define FILTER_4X4_FLAT 5 -#define FILTER_6X5_MONO 6 /* XXX - check */ +#define FILTER_6X5_MONO 6 /* XXX - check */ #define SS2_MIN_FILTER_SHIFT 14 #define SS2_MIN_FILTER_MASK (0x7<<14) #define SS2_LOD_BIAS_SHIFT 5 diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index ab262ff7353..04e6106e2d6 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -46,37 +46,38 @@ static void -i915StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref, +i915StencilFuncSeparate(GLcontext * ctx, GLenum face, GLenum func, GLint ref, GLuint mask) { struct i915_context *i915 = I915_CONTEXT(ctx); - int test = intel_translate_compare_func( func ); + int test = intel_translate_compare_func(func); mask = mask & 0xff; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(func), ref, mask); + _mesa_lookup_enum_by_nr(func), ref, mask); I915_STATECHANGE(i915, I915_UPLOAD_CTX); i915->state.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; i915->state.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(mask)); + STENCIL_TEST_MASK(mask)); i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK | - S5_STENCIL_TEST_FUNC_MASK); - - i915->state.Ctx[I915_CTXREG_LIS5] |= ((ref << S5_STENCIL_REF_SHIFT) | - (test << S5_STENCIL_TEST_FUNC_SHIFT)); + S5_STENCIL_TEST_FUNC_MASK); + + i915->state.Ctx[I915_CTXREG_LIS5] |= ((ref << S5_STENCIL_REF_SHIFT) | + (test << + S5_STENCIL_TEST_FUNC_SHIFT)); } static void -i915StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) +i915StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask) { struct i915_context *i915 = I915_CONTEXT(ctx); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask); mask = mask & 0xff; @@ -84,50 +85,53 @@ i915StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) I915_STATECHANGE(i915, I915_UPLOAD_CTX); i915->state.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; i915->state.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(mask)); + STENCIL_WRITE_MASK(mask)); } static void -i915StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail, +i915StencilOpSeparate(GLcontext * ctx, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { struct i915_context *i915 = I915_CONTEXT(ctx); - int fop = intel_translate_stencil_op(fail); - int dfop = intel_translate_stencil_op(zfail); + int fop = intel_translate_stencil_op(fail); + int dfop = intel_translate_stencil_op(zfail); int dpop = intel_translate_stencil_op(zpass); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(fail), - _mesa_lookup_enum_by_nr(zfail), - _mesa_lookup_enum_by_nr(zpass)); + _mesa_lookup_enum_by_nr(fail), + _mesa_lookup_enum_by_nr(zfail), _mesa_lookup_enum_by_nr(zpass)); I915_STATECHANGE(i915, I915_UPLOAD_CTX); i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK | - S5_STENCIL_PASS_Z_FAIL_MASK | - S5_STENCIL_PASS_Z_PASS_MASK); + S5_STENCIL_PASS_Z_FAIL_MASK | + S5_STENCIL_PASS_Z_PASS_MASK); i915->state.Ctx[I915_CTXREG_LIS5] |= ((fop << S5_STENCIL_FAIL_SHIFT) | - (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) | - (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT)); + (dfop << + S5_STENCIL_PASS_Z_FAIL_SHIFT) | + (dpop << + S5_STENCIL_PASS_Z_PASS_SHIFT)); } -static void i915AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) +static void +i915AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref) { struct i915_context *i915 = I915_CONTEXT(ctx); - int test = intel_translate_compare_func( func ); + int test = intel_translate_compare_func(func); GLubyte refByte; UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref); I915_STATECHANGE(i915, I915_UPLOAD_CTX); i915->state.Ctx[I915_CTXREG_LIS6] &= ~(S6_ALPHA_TEST_FUNC_MASK | - S6_ALPHA_REF_MASK); + S6_ALPHA_REF_MASK); i915->state.Ctx[I915_CTXREG_LIS6] |= ((test << S6_ALPHA_TEST_FUNC_SHIFT) | - (((GLuint)refByte) << S6_ALPHA_REF_SHIFT)); + (((GLuint) refByte) << + S6_ALPHA_REF_SHIFT)); } /* This function makes sure that the proper enables are @@ -136,7 +140,8 @@ static void i915AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) * could change the LogicOp or Independant Alpha Blend without subsequent * calls to glEnable. */ -static void i915EvalLogicOpBlendState(GLcontext *ctx) +static void +i915EvalLogicOpBlendState(GLcontext * ctx) { struct i915_context *i915 = I915_CONTEXT(ctx); @@ -145,23 +150,26 @@ static void i915EvalLogicOpBlendState(GLcontext *ctx) if (ctx->Color._LogicOpEnabled) { i915->state.Ctx[I915_CTXREG_LIS5] |= S5_LOGICOP_ENABLE; i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE; - } else { + } + else { i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_LOGICOP_ENABLE; if (ctx->Color.BlendEnabled) { - i915->state.Ctx[I915_CTXREG_LIS6] |= S6_CBUF_BLEND_ENABLE; - } else { - i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS6] |= S6_CBUF_BLEND_ENABLE; + } + else { + i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE; } } } -static void i915BlendColor(GLcontext *ctx, const GLfloat color[4]) +static void +i915BlendColor(GLcontext * ctx, const GLfloat color[4]) { struct i915_context *i915 = I915_CONTEXT(ctx); GLubyte r, g, b, a; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]); @@ -170,7 +178,8 @@ static void i915BlendColor(GLcontext *ctx, const GLfloat color[4]) UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]); I915_STATECHANGE(i915, I915_UPLOAD_CTX); - i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b; + i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] = + (a << 24) | (r << 16) | (g << 8) | b; } @@ -181,31 +190,37 @@ static void i915BlendColor(GLcontext *ctx, const GLfloat color[4]) -static GLuint translate_blend_equation( GLenum mode ) +static GLuint +translate_blend_equation(GLenum mode) { switch (mode) { - case GL_FUNC_ADD: return BLENDFUNC_ADD; - case GL_MIN: return BLENDFUNC_MIN; - case GL_MAX: return BLENDFUNC_MAX; - case GL_FUNC_SUBTRACT: return BLENDFUNC_SUBTRACT; - case GL_FUNC_REVERSE_SUBTRACT: return BLENDFUNC_REVERSE_SUBTRACT; - default: return 0; + case GL_FUNC_ADD: + return BLENDFUNC_ADD; + case GL_MIN: + return BLENDFUNC_MIN; + case GL_MAX: + return BLENDFUNC_MAX; + case GL_FUNC_SUBTRACT: + return BLENDFUNC_SUBTRACT; + case GL_FUNC_REVERSE_SUBTRACT: + return BLENDFUNC_REVERSE_SUBTRACT; + default: + return 0; } } -static void i915UpdateBlendState( GLcontext *ctx ) +static void +i915UpdateBlendState(GLcontext * ctx) { struct i915_context *i915 = I915_CONTEXT(ctx); - GLuint iab = (i915->state.Ctx[I915_CTXREG_IAB] & - ~(IAB_SRC_FACTOR_MASK | - IAB_DST_FACTOR_MASK | - (BLENDFUNC_MASK << IAB_FUNC_SHIFT) | - IAB_ENABLE)); + GLuint iab = (i915->state.Ctx[I915_CTXREG_IAB] & + ~(IAB_SRC_FACTOR_MASK | + IAB_DST_FACTOR_MASK | + (BLENDFUNC_MASK << IAB_FUNC_SHIFT) | IAB_ENABLE)); - GLuint lis6 = (i915->state.Ctx[I915_CTXREG_LIS6] & - ~(S6_CBUF_SRC_BLEND_FACT_MASK | - S6_CBUF_DST_BLEND_FACT_MASK | - S6_CBUF_BLEND_FUNC_MASK)); + GLuint lis6 = (i915->state.Ctx[I915_CTXREG_LIS6] & + ~(S6_CBUF_SRC_BLEND_FACT_MASK | + S6_CBUF_DST_BLEND_FACT_MASK | S6_CBUF_BLEND_FUNC_MASK)); GLuint eqRGB = ctx->Color.BlendEquationRGB; GLuint eqA = ctx->Color.BlendEquationA; @@ -222,15 +237,15 @@ static void i915UpdateBlendState( GLcontext *ctx ) srcA = dstA = GL_ONE; } - lis6 |= SRC_BLND_FACT(intel_translate_blend_factor(srcRGB)); - lis6 |= DST_BLND_FACT(intel_translate_blend_factor(dstRGB)); - lis6 |= translate_blend_equation( eqRGB ) << S6_CBUF_BLEND_FUNC_SHIFT; + lis6 |= SRC_BLND_FACT(intel_translate_blend_factor(srcRGB)); + lis6 |= DST_BLND_FACT(intel_translate_blend_factor(dstRGB)); + lis6 |= translate_blend_equation(eqRGB) << S6_CBUF_BLEND_FUNC_SHIFT; - iab |= SRC_ABLND_FACT(intel_translate_blend_factor(srcA)); - iab |= DST_ABLND_FACT(intel_translate_blend_factor(dstA)); - iab |= translate_blend_equation( eqA ) << IAB_FUNC_SHIFT; + iab |= SRC_ABLND_FACT(intel_translate_blend_factor(srcA)); + iab |= DST_ABLND_FACT(intel_translate_blend_factor(dstA)); + iab |= translate_blend_equation(eqA) << IAB_FUNC_SHIFT; - if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB) + if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB) iab |= IAB_ENABLE; if (iab != i915->state.Ctx[I915_CTXREG_IAB] || @@ -245,27 +260,28 @@ static void i915UpdateBlendState( GLcontext *ctx ) } -static void i915BlendFuncSeparate(GLcontext *ctx, GLenum srcRGB, - GLenum dstRGB, GLenum srcA, - GLenum dstA ) -{ - i915UpdateBlendState( ctx ); -} - - -static void i915BlendEquationSeparate(GLcontext *ctx, GLenum eqRGB, - GLenum eqA) +static void +i915BlendFuncSeparate(GLcontext * ctx, GLenum srcRGB, + GLenum dstRGB, GLenum srcA, GLenum dstA) { - i915UpdateBlendState( ctx ); + i915UpdateBlendState(ctx); } -static void i915DepthFunc(GLcontext *ctx, GLenum func) +static void +i915BlendEquationSeparate(GLcontext * ctx, GLenum eqRGB, GLenum eqA) +{ + i915UpdateBlendState(ctx); +} + + +static void +i915DepthFunc(GLcontext * ctx, GLenum func) { struct i915_context *i915 = I915_CONTEXT(ctx); - int test = intel_translate_compare_func( func ); + int test = intel_translate_compare_func(func); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I915_STATECHANGE(i915, I915_UPLOAD_CTX); @@ -273,11 +289,12 @@ static void i915DepthFunc(GLcontext *ctx, GLenum func) i915->state.Ctx[I915_CTXREG_LIS6] |= test << S6_DEPTH_TEST_FUNC_SHIFT; } -static void i915DepthMask(GLcontext *ctx, GLboolean flag) +static void +i915DepthMask(GLcontext * ctx, GLboolean flag) { struct i915_context *i915 = I915_CONTEXT(ctx); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag); I915_STATECHANGE(i915, I915_UPLOAD_CTX); @@ -294,14 +311,15 @@ static void i915DepthMask(GLcontext *ctx, GLboolean flag) * The i915 supports a 4x4 stipple natively, GL wants 32x32. * Fortunately stipple is usually a repeating pattern. */ -static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask ) +static void +i915PolygonStipple(GLcontext * ctx, const GLubyte * mask) { struct i915_context *i915 = I915_CONTEXT(ctx); const GLubyte *m = mask; GLubyte p[4]; - int i,j,k; + int i, j, k; int active = (ctx->Polygon.StippleFlag && - i915->intel.reduced_primitive == GL_TRIANGLES); + i915->intel.reduced_primitive == GL_TRIANGLES); GLuint newMask; if (active) { @@ -309,23 +327,26 @@ static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask ) i915->state.Stipple[I915_STPREG_ST1] &= ~ST1_ENABLE; } - p[0] = mask[12] & 0xf; p[0] |= p[0] << 4; - p[1] = mask[8] & 0xf; p[1] |= p[1] << 4; - p[2] = mask[4] & 0xf; p[2] |= p[2] << 4; - p[3] = mask[0] & 0xf; p[3] |= p[3] << 4; + p[0] = mask[12] & 0xf; + p[0] |= p[0] << 4; + p[1] = mask[8] & 0xf; + p[1] |= p[1] << 4; + p[2] = mask[4] & 0xf; + p[2] |= p[2] << 4; + p[3] = mask[0] & 0xf; + p[3] |= p[3] << 4; - for (k = 0 ; k < 8 ; k++) - for (j = 3 ; j >= 0; j--) - for (i = 0 ; i < 4 ; i++, m++) - if (*m != p[j]) { - i915->intel.hw_stipple = 0; - return; - } + for (k = 0; k < 8; k++) + for (j = 3; j >= 0; j--) + for (i = 0; i < 4; i++, m++) + if (*m != p[j]) { + i915->intel.hw_stipple = 0; + return; + } newMask = (((p[0] & 0xf) << 0) | - ((p[1] & 0xf) << 4) | - ((p[2] & 0xf) << 8) | - ((p[3] & 0xf) << 12)); + ((p[1] & 0xf) << 4) | + ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12)); if (newMask == 0xffff || newMask == 0x0) { @@ -346,8 +367,8 @@ static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask ) /* ============================================================= * Hardware clipping */ -static void i915Scissor(GLcontext *ctx, GLint x, GLint y, - GLsizei w, GLsizei h) +static void +i915Scissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) { struct i915_context *i915 = I915_CONTEXT(ctx); int x1, y1, x2, y2; @@ -360,9 +381,9 @@ static void i915Scissor(GLcontext *ctx, GLint x, GLint y, x2 = x + w - 1; y2 = y1 + h - 1; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__, - x, y, w, h); + x, y, w, h); x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1); y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1); @@ -374,12 +395,13 @@ static void i915Scissor(GLcontext *ctx, GLint x, GLint y, i915->state.Buffer[I915_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff); } -static void i915LogicOp(GLcontext *ctx, GLenum opcode) +static void +i915LogicOp(GLcontext * ctx, GLenum opcode) { struct i915_context *i915 = I915_CONTEXT(ctx); int tmp = intel_translate_logic_op(opcode); - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I915_STATECHANGE(i915, I915_UPLOAD_CTX); @@ -389,14 +411,15 @@ static void i915LogicOp(GLcontext *ctx, GLenum opcode) -static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused) +static void +i915CullFaceFrontFace(GLcontext * ctx, GLenum unused) { struct i915_context *i915 = I915_CONTEXT(ctx); GLuint mode; - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s %d\n", __FUNCTION__, - ctx->DrawBuffer ? ctx->DrawBuffer->Name : 0); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s %d\n", __FUNCTION__, + ctx->DrawBuffer ? ctx->DrawBuffer->Name : 0); if (!ctx->Polygon.CullFlag) { mode = S4_CULLMODE_NONE; @@ -404,12 +427,12 @@ static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused) else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) { mode = S4_CULLMODE_CW; - if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); + if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) + mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); if (ctx->Polygon.CullFaceMode == GL_FRONT) - mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); + mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); if (ctx->Polygon.FrontFace != GL_CCW) - mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); + mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); } else { mode = S4_CULLMODE_BOTH; @@ -420,16 +443,17 @@ static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused) i915->state.Ctx[I915_CTXREG_LIS4] |= mode; } -static void i915LineWidth( GLcontext *ctx, GLfloat widthf ) +static void +i915LineWidth(GLcontext * ctx, GLfloat widthf) { - struct i915_context *i915 = I915_CONTEXT( ctx ); + struct i915_context *i915 = I915_CONTEXT(ctx); int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_LINE_WIDTH_MASK; int width; - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); - width = (int)(widthf * 2); + width = (int) (widthf * 2); CLAMP_SELF(width, 1, 0xf); lis4 |= width << S4_LINE_WIDTH_SHIFT; @@ -439,14 +463,15 @@ static void i915LineWidth( GLcontext *ctx, GLfloat widthf ) } } -static void i915PointSize(GLcontext *ctx, GLfloat size) +static void +i915PointSize(GLcontext * ctx, GLfloat size) { struct i915_context *i915 = I915_CONTEXT(ctx); int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_POINT_WIDTH_MASK; - GLint point_size = (int)size; + GLint point_size = (int) size; - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s\n", __FUNCTION__); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s\n", __FUNCTION__); CLAMP_SELF(point_size, 1, 255); lis4 |= point_size << S4_POINT_WIDTH_SHIFT; @@ -462,20 +487,25 @@ static void i915PointSize(GLcontext *ctx, GLfloat size) * Color masks */ -static void i915ColorMask(GLcontext *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a) +static void +i915ColorMask(GLcontext * ctx, + GLboolean r, GLboolean g, GLboolean b, GLboolean a) { - struct i915_context *i915 = I915_CONTEXT( ctx ); + struct i915_context *i915 = I915_CONTEXT(ctx); GLuint tmp = i915->state.Ctx[I915_CTXREG_LIS5] & ~S5_WRITEDISABLE_MASK; - if (INTEL_DEBUG&DEBUG_DRI) - fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a); + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, + a); - if (!r) tmp |= S5_WRITEDISABLE_RED; - if (!g) tmp |= S5_WRITEDISABLE_GREEN; - if (!b) tmp |= S5_WRITEDISABLE_BLUE; - if (!a) tmp |= S5_WRITEDISABLE_ALPHA; + if (!r) + tmp |= S5_WRITEDISABLE_RED; + if (!g) + tmp |= S5_WRITEDISABLE_GREEN; + if (!b) + tmp |= S5_WRITEDISABLE_BLUE; + if (!a) + tmp |= S5_WRITEDISABLE_ALPHA; if (tmp != i915->state.Ctx[I915_CTXREG_LIS5]) { I915_STATECHANGE(i915, I915_UPLOAD_CTX); @@ -483,54 +513,58 @@ static void i915ColorMask(GLcontext *ctx, } } -static void update_specular( GLcontext *ctx ) +static void +update_specular(GLcontext * ctx) { /* A hack to trigger the rebuild of the fragment program. */ intel_context(ctx)->NewGLState |= _NEW_TEXTURE; - I915_CONTEXT(ctx)->tex_program.translated = 0; + I915_CONTEXT(ctx)->tex_program.translated = 0; } -static void i915LightModelfv(GLcontext *ctx, GLenum pname, - const GLfloat *param) +static void +i915LightModelfv(GLcontext * ctx, GLenum pname, const GLfloat * param) { - if (INTEL_DEBUG&DEBUG_DRI) + if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { - update_specular( ctx ); + update_specular(ctx); } } -static void i915ShadeModel(GLcontext *ctx, GLenum mode) +static void +i915ShadeModel(GLcontext * ctx, GLenum mode) { struct i915_context *i915 = I915_CONTEXT(ctx); I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (mode == GL_SMOOTH) { - i915->state.Ctx[I915_CTXREG_LIS4] &= ~(S4_FLATSHADE_ALPHA | - S4_FLATSHADE_COLOR | - S4_FLATSHADE_SPECULAR); - } else { - i915->state.Ctx[I915_CTXREG_LIS4] |= (S4_FLATSHADE_ALPHA | - S4_FLATSHADE_COLOR | - S4_FLATSHADE_SPECULAR); + i915->state.Ctx[I915_CTXREG_LIS4] &= ~(S4_FLATSHADE_ALPHA | + S4_FLATSHADE_COLOR | + S4_FLATSHADE_SPECULAR); + } + else { + i915->state.Ctx[I915_CTXREG_LIS4] |= (S4_FLATSHADE_ALPHA | + S4_FLATSHADE_COLOR | + S4_FLATSHADE_SPECULAR); } } /* ============================================================= * Fog */ -void i915_update_fog( GLcontext *ctx ) +void +i915_update_fog(GLcontext * ctx) { struct i915_context *i915 = I915_CONTEXT(ctx); GLenum mode; GLboolean enabled; GLboolean try_pixel_fog; - + if (ctx->FragmentProgram._Active) { /* Pull in static fog state from program */ - + mode = ctx->FragmentProgram._Current->FogOption; enabled = (mode != GL_NONE); try_pixel_fog = 0; @@ -539,9 +573,7 @@ void i915_update_fog( GLcontext *ctx ) enabled = ctx->Fog.Enabled; mode = ctx->Fog.Mode; - try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && - ctx->Hint.Fog == GL_NICEST && - 0); /* XXX - DISABLE -- Need ortho fallback */ + try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && ctx->Hint.Fog == GL_NICEST && 0); /* XXX - DISABLE -- Need ortho fallback */ } if (!enabled) { @@ -552,47 +584,53 @@ void i915_update_fog( GLcontext *ctx ) I915_STATECHANGE(i915, I915_UPLOAD_FOG); i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK; i915->vertex_fog = I915_FOG_PIXEL; - + switch (mode) { case GL_LINEAR: - if (ctx->Fog.End <= ctx->Fog.Start) { - /* XXX - this won't work with fragment programs. Need to - * either fallback or append fog instructions to end of - * program in the case of linear fog. - */ - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX; - i915->vertex_fog = I915_FOG_VERTEX; - } - else { - GLfloat c1 = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start); - GLfloat c2 = 1.0/(ctx->Fog.End-ctx->Fog.Start); + if (ctx->Fog.End <= ctx->Fog.Start) { + /* XXX - this won't work with fragment programs. Need to + * either fallback or append fog instructions to end of + * program in the case of linear fog. + */ + i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX; + i915->vertex_fog = I915_FOG_VERTEX; + } + else { + GLfloat c1 = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start); + GLfloat c2 = 1.0 / (ctx->Fog.End - ctx->Fog.Start); - i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK; - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR; - i915->state.Fog[I915_FOGREG_MODE1] |= - ((GLuint)(c1 * FMC1_C1_ONE)) & FMC1_C1_MASK; + i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK; + i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR; + i915->state.Fog[I915_FOGREG_MODE1] |= + ((GLuint) (c1 * FMC1_C1_ONE)) & FMC1_C1_MASK; - if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) { - i915->state.Fog[I915_FOGREG_MODE2] = (GLuint)(c2 * FMC2_C2_ONE); - } - else { - union { float f; int i; } fi; - fi.f = c2; - i915->state.Fog[I915_FOGREG_MODE2] = fi.i; - } - } - break; + if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) { + i915->state.Fog[I915_FOGREG_MODE2] = + (GLuint) (c2 * FMC2_C2_ONE); + } + else { + union + { + float f; + int i; + } fi; + fi.f = c2; + i915->state.Fog[I915_FOGREG_MODE2] = fi.i; + } + } + break; case GL_EXP: - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP; - break; + i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP; + break; case GL_EXP2: - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP2; - break; + i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP2; + break; default: - break; + break; } } - else /* if (i915->vertex_fog != I915_FOG_VERTEX) */ { + else { /* if (i915->vertex_fog != I915_FOG_VERTEX) */ + I915_STATECHANGE(i915, I915_UPLOAD_FOG); i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK; i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX; @@ -603,49 +641,54 @@ void i915_update_fog( GLcontext *ctx ) I915_STATECHANGE(i915, I915_UPLOAD_CTX); I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled); if (enabled) - i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE; else - i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE; } if (enabled) { - _tnl_allow_vertex_fog( ctx, (i915->vertex_fog == I915_FOG_VERTEX) ); - _tnl_allow_pixel_fog( ctx, (i915->vertex_fog != I915_FOG_VERTEX) ); + _tnl_allow_vertex_fog(ctx, (i915->vertex_fog == I915_FOG_VERTEX)); + _tnl_allow_pixel_fog(ctx, (i915->vertex_fog != I915_FOG_VERTEX)); } } -static void i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) +static void +i915Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param) { struct i915_context *i915 = I915_CONTEXT(ctx); switch (pname) { - case GL_FOG_COORDINATE_SOURCE_EXT: + case GL_FOG_COORDINATE_SOURCE_EXT: case GL_FOG_MODE: case GL_FOG_START: - case GL_FOG_END: + case GL_FOG_END: break; case GL_FOG_DENSITY: I915_STATECHANGE(i915, I915_UPLOAD_FOG); if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) { - i915->state.Fog[I915_FOGREG_MODE3] = (GLuint)(ctx->Fog.Density * - FMC3_D_ONE); + i915->state.Fog[I915_FOGREG_MODE3] = (GLuint) (ctx->Fog.Density * + FMC3_D_ONE); } else { - union { float f; int i; } fi; - fi.f = ctx->Fog.Density; - i915->state.Fog[I915_FOGREG_MODE3] = fi.i; + union + { + float f; + int i; + } fi; + fi.f = ctx->Fog.Density; + i915->state.Fog[I915_FOGREG_MODE3] = fi.i; } break; - case GL_FOG_COLOR: + case GL_FOG_COLOR: I915_STATECHANGE(i915, I915_UPLOAD_FOG); - i915->state.Fog[I915_FOGREG_COLOR] = - (_3DSTATE_FOG_COLOR_CMD | - ((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) | - ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) | - ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0)); + i915->state.Fog[I915_FOGREG_COLOR] = + (_3DSTATE_FOG_COLOR_CMD | + ((GLubyte) (ctx->Fog.Color[0] * 255.0F) << 16) | + ((GLubyte) (ctx->Fog.Color[1] * 255.0F) << 8) | + ((GLubyte) (ctx->Fog.Color[2] * 255.0F) << 0)); break; default: @@ -653,7 +696,8 @@ static void i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) } } -static void i915Hint(GLcontext *ctx, GLenum target, GLenum state) +static void +i915Hint(GLcontext * ctx, GLenum target, GLenum state) { switch (target) { case GL_FOG_HINT: @@ -666,25 +710,26 @@ static void i915Hint(GLcontext *ctx, GLenum target, GLenum state) /* ============================================================= */ -static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) +static void +i915Enable(GLcontext * ctx, GLenum cap, GLboolean state) { struct i915_context *i915 = I915_CONTEXT(ctx); - switch(cap) { + switch (cap) { case GL_TEXTURE_2D: break; case GL_LIGHTING: case GL_COLOR_SUM: - update_specular( ctx ); + update_specular(ctx); break; case GL_ALPHA_TEST: I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (state) - i915->state.Ctx[I915_CTXREG_LIS6] |= S6_ALPHA_TEST_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS6] |= S6_ALPHA_TEST_ENABLE; else - i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_ALPHA_TEST_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_ALPHA_TEST_ENABLE; break; case GL_BLEND: @@ -696,8 +741,8 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) /* Logicop doesn't seem to work at 16bpp: */ - if (i915->intel.intelScreen->cpp == 2) /* XXX FBO fix */ - FALLBACK( &i915->intel, I915_FALLBACK_LOGICOP, state ); + if (i915->intel.intelScreen->cpp == 2) /* XXX FBO fix */ + FALLBACK(&i915->intel, I915_FALLBACK_LOGICOP, state); break; case GL_FRAGMENT_PROGRAM_ARB: @@ -706,37 +751,37 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_DITHER: I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (state) - i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE; else - i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_COLOR_DITHER_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_COLOR_DITHER_ENABLE; break; case GL_DEPTH_TEST: I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (state) - i915->state.Ctx[I915_CTXREG_LIS6] |= S6_DEPTH_TEST_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS6] |= S6_DEPTH_TEST_ENABLE; else - i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_ENABLE; - i915DepthMask( ctx, ctx->Depth.Mask ); + i915DepthMask(ctx, ctx->Depth.Mask); break; case GL_SCISSOR_TEST: I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); if (state) - i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD | - ENABLE_SCISSOR_RECT); + i915->state.Buffer[I915_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT); else - i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + i915->state.Buffer[I915_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); break; case GL_LINE_SMOOTH: I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (state) - i915->state.Ctx[I915_CTXREG_LIS4] |= S4_LINE_ANTIALIAS_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS4] |= S4_LINE_ANTIALIAS_ENABLE; else - i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_LINE_ANTIALIAS_ENABLE; + i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_LINE_ANTIALIAS_ENABLE; break; case GL_FOG: @@ -758,12 +803,13 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) I915_STATECHANGE(i915, I915_UPLOAD_CTX); if (state) i915->state.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); + S5_STENCIL_WRITE_ENABLE); else - i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); - } else { - FALLBACK( &i915->intel, I915_FALLBACK_STENCIL, state ); + i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | + S5_STENCIL_WRITE_ENABLE); + } + else { + FALLBACK(&i915->intel, I915_FALLBACK_STENCIL, state); } } break; @@ -773,23 +819,22 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) * I'll do more testing later to find out exactly which hardware * supports it. Disabled for now. */ - if (i915->intel.hw_stipple && - i915->intel.reduced_primitive == GL_TRIANGLES) - { - I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE); - if (state) - i915->state.Stipple[I915_STPREG_ST1] |= ST1_ENABLE; - else - i915->state.Stipple[I915_STPREG_ST1] &= ~ST1_ENABLE; + if (i915->intel.hw_stipple && + i915->intel.reduced_primitive == GL_TRIANGLES) { + I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE); + if (state) + i915->state.Stipple[I915_STPREG_ST1] |= ST1_ENABLE; + else + i915->state.Stipple[I915_STPREG_ST1] &= ~ST1_ENABLE; } break; case GL_POLYGON_SMOOTH: - FALLBACK( &i915->intel, I915_FALLBACK_POLYGON_SMOOTH, state ); + FALLBACK(&i915->intel, I915_FALLBACK_POLYGON_SMOOTH, state); break; case GL_POINT_SMOOTH: - FALLBACK( &i915->intel, I915_FALLBACK_POINT_SMOOTH, state ); + FALLBACK(&i915->intel, I915_FALLBACK_POINT_SMOOTH, state); break; default: @@ -798,7 +843,8 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state) } -static void i915_init_packets( struct i915_context *i915 ) +static void +i915_init_packets(struct i915_context *i915) { intelScreenPrivate *screen = i915->intel.intelScreen; @@ -811,38 +857,35 @@ static void i915_init_packets( struct i915_context *i915 ) /* Probably don't want to upload all this stuff every time one * piece changes. */ - i915->state.Ctx[I915_CTXREG_LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | - I1_LOAD_S(4) | - I1_LOAD_S(5) | - I1_LOAD_S(6) | - (4)); + i915->state.Ctx[I915_CTXREG_LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | + I1_LOAD_S(4) | + I1_LOAD_S(5) | I1_LOAD_S(6) | (4)); i915->state.Ctx[I915_CTXREG_LIS2] = 0; i915->state.Ctx[I915_CTXREG_LIS4] = 0; i915->state.Ctx[I915_CTXREG_LIS5] = 0; - if (screen->cpp == 2) /* XXX FBO fix */ - i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE; + if (screen->cpp == 2) /* XXX FBO fix */ + i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE; i915->state.Ctx[I915_CTXREG_LIS6] = (S6_COLOR_WRITE_ENABLE | - (2 << S6_TRISTRIP_PV_SHIFT)); + (2 << S6_TRISTRIP_PV_SHIFT)); i915->state.Ctx[I915_CTXREG_STATE4] = (_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | - LOGIC_OP_FUNC(LOGICOP_COPY) | - ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff) | - ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(0xff)); + ENABLE_LOGIC_OP_FUNC | + LOGIC_OP_FUNC(LOGICOP_COPY) | + ENABLE_STENCIL_TEST_MASK | + STENCIL_TEST_MASK(0xff) | + ENABLE_STENCIL_WRITE_MASK | + STENCIL_WRITE_MASK(0xff)); - i915->state.Ctx[I915_CTXREG_IAB] = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_MODIFY_FUNC | - IAB_MODIFY_SRC_FACTOR | - IAB_MODIFY_DST_FACTOR); + i915->state.Ctx[I915_CTXREG_IAB] = + (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | IAB_MODIFY_ENABLE | + IAB_MODIFY_FUNC | IAB_MODIFY_SRC_FACTOR | IAB_MODIFY_DST_FACTOR); - i915->state.Ctx[I915_CTXREG_BLENDCOLOR0] = _3DSTATE_CONST_BLEND_COLOR_CMD; + i915->state.Ctx[I915_CTXREG_BLENDCOLOR0] = + _3DSTATE_CONST_BLEND_COLOR_CMD; i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] = 0; } @@ -857,11 +900,11 @@ static void i915_init_packets( struct i915_context *i915 ) I915_STATECHANGE(i915, I915_UPLOAD_FOG); i915->state.Fog[I915_FOGREG_MODE0] = _3DSTATE_FOG_MODE_CMD; i915->state.Fog[I915_FOGREG_MODE1] = (FMC1_FOGFUNC_MODIFY_ENABLE | - FMC1_FOGFUNC_VERTEX | - FMC1_FOGINDEX_MODIFY_ENABLE | - FMC1_FOGINDEX_W | - FMC1_C1_C2_MODIFY_ENABLE | - FMC1_DENSITY_MODIFY_ENABLE); + FMC1_FOGFUNC_VERTEX | + FMC1_FOGINDEX_MODIFY_ENABLE | + FMC1_FOGINDEX_W | + FMC1_C1_C2_MODIFY_ENABLE | + FMC1_DENSITY_MODIFY_ENABLE); i915->state.Fog[I915_FOGREG_COLOR] = _3DSTATE_FOG_COLOR_CMD; } @@ -871,47 +914,43 @@ static void i915_init_packets( struct i915_context *i915 ) /* color buffer offset/stride */ i915->state.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ - i915->state.Buffer[I915_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | - BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); + i915->state.Buffer[I915_DESTREG_CBUFADDR1] = (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(screen->front.pitch) | /* pitch in bytes */ + BUF_3D_USE_FENCE); i915->state.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ - i915->state.Buffer[I915_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | - BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ - BUF_3D_USE_FENCE); + i915->state.Buffer[I915_DESTREG_DBUFADDR1] = (BUF_3D_ID_DEPTH | BUF_3D_PITCH(screen->depth.pitch) | /* pitch in bytes */ + BUF_3D_USE_FENCE); i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; /* XXX FBO: remove this? Also get set in i915_set_draw_region() */ -#if 0 /* seems we don't need this */ +#if 0 /* seems we don't need this */ switch (screen->fbFormat) { case DV_PF_565: - i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - DITHER_FULL_ALWAYS | - screen->fbFormat | - DEPTH_FRMT_16_FIXED); - break; + i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + LOD_PRECLAMP_OGL | + TEX_DEFAULT_COLOR_OGL | + DITHER_FULL_ALWAYS | + screen->fbFormat | + DEPTH_FRMT_16_FIXED); + break; case DV_PF_8888: - i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - screen->fbFormat | - DEPTH_FRMT_24_FIXED_8_OTHER); - break; + i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + LOD_PRECLAMP_OGL | + TEX_DEFAULT_COLOR_OGL | + screen->fbFormat | + DEPTH_FRMT_24_FIXED_8_OTHER); + break; } #endif /* scissor */ - i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + i915->state.Buffer[I915_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); i915->state.Buffer[I915_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD; i915->state.Buffer[I915_DESTREG_SR1] = 0; i915->state.Buffer[I915_DESTREG_SR2] = 0; @@ -934,14 +973,14 @@ static void i915_init_packets( struct i915_context *i915 ) /* These will be emitted every at the head of every buffer, unless * we get hardware contexts working. */ - i915->state.active = (I915_UPLOAD_PROGRAM | - I915_UPLOAD_STIPPLE | - I915_UPLOAD_CTX | - I915_UPLOAD_BUFFERS | - I915_UPLOAD_INVARIENT); + i915->state.active = (I915_UPLOAD_PROGRAM | + I915_UPLOAD_STIPPLE | + I915_UPLOAD_CTX | + I915_UPLOAD_BUFFERS | I915_UPLOAD_INVARIENT); } -void i915InitStateFunctions( struct dd_function_table *functions ) +void +i915InitStateFunctions(struct dd_function_table *functions) { functions->AlphaFunc = i915AlphaFunc; functions->BlendColor = i915BlendColor; @@ -968,21 +1007,15 @@ void i915InitStateFunctions( struct dd_function_table *functions ) } -void i915InitState( struct i915_context *i915 ) +void +i915InitState(struct i915_context *i915) { GLcontext *ctx = &i915->intel.ctx; - i915_init_packets( i915 ); + i915_init_packets(i915); - intelInitState( ctx ); + intelInitState(ctx); - memcpy( &i915->initial, &i915->state, sizeof(i915->state) ); + memcpy(&i915->initial, &i915->state, sizeof(i915->state)); i915->current = &i915->state; } - - - - - - - diff --git a/src/mesa/drivers/dri/i915/i915_tex.c b/src/mesa/drivers/dri/i915/i915_tex.c index 7f47cf90445..a53abe9a92f 100644 --- a/src/mesa/drivers/dri/i915/i915_tex.c +++ b/src/mesa/drivers/dri/i915/i915_tex.c @@ -45,13 +45,14 @@ -static void i915TexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) +static void +i915TexEnv(GLcontext * ctx, GLenum target, + GLenum pname, const GLfloat * param) { - struct i915_context *i915 = I915_CONTEXT( ctx ); + struct i915_context *i915 = I915_CONTEXT(ctx); switch (pname) { - case GL_TEXTURE_ENV_COLOR: /* Should be a tracked param */ + case GL_TEXTURE_ENV_COLOR: /* Should be a tracked param */ case GL_TEXTURE_ENV_MODE: case GL_COMBINE_RGB: case GL_COMBINE_ALPHA: @@ -69,18 +70,21 @@ static void i915TexEnv( GLcontext *ctx, GLenum target, case GL_OPERAND2_ALPHA: case GL_RGB_SCALE: case GL_ALPHA_SCALE: - i915->tex_program.translated = 0; + i915->tex_program.translated = 0; break; - case GL_TEXTURE_LOD_BIAS: { - GLuint unit = ctx->Texture.CurrentUnit; - GLint b = (int) ((*param) * 16.0); - if (b > 255) b = 255; - if (b < -256) b = -256; - I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit)); - i915->lodbias_ss2[unit] = ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK); - break; - } + case GL_TEXTURE_LOD_BIAS:{ + GLuint unit = ctx->Texture.CurrentUnit; + GLint b = (int) ((*param) * 16.0); + if (b > 255) + b = 255; + if (b < -256) + b = -256; + I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit)); + i915->lodbias_ss2[unit] = + ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK); + break; + } default: break; @@ -88,19 +92,21 @@ static void i915TexEnv( GLcontext *ctx, GLenum target, } -static void i915BindTexture( GLcontext *ctx, GLenum target, - struct gl_texture_object *texobj ) +static void +i915BindTexture(GLcontext * ctx, GLenum target, + struct gl_texture_object *texobj) { /* Need this if image format changes between bound textures. * Could try and shortcircuit by checking for differences in * state between incoming and outgoing textures: */ - I915_CONTEXT(ctx)->tex_program.translated = 0; + I915_CONTEXT(ctx)->tex_program.translated = 0; } -void i915InitTextureFuncs( struct dd_function_table *functions ) +void +i915InitTextureFuncs(struct dd_function_table *functions) { functions->BindTexture = i915BindTexture; functions->TexEnv = i915TexEnv; diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c index e7622776452..771289a5d04 100644 --- a/src/mesa/drivers/dri/i915/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c @@ -31,334 +31,333 @@ #include "intel_mipmap_tree.h" #include "macros.h" +#include "intel_context.h" #define FILE_DEBUG_FLAG DEBUG_TEXTURE -static GLint initial_offsets[6][2] = { {0,0}, - {0,2}, - {1,0}, - {1,2}, - {1,1}, - {1,3} }; +static GLint initial_offsets[6][2] = { {0, 0}, +{0, 2}, +{1, 0}, +{1, 2}, +{1, 1}, +{1, 3} +}; -static GLint step_offsets[6][2] = { {0,2}, - {0,2}, - {-1,2}, - {-1,2}, - {-1,1}, - {-1,1} }; +static GLint step_offsets[6][2] = { {0, 2}, +{0, 2}, +{-1, 2}, +{-1, 2}, +{-1, 1}, +{-1, 1} +}; -static GLuint minify( GLuint d ) +static GLuint +minify(GLuint d) { - return MAX2(1, d>>1); + return MAX2(1, d >> 1); } -GLboolean i915_miptree_layout( struct intel_mipmap_tree *mt ) +GLboolean +i915_miptree_layout(struct intel_mipmap_tree * mt) { GLint level; switch (mt->target) { - case GL_TEXTURE_CUBE_MAP: { - const GLuint dim = mt->width0; - GLuint face; + case GL_TEXTURE_CUBE_MAP:{ + const GLuint dim = mt->width0; + GLuint face; - /* 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++) - intel_miptree_set_level_info(mt, level, 6, - 0, 0, - mt->pitch, mt->total_height, 1); + /* double pitch for cube layouts */ + mt->pitch = ((dim * mt->cpp * 2 + 3) & ~3) / mt->cpp; + mt->total_height = dim * 4; - for ( face = 0 ; face < 6 ; face++) { - GLuint x = initial_offsets[face][0] * dim; - GLuint y = initial_offsets[face][1] * dim; - GLuint d = dim; - - for (level = mt->first_level; level <= mt->last_level; level++) { - intel_miptree_set_image_offset(mt, level, face, x, y); + 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); - if (d == 0) - _mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n", - face, level, mt->first_level, mt->last_level); + for (face = 0; face < 6; face++) { + GLuint x = initial_offsets[face][0] * dim; + GLuint y = initial_offsets[face][1] * dim; + GLuint d = dim; - d >>= 1; - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - } + for (level = mt->first_level; level <= mt->last_level; level++) { + intel_miptree_set_image_offset(mt, level, face, x, y); + + if (d == 0) + _mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n", + face, level, mt->first_level, mt->last_level); + + d >>= 1; + x += step_offsets[face][0] * d; + y += step_offsets[face][1] * d; + } + } + break; } - break; - } - case GL_TEXTURE_3D: { - GLuint width = mt->width0; - GLuint height = mt->height0; - GLuint depth = mt->depth0; - GLuint stack_height = 0; + case GL_TEXTURE_3D:{ + GLuint width = mt->width0; + GLuint height = mt->height0; + GLuint depth = mt->depth0; + GLuint stack_height = 0; - /* Calculate the size of a single slice. - */ - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + /* Calculate the size of a single slice. + */ + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - /* XXX: hardware expects/requires 9 levels at minimum. - */ - for ( level = mt->first_level ; level <= MAX2(8, mt->last_level) ; level++ ) { - intel_miptree_set_level_info(mt, level, 1, - 0, mt->total_height, - width, height, depth); + /* XXX: hardware expects/requires 9 levels at minimum. + */ + for (level = mt->first_level; level <= MAX2(8, mt->last_level); + level++) { + intel_miptree_set_level_info(mt, level, 1, 0, mt->total_height, + width, height, depth); - stack_height += MAX2(2, height); + stack_height += MAX2(2, height); - width = minify(width); - height = minify(height); - depth = minify(depth); + width = minify(width); + height = minify(height); + depth = minify(depth); + } + + /* Fixup depth image_offsets: + */ + depth = mt->depth0; + for (level = mt->first_level; level <= mt->last_level; level++) { + GLuint i; + for (i = 0; i < depth; i++) + intel_miptree_set_image_offset(mt, level, depth, + 0, i * stack_height); + + + depth = minify(depth); + } + + + /* Multiply slice size by texture depth for total size. It's + * remarkable how wasteful of memory the i915 texture layouts + * are. They are largely fixed in the i945. + */ + mt->total_height = stack_height * mt->depth0; + break; } - /* Fixup depth image_offsets: - */ - depth = mt->depth0; - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - GLuint i; - for (i = 0; i < depth; i++) - intel_miptree_set_image_offset(mt, level, depth, - 0, i * stack_height ); + default:{ + GLuint width = mt->width0; + GLuint height = mt->height0; + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + mt->total_height = 0; - depth = minify(depth); + for (level = mt->first_level; level <= mt->last_level; level++) { + intel_miptree_set_level_info(mt, level, 1, + 0, mt->total_height, + width, height, 1); + + if (mt->compressed) + mt->total_height += MAX2(1, height / 4); + else + mt->total_height += MAX2(2, height); + + width = minify(width); + height = minify(height); + } + break; } - - - /* Multiply slice size by texture depth for total size. It's - * remarkable how wasteful of memory the i915 texture layouts - * are. They are largely fixed in the i945. - */ - mt->total_height = stack_height * mt->depth0; - break; } - - default: { - GLuint width = mt->width0; - GLuint height = mt->height0; - - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - mt->total_height = 0; - - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - intel_miptree_set_level_info(mt, level, 1, - 0, mt->total_height, - width, height, 1); - - if (mt->compressed) - mt->total_height += MAX2(1, height/4); - else - mt->total_height += MAX2(2, height); - - width = minify(width); - height = minify(height); - } - break; - } - } - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - mt->pitch, - mt->total_height, - mt->cpp, - mt->pitch * mt->total_height * mt->cpp ); + DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, + mt->pitch, + mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp); return GL_TRUE; } -GLboolean i945_miptree_layout( struct intel_mipmap_tree *mt ) +GLboolean +i945_miptree_layout(struct intel_mipmap_tree * mt) { GLint level; switch (mt->target) { - case GL_TEXTURE_CUBE_MAP: { - const GLuint dim = mt->width0; - GLuint face; + case GL_TEXTURE_CUBE_MAP:{ + const GLuint dim = mt->width0; + GLuint face; - /* Depending on the size of the largest images, pitch can be - * determined either by the old-style packing of cubemap faces, - * or the final row of 4x4, 2x2 and 1x1 faces below this. - */ - if (dim > 32) - mt->pitch = ((dim * mt->cpp * 2 + 3) & ~3) / mt->cpp; - else - mt->pitch = 14 * 8; + /* Depending on the size of the largest images, pitch can be + * determined either by the old-style packing of cubemap faces, + * or the final row of 4x4, 2x2 and 1x1 faces below this. + */ + if (dim > 32) + mt->pitch = ((dim * mt->cpp * 2 + 3) & ~3) / mt->cpp; + else + mt->pitch = 14 * 8; - mt->total_height = dim * 4 + 4; + mt->total_height = dim * 4 + 4; - /* Set all the levels to effectively occupy the whole rectangular region. - */ - 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); + /* Set all the levels to effectively occupy the whole rectangular region. + */ + 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); - - for ( face = 0 ; face < 6 ; face++) { - GLuint x = initial_offsets[face][0] * dim; - GLuint y = initial_offsets[face][1] * dim; - GLuint d = dim; - - if (dim == 4 && face >= 4) { - y = mt->total_height - 4; - x = (face - 4) * 8; - } - else if (dim < 4) { - y = mt->total_height - 4; - x = face * 8; - } - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - intel_miptree_set_image_offset(mt, level, face, - x, y); + for (face = 0; face < 6; face++) { + GLuint x = initial_offsets[face][0] * dim; + GLuint y = initial_offsets[face][1] * dim; + GLuint d = dim; - d >>= 1; - - switch (d) { - case 4: - switch (face) { - case FACE_POS_X: - case FACE_NEG_X: - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - break; - case FACE_POS_Y: - case FACE_NEG_Y: - y += 12; - x -= 8; - break; - case FACE_POS_Z: - case FACE_NEG_Z: - y = mt->total_height - 4; - x = (face - 4) * 8; - break; - } + if (dim == 4 && face >= 4) { + y = mt->total_height - 4; + x = (face - 4) * 8; + } + else if (dim < 4) { + y = mt->total_height - 4; + x = face * 8; + } - case 2: - y = mt->total_height - 4; - x = 16 + face * 8; - break; + for (level = mt->first_level; level <= mt->last_level; level++) { + intel_miptree_set_image_offset(mt, level, face, x, y); - case 1: - x += 48; - break; - - default: - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - break; - } - } + d >>= 1; + + switch (d) { + case 4: + switch (face) { + case FACE_POS_X: + case FACE_NEG_X: + x += step_offsets[face][0] * d; + y += step_offsets[face][1] * d; + break; + case FACE_POS_Y: + case FACE_NEG_Y: + y += 12; + x -= 8; + break; + case FACE_POS_Z: + case FACE_NEG_Z: + y = mt->total_height - 4; + x = (face - 4) * 8; + break; + } + + case 2: + y = mt->total_height - 4; + x = 16 + face * 8; + break; + + case 1: + x += 48; + break; + + default: + x += step_offsets[face][0] * d; + y += step_offsets[face][1] * d; + break; + } + } + } + break; } - break; - } - case GL_TEXTURE_3D: { - GLuint width = mt->width0; - GLuint height = mt->height0; - GLuint depth = mt->depth0; - GLuint pack_x_pitch, pack_x_nr; - GLuint pack_y_pitch; - GLuint level; + case GL_TEXTURE_3D:{ + GLuint width = mt->width0; + GLuint height = mt->height0; + GLuint depth = mt->depth0; + GLuint pack_x_pitch, pack_x_nr; + GLuint pack_y_pitch; + GLuint level; - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - mt->total_height = 0; + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + mt->total_height = 0; - pack_y_pitch = MAX2(mt->height0, 2); - pack_x_pitch = mt->pitch; - pack_x_nr = 1; + pack_y_pitch = MAX2(mt->height0, 2); + pack_x_pitch = mt->pitch; + pack_x_nr = 1; - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - GLuint nr_images = mt->target == GL_TEXTURE_3D ? depth : 6; - GLint x = 0; - GLint y = 0; - GLint q, j; - - intel_miptree_set_level_info(mt, level, nr_images, - 0, mt->total_height, - width, height, depth); + for (level = mt->first_level; level <= mt->last_level; level++) { + GLuint nr_images = mt->target == GL_TEXTURE_3D ? depth : 6; + GLint x = 0; + GLint y = 0; + GLint q, j; - for (q = 0; q < nr_images;) { - for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) { - intel_miptree_set_image_offset(mt, level, q, x, y); - x += pack_x_pitch; - } + intel_miptree_set_level_info(mt, level, nr_images, + 0, mt->total_height, + width, height, depth); - x = 0; - y += pack_y_pitch; - } + for (q = 0; q < nr_images;) { + for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) { + intel_miptree_set_image_offset(mt, level, q, x, y); + x += pack_x_pitch; + } + + x = 0; + y += pack_y_pitch; + } - mt->total_height += y; + mt->total_height += y; - if (pack_x_pitch > 4) { - pack_x_pitch >>= 1; - pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr <= mt->pitch); - } + if (pack_x_pitch > 4) { + pack_x_pitch >>= 1; + pack_x_nr <<= 1; + assert(pack_x_pitch * pack_x_nr <= mt->pitch); + } - if (pack_y_pitch > 2) { - pack_y_pitch >>= 1; - } + if (pack_y_pitch > 2) { + pack_y_pitch >>= 1; + } - width = minify(width); - height = minify(height); - depth = minify(depth); + width = minify(width); + height = minify(height); + depth = minify(depth); + } + break; } - break; - } case GL_TEXTURE_1D: case GL_TEXTURE_2D: - case GL_TEXTURE_RECTANGLE_ARB: { - GLuint x = 0; - GLuint y = 0; - GLuint width = mt->width0; - GLuint height = mt->height0; + case GL_TEXTURE_RECTANGLE_ARB:{ + GLuint x = 0; + GLuint y = 0; + GLuint width = mt->width0; + GLuint height = mt->height0; - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; - mt->total_height = 0; + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + mt->total_height = 0; - for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { - intel_miptree_set_level_info(mt, level, 1, - x, y, - width, height, 1); + for (level = mt->first_level; level <= mt->last_level; level++) { + intel_miptree_set_level_info(mt, level, 1, + x, y, width, height, 1); - - /* LPT change: step right after second mipmap. - */ - if (level == 1) - x += mt->pitch / 2; - else if (mt->compressed) - y += MAX2(1, height/4); - else - y += MAX2(2, height); - /* Because the images are packed better, the final offset - * might not be the maximal one: - */ - mt->total_height = MAX2(mt->total_height, y); + /* LPT change: step right after second mipmap. + */ + if (level == 1) + x += mt->pitch / 2; + else if (mt->compressed) + y += MAX2(1, height / 4); + else + y += MAX2(2, height); - width = minify(width); - height = minify(height); + /* Because the images are packed better, the final offset + * might not be the maximal one: + */ + mt->total_height = MAX2(mt->total_height, y); + + width = minify(width); + height = minify(height); + } + break; } - break; - } default: _mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()"); } - - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - mt->pitch, - mt->total_height, - mt->cpp, - mt->pitch * mt->total_height * mt->cpp ); - + + DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, + mt->pitch, + mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp); + return GL_TRUE; } - diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index af68c9f4242..033369a5a8f 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -36,7 +36,8 @@ #include "i915_reg.h" -static GLuint translate_texture_format( GLuint mesa_format ) +static GLuint +translate_texture_format(GLuint mesa_format) { switch (mesa_format) { case MESA_FORMAT_L8: @@ -44,7 +45,7 @@ static GLuint translate_texture_format( GLuint mesa_format ) case MESA_FORMAT_I8: return MAPSURF_8BIT | MT_8BIT_I8; case MESA_FORMAT_A8: - return MAPSURF_8BIT | MT_8BIT_A8; + return MAPSURF_8BIT | MT_8BIT_A8; case MESA_FORMAT_AL88: return MAPSURF_16BIT | MT_16BIT_AY88; case MESA_FORMAT_RGB565: @@ -74,8 +75,7 @@ static GLuint translate_texture_format( GLuint mesa_format ) case MESA_FORMAT_Z24_S8: return (MAPSURF_32BIT | MT_32BIT_xL824); default: - fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, - mesa_format); + fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format); abort(); return 0; } @@ -88,20 +88,21 @@ static GLuint translate_texture_format( GLuint mesa_format ) * Intel drivers for "other operating systems" implement GL_CLAMP as * GL_CLAMP_TO_EDGE, so the same is done here. */ -static GLuint translate_wrap_mode( GLenum wrap ) +static GLuint +translate_wrap_mode(GLenum wrap) { - switch( wrap ) { - case GL_REPEAT: + switch (wrap) { + case GL_REPEAT: return TEXCOORDMODE_WRAP; - case GL_CLAMP: - return TEXCOORDMODE_CLAMP_EDGE; /* not quite correct */ - case GL_CLAMP_TO_EDGE: + case GL_CLAMP: + return TEXCOORDMODE_CLAMP_EDGE; /* not quite correct */ + case GL_CLAMP_TO_EDGE: return TEXCOORDMODE_CLAMP_EDGE; - case GL_CLAMP_TO_BORDER: + case GL_CLAMP_TO_BORDER: return TEXCOORDMODE_CLAMP_BORDER; - case GL_MIRRORED_REPEAT: + case GL_MIRRORED_REPEAT: return TEXCOORDMODE_MIRROR; - default: + default: return TEXCOORDMODE_WRAP; } } @@ -112,9 +113,8 @@ static GLuint translate_wrap_mode( GLenum wrap ) * efficient, but this has gotten complex enough that we need * something which is understandable and reliable. */ -static GLboolean i915_update_tex_unit( struct intel_context *intel, - GLuint unit, - GLuint ss3 ) +static GLboolean +i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) { GLcontext *ctx = &intel->ctx; struct i915_context *i915 = i915_context(ctx); @@ -128,7 +128,7 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, /* intel_region_release(intel, &i915->state.tex_region[unit]); */ if (!intel_finalize_mipmap_tree(intel, unit)) - return GL_FALSE; + return GL_FALSE; /* Get first image here, since intelObj->firstLevel will get set in * the intel_finalize_mipmap_tree() call above. @@ -140,20 +140,23 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, i915->state.tex_buffer[unit] = intelObj->mt->region->buffer; i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0, - intelObj->firstLevel); + intelObj-> + firstLevel); - state[I915_TEXREG_MS3] = + state[I915_TEXREG_MS3] = (((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) | ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | - translate_texture_format( firstImage->TexFormat->MesaFormat ) | + translate_texture_format(firstImage->TexFormat->MesaFormat) | MS3_USE_FENCE_REGS); - state[I915_TEXREG_MS4] = - (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) - 1) << MS4_PITCH_SHIFT) | - MS4_CUBE_FACE_ENA_MASK | - ((((intelObj->lastLevel - intelObj->firstLevel) * 4)) << MS4_MAX_LOD_SHIFT) | - ((firstImage->Depth - 1) << MS4_VOLUME_DEPTH_SHIFT)); + state[I915_TEXREG_MS4] = + (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) - + 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK | + ((((intelObj->lastLevel - + intelObj->firstLevel) * + 4)) << MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - + 1) << MS4_VOLUME_DEPTH_SHIFT)); { @@ -161,48 +164,48 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, switch (tObj->MinFilter) { case GL_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NONE; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NONE; + break; case GL_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NONE; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NONE; + break; case GL_NEAREST_MIPMAP_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NEAREST; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NEAREST; + break; case GL_LINEAR_MIPMAP_NEAREST: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NEAREST; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NEAREST; + break; case GL_NEAREST_MIPMAP_LINEAR: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_LINEAR; - break; + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_LINEAR; + break; case GL_LINEAR_MIPMAP_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_LINEAR; - break; + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_LINEAR; + break; default: - return GL_FALSE; + return GL_FALSE; } - if ( tObj->MaxAnisotropy > 1.0 ) { - minFilt = FILTER_ANISOTROPIC; - magFilt = FILTER_ANISOTROPIC; + if (tObj->MaxAnisotropy > 1.0) { + minFilt = FILTER_ANISOTROPIC; + magFilt = FILTER_ANISOTROPIC; } else { - switch (tObj->MagFilter) { - case GL_NEAREST: - magFilt = FILTER_NEAREST; - break; - case GL_LINEAR: - magFilt = FILTER_LINEAR; - break; - default: - return GL_FALSE; - } + switch (tObj->MagFilter) { + case GL_NEAREST: + magFilt = FILTER_NEAREST; + break; + case GL_LINEAR: + magFilt = FILTER_LINEAR; + break; + default: + return GL_FALSE; + } } state[I915_TEXREG_SS2] = i915->lodbias_ss2[unit]; @@ -210,32 +213,32 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, /* YUV conversion: */ if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR || - firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV) - state[I915_TEXREG_SS2] |= SS2_COLORSPACE_CONVERSION; + firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV) + state[I915_TEXREG_SS2] |= SS2_COLORSPACE_CONVERSION; /* Shadow: */ - if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB && - tObj->Target != GL_TEXTURE_3D) { + if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB && + tObj->Target != GL_TEXTURE_3D) { - state[I915_TEXREG_SS2] |= - (SS2_SHADOW_ENABLE | - intel_translate_compare_func( tObj->CompareFunc )); - - minFilt = FILTER_4X4_FLAT; - magFilt = FILTER_4X4_FLAT; + state[I915_TEXREG_SS2] |= + (SS2_SHADOW_ENABLE | + intel_translate_compare_func(tObj->CompareFunc)); + + minFilt = FILTER_4X4_FLAT; + magFilt = FILTER_4X4_FLAT; } state[I915_TEXREG_SS2] |= ((minFilt << SS2_MIN_FILTER_SHIFT) | - (mipFilt << SS2_MIP_FILTER_SHIFT) | - (magFilt << SS2_MAG_FILTER_SHIFT)); + (mipFilt << SS2_MIP_FILTER_SHIFT) | + (magFilt << SS2_MAG_FILTER_SHIFT)); } { GLenum ws = tObj->WrapS; GLenum wt = tObj->WrapT; GLenum wr = tObj->WrapR; - + /* 3D textures don't seem to respect the border color. * Fallback if there's ever a danger that they might refer to @@ -245,38 +248,38 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, * clamp_to_border. */ if (tObj->Target == GL_TEXTURE_3D && - (tObj->MinFilter != GL_NEAREST || - tObj->MagFilter != GL_NEAREST) && - (ws == GL_CLAMP || - wt == GL_CLAMP || - wr == GL_CLAMP || - ws == GL_CLAMP_TO_BORDER || - wt == GL_CLAMP_TO_BORDER || - wr == GL_CLAMP_TO_BORDER)) - return GL_FALSE; - + (tObj->MinFilter != GL_NEAREST || + tObj->MagFilter != GL_NEAREST) && + (ws == GL_CLAMP || + wt == GL_CLAMP || + wr == GL_CLAMP || + ws == GL_CLAMP_TO_BORDER || + wt == GL_CLAMP_TO_BORDER || wr == GL_CLAMP_TO_BORDER)) + return GL_FALSE; - state[I915_TEXREG_SS3] = ss3; /* SS3_NORMALIZED_COORDS */ - state[I915_TEXREG_SS3] |= ((translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT) | - (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) | - (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT)); + state[I915_TEXREG_SS3] = ss3; /* SS3_NORMALIZED_COORDS */ + + state[I915_TEXREG_SS3] |= + ((translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT) | + (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) | + (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT)); state[I915_TEXREG_SS3] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT); } state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0], - tObj->_BorderChan[1], - tObj->_BorderChan[2], - tObj->_BorderChan[3]); - + tObj->_BorderChan[1], + tObj->_BorderChan[2], + tObj->_BorderChan[3]); + I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(unit), GL_TRUE); /* memcmp was already disabled, but definitely won't work as the * region might now change and that wouldn't be detected: */ - I915_STATECHANGE( i915, I915_UPLOAD_TEX(unit) ); + I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit)); #if 0 @@ -294,36 +297,34 @@ static GLboolean i915_update_tex_unit( struct intel_context *intel, -void i915UpdateTextureState( struct intel_context *intel ) +void +i915UpdateTextureState(struct intel_context *intel) { GLboolean ok = GL_TRUE; GLuint i; - for (i = 0 ; i < I915_TEX_UNITS && ok ; i++) { + for (i = 0; i < I915_TEX_UNITS && ok; i++) { switch (intel->ctx.Texture.Unit[i]._ReallyEnabled) { case TEXTURE_1D_BIT: case TEXTURE_2D_BIT: case TEXTURE_CUBE_BIT: case TEXTURE_3D_BIT: - ok = i915_update_tex_unit( intel, i, SS3_NORMALIZED_COORDS ); - break; + ok = i915_update_tex_unit(intel, i, SS3_NORMALIZED_COORDS); + break; case TEXTURE_RECT_BIT: - ok = i915_update_tex_unit( intel, i, 0 ); - break; - case 0: { - struct i915_context *i915 = i915_context(&intel->ctx); - if (i915->state.active & I915_UPLOAD_TEX(i)) - I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(i), GL_FALSE); - break; - } + ok = i915_update_tex_unit(intel, i, 0); + break; + case 0:{ + struct i915_context *i915 = i915_context(&intel->ctx); + if (i915->state.active & I915_UPLOAD_TEX(i)) + I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(i), GL_FALSE); + break; + } default: - ok = GL_FALSE; - break; + ok = GL_FALSE; + break; } } - FALLBACK( intel, I915_FALLBACK_TEXTURE, !ok ); + FALLBACK(intel, I915_FALLBACK_TEXTURE, !ok); } - - - diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 3d914fb3fbb..c29875b502e 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -43,16 +43,17 @@ #include "i915_reg.h" #include "i915_context.h" -static void i915_render_start( struct intel_context *intel ) +static void +i915_render_start(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); - i915ValidateFragmentProgram( i915 ); + i915ValidateFragmentProgram(i915); } -static void i915_reduced_primitive_state( struct intel_context *intel, - GLenum rprim ) +static void +i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) { struct i915_context *i915 = i915_context(&intel->ctx); GLuint st1 = i915->state.Stipple[I915_STPREG_ST1]; @@ -61,9 +62,8 @@ static void i915_reduced_primitive_state( struct intel_context *intel, switch (rprim) { case GL_TRIANGLES: - if (intel->ctx.Polygon.StippleFlag && - intel->hw_stipple) - st1 |= ST1_ENABLE; + if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) + st1 |= ST1_ENABLE; break; case GL_LINES: case GL_POINTS: @@ -83,8 +83,8 @@ static void i915_reduced_primitive_state( struct intel_context *intel, /* Pull apart the vertex format registers and figure out how large a * vertex is supposed to be. */ -static GLboolean i915_check_vertex_size( struct intel_context *intel, - GLuint expected ) +static GLboolean +i915_check_vertex_size(struct intel_context *intel, GLuint expected) { struct i915_context *i915 = i915_context(&intel->ctx); int lis2 = i915->current->Ctx[I915_CTXREG_LIS2]; @@ -92,55 +92,81 @@ static GLboolean i915_check_vertex_size( struct intel_context *intel, int i, sz = 0; switch (lis4 & S4_VFMT_XYZW_MASK) { - case S4_VFMT_XY: sz = 2; break; - case S4_VFMT_XYZ: sz = 3; break; - case S4_VFMT_XYW: sz = 3; break; - case S4_VFMT_XYZW: sz = 4; break; - default: + case S4_VFMT_XY: + sz = 2; + break; + case S4_VFMT_XYZ: + sz = 3; + break; + case S4_VFMT_XYW: + sz = 3; + break; + case S4_VFMT_XYZW: + sz = 4; + break; + default: fprintf(stderr, "no xyzw specified\n"); return 0; } - if (lis4 & S4_VFMT_SPEC_FOG) sz++; - if (lis4 & S4_VFMT_COLOR) sz++; - if (lis4 & S4_VFMT_DEPTH_OFFSET) sz++; - if (lis4 & S4_VFMT_POINT_WIDTH) sz++; - if (lis4 & S4_VFMT_FOG_PARAM) sz++; - - for (i = 0 ; i < 8 ; i++) { + if (lis4 & S4_VFMT_SPEC_FOG) + sz++; + if (lis4 & S4_VFMT_COLOR) + sz++; + if (lis4 & S4_VFMT_DEPTH_OFFSET) + sz++; + if (lis4 & S4_VFMT_POINT_WIDTH) + sz++; + if (lis4 & S4_VFMT_FOG_PARAM) + sz++; + + for (i = 0; i < 8; i++) { switch (lis2 & S2_TEXCOORD_FMT0_MASK) { - case TEXCOORDFMT_2D: sz += 2; break; - case TEXCOORDFMT_3D: sz += 3; break; - case TEXCOORDFMT_4D: sz += 4; break; - case TEXCOORDFMT_1D: sz += 1; break; - case TEXCOORDFMT_2D_16: sz += 1; break; - case TEXCOORDFMT_4D_16: sz += 2; break; - case TEXCOORDFMT_NOT_PRESENT: break; + case TEXCOORDFMT_2D: + sz += 2; + break; + case TEXCOORDFMT_3D: + sz += 3; + break; + case TEXCOORDFMT_4D: + sz += 4; + break; + case TEXCOORDFMT_1D: + sz += 1; + break; + case TEXCOORDFMT_2D_16: + sz += 1; + break; + case TEXCOORDFMT_4D_16: + sz += 2; + break; + case TEXCOORDFMT_NOT_PRESENT: + break; default: - fprintf(stderr, "bad texcoord fmt %d\n", i); - return GL_FALSE; + fprintf(stderr, "bad texcoord fmt %d\n", i); + return GL_FALSE; } lis2 >>= S2_TEXCOORD_FMT1_SHIFT; } - - if (sz != expected) + + if (sz != expected) fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected); - + return sz == expected; } -static void i915_emit_invarient_state( struct intel_context *intel ) +static void +i915_emit_invarient_state(struct intel_context *intel) { BATCH_LOCALS; - BEGIN_BATCH( 200, 0 ); + BEGIN_BATCH(200, 0); OUT_BATCH(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | - AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | - AA_LINE_REGION_WIDTH_1_0); + AA_LINE_ECAAR_WIDTH_ENABLE | + AA_LINE_ECAAR_WIDTH_1_0 | + AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); OUT_BATCH(0); @@ -153,35 +179,27 @@ static void i915_emit_invarient_state( struct intel_context *intel ) /* Don't support texture crossbar yet */ OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS | - CSB_TCB(0, 0) | - CSB_TCB(1, 1) | - CSB_TCB(2, 2) | - CSB_TCB(3, 3) | - CSB_TCB(4, 4) | - CSB_TCB(5, 5) | - CSB_TCB(6, 6) | - CSB_TCB(7, 7)); + CSB_TCB(0, 0) | + CSB_TCB(1, 1) | + CSB_TCB(2, 2) | + CSB_TCB(3, 3) | + CSB_TCB(4, 4) | CSB_TCB(5, 5) | CSB_TCB(6, 6) | CSB_TCB(7, 7)); OUT_BATCH(_3DSTATE_RASTER_RULES_CMD | - ENABLE_POINT_RASTER_RULE | - OGL_POINT_RASTER_RULE | - ENABLE_LINE_STRIP_PROVOKE_VRTX | - ENABLE_TRI_FAN_PROVOKE_VRTX | - LINE_STRIP_PROVOKE_VRTX(1) | - TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_TEXKILL_3D_4D | - TEXKILL_4D); + ENABLE_POINT_RASTER_RULE | + OGL_POINT_RASTER_RULE | + ENABLE_LINE_STRIP_PROVOKE_VRTX | + ENABLE_TRI_FAN_PROVOKE_VRTX | + LINE_STRIP_PROVOKE_VRTX(1) | + TRI_FAN_PROVOKE_VRTX(2) | ENABLE_TEXKILL_3D_4D | TEXKILL_4D); /* Need to initialize this to zero. */ - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(3) | - (1)); + OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (1)); OUT_BATCH(0); - + /* XXX: Use this */ - OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD); OUT_BATCH(0); @@ -189,15 +207,13 @@ static void i915_emit_invarient_state( struct intel_context *intel ) OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE); - OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */ + OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */ OUT_BATCH(0); /* Don't support twosided stencil yet */ - OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | - BFO_ENABLE_STENCIL_TWO_SIDE | - 0 ); - + OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0); + ADVANCE_BATCH(); } @@ -205,7 +221,8 @@ static void i915_emit_invarient_state( struct intel_context *intel ) #define emit(intel, state, size ) \ intel_batchbuffer_data(intel->batch, state, size, 0 ) -static GLuint get_dirty( struct i915_hw_state *state ) +static GLuint +get_dirty(struct i915_hw_state *state) { GLuint dirty; @@ -216,12 +233,12 @@ static GLuint get_dirty( struct i915_hw_state *state ) if (dirty & I915_UPLOAD_TEX_ALL) state->emitted &= ~I915_UPLOAD_TEX_ALL; dirty = state->active & ~state->emitted; - return dirty; } -static GLuint get_state_size( struct i915_hw_state *state ) +static GLuint +get_state_size(struct i915_hw_state *state) { GLuint dirty = get_dirty(state); GLuint i; @@ -230,28 +247,28 @@ static GLuint get_state_size( struct i915_hw_state *state ) if (dirty & I915_UPLOAD_CTX) sz += sizeof(state->Ctx); - if (dirty & I915_UPLOAD_BUFFERS) + if (dirty & I915_UPLOAD_BUFFERS) sz += sizeof(state->Buffer); if (dirty & I915_UPLOAD_STIPPLE) sz += sizeof(state->Stipple); - if (dirty & I915_UPLOAD_FOG) + if (dirty & I915_UPLOAD_FOG) sz += sizeof(state->Fog); if (dirty & I915_UPLOAD_TEX_ALL) { int nr = 0; - for (i = 0; i < I915_TEX_UNITS; i++) - if (dirty & I915_UPLOAD_TEX(i)) - nr++; + for (i = 0; i < I915_TEX_UNITS; i++) + if (dirty & I915_UPLOAD_TEX(i)) + nr++; - sz += (2+nr*3) * sizeof(GLuint) * 2; + sz += (2 + nr * 3) * sizeof(GLuint) * 2; } - if (dirty & I915_UPLOAD_CONSTANTS) + if (dirty & I915_UPLOAD_CONSTANTS) sz += state->ConstantSize * sizeof(GLuint); - if (dirty & I915_UPLOAD_PROGRAM) + if (dirty & I915_UPLOAD_PROGRAM) sz += state->ProgramSize * sizeof(GLuint); return sz; @@ -260,7 +277,8 @@ static GLuint get_state_size( struct i915_hw_state *state ) /* Push the state into the sarea and/or texture memory. */ -static void i915_emit_state( struct intel_context *intel ) +static void +i915_emit_state(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); struct i915_hw_state *state = i915->current; @@ -275,35 +293,40 @@ static void i915_emit_state( struct intel_context *intel ) * scheduling is allowed, rather than assume that it is whenever a * batchbuffer fills up. */ - intel_batchbuffer_require_space(intel->batch, - get_state_size(state), - 0); + intel_batchbuffer_require_space(intel->batch, get_state_size(state), 0); - if (INTEL_DEBUG & DEBUG_STATE) + if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty); if (dirty & I915_UPLOAD_INVARIENT) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_INVARIENT:\n"); - i915_emit_invarient_state( intel ); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_INVARIENT:\n"); + i915_emit_invarient_state(intel); } if (dirty & I915_UPLOAD_CTX) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_CTX:\n"); - emit(intel, state->Ctx, sizeof(state->Ctx) ); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_CTX:\n"); + emit(intel, state->Ctx, sizeof(state->Ctx)); } if (dirty & I915_UPLOAD_BUFFERS) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_BUFFERS:\n"); - BEGIN_BATCH(I915_DEST_SETUP_SIZE+2, 0); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_BUFFERS:\n"); + BEGIN_BATCH(I915_DEST_SETUP_SIZE + 2, 0); OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]); OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]); - OUT_RELOC(state->draw_region->buffer, DRM_MM_TT|DRM_MM_WRITE, + OUT_RELOC(state->draw_region->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, state->draw_region->draw_offset); if (state->depth_region) { OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]); OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]); - OUT_RELOC(state->depth_region->buffer, DRM_MM_TT|DRM_MM_WRITE, + OUT_RELOC(state->depth_region->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, state->depth_region->draw_offset); } @@ -317,13 +340,15 @@ static void i915_emit_state( struct intel_context *intel ) } if (dirty & I915_UPLOAD_STIPPLE) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_STIPPLE:\n"); - emit(intel, state->Stipple, sizeof(state->Stipple) ); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_STIPPLE:\n"); + emit(intel, state->Stipple, sizeof(state->Stipple)); } if (dirty & I915_UPLOAD_FOG) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_FOG:\n"); - emit(intel, state->Fog, sizeof(state->Fog) ); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_FOG:\n"); + emit(intel, state->Fog, sizeof(state->Fog)); } /* Combine all the dirty texture state into a single command to @@ -332,63 +357,67 @@ static void i915_emit_state( struct intel_context *intel ) if (dirty & I915_UPLOAD_TEX_ALL) { int nr = 0; - for (i = 0; i < I915_TEX_UNITS; i++) - if (dirty & I915_UPLOAD_TEX(i)) - nr++; + for (i = 0; i < I915_TEX_UNITS; i++) + if (dirty & I915_UPLOAD_TEX(i)) + nr++; - BEGIN_BATCH(2+nr*3, 0); - OUT_BATCH(_3DSTATE_MAP_STATE | (3*nr)); + BEGIN_BATCH(2 + nr * 3, 0); + OUT_BATCH(_3DSTATE_MAP_STATE | (3 * nr)); OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT); - for (i = 0 ; i < I915_TEX_UNITS ; i++) - if (dirty & I915_UPLOAD_TEX(i)) { + for (i = 0; i < I915_TEX_UNITS; i++) + if (dirty & I915_UPLOAD_TEX(i)) { - if (state->tex_buffer[i]) { - OUT_RELOC(state->tex_buffer[i], - DRM_MM_TT|DRM_MM_READ, - state->tex_offset[i]); - } - else { - assert(i == 0); - assert(state == &i915->meta); - OUT_BATCH(0); - } + if (state->tex_buffer[i]) { + OUT_RELOC(state->tex_buffer[i], + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, + state->tex_offset[i]); + } + else { + assert(i == 0); + assert(state == &i915->meta); + OUT_BATCH(0); + } - OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]); - OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]); - } + OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]); + OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]); + } ADVANCE_BATCH(); - BEGIN_BATCH(2+nr*3, 0); - OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3*nr)); + BEGIN_BATCH(2 + nr * 3, 0); + OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * nr)); OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT); - for (i = 0 ; i < I915_TEX_UNITS ; i++) - if (dirty & I915_UPLOAD_TEX(i)) { - OUT_BATCH(state->Tex[i][I915_TEXREG_SS2]); - OUT_BATCH(state->Tex[i][I915_TEXREG_SS3]); - OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]); - } + for (i = 0; i < I915_TEX_UNITS; i++) + if (dirty & I915_UPLOAD_TEX(i)) { + OUT_BATCH(state->Tex[i][I915_TEXREG_SS2]); + OUT_BATCH(state->Tex[i][I915_TEXREG_SS3]); + OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]); + } ADVANCE_BATCH(); } if (dirty & I915_UPLOAD_CONSTANTS) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n"); - emit(intel, state->Constant, state->ConstantSize * sizeof(GLuint) ); + if (INTEL_DEBUG & DEBUG_STATE) + fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n"); + emit(intel, state->Constant, state->ConstantSize * sizeof(GLuint)); } if (dirty & I915_UPLOAD_PROGRAM) { - if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "I915_UPLOAD_PROGRAM:\n"); - - assert((state->Program[0] & 0x1ff)+2 == state->ProgramSize); - - emit(intel, state->Program, state->ProgramSize * sizeof(GLuint) ); if (INTEL_DEBUG & DEBUG_STATE) - i915_disassemble_program( state->Program, state->ProgramSize ); + fprintf(stderr, "I915_UPLOAD_PROGRAM:\n"); + + assert((state->Program[0] & 0x1ff) + 2 == state->ProgramSize); + + emit(intel, state->Program, state->ProgramSize * sizeof(GLuint)); + if (INTEL_DEBUG & DEBUG_STATE) + i915_disassemble_program(state->Program, state->ProgramSize); } state->emitted |= dirty; } -static void i915_destroy_context( struct intel_context *intel ) +static void +i915_destroy_context(struct intel_context *intel) { _tnl_free_vertices(&intel->ctx); } @@ -401,7 +430,7 @@ static void i915_destroy_context( struct intel_context *intel ) * Used for setting both regular and meta state. */ void -i915_state_draw_region(struct intel_context *intel, +i915_state_draw_region(struct intel_context *intel, struct i915_hw_state *state, struct intel_region *color_region, struct intel_region *depth_region) @@ -425,27 +454,26 @@ i915_state_draw_region(struct intel_context *intel, */ if (color_region) { state->Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - state->Buffer[I915_DESTREG_CBUFADDR1] = - (BUF_3D_ID_COLOR_BACK | + state->Buffer[I915_DESTREG_CBUFADDR1] = + (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(color_region->pitch * color_region->cpp) | BUF_3D_USE_FENCE); } if (depth_region) { state->Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD; - state->Buffer[I915_DESTREG_DBUFADDR1] = - (BUF_3D_ID_DEPTH | - BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) | - BUF_3D_USE_FENCE); + state->Buffer[I915_DESTREG_DBUFADDR1] = + (BUF_3D_ID_DEPTH | + BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) | + BUF_3D_USE_FENCE); } /* * Compute/set I915_DESTREG_DV1 value */ - value = (DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL); + value = (DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL); if (color_region && color_region->cpp == 4) { value |= DV_PF_8888; } @@ -460,12 +488,12 @@ i915_state_draw_region(struct intel_context *intel, } state->Buffer[I915_DESTREG_DV1] = value; - I915_STATECHANGE( i915, I915_UPLOAD_BUFFERS ); + I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); } static void -i915_set_draw_region(struct intel_context *intel, +i915_set_draw_region(struct intel_context *intel, struct intel_region *color_region, struct intel_region *depth_region) { @@ -475,19 +503,22 @@ i915_set_draw_region(struct intel_context *intel, -static void i915_lost_hardware( struct intel_context *intel ) +static void +i915_lost_hardware(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); i915->state.emitted = 0; } -static GLuint i915_flush_cmd( void ) +static GLuint +i915_flush_cmd(void) { return MI_FLUSH | FLUSH_MAP_CACHE; } -void i915InitVtbl( struct i915_context *i915 ) +void +i915InitVtbl(struct i915_context *i915) { i915->intel.vtbl.check_vertex_size = i915_check_vertex_size; i915->intel.vtbl.destroy = i915_destroy_context; @@ -499,4 +530,3 @@ void i915InitVtbl( struct i915_context *i915 ) i915->intel.vtbl.update_texture_state = i915UpdateTextureState; i915->intel.vtbl.flush_cmd = i915_flush_cmd; } - diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/src/mesa/drivers/dri/i915/intel_batchbuffer.c index 5997a63cad8..f7636c4bcd3 100644 --- a/src/mesa/drivers/dri/i915/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915/intel_batchbuffer.c @@ -27,7 +27,6 @@ #include "intel_batchbuffer.h" #include "intel_ioctl.h" -#include "intel_bufmgr.h" /* Relocations in kernel space: * - pass dma buffer seperately @@ -65,160 +64,222 @@ * Applies to: Blit operations, metaops, X server operations -- X * server automatically waits on its own dma to complete before * modifying cliprects ??? - */ + */ -static void intel_dump_batchbuffer( GLuint offset, - GLuint *ptr, - GLuint count ) +static void +intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count) { int i; - fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count/4); - for (i = 0; i < count/4; i += 4) - fprintf(stderr, "0x%x:\t0x%08x 0x%08x 0x%08x 0x%08x\n", - offset + i*4, ptr[i], ptr[i+1], ptr[i+2], ptr[i+3]); + fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4); + for (i = 0; i < count / 4; i += 4) + fprintf(stderr, "0x%x:\t0x%08x 0x%08x 0x%08x 0x%08x\n", + offset + i * 4, ptr[i], ptr[i + 1], ptr[i + 2], ptr[i + 3]); fprintf(stderr, "END BATCH\n\n\n"); } - -void intel_batchbuffer_reset( struct intel_batchbuffer *batch ) +void +dbatch(struct intel_context *intel) { - bmBufferData(batch->intel, - batch->buffer, - BATCH_SZ, - NULL, - 0); - - if (!batch->list) - batch->list = bmNewBufferList(); + intel_dump_batchbuffer(0, intel->batch->map, + intel->batch->ptr - intel->batch->map); +} + +void +intel_batchbuffer_reset(struct intel_batchbuffer *batch) +{ + + int i; + /* + * Get a new, free batchbuffer. + */ + + driBOData(batch->buffer, BATCH_SZ, NULL, 0); + + driBOResetList(&batch->list); + + /* + * Unreference buffers previously on the relocation list. + */ + + for (i = 0; i < batch->nr_relocs; i++) { + struct buffer_reloc *r = &batch->reloc[i]; + driBOUnReference(r->buf); + } - drmMMClearBufList(batch->list); batch->list_count = 0; batch->nr_relocs = 0; batch->flags = 0; - bmAddBuffer( batch->intel, - batch->list, - batch->buffer, - DRM_MM_TT, - NULL, - &batch->offset[batch->list_count++]); + /* + * We don't refcount the batchbuffer itself since we can't destroy it + * while it's on the list. + */ - batch->map = bmMapBuffer(batch->intel, batch->buffer, DRM_MM_WRITE); + + driBOAddListItem(&batch->list, batch->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE); + + + batch->map = driBOMap(batch->buffer, DRM_BO_FLAG_WRITE, 0); batch->ptr = batch->map; } /*====================================================================== * Public functions */ -struct intel_batchbuffer *intel_batchbuffer_alloc( struct intel_context *intel ) +struct intel_batchbuffer * +intel_batchbuffer_alloc(struct intel_context *intel) { struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1); batch->intel = intel; - bmGenBuffers(intel, "batchbuffer", 1, &batch->buffer, BM_BATCHBUFFER); - batch->last_fence = bmInitFence(batch->intel); - intel_batchbuffer_reset( batch ); + driGenBuffers(intel->intelScreen->batchPool, "batchbuffer", 1, + &batch->buffer, 4096, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, 0); + batch->last_fence = NULL; + driBOCreateList(20, &batch->list); + intel_batchbuffer_reset(batch); return batch; } -void intel_batchbuffer_free( struct intel_batchbuffer *batch ) +void +intel_batchbuffer_free(struct intel_batchbuffer *batch) { - if (batch->map) - bmUnmapBuffer(batch->intel, batch->buffer); - + if (batch->map) { + driBOUnmap(batch->buffer); + batch->map = NULL; + } + driBOUnReference(batch->buffer); + batch->buffer = NULL; free(batch); } /* TODO: Push this whole function into bufmgr. */ -static void do_flush_locked( struct intel_batchbuffer *batch, - GLuint used, - GLboolean ignore_cliprects, - GLboolean allow_unlock) +static void +do_flush_locked(struct intel_batchbuffer *batch, + GLuint used, + GLboolean ignore_cliprects, GLboolean allow_unlock) { GLuint *ptr; GLuint i; + struct intel_context *intel = batch->intel; - bmValidateBufferList( batch->intel, - batch->list, - DRM_MM_TT ); + driBOValidateList(batch->intel->driFd, &batch->list); /* Apply the relocations. This nasty map indicates to me that the * whole task should be done internally by the memory manager, and * that dma buffers probably need to be pinned within agp space. */ - ptr = (GLuint *)bmMapBuffer(batch->intel, batch->buffer, DRM_MM_WRITE); + ptr = (GLuint *) driBOMap(batch->buffer, DRM_BO_FLAG_WRITE, + DRM_BO_HINT_ALLOW_UNFENCED_MAP); + - for (i = 0; i < batch->nr_relocs; i++) { struct buffer_reloc *r = &batch->reloc[i]; - - assert(r->elem < batch->list_count); - ptr[r->offset/4] = batch->offset[r->elem] + r->delta; + + ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta; } if (INTEL_DEBUG & DEBUG_BATCH) - intel_dump_batchbuffer( 0, ptr, used ); + intel_dump_batchbuffer(0, ptr, used); + + driBOUnmap(batch->buffer); + batch->map = NULL; - bmUnmapBuffer(batch->intel, batch->buffer); - /* Fire the batch buffer, which was uploaded above: */ - intel_batch_ioctl(batch->intel, - batch->offset[0], - used, - ignore_cliprects, - allow_unlock); - batch->last_fence = bmFenceBufferList(batch->intel, batch->list); - if (!batch->intel->last_swap_fence_retired) { - int retired; - drmFence dFence = {0,batch->intel->last_swap_fence}; - - /*FIXME: Temporary fix for fence ageing - * - */ - if (!drmTestFence(batch->intel->driFd, dFence, 0, &retired)) { - batch->intel->last_swap_fence_retired = retired; +#if 0 + { + void *iterator = drmBOListIterator(&batch->list); + + _mesa_printf("\n"); + while (iterator != NULL) { + _mesa_printf("0x%08x\n", drmBOListBuf(iterator)->offset); + iterator = drmBOListNext(&batch->list, iterator); } - } + _mesa_printf("Submitting 0x%08x\n", driBOOffset(batch->buffer)); + + } +#endif + + /* Throw away non-effective packets. Won't work once we have + * hardware contexts which would preserve statechanges beyond a + * single buffer. + */ + + if (!(intel->numClipRects == 0 && !ignore_cliprects)) { + intel_batch_ioctl(batch->intel, + driBOOffset(batch->buffer), + used, ignore_cliprects, allow_unlock); + } + + driFenceUnReference(batch->last_fence); + + /* + * Kernel fencing. + */ + + + batch->last_fence = driFenceBuffers(batch->intel->driFd, + "Batch fence", GL_FALSE); + + /* + * User space fencing. + */ + + driBOFence(batch->buffer, batch->last_fence); + for (i = 0; i < batch->nr_relocs; i++) { + struct buffer_reloc *r = &batch->reloc[i]; + driBOFence(r->buf, batch->last_fence); + } + + if (intel->numClipRects == 0 && !ignore_cliprects) { + if (allow_unlock) { + UNLOCK_HARDWARE(intel); + sched_yield(); + LOCK_HARDWARE(intel); + } + intel->vtbl.lost_hardware(intel); + } } - -GLuint intel_batchbuffer_flush( struct intel_batchbuffer *batch ) +struct _DriFenceObject * +intel_batchbuffer_flush(struct intel_batchbuffer *batch) { struct intel_context *intel = batch->intel; GLuint used = batch->ptr - batch->map; - if (used == 0) + if (used == 0) return batch->last_fence; /* Add the MI_BATCH_BUFFER_END. Always add an MI_FLUSH - this is a * performance drain that we would like to avoid. */ if (used & 4) { - ((int *)batch->ptr)[0] = intel->vtbl.flush_cmd(); - ((int *)batch->ptr)[1] = 0; - ((int *)batch->ptr)[2] = MI_BATCH_BUFFER_END; + ((int *) batch->ptr)[0] = 0; /*intel->vtbl.flush_cmd(); */ + ((int *) batch->ptr)[1] = 0; + ((int *) batch->ptr)[2] = MI_BATCH_BUFFER_END; used += 12; } else { - ((int *)batch->ptr)[0] = intel->vtbl.flush_cmd() ; - ((int *)batch->ptr)[1] = MI_BATCH_BUFFER_END; + ((int *) batch->ptr)[0] = 0; /*intel->vtbl.flush_cmd(); */ + ((int *) batch->ptr)[1] = MI_BATCH_BUFFER_END; used += 8; } - bmUnmapBuffer(batch->intel, batch->buffer); + driBOUnmap(batch->buffer); batch->ptr = NULL; batch->map = NULL; /* TODO: Just pass the relocation list and dma buffer up to the * kernel. */ - if (!intel->locked) - { + if (!intel->locked) { assert(!(batch->flags & INTEL_BATCH_NO_CLIPRECTS)); LOCK_HARDWARE(intel); @@ -232,44 +293,37 @@ GLuint intel_batchbuffer_flush( struct intel_batchbuffer *batch ) /* Reset the buffer: */ - intel_batchbuffer_reset( batch ); + intel_batchbuffer_reset(batch); return batch->last_fence; } -void intel_batchbuffer_finish( struct intel_batchbuffer *batch ) -{ - bmFinishFence(batch->intel, - intel_batchbuffer_flush(batch)); +void +intel_batchbuffer_finish(struct intel_batchbuffer *batch) +{ + struct _DriFenceObject *fence = intel_batchbuffer_flush(batch); + driFenceReference(fence); + driFenceFinish(fence, 3, GL_FALSE); + driFenceUnReference(fence); } - + /* This is the only way buffers get added to the validate list. */ -GLboolean intel_batchbuffer_emit_reloc( struct intel_batchbuffer *batch, - struct buffer *buffer, - GLuint flags, - GLuint delta ) +GLboolean +intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch, + struct _DriBufferObject *buffer, + GLuint flags, GLuint mask, GLuint delta) { - GLuint i; - assert(batch->nr_relocs <= MAX_RELOCS); - i = bmScanBufferList(batch->intel, batch->list, buffer); - if (i == -1) { - i = batch->list_count; - bmAddBuffer(batch->intel, - batch->list, - buffer, - flags, - NULL, - &batch->offset[batch->list_count++]); - } + driBOAddListItem(&batch->list, buffer, flags, mask); { struct buffer_reloc *r = &batch->reloc[batch->nr_relocs++]; + driBOReference(buffer); + r->buf = buffer; r->offset = batch->ptr - batch->map; r->delta = delta; - r->elem = i; } batch->ptr += 4; @@ -278,14 +332,12 @@ GLboolean intel_batchbuffer_emit_reloc( struct intel_batchbuffer *batch, -void intel_batchbuffer_data(struct intel_batchbuffer *batch, - const void *data, - GLuint bytes, - GLuint flags) +void +intel_batchbuffer_data(struct intel_batchbuffer *batch, + const void *data, GLuint bytes, GLuint flags) { assert((bytes & 3) == 0); intel_batchbuffer_require_space(batch, bytes, flags); __memcpy(batch->ptr, data, bytes); batch->ptr += bytes; } - diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.h b/src/mesa/drivers/dri/i915/intel_batchbuffer.h index ab09335b5e7..7bfef2d4832 100644 --- a/src/mesa/drivers/dri/i915/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915/intel_batchbuffer.h @@ -2,7 +2,7 @@ #define INTEL_BATCHBUFFER_H #include "mtypes.h" -#include "intel_bufmgr.h" +#include "dri_bufmgr.h" struct intel_context; @@ -14,42 +14,43 @@ struct intel_context; #define INTEL_BATCH_NO_CLIPRECTS 0x1 #define INTEL_BATCH_CLIPRECTS 0x2 -struct buffer_reloc { +struct buffer_reloc +{ + struct _DriBufferObject *buf; GLuint offset; - GLuint elem; /* elem in buffer list, not buffer id */ - GLuint delta; /* not needed? */ + GLuint delta; /* not needed? */ }; -struct intel_batchbuffer { +struct intel_batchbuffer +{ struct bufmgr *bm; struct intel_context *intel; - struct buffer *buffer; - GLuint last_fence; + struct _DriBufferObject *buffer; + struct _DriFenceObject *last_fence; GLuint flags; - /* In progress: - */ - unsigned long offset[MAX_RELOCS]; - struct _drmMMBufList *list; + drmBOList list; GLuint list_count; GLubyte *map; - GLubyte *ptr; + GLubyte *ptr; struct buffer_reloc reloc[MAX_RELOCS]; GLuint nr_relocs; }; -struct intel_batchbuffer *intel_batchbuffer_alloc( struct intel_context *intel ); +struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context + *intel); -void intel_batchbuffer_free( struct intel_batchbuffer *batch ); +void intel_batchbuffer_free(struct intel_batchbuffer *batch); -void intel_batchbuffer_finish( struct intel_batchbuffer *batch ); +void intel_batchbuffer_finish(struct intel_batchbuffer *batch); -GLuint intel_batchbuffer_flush( struct intel_batchbuffer *batch ); +struct _DriFenceObject *intel_batchbuffer_flush(struct intel_batchbuffer + *batch); -void intel_batchbuffer_reset( struct intel_batchbuffer *batch ); +void intel_batchbuffer_reset(struct intel_batchbuffer *batch); /* Unlike bmBufferData, this currently requires the buffer be mapped. @@ -57,56 +58,52 @@ void intel_batchbuffer_reset( struct intel_batchbuffer *batch ); * intel_buffer_dword() calls. */ void intel_batchbuffer_data(struct intel_batchbuffer *batch, - const void *data, - GLuint bytes, - GLuint flags); + const void *data, GLuint bytes, GLuint flags); void intel_batchbuffer_release_space(struct intel_batchbuffer *batch, - GLuint bytes); + GLuint bytes); -GLboolean intel_batchbuffer_emit_reloc( struct intel_batchbuffer *batch, - struct buffer *buffer, - GLuint flags, - GLuint offset ); +GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch, + struct _DriBufferObject *buffer, + GLuint flags, + GLuint mask, GLuint offset); /* Inline functions - might actually be better off with these * non-inlined. Certainly better off switching all command packets to * be passed as structs rather than dwords, but that's a little bit of * work... */ -static INLINE GLuint -intel_batchbuffer_space( struct intel_batchbuffer *batch ) +static INLINE GLuint +intel_batchbuffer_space(struct intel_batchbuffer *batch) { return (BATCH_SZ - BATCH_RESERVED) - (batch->ptr - batch->map); } -static INLINE void -intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, - GLuint dword) +static INLINE void +intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, GLuint dword) { assert(batch->map); assert(intel_batchbuffer_space(batch) >= 4); - *(GLuint *)(batch->ptr) = dword; + *(GLuint *) (batch->ptr) = dword; batch->ptr += 4; } -static INLINE void +static INLINE void intel_batchbuffer_require_space(struct intel_batchbuffer *batch, - GLuint sz, - GLuint flags) + GLuint sz, GLuint flags) { assert(sz < BATCH_SZ - 8); if (intel_batchbuffer_space(batch) < sz || (batch->flags != 0 && flags != 0 && batch->flags != flags)) intel_batchbuffer_flush(batch); - + batch->flags |= flags; } /* Here are the crusty old macros, to be removed: */ -#define BATCH_LOCALS +#define BATCH_LOCALS #define BEGIN_BATCH(n, flags) do { \ assert(!intel->prim.flush); \ @@ -115,9 +112,9 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch, #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d) -#define OUT_RELOC(buf,flags,delta) do { \ +#define OUT_RELOC(buf,flags,mask,delta) do { \ assert((delta) >= 0); \ - intel_batchbuffer_emit_reloc(intel->batch, buf, flags, delta); \ + intel_batchbuffer_emit_reloc(intel->batch, buf, flags, mask, delta); \ } while (0) #define ADVANCE_BATCH() do { } while(0) diff --git a/src/mesa/drivers/dri/i915/intel_batchpool.c b/src/mesa/drivers/dri/i915/intel_batchpool.c new file mode 100644 index 00000000000..5c69c1b8e12 --- /dev/null +++ b/src/mesa/drivers/dri/i915/intel_batchpool.c @@ -0,0 +1,406 @@ +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström + */ + +#include +#include +#include +#include "imports.h" +#include "glthread.h" +#include "dri_bufpool.h" +#include "dri_bufmgr.h" + +typedef struct +{ + drmMMListHead head; + struct _BPool *parent; + struct _DriFenceObject *fence; + unsigned long start; + int unfenced; + int mapped; +} BBuf; + +typedef struct _BPool +{ + _glthread_Mutex mutex; + unsigned long bufSize; + unsigned poolSize; + unsigned numFree; + unsigned numTot; + unsigned numDelayed; + unsigned checkDelayed; + drmMMListHead free; + drmMMListHead delayed; + drmMMListHead head; + drmBO kernelBO; + void *virtual; + BBuf *bufs; +} BPool; + + +static BPool * +createBPool(int fd, unsigned long bufSize, unsigned numBufs, unsigned flags, + unsigned checkDelayed) +{ + BPool *p = (BPool *) malloc(sizeof(*p)); + BBuf *buf; + int i; + + if (!p) + return NULL; + + p->bufs = (BBuf *) malloc(numBufs * sizeof(*p->bufs)); + if (!p->bufs) { + free(p); + return NULL; + } + + DRMINITLISTHEAD(&p->free); + DRMINITLISTHEAD(&p->head); + DRMINITLISTHEAD(&p->delayed); + + p->numTot = numBufs; + p->numFree = numBufs; + p->bufSize = bufSize; + p->numDelayed = 0; + p->checkDelayed = checkDelayed; + + _glthread_INIT_MUTEX(p->mutex); + + if (drmBOCreate(fd, NULL, 0, numBufs * bufSize, NULL, drm_bo_type_dc, + flags, 0, &p->kernelBO)) { + free(p->bufs); + free(p); + return NULL; + } + if (drmBOMap(fd, &p->kernelBO, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, + &p->virtual)) { + drmBODestroy(fd, &p->kernelBO); + free(p->bufs); + free(p); + return NULL; + } + + /* + * We unmap the buffer so that we can validate it later. Note that this is + * just a synchronizing operation. The buffer will have a virtual mapping + * until it is destroyed. + */ + + drmBOUnmap(fd, &p->kernelBO); + + buf = p->bufs; + for (i = 0; i < numBufs; ++i) { + buf->parent = p; + buf->fence = NULL; + buf->start = i * bufSize; + buf->mapped = 0; + buf->unfenced = 0; + DRMLISTADDTAIL(&buf->head, &p->free); + buf++; + } + + return p; +} + + +static void +pool_checkFree(BPool * p, int wait) +{ + drmMMListHead *list, *prev; + BBuf *buf; + int signaled = 0; + int i; + + list = p->delayed.next; + + if (p->numDelayed > 3) { + for (i = 0; i < p->numDelayed; i += 3) { + list = list->next; + } + } + + prev = list->prev; + for (; list != &p->delayed; list = prev, prev = list->prev) { + + buf = DRMLISTENTRY(BBuf, list, head); + + if (!signaled) { + if (wait) { + driFenceFinish(buf->fence, DRM_FENCE_EXE, 1); + signaled = 1; + } + else { + signaled = driFenceSignaled(buf->fence, DRM_FENCE_EXE); + } + } + + if (!signaled) + break; + + driFenceUnReference(buf->fence); + buf->fence = NULL; + DRMLISTDEL(list); + p->numDelayed--; + DRMLISTADD(list, &p->free); + p->numFree++; + } +} + +static void * +pool_create(struct _DriBufferPool *pool, + unsigned long size, unsigned flags, unsigned hint, + unsigned alignment) +{ + BPool *p = (BPool *) pool->data; + + drmMMListHead *item; + + if (alignment && (alignment != 4096)) + return NULL; + + _glthread_LOCK_MUTEX(p->mutex); + + if (p->numFree == 0) + pool_checkFree(p, GL_TRUE); + + if (p->numFree == 0) { + fprintf(stderr, "Out of fixed size buffer objects\n"); + BM_CKFATAL(-ENOMEM); + } + + item = p->free.next; + + if (item == &p->free) { + fprintf(stderr, "Fixed size buffer pool corruption\n"); + } + + DRMLISTDEL(item); + --p->numFree; + + _glthread_UNLOCK_MUTEX(p->mutex); + return (void *) DRMLISTENTRY(BBuf, item, head); +} + + +static int +pool_destroy(struct _DriBufferPool *pool, void *private) +{ + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + + _glthread_LOCK_MUTEX(p->mutex); + + if (buf->fence) { + DRMLISTADDTAIL(&buf->head, &p->delayed); + p->numDelayed++; + } + else { + buf->unfenced = 0; + DRMLISTADD(&buf->head, &p->free); + p->numFree++; + } + + if ((p->numDelayed % p->checkDelayed) == 0) + pool_checkFree(p, 0); + + _glthread_UNLOCK_MUTEX(p->mutex); + return 0; +} + + +static int +pool_map(struct _DriBufferPool *pool, void *private, unsigned flags, + int hint, void **virtual) +{ + + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + + _glthread_LOCK_MUTEX(p->mutex); + + /* + * Currently Mesa doesn't have any condition variables to resolve this + * cleanly in a multithreading environment. + * We bail out instead. + */ + + if (buf->mapped) { + fprintf(stderr, "Trying to map already mapped buffer object\n"); + BM_CKFATAL(-EINVAL); + } + +#if 0 + if (buf->unfenced && !(hint & DRM_BO_HINT_ALLOW_UNFENCED_MAP)) { + fprintf(stderr, "Trying to map an unfenced buffer object 0x%08x" + " 0x%08x %d\n", hint, flags, buf->start); + BM_CKFATAL(-EINVAL); + } + +#endif + + if (buf->fence) { + _glthread_UNLOCK_MUTEX(p->mutex); + return -EBUSY; + } + + buf->mapped = GL_TRUE; + *virtual = (unsigned char *) p->virtual + buf->start; + _glthread_UNLOCK_MUTEX(p->mutex); + return 0; +} + +static int +pool_unmap(struct _DriBufferPool *pool, void *private) +{ + BBuf *buf = (BBuf *) private; + + buf->mapped = 0; + return 0; +} + +static unsigned long +pool_offset(struct _DriBufferPool *pool, void *private) +{ + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + + return p->kernelBO.offset + buf->start; +} + +static unsigned +pool_flags(struct _DriBufferPool *pool, void *private) +{ + BPool *p = (BPool *) pool->data; + + return p->kernelBO.flags; +} + +static unsigned long +pool_size(struct _DriBufferPool *pool, void *private) +{ + BPool *p = (BPool *) pool->data; + + return p->bufSize; +} + + +static int +pool_fence(struct _DriBufferPool *pool, void *private, + struct _DriFenceObject *fence) +{ + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + + _glthread_LOCK_MUTEX(p->mutex); + if (buf->fence) { + driFenceUnReference(buf->fence); + } + buf->fence = fence; + buf->unfenced = 0; + driFenceReference(buf->fence); + _glthread_UNLOCK_MUTEX(p->mutex); + + return 0; +} + +static drmBO * +pool_kernel(struct _DriBufferPool *pool, void *private) +{ + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + + return &p->kernelBO; +} + +static int +pool_validate(struct _DriBufferPool *pool, void *private) +{ + BBuf *buf = (BBuf *) private; + BPool *p = buf->parent; + _glthread_LOCK_MUTEX(p->mutex); + buf->unfenced = GL_TRUE; + _glthread_UNLOCK_MUTEX(p->mutex); + return 0; +} + +static void +pool_takedown(struct _DriBufferPool *pool) +{ + BPool *p = (BPool *) pool->data; + + /* + * Wait on outstanding fences. + */ + + _glthread_LOCK_MUTEX(p->mutex); + while (p->numFree < p->numTot) { + _glthread_UNLOCK_MUTEX(p->mutex); + sched_yield(); + pool_checkFree(p, GL_TRUE); + _glthread_LOCK_MUTEX(p->mutex); + } + + drmBODestroy(pool->fd, &p->kernelBO); + free(p->bufs); + _glthread_UNLOCK_MUTEX(p->mutex); + free(p); + free(pool); +} + + +struct _DriBufferPool * +driBatchPoolInit(int fd, unsigned flags, + unsigned long bufSize, + unsigned numBufs, unsigned checkDelayed) +{ + struct _DriBufferPool *pool; + + pool = (struct _DriBufferPool *) malloc(sizeof(*pool)); + if (!pool) + return NULL; + + pool->data = createBPool(fd, bufSize, numBufs, flags, checkDelayed); + + pool->fd = fd; + pool->map = &pool_map; + pool->unmap = &pool_unmap; + pool->destroy = &pool_destroy; + pool->offset = &pool_offset; + pool->flags = &pool_flags; + pool->size = &pool_size; + pool->create = &pool_create; + pool->fence = &pool_fence; + pool->kernel = &pool_kernel; + pool->validate = &pool_validate; + pool->setstatic = NULL; + pool->takeDown = &pool_takedown; + return pool; +} diff --git a/src/mesa/drivers/dri/i915/intel_blit.c b/src/mesa/drivers/dri/i915/intel_blit.c index 5cbbea1005e..22c8fe1543d 100644 --- a/src/mesa/drivers/dri/i915/intel_blit.c +++ b/src/mesa/drivers/dri/i915/intel_blit.c @@ -41,20 +41,19 @@ #include "intel_reg.h" #include "intel_regions.h" -#include "intel_bufmgr.h" - #define FILE_DEBUG_FLAG DEBUG_BLIT /** * Copy the back color buffer to the front color buffer. * Used for SwapBuffers(). */ -void intelCopyBuffer( const __DRIdrawablePrivate *dPriv, - const drm_clip_rect_t *rect ) +void +intelCopyBuffer(const __DRIdrawablePrivate * dPriv, + const drm_clip_rect_t * rect) { GET_CURRENT_CONTEXT(ctx); struct intel_context *intel; - GLboolean missed_target; + GLboolean missed_target; int64_t ust; DBG("%s\n", __FUNCTION__); @@ -70,30 +69,26 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv, return; } intel = (struct intel_context *) ctx; - - /* FIXME: Temporary fix for fence ageing. - * - */ - - if (!intel->last_swap_fence_retired) { - bmFinishFence(intel, intel->last_swap_fence); + if (intel->last_swap_fence) { + driFenceFinish(intel->last_swap_fence, DRM_FENCE_EXE, GL_TRUE); + driFenceUnReference(intel->last_swap_fence); + intel->last_swap_fence = NULL; } + intel->last_swap_fence = intel->first_swap_fence; + intel->first_swap_fence = NULL; - - if (!rect) - { - driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target ); + if (!rect) { + driWaitForVBlank(dPriv, &intel->vbl_seq, intel->vblank_flags, + &missed_target); } /* The LOCK_HARDWARE is required for the cliprects. Buffer offsets * should work regardless. */ - LOCK_HARDWARE( intel ); + LOCK_HARDWARE(intel); - if (intel->driDrawable && - intel->driDrawable->numClipRects) - { + if (intel->driDrawable && intel->driDrawable->numClipRects) { const intelScreenPrivate *intelScreen = intel->intelScreen; struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; @@ -109,151 +104,156 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv, int i; ASSERT(fb); - ASSERT(fb->Name == 0); /* Not a user-created FBO */ + ASSERT(fb->Name == 0); /* Not a user-created FBO */ ASSERT(frontRegion); ASSERT(backRegion); ASSERT(frontRegion->pitch == backRegion->pitch); ASSERT(frontRegion->cpp == backRegion->cpp); if (cpp == 2) { - BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24); - CMD = XY_SRC_COPY_BLT_CMD; - } + BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24); + CMD = XY_SRC_COPY_BLT_CMD; + } else { - BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24) | (1<<25); - CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB); + BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25); + CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); } - for (i = 0 ; i < nbox; i++, pbox++) - { - drm_clip_rect_t box; + for (i = 0; i < nbox; i++, pbox++) { + drm_clip_rect_t box; - if (pbox->x1 > pbox->x2 || - pbox->y1 > pbox->y2 || - pbox->x2 > intelScreen->width || - pbox->y2 > intelScreen->height) - continue; - - box = *pbox; + if (pbox->x1 > pbox->x2 || + pbox->y1 > pbox->y2 || + pbox->x2 > intelScreen->width || pbox->y2 > intelScreen->height) + continue; - if (rect) - { - if (rect->x1 > box.x1) - box.x1 = rect->x1; - if (rect->y1 > box.y1) - box.y1 = rect->y1; - if (rect->x2 < box.x2) - box.x2 = rect->x2; - if (rect->y2 < box.y2) - box.y2 = rect->y2; + box = *pbox; - if (box.x1 > box.x2 || box.y1 > box.y2) - continue; - } + if (rect) { + if (rect->x1 > box.x1) + box.x1 = rect->x1; + if (rect->y1 > box.y1) + box.y1 = rect->y1; + if (rect->x2 < box.x2) + box.x2 = rect->x2; + if (rect->y2 < box.y2) + box.y2 = rect->y2; - BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS); - OUT_BATCH( CMD ); - OUT_BATCH( BR13 ); - OUT_BATCH( (pbox->y1 << 16) | pbox->x1 ); - OUT_BATCH( (pbox->y2 << 16) | pbox->x2 ); + if (box.x1 > box.x2 || box.y1 > box.y2) + continue; + } - if (intel->sarea->pf_current_page == 0) - OUT_RELOC( frontRegion->buffer, DRM_MM_TT|DRM_MM_WRITE, 0 ); - else - OUT_RELOC( backRegion->buffer, DRM_MM_TT|DRM_MM_WRITE, 0 ); - OUT_BATCH( (pbox->y1 << 16) | pbox->x1 ); - OUT_BATCH( BR13 & 0xffff ); + BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((pbox->y1 << 16) | pbox->x1); + OUT_BATCH((pbox->y2 << 16) | pbox->x2); - if (intel->sarea->pf_current_page == 0) - OUT_RELOC( backRegion->buffer, DRM_MM_TT|DRM_MM_READ, 0 ); - else - OUT_RELOC( frontRegion->buffer, DRM_MM_TT|DRM_MM_READ, 0 ); + if (intel->sarea->pf_current_page == 0) + OUT_RELOC(frontRegion->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); + else + OUT_RELOC(backRegion->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0); + OUT_BATCH((pbox->y1 << 16) | pbox->x1); + OUT_BATCH(BR13 & 0xffff); - ADVANCE_BATCH(); + if (intel->sarea->pf_current_page == 0) + OUT_RELOC(backRegion->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0); + else + OUT_RELOC(frontRegion->buffer, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0); + + ADVANCE_BATCH(); } - intel->last_swap_fence = intel_batchbuffer_flush( intel->batch ); - intel->last_swap_fence_retired = GL_FALSE; + if (intel->first_swap_fence) + driFenceUnReference(intel->first_swap_fence); + intel->first_swap_fence = intel_batchbuffer_flush(intel->batch); + driFenceReference(intel->first_swap_fence); } - UNLOCK_HARDWARE( intel ); - if (!rect) - { - intel->swap_count++; - (*dri_interface->getUST)(&ust); - if (missed_target) { - intel->swap_missed_count++; - intel->swap_missed_ust = ust - intel->swap_ust; - } - - intel->swap_ust = ust; + UNLOCK_HARDWARE(intel); + + if (!rect) { + intel->swap_count++; + (*dri_interface->getUST) (&ust); + if (missed_target) { + intel->swap_missed_count++; + intel->swap_missed_ust = ust - intel->swap_ust; + } + + intel->swap_ust = ust; } } -void intelEmitFillBlit( struct intel_context *intel, - GLuint cpp, - GLshort dst_pitch, - struct buffer *dst_buffer, - GLuint dst_offset, - GLshort x, GLshort y, - GLshort w, GLshort h, - GLuint color ) +void +intelEmitFillBlit(struct intel_context *intel, + GLuint cpp, + GLshort dst_pitch, + struct _DriBufferObject *dst_buffer, + GLuint dst_offset, + GLshort x, GLshort y, GLshort w, GLshort h, GLuint color) { GLuint BR13, CMD; BATCH_LOCALS; dst_pitch *= cpp; - switch(cpp) { - case 1: - case 2: - case 3: - BR13 = dst_pitch | (0xF0 << 16) | (1<<24); + switch (cpp) { + case 1: + case 2: + case 3: + BR13 = dst_pitch | (0xF0 << 16) | (1 << 24); CMD = XY_COLOR_BLT_CMD; break; case 4: - BR13 = dst_pitch | (0xF0 << 16) | (1<<24) | (1<<25); + BR13 = dst_pitch | (0xF0 << 16) | (1 << 24) | (1 << 25); CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | - XY_COLOR_BLT_WRITE_RGB); + XY_COLOR_BLT_WRITE_RGB); break; default: return; } DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", - __FUNCTION__, - dst_buffer, dst_pitch, dst_offset, x, y, - w,h); + __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h); BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS); - OUT_BATCH( CMD ); - OUT_BATCH( BR13 ); - OUT_BATCH( (y << 16) | x ); - OUT_BATCH( ((y+h) << 16) | (x+w) ); - OUT_RELOC( dst_buffer, DRM_MM_TT|DRM_MM_WRITE, dst_offset ); - OUT_BATCH( color ); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((y << 16) | x); + OUT_BATCH(((y + h) << 16) | (x + w)); + OUT_RELOC(dst_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, dst_offset); + OUT_BATCH(color); ADVANCE_BATCH(); } /* Copy BitBlt */ -void intelEmitCopyBlit( struct intel_context *intel, - GLuint cpp, - GLshort src_pitch, - struct buffer *src_buffer, - GLuint src_offset, - GLshort dst_pitch, - struct buffer *dst_buffer, - GLuint dst_offset, - GLshort src_x, GLshort src_y, - GLshort dst_x, GLshort dst_y, - GLshort w, GLshort h ) +void +intelEmitCopyBlit(struct intel_context *intel, + GLuint cpp, + GLshort src_pitch, + struct _DriBufferObject *src_buffer, + GLuint src_offset, + GLshort dst_pitch, + struct _DriBufferObject *dst_buffer, + GLuint dst_offset, + GLshort src_x, GLshort src_y, + GLshort dst_x, GLshort dst_y, GLshort w, GLshort h) { GLuint CMD, BR13; int dst_y2 = dst_y + h; @@ -264,30 +264,31 @@ void intelEmitCopyBlit( struct intel_context *intel, DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", __FUNCTION__, src_buffer, src_pitch, src_offset, src_x, src_y, - dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, - w,h); + dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h); src_pitch *= cpp; dst_pitch *= cpp; - switch(cpp) { - case 1: - case 2: - case 3: - BR13 = (((GLint)dst_pitch)&0xffff) | (0xCC << 16) | (1<<24); + switch (cpp) { + case 1: + case 2: + case 3: + BR13 = (((GLint) dst_pitch) & 0xffff) | (0xCC << 16) | (1 << 24); CMD = XY_SRC_COPY_BLT_CMD; break; case 4: - BR13 = (((GLint)dst_pitch)&0xffff) | (0xCC << 16) | (1<<24) | (1<<25); - CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB); + BR13 = + (((GLint) dst_pitch) & 0xffff) | (0xCC << 16) | (1 << 24) | (1 << + 25); + CMD = + (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); break; default: return; } - if (dst_y2 < dst_y || - dst_x2 < dst_x) { + if (dst_y2 < dst_y || dst_x2 < dst_x) { return; } @@ -298,29 +299,34 @@ void intelEmitCopyBlit( struct intel_context *intel, * know which blit directions to use, so overlapping copypixels get * the wrong result. */ - if ( dst_pitch > 0 && - src_pitch > 0) { + if (dst_pitch > 0 && src_pitch > 0) { BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS); - OUT_BATCH( CMD ); - OUT_BATCH( BR13 ); - OUT_BATCH( (dst_y << 16) | dst_x ); - OUT_BATCH( (dst_y2 << 16) | dst_x2 ); - OUT_RELOC( dst_buffer, DRM_MM_TT|DRM_MM_WRITE, dst_offset ); - OUT_BATCH( (src_y << 16) | src_x ); - OUT_BATCH( ((GLint)src_pitch&0xffff) ); - OUT_RELOC( src_buffer, DRM_MM_TT|DRM_MM_READ, src_offset ); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((dst_y << 16) | dst_x); + OUT_BATCH((dst_y2 << 16) | dst_x2); + OUT_RELOC(dst_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, dst_offset); + OUT_BATCH((src_y << 16) | src_x); + OUT_BATCH(((GLint) src_pitch & 0xffff)); + OUT_RELOC(src_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, src_offset); ADVANCE_BATCH(); } else { BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS); - OUT_BATCH( CMD ); - OUT_BATCH( BR13 ); - OUT_BATCH( (0 << 16) | dst_x ); - OUT_BATCH( (h << 16) | dst_x2 ); - OUT_RELOC( dst_buffer, DRM_MM_TT|DRM_MM_WRITE, dst_offset + dst_y * dst_pitch ); - OUT_BATCH( (0 << 16) | src_x ); - OUT_BATCH( ((GLint)src_pitch&0xffff) ); - OUT_RELOC( src_buffer, DRM_MM_TT|DRM_MM_READ, src_offset + src_y * src_pitch ); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((0 << 16) | dst_x); + OUT_BATCH((h << 16) | dst_x2); + OUT_RELOC(dst_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, + dst_offset + dst_y * dst_pitch); + OUT_BATCH((0 << 16) | src_x); + OUT_BATCH(((GLint) src_pitch & 0xffff)); + OUT_RELOC(src_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, + DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, + src_offset + src_y * src_pitch); ADVANCE_BATCH(); } } @@ -333,10 +339,11 @@ void intelEmitCopyBlit( struct intel_context *intel, * which we're clearing with triangles. * \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear */ -void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, - GLint cx, GLint cy, GLint cw, GLint ch) +void +intelClearWithBlit(GLcontext * ctx, GLbitfield mask, GLboolean all, + GLint cx, GLint cy, GLint cw, GLint ch) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); GLuint clear_depth; GLbitfield skipBuffers = 0; BATCH_LOCALS; @@ -363,11 +370,10 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, } /* XXX Move this flush/lock into the following conditional? */ - intelFlush( &intel->ctx ); - LOCK_HARDWARE( intel ); + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); - if (intel->numClipRects) - { + if (intel->numClipRects) { drm_clip_rect_t clear; int i; @@ -377,10 +383,10 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, * reliable. */ { - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + cx = ctx->DrawBuffer->_Xmin; + cy = ctx->DrawBuffer->_Ymin; + ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; + cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; } if (intel->ctx.DrawBuffer->Name == 0) { @@ -393,11 +399,13 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, clear.y2 = clear.y1 + ch; /* adjust for page flipping */ - if ( intel->sarea->pf_current_page == 1 ) { + if (intel->sarea->pf_current_page == 1) { const GLuint tmp = mask; mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - if ( tmp & BUFFER_BIT_FRONT_LEFT ) mask |= BUFFER_BIT_BACK_LEFT; - if ( tmp & BUFFER_BIT_BACK_LEFT ) mask |= BUFFER_BIT_FRONT_LEFT; + if (tmp & BUFFER_BIT_FRONT_LEFT) + mask |= BUFFER_BIT_BACK_LEFT; + if (tmp & BUFFER_BIT_BACK_LEFT) + mask |= BUFFER_BIT_FRONT_LEFT; } } else { @@ -411,24 +419,22 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, /* no change to mask */ } - for (i = 0 ; i < intel->numClipRects ; i++) - { - const drm_clip_rect_t *box = &intel->pClipRects[i]; - drm_clip_rect_t b; + for (i = 0; i < intel->numClipRects; i++) { + const drm_clip_rect_t *box = &intel->pClipRects[i]; + drm_clip_rect_t b; GLuint buf; - GLuint clearMask = mask; /* use copy, since we modify it below */ + GLuint clearMask = mask; /* use copy, since we modify it below */ - if (!all) { - intel_intersect_cliprects(&b, &clear, box); - } else { - b = *box; - } + if (!all) { + intel_intersect_cliprects(&b, &clear, box); + } + else { + b = *box; + } - if (0) - _mesa_printf("clear %d,%d..%d,%d, mask %x\n", - b.x1, b.y1, - b.x2, b.y2, - mask); + if (0) + _mesa_printf("clear %d,%d..%d,%d, mask %x\n", + b.x1, b.y1, b.x2, b.y2, mask); /* Loop over all renderbuffers */ for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) { @@ -438,9 +444,10 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, const struct intel_renderbuffer *irb = intel_renderbuffer(ctx->DrawBuffer-> Attachment[buf].Renderbuffer); - struct buffer *write_buffer = - intel_region_buffer(intel, irb->region, - all ? INTEL_WRITE_FULL : INTEL_WRITE_PART); + struct _DriBufferObject *write_buffer = + intel_region_buffer(intel, irb->region, + all ? INTEL_WRITE_FULL : + INTEL_WRITE_PART); GLuint clearVal; GLint pitch, cpp; @@ -452,17 +459,16 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, pitch = irb->region->pitch; cpp = irb->region->cpp; - DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", - __FUNCTION__, - irb->region->buffer, (pitch * cpp), - irb->region->draw_offset, - b.x1, b.y1, - b.x2 - b.x1, b.y2 - b.y1); + DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", + __FUNCTION__, + irb->region->buffer, (pitch * cpp), + irb->region->draw_offset, + b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1); /* Setup the blit command */ if (cpp == 4) { - BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24) | (1<<25); + BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24) | (1 << 25); if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) { CMD = XY_COLOR_BLT_CMD; if (clearMask & BUFFER_BIT_DEPTH) @@ -473,13 +479,13 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, else { /* clearing RGBA */ CMD = (XY_COLOR_BLT_CMD | - XY_COLOR_BLT_WRITE_ALPHA | + XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); } } else { ASSERT(cpp == 2 || cpp == 0); - BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24); + BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24); CMD = XY_COLOR_BLT_CMD; } @@ -491,26 +497,25 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, ? intel->ClearColor8888 : intel->ClearColor565; } /* - _mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n", - buf, irb->Base.Name); - */ + _mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n", + buf, irb->Base.Name); + */ BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS); - OUT_BATCH( CMD ); - OUT_BATCH( BR13 ); - OUT_BATCH( (b.y1 << 16) | b.x1 ); - OUT_BATCH( (b.y2 << 16) | b.x2 ); - OUT_RELOC( write_buffer, DRM_MM_TT|DRM_MM_WRITE, - irb->region->draw_offset ); - OUT_BATCH( clearVal ); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((b.y1 << 16) | b.x1); + OUT_BATCH((b.y2 << 16) | b.x2); + OUT_RELOC(write_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE, + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, + irb->region->draw_offset); + OUT_BATCH(clearVal); ADVANCE_BATCH(); - clearMask &= ~bufBit; /* turn off bit, for faster loop exit */ + clearMask &= ~bufBit; /* turn off bit, for faster loop exit */ } } } - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); } - - diff --git a/src/mesa/drivers/dri/i915/intel_blit.h b/src/mesa/drivers/dri/i915/intel_blit.h index 87f52a356e1..1d99988c3c6 100644 --- a/src/mesa/drivers/dri/i915/intel_blit.h +++ b/src/mesa/drivers/dri/i915/intel_blit.h @@ -30,33 +30,34 @@ #include "intel_context.h" #include "intel_ioctl.h" +#include "dri_bufmgr.h" -extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv, - const drm_clip_rect_t *rect); +extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv, + const drm_clip_rect_t * rect); -extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all, - GLint cx1, GLint cy1, GLint cw, GLint ch); +extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask, + GLboolean all, GLint cx1, GLint cy1, GLint cw, + GLint ch); -extern void intelEmitCopyBlit( struct intel_context *intel, - GLuint cpp, - GLshort src_pitch, - struct buffer *src_buffer, - GLuint src_offset, - GLshort dst_pitch, - struct buffer *dst_buffer, - GLuint dst_offset, - GLshort srcx, GLshort srcy, - GLshort dstx, GLshort dsty, - GLshort w, GLshort h ); +extern void intelEmitCopyBlit(struct intel_context *intel, + GLuint cpp, + GLshort src_pitch, + struct _DriBufferObject *src_buffer, + GLuint src_offset, + GLshort dst_pitch, + struct _DriBufferObject *dst_buffer, + GLuint dst_offset, + GLshort srcx, GLshort srcy, + GLshort dstx, GLshort dsty, + GLshort w, GLshort h); -extern void intelEmitFillBlit( struct intel_context *intel, - GLuint cpp, - GLshort dst_pitch, - struct buffer *dst_buffer, - GLuint dst_offset, - GLshort x, GLshort y, - GLshort w, GLshort h, - GLuint color ); +extern void intelEmitFillBlit(struct intel_context *intel, + GLuint cpp, + GLshort dst_pitch, + struct _DriBufferObject *dst_buffer, + GLuint dst_offset, + GLshort x, GLshort y, + GLshort w, GLshort h, GLuint color); #endif diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c index 6cb2a65035c..abc2a6594ca 100644 --- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c @@ -33,8 +33,7 @@ #include "intel_context.h" #include "intel_buffer_objects.h" #include "intel_regions.h" -#include "intel_bufmgr.h" - +#include "dri_bufmgr.h" /** * There is some duplication between mesa's bufferobjects and our @@ -42,16 +41,16 @@ * lookup an opaque structure. It would be nice if the handles and * internal structure where somehow shared. */ -static struct gl_buffer_object *intel_bufferobj_alloc( GLcontext *ctx, - GLuint name, - GLenum target ) +static struct gl_buffer_object * +intel_bufferobj_alloc(GLcontext * ctx, GLuint name, GLenum target) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object); _mesa_initialize_buffer_object(&obj->Base, name, target); - bmGenBuffers(intel, "bufferobj", 1, &obj->buffer, 0); + driGenBuffers(intel->intelScreen->regionPool, + "bufferobj", 1, &obj->buffer, 64, 0, 0); return &obj->Base; } @@ -59,29 +58,32 @@ static struct gl_buffer_object *intel_bufferobj_alloc( GLcontext *ctx, /* Break the COW tie to the region. The region gets to keep the data. */ -void intel_bufferobj_release_region( struct intel_context *intel, - struct intel_buffer_object *intel_obj ) +void +intel_bufferobj_release_region(struct intel_context *intel, + struct intel_buffer_object *intel_obj) { assert(intel_obj->region->buffer == intel_obj->buffer); intel_obj->region->pbo = NULL; intel_obj->region = NULL; - intel_obj->buffer = NULL; /* refcount? */ + intel_obj->buffer = NULL; /* refcount? */ /* This leads to a large number of buffer deletion/creation events. * Currently the drm doesn't like that: */ - bmGenBuffers(intel, "buffer object", 1, &intel_obj->buffer, 0); - bmBufferData(intel, intel_obj->buffer, intel_obj->Base.Size, NULL, 0); + driGenBuffers(intel->intelScreen->regionPool, + "buffer object", 1, &intel_obj->buffer, 64, 0, 0); + driBOData(intel_obj->buffer, intel_obj->Base.Size, NULL, 0); } /* Break the COW tie to the region. Both the pbo and the region end * up with a copy of the data. */ -void intel_bufferobj_cow( struct intel_context *intel, - struct intel_buffer_object *intel_obj ) +void +intel_bufferobj_cow(struct intel_context *intel, + struct intel_buffer_object *intel_obj) { assert(intel_obj->region); - intel_region_cow( intel, intel_obj->region ); + intel_region_cow(intel, intel_obj->region); } @@ -89,9 +91,9 @@ void intel_bufferobj_cow( struct intel_context *intel, * Deallocate/free a vertex/pixel buffer object. * Called via glDeleteBuffersARB(). */ -static void intel_bufferobj_free( GLcontext *ctx, - struct gl_buffer_object *obj ) -{ +static void +intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj) +{ struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); @@ -101,9 +103,9 @@ static void intel_bufferobj_free( GLcontext *ctx, intel_bufferobj_release_region(intel, intel_obj); } else if (intel_obj->buffer) { - bmDeleteBuffers( intel, 1, &intel_obj->buffer ); + driDeleteBuffers(1, &intel_obj->buffer); } - + _mesa_free(intel_obj); } @@ -115,12 +117,12 @@ static void intel_bufferobj_free( GLcontext *ctx, * memory will be allocated, but no copy will occur. * Called via glBufferDataARB(). */ -static void intel_bufferobj_data( GLcontext *ctx, - GLenum target, - GLsizeiptrARB size, - const GLvoid *data, - GLenum usage, - struct gl_buffer_object *obj ) +static void +intel_bufferobj_data(GLcontext * ctx, + GLenum target, + GLsizeiptrARB size, + const GLvoid * data, + GLenum usage, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); @@ -131,7 +133,7 @@ static void intel_bufferobj_data( GLcontext *ctx, if (intel_obj->region) intel_bufferobj_release_region(intel, intel_obj); - bmBufferData(intel, intel_obj->buffer, size, data, 0); + driBOData(intel_obj->buffer, size, data, 0); } @@ -141,12 +143,12 @@ static void intel_bufferobj_data( GLcontext *ctx, * if data is NULL, no copy is performed. * Called via glBufferSubDataARB(). */ -static void intel_bufferobj_subdata( GLcontext *ctx, - GLenum target, - GLintptrARB offset, - GLsizeiptrARB size, - const GLvoid * data, - struct gl_buffer_object * obj ) +static void +intel_bufferobj_subdata(GLcontext * ctx, + GLenum target, + GLintptrARB offset, + GLsizeiptrARB size, + const GLvoid * data, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); @@ -156,25 +158,24 @@ static void intel_bufferobj_subdata( GLcontext *ctx, if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); - bmBufferSubData(intel, intel_obj->buffer, offset, size, data); + driBOSubData(intel_obj->buffer, offset, size, data); } /** * Called via glGetBufferSubDataARB(). */ -static void intel_bufferobj_get_subdata( GLcontext *ctx, - GLenum target, - GLintptrARB offset, - GLsizeiptrARB size, - GLvoid * data, - struct gl_buffer_object * obj ) +static void +intel_bufferobj_get_subdata(GLcontext * ctx, + GLenum target, + GLintptrARB offset, + GLsizeiptrARB size, + GLvoid * data, struct gl_buffer_object *obj) { - struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); assert(intel_obj); - bmBufferGetSubData(intel, intel_obj->buffer, offset, size, data); + driBOGetSubData(intel_obj->buffer, offset, size, data); } @@ -182,10 +183,10 @@ static void intel_bufferobj_get_subdata( GLcontext *ctx, /** * Called via glMapBufferARB(). */ -static void *intel_bufferobj_map( GLcontext *ctx, - GLenum target, - GLenum access, - struct gl_buffer_object *obj ) +static void * +intel_bufferobj_map(GLcontext * ctx, + GLenum target, + GLenum access, struct gl_buffer_object *obj) { struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); @@ -197,7 +198,8 @@ static void *intel_bufferobj_map( GLcontext *ctx, if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); - obj->Pointer = bmMapBuffer(intel, intel_obj->buffer, 0); + obj->Pointer = driBOMap(intel_obj->buffer, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0); return obj->Pointer; } @@ -205,35 +207,35 @@ static void *intel_bufferobj_map( GLcontext *ctx, /** * Called via glMapBufferARB(). */ -static GLboolean intel_bufferobj_unmap( GLcontext *ctx, - GLenum target, - struct gl_buffer_object *obj ) +static GLboolean +intel_bufferobj_unmap(GLcontext * ctx, + GLenum target, struct gl_buffer_object *obj) { - struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); assert(intel_obj); assert(obj->Pointer); - bmUnmapBuffer(intel, intel_obj->buffer); + driBOUnmap(intel_obj->buffer); obj->Pointer = NULL; return GL_TRUE; } -struct buffer *intel_bufferobj_buffer( struct intel_context *intel, - struct intel_buffer_object *intel_obj, - GLuint flag ) +struct _DriBufferObject * +intel_bufferobj_buffer(struct intel_context *intel, + struct intel_buffer_object *intel_obj, GLuint flag) { if (intel_obj->region) { if (flag == INTEL_WRITE_PART) - intel_bufferobj_cow(intel, intel_obj); + intel_bufferobj_cow(intel, intel_obj); else if (flag == INTEL_WRITE_FULL) - intel_bufferobj_release_region(intel, intel_obj); + intel_bufferobj_release_region(intel, intel_obj); } return intel_obj->buffer; -} +} -void intel_bufferobj_init( struct intel_context *intel ) +void +intel_bufferobj_init(struct intel_context *intel) { GLcontext *ctx = &intel->ctx; diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.h b/src/mesa/drivers/dri/i915/intel_buffer_objects.h index 93dfbbc3c92..afe9b2f7cf2 100644 --- a/src/mesa/drivers/dri/i915/intel_buffer_objects.h +++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.h @@ -38,25 +38,26 @@ struct gl_buffer_object; /** * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object. */ -struct intel_buffer_object { +struct intel_buffer_object +{ struct gl_buffer_object Base; - struct buffer *buffer; /* the low-level buffer manager's buffer handle */ - + struct _DriBufferObject *buffer; /* the low-level buffer manager's buffer handle */ + struct intel_region *region; /* Is there a zero-copy texture - associated with this (pixel) - buffer object? */ + associated with this (pixel) + buffer object? */ }; /* Get the bm buffer associated with a GL bufferobject: */ -struct buffer *intel_bufferobj_buffer( struct intel_context *intel, - struct intel_buffer_object *obj, - GLuint flag ); +struct _DriBufferObject *intel_bufferobj_buffer(struct intel_context *intel, + struct intel_buffer_object + *obj, GLuint flag); /* Hook the bufferobject implementation into mesa: */ -void intel_bufferobj_init( struct intel_context *intel ); +void intel_bufferobj_init(struct intel_context *intel); @@ -66,20 +67,20 @@ void intel_bufferobj_init( struct intel_context *intel ); * casting them erroneously to our structs. */ static INLINE struct intel_buffer_object * -intel_buffer_object( struct gl_buffer_object *obj ) +intel_buffer_object(struct gl_buffer_object *obj) { if (obj->Name) - return (struct intel_buffer_object *)obj; + return (struct intel_buffer_object *) obj; else return NULL; } /* Helpers for zerocopy image uploads. See also intel_regions.h: */ -void intel_bufferobj_cow( struct intel_context *intel, - struct intel_buffer_object *intel_obj ); -void intel_bufferobj_release_region( struct intel_context *intel, - struct intel_buffer_object *intel_obj ); +void intel_bufferobj_cow(struct intel_context *intel, + struct intel_buffer_object *intel_obj); +void intel_bufferobj_release_region(struct intel_context *intel, + struct intel_buffer_object *intel_obj); #endif diff --git a/src/mesa/drivers/dri/i915/intel_buffers.c b/src/mesa/drivers/dri/i915/intel_buffers.c index 0893b154544..8022f17b719 100644 --- a/src/mesa/drivers/dri/i915/intel_buffers.c +++ b/src/mesa/drivers/dri/i915/intel_buffers.c @@ -42,21 +42,28 @@ /** * XXX move this into a new dri/common/cliprects.c file. */ -GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b ) +GLboolean +intel_intersect_cliprects(drm_clip_rect_t * dst, + const drm_clip_rect_t * a, + const drm_clip_rect_t * b) { GLint bx = b->x1; GLint by = b->y1; GLint bw = b->x2 - bx; GLint bh = b->y2 - by; - if (bx < a->x1) bw -= a->x1 - bx, bx = a->x1; - if (by < a->y1) bh -= a->y1 - by, by = a->y1; - if (bx + bw > a->x2) bw = a->x2 - bx; - if (by + bh > a->y2) bh = a->y2 - by; - if (bw <= 0) return GL_FALSE; - if (bh <= 0) return GL_FALSE; + if (bx < a->x1) + bw -= a->x1 - bx, bx = a->x1; + if (by < a->y1) + bh -= a->y1 - by, by = a->y1; + if (bx + bw > a->x2) + bw = a->x2 - bx; + if (by + bh > a->y2) + bh = a->y2 - by; + if (bw <= 0) + return GL_FALSE; + if (bh <= 0) + return GL_FALSE; dst->x1 = bx; dst->y1 = by; @@ -69,7 +76,8 @@ GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst, /** * Return pointer to current color drawing region, or NULL. */ -struct intel_region *intel_drawbuf_region( struct intel_context *intel ) +struct intel_region * +intel_drawbuf_region(struct intel_context *intel) { struct intel_renderbuffer *irbColor = intel_renderbuffer(intel->ctx.DrawBuffer->_ColorDrawBuffers[0][0]); @@ -82,7 +90,8 @@ struct intel_region *intel_drawbuf_region( struct intel_context *intel ) /** * Return pointer to current color reading region, or NULL. */ -struct intel_region *intel_readbuf_region( struct intel_context *intel ) +struct intel_region * +intel_readbuf_region(struct intel_context *intel) { struct intel_renderbuffer *irb = intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer); @@ -94,9 +103,8 @@ struct intel_region *intel_readbuf_region( struct intel_context *intel ) -static void intelBufferSize(GLframebuffer *buffer, - GLuint *width, - GLuint *height) +static void +intelBufferSize(GLframebuffer * buffer, GLuint * width, GLuint * height) { GET_CURRENT_CONTEXT(ctx); struct intel_context *intel = intel_context(ctx); @@ -128,7 +136,8 @@ static void intelBufferSize(GLframebuffer *buffer, * intel->drawX * intel->drawY */ -static void intelSetRenderbufferClipRects( struct intel_context *intel ) +static void +intelSetRenderbufferClipRects(struct intel_context *intel) { assert(intel->ctx.DrawBuffer->Width > 0); assert(intel->ctx.DrawBuffer->Height > 0); @@ -147,11 +156,13 @@ static void intelSetRenderbufferClipRects( struct intel_context *intel ) * As above, but for rendering to front buffer of a window. * \sa intelSetRenderbufferClipRects */ -static void intelSetFrontClipRects( struct intel_context *intel ) +static void +intelSetFrontClipRects(struct intel_context *intel) { __DRIdrawablePrivate *dPriv = intel->driDrawable; - if (!dPriv) return; + if (!dPriv) + return; intel->numClipRects = dPriv->numClipRects; intel->pClipRects = dPriv->pClipRects; @@ -163,11 +174,13 @@ static void intelSetFrontClipRects( struct intel_context *intel ) /** * As above, but for rendering to back buffer of a window. */ -static void intelSetBackClipRects( struct intel_context *intel ) +static void +intelSetBackClipRects(struct intel_context *intel) { __DRIdrawablePrivate *dPriv = intel->driDrawable; - if (!dPriv) return; + if (!dPriv) + return; if (intel->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) { /* use the front clip rects */ @@ -175,41 +188,45 @@ static void intelSetBackClipRects( struct intel_context *intel ) intel->pClipRects = dPriv->pClipRects; intel->drawX = dPriv->x; intel->drawY = dPriv->y; - } else { + } + else { /* use the back clip rects */ intel->numClipRects = dPriv->numBackClipRects; intel->pClipRects = dPriv->pBackClipRects; intel->drawX = dPriv->backX; intel->drawY = dPriv->backY; - + if (dPriv->numBackClipRects == 1 && - dPriv->x == dPriv->backX && - dPriv->y == dPriv->backY) { - - /* Repeat the calculation of the back cliprect dimensions here - * as early versions of dri.a in the Xserver are incorrect. Try - * very hard not to restrict future versions of dri.a which - * might eg. allocate truly private back buffers. - */ - int x1, y1; - int x2, y2; - - x1 = dPriv->x; - y1 = dPriv->y; - x2 = dPriv->x + dPriv->w; - y2 = dPriv->y + dPriv->h; - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > intel->intelScreen->width) x2 = intel->intelScreen->width; - if (y2 > intel->intelScreen->height) y2 = intel->intelScreen->height; + dPriv->x == dPriv->backX && dPriv->y == dPriv->backY) { - if (x1 == dPriv->pBackClipRects[0].x1 && - y1 == dPriv->pBackClipRects[0].y1) { + /* Repeat the calculation of the back cliprect dimensions here + * as early versions of dri.a in the Xserver are incorrect. Try + * very hard not to restrict future versions of dri.a which + * might eg. allocate truly private back buffers. + */ + int x1, y1; + int x2, y2; - dPriv->pBackClipRects[0].x2 = x2; - dPriv->pBackClipRects[0].y2 = y2; - } + x1 = dPriv->x; + y1 = dPriv->y; + x2 = dPriv->x + dPriv->w; + y2 = dPriv->y + dPriv->h; + + if (x1 < 0) + x1 = 0; + if (y1 < 0) + y1 = 0; + if (x2 > intel->intelScreen->width) + x2 = intel->intelScreen->width; + if (y2 > intel->intelScreen->height) + y2 = intel->intelScreen->height; + + if (x1 == dPriv->pBackClipRects[0].x1 && + y1 == dPriv->pBackClipRects[0].y1) { + + dPriv->pBackClipRects[0].x2 = x2; + dPriv->pBackClipRects[0].y2 = y2; + } } } } @@ -219,13 +236,14 @@ static void intelSetBackClipRects( struct intel_context *intel ) * This will be called whenever the currently bound window is moved/resized. * XXX: actually, it seems to NOT be called when the window is only moved (BP). */ -void intelWindowMoved( struct intel_context *intel ) +void +intelWindowMoved(struct intel_context *intel) { GLcontext *ctx = &intel->ctx; if (!intel->ctx.DrawBuffer) { /* when would this happen? -BP */ - intelSetFrontClipRects( intel ); + intelSetFrontClipRects(intel); } else if (intel->ctx.DrawBuffer->Name != 0) { /* drawing to user-created FBO - do nothing */ @@ -235,14 +253,14 @@ void intelWindowMoved( struct intel_context *intel ) /* drawing to a window */ switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) { case BUFFER_BIT_FRONT_LEFT: - intelSetFrontClipRects( intel ); - break; + intelSetFrontClipRects(intel); + break; case BUFFER_BIT_BACK_LEFT: - intelSetBackClipRects( intel ); - break; + intelSetBackClipRects(intel); + break; default: - /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */ - intelSetFrontClipRects( intel ); + /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */ + intelSetFrontClipRects(intel); } } @@ -253,8 +271,8 @@ void intelWindowMoved( struct intel_context *intel ) } /* Update hardware scissor */ - ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height ); + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); } @@ -262,11 +280,10 @@ void intelWindowMoved( struct intel_context *intel ) /* A true meta version of this would be very simple and additionally * machine independent. Maybe we'll get there one day. */ -static void intelClearWithTris(struct intel_context *intel, - GLbitfield mask, - GLboolean all, - GLint cx, GLint cy, - GLint cw, GLint ch) +static void +intelClearWithTris(struct intel_context *intel, + GLbitfield mask, + GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) { GLcontext *ctx = &intel->ctx; drm_clip_rect_t clear; @@ -289,10 +306,10 @@ static void intelClearWithTris(struct intel_context *intel, * reliable. */ { - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + cx = ctx->DrawBuffer->_Xmin; + cy = ctx->DrawBuffer->_Ymin; + ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; + cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; } /* note: regardless of 'all', cx, cy, cw, ch are now correct */ @@ -304,44 +321,41 @@ static void intelClearWithTris(struct intel_context *intel, /* Back and stencil cliprects are the same. Try and do both * buffers at once: */ - if (mask & (BUFFER_BIT_BACK_LEFT|BUFFER_BIT_STENCIL|BUFFER_BIT_DEPTH)) { - struct intel_region *backRegion - = intel_get_rb_region(ctx->DrawBuffer, BUFFER_BACK_LEFT); - struct intel_region *depthRegion - = intel_get_rb_region(ctx->DrawBuffer, BUFFER_DEPTH); + if (mask & + (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH)) { + struct intel_region *backRegion = + intel_get_rb_region(ctx->DrawBuffer, BUFFER_BACK_LEFT); + struct intel_region *depthRegion = + intel_get_rb_region(ctx->DrawBuffer, BUFFER_DEPTH); const GLuint clearColor = (backRegion && backRegion->cpp == 4) ? intel->ClearColor8888 : intel->ClearColor565; - intel->vtbl.meta_draw_region(intel, backRegion, depthRegion ); + intel->vtbl.meta_draw_region(intel, backRegion, depthRegion); - if (mask & BUFFER_BIT_BACK_LEFT) - intel->vtbl.meta_color_mask(intel, GL_TRUE ); - else - intel->vtbl.meta_color_mask(intel, GL_FALSE ); + if (mask & BUFFER_BIT_BACK_LEFT) + intel->vtbl.meta_color_mask(intel, GL_TRUE); + else + intel->vtbl.meta_color_mask(intel, GL_FALSE); - if (mask & BUFFER_BIT_STENCIL) - intel->vtbl.meta_stencil_replace( intel, - intel->ctx.Stencil.WriteMask[0], - intel->ctx.Stencil.Clear); - else - intel->vtbl.meta_no_stencil_write(intel); + if (mask & BUFFER_BIT_STENCIL) + intel->vtbl.meta_stencil_replace(intel, + intel->ctx.Stencil.WriteMask[0], + intel->ctx.Stencil.Clear); + else + intel->vtbl.meta_no_stencil_write(intel); - if (mask & BUFFER_BIT_DEPTH) - intel->vtbl.meta_depth_replace( intel ); - else - intel->vtbl.meta_no_depth_write(intel); - - /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the - * drawing origin may not be correctly emitted. - */ - intel_meta_draw_quad(intel, - clear.x1, clear.x2, - clear.y1, clear.y2, - intel->ctx.Depth.Clear, - clearColor, - 0, 0, 0, 0); /* texcoords */ + if (mask & BUFFER_BIT_DEPTH) + intel->vtbl.meta_depth_replace(intel); + else + intel->vtbl.meta_no_depth_write(intel); - mask &= ~(BUFFER_BIT_BACK_LEFT|BUFFER_BIT_STENCIL|BUFFER_BIT_DEPTH); + /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the + * drawing origin may not be correctly emitted. + */ + intel_meta_draw_quad(intel, clear.x1, clear.x2, clear.y1, clear.y2, intel->ctx.Depth.Clear, clearColor, 0, 0, 0, 0); /* texcoords */ + + mask &= + ~(BUFFER_BIT_BACK_LEFT | BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH); } /* clear the remaining (color) renderbuffers */ @@ -358,25 +372,21 @@ static void intelClearWithTris(struct intel_context *intel, intel->vtbl.meta_no_depth_write(intel); intel->vtbl.meta_no_stencil_write(intel); - intel->vtbl.meta_color_mask(intel, GL_TRUE ); + intel->vtbl.meta_color_mask(intel, GL_TRUE); intel->vtbl.meta_draw_region(intel, irbColor->region, NULL); /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the * drawing origin may not be correctly emitted. */ - intel_meta_draw_quad(intel, - clear.x1, clear.x2, - clear.y1, clear.y2, - 0, /* depth clear val */ - color, - 0, 0, 0, 0); /* texcoords */ + intel_meta_draw_quad(intel, clear.x1, clear.x2, clear.y1, clear.y2, 0, /* depth clear val */ + color, 0, 0, 0, 0); /* texcoords */ mask &= ~bufBit; } } - intel->vtbl.leave_meta_state( intel ); - intel_batchbuffer_flush( intel->batch ); + intel->vtbl.leave_meta_state(intel); + intel_batchbuffer_flush(intel->batch); } UNLOCK_HARDWARE(intel); } @@ -389,9 +399,9 @@ static void intelClearWithTris(struct intel_context *intel, * color buffer. * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source. */ -void intelRotateWindow(struct intel_context *intel, - __DRIdrawablePrivate *dPriv, - GLuint srcBuf) +void +intelRotateWindow(struct intel_context *intel, + __DRIdrawablePrivate * dPriv, GLuint srcBuf) { intelScreenPrivate *screen = intel->intelScreen; drm_clip_rect_t fullRect; @@ -408,7 +418,7 @@ void intelRotateWindow(struct intel_context *intel, /* * set up hardware state */ - intelFlush( &intel->ctx ); + intelFlush(&intel->ctx); LOCK_HARDWARE(intel); @@ -418,10 +428,10 @@ void intelRotateWindow(struct intel_context *intel, } intel->vtbl.install_meta_state(intel); - - intel->vtbl.meta_no_depth_write( intel ); - intel->vtbl.meta_no_stencil_write( intel ); - intel->vtbl.meta_color_mask( intel, GL_FALSE ); + + intel->vtbl.meta_no_depth_write(intel); + intel->vtbl.meta_no_stencil_write(intel); + intel->vtbl.meta_color_mask(intel, GL_FALSE); /* save current drawing origin and cliprects (restored at end) */ @@ -442,9 +452,7 @@ void intelRotateWindow(struct intel_context *intel, intel->numClipRects = 1; intel->pClipRects = &fullRect; - intel->vtbl.meta_draw_region( intel, - intel->rotated_region, - NULL ); /* ? */ + intel->vtbl.meta_draw_region(intel, intel->rotated_region, NULL); /* ? */ if (srcBuf == BUFFER_BIT_FRONT_LEFT) { src = intel->front_region; @@ -468,12 +476,9 @@ void intelRotateWindow(struct intel_context *intel, /* set the whole screen up as a texture to avoid alignment issues */ intel->vtbl.meta_tex_rect_source(intel, - src->buffer, - screen->width, - screen->height, - src->pitch, - format, - type); + src->buffer, + screen->width, + screen->height, src->pitch, format, type); intel->vtbl.meta_texture_blend_replace(intel); @@ -489,16 +494,24 @@ void intelRotateWindow(struct intel_context *intel, int j; /* build vertices for four corners of clip rect */ - verts[0][0] = srcX0; verts[0][1] = srcY0; - verts[1][0] = srcX1; verts[1][1] = srcY0; - verts[2][0] = srcX1; verts[2][1] = srcY1; - verts[3][0] = srcX0; verts[3][1] = srcY1; + verts[0][0] = srcX0; + verts[0][1] = srcY0; + verts[1][0] = srcX1; + verts[1][1] = srcY0; + verts[2][0] = srcX1; + verts[2][1] = srcY1; + verts[3][0] = srcX0; + verts[3][1] = srcY1; /* .. and texcoords */ - tex[0][0] = srcX0; tex[0][1] = srcY0; - tex[1][0] = srcX1; tex[1][1] = srcY0; - tex[2][0] = srcX1; tex[2][1] = srcY1; - tex[3][0] = srcX0; tex[3][1] = srcY1; + tex[0][0] = srcX0; + tex[0][1] = srcY0; + tex[1][0] = srcX1; + tex[1][1] = srcY0; + tex[2][0] = srcX1; + tex[2][1] = srcY1; + tex[3][0] = srcX0; + tex[3][1] = srcY1; /* transform coords to rotated screen coords */ @@ -510,10 +523,10 @@ void intelRotateWindow(struct intel_context *intel, /* draw polygon to map source image to dest region */ intel_meta_draw_poly(intel, 4, verts, 0, 0, tex); - } /* cliprect loop */ + } /* cliprect loop */ - intel->vtbl.leave_meta_state( intel ); - intel_batchbuffer_flush( intel->batch ); + intel->vtbl.leave_meta_state(intel); + intel_batchbuffer_flush(intel->batch); /* restore original drawing origin and cliprects */ intel->drawX = xOrig; @@ -528,14 +541,13 @@ void intelRotateWindow(struct intel_context *intel, /** * Called by ctx->Driver.Clear. */ -static void intelClear(GLcontext *ctx, - GLbitfield mask, - GLboolean all, - GLint cx, GLint cy, - GLint cw, GLint ch) +static void +intelClear(GLcontext * ctx, + GLbitfield mask, + GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) { - struct intel_context *intel = intel_context( ctx ); - const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); + struct intel_context *intel = intel_context(ctx); + const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); GLbitfield tri_mask = 0; GLbitfield blit_mask = 0; GLbitfield swrast_mask = 0; @@ -564,7 +576,7 @@ static void intelClear(GLcontext *ctx, if ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff) { /* not clearing all stencil bits, so use triangle clearing */ tri_mask |= BUFFER_BIT_STENCIL; - } + } else { /* clearing all stencil bits, use blitting */ blit_mask |= BUFFER_BIT_STENCIL; @@ -576,9 +588,9 @@ static void intelClear(GLcontext *ctx, if (mask & BUFFER_BIT_DEPTH) { /* clear depth with whatever method is used for stencil (see above) */ if (tri_mask & BUFFER_BIT_STENCIL) - tri_mask |= BUFFER_BIT_DEPTH; - else - blit_mask |= BUFFER_BIT_DEPTH; + tri_mask |= BUFFER_BIT_DEPTH; + else + blit_mask |= BUFFER_BIT_DEPTH; } /* SW fallback clearing */ @@ -596,23 +608,24 @@ static void intelClear(GLcontext *ctx, } - intelFlush( ctx ); /* XXX intelClearWithBlit also does this */ + intelFlush(ctx); /* XXX intelClearWithBlit also does this */ if (blit_mask) - intelClearWithBlit( ctx, blit_mask, all, cx, cy, cw, ch ); + intelClearWithBlit(ctx, blit_mask, all, cx, cy, cw, ch); - if (tri_mask) - intelClearWithTris( intel, tri_mask, all, cx, cy, cw, ch); + if (tri_mask) + intelClearWithTris(intel, tri_mask, all, cx, cy, cw, ch); if (swrast_mask) - _swrast_Clear( ctx, swrast_mask, all, cx, cy, cw, ch ); + _swrast_Clear(ctx, swrast_mask, all, cx, cy, cw, ch); } /* Flip the front & back buffers */ -static void intelPageFlip( const __DRIdrawablePrivate *dPriv ) +static void +intelPageFlip(const __DRIdrawablePrivate * dPriv) { #if 0 struct intel_context *intel; @@ -627,32 +640,33 @@ static void intelPageFlip( const __DRIdrawablePrivate *dPriv ) intel = (struct intel_context *) dPriv->driContextPriv->driverPrivate; - intelFlush( &intel->ctx ); - LOCK_HARDWARE( intel ); + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); if (dPriv->pClipRects) { - *(drm_clip_rect_t *)intel->sarea->boxes = dPriv->pClipRects[0]; + *(drm_clip_rect_t *) intel->sarea->boxes = dPriv->pClipRects[0]; intel->sarea->nbox = 1; } - ret = drmCommandNone(intel->driFd, DRM_I830_FLIP); + ret = drmCommandNone(intel->driFd, DRM_I830_FLIP); if (ret) { fprintf(stderr, "%s: %d\n", __FUNCTION__, ret); - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); exit(1); } tmp = intel->sarea->last_enqueue; - intelRefillBatchLocked( intel ); - UNLOCK_HARDWARE( intel ); + intelRefillBatchLocked(intel); + UNLOCK_HARDWARE(intel); - intelSetDrawBuffer( &intel->ctx, intel->ctx.Color.DriverDrawBuffer ); + intelSetDrawBuffer(&intel->ctx, intel->ctx.Color.DriverDrawBuffer); #endif } #if 0 -void intelSwapBuffers( __DRIdrawablePrivate *dPriv ) +void +intelSwapBuffers(__DRIdrawablePrivate * dPriv) { if (dPriv->driverPrivate) { const struct gl_framebuffer *fb @@ -660,13 +674,14 @@ void intelSwapBuffers( __DRIdrawablePrivate *dPriv ) if (fb->Visual.doubleBufferMode) { GET_CURRENT_CONTEXT(ctx); if (ctx && ctx->DrawBuffer == fb) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering */ + _mesa_notifySwapBuffers(ctx); /* flush pending rendering */ + } + if (0 /*intel->doPageFlip */ ) { /* doPageFlip is never set !!! */ + intelPageFlip(dPriv); + } + else { + intelCopyBuffer(dPriv); } - if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */ - intelPageFlip( dPriv ); - } else { - intelCopyBuffer( dPriv ); - } } } else { @@ -677,50 +692,54 @@ void intelSwapBuffers( __DRIdrawablePrivate *dPriv ) #else /* Trunk version: */ -void intelSwapBuffers( __DRIdrawablePrivate *dPriv ) +void +intelSwapBuffers(__DRIdrawablePrivate * dPriv) { if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - struct intel_context *intel = - (struct intel_context *) dPriv->driContextPriv->driverPrivate; + struct intel_context *intel = + (struct intel_context *) dPriv->driContextPriv->driverPrivate; GLcontext *ctx = &intel->ctx; if (ctx->Visual.doubleBufferMode) { intelScreenPrivate *screen = intel->intelScreen; - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */ - intelPageFlip( dPriv ); - } else { - intelCopyBuffer( dPriv, NULL ); - } + _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ + if (0 /*intel->doPageFlip */ ) { /* doPageFlip is never set !!! */ + intelPageFlip(dPriv); + } + else { + intelCopyBuffer(dPriv, NULL); + } if (screen->current_rotation != 0) { intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT); } } - } else { + } + else { /* XXX this shouldn't be an error but we can't handle it for now */ fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__); } } #endif -void intelCopySubBuffer( __DRIdrawablePrivate *dPriv, - int x, int y, int w, int h ) +void +intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) { if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - struct intel_context *intel = - (struct intel_context *) dPriv->driContextPriv->driverPrivate; + struct intel_context *intel = + (struct intel_context *) dPriv->driContextPriv->driverPrivate; GLcontext *ctx = &intel->ctx; if (ctx->Visual.doubleBufferMode) { - drm_clip_rect_t rect; - rect.x1 = x + dPriv->x; - rect.y1 = (dPriv->h - y - h) + dPriv->y; - rect.x2 = rect.x1 + w; - rect.y2 = rect.y1 + h; - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - intelCopyBuffer( dPriv, &rect ); + drm_clip_rect_t rect; + rect.x1 = x + dPriv->x; + rect.y1 = (dPriv->h - y - h) + dPriv->y; + rect.x2 = rect.x1 + w; + rect.y2 = rect.y1 + h; + _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ + intelCopyBuffer(dPriv, &rect); } - } else { + } + else { /* XXX this shouldn't be an error but we can't handle it for now */ fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__); } @@ -738,13 +757,13 @@ void intelCopySubBuffer( __DRIdrawablePrivate *dPriv, * color buffers. */ void -intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) +intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) { struct intel_context *intel = intel_context(ctx); struct intel_region *colorRegion, *depthRegion = NULL; struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL; - int front = 0; /* drawing to front color buffer? */ - + int front = 0; /* drawing to front color buffer? */ + if (!fb) { /* this can happen during the initial context initialization */ return; @@ -779,16 +798,16 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) /* XXX FBO temporary - always use software rendering */ || 1 #endif - ) { + ) { /* writing to 0 or 2 or 4 color buffers */ /*_mesa_debug(ctx, "Software rendering\n");*/ - FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE ); - front = 1; /* might not have back color buffer */ + FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE); + front = 1; /* might not have back color buffer */ } else { /* draw to exactly one color buffer */ /*_mesa_debug(ctx, "Hardware rendering\n");*/ - FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE ); + FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE); if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { front = 1; } @@ -800,16 +819,16 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) */ if (fb->Name == 0) { /* drawing to window system buffer */ - if (intel->sarea->pf_current_page == 1 ) { + if (intel->sarea->pf_current_page == 1) { /* page flipped back/front */ front ^= 1; } if (front) { - intelSetFrontClipRects( intel ); + intelSetFrontClipRects(intel); colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT); } else { - intelSetBackClipRects( intel ); + intelSetBackClipRects(intel); colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT); } } @@ -830,10 +849,10 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) ctx->NewState |= _NEW_POLYGON; if (!colorRegion) { - FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE ); + FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE); } else { - FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE ); + FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE); } /*** @@ -887,7 +906,7 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) /** ** Release old regions, reference new regions **/ -#if 0 /* XXX FBO: this seems to be redundant with i915_state_draw_region() */ +#if 0 /* XXX FBO: this seems to be redundant with i915_state_draw_region() */ if (intel->draw_region != colorRegion) { intel_region_release(intel, &intel->draw_region); intel_region_reference(&intel->draw_region, colorRegion); @@ -898,27 +917,27 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } #endif - intel->vtbl.set_draw_region( intel, colorRegion, depthRegion ); + intel->vtbl.set_draw_region(intel, colorRegion, depthRegion); /* update viewport since it depends on window size */ ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, ctx->Viewport.Width, ctx->Viewport.Height); /* Update hardware scissor */ - ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height ); + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); } static void -intelDrawBuffer(GLcontext *ctx, GLenum mode) +intelDrawBuffer(GLcontext * ctx, GLenum mode) { intel_draw_buffer(ctx, ctx->DrawBuffer); } -static void -intelReadBuffer( GLcontext *ctx, GLenum mode ) +static void +intelReadBuffer(GLcontext * ctx, GLenum mode) { if (ctx->ReadBuffer == ctx->DrawBuffer) { /* This will update FBO completeness status. @@ -934,7 +953,8 @@ intelReadBuffer( GLcontext *ctx, GLenum mode ) } -void intelInitBufferFuncs( struct dd_function_table *functions ) +void +intelInitBufferFuncs(struct dd_function_table *functions) { functions->Clear = intelClear; functions->GetBufferSize = intelBufferSize; diff --git a/src/mesa/drivers/dri/i915/intel_buffers.h b/src/mesa/drivers/dri/i915/intel_buffers.h index f06cc7e5c09..0faf0553474 100644 --- a/src/mesa/drivers/dri/i915/intel_buffers.h +++ b/src/mesa/drivers/dri/i915/intel_buffers.h @@ -33,31 +33,24 @@ struct intel_context; extern GLboolean -intel_intersect_cliprects(drm_clip_rect_t *dest, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b); +intel_intersect_cliprects(drm_clip_rect_t * dest, + const drm_clip_rect_t * a, + const drm_clip_rect_t * b); -extern struct intel_region * -intel_readbuf_region(struct intel_context *intel); +extern struct intel_region *intel_readbuf_region(struct intel_context *intel); -extern struct intel_region * -intel_drawbuf_region(struct intel_context *intel); +extern struct intel_region *intel_drawbuf_region(struct intel_context *intel); + +extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv); + +extern void intelWindowMoved(struct intel_context *intel); + +extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb); + +extern void intelInitBufferFuncs(struct dd_function_table *functions); extern void -intelSwapBuffers( __DRIdrawablePrivate *dPriv); - -extern void -intelWindowMoved(struct intel_context *intel); - -extern void -intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb); - -extern void -intelInitBufferFuncs(struct dd_function_table *functions); - -extern void intelRotateWindow(struct intel_context *intel, - __DRIdrawablePrivate *dPriv, - GLuint srcBuf); + __DRIdrawablePrivate * dPriv, GLuint srcBuf); #endif /* INTEL_BUFFERS_H */ diff --git a/src/mesa/drivers/dri/i915/intel_bufmgr.c b/src/mesa/drivers/dri/i915/intel_bufmgr.c deleted file mode 100644 index 635ae8bad63..00000000000 --- a/src/mesa/drivers/dri/i915/intel_bufmgr.c +++ /dev/null @@ -1,467 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Steamboat Springs, CO. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -#include "intel_bufmgr.h" - -#include "intel_context.h" -#include "intel_ioctl.h" - -#include "simple_list.h" -#include "mm.h" -#include "imports.h" -#include "glthread.h" -#include -#include -#include - -#define FILE_DEBUG_FLAG DEBUG_BUFMGR - -/* The buffer manager is really part of the gl_shared_state struct. - * TODO: Organize for the bufmgr to be created/deleted with the shared - * state and stored within the DriverData of that struct. Currently - * there are no mesa callbacks for this. - */ -struct buffer { - drmMMBuf drm_buf; - const char *name; - int refcount; -}; - - -#define BM_MAX 16 -static struct bufmgr -{ - _glthread_Mutex mutex; /**< for thread safety */ - int refcount; - int driFd; - - unsigned buf_nr; /* for generating ids */ - drmMMPool batchPool; - drmFence initFence; -} bufmgr_pool[BM_MAX]; - -static int nr_bms; - -#define LOCK(bm) _glthread_LOCK_MUTEX(bm->mutex) -#define UNLOCK(bm) _glthread_UNLOCK_MUTEX(bm->mutex) - -static void -bmError(int val, const char *file, const char *function, int line) -{ - _mesa_printf("Fatal video memory manager error \"%s\".\n" - "Check kernel logs or set the LIBGL_DEBUG\n" - "environment variable to \"verbose\" for more info.\n" - "Detected in file %s, line %d, function %s.\n", - strerror(-val), file, line, function); -#ifndef NDEBUG - exit(-1); -#else - abort(); -#endif -} - -#define BM_CKFATAL(val) \ - do{ \ - int tstVal = (val); \ - if (tstVal) \ - bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \ - } while(0); - -/*********************************************************************** - * Public functions - */ - -/* The initialization functions are skewed in the fake implementation. - * This call would be to attach to an existing manager, rather than to - * create a local one. - */ - -struct bufmgr * -bm_intel_Attach(struct intel_context *intel) -{ - GLuint i; - - for (i = 0; i < nr_bms; i++) - if (bufmgr_pool[i].driFd == intel->driFd) { - bufmgr_pool[i].refcount++; - _mesa_printf("retrieive old bufmgr for fd %d\n", - bufmgr_pool[i].driFd); - return &bufmgr_pool[i]; - } - - if (nr_bms < BM_MAX) { - struct bufmgr *bm = &bufmgr_pool[nr_bms++]; - - _mesa_printf("create new bufmgr for fd %d\n", intel->driFd); - bm->driFd = intel->driFd; - bm->refcount = 1; - _glthread_INIT_MUTEX(bm->mutex); - - drmGetLock(bm->driFd, intel->hHWContext, 0); - BM_CKFATAL(drmMMAllocBufferPool(bm->driFd, mmPoolRing, 0, - DRM_MM_TT | DRM_MM_NO_EVICT | - DRM_MM_READ | DRM_MM_EXE | - BM_BATCHBUFFER, 1024 * 1024, 4096, - &bm->batchPool)); - - - BM_CKFATAL(drmEmitFence(bm->driFd, 0, &bm->initFence)); - drmUnlock(bm->driFd, intel->hHWContext); - return bm; - } - - _mesa_printf("failed to create new bufmgr for fd %d\n", intel->driFd); - return NULL; -} - -void -bmGenBuffers(struct intel_context *intel, - const char *name, - unsigned n, struct buffer **buffers, unsigned flags) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - unsigned i; - unsigned bFlags = - (flags) ? flags : DRM_MM_TT | DRM_MM_VRAM | DRM_MM_SYSTEM; - - for (i = 0; i < n; i++) { - struct buffer *buf = calloc(sizeof(*buf), 1); - - BM_CKFATAL(drmMMInitBuffer(bm->driFd, bFlags, 12, &buf->drm_buf)); - buf->refcount = 1; - buf->name = name; - buffers[i] = buf; - } - } - UNLOCK(bm); -} - -void -bmSetShared(struct intel_context *intel, struct buffer *buffer, unsigned flags, - unsigned long offset, void *virtual) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - buffer->drm_buf.flags = DRM_MM_NO_EVICT | DRM_MM_SHARED - | DRM_MM_WRITE | DRM_MM_READ; - buffer->drm_buf.flags |= flags & DRM_MM_MEMTYPE_MASK; - buffer->drm_buf.offset = offset; - buffer->drm_buf.virtual = virtual; - BM_CKFATAL(drmMMAllocBuffer(bm->driFd, 0, NULL, 0, &buffer->drm_buf)); - } - UNLOCK(bm); -} - -void -bmDeleteBuffers(struct intel_context *intel, unsigned n, struct buffer **buffers) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - unsigned i; - - for (i = 0; i < n; i++) { - struct buffer *buf = buffers[i]; - - if (buf) - BM_CKFATAL(drmMMFreeBuffer(bm->driFd, &buf->drm_buf)); - } - } - UNLOCK(bm); -} - -/* If buffer size changes, free and reallocate. Otherwise update in - * place. - */ - -void -bmBufferData(struct intel_context *intel, - struct buffer *buffer, unsigned size, const void *data, unsigned flags) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - drmMMBuf *buf = &buffer->drm_buf; - - DBG("bmBufferData %d sz 0x%x data: %p\n", buffer, size, data); - - assert(buf); - assert(!buf->mapped); - assert(size); - - if (buf->flags & BM_BATCHBUFFER) { - BM_CKFATAL(drmMMFreeBuffer(bm->driFd, buf)); - BM_CKFATAL(drmMMAllocBuffer - (bm->driFd, size, &bm->batchPool, 1, buf)); - } else if (!(buf->flags & DRM_MM_SHARED)) { - - if (buf->block && (buf->size < size || drmBufIsBusy(bm->driFd, buf))) { - BM_CKFATAL(drmMMFreeBuffer(bm->driFd, buf)); - } - if (!buf->block) { - BM_CKFATAL(drmMMAllocBuffer(bm->driFd, size, NULL, 0, buf)); - } - - } - - if (data != NULL) { - - memcpy(drmMMMapBuffer(bm->driFd, buf), data, size); - drmMMUnmapBuffer(bm->driFd, buf); - - } - } - UNLOCK(bm); -} - -/* Update the buffer in place, in whatever space it is currently resident: - */ -void -bmBufferSubData(struct intel_context *intel, - struct buffer *buffer, - unsigned offset, unsigned size, const void *data) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - drmMMBuf *buf = &buffer->drm_buf; - - DBG("bmBufferSubdata %d offset 0x%x sz 0x%x\n", buffer, offset, size); - - assert(buf); - drmBufWaitBusy(bm->driFd, buf); - - if (size) { - memcpy((unsigned char *) drmMMMapBuffer(bm->driFd, buf) + offset, - data, size); - drmMMUnmapBuffer(bm->driFd, buf); - } - } - UNLOCK(bm); -} - -/* Extract data from the buffer: - */ -void -bmBufferGetSubData(struct intel_context *intel, - struct buffer *buffer, - unsigned offset, unsigned size, void *data) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - drmMMBuf *buf = &buffer->drm_buf; - - DBG("bmBufferSubdata %d offset 0x%x sz 0x%x\n", buffer, offset, size); - - assert(buf); - drmBufWaitBusy(bm->driFd, buf); - - if (size) { - memcpy(data, - (unsigned char *) drmMMMapBuffer(bm->driFd, buf) + offset, - size); - drmMMUnmapBuffer(bm->driFd, buf); - } - } - UNLOCK(bm); -} - -/* Return a pointer to whatever space the buffer is currently resident in: - */ -void * -bmMapBuffer(struct intel_context *intel, - struct buffer *buffer, unsigned flags) -{ - struct bufmgr *bm = intel->bm; - void *retval; - - LOCK(bm); - { - drmMMBuf *buf = &buffer->drm_buf; - - DBG("bmMapBuffer %d\n", buffer); - DBG("Map: Block is 0x%x\n", &buf->block); - - assert(buf); - /* assert(!buf->mapped); */ - - drmBufWaitBusy(bm->driFd, buf); - - retval = drmMMMapBuffer(bm->driFd, buf); - } - UNLOCK(bm); - - return retval; -} - -void -bmUnmapBuffer(struct intel_context *intel, - struct buffer *buffer) -{ - struct bufmgr *bm = intel->bm; - - LOCK(bm); - { - drmMMBuf *buf = &buffer->drm_buf; - - if (!buf) - goto out; - - DBG("bmUnmapBuffer %d\n", buffer); - - drmMMUnmapBuffer(bm->driFd, buf); - } - out: - UNLOCK(bm); -} - -/* Build the list of buffers to validate. Note that the buffer list - * isn't a shared structure so we don't need mutexes when manipulating - * it. - * - * XXX: need refcounting for drmMMBuf structs so that they can't be - * deleted while on these lists. - */ -struct _drmMMBufList * -bmNewBufferList(void) -{ - return drmMMInitListHead(); -} - -int -bmAddBuffer(struct intel_context *intel, - struct _drmMMBufList *list, - struct buffer *buffer, - unsigned flags, - unsigned *memtype_return, unsigned long *offset_return) -{ - assert(buffer); - return drmMMBufListAdd(list, &buffer->drm_buf, 0, flags, memtype_return, offset_return); -} - -void -bmFreeBufferList(struct _drmMMBufList *list) -{ - drmMMFreeBufList(list); -} - -int -bmScanBufferList(struct intel_context *intel, - struct _drmMMBufList *list, struct buffer *buffer) -{ - return drmMMScanBufList(list, &buffer->drm_buf); -} - -/* To be called prior to emitting commands to hardware which reference - * these buffers. The buffer_usage list provides information on where - * the buffers should be placed and whether their contents need to be - * preserved on copying. The offset and pool data elements are return - * values from this function telling the driver exactly where the - * buffers are currently located. - */ - -int -bmValidateBufferList(struct intel_context *intel, - struct _drmMMBufList *list, unsigned flags) -{ - BM_CKFATAL(drmMMValidateBuffers(intel->driFd, list)); - return 0; -} - -/* After commands are emitted but before unlocking, this must be - * called so that the buffer manager can correctly age the buffers. - * The buffer manager keeps track of the list of validated buffers, so - * already knows what to apply the fence to. - * - * The buffer manager knows how to emit and test fences directly - * through the drm and without callbacks or whatever into the driver. - */ -unsigned -bmFenceBufferList(struct intel_context *intel, struct _drmMMBufList *list) -{ - drmFence fence; - - BM_CKFATAL(drmMMFenceBuffers(intel->driFd, list)); - BM_CKFATAL(drmEmitFence(intel->driFd, 0, &fence)); - - return fence.fenceSeq; -} - -/* This functionality is used by the buffer manager, not really sure - * if we need to be exposing it in this way, probably libdrm will - * offer equivalent calls. - * - * For now they can stay, but will likely change/move before final: - */ -unsigned -bmSetFence(struct intel_context *intel) -{ - drmFence dFence; - - BM_CKFATAL(drmEmitFence(intel->driFd, 0, &dFence)); - - return dFence.fenceSeq; -} - -int -bmTestFence(struct intel_context *intel, unsigned fence) -{ - drmFence dFence; - int retired; - - dFence.fenceType = 0; - dFence.fenceSeq = fence; - BM_CKFATAL(drmTestFence(intel->driFd, dFence, 0, &retired)); - return retired; -} - -void -bmFinishFence(struct intel_context *intel, unsigned fence) -{ - drmFence dFence; - dFence.fenceType = 0; - dFence.fenceSeq = fence; - BM_CKFATAL(drmWaitFence(intel->driFd, dFence)); - intel->bm->initFence = dFence; -} - -unsigned -bmInitFence(struct intel_context *intel) -{ - return intel->bm->initFence.fenceSeq; -} diff --git a/src/mesa/drivers/dri/i915/intel_bufmgr.h b/src/mesa/drivers/dri/i915/intel_bufmgr.h deleted file mode 100644 index 3be1656c33b..00000000000 --- a/src/mesa/drivers/dri/i915/intel_bufmgr.h +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Steamboat Springs, CO. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -#ifndef BUFMGR_H -#define BUFMGR_H - -#include "intel_context.h" - - -/* The buffer manager context. Opaque. - */ -struct bufmgr; -struct buffer; - -struct bufmgr *bm_intel_Attach(struct intel_context *intel); - -#define BM_BATCHBUFFER 0x10000000 /* for map - pointer will be accessed - * without dri lock */ - -/* Stick closely to ARB_vbo semantics - they're well defined and - * understood, and drivers can just pass the calls through without too - * much thunking. - */ -void bmGenBuffers(struct intel_context *, - const char *name, - unsigned n, struct buffer **buffers, - unsigned flags); - -void bmDeleteBuffers(struct intel_context *, unsigned n, struct buffer **buffers); - -/* The driver has more intimate knowledge of the hardare than a GL - * client would, so flags here is more proscriptive than the usage - * values in the ARB_vbo interface: - */ -void bmBufferData(struct intel_context *, - struct buffer *buffer, - unsigned size, const void *data, unsigned flags); - -void bmBufferSubData(struct intel_context *, - struct buffer *buffer, - unsigned offset, unsigned size, const void *data); - -void bmBufferGetSubData(struct intel_context *, - struct buffer *buffer, - unsigned offset, unsigned size, void *data); - -void *bmMapBuffer(struct intel_context *, struct buffer *buffer, unsigned access); - -void bmUnmapBuffer(struct intel_context *, struct buffer *buffer); - -/* To be called prior to emitting commands to hardware which reference - * these buffers. - * - * NewBufferList() and AddBuffer() build up a list of buffers to be - * validated. The buffer list provides information on where the - * buffers should be placed and whether their contents need to be - * preserved on copying. The offset data elements are return values - * from this function telling the driver exactly where the buffers are - * currently located. - * - * ValidateBufferList() performs the actual validation and returns the - * buffer pools and offsets within the pools. - * - * FenceBufferList() must be called to set fences and other - * housekeeping before unlocking after a successful call to - * ValidateBufferList(). The buffer manager knows how to emit and test - * fences directly through the drm and without callbacks to the - * driver. - */ -struct _drmMMBufList *bmNewBufferList(void); - -int bmAddBuffer(struct intel_context *, - struct _drmMMBufList *list, - struct buffer *buffer, - unsigned flags, - unsigned *pool_return, unsigned long *offset_return); - -int bmValidateBufferList(struct intel_context *, - struct _drmMMBufList *, unsigned flags); - -unsigned bmFenceBufferList(struct intel_context *, struct _drmMMBufList *); - -void bmFreeBufferList(struct _drmMMBufList *); - -int bmScanBufferList(struct intel_context *, - struct _drmMMBufList *list, struct buffer *buffer); - -/* This functionality is used by the buffer manager, not really sure - * if we need to be exposing it in this way, probably libdrm will - * offer equivalent calls. - * - * For now they can stay, but will likely change/move before final: - */ -unsigned bmSetFence(struct intel_context *); -int bmTestFence(struct intel_context *, unsigned fence); -void bmFinishFence(struct intel_context *, unsigned fence); -unsigned bmInitFence(struct intel_context *); -void bmSetShared(struct intel_context *, struct buffer *buffer, - unsigned flags, unsigned long offset, void *virtual); - -#endif diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index b7104a08b4b..6c757da464a 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -60,11 +60,9 @@ #include "intel_buffer_objects.h" #include "intel_fbo.h" -#include "intel_bufmgr.h" - #include "vblank.h" #include "utils.h" -#include "xmlpool.h" /* for symbolic values of enum-type options */ +#include "xmlpool.h" /* for symbolic values of enum-type options */ #ifndef INTEL_DEBUG int INTEL_DEBUG = (0); #endif @@ -94,39 +92,49 @@ _glthread_Mutex lockMutex; static GLboolean lockMutexInit = GL_FALSE; -static const GLubyte *intelGetString( GLcontext *ctx, GLenum name ) +static const GLubyte * +intelGetString(GLcontext * ctx, GLenum name) { - const char * chipset; + const char *chipset; static char buffer[128]; switch (name) { case GL_VENDOR: - return (GLubyte *)"Tungsten Graphics, Inc"; + return (GLubyte *) "Tungsten Graphics, Inc"; break; - + case GL_RENDERER: switch (intel_context(ctx)->intelScreen->deviceID) { case PCI_CHIP_845_G: - chipset = "Intel(R) 845G"; break; + chipset = "Intel(R) 845G"; + break; case PCI_CHIP_I830_M: - chipset = "Intel(R) 830M"; break; + chipset = "Intel(R) 830M"; + break; case PCI_CHIP_I855_GM: - chipset = "Intel(R) 852GM/855GM"; break; + chipset = "Intel(R) 852GM/855GM"; + break; case PCI_CHIP_I865_G: - chipset = "Intel(R) 865G"; break; + chipset = "Intel(R) 865G"; + break; case PCI_CHIP_I915_G: - chipset = "Intel(R) 915G"; break; + chipset = "Intel(R) 915G"; + break; case PCI_CHIP_I915_GM: - chipset = "Intel(R) 915GM"; break; + chipset = "Intel(R) 915GM"; + break; case PCI_CHIP_I945_G: - chipset = "Intel(R) 945G"; break; + chipset = "Intel(R) 945G"; + break; case PCI_CHIP_I945_GM: - chipset = "Intel(R) 945GM"; break; + chipset = "Intel(R) 945GM"; + break; default: - chipset = "Unknown Intel Chipset"; break; + chipset = "Unknown Intel Chipset"; + break; } - (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 ); + (void) driGetRendererString(buffer, chipset, DRIVER_DATE, 0); return (GLubyte *) buffer; default: @@ -142,51 +150,51 @@ static const GLubyte *intelGetString( GLcontext *ctx, GLenum name ) * It appears that ARB_texture_env_crossbar has "disappeared" compared to the * old i830-specific driver. */ -const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multisample", GL_ARB_multisample_functions }, - { "GL_ARB_multitexture", NULL }, - { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, - { "GL_ARB_texture_border_clamp", NULL }, - { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, - { "GL_ARB_texture_cube_map", NULL }, - { "GL_ARB_texture_env_add", NULL }, - { "GL_ARB_texture_env_combine", NULL }, - { "GL_ARB_texture_env_dot3", NULL }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_ARB_texture_rectangle", NULL }, - { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, - { "GL_ARB_pixel_buffer_object", NULL }, - { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, - { "GL_ARB_window_pos", GL_ARB_window_pos_functions }, - { "GL_EXT_blend_color", GL_EXT_blend_color_functions }, - { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions }, - { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, - { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions }, - { "GL_EXT_blend_subtract", NULL }, - { "GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, - { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, -#if 1 /* XXX FBO temporary? */ - { "GL_EXT_packed_depth_stencil", NULL }, +const struct dri_extension card_extensions[] = { + {"GL_ARB_multisample", GL_ARB_multisample_functions}, + {"GL_ARB_multitexture", NULL}, + {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, + {"GL_ARB_texture_border_clamp", NULL}, + {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, + {"GL_ARB_texture_cube_map", NULL}, + {"GL_ARB_texture_env_add", NULL}, + {"GL_ARB_texture_env_combine", NULL}, + {"GL_ARB_texture_env_dot3", NULL}, + {"GL_ARB_texture_mirrored_repeat", NULL}, + {"GL_ARB_texture_rectangle", NULL}, + {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, + {"GL_ARB_pixel_buffer_object", NULL}, + {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, + {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, + {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, + {"GL_EXT_blend_equation_separate", + GL_EXT_blend_equation_separate_functions}, + {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, + {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, + {"GL_EXT_blend_subtract", NULL}, + {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, + {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, + {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, + {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, +#if 1 /* XXX FBO temporary? */ + {"GL_EXT_packed_depth_stencil", NULL}, #endif - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_edge_clamp", NULL }, - { "GL_EXT_texture_env_combine", NULL }, - { "GL_EXT_texture_env_dot3", NULL }, - { "GL_EXT_texture_filter_anisotropic", NULL }, - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_3DFX_texture_compression_FXT1", NULL }, - { "GL_APPLE_client_storage", NULL }, - { "GL_MESA_pack_invert", NULL }, - { "GL_MESA_ycbcr_texture", NULL }, - { "GL_NV_blend_square", NULL }, - { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, - { "GL_NV_vertex_program1_1", NULL }, + {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, + {"GL_EXT_stencil_wrap", NULL}, + {"GL_EXT_texture_edge_clamp", NULL}, + {"GL_EXT_texture_env_combine", NULL}, + {"GL_EXT_texture_env_dot3", NULL}, + {"GL_EXT_texture_filter_anisotropic", NULL}, + {"GL_EXT_texture_lod_bias", NULL}, + {"GL_3DFX_texture_compression_FXT1", NULL}, + {"GL_APPLE_client_storage", NULL}, + {"GL_MESA_pack_invert", NULL}, + {"GL_MESA_ycbcr_texture", NULL}, + {"GL_NV_blend_square", NULL}, + {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, + {"GL_NV_vertex_program1_1", NULL}, /* { "GL_SGIS_generate_mipmap", NULL }, */ - { NULL, NULL } + {NULL, NULL} }; extern const struct tnl_pipeline_stage _intel_render_stage; @@ -203,55 +211,56 @@ static const struct tnl_pipeline_stage *intel_pipeline[] = { &_tnl_arb_vertex_program_stage, &_tnl_vertex_program_stage, #if 1 - &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */ + &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */ #endif &_tnl_render_stage, 0, }; -static const struct dri_debug_control debug_control[] = -{ - { "fall", DEBUG_FALLBACKS }, - { "tex", DEBUG_TEXTURE }, - { "ioctl", DEBUG_IOCTL }, - { "blit", DEBUG_BLIT }, - { "vert", DEBUG_VERTS }, - { "state", DEBUG_STATE }, - { "verb", DEBUG_VERBOSE }, - { "dri", DEBUG_DRI }, - { "bat", DEBUG_BATCH }, - { "san", DEBUG_SANITY }, - { "sync", DEBUG_SYNC }, - { "sleep", DEBUG_SLEEP }, - { "pix", DEBUG_PIXEL }, - { "buf", DEBUG_BUFMGR }, - { NULL, 0 } +static const struct dri_debug_control debug_control[] = { + {"fall", DEBUG_FALLBACKS}, + {"tex", DEBUG_TEXTURE}, + {"ioctl", DEBUG_IOCTL}, + {"blit", DEBUG_BLIT}, + {"vert", DEBUG_VERTS}, + {"state", DEBUG_STATE}, + {"verb", DEBUG_VERBOSE}, + {"dri", DEBUG_DRI}, + {"bat", DEBUG_BATCH}, + {"san", DEBUG_SANITY}, + {"sync", DEBUG_SYNC}, + {"sleep", DEBUG_SLEEP}, + {"pix", DEBUG_PIXEL}, + {"buf", DEBUG_BUFMGR}, + {NULL, 0} }; -static void intelInvalidateState( GLcontext *ctx, GLuint new_state ) +static void +intelInvalidateState(GLcontext * ctx, GLuint new_state) { - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _ac_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - _tnl_invalidate_vertex_state( ctx, new_state ); + _swrast_InvalidateState(ctx, new_state); + _swsetup_InvalidateState(ctx, new_state); + _ac_InvalidateState(ctx, new_state); + _tnl_InvalidateState(ctx, new_state); + _tnl_invalidate_vertex_state(ctx, new_state); intel_context(ctx)->NewGLState |= new_state; } -void intelFlush( GLcontext *ctx ) +void +intelFlush(GLcontext * ctx) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); if (intel->Fallback) - _swrast_flush( ctx ); + _swrast_flush(ctx); - INTEL_FIREVERTICES( intel ); + INTEL_FIREVERTICES(intel); if (intel->batch->map != intel->batch->ptr) - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); /* XXX: Need to do an MI_FLUSH here. Actually, the bufmgr_fake.c * code will have done one already. @@ -272,11 +281,11 @@ void intelFlush( GLcontext *ctx ) * Note that these don't allocate video memory, just describe * allocations alread made by the X server. */ -static void -intel_recreate_static_regions( struct intel_context *intel ) +static void +intel_recreate_static_regions(struct intel_context *intel) { intelScreenPrivate *intelScreen = intel->intelScreen; - + if (intel->front_region) intel_region_release(intel, &intel->front_region); @@ -288,46 +297,46 @@ intel_recreate_static_regions( struct intel_context *intel ) if (intel->depth_region) intel_region_release(intel, &intel->depth_region); - - intel->front_region = + + intel->front_region = intel_region_create_static(intel, - DRM_MM_TT, - intelScreen->front.offset, - intelScreen->front.map, - intelScreen->cpp, - intelScreen->front.pitch / intelScreen->cpp, - intelScreen->height); + DRM_BO_FLAG_MEM_TT, + intelScreen->front.offset, + intelScreen->front.map, + intelScreen->cpp, + intelScreen->front.pitch / intelScreen->cpp, + intelScreen->height); - intel->rotated_region = + intel->rotated_region = intel_region_create_static(intel, - DRM_MM_TT, - intelScreen->rotated.offset, - intelScreen->rotated.map, - intelScreen->cpp, - intelScreen->rotated.pitch / intelScreen->cpp, - intelScreen->height); + DRM_BO_FLAG_MEM_TT, + intelScreen->rotated.offset, + intelScreen->rotated.map, + intelScreen->cpp, + intelScreen->rotated.pitch / + intelScreen->cpp, intelScreen->height); - intel->back_region = + intel->back_region = intel_region_create_static(intel, - DRM_MM_TT, - intelScreen->back.offset, - intelScreen->back.map, - intelScreen->cpp, - intelScreen->back.pitch / intelScreen->cpp, - intelScreen->height); + DRM_BO_FLAG_MEM_TT, + intelScreen->back.offset, + intelScreen->back.map, + intelScreen->cpp, + intelScreen->back.pitch / intelScreen->cpp, + intelScreen->height); /* Still assuming front.cpp == depth.cpp */ - intel->depth_region = + intel->depth_region = intel_region_create_static(intel, - DRM_MM_TT, - intelScreen->depth.offset, - intelScreen->depth.map, - intelScreen->cpp, - intelScreen->depth.pitch / intelScreen->cpp, - intelScreen->height); + DRM_BO_FLAG_MEM_TT, + intelScreen->depth.offset, + intelScreen->depth.map, + intelScreen->cpp, + intelScreen->depth.pitch / intelScreen->cpp, + intelScreen->height); } @@ -337,10 +346,11 @@ intel_recreate_static_regions( struct intel_context *intel ) * or glFinish after drawing to the front color buffer. */ static void -intelCheckFrontRotate(GLcontext *ctx) +intelCheckFrontRotate(GLcontext * ctx) { - struct intel_context *intel = intel_context( ctx ); - if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + struct intel_context *intel = intel_context(ctx); + if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == + BUFFER_BIT_FRONT_LEFT) { intelScreenPrivate *screen = intel->intelScreen; if (screen->current_rotation != 0) { __DRIdrawablePrivate *dPriv = intel->driDrawable; @@ -353,24 +363,32 @@ intelCheckFrontRotate(GLcontext *ctx) /** * Called via glFlush. */ -static void intelglFlush( GLcontext *ctx ) +static void +intelglFlush(GLcontext * ctx) { intelFlush(ctx); intelCheckFrontRotate(ctx); } -void intelFinish( GLcontext *ctx ) +void +intelFinish(GLcontext * ctx) { - struct intel_context *intel = intel_context( ctx ); - intelFlush( ctx ); - bmFinishFence( intel, intel->batch->last_fence ); + struct intel_context *intel = intel_context(ctx); + intelFlush(ctx); + if (intel->batch->last_fence) { + driFenceFinish(intel->batch->last_fence, + DRM_FENCE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE); + driFenceUnReference(intel->batch->last_fence); + intel->batch->last_fence = NULL; + } intelCheckFrontRotate(ctx); } -void intelInitDriverFunctions( struct dd_function_table *functions ) +void +intelInitDriverFunctions(struct dd_function_table *functions) { - _mesa_init_driver_functions( functions ); + _mesa_init_driver_functions(functions); functions->Flush = intelglFlush; functions->Finish = intelFinish; @@ -381,31 +399,31 @@ void intelInitDriverFunctions( struct dd_function_table *functions ) functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; - intelInitTextureFuncs( functions ); - intelInitPixelFuncs( functions ); - intelInitStateFuncs( functions ); - intelInitBufferFuncs( functions ); + intelInitTextureFuncs(functions); + intelInitPixelFuncs(functions); + intelInitStateFuncs(functions); + intelInitBufferFuncs(functions); } -GLboolean intelInitContext( struct intel_context *intel, - const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate, - struct dd_function_table *functions ) +GLboolean +intelInitContext(struct intel_context *intel, + const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate, + struct dd_function_table *functions) { GLcontext *ctx = &intel->ctx; GLcontext *shareCtx = (GLcontext *) sharedContextPrivate; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; drmI830Sarea *saPriv = (drmI830Sarea *) - (((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset); + (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset); int fthrottle_mode; if (!_mesa_initialize_context(&intel->ctx, - mesaVis, shareCtx, - functions, - (void*) intel)) + mesaVis, shareCtx, + functions, (void *) intel)) return GL_FALSE; driContextPriv->driverPrivate = intel; @@ -418,8 +436,8 @@ GLboolean intelInitContext( struct intel_context *intel, _glthread_INIT_MUTEX(lockMutex); } - driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache, - intel->driScreen->myNum, "i915"); + driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache, + intel->driScreen->myNum, "i915"); ctx->Const.MaxTextureMaxAnisotropy = 2.0; @@ -435,46 +453,46 @@ GLboolean intelInitContext( struct intel_context *intel, ctx->Const.MaxPointSizeAA = 3.0; ctx->Const.PointSizeGranularity = 1.0; - ctx->Const.MaxColorAttachments = 4; /* XXX FBO: review this */ + ctx->Const.MaxColorAttachments = 4; /* XXX FBO: review this */ /* Initialize the software rasterizer and helper modules. */ - _swrast_CreateContext( ctx ); - _ac_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); + _swrast_CreateContext(ctx); + _ac_CreateContext(ctx); + _tnl_CreateContext(ctx); + _swsetup_CreateContext(ctx); /* Install the customized pipeline: */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, intel_pipeline ); + _tnl_destroy_pipeline(ctx); + _tnl_install_pipeline(ctx, intel_pipeline); /* Configure swrast to match hardware characteristics: */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); + _swrast_allow_pixel_fog(ctx, GL_FALSE); + _swrast_allow_vertex_fog(ctx, GL_TRUE); /* Dri stuff */ intel->hHWContext = driContextPriv->hHWContext; intel->driFd = sPriv->fd; - intel->driHwLock = (drmLock *) &sPriv->pSAREA->lock; + intel->driHwLock = (drmLock *) & sPriv->pSAREA->lock; intel->hw_stipple = 1; /* XXX FBO: this doesn't seem to be used anywhere */ - switch(mesaVis->depthBits) { - case 0: /* what to do in this case? */ + switch (mesaVis->depthBits) { + case 0: /* what to do in this case? */ case 16: - intel->polygon_offset_scale = 1.0/0xffff; + intel->polygon_offset_scale = 1.0 / 0xffff; break; case 24: - intel->polygon_offset_scale = 2.0/0xffffff; /* req'd to pass glean */ + intel->polygon_offset_scale = 2.0 / 0xffffff; /* req'd to pass glean */ break; default: - assert(0); + assert(0); break; } /* Initialize swrast, tnl driver tables: */ - intelInitSpanFuncs( ctx ); - intelInitTriFuncs( ctx ); + intelInitSpanFuncs(ctx); + intelInitTriFuncs(ctx); intel->RenderIndex = ~0; @@ -484,89 +502,87 @@ GLboolean intelInitContext( struct intel_context *intel, intel->irqsEmitted = 0; intel->do_irqs = (intel->intelScreen->irq_active && - fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS); + fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS); intel->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS); intel->vblank_flags = (intel->intelScreen->irq_active != 0) - ? driGetDefaultVBlankFlags(&intelScreen->optionCache) : VBLANK_FLAG_NO_IRQ; + ? driGetDefaultVBlankFlags(&intelScreen-> + optionCache) : VBLANK_FLAG_NO_IRQ; - (*dri_interface->getUST)(&intel->swap_ust); - _math_matrix_ctr (&intel->ViewportMatrix); + (*dri_interface->getUST) (&intel->swap_ust); + _math_matrix_ctr(&intel->ViewportMatrix); /* Disable imaging extension until convolution is working in * teximage paths: */ - driInitExtensions( ctx, card_extensions, + driInitExtensions(ctx, card_extensions, /* GL_TRUE, */ - GL_FALSE); + GL_FALSE); - /* Buffer manager: - */ - intel->bm = bm_intel_Attach( intel ); + intel->batch = intel_batchbuffer_alloc(intel); + intel->last_swap_fence = NULL; + intel->first_swap_fence = NULL; - intel->batch = intel_batchbuffer_alloc( intel ); - intel->last_swap_fence_retired = GL_TRUE; - intel->last_swap_fence = bmInitFence(intel); - - intel_recreate_static_regions( intel ); - intel_bufferobj_init( intel ); - intel_fbo_init( intel ); + intel_recreate_static_regions(intel); + intel_bufferobj_init(intel); + intel_fbo_init(intel); if (intel->ctx.Mesa_DXTn) { - _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" ); - _mesa_enable_extension( ctx, "GL_S3_s3tc" ); + _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); + _mesa_enable_extension(ctx, "GL_S3_s3tc"); } - else if (driQueryOptionb (&intelScreen->optionCache, "force_s3tc_enable")) { - _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" ); + else if (driQueryOptionb(&intelScreen->optionCache, "force_s3tc_enable")) { + _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); } intel->prim.primitive = ~0; #if DO_DEBUG - INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ), - debug_control ); + INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control); #endif if (getenv("INTEL_NO_RAST")) { fprintf(stderr, "disabling 3D rasterization\n"); - FALLBACK(intel, INTEL_FALLBACK_USER, 1); + FALLBACK(intel, INTEL_FALLBACK_USER, 1); } return GL_TRUE; } -void intelDestroyContext(__DRIcontextPrivate *driContextPriv) +void +intelDestroyContext(__DRIcontextPrivate * driContextPriv) { - struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + struct intel_context *intel = + (struct intel_context *) driContextPriv->driverPrivate; - assert(intel); /* should never be null */ + assert(intel); /* should never be null */ if (intel) { - GLboolean release_texture_heaps; + GLboolean release_texture_heaps; - INTEL_FIREVERTICES( intel ); + INTEL_FIREVERTICES(intel); - intel->vtbl.destroy( intel ); + intel->vtbl.destroy(intel); release_texture_heaps = (intel->ctx.Shared->RefCount == 1); - _swsetup_DestroyContext (&intel->ctx); - _tnl_DestroyContext (&intel->ctx); - _ac_DestroyContext (&intel->ctx); + _swsetup_DestroyContext(&intel->ctx); + _tnl_DestroyContext(&intel->ctx); + _ac_DestroyContext(&intel->ctx); - _swrast_DestroyContext (&intel->ctx); - intel->Fallback = 0; /* don't call _swrast_Flush later */ + _swrast_DestroyContext(&intel->ctx); + intel->Fallback = 0; /* don't call _swrast_Flush later */ intel_batchbuffer_free(intel->batch); - - if ( release_texture_heaps ) { + + if (release_texture_heaps) { /* This share group is about to go away, free our private * texture object data. */ - if (INTEL_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, "do something to free texture heaps\n"); + if (INTEL_DEBUG & DEBUG_TEXTURE) + fprintf(stderr, "do something to free texture heaps\n"); } /* free the Mesa context */ @@ -574,27 +590,30 @@ void intelDestroyContext(__DRIcontextPrivate *driContextPriv) } } -GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv) +GLboolean +intelUnbindContext(__DRIcontextPrivate * driContextPriv) { return GL_TRUE; } -GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) +GLboolean +intelMakeCurrent(__DRIcontextPrivate * driContextPriv, + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv) { if (driContextPriv) { - struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + struct intel_context *intel = + (struct intel_context *) driContextPriv->driverPrivate; GLframebuffer *drawFb = (GLframebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; - if ( intel->driDrawable != driDrawPriv ) { - /* Shouldn't the readbuffer be stored also? */ - driDrawableInitVBlank( driDrawPriv, intel->vblank_flags ); + if (intel->driDrawable != driDrawPriv) { + /* Shouldn't the readbuffer be stored also? */ + driDrawableInitVBlank(driDrawPriv, intel->vblank_flags); - intel->driDrawable = driDrawPriv; - intelWindowMoved( intel ); + intel->driDrawable = driDrawPriv; + intelWindowMoved(intel); } /* XXX FBO temporary fix-ups! */ @@ -640,10 +659,9 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv, */ static void intelUpdateScreenRotation(struct intel_context *intel, - __DRIscreenPrivate *sPriv, - drmI830Sarea *sarea) + __DRIscreenPrivate * sPriv, drmI830Sarea * sarea) { - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; intelRegion *colorBuf; intelUnmapScreenRegions(intelScreen); @@ -662,12 +680,13 @@ intelUpdateScreenRotation(struct intel_context *intel, intel_recreate_static_regions(intel); } -void intelGetLock( struct intel_context *intel, GLuint flags ) +void +intelGetLock(struct intel_context *intel, GLuint flags) { __DRIdrawablePrivate *dPriv = intel->driDrawable; __DRIscreenPrivate *sPriv = intel->driScreen; - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; - drmI830Sarea * sarea = intel->sarea; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; + drmI830Sarea *sarea = intel->sarea; drmGetLock(intel->driFd, intel->hHWContext, flags); @@ -693,7 +712,7 @@ void intelGetLock( struct intel_context *intel, GLuint flags ) intel->prim.flush = 0; /* re-emit all state */ - intel->vtbl.lost_hardware( intel ); + intel->vtbl.lost_hardware(intel); /* force window update */ intel->lastStamp = 0; @@ -703,8 +722,7 @@ void intelGetLock( struct intel_context *intel, GLuint flags ) /* Drawable changed? */ if (dPriv && intel->lastStamp != dPriv->lastStamp) { - intelWindowMoved( intel ); + intelWindowMoved(intel); intel->lastStamp = dPriv->lastStamp; } } - diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h index 150baffc4ea..85fdd22855c 100644 --- a/src/mesa/drivers/dri/i915/intel_context.h +++ b/src/mesa/drivers/dri/i915/intel_context.h @@ -50,12 +50,13 @@ struct intel_region; struct intel_context; -struct buffer; +struct _DriBufferObject; -typedef void (*intel_tri_func)(struct intel_context *, intelVertex *, intelVertex *, - intelVertex *); -typedef void (*intel_line_func)(struct intel_context *, intelVertex *, intelVertex *); -typedef void (*intel_point_func)(struct intel_context *, intelVertex *); +typedef void (*intel_tri_func) (struct intel_context *, intelVertex *, + intelVertex *, intelVertex *); +typedef void (*intel_line_func) (struct intel_context *, intelVertex *, + intelVertex *); +typedef void (*intel_point_func) (struct intel_context *, intelVertex *); #define INTEL_FALLBACK_DRAW_BUFFER 0x1 #define INTEL_FALLBACK_READ_BUFFER 0x2 @@ -64,7 +65,8 @@ typedef void (*intel_point_func)(struct intel_context *, intelVertex *); #define INTEL_FALLBACK_USER 0x10 #define INTEL_FALLBACK_RENDERMODE 0x20 -extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode ); +extern void intelFallback(struct intel_context *intel, GLuint bit, + GLboolean mode); #define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode ) @@ -74,7 +76,7 @@ extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mo struct intel_texture_object { - struct gl_texture_object base; /* The "parent" object */ + struct gl_texture_object base; /* The "parent" object */ /* The mipmap tree must include at least these levels once * validated: @@ -94,7 +96,7 @@ struct intel_texture_object -struct intel_texture_image +struct intel_texture_image { struct gl_texture_image base; @@ -115,79 +117,79 @@ struct intel_texture_image struct intel_context { - GLcontext ctx; /* the parent class */ + GLcontext ctx; /* the parent class */ - struct { - void (*destroy)( struct intel_context *intel ); - void (*emit_state)( struct intel_context *intel ); - void (*lost_hardware)( struct intel_context *intel ); - void (*update_texture_state)( struct intel_context *intel ); + struct + { + void (*destroy) (struct intel_context * intel); + void (*emit_state) (struct intel_context * intel); + void (*lost_hardware) (struct intel_context * intel); + void (*update_texture_state) (struct intel_context * intel); - void (*render_start)( struct intel_context *intel ); - void (*set_draw_region)( struct intel_context *intel, - struct intel_region *draw_region, - struct intel_region *depth_region ); + void (*render_start) (struct intel_context * intel); + void (*set_draw_region) (struct intel_context * intel, + struct intel_region * draw_region, + struct intel_region * depth_region); - GLuint (*flush_cmd)( void ); + GLuint(*flush_cmd) (void); - void (*reduced_primitive_state)( struct intel_context *intel, GLenum rprim ); + void (*reduced_primitive_state) (struct intel_context * intel, + GLenum rprim); - GLboolean (*check_vertex_size)( struct intel_context *intel, GLuint expected ); + GLboolean(*check_vertex_size) (struct intel_context * intel, + GLuint expected); /* Metaops: */ - void (*install_meta_state)( struct intel_context *intel ); - void (*leave_meta_state)( struct intel_context *intel ); + void (*install_meta_state) (struct intel_context * intel); + void (*leave_meta_state) (struct intel_context * intel); - void (*meta_draw_region)( struct intel_context *intel, - struct intel_region *draw_region, - struct intel_region *depth_region ); + void (*meta_draw_region) (struct intel_context * intel, + struct intel_region * draw_region, + struct intel_region * depth_region); - void (*meta_color_mask)( struct intel_context *intel, - GLboolean ); - - void (*meta_stencil_replace)( struct intel_context *intel, - GLuint mask, - GLuint clear ); + void (*meta_color_mask) (struct intel_context * intel, GLboolean); - void (*meta_depth_replace)( struct intel_context *intel ); + void (*meta_stencil_replace) (struct intel_context * intel, + GLuint mask, GLuint clear); - void (*meta_texture_blend_replace)( struct intel_context *intel ); + void (*meta_depth_replace) (struct intel_context * intel); - void (*meta_no_stencil_write)( struct intel_context *intel ); - void (*meta_no_depth_write)( struct intel_context *intel ); - void (*meta_no_texture)( struct intel_context *intel ); + void (*meta_texture_blend_replace) (struct intel_context * intel); - void (*meta_import_pixel_state)( struct intel_context *intel ); + void (*meta_no_stencil_write) (struct intel_context * intel); + void (*meta_no_depth_write) (struct intel_context * intel); + void (*meta_no_texture) (struct intel_context * intel); - GLboolean (*meta_tex_rect_source)( struct intel_context *intel, - struct buffer *buffer, - GLuint offset, - GLuint pitch, - GLuint height, - GLenum format, - GLenum type); - void (*rotate_window)( struct intel_context *intel, - __DRIdrawablePrivate *dPriv, GLuint srcBuf); + void (*meta_import_pixel_state) (struct intel_context * intel); + + GLboolean(*meta_tex_rect_source) (struct intel_context * intel, + struct _DriBufferObject * buffer, + GLuint offset, + GLuint pitch, + GLuint height, + GLenum format, GLenum type); + void (*rotate_window) (struct intel_context * intel, + __DRIdrawablePrivate * dPriv, GLuint srcBuf); } vtbl; - GLint refcount; + GLint refcount; GLuint Fallback; GLuint NewGLState; - - GLuint last_fence; - GLuint last_swap_fence; - GLboolean last_swap_fence_retired; + + struct _DriFenceObject *last_swap_fence; + struct _DriFenceObject *first_swap_fence; struct intel_batchbuffer *batch; - struct { + struct + { GLuint id; GLuint primitive; - GLubyte *start_ptr; - void (*flush)( struct intel_context * ); + GLubyte *start_ptr; + void (*flush) (struct intel_context *); } prim; GLboolean locked; @@ -207,10 +209,10 @@ struct intel_context struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; GLuint vertex_attr_count; - GLfloat polygon_offset_scale; /* dependent on depth_scale, bpp */ + GLfloat polygon_offset_scale; /* dependent on depth_scale, bpp */ GLboolean hw_stipple; - + /* AGP memory buffer manager: */ struct bufmgr *bm; @@ -223,11 +225,11 @@ struct intel_context GLenum render_primitive; GLenum reduced_primitive; GLuint vertex_size; - GLubyte *verts; /* points to tnl->clipspace.vertex_buf */ + GLubyte *verts; /* points to tnl->clipspace.vertex_buf */ struct intel_region *front_region; /* XXX FBO: obsolete */ - struct intel_region *rotated_region; /* XXX FBO: obsolete */ + struct intel_region *rotated_region; /* XXX FBO: obsolete */ struct intel_region *back_region; /* XXX FBO: obsolete */ struct intel_region *draw_region; /* XXX FBO: rename to color_region */ struct intel_region *depth_region; /**< currently bound depth/Z region */ @@ -242,7 +244,7 @@ struct intel_context /* These refer to the current drawing buffer: */ int drawX, drawY; /**< origin of drawing area within region */ - GLuint numClipRects; /**< cliprects for drawing */ + GLuint numClipRects; /**< cliprects for drawing */ drm_clip_rect_t *pClipRects; drm_clip_rect_t fboRect; /**< cliprect for FBO rendering */ @@ -259,9 +261,9 @@ struct intel_context __DRIdrawablePrivate *driDrawable; __DRIscreenPrivate *driScreen; - intelScreenPrivate *intelScreen; - drmI830Sarea *sarea; - + intelScreenPrivate *intelScreen; + drmI830Sarea *sarea; + GLuint lastStamp; /** @@ -279,6 +281,7 @@ struct intel_context GLuint swap_count; GLuint swap_missed_count; + }; @@ -346,8 +349,8 @@ do { \ DEBUG_LOCK(); \ (intel)->locked = 1; \ }while (0) - - + + /* Unlock the hardware using the global current context */ #define UNLOCK_HARDWARE(intel) \ @@ -396,21 +399,19 @@ do { \ * XXX Put this in src/mesa/main/imports.h ??? */ #if defined(i386) || defined(__i386__) -static INLINE void * __memcpy(void * to, const void * from, size_t n) +static INLINE void * +__memcpy(void *to, const void *from, size_t n) { int d0, d1, d2; - __asm__ __volatile__( - "rep ; movsl\n\t" - "testb $2,%b4\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b4\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) - : "memory"); + __asm__ __volatile__("rep ; movsl\n\t" + "testb $2,%b4\n\t" + "je 1f\n\t" + "movsw\n" + "1:\ttestb $1,%b4\n\t" + "je 2f\n\t" + "movsb\n" "2:":"=&c"(d0), "=&D"(d1), "=&S"(d2) + :"0"(n / 4), "q"(n), "1"((long) to), "2"((long) from) + :"memory"); return (to); } #else @@ -461,25 +462,25 @@ extern int INTEL_DEBUG; * intel_context.c: */ -extern GLboolean intelInitContext( struct intel_context *intel, - const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate, - struct dd_function_table *functions ); +extern GLboolean intelInitContext(struct intel_context *intel, + const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate, + struct dd_function_table *functions); extern void intelGetLock(struct intel_context *intel, GLuint flags); -extern void intelInitState( GLcontext *ctx ); -extern void intelFinish( GLcontext *ctx ); -extern void intelFlush( GLcontext *ctx ); +extern void intelInitState(GLcontext * ctx); +extern void intelFinish(GLcontext * ctx); +extern void intelFlush(GLcontext * ctx); -extern void intelInitDriverFunctions( struct dd_function_table *functions ); +extern void intelInitDriverFunctions(struct dd_function_table *functions); /* ================================================================ * intel_state.c: */ -extern void intelInitStateFuncs( struct dd_function_table *functions ); +extern void intelInitStateFuncs(struct dd_function_table *functions); #define COMPAREFUNC_ALWAYS 0 #define COMPAREFUNC_NEVER 0x1 @@ -536,33 +537,36 @@ extern void intelInitStateFuncs( struct dd_function_table *functions ); #define MI_BATCH_BUFFER_END (0xA<<23) -extern int intel_translate_compare_func( GLenum func ); -extern int intel_translate_stencil_op( GLenum op ); -extern int intel_translate_blend_factor( GLenum factor ); -extern int intel_translate_logic_op( GLenum opcode ); +extern int intel_translate_compare_func(GLenum func); +extern int intel_translate_stencil_op(GLenum op); +extern int intel_translate_blend_factor(GLenum factor); +extern int intel_translate_logic_op(GLenum opcode); /*====================================================================== * Inline conversion functions. * These are better-typed than the macros used previously: */ -static INLINE struct intel_context *intel_context( GLcontext *ctx ) +static INLINE struct intel_context * +intel_context(GLcontext * ctx) { - return (struct intel_context *)ctx; + return (struct intel_context *) ctx; } -static INLINE struct intel_texture_object *intel_texture_object( struct gl_texture_object *obj ) +static INLINE struct intel_texture_object * +intel_texture_object(struct gl_texture_object *obj) { - return (struct intel_texture_object *)obj; + return (struct intel_texture_object *) obj; } -static INLINE struct intel_texture_image *intel_texture_image( struct gl_texture_image *img ) +static INLINE struct intel_texture_image * +intel_texture_image(struct gl_texture_image *img) { - return (struct intel_texture_image *)img; + return (struct intel_texture_image *) img; } -extern struct intel_renderbuffer *intel_renderbuffer( struct gl_renderbuffer *rb ); +extern struct intel_renderbuffer *intel_renderbuffer(struct gl_renderbuffer + *rb); #endif - diff --git a/src/mesa/drivers/dri/i915/intel_depthstencil.c b/src/mesa/drivers/dri/i915/intel_depthstencil.c index 51eb799f920..90baecd8c21 100644 --- a/src/mesa/drivers/dri/i915/intel_depthstencil.c +++ b/src/mesa/drivers/dri/i915/intel_depthstencil.c @@ -89,7 +89,7 @@ static void -map_regions(GLcontext *ctx, +map_regions(GLcontext * ctx, struct intel_renderbuffer *depthRb, struct intel_renderbuffer *stencilRb) { @@ -107,7 +107,7 @@ map_regions(GLcontext *ctx, } static void -unmap_regions(GLcontext *ctx, +unmap_regions(GLcontext * ctx, struct intel_renderbuffer *depthRb, struct intel_renderbuffer *stencilRb) { @@ -131,7 +131,7 @@ unmap_regions(GLcontext *ctx, * irb should be a depth/stencil or stencil renderbuffer. */ void -intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb) +intel_unpair_depth_stencil(GLcontext * ctx, struct intel_renderbuffer *irb) { if (irb->PairedStencil) { /* irb is a depth/stencil buffer */ @@ -191,7 +191,8 @@ intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb) * change, for example). */ void -intel_validate_paired_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb) +intel_validate_paired_depth_stencil(GLcontext * ctx, + struct gl_framebuffer *fb) { struct intel_renderbuffer *depthRb, *stencilRb; @@ -243,8 +244,8 @@ intel_validate_paired_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb) * We'll use a GL_DEPTH24_STENCIL8 buffer and ignore the stencil bits. */ /* can't assert this until storage is allocated: - ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT); - */ + ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT); + */ /* intel_undo any previous pairing */ if (depthRb->PairedStencil) { intel_unpair_depth_stencil(ctx, depthRb); diff --git a/src/mesa/drivers/dri/i915/intel_depthstencil.h b/src/mesa/drivers/dri/i915/intel_depthstencil.h index 33699535664..2d3fc48b3a3 100644 --- a/src/mesa/drivers/dri/i915/intel_depthstencil.h +++ b/src/mesa/drivers/dri/i915/intel_depthstencil.h @@ -4,10 +4,11 @@ extern void -intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb); +intel_unpair_depth_stencil(GLcontext * ctx, struct intel_renderbuffer *irb); extern void -intel_validate_paired_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb); +intel_validate_paired_depth_stencil(GLcontext * ctx, + struct gl_framebuffer *fb); #endif /* INTEL_DEPTH_STENCIL_H */ diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c index 0c1a0840bde..0f77f9578b0 100644 --- a/src/mesa/drivers/dri/i915/intel_fbo.c +++ b/src/mesa/drivers/dri/i915/intel_fbo.c @@ -37,7 +37,6 @@ #include "intel_context.h" #include "intel_buffers.h" -#include "intel_bufmgr.h" #include "intel_depthstencil.h" #include "intel_fbo.h" #include "intel_mipmap_tree.h" @@ -53,7 +52,8 @@ * NULL will be returned if the rb isn't really an intel_renderbuffer. * This is determiend by checking the ClassID. */ -struct intel_renderbuffer *intel_renderbuffer( struct gl_renderbuffer *rb ) +struct intel_renderbuffer * +intel_renderbuffer(struct gl_renderbuffer *rb) { struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb; if (irb && irb->Base.ClassID == INTEL_RB_CLASS) { @@ -89,7 +89,7 @@ intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex) * Create a new framebuffer object. */ static struct gl_framebuffer * -intel_new_framebuffer(GLcontext *ctx, GLuint name) +intel_new_framebuffer(GLcontext * ctx, GLuint name) { /* there's no intel_framebuffer at this time, just use Mesa's class */ return _mesa_new_framebuffer(ctx, name); @@ -122,7 +122,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb) * Return a pointer to a specific pixel in a renderbuffer. */ static void * -intel_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, +intel_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb, GLint x, GLint y) { /* By returning NULL we force all software rendering to go through @@ -138,7 +138,7 @@ intel_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, * storage for a user-created renderbuffer. */ static GLboolean -intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, +intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { @@ -215,7 +215,8 @@ intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, cpp = 4; break; default: - _mesa_problem(ctx, "Unexpected format in intel_alloc_renderbuffer_storage"); + _mesa_problem(ctx, + "Unexpected format in intel_alloc_renderbuffer_storage"); return GL_FALSE; } @@ -223,9 +224,9 @@ intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /* free old region */ if (irb->region) { - /*LOCK_HARDWARE(intel);*/ + /*LOCK_HARDWARE(intel); */ intel_region_release(intel, &irb->region); - /*UNLOCK_HARDWARE(intel);*/ + /*UNLOCK_HARDWARE(intel); */ } /* allocate new memory region/renderbuffer */ @@ -239,11 +240,12 @@ intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint pitch = ((cpp * width + 63) & ~63) / cpp; /* alloc hardware renderbuffer */ - _mesa_debug(ctx, "Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch); + _mesa_debug(ctx, "Allocating %d x %d Intel RBO (pitch %d)\n", width, + height, pitch); irb->region = intel_region_alloc(intel, cpp, pitch, height); if (!irb->region) - return GL_FALSE; /* out of memory? */ + return GL_FALSE; /* out of memory? */ ASSERT(irb->region->buffer); @@ -265,9 +267,8 @@ intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, * Not used for user-created renderbuffers! */ static GLboolean -intel_alloc_window_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) +intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) { ASSERT(rb->Name == 0); rb->Width = width; @@ -278,9 +279,8 @@ intel_alloc_window_storage(GLcontext *ctx, struct gl_renderbuffer *rb, static GLboolean -intel_nop_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) +intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) { _mesa_problem(ctx, "intel_op_alloc_storage should never be called."); return GL_FALSE; @@ -299,7 +299,7 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, int offset, int pitch, int cpp, void *map) { GET_CURRENT_CONTEXT(ctx); - + struct intel_renderbuffer *irb; const GLuint name = 0; @@ -362,7 +362,8 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, cpp = 4; break; default: - _mesa_problem(NULL, "Unexpected intFormat in intel_create_renderbuffer"); + _mesa_problem(NULL, + "Unexpected intFormat in intel_create_renderbuffer"); return NULL; } @@ -381,10 +382,7 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, #if 00 irb->region = intel_region_create_static(intel, DRM_MM_TT, - offset, - map, - cpp, - width, height); + offset, map, cpp, width, height); #endif return irb; @@ -396,9 +394,9 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, * Typically called via glBindRenderbufferEXT(). */ static struct gl_renderbuffer * -intel_new_renderbuffer(GLcontext *ctx, GLuint name) +intel_new_renderbuffer(GLcontext * ctx, GLuint name) { - /*struct intel_context *intel = intel_context(ctx);*/ + /*struct intel_context *intel = intel_context(ctx); */ struct intel_renderbuffer *irb; irb = CALLOC_STRUCT(intel_renderbuffer); @@ -424,12 +422,12 @@ intel_new_renderbuffer(GLcontext *ctx, GLuint name) * Called via glBindFramebufferEXT(). */ static void -intel_bind_framebuffer(GLcontext *ctx, GLenum target, +intel_bind_framebuffer(GLcontext * ctx, GLenum target, struct gl_framebuffer *fb) { /* - _mesa_debug(ctx, "%s %d\n", __FUNCTION__, fb->Name); - */ + _mesa_debug(ctx, "%s %d\n", __FUNCTION__, fb->Name); + */ /* XXX FBO: putting this flush here fixes a rendering offset bug. * Not sure why this is needed when _mesa_BindFrameBuffer does * a FLUSH_VERTICES(). @@ -451,15 +449,14 @@ intel_bind_framebuffer(GLcontext *ctx, GLenum target, * Called via glFramebufferRenderbufferEXT(). */ static void -intel_framebuffer_renderbuffer(GLcontext *ctx, +intel_framebuffer_renderbuffer(GLcontext * ctx, struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb) + GLenum attachment, struct gl_renderbuffer *rb) { /* - _mesa_debug(ctx, "Intel FramebufferRenderbuffer %u %u\n", - fb->Name, rb ? rb->Name : 0); - */ + _mesa_debug(ctx, "Intel FramebufferRenderbuffer %u %u\n", + fb->Name, rb ? rb->Name : 0); + */ intelFlush(ctx); @@ -474,9 +471,9 @@ intel_framebuffer_renderbuffer(GLcontext *ctx, * This will have the region info needed for hardware rendering. */ static struct intel_renderbuffer * -intel_wrap_texture(GLcontext *ctx, struct gl_texture_image *texImage) +intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage) { - const GLuint name = ~0; /* not significant, but distinct for debugging */ + const GLuint name = ~0; /* not significant, but distinct for debugging */ struct intel_renderbuffer *irb; /* make an intel_renderbuffer to wrap the texture image */ @@ -505,7 +502,8 @@ intel_wrap_texture(GLcontext *ctx, struct gl_texture_image *texImage) _mesa_debug(ctx, "Render to DEPTH16 texture OK\n"); } else { - _mesa_debug(ctx, "Render to texture BAD FORMAT %d\n", texImage->TexFormat->MesaFormat); + _mesa_debug(ctx, "Render to texture BAD FORMAT %d\n", + texImage->TexFormat->MesaFormat); _mesa_free(irb); return NULL; } @@ -513,7 +511,7 @@ intel_wrap_texture(GLcontext *ctx, struct gl_texture_image *texImage) irb->Base.InternalFormat = irb->Base._ActualFormat; irb->Base.Width = texImage->Width; irb->Base.Height = texImage->Height; - irb->Base.DataType = GL_UNSIGNED_BYTE; /* FBO XXX fix */ + irb->Base.DataType = GL_UNSIGNED_BYTE; /* FBO XXX fix */ irb->Base.RedBits = texImage->TexFormat->RedBits; irb->Base.GreenBits = texImage->TexFormat->GreenBits; irb->Base.BlueBits = texImage->TexFormat->BlueBits; @@ -537,14 +535,13 @@ intel_wrap_texture(GLcontext *ctx, struct gl_texture_image *texImage) * before intel_finish_render_texture() is ever called. */ static void -intel_render_texture(GLcontext *ctx, +intel_render_texture(GLcontext * ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { struct gl_texture_image *newImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; - struct intel_renderbuffer *irb - = intel_renderbuffer(att->Renderbuffer); + struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer); struct intel_texture_image *intel_image; GLuint imageOffset; @@ -566,10 +563,10 @@ intel_render_texture(GLcontext *ctx, } /* - _mesa_debug(ctx, "Begin render texture tex=%u w=%d h=%d refcount=%d\n", - att->Texture->Name, newImage->Width, newImage->Height, - irb->Base.RefCount); - */ + _mesa_debug(ctx, "Begin render texture tex=%u w=%d h=%d refcount=%d\n", + att->Texture->Name, newImage->Width, newImage->Height, + irb->Base.RefCount); + */ /* point the renderbufer's region to the texture image region */ intel_image = intel_texture_image(newImage); @@ -599,17 +596,16 @@ intel_render_texture(GLcontext *ctx, * Called by Mesa when rendering to a texture is done. */ static void -intel_finish_render_texture(GLcontext *ctx, - struct gl_renderbuffer_attachment *att) +intel_finish_render_texture(GLcontext * ctx, + struct gl_renderbuffer_attachment *att) { struct intel_context *intel = intel_context(ctx); - struct intel_renderbuffer *irb - = intel_renderbuffer(att->Renderbuffer); + struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer); /* - _mesa_debug(ctx, "End render texture (tid %u) tex %u\n", - _glthread_GetID(), att->Texture->Name); - */ + _mesa_debug(ctx, "End render texture (tid %u) tex %u\n", + _glthread_GetID(), att->Texture->Name); + */ if (irb) { /* just release the region */ @@ -628,7 +624,7 @@ intel_finish_render_texture(GLcontext *ctx, * Hook in device driver functions. */ void -intel_fbo_init( struct intel_context *intel ) +intel_fbo_init(struct intel_context *intel) { intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer; intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer; diff --git a/src/mesa/drivers/dri/i915/intel_fbo.h b/src/mesa/drivers/dri/i915/intel_fbo.h index 980726763ab..221f09b39ab 100644 --- a/src/mesa/drivers/dri/i915/intel_fbo.h +++ b/src/mesa/drivers/dri/i915/intel_fbo.h @@ -39,35 +39,40 @@ struct intel_region; * not pointers because in some circumstances a deleted renderbuffer could * result in a dangling pointer here. */ -struct intel_renderbuffer { +struct intel_renderbuffer +{ struct gl_renderbuffer Base; struct intel_region *region; - void *pfMap; /* possibly paged flipped map pointer */ - GLuint pfPitch; /* possibly paged flipped pitch */ - GLboolean RenderToTexture; /* RTT? */ + void *pfMap; /* possibly paged flipped map pointer */ + GLuint pfPitch; /* possibly paged flipped pitch */ + GLboolean RenderToTexture; /* RTT? */ GLuint PairedDepth; /**< only used if this is a depth renderbuffer */ GLuint PairedStencil; /**< only used if this is a stencil renderbuffer */ }; -extern struct intel_renderbuffer * -intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, - int offset, int pitch, int cpp, void *map); +extern struct intel_renderbuffer *intel_create_renderbuffer(GLenum intFormat, + GLsizei width, + GLsizei height, + int offset, + int pitch, + int cpp, + void *map); -extern void -intel_fbo_init( struct intel_context *intel ); +extern void intel_fbo_init(struct intel_context *intel); /* XXX make inline or macro */ -extern struct intel_renderbuffer * -intel_get_renderbuffer(struct gl_framebuffer *fb, GLuint attIndex); +extern struct intel_renderbuffer *intel_get_renderbuffer(struct gl_framebuffer + *fb, + GLuint attIndex); /* XXX make inline or macro */ -extern struct intel_region * -intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex); +extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb, + GLuint attIndex); diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c index a46c03fd3c6..31c87276fcd 100644 --- a/src/mesa/drivers/dri/i915/intel_ioctl.c +++ b/src/mesa/drivers/dri/i915/intel_ioctl.c @@ -41,56 +41,58 @@ #include "intel_blit.h" #include "intel_regions.h" #include "drm.h" -#include "intel_bufmgr.h" #define FILE_DEBUG_FLAG DEBUG_IOCTL -int intelEmitIrqLocked( struct intel_context *intel ) +int +intelEmitIrqLocked(struct intel_context *intel) { drmI830IrqEmit ie; int ret, seq; - - assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) == - (DRM_LOCK_HELD|intel->hHWContext)); + + assert(((*(int *) intel->driHwLock) & ~DRM_LOCK_CONT) == + (DRM_LOCK_HELD | intel->hHWContext)); ie.irq_seq = &seq; - ret = drmCommandWriteRead( intel->driFd, DRM_I830_IRQ_EMIT, - &ie, sizeof(ie) ); - if ( ret ) { - fprintf( stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret ); + ret = drmCommandWriteRead(intel->driFd, DRM_I830_IRQ_EMIT, + &ie, sizeof(ie)); + if (ret) { + fprintf(stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret); exit(1); - } + } - DBG("%s --> %d\n", __FUNCTION__, seq ); + DBG("%s --> %d\n", __FUNCTION__, seq); return seq; } -void intelWaitIrq( struct intel_context *intel, int seq ) +void +intelWaitIrq(struct intel_context *intel, int seq) { int ret; - - DBG("%s %d\n", __FUNCTION__, seq ); + + DBG("%s %d\n", __FUNCTION__, seq); intel->iw.irq_seq = seq; - + do { - ret = drmCommandWrite( intel->driFd, DRM_I830_IRQ_WAIT, &intel->iw, sizeof(intel->iw) ); + ret = + drmCommandWrite(intel->driFd, DRM_I830_IRQ_WAIT, &intel->iw, + sizeof(intel->iw)); } while (ret == -EAGAIN || ret == -EINTR); - if ( ret ) { - fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret ); + if (ret) { + fprintf(stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret); exit(1); } } -void intel_batch_ioctl( struct intel_context *intel, - GLuint start_offset, - GLuint used, - GLboolean ignore_cliprects, - GLboolean allow_unlock) +intel_batch_ioctl(struct intel_context *intel, + GLuint start_offset, + GLuint used, + GLboolean ignore_cliprects, GLboolean allow_unlock) { drmI830BatchBuffer batch; @@ -98,49 +100,38 @@ void intel_batch_ioctl( struct intel_context *intel, assert(used); DBG("%s used %d offset %x..%x ignore_cliprects %d\n", - __FUNCTION__, - used, - start_offset, - start_offset + used, - ignore_cliprects); - + __FUNCTION__, + used, start_offset, start_offset + used, ignore_cliprects); + /* Throw away non-effective packets. Won't work once we have * hardware contexts which would preserve statechanges beyond a * single buffer. */ - if (intel->numClipRects == 0 && !ignore_cliprects) { - if (allow_unlock) { - UNLOCK_HARDWARE(intel); - sched_yield(); - LOCK_HARDWARE(intel); - } - intel->vtbl.lost_hardware( intel ); - return; - } + + batch.start = start_offset; batch.used = used; batch.cliprects = intel->pClipRects; batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects; batch.DR1 = 0; - batch.DR4 = ((((GLuint)intel->drawX) & 0xffff) | - (((GLuint)intel->drawY) << 16)); - - DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n", - __FUNCTION__, - batch.start, - batch.start + batch.used * 4, - batch.DR4, batch.num_cliprects); + batch.DR4 = ((((GLuint) intel->drawX) & 0xffff) | + (((GLuint) intel->drawY) << 16)); - if (drmCommandWrite (intel->driFd, DRM_I830_BATCHBUFFER, &batch, - sizeof(batch))) { - fprintf(stderr, "DRM_I830_BATCHBUFFER: %d\n", -errno); + DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n", + __FUNCTION__, + batch.start, + batch.start + batch.used * 4, batch.DR4, batch.num_cliprects); + + if (drmCommandWrite(intel->driFd, DRM_I830_BATCHBUFFER, &batch, + sizeof(batch))) { + fprintf(stderr, "DRM_I830_BATCHBUFFER: %d\n", -errno); UNLOCK_HARDWARE(intel); exit(1); } - + /* FIXME: use hardware contexts to avoid 'losing' hardware after * each buffer flush. */ - intel->vtbl.lost_hardware( intel ); + intel->vtbl.lost_hardware(intel); } diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.h b/src/mesa/drivers/dri/i915/intel_ioctl.h index d1e7f9ade6e..e8d07de893e 100644 --- a/src/mesa/drivers/dri/i915/intel_ioctl.h +++ b/src/mesa/drivers/dri/i915/intel_ioctl.h @@ -30,12 +30,11 @@ #include "intel_context.h" -void intelWaitIrq( struct intel_context *intel, int seq ); -int intelEmitIrqLocked( struct intel_context *intel ); +void intelWaitIrq(struct intel_context *intel, int seq); +int intelEmitIrqLocked(struct intel_context *intel); -void intel_batch_ioctl( struct intel_context *intel, - GLuint start_offset, - GLuint used, - GLboolean ignore_cliprects, - GLboolean allow_unlock); +void intel_batch_ioctl(struct intel_context *intel, + GLuint start_offset, + GLuint used, + GLboolean ignore_cliprects, GLboolean allow_unlock); #endif diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c index 5cc36a520e4..485526c4483 100644 --- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c @@ -28,12 +28,12 @@ #include "intel_context.h" #include "intel_mipmap_tree.h" #include "intel_regions.h" -#include "intel_bufmgr.h" #include "enums.h" #define FILE_DEBUG_FLAG DEBUG_TEXTURE -static GLenum target_to_target( GLenum target ) +static GLenum +target_to_target(GLenum target) { switch (target) { case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: @@ -48,25 +48,22 @@ static GLenum target_to_target( GLenum target ) } } -struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, - GLenum target, - GLenum internal_format, - GLuint first_level, - GLuint last_level, - GLuint width0, - GLuint height0, - GLuint depth0, - GLuint cpp, - GLboolean compressed) +struct intel_mipmap_tree * +intel_miptree_create(struct intel_context *intel, + GLenum target, + GLenum internal_format, + GLuint first_level, + GLuint last_level, + GLuint width0, + GLuint height0, + GLuint depth0, GLuint cpp, GLboolean compressed) { GLboolean ok; struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1); DBG("%s target %s format %s level %d..%d\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(internal_format), - first_level, - last_level); + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(internal_format), first_level, last_level); mt->target = target_to_target(target); mt->internal_format = internal_format; @@ -81,8 +78,8 @@ struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, switch (intel->intelScreen->deviceID) { case PCI_CHIP_I945_G: - case PCI_CHIP_I945_GM: - ok = i945_miptree_layout( mt ); + case PCI_CHIP_I945_GM: + ok = i945_miptree_layout(mt); break; case PCI_CHIP_I915_G: case PCI_CHIP_I915_GM: @@ -92,15 +89,13 @@ struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, default: /* All the i830 chips and the i915 use this layout: */ - ok = i915_miptree_layout( mt ); + ok = i915_miptree_layout(mt); break; } if (ok) - mt->region = intel_region_alloc( intel, - mt->cpp, - mt->pitch, - mt->total_height ); + mt->region = intel_region_alloc(intel, + mt->cpp, mt->pitch, mt->total_height); if (!mt->region) { free(mt); @@ -111,28 +106,30 @@ struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, } -void intel_miptree_reference( struct intel_mipmap_tree **dst, - struct intel_mipmap_tree *src ) +void +intel_miptree_reference(struct intel_mipmap_tree **dst, + struct intel_mipmap_tree *src) { src->refcount++; *dst = src; } -void intel_miptree_release( struct intel_context *intel, - struct intel_mipmap_tree **mt ) +void +intel_miptree_release(struct intel_context *intel, + struct intel_mipmap_tree **mt) { if (!*mt) return; - DBG("%s %d\n", __FUNCTION__, (*mt)->refcount-1); + DBG("%s %d\n", __FUNCTION__, (*mt)->refcount - 1); if (--(*mt)->refcount == 0) { GLuint i; intel_region_release(intel, &((*mt)->region)); for (i = 0; i < MAX_TEXTURE_LEVELS; i++) - if ((*mt)->level[i].image_offset) - free((*mt)->level[i].image_offset); + if ((*mt)->level[i].image_offset) + free((*mt)->level[i].image_offset); free(*mt); } @@ -147,15 +144,15 @@ void intel_miptree_release( struct intel_context *intel, * * Not sure whether I want to pass gl_texture_image here. */ -GLboolean intel_miptree_match_image( struct intel_mipmap_tree *mt, - struct gl_texture_image *image, - GLuint face, - GLuint level ) +GLboolean +intel_miptree_match_image(struct intel_mipmap_tree *mt, + struct gl_texture_image *image, + GLuint face, GLuint level) { DBG("%s %d %d/%d %d/%d\n", __FUNCTION__, - image->Border, - image->InternalFormat, mt->internal_format, - image->IsCompressed, mt->compressed); + image->Border, + image->InternalFormat, mt->internal_format, + image->IsCompressed, mt->compressed); /* Images with borders are never pulled into mipmap trees. */ @@ -186,11 +183,11 @@ GLboolean intel_miptree_match_image( struct intel_mipmap_tree *mt, } -void intel_miptree_set_level_info(struct intel_mipmap_tree *mt, - GLuint level, - GLuint nr_images, - GLuint x, GLuint y, - GLuint w, GLuint h, GLuint d) +void +intel_miptree_set_level_info(struct intel_mipmap_tree *mt, + GLuint level, + GLuint nr_images, + GLuint x, GLuint y, GLuint w, GLuint h, GLuint d) { mt->level[level].width = w; @@ -199,8 +196,8 @@ void intel_miptree_set_level_info(struct intel_mipmap_tree *mt, mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp; mt->level[level].nr_images = nr_images; - DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, level, w, h, d, - x, y, mt->level[level].level_offset); + DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, + level, w, h, d, x, y, mt->level[level].level_offset); /* Not sure when this would happen, but anyway: */ @@ -217,21 +214,19 @@ void intel_miptree_set_level_info(struct intel_mipmap_tree *mt, -void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt, - GLuint level, - GLuint img, - GLuint x, GLuint y) +void +intel_miptree_set_image_offset(struct intel_mipmap_tree *mt, + GLuint level, GLuint img, GLuint x, GLuint y) { if (img == 0 && level == 0) assert(x == 0 && y == 0); - + assert(img < mt->level[level].nr_images); mt->level[level].image_offset[img] = (x + y * mt->pitch); - DBG("%s level %d img %d pos %d,%d image_offset %x\n", - __FUNCTION__, level, img, x, y, - mt->level[level].image_offset[img]); + DBG("%s level %d img %d pos %d,%d image_offset %x\n", + __FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]); } @@ -241,26 +236,25 @@ void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt, * * These functions present that view to mesa: */ -const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, - GLuint level) +const GLuint * +intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, GLuint level) { static const GLuint zero = 0; - if (mt->target != GL_TEXTURE_3D || - mt->level[level].nr_images == 1) + if (mt->target != GL_TEXTURE_3D || mt->level[level].nr_images == 1) return &zero; else return mt->level[level].image_offset; } -GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt, - GLuint face, - GLuint level) +GLuint +intel_miptree_image_offset(struct intel_mipmap_tree * mt, + GLuint face, GLuint level) { if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) return (mt->level[level].level_offset + - mt->level[level].image_offset[face] * mt->cpp); + mt->level[level].image_offset[face] * mt->cpp); else return mt->level[level].level_offset; } @@ -273,28 +267,29 @@ GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt, * \param image_stride returns image stride in bytes (for 3D textures). * \return address of mapping */ -GLubyte *intel_miptree_image_map(struct intel_context *intel, - struct intel_mipmap_tree *mt, - GLuint face, - GLuint level, - GLuint *row_stride, - GLuint *image_offsets) +GLubyte * +intel_miptree_image_map(struct intel_context * intel, + struct intel_mipmap_tree * mt, + GLuint face, + GLuint level, + GLuint * row_stride, GLuint * image_offsets) { DBG("%s \n", __FUNCTION__); - + if (row_stride) *row_stride = mt->pitch * mt->cpp; - + if (image_offsets) memcpy(image_offsets, mt->level[level].image_offset, - mt->level[level].depth * sizeof(GLuint)); + mt->level[level].depth * sizeof(GLuint)); return (intel_region_map(intel, mt->region) + - intel_miptree_image_offset(mt, face, level)); + intel_miptree_image_offset(mt, face, level)); } -void intel_miptree_image_unmap(struct intel_context *intel, - struct intel_mipmap_tree *mt) +void +intel_miptree_image_unmap(struct intel_context *intel, + struct intel_mipmap_tree *mt) { DBG("%s\n", __FUNCTION__); intel_region_unmap(intel, mt->region); @@ -304,13 +299,13 @@ void intel_miptree_image_unmap(struct intel_context *intel, /* Upload data for a particular image. */ -void intel_miptree_image_data(struct intel_context *intel, - struct intel_mipmap_tree *dst, - GLuint face, - GLuint level, - void *src, - GLuint src_row_pitch, - GLuint src_image_pitch) +void +intel_miptree_image_data(struct intel_context *intel, + struct intel_mipmap_tree *dst, + GLuint face, + GLuint level, + void *src, + GLuint src_row_pitch, GLuint src_image_pitch) { GLuint depth = dst->level[level].depth; GLuint dst_offset = intel_miptree_image_offset(dst, face, level); @@ -319,26 +314,20 @@ void intel_miptree_image_data(struct intel_context *intel, DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { - intel_region_data(intel, - dst->region, dst_offset + dst_depth_offset[i], - 0, - 0, - src, - src_row_pitch, - 0, 0, /* source x,y */ - dst->level[level].width, - dst->level[level].height); + intel_region_data(intel, dst->region, dst_offset + dst_depth_offset[i], 0, 0, src, src_row_pitch, 0, 0, /* source x,y */ + dst->level[level].width, dst->level[level].height); src += src_image_pitch; } } - + /* Copy mipmap image between trees */ -void intel_miptree_image_copy( struct intel_context *intel, - struct intel_mipmap_tree *dst, - GLuint face, GLuint level, - struct intel_mipmap_tree *src ) +void +intel_miptree_image_copy(struct intel_context *intel, + struct intel_mipmap_tree *dst, + GLuint face, GLuint level, + struct intel_mipmap_tree *src) { GLuint width = src->level[level].width; GLuint height = src->level[level].height; @@ -351,14 +340,11 @@ void intel_miptree_image_copy( struct intel_context *intel, for (i = 0; i < depth; i++) { intel_region_copy(intel, - dst->region, dst_offset + dst_depth_offset[i], - 0, - 0, - src->region, src_offset + src_depth_offset[i], - 0, - 0, - width, - height); + dst->region, dst_offset + dst_depth_offset[i], + 0, + 0, + src->region, src_offset + src_depth_offset[i], + 0, 0, width, height); } - + } diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.h b/src/mesa/drivers/dri/i915/intel_mipmap_tree.h index 541598d278d..e6dd5bb6008 100644 --- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.h @@ -60,7 +60,8 @@ /** * Describes the location of each texture image within a texture region. */ -struct intel_mipmap_level { +struct intel_mipmap_level +{ GLuint level_offset; GLuint width; GLuint height; @@ -76,7 +77,8 @@ struct intel_mipmap_level { GLuint *image_offset; }; -struct intel_mipmap_tree { +struct intel_mipmap_tree +{ /* Effectively the key: */ GLenum target; @@ -90,11 +92,11 @@ struct intel_mipmap_tree { GLboolean compressed; /* Derived from the above: - */ + */ GLuint pitch; - GLuint depth_pitch; /* per-image on i945? */ + GLuint depth_pitch; /* per-image on i945? */ GLuint total_height; - + /* Includes image offset tables: */ struct intel_mipmap_level level[MAX_TEXTURE_LEVELS]; @@ -110,91 +112,86 @@ struct intel_mipmap_tree { -struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, - GLenum target, - GLenum internal_format, - GLuint first_level, - GLuint last_level, - GLuint width0, - GLuint height0, - GLuint depth0, - GLuint cpp, - GLboolean compressed); +struct intel_mipmap_tree *intel_miptree_create(struct intel_context *intel, + GLenum target, + GLenum internal_format, + GLuint first_level, + GLuint last_level, + GLuint width0, + GLuint height0, + GLuint depth0, + GLuint cpp, + GLboolean compressed); -void intel_miptree_reference( struct intel_mipmap_tree **dst, - struct intel_mipmap_tree *src ); +void intel_miptree_reference(struct intel_mipmap_tree **dst, + struct intel_mipmap_tree *src); -void intel_miptree_release( struct intel_context *intel, - struct intel_mipmap_tree **mt ); +void intel_miptree_release(struct intel_context *intel, + struct intel_mipmap_tree **mt); /* Check if an image fits an existing mipmap tree layout */ -GLboolean intel_miptree_match_image( struct intel_mipmap_tree *mt, - struct gl_texture_image *image, - GLuint face, - GLuint level ); +GLboolean intel_miptree_match_image(struct intel_mipmap_tree *mt, + struct gl_texture_image *image, + GLuint face, GLuint level); /* Return a pointer to an image within a tree. Return image stride as * well. */ -GLubyte *intel_miptree_image_map( struct intel_context *intel, - struct intel_mipmap_tree *mt, - GLuint face, - GLuint level, - GLuint *row_stride, - GLuint *image_stride); +GLubyte *intel_miptree_image_map(struct intel_context *intel, + struct intel_mipmap_tree *mt, + GLuint face, + GLuint level, + GLuint * row_stride, GLuint * image_stride); -void intel_miptree_image_unmap( struct intel_context *intel, - struct intel_mipmap_tree *mt ); +void intel_miptree_image_unmap(struct intel_context *intel, + struct intel_mipmap_tree *mt); /* Return the linear offset of an image relative to the start of the * tree: */ -GLuint intel_miptree_image_offset( struct intel_mipmap_tree *mt, - GLuint face, - GLuint level ); +GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt, + GLuint face, GLuint level); /* Return pointers to each 2d slice within an image. Indexed by depth * value. */ const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, - GLuint level); + GLuint level); void intel_miptree_set_level_info(struct intel_mipmap_tree *mt, - GLuint level, - GLuint nr_images, - GLuint x, GLuint y, - GLuint w, GLuint h, GLuint d); + GLuint level, + GLuint nr_images, + GLuint x, GLuint y, + GLuint w, GLuint h, GLuint d); void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt, - GLuint level, - GLuint img, - GLuint x, GLuint y); + GLuint level, + GLuint img, GLuint x, GLuint y); /* Upload an image into a tree */ -void intel_miptree_image_data(struct intel_context *intel, - struct intel_mipmap_tree *dst, - GLuint face, - GLuint level, - void *src, - GLuint src_row_pitch, - GLuint src_image_pitch); +void intel_miptree_image_data(struct intel_context *intel, + struct intel_mipmap_tree *dst, + GLuint face, + GLuint level, + void *src, + GLuint src_row_pitch, GLuint src_image_pitch); /* Copy an image between two trees */ -void intel_miptree_image_copy( struct intel_context *intel, - struct intel_mipmap_tree *dst, - GLuint face, GLuint level, - struct intel_mipmap_tree *src ); +void intel_miptree_image_copy(struct intel_context *intel, + struct intel_mipmap_tree *dst, + GLuint face, GLuint level, + struct intel_mipmap_tree *src); /* i915_mipmap_tree.c: */ -GLboolean i915_miptree_layout( struct intel_mipmap_tree *mt ); -GLboolean i945_miptree_layout( struct intel_mipmap_tree *mt ); +GLboolean i915_miptree_layout(struct intel_mipmap_tree *mt); +GLboolean i945_miptree_layout(struct intel_mipmap_tree *mt); diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c index 9b2d7d9d2e2..4fe128deea1 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel.c +++ b/src/mesa/drivers/dri/i915/intel_pixel.c @@ -38,7 +38,8 @@ * Check if any fragment operations are in effect which might effect * glDraw/CopyPixels. */ -GLboolean intel_check_blit_fragment_ops( GLcontext *ctx ) +GLboolean +intel_check_blit_fragment_ops(GLcontext * ctx) { if (ctx->NewState) _mesa_update_state(ctx); @@ -46,22 +47,22 @@ GLboolean intel_check_blit_fragment_ops( GLcontext *ctx ) /* XXX Note: Scissor could be done with the blitter: */ return !(ctx->_ImageTransferState || - ctx->Color.AlphaEnabled || - ctx->Depth.Test || - ctx->Fog.Enabled || - ctx->Scissor.Enabled || - ctx->Stencil.Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || - ctx->Color.ColorLogicOpEnabled || - ctx->Texture._EnabledUnits || - ctx->FragmentProgram._Enabled); + ctx->Color.AlphaEnabled || + ctx->Depth.Test || + ctx->Fog.Enabled || + ctx->Scissor.Enabled || + ctx->Stencil.Enabled || + !ctx->Color.ColorMask[0] || + !ctx->Color.ColorMask[1] || + !ctx->Color.ColorMask[2] || + !ctx->Color.ColorMask[3] || + ctx->Color.ColorLogicOpEnabled || + ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled); } -GLboolean intel_check_meta_tex_fragment_ops( GLcontext *ctx ) +GLboolean +intel_check_meta_tex_fragment_ops(GLcontext * ctx) { if (ctx->NewState) _mesa_update_state(ctx); @@ -69,10 +70,8 @@ GLboolean intel_check_meta_tex_fragment_ops( GLcontext *ctx ) /* Some of _ImageTransferState (scale, bias) could be done with * fragment programs on i915. */ - return !(ctx->_ImageTransferState || - ctx->Fog.Enabled || /* not done yet */ - ctx->Texture._EnabledUnits || - ctx->FragmentProgram._Enabled); + return !(ctx->_ImageTransferState || ctx->Fog.Enabled || /* not done yet */ + ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled); } /* The intel_region struct doesn't really do enough to capture the @@ -85,38 +84,36 @@ GLboolean intel_check_meta_tex_fragment_ops( GLcontext *ctx ) * \param format as given to glDraw/ReadPixels * \param type as given to glDraw/ReadPixels */ -GLboolean intel_check_blit_format( struct intel_region *region, - GLenum format, GLenum type ) +GLboolean +intel_check_blit_format(struct intel_region * region, + GLenum format, GLenum type) { if (region->cpp == 4 && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - type == GL_UNSIGNED_BYTE) && - format == GL_BGRA ) { + type == GL_UNSIGNED_BYTE) && format == GL_BGRA) { return GL_TRUE; } - - if (region->cpp == 2 && - type == GL_UNSIGNED_SHORT_5_6_5_REV && - format == GL_BGR ) { + + if (region->cpp == 2 && + type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) { return GL_TRUE; } if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: bad format for blit (cpp %d, type %s format %s)\n", - __FUNCTION__, region->cpp, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(format)); + fprintf(stderr, "%s: bad format for blit (cpp %d, type %s format %s)\n", + __FUNCTION__, region->cpp, + _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format)); return GL_FALSE; } -void intelInitPixelFuncs( struct dd_function_table *functions ) +void +intelInitPixelFuncs(struct dd_function_table *functions) { functions->Accum = _swrast_Accum; functions->Bitmap = _swrast_Bitmap; functions->CopyPixels = intelCopyPixels; - functions->ReadPixels = intelReadPixels; - functions->DrawPixels = intelDrawPixels; + functions->ReadPixels = intelReadPixels; + functions->DrawPixels = intelDrawPixels; } - diff --git a/src/mesa/drivers/dri/i915/intel_pixel.h b/src/mesa/drivers/dri/i915/intel_pixel.h index 3654a91b595..a6fcf90ce03 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel.h +++ b/src/mesa/drivers/dri/i915/intel_pixel.h @@ -30,35 +30,34 @@ #include "mtypes.h" -void intelInitPixelFuncs( struct dd_function_table *functions ); +void intelInitPixelFuncs(struct dd_function_table *functions); -GLboolean intel_check_blit_fragment_ops( GLcontext *ctx ); +GLboolean intel_check_blit_fragment_ops(GLcontext * ctx); -GLboolean intel_check_meta_tex_fragment_ops( GLcontext *ctx ); +GLboolean intel_check_meta_tex_fragment_ops(GLcontext * ctx); -GLboolean intel_check_blit_format( struct intel_region *region, - GLenum format, GLenum type ); +GLboolean intel_check_blit_format(struct intel_region *region, + GLenum format, GLenum type); -void intelReadPixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - GLvoid *pixels ); +void intelReadPixels(GLcontext * ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, + GLvoid * pixels); -void intelDrawPixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, - GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); +void intelDrawPixels(GLcontext * ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, + GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid * pixels); -void intelCopyPixels( GLcontext *ctx, - GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint destx, GLint desty, - GLenum type ); +void intelCopyPixels(GLcontext * ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint destx, GLint desty, GLenum type); #endif diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c index 6ba44fee11d..79fe8ee3e93 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c @@ -41,21 +41,19 @@ #include "intel_regions.h" #include "intel_tris.h" #include "intel_pixel.h" -#include "intel_bufmgr.h" -static struct intel_region *copypix_src_region( struct intel_context *intel, - GLenum type ) +static struct intel_region * +copypix_src_region(struct intel_context *intel, GLenum type) { switch (type) { case GL_COLOR: - return intel_readbuf_region( intel ); + return intel_readbuf_region(intel); case GL_DEPTH: /* Don't think this is really possible execpt at 16bpp, when we have no stencil. */ - if (intel->depth_region && - intel->depth_region->cpp == 2) - return intel->depth_region; + if (intel->depth_region && intel->depth_region->cpp == 2) + return intel->depth_region; case GL_STENCIL: /* Don't think this is really possible. */ @@ -75,14 +73,14 @@ static struct intel_region *copypix_src_region( struct intel_context *intel, /* Doesn't work for overlapping regions. Could do a double copy or * just fallback. */ -static GLboolean do_texture_copypixels( GLcontext *ctx, - GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, - GLenum type ) +static GLboolean +do_texture_copypixels(GLcontext * ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type) { - struct intel_context *intel = intel_context( ctx ); - struct intel_region *dst = intel_drawbuf_region( intel ); + struct intel_context *intel = intel_context(ctx); + struct intel_region *dst = intel_drawbuf_region(intel); struct intel_region *src = copypix_src_region(intel, type); GLenum src_format; GLenum src_type; @@ -99,12 +97,11 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, * * XXX: do a copy to a temporary. */ - if (src->buffer == dst->buffer) - { + if (src->buffer == dst->buffer) { drm_clip_rect_t srcbox; drm_clip_rect_t dstbox; drm_clip_rect_t tmp; - + srcbox.x1 = srcx; srcbox.y1 = srcy; srcbox.x2 = srcx + width; @@ -117,13 +114,13 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, if (intel_intersect_cliprects(&tmp, &srcbox, &dstbox)) { - if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: regions overlap\n", __FUNCTION__); - return GL_FALSE; + if (INTEL_DEBUG & DEBUG_PIXEL) + _mesa_printf("%s: regions overlap\n", __FUNCTION__); + return GL_FALSE; } } - intelFlush( &intel->ctx ); + intelFlush(&intel->ctx); intel->vtbl.install_meta_state(intel); @@ -142,7 +139,7 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, if (src->cpp == 2) { src_format = GL_RGB; src_type = GL_UNSIGNED_SHORT_5_6_5; - } + } else { src_format = GL_BGRA; src_type = GL_UNSIGNED_BYTE; @@ -150,27 +147,24 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, /* Set the frontbuffer up as a large rectangular texture. */ - if (!intel->vtbl.meta_tex_rect_source( intel, src->buffer, 0, - src->pitch, - src->height, - src_format, - src_type )) { + if (!intel->vtbl.meta_tex_rect_source(intel, src->buffer, 0, + src->pitch, + src->height, src_format, src_type)) { intel->vtbl.leave_meta_state(intel); return GL_FALSE; } - - intel->vtbl.meta_texture_blend_replace( intel ); + + intel->vtbl.meta_texture_blend_replace(intel); - LOCK_HARDWARE( intel ); - - if (intel->driDrawable->numClipRects) - { + LOCK_HARDWARE(intel); + + if (intel->driDrawable->numClipRects) { __DRIdrawablePrivate *dPriv = intel->driDrawable; - srcy = dPriv->h - srcy - height; /* convert from gl to hardware coords */ + srcy = dPriv->h - srcy - height; /* convert from gl to hardware coords */ srcx += dPriv->x; srcy += dPriv->y; @@ -181,37 +175,29 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, * */ if (0) { - GLint orig_x = srcx; - GLint orig_y = srcy; + GLint orig_x = srcx; + GLint orig_y = srcy; - if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, - &srcx, &srcy, &width, &height)) - goto out; + if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, + &srcx, &srcy, &width, &height)) + goto out; - dstx += srcx - orig_x; - dsty += (srcy - orig_y) * ctx->Pixel.ZoomY; + dstx += srcx - orig_x; + dsty += (srcy - orig_y) * ctx->Pixel.ZoomY; } /* Just use the regular cliprect mechanism... Does this need to * even hold the lock??? */ - intel_meta_draw_quad(intel, + intel_meta_draw_quad(intel, dstx, dstx + width * ctx->Pixel.ZoomX, dPriv->h - (dsty + height * ctx->Pixel.ZoomY), dPriv->h - (dsty), 0, /* XXX: what z value? */ + 0x00ff00ff, + srcx, srcx + width, srcy, srcy + height); - dstx, - dstx + width * ctx->Pixel.ZoomX, - dPriv->h - (dsty + height * ctx->Pixel.ZoomY), - dPriv->h - (dsty), - - 0, /* XXX: what z value? */ - 0x00ff00ff, - srcx, srcx+width, - srcy, srcy+height); - - out: + out: intel->vtbl.leave_meta_state(intel); intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); return GL_TRUE; } @@ -222,48 +208,46 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, /** * CopyPixels with the blitter. Don't support zooming, pixel transfer, etc. */ -static GLboolean do_blit_copypixels( GLcontext *ctx, - GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, - GLenum type ) +static GLboolean +do_blit_copypixels(GLcontext * ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type) { - struct intel_context *intel = intel_context( ctx ); - struct intel_region *dst = intel_drawbuf_region( intel ); - struct intel_region *src = copypix_src_region( intel, type ); + struct intel_context *intel = intel_context(ctx); + struct intel_region *dst = intel_drawbuf_region(intel); + struct intel_region *src = copypix_src_region(intel, type); /* Copypixels can be more than a straight copy. Ensure all the * extra operations are disabled: */ if (!intel_check_blit_fragment_ops(ctx) || - ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F) + ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; - if (!src || !dst) + if (!src || !dst) return GL_FALSE; - intelFlush( &intel->ctx ); + intelFlush(&intel->ctx); intel->vtbl.render_start(intel); intel->vtbl.emit_state(intel); - LOCK_HARDWARE( intel ); + LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) - { + if (intel->driDrawable->numClipRects) { __DRIdrawablePrivate *dPriv = intel->driDrawable; drm_clip_rect_t *box = dPriv->pClipRects; drm_clip_rect_t dest_rect; GLint nbox = dPriv->numClipRects; - GLint delta_x = 0; - GLint delta_y = 0; + GLint delta_x = 0; + GLint delta_y = 0; GLuint i; - dsty = dPriv->h - dsty - height; /* convert from gl to hardware coords */ - srcy = dPriv->h - srcy - height; /* convert from gl to hardware coords */ + dsty = dPriv->h - dsty - height; /* convert from gl to hardware coords */ + srcy = dPriv->h - srcy - height; /* convert from gl to hardware coords */ dstx += dPriv->x; dsty += dPriv->y; srcx += dPriv->x; @@ -275,15 +259,15 @@ static GLboolean do_blit_copypixels( GLcontext *ctx, * TODO: Scissor? */ { - delta_x = srcx - dstx; - delta_y = srcy - dsty; + delta_x = srcx - dstx; + delta_y = srcy - dsty; - if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, - &srcx, &srcy, &width, &height)) - goto out; + if (!_mesa_clip_to_region(0, 0, src->pitch, src->height, + &srcx, &srcy, &width, &height)) + goto out; - dstx = srcx - delta_x; - dsty = srcy - delta_y; + dstx = srcx - delta_x; + dsty = srcy - delta_y; } dest_rect.x1 = dstx; @@ -298,53 +282,44 @@ static GLboolean do_blit_copypixels( GLcontext *ctx, * This code will not overwrite other windows, but will * introduce garbage when copying from obscured window regions. */ - for (i = 0 ; i < nbox ; i++ ) - { - drm_clip_rect_t rect; + for (i = 0; i < nbox; i++) { + drm_clip_rect_t rect; - if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) - continue; + if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) + continue; - - intelEmitCopyBlit( intel, - dst->cpp, - src->pitch, src->buffer, 0, - dst->pitch, dst->buffer, 0, - rect.x1 + delta_x, - rect.y1 + delta_y, /* srcx, srcy */ - rect.x1, - rect.y1, /* dstx, dsty */ - rect.x2 - rect.x1, - rect.y2 - rect.y1 ); + + intelEmitCopyBlit(intel, dst->cpp, src->pitch, src->buffer, 0, dst->pitch, dst->buffer, 0, rect.x1 + delta_x, rect.y1 + delta_y, /* srcx, srcy */ + rect.x1, rect.y1, /* dstx, dsty */ + rect.x2 - rect.x1, rect.y2 - rect.y1); } - out: - intel_batchbuffer_flush( intel->batch ); + out: + intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); return GL_TRUE; } -void intelCopyPixels( GLcontext *ctx, - GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint destx, GLint desty, - GLenum type ) +void +intelCopyPixels(GLcontext * ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint destx, GLint desty, GLenum type) { if (INTEL_DEBUG & DEBUG_PIXEL) fprintf(stderr, "%s\n", __FUNCTION__); - if (do_blit_copypixels( ctx, srcx, srcy, width, height, destx, desty, type)) + if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type)) return; - if (do_texture_copypixels( ctx, srcx, srcy, width, height, destx, desty, type)) + if (do_texture_copypixels + (ctx, srcx, srcy, width, height, destx, desty, type)) return; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("fallback to _swrast_CopyPixels\n"); - _swrast_CopyPixels( ctx, srcx, srcy, width, height, destx, desty, type); + _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type); } - - diff --git a/src/mesa/drivers/dri/i915/intel_pixel_draw.c b/src/mesa/drivers/dri/i915/intel_pixel_draw.c index b35ab635658..5b04cd61898 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_draw.c @@ -43,19 +43,19 @@ #include "intel_pixel.h" #include "intel_buffer_objects.h" #include "intel_tris.h" -#include "intel_bufmgr.h" -static GLboolean do_texture_drawpixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) +static GLboolean +do_texture_drawpixels(GLcontext * ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid * pixels) { - struct intel_context *intel = intel_context( ctx ); - struct intel_region *dst = intel_drawbuf_region( intel ); + struct intel_context *intel = intel_context(ctx); + struct intel_region *dst = intel_drawbuf_region(intel); struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj); GLuint rowLength = unpack->RowLength ? unpack->RowLength : width; GLuint src_offset; @@ -63,7 +63,7 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, if (INTEL_DEBUG & DEBUG_PIXEL) fprintf(stderr, "%s\n", __FUNCTION__); - intelFlush( &intel->ctx ); + intelFlush(&intel->ctx); intel->vtbl.render_start(intel); intel->vtbl.emit_state(intel); @@ -96,7 +96,8 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, */ if (!intel_check_meta_tex_fragment_ops(ctx)) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad GL fragment state for metaops texture\n", __FUNCTION__); + _mesa_printf("%s - bad GL fragment state for metaops texture\n", + __FUNCTION__); return GL_FALSE; } @@ -116,7 +117,7 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, intel->vtbl.meta_import_pixel_state(intel); src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height, - format, type, 0, 0, 0); + format, type, 0, 0, 0); /* Setup the pbo up as a rectangular texture, if possible. @@ -126,20 +127,18 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, * The major exception is any 24bit texture, like RGB888, for which * there is no hardware support. */ - if (!intel->vtbl.meta_tex_rect_source( intel, src->buffer, src_offset, - rowLength, height, - format, type )) { + if (!intel->vtbl.meta_tex_rect_source(intel, src->buffer, src_offset, + rowLength, height, format, type)) { intel->vtbl.leave_meta_state(intel); return GL_FALSE; } - - intel->vtbl.meta_texture_blend_replace( intel ); + + intel->vtbl.meta_texture_blend_replace(intel); - LOCK_HARDWARE( intel ); + LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) - { + if (intel->driDrawable->numClipRects) { __DRIdrawablePrivate *dPriv = intel->driDrawable; GLint srcx, srcy; GLint dstx, dsty; @@ -147,43 +146,42 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, dstx = x; dsty = dPriv->h - (y + height); - srcx = 0; /* skiprows/pixels already done */ + srcx = 0; /* skiprows/pixels already done */ srcy = 0; if (0) { - const GLint orig_x = dstx; - const GLint orig_y = dsty; + const GLint orig_x = dstx; + const GLint orig_y = dsty; - if (!_mesa_clip_to_region(0, 0, dst->pitch, dst->height, - &dstx, &dsty, &width, &height)) - goto out; + if (!_mesa_clip_to_region(0, 0, dst->pitch, dst->height, + &dstx, &dsty, &width, &height)) + goto out; - srcx += dstx - orig_x; - srcy += dsty - orig_y; + srcx += dstx - orig_x; + srcy += dsty - orig_y; } if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("draw %d,%d %dx%d\n", dstx,dsty,width,height); + _mesa_printf("draw %d,%d %dx%d\n", dstx, dsty, width, height); /* Must use the regular cliprect mechanism in order to get the * drawing origin set correctly. Otherwise scissor state is in * incorrect coordinate space. Does this even need to hold the * lock??? */ - intel_meta_draw_quad(intel, - dstx, dstx + width * ctx->Pixel.ZoomX, - dPriv->h - (y + height * ctx->Pixel.ZoomY), - dPriv->h - (y), - - ctx->Current.RasterPos[2] * .5, - 0x00ff00ff, - srcx, srcx+width, - srcy+height, srcy); - out: + intel_meta_draw_quad(intel, + dstx, dstx + width * ctx->Pixel.ZoomX, + dPriv->h - (y + height * ctx->Pixel.ZoomY), + dPriv->h - (y), + -ctx->Current.RasterPos[2] * .5, + 0x00ff00ff, + srcx, srcx + width, srcy + height, srcy); + out: intel->vtbl.leave_meta_state(intel); intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); return GL_TRUE; } @@ -206,27 +204,28 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, * data to agp space before performing the blit. (Though it may turn * out to be better/simpler just to use the texture engine). */ -static GLboolean do_blit_drawpixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) +static GLboolean +do_blit_drawpixels(GLcontext * ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid * pixels) { struct intel_context *intel = intel_context(ctx); struct intel_region *dest = intel_drawbuf_region(intel); struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj); GLuint src_offset; GLuint rowLength; - GLuint fence = bmInitFence(intel); - + struct _DriFenceObject *fence = NULL; + if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); - - + + if (!dest) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - no dest\n", __FUNCTION__); + _mesa_printf("%s - no dest\n", __FUNCTION__); return GL_FALSE; } @@ -243,25 +242,26 @@ static GLboolean do_blit_drawpixels( GLcontext *ctx, /* PBO only for now: */ if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - not PBO\n", __FUNCTION__); + _mesa_printf("%s - not PBO\n", __FUNCTION__); return GL_FALSE; } - + if (!intel_check_blit_format(dest, format, type)) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad format for blit\n", __FUNCTION__); + _mesa_printf("%s - bad format for blit\n", __FUNCTION__); return GL_FALSE; } if (!intel_check_meta_tex_fragment_ops(ctx)) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad GL fragment state for meta tex\n", __FUNCTION__); + _mesa_printf("%s - bad GL fragment state for meta tex\n", + __FUNCTION__); return GL_FALSE; } if (ctx->Pixel.ZoomX != 1.0F) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad PixelZoomX for blit\n", __FUNCTION__); + _mesa_printf("%s - bad PixelZoomX for blit\n", __FUNCTION__); return GL_FALSE; } @@ -273,8 +273,8 @@ static GLboolean do_blit_drawpixels( GLcontext *ctx, if (ctx->Pixel.ZoomY == -1.0F) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__); - return GL_FALSE; /* later */ + _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__); + return GL_FALSE; /* later */ y -= height; } else if (ctx->Pixel.ZoomY == 1.0F) { @@ -282,55 +282,55 @@ static GLboolean do_blit_drawpixels( GLcontext *ctx, } else { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__); + _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__); return GL_FALSE; } src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height, - format, type, 0, 0, 0); + format, type, 0, 0, 0); - intelFlush( &intel->ctx ); - LOCK_HARDWARE( intel ); + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) - { + if (intel->driDrawable->numClipRects) { __DRIdrawablePrivate *dPriv = intel->driDrawable; int nbox = dPriv->numClipRects; drm_clip_rect_t *box = dPriv->pClipRects; drm_clip_rect_t rect; drm_clip_rect_t dest_rect; - struct buffer *src_buffer = intel_bufferobj_buffer(intel, src, INTEL_READ); + struct _DriBufferObject *src_buffer = + intel_bufferobj_buffer(intel, src, INTEL_READ); int i; - + dest_rect.x1 = dPriv->x + x; dest_rect.y1 = dPriv->y + dPriv->h - (y + height); dest_rect.x2 = dest_rect.x1 + width; dest_rect.y2 = dest_rect.y1 + height; - for (i = 0 ; i < nbox ; i++ ) - { - if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) - continue; + for (i = 0; i < nbox; i++) { + if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i])) + continue; - intelEmitCopyBlit( intel, - dest->cpp, - rowLength, - src_buffer, src_offset, - dest->pitch, - dest->buffer, 0, - rect.x1 - dest_rect.x1, - rect.y2 - dest_rect.y2, - rect.x1, - rect.y1, - rect.x2 - rect.x1, - rect.y2 - rect.y1 ); + intelEmitCopyBlit(intel, + dest->cpp, + rowLength, + src_buffer, src_offset, + dest->pitch, + dest->buffer, 0, + rect.x1 - dest_rect.x1, + rect.y2 - dest_rect.y2, + rect.x1, + rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1); } - fence = intel_batchbuffer_flush( intel->batch ); + fence = intel_batchbuffer_flush(intel->batch); + driFenceReference(fence); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); if (intel->driDrawable->numClipRects) - bmFinishFence(intel, fence); + driFenceFinish(fence, DRM_FENCE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE); + + driFenceUnReference(fence); if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s - DONE\n", __FUNCTION__); @@ -340,27 +340,26 @@ static GLboolean do_blit_drawpixels( GLcontext *ctx, -void intelDrawPixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, - GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) +void +intelDrawPixels(GLcontext * ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, + GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid * pixels) { - if (do_blit_drawpixels( ctx, x, y, width, height, format, type, - unpack, pixels )) + if (do_blit_drawpixels(ctx, x, y, width, height, format, type, + unpack, pixels)) return; - if (do_texture_drawpixels( ctx, x, y, width, height, format, type, - unpack, pixels )) + if (do_texture_drawpixels(ctx, x, y, width, height, format, type, + unpack, pixels)) return; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s: fallback to swrast\n", __FUNCTION__); - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); + _swrast_DrawPixels(ctx, x, y, width, height, format, type, unpack, pixels); } - diff --git a/src/mesa/drivers/dri/i915/intel_pixel_read.c b/src/mesa/drivers/dri/i915/intel_pixel_read.c index 13890550d11..5edfd79f4f0 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_read.c @@ -43,8 +43,6 @@ #include "intel_pixel.h" #include "intel_buffer_objects.h" -#include "intel_bufmgr.h" - /* For many applications, the new ability to pull the source buffers * back out of the GTT and then do the packing/conversion operations * in software will be as much of an improvement as trying to get the @@ -69,11 +67,11 @@ static GLboolean -do_texture_readpixels( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - struct intel_region *dest_region ) +do_texture_readpixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, + struct intel_region *dest_region) { #if 0 struct intel_context *intel = intel_context(ctx); @@ -89,30 +87,25 @@ do_texture_readpixels( GLcontext *ctx, fprintf(stderr, "%s\n", __FUNCTION__); - if ( ctx->_ImageTransferState || - pack->SwapBytes || - pack->LsbFirst || - !pack->Invert) { + if (ctx->_ImageTransferState || + pack->SwapBytes || pack->LsbFirst || !pack->Invert) { if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: check_color failed\n", __FUNCTION__); + fprintf(stderr, "%s: check_color failed\n", __FUNCTION__); return GL_FALSE; } intel->vtbl.meta_texrect_source(intel, intel_readbuf_region(intel)); - if (!intel->vtbl.meta_render_dest(intel, - dest_region, - type, format)) - { + if (!intel->vtbl.meta_render_dest(intel, dest_region, type, format)) { if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: couldn't set dest %s/%s\n", - __FUNCTION__, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(format)); + fprintf(stderr, "%s: couldn't set dest %s/%s\n", + __FUNCTION__, + _mesa_lookup_enum_by_nr(type), + _mesa_lookup_enum_by_nr(format)); return GL_FALSE; } - LOCK_HARDWARE( intel ); + LOCK_HARDWARE(intel); if (intel->driDrawable->numClipRects) { intel->vtbl.install_meta_state(intel); @@ -120,11 +113,11 @@ do_texture_readpixels( GLcontext *ctx, intel->vtbl.meta_no_stencil_write(intel); if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) { - UNLOCK_HARDWARE( intel ); - SET_STATE(i830, state); - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__); - return GL_TRUE; + UNLOCK_HARDWARE(intel); + SET_STATE(i830, state); + if (INTEL_DEBUG & DEBUG_PIXEL) + fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__); + return GL_TRUE; } y = dPriv->h - y - height; @@ -134,36 +127,32 @@ do_texture_readpixels( GLcontext *ctx, /* Set the frontbuffer up as a large rectangular texture. */ - intel->vtbl.meta_tex_rect_source( intel, - src_region, - textureFormat ); - - - intel->vtbl.meta_texture_blend_replace( i830, glTextureFormat ); + intel->vtbl.meta_tex_rect_source(intel, src_region, textureFormat); + + + intel->vtbl.meta_texture_blend_replace(i830, glTextureFormat); /* Set the 3d engine to draw into the destination region: */ - intel->vtbl.meta_draw_region(intel, dest_region); - intel->vtbl.meta_draw_format(intel, destFormat, depthFormat ); /* ?? */ + intel->vtbl.meta_draw_region(intel, dest_region); + intel->vtbl.meta_draw_format(intel, destFormat, depthFormat); /* ?? */ /* Draw a single quad, no cliprects: */ intel->vtbl.meta_disable_cliprects(intel); - intel->vtbl.draw_quad(intel, - 0, width, 0, height, - 0x00ff00ff, - x, x+width, - y, y+height ); + intel->vtbl.draw_quad(intel, + 0, width, 0, height, + 0x00ff00ff, x, x + width, y, y + height); intel->vtbl.leave_meta_state(intel); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); - intel_region_wait_fence( ctx, dest_region ); /* required by GL */ + intel_region_wait_fence(ctx, dest_region); /* required by GL */ return GL_TRUE; #endif @@ -173,18 +162,18 @@ do_texture_readpixels( GLcontext *ctx, -static GLboolean do_blit_readpixels( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - GLvoid *pixels ) +static GLboolean +do_blit_readpixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, GLvoid * pixels) { struct intel_context *intel = intel_context(ctx); struct intel_region *src = intel_readbuf_region(intel); struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj); GLuint dst_offset; GLuint rowLength; - GLuint fence = bmInitFence(intel); + struct _DriFenceObject *fence = NULL; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); @@ -205,21 +194,21 @@ static GLboolean do_blit_readpixels( GLcontext *ctx, /* PBO only for now: */ if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - not PBO\n", __FUNCTION__); + _mesa_printf("%s - not PBO\n", __FUNCTION__); return GL_FALSE; } - + if (ctx->_ImageTransferState || !intel_check_blit_format(src, format, type)) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad format for blit\n", __FUNCTION__); + _mesa_printf("%s - bad format for blit\n", __FUNCTION__); return GL_FALSE; } if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: bad packing params\n", __FUNCTION__); + _mesa_printf("%s: bad packing params\n", __FUNCTION__); return GL_FALSE; } @@ -230,7 +219,7 @@ static GLboolean do_blit_readpixels( GLcontext *ctx, if (pack->Invert) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__); + _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__); return GL_FALSE; } else { @@ -239,31 +228,29 @@ static GLboolean do_blit_readpixels( GLcontext *ctx, /* XXX 64-bit cast? */ dst_offset = (GLuint) _mesa_image_address(2, pack, pixels, width, height, - format, type, 0, 0, 0); + format, type, 0, 0, 0); /* Although the blits go on the command buffer, need to do this and * fire with lock held to guarentee cliprects are correct. */ - intelFlush( &intel->ctx ); - LOCK_HARDWARE( intel ); + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); - if (intel->driDrawable->numClipRects) - { + if (intel->driDrawable->numClipRects) { GLboolean all = (width * height * src->cpp == dst->Base.Size && - x == 0 && - dst_offset == 0); - - struct buffer *dst_buffer = intel_bufferobj_buffer(intel, dst, - all ? INTEL_WRITE_FULL : - INTEL_WRITE_PART); - __DRIdrawablePrivate *dPriv = intel->driDrawable; + x == 0 && dst_offset == 0); + + struct _DriBufferObject *dst_buffer = + intel_bufferobj_buffer(intel, dst, all ? INTEL_WRITE_FULL : + INTEL_WRITE_PART); + __DRIdrawablePrivate *dPriv = intel->driDrawable; int nbox = dPriv->numClipRects; drm_clip_rect_t *box = dPriv->pClipRects; drm_clip_rect_t rect; drm_clip_rect_t src_rect; int i; - + src_rect.x1 = dPriv->x + x; src_rect.y1 = dPriv->y + dPriv->h - (y + height); src_rect.x2 = src_rect.x1 + width; @@ -271,31 +258,32 @@ static GLboolean do_blit_readpixels( GLcontext *ctx, - for (i = 0 ; i < nbox ; i++) - { - if (!intel_intersect_cliprects(&rect, &src_rect, &box[i])) - continue; + for (i = 0; i < nbox; i++) { + if (!intel_intersect_cliprects(&rect, &src_rect, &box[i])) + continue; - intelEmitCopyBlit( intel, - src->cpp, - src->pitch, src->buffer, 0, - rowLength, - dst_buffer, dst_offset, - rect.x1, - rect.y1, - rect.x1 - src_rect.x1, - rect.y2 - src_rect.y2, - rect.x2 - rect.x1, - rect.y2 - rect.y1 ); + intelEmitCopyBlit(intel, + src->cpp, + src->pitch, src->buffer, 0, + rowLength, + dst_buffer, dst_offset, + rect.x1, + rect.y1, + rect.x1 - src_rect.x1, + rect.y2 - src_rect.y2, + rect.x2 - rect.x1, rect.y2 - rect.y1); } fence = intel_batchbuffer_flush(intel->batch); + driFenceReference(fence); + } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); if (intel->driDrawable->numClipRects) - bmFinishFence(intel, fence); + driFenceFinish(fence, DRM_FENCE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE); + driFenceUnReference(fence); if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s - DONE\n", __FUNCTION__); @@ -303,26 +291,26 @@ static GLboolean do_blit_readpixels( GLcontext *ctx, } void -intelReadPixels( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - GLvoid *pixels ) +intelReadPixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, GLvoid * pixels) { if (INTEL_DEBUG & DEBUG_PIXEL) fprintf(stderr, "%s\n", __FUNCTION__); - intelFlush( ctx ); + intelFlush(ctx); - if (do_blit_readpixels(ctx, x, y, width, height, format, type, pack, pixels)) + if (do_blit_readpixels + (ctx, x, y, width, height, format, type, pack, pixels)) return; - if (do_texture_readpixels(ctx, x, y, width, height, format, type, pack, pixels)) + if (do_texture_readpixels + (ctx, x, y, width, height, format, type, pack, pixels)) return; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s: fallback to swrast\n", __FUNCTION__); - _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, pixels); + _swrast_ReadPixels(ctx, x, y, width, height, format, type, pack, pixels); } - diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c index 8eb055d624b..4afb89b01b9 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.c +++ b/src/mesa/drivers/dri/i915/intel_regions.c @@ -42,41 +42,43 @@ #include "intel_context.h" #include "intel_regions.h" #include "intel_blit.h" -#include "intel_bufmgr.h" #include "intel_buffer_objects.h" +#include "dri_bufmgr.h" +#include "intel_batchbuffer.h" #define FILE_DEBUG_FLAG DEBUG_BUFMGR /* XXX: Thread safety? */ -GLubyte *intel_region_map(struct intel_context *intel, struct intel_region *region) +GLubyte * +intel_region_map(struct intel_context *intel, struct intel_region *region) { DBG("%s\n", __FUNCTION__); if (!region->map_refcount++) { if (region->pbo) - intel_region_cow(intel, region); + intel_region_cow(intel, region); - region->map = bmMapBuffer(intel, region->buffer, 0); + region->map = driBOMap(region->buffer, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0); } return region->map; } -void intel_region_unmap(struct intel_context *intel, - struct intel_region *region) +void +intel_region_unmap(struct intel_context *intel, struct intel_region *region) { DBG("%s\n", __FUNCTION__); if (!--region->map_refcount) { - bmUnmapBuffer(intel, region->buffer); + driBOUnmap(region->buffer); region->map = NULL; } } -struct intel_region *intel_region_alloc( struct intel_context *intel, - GLuint cpp, - GLuint pitch, - GLuint height ) +struct intel_region * +intel_region_alloc(struct intel_context *intel, + GLuint cpp, GLuint pitch, GLuint height) { struct intel_region *region = calloc(sizeof(*region), 1); @@ -84,17 +86,18 @@ struct intel_region *intel_region_alloc( struct intel_context *intel, region->cpp = cpp; region->pitch = pitch; - region->height = height; /* needed? */ + region->height = height; /* needed? */ region->refcount = 1; - bmGenBuffers(intel, "region", 1, ®ion->buffer, 0); - bmBufferData(intel, region->buffer, pitch * cpp * height, NULL, 0); + driGenBuffers(intel->intelScreen->regionPool, + "region", 1, ®ion->buffer, 64, 0, 0); + driBOData(region->buffer, pitch * cpp * height, NULL, 0); return region; } -void intel_region_reference( struct intel_region **dst, - struct intel_region *src) +void +intel_region_reference(struct intel_region **dst, struct intel_region *src) { assert(*dst == NULL); if (src) { @@ -103,13 +106,14 @@ void intel_region_reference( struct intel_region **dst, } } -void intel_region_release( struct intel_context *intel, - struct intel_region **region ) +void +intel_region_release(struct intel_context *intel, + struct intel_region **region) { if (!*region) return; - DBG("%s %d\n", __FUNCTION__, (*region)->refcount-1); + DBG("%s %d\n", __FUNCTION__, (*region)->refcount - 1); ASSERT((*region)->refcount > 0); (*region)->refcount--; @@ -117,10 +121,10 @@ void intel_region_release( struct intel_context *intel, if ((*region)->refcount == 0) { assert((*region)->map_refcount == 0); - if ((*region)->pbo) - intel_region_release_pbo( intel, *region ); + if ((*region)->pbo) + intel_region_release_pbo(intel, *region); else - bmDeleteBuffers(intel, 1, &(*region)->buffer); + driDeleteBuffers(1, &(*region)->buffer); free(*region); } @@ -128,20 +132,19 @@ void intel_region_release( struct intel_context *intel, } -struct intel_region *intel_region_create_static( struct intel_context *intel, - GLuint mem_type, - GLuint offset, - void *virtual, - GLuint cpp, - GLuint pitch, - GLuint height ) +struct intel_region * +intel_region_create_static(struct intel_context *intel, + GLuint mem_type, + GLuint offset, + void *virtual, + GLuint cpp, GLuint pitch, GLuint height) { struct intel_region *region = calloc(sizeof(*region), 1); DBG("%s\n", __FUNCTION__); region->cpp = cpp; region->pitch = pitch; - region->height = height; /* needed? */ + region->height = height; /* needed? */ region->refcount = 1; /* @@ -149,8 +152,11 @@ struct intel_region *intel_region_create_static( struct intel_context *intel, * shared by others. */ - bmGenBuffers(intel, "static region", 1, ®ion->buffer, DRM_MM_TT | DRM_MM_SHARED); - bmSetShared(intel, region->buffer, DRM_MM_TT, offset, virtual); + driGenBuffers(intel->intelScreen->staticPool, "static region", 1, + ®ion->buffer, 64, + DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_EVICT | + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0); + driBOSetStatic(region->buffer, offset, pitch * cpp * height, virtual, 0); return region; } @@ -160,17 +166,15 @@ struct intel_region *intel_region_create_static( struct intel_context *intel, /* * XXX Move this into core Mesa? */ -static void _mesa_copy_rect( GLubyte *dst, - GLuint cpp, - GLuint dst_pitch, - GLuint dst_x, - GLuint dst_y, - GLuint width, - GLuint height, - GLubyte *src, - GLuint src_pitch, - GLuint src_x, - GLuint src_y ) +static void +_mesa_copy_rect(GLubyte * dst, + GLuint cpp, + GLuint dst_pitch, + GLuint dst_x, + GLuint dst_y, + GLuint width, + GLuint height, + GLubyte * src, GLuint src_pitch, GLuint src_x, GLuint src_y) { GLuint i; @@ -182,14 +186,13 @@ static void _mesa_copy_rect( GLubyte *dst, src += src_y * dst_pitch; width *= cpp; - if (width == dst_pitch && - width == src_pitch) + if (width == dst_pitch && width == src_pitch) memcpy(dst, src, height * width); else { for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; + memcpy(dst, src, width); + dst += dst_pitch; + src += src_pitch; } } } @@ -202,115 +205,102 @@ static void _mesa_copy_rect( GLubyte *dst, * * Currently always memcpy. */ -void intel_region_data(struct intel_context *intel, - struct intel_region *dst, - GLuint dst_offset, - GLuint dstx, GLuint dsty, - void *src, GLuint src_pitch, - GLuint srcx, GLuint srcy, - GLuint width, GLuint height) +void +intel_region_data(struct intel_context *intel, + struct intel_region *dst, + GLuint dst_offset, + GLuint dstx, GLuint dsty, + void *src, GLuint src_pitch, + GLuint srcx, GLuint srcy, GLuint width, GLuint height) { DBG("%s\n", __FUNCTION__); if (dst->pbo) { - if (dstx == 0 && - dsty == 0 && - width == dst->pitch && - height == dst->height) - intel_region_release_pbo(intel, dst); + if (dstx == 0 && + dsty == 0 && width == dst->pitch && height == dst->height) + intel_region_release_pbo(intel, dst); else - intel_region_cow(intel, dst); + intel_region_cow(intel, dst); } - + LOCK_HARDWARE(intel); - + _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset, - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - src, - src_pitch, - srcx, srcy); + dst->cpp, + dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); intel_region_unmap(intel, dst); UNLOCK_HARDWARE(intel); - + } - + /* Copy rectangular sub-regions. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ -void intel_region_copy( struct intel_context *intel, - struct intel_region *dst, - GLuint dst_offset, - GLuint dstx, GLuint dsty, - struct intel_region *src, - GLuint src_offset, - GLuint srcx, GLuint srcy, - GLuint width, GLuint height ) +void +intel_region_copy(struct intel_context *intel, + struct intel_region *dst, + GLuint dst_offset, + GLuint dstx, GLuint dsty, + struct intel_region *src, + GLuint src_offset, + GLuint srcx, GLuint srcy, GLuint width, GLuint height) { DBG("%s\n", __FUNCTION__); if (dst->pbo) { - if (dstx == 0 && - dsty == 0 && - width == dst->pitch && - height == dst->height) - intel_region_release_pbo(intel, dst); + if (dstx == 0 && + dsty == 0 && width == dst->pitch && height == dst->height) + intel_region_release_pbo(intel, dst); else - intel_region_cow(intel, dst); + intel_region_cow(intel, dst); } assert(src->cpp == dst->cpp); intelEmitCopyBlit(intel, - dst->cpp, - src->pitch, src->buffer, src_offset, - dst->pitch, dst->buffer, dst_offset, - srcx, srcy, - dstx, dsty, - width, height); + dst->cpp, + src->pitch, src->buffer, src_offset, + dst->pitch, dst->buffer, dst_offset, + srcx, srcy, dstx, dsty, width, height); } /* Fill a rectangular sub-region. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ -void intel_region_fill( struct intel_context *intel, - struct intel_region *dst, - GLuint dst_offset, - GLuint dstx, GLuint dsty, - GLuint width, GLuint height, - GLuint color ) +void +intel_region_fill(struct intel_context *intel, + struct intel_region *dst, + GLuint dst_offset, + GLuint dstx, GLuint dsty, + GLuint width, GLuint height, GLuint color) { DBG("%s\n", __FUNCTION__); - + if (dst->pbo) { - if (dstx == 0 && - dsty == 0 && - width == dst->pitch && - height == dst->height) - intel_region_release_pbo(intel, dst); + if (dstx == 0 && + dsty == 0 && width == dst->pitch && height == dst->height) + intel_region_release_pbo(intel, dst); else - intel_region_cow(intel, dst); + intel_region_cow(intel, dst); } intelEmitFillBlit(intel, - dst->cpp, - dst->pitch, dst->buffer, dst_offset, - dstx, dsty, - width, height, - color ); + dst->cpp, + dst->pitch, dst->buffer, dst_offset, + dstx, dsty, width, height, color); } /* Attach to a pbo, discarding our data. Effectively zero-copy upload * the pbo's data. */ -void intel_region_attach_pbo( struct intel_context *intel, - struct intel_region *region, - struct intel_buffer_object *pbo ) +void +intel_region_attach_pbo(struct intel_context *intel, + struct intel_region *region, + struct intel_buffer_object *pbo) { if (region->pbo == pbo) return; @@ -323,83 +313,79 @@ void intel_region_attach_pbo( struct intel_context *intel, if (region->pbo) { region->pbo->region = NULL; region->pbo = NULL; - region->buffer = NULL; /* refcount? */ + region->buffer = NULL; /* refcount? */ } if (region->buffer) { - bmDeleteBuffers(intel, 1, region->buffer); + driDeleteBuffers(1, ®ion->buffer); } region->pbo = pbo; region->pbo->region = region; - region->buffer = pbo->buffer; /* refcount? */ + region->buffer = pbo->buffer; /* refcount? */ - _mesa_printf("%s attach buffer %p from pbo\n", region->buffer); } /* Break the COW tie to the pbo. The pbo gets to keep the data. */ -void intel_region_release_pbo( struct intel_context *intel, - struct intel_region *region ) +void +intel_region_release_pbo(struct intel_context *intel, + struct intel_region *region) { assert(region->buffer == region->pbo->buffer); - region->pbo->region = NULL; + region->pbo->region = NULL; region->pbo = NULL; - region->buffer = NULL; /* refcount? */ + region->buffer = NULL; /* refcount? */ - bmGenBuffers(intel, "region", 1, ®ion->buffer, 0); - bmBufferData(intel, region->buffer, - region->cpp * region->pitch * region->height, NULL, 0); + driGenBuffers(intel->intelScreen->regionPool, + "region", 1, ®ion->buffer, 64, 0, 0); + driBOData(region->buffer, + region->cpp * region->pitch * region->height, NULL, 0); } /* Break the COW tie to the pbo. Both the pbo and the region end up * with a copy of the data. */ -void intel_region_cow( struct intel_context *intel, - struct intel_region *region ) +void +intel_region_cow(struct intel_context *intel, struct intel_region *region) { struct intel_buffer_object *pbo = region->pbo; intel_region_release_pbo(intel, region); - assert(region->cpp * - region->pitch * - region->height == pbo->Base.Size); + assert(region->cpp * region->pitch * region->height == pbo->Base.Size); _mesa_printf("%s (%d bytes)\n", __FUNCTION__, pbo->Base.Size); /* Now blit from the texture buffer to the new buffer: */ - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); LOCK_HARDWARE(intel); - intelEmitCopyBlit( intel, - region->cpp, - region->pitch, - region->buffer, 0, - region->pitch, - pbo->buffer, 0, - 0,0, - 0,0, - region->pitch, - region->height ); + intelEmitCopyBlit(intel, + region->cpp, + region->pitch, + region->buffer, 0, + region->pitch, + pbo->buffer, 0, + 0, 0, 0, 0, region->pitch, region->height); - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); UNLOCK_HARDWARE(intel); } -struct buffer *intel_region_buffer( struct intel_context *intel, - struct intel_region *region, - GLuint flag ) +struct _DriBufferObject * +intel_region_buffer(struct intel_context *intel, + struct intel_region *region, GLuint flag) { if (region->pbo) { if (flag == INTEL_WRITE_PART) - intel_region_cow(intel, region); + intel_region_cow(intel, region); else if (flag == INTEL_WRITE_FULL) - intel_region_release_pbo(intel, region); + intel_region_release_pbo(intel, region); } return region->buffer; -} +} diff --git a/src/mesa/drivers/dri/i915/intel_regions.h b/src/mesa/drivers/dri/i915/intel_regions.h index a54de926d35..e3a285fe867 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.h +++ b/src/mesa/drivers/dri/i915/intel_regions.h @@ -29,7 +29,7 @@ #define INTEL_REGIONS_H #include "mtypes.h" -#include "intel_bufmgr.h" /* for DBG! */ + struct intel_context; struct intel_buffer_object; @@ -41,8 +41,9 @@ struct intel_buffer_object; * - Buffer dimensions - pitch and height. * - Blitter commands for copying 2D regions between buffers. (really???) */ -struct intel_region { - struct buffer *buffer; /**< buffer manager's buffer ID */ +struct intel_region +{ + struct _DriBufferObject *buffer; /**< buffer manager's buffer ID */ GLuint refcount; /**< Reference count for region */ GLuint cpp; /**< bytes per pixel */ GLuint pitch; /**< in pixels */ @@ -52,84 +53,78 @@ struct intel_region { GLuint draw_offset; /**< Offset of drawing address within the region */ - struct intel_buffer_object *pbo; /* zero-copy uploads */ + struct intel_buffer_object *pbo; /* zero-copy uploads */ }; /* Allocate a refcounted region. Pointers to regions should only be * copied by calling intel_reference_region(). */ -struct intel_region *intel_region_alloc( struct intel_context *intel, - GLuint cpp, - GLuint pitch, - GLuint height ); +struct intel_region *intel_region_alloc(struct intel_context *intel, + GLuint cpp, + GLuint pitch, GLuint height); -void intel_region_reference( struct intel_region **dst, - struct intel_region *src ); +void intel_region_reference(struct intel_region **dst, + struct intel_region *src); void intel_region_release(struct intel_context *intel, - struct intel_region **ib ); + struct intel_region **ib); -struct intel_region *intel_region_create_static( struct intel_context *intel, - GLuint mem_type, - GLuint offset, - void *virtual, - GLuint cpp, - GLuint pitch, - GLuint height ); +struct intel_region *intel_region_create_static(struct intel_context *intel, + GLuint mem_type, + GLuint offset, + void *virtual, + GLuint cpp, + GLuint pitch, GLuint height); /* Map/unmap regions. This is refcounted also: */ -GLubyte *intel_region_map(struct intel_context *intel, - struct intel_region *ib); +GLubyte *intel_region_map(struct intel_context *intel, + struct intel_region *ib); -void intel_region_unmap(struct intel_context *intel, - struct intel_region *ib); +void intel_region_unmap(struct intel_context *intel, struct intel_region *ib); /* Upload data to a rectangular sub-region */ -void intel_region_data(struct intel_context *intel, - struct intel_region *dest, - GLuint dest_offset, - GLuint destx, GLuint desty, - void *src, GLuint src_stride, - GLuint srcx, GLuint srcy, - GLuint width, GLuint height); - +void intel_region_data(struct intel_context *intel, + struct intel_region *dest, + GLuint dest_offset, + GLuint destx, GLuint desty, + void *src, GLuint src_stride, + GLuint srcx, GLuint srcy, GLuint width, GLuint height); + /* Copy rectangular sub-regions */ -void intel_region_copy( struct intel_context *intel, - struct intel_region *dest, - GLuint dest_offset, - GLuint destx, GLuint desty, - struct intel_region *src, - GLuint src_offset, - GLuint srcx, GLuint srcy, - GLuint width, GLuint height ); +void intel_region_copy(struct intel_context *intel, + struct intel_region *dest, + GLuint dest_offset, + GLuint destx, GLuint desty, + struct intel_region *src, + GLuint src_offset, + GLuint srcx, GLuint srcy, GLuint width, GLuint height); /* Fill a rectangular sub-region */ -void intel_region_fill( struct intel_context *intel, - struct intel_region *dest, - GLuint dest_offset, - GLuint destx, GLuint desty, - GLuint width, GLuint height, - GLuint color ); +void intel_region_fill(struct intel_context *intel, + struct intel_region *dest, + GLuint dest_offset, + GLuint destx, GLuint desty, + GLuint width, GLuint height, GLuint color); /* Helpers for zerocopy uploads, particularly texture image uploads: */ -void intel_region_attach_pbo( struct intel_context *intel, - struct intel_region *region, - struct intel_buffer_object *pbo ); -void intel_region_release_pbo( struct intel_context *intel, - struct intel_region *region ); -void intel_region_cow( struct intel_context *intel, - struct intel_region *region ); +void intel_region_attach_pbo(struct intel_context *intel, + struct intel_region *region, + struct intel_buffer_object *pbo); +void intel_region_release_pbo(struct intel_context *intel, + struct intel_region *region); +void intel_region_cow(struct intel_context *intel, + struct intel_region *region); -struct buffer *intel_region_buffer( struct intel_context *intel, - struct intel_region *region, - GLuint flag ); +struct _DriBufferObject *intel_region_buffer(struct intel_context *intel, + struct intel_region *region, + GLuint flag); #endif diff --git a/src/mesa/drivers/dri/i915/intel_render.c b/src/mesa/drivers/dri/i915/intel_render.c index 075b453848b..5f12f701a94 100644 --- a/src/mesa/drivers/dri/i915/intel_render.c +++ b/src/mesa/drivers/dri/i915/intel_render.c @@ -51,14 +51,14 @@ * dma buffers. Use strip/fan hardware primitives where possible. * Try to simulate missing primitives with indexed vertices. */ -#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to - * be adjusted for points on the INTEL/I845G - */ +#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to + * be adjusted for points on the INTEL/I845G + */ #define HAVE_LINES 1 #define HAVE_LINE_STRIPS 1 #define HAVE_TRIANGLES 1 #define HAVE_TRI_STRIPS 1 -#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */ +#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */ #define HAVE_TRI_FANS 1 #define HAVE_POLYGONS 1 #define HAVE_QUADS 0 @@ -66,7 +66,7 @@ #define HAVE_ELTS 0 -static GLuint hw_prim[GL_POLYGON+1] = { +static GLuint hw_prim[GL_POLYGON + 1] = { 0, PRIM3D_LINELIST, PRIM3D_LINESTRIP, @@ -79,7 +79,7 @@ static GLuint hw_prim[GL_POLYGON+1] = { PRIM3D_POLY }; -static const GLenum reduced_prim[GL_POLYGON+1] = { +static const GLenum reduced_prim[GL_POLYGON + 1] = { GL_POINTS, GL_LINES, GL_LINES, @@ -92,26 +92,28 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { GL_TRIANGLES }; -static const int scale_prim[GL_POLYGON+1] = { - 0, /* fallback case */ +static const int scale_prim[GL_POLYGON + 1] = { + 0, /* fallback case */ 1, 2, 2, 1, 3, 3, - 0, /* fallback case */ - 0, /* fallback case */ + 0, /* fallback case */ + 0, /* fallback case */ 3 }; -static void intelDmaPrimitive( struct intel_context *intel, GLenum prim ) +static void +intelDmaPrimitive(struct intel_context *intel, GLenum prim) { - if (0) fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); + if (0) + fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); INTEL_FIREVERTICES(intel); - intel->vtbl.reduced_primitive_state( intel, reduced_prim[prim] ); - intelStartInlinePrimitive( intel, hw_prim[prim], INTEL_BATCH_CLIPRECTS ); + intel->vtbl.reduced_primitive_state(intel, reduced_prim[prim]); + intelStartInlinePrimitive(intel, hw_prim[prim], INTEL_BATCH_CLIPRECTS); } @@ -133,22 +135,22 @@ do { \ #define ALLOC_VERTS( nr ) \ intelExtendInlinePrimitive( intel, (nr) * intel->vertex_size ) - + #define EMIT_VERTS( ctx, j, nr, buf ) \ - _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) + _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) #define TAG(x) intel_##x #include "tnl_dd/t_dd_dmatmp.h" - - + + /**********************************************************************/ /* Render pipeline stage */ /**********************************************************************/ /* Heuristic to choose between the two render paths: */ -static GLboolean choose_render( struct intel_context *intel, - struct vertex_buffer *VB ) +static GLboolean +choose_render(struct intel_context *intel, struct vertex_buffer *VB) { int vertsz = intel->vertex_size; int cost_render = 0; @@ -158,20 +160,20 @@ static GLboolean choose_render( struct intel_context *intel, int nr_rverts = 0; int rprim = intel->reduced_primitive; int i = 0; - - for (i = 0 ; i < VB->PrimitiveCount ; i++) { + + for (i = 0; i < VB->PrimitiveCount; i++) { GLuint prim = VB->Primitive[i].mode; GLuint length = VB->Primitive[i].count; if (!length) - continue; + continue; nr_prims++; nr_rverts += length * scale_prim[prim & PRIM_MODE_MASK]; if (reduced_prim[prim & PRIM_MODE_MASK] != rprim) { - nr_rprims++; - rprim = reduced_prim[prim & PRIM_MODE_MASK]; + nr_rprims++; + rprim = reduced_prim[prim & PRIM_MODE_MASK]; } } @@ -182,22 +184,22 @@ static GLboolean choose_render( struct intel_context *intel, /* One point for every 1024 dwords (4k) of dma: */ - cost_render += (vertsz * i) / 1024; - cost_fallback += (vertsz * nr_rverts) / 1024; + cost_render += (vertsz * i) / 1024; + cost_fallback += (vertsz * nr_rverts) / 1024; if (0) fprintf(stderr, "cost render: %d fallback: %d\n", - cost_render, cost_fallback); + cost_render, cost_fallback); - if (cost_render > cost_fallback) + if (cost_render > cost_fallback) return GL_FALSE; return GL_TRUE; } -static GLboolean intel_run_render( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) +static GLboolean +intel_run_render(GLcontext * ctx, struct tnl_pipeline_stage *stage) { struct intel_context *intel = intel_context(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -206,43 +208,40 @@ static GLboolean intel_run_render( GLcontext *ctx, /* Don't handle clipping or indexed vertices. */ - if (intel->RenderIndex != 0 || - !intel_validate_render( ctx, VB ) || - !choose_render( intel, VB )) { + if (intel->RenderIndex != 0 || + !intel_validate_render(ctx, VB) || !choose_render(intel, VB)) { return GL_TRUE; } tnl->clipspace.new_inputs |= VERT_BIT_POS; - tnl->Driver.Render.Start( ctx ); - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { + tnl->Driver.Render.Start(ctx); + + for (i = 0; i < VB->PrimitiveCount; i++) { GLuint prim = VB->Primitive[i].mode; GLuint start = VB->Primitive[i].start; GLuint length = VB->Primitive[i].count; if (!length) - continue; + continue; - intel_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length, - prim ); + intel_render_tab_verts[prim & PRIM_MODE_MASK] (ctx, start, + start + length, prim); } - - tnl->Driver.Render.Finish( ctx ); - + + tnl->Driver.Render.Finish(ctx); + if (intel->prim.flush) intel->prim.flush(intel); - return GL_FALSE; /* finished the pipe */ + return GL_FALSE; /* finished the pipe */ } -const struct tnl_pipeline_stage _intel_render_stage = -{ +const struct tnl_pipeline_stage _intel_render_stage = { "intel render", NULL, NULL, NULL, NULL, - intel_run_render /* run */ + intel_run_render /* run */ }; diff --git a/src/mesa/drivers/dri/i915/intel_rotate.c b/src/mesa/drivers/dri/i915/intel_rotate.c index a77640ee54d..12d98c4ad2f 100644 --- a/src/mesa/drivers/dri/i915/intel_rotate.c +++ b/src/mesa/drivers/dri/i915/intel_rotate.c @@ -15,11 +15,14 @@ void matrix23Set(struct matrix23 *m, - int m00, int m01, int m02, - int m10, int m11, int m12) + int m00, int m01, int m02, int m10, int m11, int m12) { - m->m00 = m00; m->m01 = m01; m->m02 = m02; - m->m10 = m10; m->m11 = m11; m->m12 = m12; + m->m00 = m00; + m->m01 = m01; + m->m02 = m02; + m->m10 = m10; + m->m11 = m11; + m->m12 = m12; } @@ -66,9 +69,9 @@ matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist) *yDist = (y1 - y0) + (y2 - y0); if (*xDist < 0) - *xDist = -*xDist; + *xDist = -*xDist; if (*yDist < 0) - *yDist = -*yDist; + *yDist = -*yDist; } @@ -76,7 +79,8 @@ matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist) * Transform the rect defined by (x, y, w, h) by m. */ void -matrix23TransformRect(const struct matrix23 *m, int *x, int *y, int *w, int *h) +matrix23TransformRect(const struct matrix23 *m, int *x, int *y, int *w, + int *h) { int x0 = *x, y0 = *y; int x1 = *x + *w, y1 = *y; @@ -108,16 +112,16 @@ matrix23Rotate(struct matrix23 *m, int width, int height, int angle) matrix23Set(m, 1, 0, 0, 0, 1, 0); break; case 90: - matrix23Set(m, 0, 1, 0, -1, 0, width); + matrix23Set(m, 0, 1, 0, -1, 0, width); break; case 180: - matrix23Set(m, -1, 0, width, 0, -1, height); + matrix23Set(m, -1, 0, width, 0, -1, height); break; case 270: - matrix23Set(m, 0, -1, height, 1, 0, 0); + matrix23Set(m, 0, -1, height, 1, 0, 0); break; default: - /*abort()*/; + /*abort() */ ; } } @@ -129,16 +133,24 @@ void matrix23Flip(struct matrix23 *m, int width, int height, int xflip, int yflip) { if (xflip) { - m->m00 = -1; m->m01 = 0; m->m02 = width - 1; + m->m00 = -1; + m->m01 = 0; + m->m02 = width - 1; } else { - m->m00 = 1; m->m01 = 0; m->m02 = 0; + m->m00 = 1; + m->m01 = 0; + m->m02 = 0; } if (yflip) { - m->m10 = 0; m->m11 = -1; m->m12 = height - 1; + m->m10 = 0; + m->m11 = -1; + m->m12 = height - 1; } else { - m->m10 = 0; m->m11 = 1; m->m12 = 0; + m->m10 = 0; + m->m11 = 1; + m->m12 = 0; } } @@ -169,14 +181,18 @@ main(int argc, char *argv[]) { int width = 500, height = 400; int rot; - int fx = 0, fy = 0; /* flip x and/or y ? */ + int fx = 0, fy = 0; /* flip x and/or y ? */ int coords[4][2]; /* four corner coords to test with */ - coords[0][0] = 0; coords[0][1] = 0; - coords[1][0] = width-1; coords[1][1] = 0; - coords[2][0] = width-1; coords[2][1] = height-1; - coords[3][0] = 0; coords[3][1] = height-1; + coords[0][0] = 0; + coords[0][1] = 0; + coords[1][0] = width - 1; + coords[1][1] = 0; + coords[2][0] = width - 1; + coords[2][1] = height - 1; + coords[3][0] = 0; + coords[3][1] = height - 1; for (rot = 0; rot < 360; rot += 90) { diff --git a/src/mesa/drivers/dri/i915/intel_rotate.h b/src/mesa/drivers/dri/i915/intel_rotate.h index 0da45d20ce5..9c8802ca477 100644 --- a/src/mesa/drivers/dri/i915/intel_rotate.h +++ b/src/mesa/drivers/dri/i915/intel_rotate.h @@ -11,11 +11,9 @@ struct matrix23 extern void matrix23Set(struct matrix23 *m, - int m00, int m01, int m02, - int m10, int m11, int m12); + int m00, int m01, int m02, int m10, int m11, int m12); -extern void -matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y); +extern void matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y); extern void matrix23TransformCoordf(const struct matrix23 *m, float *x, float *y); diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 6e42c62cc4f..a44ef24e23b 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -46,40 +46,38 @@ #include "intel_fbo.h" #include "i830_dri.h" +#include "dri_bufpool.h" PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END - DRI_CONF_SECTION_QUALITY - DRI_CONF_FORCE_S3TC_ENABLE(false) - DRI_CONF_ALLOW_LARGE_TEXTURES(1) - DRI_CONF_SECTION_END -DRI_CONF_END; -const GLuint __driNConfigOptions = 4; + DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) + DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY + DRI_CONF_FORCE_S3TC_ENABLE(false) + DRI_CONF_ALLOW_LARGE_TEXTURES(1) + DRI_CONF_SECTION_END DRI_CONF_END; + const GLuint __driNConfigOptions = 4; #ifdef USE_NEW_INTERFACE -static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; -#endif /*USE_NEW_INTERFACE*/ + static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; +#endif /*USE_NEW_INTERFACE */ -extern const struct dri_extension card_extensions[]; + extern const struct dri_extension card_extensions[]; /** * Map all the memory regions described by the screen. * \return GL_TRUE if success, GL_FALSE if error. */ GLboolean -intelMapScreenRegions(__DRIscreenPrivate *sPriv) +intelMapScreenRegions(__DRIscreenPrivate * sPriv) { - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; if (intelScreen->front.handle) { if (drmMap(sPriv->fd, intelScreen->front.handle, intelScreen->front.size, - (drmAddress *)&intelScreen->front.map) != 0) { + (drmAddress *) & intelScreen->front.map) != 0) { _mesa_problem(NULL, "drmMap(frontbuffer) failed!"); return GL_FALSE; } @@ -88,42 +86,45 @@ intelMapScreenRegions(__DRIscreenPrivate *sPriv) _mesa_warning(NULL, "no front buffer handle in intelMapScreenRegions!"); } + _mesa_printf("Back 0x%08x ", intelScreen->back.handle); if (drmMap(sPriv->fd, intelScreen->back.handle, intelScreen->back.size, - (drmAddress *)&intelScreen->back.map) != 0) { + (drmAddress *) & intelScreen->back.map) != 0) { intelUnmapScreenRegions(intelScreen); return GL_FALSE; } + _mesa_printf("Depth 0x%08x ", intelScreen->depth.handle); if (drmMap(sPriv->fd, intelScreen->depth.handle, intelScreen->depth.size, - (drmAddress *)&intelScreen->depth.map) != 0) { + (drmAddress *) & intelScreen->depth.map) != 0) { intelUnmapScreenRegions(intelScreen); return GL_FALSE; } +#if 0 + _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle); if (drmMap(sPriv->fd, intelScreen->tex.handle, intelScreen->tex.size, - (drmAddress *)&intelScreen->tex.map) != 0) { + (drmAddress *) & intelScreen->tex.map) != 0) { intelUnmapScreenRegions(intelScreen); return GL_FALSE; } - +#endif if (0) printf("Mappings: front: %p back: %p depth: %p tex: %p\n", - intelScreen->front.map, - intelScreen->back.map, - intelScreen->depth.map, - intelScreen->tex.map); + intelScreen->front.map, + intelScreen->back.map, + intelScreen->depth.map, intelScreen->tex.map); return GL_TRUE; } void -intelUnmapScreenRegions(intelScreenPrivate *intelScreen) +intelUnmapScreenRegions(intelScreenPrivate * intelScreen) { #define REALLY_UNMAP 1 if (intelScreen->front.map) { @@ -156,9 +157,8 @@ intelUnmapScreenRegions(intelScreenPrivate *intelScreen) static void -intelPrintDRIInfo(intelScreenPrivate *intelScreen, - __DRIscreenPrivate *sPriv, - I830DRIPtr gDRIPriv) +intelPrintDRIInfo(intelScreenPrivate * intelScreen, + __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv) { fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n", intelScreen->front.size, intelScreen->front.offset, @@ -179,9 +179,10 @@ intelPrintDRIInfo(intelScreenPrivate *intelScreen, static void -intelPrintSAREA(const drmI830Sarea *sarea) +intelPrintSAREA(const drmI830Sarea * sarea) { - fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width, sarea->height); + fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width, + sarea->height); fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch); fprintf(stderr, "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n", @@ -195,8 +196,7 @@ intelPrintSAREA(const drmI830Sarea *sarea) sarea->depth_offset, sarea->depth_size, (unsigned) sarea->depth_handle); fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n", - sarea->tex_offset, sarea->tex_size, - (unsigned) sarea->tex_handle); + sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle); fprintf(stderr, "SAREA: rotation: %d\n", sarea->rotation); fprintf(stderr, "SAREA: rotated offset: 0x%08x size: 0x%x\n", @@ -210,8 +210,8 @@ intelPrintSAREA(const drmI830Sarea *sarea) * information in the SAREA. This function updates those parameters. */ void -intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, - drmI830Sarea *sarea) +intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, + drmI830Sarea * sarea) { intelScreen->width = sarea->width; intelScreen->height = sarea->height; @@ -225,7 +225,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, intelScreen->back.pitch = sarea->pitch * intelScreen->cpp; intelScreen->back.handle = sarea->back_handle; intelScreen->back.size = sarea->back_size; - + intelScreen->depth.offset = sarea->depth_offset; intelScreen->depth.pitch = sarea->pitch * intelScreen->cpp; intelScreen->depth.handle = sarea->depth_handle; @@ -250,50 +250,59 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, } -static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) +static GLboolean +intelInitDriver(__DRIscreenPrivate * sPriv) { intelScreenPrivate *intelScreen; - I830DRIPtr gDRIPriv = (I830DRIPtr)sPriv->pDevPriv; + I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv; drmI830Sarea *sarea; PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); - void * const psc = sPriv->psc->screenConfigs; + (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface-> + getProcAddress("glxEnableExtension")); + void *const psc = sPriv->psc->screenConfigs; if (sPriv->devPrivSize != sizeof(I830DRIRec)) { - fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n"); + fprintf(stderr, + "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n"); return GL_FALSE; } /* Allocate the private area */ - intelScreen = (intelScreenPrivate *)CALLOC(sizeof(intelScreenPrivate)); + intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate)); if (!intelScreen) { - fprintf(stderr,"\nERROR! Allocating private area failed\n"); + fprintf(stderr, "\nERROR! Allocating private area failed\n"); return GL_FALSE; } /* parse information in __driConfigOptions */ - driParseOptionInfo (&intelScreen->optionCache, - __driConfigOptions, __driNConfigOptions); + driParseOptionInfo(&intelScreen->optionCache, + __driConfigOptions, __driNConfigOptions); intelScreen->driScrnPriv = sPriv; - sPriv->private = (void *)intelScreen; + sPriv->private = (void *) intelScreen; intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; sarea = (drmI830Sarea *) - (((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset); + (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset); intelScreen->deviceID = gDRIPriv->deviceID; intelScreen->mem = gDRIPriv->mem; intelScreen->cpp = gDRIPriv->cpp; switch (gDRIPriv->bitsPerPixel) { - case 16: intelScreen->fbFormat = DV_PF_565; break; - case 32: intelScreen->fbFormat = DV_PF_8888; break; - default: exit(1); break; + case 16: + intelScreen->fbFormat = DV_PF_565; + break; + case 32: + intelScreen->fbFormat = DV_PF_8888; + break; + default: + exit(1); + break; } - + intelUpdateScreenFromSAREA(intelScreen, sarea); if (!intelMapScreenRegions(sPriv)) { - fprintf(stderr,"\nERROR! mapping regions\n"); + fprintf(stderr, "\nERROR! mapping regions\n"); _mesa_free(intelScreen); sPriv->private = NULL; return GL_FALSE; @@ -316,10 +325,11 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) intelScreen->tex.handle = 0; intelScreen->tex.size = 0; #endif - + intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; - - if (1) intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); + + if (1) + intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); intelScreen->drmMinor = sPriv->drmMinor; @@ -331,11 +341,11 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) gp.param = I830_PARAM_IRQ_ACTIVE; gp.value = &intelScreen->irq_active; - ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM, - &gp, sizeof(gp)); + ret = drmCommandWriteRead(sPriv->fd, DRM_I830_GETPARAM, + &gp, sizeof(gp)); if (ret) { - fprintf(stderr, "drmI830GetParam: %d\n", ret); - return GL_FALSE; + fprintf(stderr, "drmI830GetParam: %d\n", ret); + return GL_FALSE; } } @@ -347,31 +357,49 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) gp.param = I830_PARAM_ALLOW_BATCHBUFFER; gp.value = &intelScreen->allow_batchbuffer; - ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM, - &gp, sizeof(gp)); + ret = drmCommandWriteRead(sPriv->fd, DRM_I830_GETPARAM, + &gp, sizeof(gp)); if (ret) { - fprintf(stderr, "drmI830GetParam: (%d) %d\n", gp.param, ret); - return GL_FALSE; + fprintf(stderr, "drmI830GetParam: (%d) %d\n", gp.param, ret); + return GL_FALSE; } } if (glx_enable_extension != NULL) { - (*glx_enable_extension)( psc, "GLX_SGI_swap_control" ); - (*glx_enable_extension)( psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( psc, "GLX_MESA_swap_control" ); - (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" ); - (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" ); + (*glx_enable_extension) (psc, "GLX_SGI_swap_control"); + (*glx_enable_extension) (psc, "GLX_SGI_video_sync"); + (*glx_enable_extension) (psc, "GLX_MESA_swap_control"); + (*glx_enable_extension) (psc, "GLX_MESA_swap_frame_usage"); + (*glx_enable_extension) (psc, "GLX_SGI_make_current_read"); } - + + intelScreen->regionPool = driDRMPoolInit(sPriv->fd); + if (!intelScreen->regionPool) + return GL_FALSE; + intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd); + if (!intelScreen->staticPool) + return GL_FALSE; + intelScreen->texPool = intelScreen->regionPool; + intelScreen->batchPool = driBatchPoolInit(sPriv->fd, + DRM_BO_FLAG_EXE | + DRM_BO_FLAG_MEM_TT | + DRM_BO_FLAG_MEM_LOCAL, + 4096, 100, 5); + return GL_TRUE; } - - -static void intelDestroyScreen(__DRIscreenPrivate *sPriv) + + +static void +intelDestroyScreen(__DRIscreenPrivate * sPriv) { - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; intelUnmapScreenRegions(intelScreen); + + driPoolTakeDown(intelScreen->regionPool); + driPoolTakeDown(intelScreen->staticPool); + driPoolTakeDown(intelScreen->batchPool); FREE(intelScreen); sPriv->private = NULL; } @@ -380,18 +408,19 @@ static void intelDestroyScreen(__DRIscreenPrivate *sPriv) /** * This is called when we need to set up GL rendering to a new X window. */ -static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) +static GLboolean +intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, + __DRIdrawablePrivate * driDrawPriv, + const __GLcontextModes * mesaVis, GLboolean isPixmap) { intelScreenPrivate *screen = (intelScreenPrivate *) driScrnPriv->private; if (isPixmap) { - return GL_FALSE; /* not implemented */ - } else { - GLboolean swStencil = (mesaVis->stencilBits > 0 && - mesaVis->depthBits != 24); + return GL_FALSE; /* not implemented */ + } + else { + GLboolean swStencil = (mesaVis->stencilBits > 0 && + mesaVis->depthBits != 24); GLenum rgbFormat = (mesaVis->redBits == 5 ? GL_RGB5 : GL_RGBA8); struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); @@ -424,12 +453,11 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv, if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { /* combined depth/stencil buffer */ struct intel_renderbuffer *depthStencilRb - = intel_create_renderbuffer( - GL_DEPTH24_STENCIL8_EXT, + = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT, screen->width, screen->height, screen->depth.offset, screen->depth.pitch, - screen->cpp, /* 4! */ + screen->cpp, /* 4! */ screen->depth.map); intel_set_span_functions(&depthStencilRb->Base); /* note: bind RB to two attachment points */ @@ -443,27 +471,25 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv, screen->width, screen->height, screen->depth.offset, screen->depth.pitch, - screen->cpp, /* 2! */ + screen->cpp, /* 2! */ screen->depth.map); intel_set_span_functions(&depthRb->Base); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); } /* now add any/all software-based renderbuffers we may need */ - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* never sw color */ - GL_FALSE, /* never sw depth */ - swStencil, - mesaVis->accumRedBits > 0, - GL_FALSE, /* never sw alpha */ - GL_FALSE /* never sw aux */); + _mesa_add_soft_renderbuffers(fb, GL_FALSE, /* never sw color */ + GL_FALSE, /* never sw depth */ + swStencil, mesaVis->accumRedBits > 0, GL_FALSE, /* never sw alpha */ + GL_FALSE /* never sw aux */ ); driDrawPriv->driverPrivate = (void *) fb; return (driDrawPriv->driverPrivate != NULL); } } -static void intelDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) +static void +intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv) { _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); } @@ -473,13 +499,13 @@ static void intelDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) * Get information about previous buffer swaps. */ static int -intelGetSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo ) +intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo) { struct intel_context *intel; - if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL) - || (dPriv->driContextPriv->driverPrivate == NULL) - || (sInfo == NULL) ) { + if ((dPriv == NULL) || (dPriv->driContextPriv == NULL) + || (dPriv->driContextPriv->driverPrivate == NULL) + || (sInfo == NULL)) { return -1; } @@ -489,8 +515,8 @@ intelGetSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo ) sInfo->swap_missed_count = intel->swap_missed_count; sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0) - ? driCalculateSwapUsage( dPriv, 0, intel->swap_missed_ust ) - : 0.0; + ? driCalculateSwapUsage(dPriv, 0, intel->swap_missed_ust) + : 0.0; return 0; } @@ -500,23 +526,24 @@ intelGetSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo ) * init-designated function to register chipids and createcontext * functions. */ -extern GLboolean i830CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate); +extern GLboolean i830CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); -extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate); +extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); -static GLboolean intelCreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) +static GLboolean +intelCreateContext(const __GLcontextModes * mesaVis, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate) { __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private; + intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; switch (intelScreen->deviceID) { /* Don't deal with i830 until texture work complete: @@ -525,16 +552,14 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis, case PCI_CHIP_I830_M: case PCI_CHIP_I855_GM: case PCI_CHIP_I865_G: - return i830CreateContext( mesaVis, driContextPriv, - sharedContextPrivate ); + return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate); case PCI_CHIP_I915_G: case PCI_CHIP_I915_GM: case PCI_CHIP_I945_G: case PCI_CHIP_I945_GM: - return i915CreateContext( mesaVis, driContextPriv, - sharedContextPrivate ); - + return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate); + default: fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID); return GL_FALSE; @@ -543,30 +568,30 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis, static const struct __DriverAPIRec intelAPI = { - .InitDriver = intelInitDriver, - .DestroyScreen = intelDestroyScreen, - .CreateContext = intelCreateContext, - .DestroyContext = intelDestroyContext, - .CreateBuffer = intelCreateBuffer, - .DestroyBuffer = intelDestroyBuffer, - .SwapBuffers = intelSwapBuffers, - .MakeCurrent = intelMakeCurrent, - .UnbindContext = intelUnbindContext, - .GetSwapInfo = intelGetSwapInfo, - .GetMSC = driGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL, - .CopySubBuffer = intelCopySubBuffer + .InitDriver = intelInitDriver, + .DestroyScreen = intelDestroyScreen, + .CreateContext = intelCreateContext, + .DestroyContext = intelDestroyContext, + .CreateBuffer = intelCreateBuffer, + .DestroyBuffer = intelDestroyBuffer, + .SwapBuffers = intelSwapBuffers, + .MakeCurrent = intelMakeCurrent, + .UnbindContext = intelUnbindContext, + .GetSwapInfo = intelGetSwapInfo, + .GetMSC = driGetMSC32, + .WaitForMSC = driWaitForMSC32, + .WaitForSBC = NULL, + .SwapBuffersMSC = NULL, + .CopySubBuffer = intelCopySubBuffer }; static __GLcontextModes * -intelFillInModes( unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) +intelFillInModes(unsigned pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer) { - __GLcontextModes * modes; - __GLcontextModes * m; + __GLcontextModes *modes; + __GLcontextModes *m; unsigned num_modes; unsigned depth_buffer_factor; unsigned back_buffer_factor; @@ -597,43 +622,45 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits, stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits; depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1; - back_buffer_factor = (have_back_buffer) ? 3 : 1; + back_buffer_factor = (have_back_buffer) ? 3 : 1; num_modes = depth_buffer_factor * back_buffer_factor * 4; - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) ); - m = modes; - if ( ! driFillInModes( & m, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR ) ) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; + if (pixel_bits == 16) { + fb_format = GL_RGB; + fb_type = GL_UNSIGNED_SHORT_5_6_5; } - if ( ! driFillInModes( & m, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_DIRECT_COLOR ) ) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; + else { + fb_format = GL_BGRA; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + } + + modes = + (*dri_interface->createContextModes) (num_modes, + sizeof(__GLcontextModes)); + m = modes; + if (!driFillInModes(&m, fb_format, fb_type, + depth_bits_array, stencil_bits_array, + depth_buffer_factor, back_buffer_modes, + back_buffer_factor, GLX_TRUE_COLOR)) { + fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, + __LINE__); + return NULL; + } + if (!driFillInModes(&m, fb_format, fb_type, + depth_bits_array, stencil_bits_array, + depth_buffer_factor, back_buffer_modes, + back_buffer_factor, GLX_DIRECT_COLOR)) { + fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, + __LINE__); + return NULL; } /* Mark the visual as slow if there are "fake" stencil bits. */ - for ( m = modes ; m != NULL ; m = m->next ) { - if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) { - m->visualRating = GLX_SLOW_CONFIG; + for (m = modes; m != NULL; m = m->next) { + if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { + m->visualRating = GLX_SLOW_CONFIG; } } @@ -651,18 +678,18 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits, * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on * failure. */ -PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) - +PUBLIC void * +__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn, + __DRIscreen * psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 5, 0 }; @@ -671,23 +698,22 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc dri_interface = interface; - if ( ! driCheckDriDdxDrmVersions2( "i915", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + if (!driCheckDriDdxDrmVersions2("i915", + dri_version, &dri_expected, + ddx_version, &ddx_expected, + drm_version, &drm_expected)) { return NULL; } psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &intelAPI); - if ( psp != NULL ) { + ddx_version, dri_version, drm_version, + frame_buffer, pSAREA, fd, + internal_api_version, &intelAPI); + if (psp != NULL) { I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; - *driver_modes = intelFillInModes( dri_priv->cpp * 8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - 1 ); + *driver_modes = intelFillInModes(dri_priv->cpp * 8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, 1); /* Calling driInitExtensions here, with a NULL context pointer, does not actually * enable the extensions. It just makes sure that all the dispatch offsets for all @@ -697,7 +723,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc * * Hello chicken. Hello egg. How are you two today? */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); + driInitExtensions(NULL, card_extensions, GL_FALSE); } return (void *) psp; diff --git a/src/mesa/drivers/dri/i915/intel_screen.h b/src/mesa/drivers/dri/i915/intel_screen.h index c72d1054e6c..e87639608c2 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.h +++ b/src/mesa/drivers/dri/i915/intel_screen.h @@ -33,38 +33,39 @@ #include "intel_rotate.h" #include "i830_common.h" #include "xmlconfig.h" - +#include "dri_bufpool.h" /* XXX: change name or eliminate to avoid conflict with "struct * intel_region"!!! */ -typedef struct { +typedef struct +{ drm_handle_t handle; - drmSize size; /* region size in bytes */ - char *map; /* memory map */ - int offset; /* from start of video mem, in bytes */ - int pitch; /* row stride, in bytes */ + drmSize size; /* region size in bytes */ + char *map; /* memory map */ + int offset; /* from start of video mem, in bytes */ + int pitch; /* row stride, in bytes */ } intelRegion; -typedef struct +typedef struct { intelRegion front; intelRegion back; intelRegion rotated; intelRegion depth; intelRegion tex; - + int deviceID; int width; int height; - int mem; /* unused */ - - int cpp; /* for front and back buffers */ + int mem; /* unused */ + + int cpp; /* for front and back buffers */ /* int bitsPerPixel; */ - int fbFormat; /* XXX FBO: this is obsolete - remove after i830 updates */ + int fbFormat; /* XXX FBO: this is obsolete - remove after i830 updates */ int logTextureGranularity; - + __DRIscreenPrivate *driScrnPriv; unsigned int sarea_priv_offset; @@ -75,41 +76,45 @@ typedef struct struct matrix23 rotMatrix; - int current_rotation; /* 0, 90, 180 or 270 */ + int current_rotation; /* 0, 90, 180 or 270 */ int rotatedWidth, rotatedHeight; /** * Configuration cache with default values for all contexts */ driOptionCache optionCache; + struct _DriBufferPool *batchPool; + struct _DriBufferPool *texPool; + struct _DriBufferPool *regionPool; + struct _DriBufferPool *staticPool; } intelScreenPrivate; -extern GLboolean -intelMapScreenRegions(__DRIscreenPrivate *sPriv); +extern GLboolean intelMapScreenRegions(__DRIscreenPrivate * sPriv); + +extern void intelUnmapScreenRegions(intelScreenPrivate * intelScreen); extern void -intelUnmapScreenRegions(intelScreenPrivate *intelScreen); +intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, + drmI830Sarea * sarea); -extern void -intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, - drmI830Sarea *sarea); +extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv); -extern void -intelDestroyContext(__DRIcontextPrivate *driContextPriv); +extern GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv); extern GLboolean -intelUnbindContext(__DRIcontextPrivate *driContextPriv); +intelMakeCurrent(__DRIcontextPrivate * driContextPriv, + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv); -extern GLboolean -intelMakeCurrent(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv); +extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv); extern void -intelSwapBuffers(__DRIdrawablePrivate *dPriv); +intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h); -extern void -intelCopySubBuffer( __DRIdrawablePrivate *dPriv, int x, int y, int w, int h ); +extern struct _DriBufferPool *driBatchPoolInit(int fd, unsigned flags, + unsigned long bufSize, + unsigned numBufs, + unsigned checkDelayed); #endif diff --git a/src/mesa/drivers/dri/i915/intel_span.c b/src/mesa/drivers/dri/i915/intel_span.c index 84f5cc037d9..efce3b7e4e0 100644 --- a/src/mesa/drivers/dri/i915/intel_span.c +++ b/src/mesa/drivers/dri/i915/intel_span.c @@ -110,7 +110,7 @@ (intel->drawY * pitch + intel->drawX) * irb->region->cpp; -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS +#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS /** ** 16-bit depthbuffer functions. @@ -188,7 +188,8 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) /* color draw buffers */ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers[i]; j++) { - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i][j]; + struct gl_renderbuffer *rb = + ctx->DrawBuffer->_ColorDrawBuffers[i][j]; irb = intel_renderbuffer(rb); if (irb) { /* this is a user-created intel_renderbuffer */ @@ -206,7 +207,8 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) /* check for render to textures */ for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment + i; + struct gl_renderbuffer_attachment *att = + ctx->DrawBuffer->Attachment + i; struct gl_texture_object *tex = att->Texture; if (tex) { /* render to texture */ @@ -305,7 +307,8 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) * * Old note: Moved locking out to get reasonable span performance. */ -void intelSpanRenderStart( GLcontext *ctx ) +void +intelSpanRenderStart(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); GLuint i; @@ -324,8 +327,8 @@ void intelSpanRenderStart( GLcontext *ctx ) for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) { - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - intel_tex_map_images(intel, intel_texture_object(texObj)); + struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; + intel_tex_map_images(intel, intel_texture_object(texObj)); } } @@ -336,12 +339,13 @@ void intelSpanRenderStart( GLcontext *ctx ) * Called when done softare rendering. Unmap the buffers we mapped in * the above function. */ -void intelSpanRenderFinish( GLcontext *ctx ) +void +intelSpanRenderFinish(GLcontext * ctx) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); GLuint i; - _swrast_flush( ctx ); + _swrast_flush(ctx); /* Now unmap the framebuffer: */ @@ -353,22 +357,23 @@ void intelSpanRenderFinish( GLcontext *ctx ) for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) { - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - intel_tex_unmap_images(intel, intel_texture_object(texObj)); + struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; + intel_tex_unmap_images(intel, intel_texture_object(texObj)); } } intel_map_unmap_buffers(intel, GL_FALSE); - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); } -void intelInitSpanFuncs( GLcontext *ctx ) +void +intelInitSpanFuncs(GLcontext * ctx) { struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); swdd->SpanRenderStart = intelSpanRenderStart; - swdd->SpanRenderFinish = intelSpanRenderFinish; + swdd->SpanRenderFinish = intelSpanRenderFinish; } @@ -390,14 +395,15 @@ intel_set_span_functions(struct gl_renderbuffer *rb) else if (rb->_ActualFormat == GL_DEPTH_COMPONENT16) { intelInitDepthPointers_z16(rb); } - else if (rb->_ActualFormat == GL_DEPTH_COMPONENT24 || /* XXX FBO remove */ + else if (rb->_ActualFormat == GL_DEPTH_COMPONENT24 || /* XXX FBO remove */ rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) { intelInitDepthPointers_z24_s8(rb); } - else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) { /* XXX FBO remove */ + else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) { /* XXX FBO remove */ intelInitStencilPointers_z24_s8(rb); } else { - _mesa_problem(NULL, "Unexpected _ActualFormat in intelSetSpanFunctions"); + _mesa_problem(NULL, + "Unexpected _ActualFormat in intelSetSpanFunctions"); } } diff --git a/src/mesa/drivers/dri/i915/intel_span.h b/src/mesa/drivers/dri/i915/intel_span.h index 98dd57b06a8..5201f6d6c6e 100644 --- a/src/mesa/drivers/dri/i915/intel_span.h +++ b/src/mesa/drivers/dri/i915/intel_span.h @@ -28,12 +28,11 @@ #ifndef _INTEL_SPAN_H #define _INTEL_SPAN_H -extern void intelInitSpanFuncs( GLcontext *ctx ); +extern void intelInitSpanFuncs(GLcontext * ctx); -extern void intelSpanRenderFinish( GLcontext *ctx ); -extern void intelSpanRenderStart( GLcontext *ctx ); +extern void intelSpanRenderFinish(GLcontext * ctx); +extern void intelSpanRenderStart(GLcontext * ctx); -extern void -intel_set_span_functions(struct gl_renderbuffer *rb); +extern void intel_set_span_functions(struct gl_renderbuffer *rb); #endif diff --git a/src/mesa/drivers/dri/i915/intel_state.c b/src/mesa/drivers/dri/i915/intel_state.c index 772bec49711..f85d8ef8353 100644 --- a/src/mesa/drivers/dri/i915/intel_state.c +++ b/src/mesa/drivers/dri/i915/intel_state.c @@ -39,136 +39,141 @@ #include "intel_regions.h" #include "swrast/swrast.h" -int intel_translate_compare_func( GLenum func ) +int +intel_translate_compare_func(GLenum func) { - switch(func) { - case GL_NEVER: - return COMPAREFUNC_NEVER; - case GL_LESS: - return COMPAREFUNC_LESS; - case GL_LEQUAL: - return COMPAREFUNC_LEQUAL; - case GL_GREATER: - return COMPAREFUNC_GREATER; - case GL_GEQUAL: - return COMPAREFUNC_GEQUAL; - case GL_NOTEQUAL: - return COMPAREFUNC_NOTEQUAL; - case GL_EQUAL: - return COMPAREFUNC_EQUAL; - case GL_ALWAYS: - return COMPAREFUNC_ALWAYS; + switch (func) { + case GL_NEVER: + return COMPAREFUNC_NEVER; + case GL_LESS: + return COMPAREFUNC_LESS; + case GL_LEQUAL: + return COMPAREFUNC_LEQUAL; + case GL_GREATER: + return COMPAREFUNC_GREATER; + case GL_GEQUAL: + return COMPAREFUNC_GEQUAL; + case GL_NOTEQUAL: + return COMPAREFUNC_NOTEQUAL; + case GL_EQUAL: + return COMPAREFUNC_EQUAL; + case GL_ALWAYS: + return COMPAREFUNC_ALWAYS; } fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func); - return COMPAREFUNC_ALWAYS; + return COMPAREFUNC_ALWAYS; } -int intel_translate_stencil_op( GLenum op ) +int +intel_translate_stencil_op(GLenum op) { - switch(op) { - case GL_KEEP: - return STENCILOP_KEEP; - case GL_ZERO: - return STENCILOP_ZERO; - case GL_REPLACE: - return STENCILOP_REPLACE; - case GL_INCR: + switch (op) { + case GL_KEEP: + return STENCILOP_KEEP; + case GL_ZERO: + return STENCILOP_ZERO; + case GL_REPLACE: + return STENCILOP_REPLACE; + case GL_INCR: return STENCILOP_INCRSAT; - case GL_DECR: + case GL_DECR: return STENCILOP_DECRSAT; case GL_INCR_WRAP: - return STENCILOP_INCR; + return STENCILOP_INCR; case GL_DECR_WRAP: - return STENCILOP_DECR; - case GL_INVERT: - return STENCILOP_INVERT; - default: + return STENCILOP_DECR; + case GL_INVERT: + return STENCILOP_INVERT; + default: return STENCILOP_ZERO; } } -int intel_translate_blend_factor( GLenum factor ) +int +intel_translate_blend_factor(GLenum factor) { - switch(factor) { - case GL_ZERO: - return BLENDFACT_ZERO; - case GL_SRC_ALPHA: - return BLENDFACT_SRC_ALPHA; - case GL_ONE: - return BLENDFACT_ONE; - case GL_SRC_COLOR: - return BLENDFACT_SRC_COLR; - case GL_ONE_MINUS_SRC_COLOR: - return BLENDFACT_INV_SRC_COLR; - case GL_DST_COLOR: - return BLENDFACT_DST_COLR; - case GL_ONE_MINUS_DST_COLOR: - return BLENDFACT_INV_DST_COLR; + switch (factor) { + case GL_ZERO: + return BLENDFACT_ZERO; + case GL_SRC_ALPHA: + return BLENDFACT_SRC_ALPHA; + case GL_ONE: + return BLENDFACT_ONE; + case GL_SRC_COLOR: + return BLENDFACT_SRC_COLR; + case GL_ONE_MINUS_SRC_COLOR: + return BLENDFACT_INV_SRC_COLR; + case GL_DST_COLOR: + return BLENDFACT_DST_COLR; + case GL_ONE_MINUS_DST_COLOR: + return BLENDFACT_INV_DST_COLR; case GL_ONE_MINUS_SRC_ALPHA: - return BLENDFACT_INV_SRC_ALPHA; - case GL_DST_ALPHA: - return BLENDFACT_DST_ALPHA; + return BLENDFACT_INV_SRC_ALPHA; + case GL_DST_ALPHA: + return BLENDFACT_DST_ALPHA; case GL_ONE_MINUS_DST_ALPHA: - return BLENDFACT_INV_DST_ALPHA; - case GL_SRC_ALPHA_SATURATE: + return BLENDFACT_INV_DST_ALPHA; + case GL_SRC_ALPHA_SATURATE: return BLENDFACT_SRC_ALPHA_SATURATE; case GL_CONSTANT_COLOR: - return BLENDFACT_CONST_COLOR; + return BLENDFACT_CONST_COLOR; case GL_ONE_MINUS_CONSTANT_COLOR: return BLENDFACT_INV_CONST_COLOR; case GL_CONSTANT_ALPHA: - return BLENDFACT_CONST_ALPHA; + return BLENDFACT_CONST_ALPHA; case GL_ONE_MINUS_CONSTANT_ALPHA: return BLENDFACT_INV_CONST_ALPHA; } - + fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, factor); return BLENDFACT_ZERO; } -int intel_translate_logic_op( GLenum opcode ) +int +intel_translate_logic_op(GLenum opcode) { - switch(opcode) { - case GL_CLEAR: - return LOGICOP_CLEAR; - case GL_AND: - return LOGICOP_AND; - case GL_AND_REVERSE: - return LOGICOP_AND_RVRSE; - case GL_COPY: - return LOGICOP_COPY; - case GL_COPY_INVERTED: - return LOGICOP_COPY_INV; - case GL_AND_INVERTED: - return LOGICOP_AND_INV; - case GL_NOOP: - return LOGICOP_NOOP; - case GL_XOR: - return LOGICOP_XOR; - case GL_OR: - return LOGICOP_OR; - case GL_OR_INVERTED: - return LOGICOP_OR_INV; - case GL_NOR: - return LOGICOP_NOR; - case GL_EQUIV: - return LOGICOP_EQUIV; - case GL_INVERT: - return LOGICOP_INV; - case GL_OR_REVERSE: - return LOGICOP_OR_RVRSE; - case GL_NAND: - return LOGICOP_NAND; - case GL_SET: - return LOGICOP_SET; + switch (opcode) { + case GL_CLEAR: + return LOGICOP_CLEAR; + case GL_AND: + return LOGICOP_AND; + case GL_AND_REVERSE: + return LOGICOP_AND_RVRSE; + case GL_COPY: + return LOGICOP_COPY; + case GL_COPY_INVERTED: + return LOGICOP_COPY_INV; + case GL_AND_INVERTED: + return LOGICOP_AND_INV; + case GL_NOOP: + return LOGICOP_NOOP; + case GL_XOR: + return LOGICOP_XOR; + case GL_OR: + return LOGICOP_OR; + case GL_OR_INVERTED: + return LOGICOP_OR_INV; + case GL_NOR: + return LOGICOP_NOR; + case GL_EQUIV: + return LOGICOP_EQUIV; + case GL_INVERT: + return LOGICOP_INV; + case GL_OR_REVERSE: + return LOGICOP_OR_RVRSE; + case GL_NAND: + return LOGICOP_NAND; + case GL_SET: + return LOGICOP_SET; default: return LOGICOP_SET; } } -static void intelClearColor(GLcontext *ctx, const GLfloat color[4]) +static void +intelClearColor(GLcontext * ctx, const GLfloat color[4]) { struct intel_context *intel = intel_context(ctx); GLubyte clear[4]; @@ -191,7 +196,8 @@ static void intelClearColor(GLcontext *ctx, const GLfloat color[4]) * - depthrange * - window pos/size or FBO size */ -static void intelCalcViewport( GLcontext *ctx ) +static void +intelCalcViewport(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); const GLfloat *v = ctx->Viewport._WindowMap.m; @@ -230,29 +236,31 @@ static void intelCalcViewport( GLcontext *ctx ) m[MAT_TZ] = v[MAT_TZ] * depthScale; } -static void intelViewport( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) +static void +intelViewport(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height) { - intelCalcViewport( ctx ); + intelCalcViewport(ctx); } -static void intelDepthRange( GLcontext *ctx, - GLclampd nearval, GLclampd farval ) +static void +intelDepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval) { - intelCalcViewport( ctx ); + intelCalcViewport(ctx); } /* Fallback to swrast for select and feedback. */ -static void intelRenderMode( GLcontext *ctx, GLenum mode ) +static void +intelRenderMode(GLcontext * ctx, GLenum mode) { struct intel_context *intel = intel_context(ctx); - FALLBACK( intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER) ); + FALLBACK(intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER)); } -void intelInitStateFuncs( struct dd_function_table *functions ) +void +intelInitStateFuncs(struct dd_function_table *functions) { functions->RenderMode = intelRenderMode; functions->Viewport = intelViewport; @@ -263,96 +271,93 @@ void intelInitStateFuncs( struct dd_function_table *functions ) -void intelInitState( GLcontext *ctx ) +void +intelInitState(GLcontext * ctx) { /* Mesa should do this for us: */ - ctx->Driver.AlphaFunc( ctx, - ctx->Color.AlphaFunc, - ctx->Color.AlphaRef); + ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef); - ctx->Driver.BlendColor( ctx, - ctx->Color.BlendColor ); + ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor); - ctx->Driver.BlendEquationSeparate( ctx, - ctx->Color.BlendEquationRGB, - ctx->Color.BlendEquationA); + ctx->Driver.BlendEquationSeparate(ctx, + ctx->Color.BlendEquationRGB, + ctx->Color.BlendEquationA); - ctx->Driver.BlendFuncSeparate( ctx, - ctx->Color.BlendSrcRGB, - ctx->Color.BlendDstRGB, - ctx->Color.BlendSrcA, - ctx->Color.BlendDstA); + ctx->Driver.BlendFuncSeparate(ctx, + ctx->Color.BlendSrcRGB, + ctx->Color.BlendDstRGB, + ctx->Color.BlendSrcA, ctx->Color.BlendDstA); - ctx->Driver.ColorMask( ctx, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + ctx->Driver.ColorMask(ctx, + ctx->Color.ColorMask[RCOMP], + ctx->Color.ColorMask[GCOMP], + ctx->Color.ColorMask[BCOMP], + ctx->Color.ColorMask[ACOMP]); - ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode ); - ctx->Driver.DepthFunc( ctx, ctx->Depth.Func ); - ctx->Driver.DepthMask( ctx, ctx->Depth.Mask ); + ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode); + ctx->Driver.DepthFunc(ctx, ctx->Depth.Func); + ctx->Driver.DepthMask(ctx, ctx->Depth.Mask); - ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled ); - ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled ); - ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled ); - ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled ); - ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag ); - ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test ); - ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag ); - ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled ); - ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled ); - ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag ); - ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag ); - ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled ); - ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled ); - ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE ); - ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE ); - ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE ); - ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE ); - ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE ); + ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled); + ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled); + ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled); + ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled); + ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag); + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); + ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag); + ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled); + ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled); + ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag); + ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag); + ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled); + ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); + ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); - ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color ); - ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 ); - ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); - ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); - ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End ); + ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color); + ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0); + ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density); + ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start); + ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End); - ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace ); + ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); { - GLfloat f = (GLfloat)ctx->Light.Model.ColorControl; - ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f ); + GLfloat f = (GLfloat) ctx->Light.Model.ColorControl; + ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f); } - ctx->Driver.LineWidth( ctx, ctx->Line.Width ); - ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); - ctx->Driver.PointSize( ctx, ctx->Point.Size ); - ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple ); - ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height ); - ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel ); - ctx->Driver.StencilFuncSeparate( ctx, GL_FRONT, - ctx->Stencil.Function[0], - ctx->Stencil.Ref[0], - ctx->Stencil.ValueMask[0] ); - ctx->Driver.StencilFuncSeparate( ctx, GL_BACK, - ctx->Stencil.Function[1], - ctx->Stencil.Ref[1], - ctx->Stencil.ValueMask[1] ); - ctx->Driver.StencilMaskSeparate( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] ); - ctx->Driver.StencilMaskSeparate( ctx, GL_BACK, ctx->Stencil.WriteMask[1] ); - ctx->Driver.StencilOpSeparate( ctx, GL_FRONT, - ctx->Stencil.FailFunc[0], - ctx->Stencil.ZFailFunc[0], - ctx->Stencil.ZPassFunc[0]); - ctx->Driver.StencilOpSeparate( ctx, GL_BACK, - ctx->Stencil.FailFunc[1], - ctx->Stencil.ZFailFunc[1], - ctx->Stencil.ZPassFunc[1]); + ctx->Driver.LineWidth(ctx, ctx->Line.Width); + ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp); + ctx->Driver.PointSize(ctx, ctx->Point.Size); + ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple); + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); + ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel); + ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, + ctx->Stencil.Function[0], + ctx->Stencil.Ref[0], + ctx->Stencil.ValueMask[0]); + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, + ctx->Stencil.Function[1], + ctx->Stencil.Ref[1], + ctx->Stencil.ValueMask[1]); + ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]); + ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]); + ctx->Driver.StencilOpSeparate(ctx, GL_FRONT, + ctx->Stencil.FailFunc[0], + ctx->Stencil.ZFailFunc[0], + ctx->Stencil.ZPassFunc[0]); + ctx->Driver.StencilOpSeparate(ctx, GL_BACK, + ctx->Stencil.FailFunc[1], + ctx->Stencil.ZFailFunc[1], + ctx->Stencil.ZPassFunc[1]); /* XXX this isn't really needed */ - ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); + ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]); } diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c index a945609023c..5be28fd7e96 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.c +++ b/src/mesa/drivers/dri/i915/intel_tex.c @@ -4,16 +4,16 @@ #include "intel_tex.h" -static GLboolean intelIsTextureResident(GLcontext *ctx, - struct gl_texture_object *texObj) +static GLboolean +intelIsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj) { #if 0 struct intel_context *intel = intel_context(ctx); struct intel_texture_object *intelObj = intel_texture_object(texObj); - - return - intelObj->mt && - intelObj->mt->region && + + return + intelObj->mt && + intelObj->mt->region && intel_is_region_resident(intel, intelObj->mt->region); #endif return 1; @@ -21,16 +21,16 @@ static GLboolean intelIsTextureResident(GLcontext *ctx, -static struct gl_texture_image *intelNewTextureImage( GLcontext *ctx ) +static struct gl_texture_image * +intelNewTextureImage(GLcontext * ctx) { (void) ctx; - return (struct gl_texture_image *)CALLOC_STRUCT(intel_texture_image); + return (struct gl_texture_image *) CALLOC_STRUCT(intel_texture_image); } -static struct gl_texture_object *intelNewTextureObject( GLcontext *ctx, - GLuint name, - GLenum target ) +static struct gl_texture_object * +intelNewTextureObject(GLcontext * ctx, GLuint name, GLenum target) { struct intel_texture_object *obj = CALLOC_STRUCT(intel_texture_object); @@ -40,8 +40,8 @@ static struct gl_texture_object *intelNewTextureObject( GLcontext *ctx, } -static void intelFreeTextureImageData( GLcontext *ctx, - struct gl_texture_image *texImage ) +static void +intelFreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage) { struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); @@ -49,7 +49,7 @@ static void intelFreeTextureImageData( GLcontext *ctx, if (intelImage->mt) { intel_miptree_release(intel, &intelImage->mt); } - + if (texImage->Data) { free(texImage->Data); texImage->Data = NULL; @@ -61,33 +61,33 @@ static void intelFreeTextureImageData( GLcontext *ctx, static unsigned fastrdtsc(void) { - unsigned eax; - __asm__ volatile ("\t" - "pushl %%ebx\n\t" - "cpuid\n\t" ".byte 0x0f, 0x31\n\t" "popl %%ebx\n":"=a" (eax) - :"0"(0) - :"ecx", "edx", "cc"); + unsigned eax; + __asm__ volatile ("\t" + "pushl %%ebx\n\t" + "cpuid\n\t" ".byte 0x0f, 0x31\n\t" + "popl %%ebx\n":"=a" (eax) + :"0"(0) + :"ecx", "edx", "cc"); - return eax; + return eax; } #else static unsigned fastrdtsc(void) { - unsigned eax; - __asm__ volatile ("\t" - "cpuid\n\t" ".byte 0x0f, 0x31\n\t" :"=a" (eax) - :"0"(0) - :"ecx", "edx", "ebx", "cc"); + unsigned eax; + __asm__ volatile ("\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t":"=a" (eax) + :"0"(0) + :"ecx", "edx", "ebx", "cc"); - return eax; + return eax; } #endif static unsigned time_diff(unsigned t, unsigned t2) { - return ((t < t2) ? t2 - t : 0xFFFFFFFFU - (t - t2 - 1)); + return ((t < t2) ? t2 - t : 0xFFFFFFFFU - (t - t2 - 1)); } @@ -103,39 +103,40 @@ time_diff(unsigned t, unsigned t2) * * TODO: switch dynamically. */ -static void *do_memcpy( void *dest, const void *src, size_t n ) +static void * +do_memcpy(void *dest, const void *src, size_t n) { - if ( (((unsigned)src) & 63) || - (((unsigned)dest) & 63)) { - return __memcpy(dest, src, n); + if ((((unsigned) src) & 63) || (((unsigned) dest) & 63)) { + return __memcpy(dest, src, n); } else return memcpy(dest, src, n); } -static void *timed_memcpy( void *dest, const void *src, size_t n ) +static void * +timed_memcpy(void *dest, const void *src, size_t n) { void *ret; unsigned t1, t2; double rate; - if ( (((unsigned)src) & 63) || - (((unsigned)dest) & 63)) + if ((((unsigned) src) & 63) || (((unsigned) dest) & 63)) _mesa_printf("Warning - non-aligned texture copy!\n"); t1 = fastrdtsc(); - ret = do_memcpy(dest, src, n); + ret = do_memcpy(dest, src, n); t2 = fastrdtsc(); rate = time_diff(t1, t2); rate /= (double) n; - _mesa_printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1, t2, rate); + _mesa_printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1, t2, rate); return ret; } -void intelInitTextureFuncs(struct dd_function_table * functions) +void +intelInitTextureFuncs(struct dd_function_table *functions) { functions->ChooseTextureFormat = intelChooseTextureFormat; functions->TexImage1D = intelTexImage1D; diff --git a/src/mesa/drivers/dri/i915/intel_tex.h b/src/mesa/drivers/dri/i915/intel_tex.h index 2880070dab2..2f3d4ec2d11 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.h +++ b/src/mesa/drivers/dri/i915/intel_tex.h @@ -33,103 +33,102 @@ #include "texmem.h" -void intelInitTextureFuncs( struct dd_function_table *functions ); +void intelInitTextureFuncs(struct dd_function_table *functions); -const struct gl_texture_format * -intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, - GLenum format, GLenum type ); +const struct gl_texture_format *intelChooseTextureFormat(GLcontext * ctx, + GLint internalFormat, + GLenum format, + GLenum type); -void intelTexImage3D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexImage3D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelTexSubImage3D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexSubImage3D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelTexImage2D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexImage2D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelTexSubImage2D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexSubImage2D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelTexImage1D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexImage1D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelTexSubImage1D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +void intelTexSubImage1D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, + GLsizei width, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -void intelCopyTexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, - GLint border ); +void intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLint border); -void intelCopyTexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ); +void intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border); -void intelCopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, - GLint x, GLint y, GLsizei width ); +void intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width); -void intelCopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ); +void intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height); -void intelGetTexImage( GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); +void intelGetTexImage(GLcontext * ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid * pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); -GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ); +GLuint intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit); -void intel_tex_map_images( struct intel_context *intel, - struct intel_texture_object *intelObj ); +void intel_tex_map_images(struct intel_context *intel, + struct intel_texture_object *intelObj); -void intel_tex_unmap_images( struct intel_context *intel, - struct intel_texture_object *intelObj ); +void intel_tex_unmap_images(struct intel_context *intel, + struct intel_texture_object *intelObj); #endif diff --git a/src/mesa/drivers/dri/i915/intel_tex_copy.c b/src/mesa/drivers/dri/i915/intel_tex_copy.c index aa3dd198e29..c07547db5aa 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_copy.c +++ b/src/mesa/drivers/dri/i915/intel_tex_copy.c @@ -41,7 +41,6 @@ #include "intel_tex.h" #include "intel_blit.h" #include "intel_pixel.h" -#include "intel_bufmgr.h" /** @@ -56,27 +55,27 @@ get_teximage_source(struct intel_context *intel, GLenum internalFormat) struct intel_renderbuffer *irb; if (0) - _mesa_printf("%s %s\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(internalFormat)); + _mesa_printf("%s %s\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(internalFormat)); switch (internalFormat) { case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT16_ARB: irb = intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH); if (irb && irb->region && irb->region->cpp == 2) - return irb->region; + return irb->region; return NULL; case GL_DEPTH24_STENCIL8_EXT: case GL_DEPTH_STENCIL_EXT: irb = intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH); if (irb && irb->region && irb->region->cpp == 4) - return irb->region; + return irb->region; return NULL; case GL_RGBA: - return intel_readbuf_region( intel ); + return intel_readbuf_region(intel); case GL_RGB: if (intel->intelScreen->cpp == 2) - return intel_readbuf_region( intel ); + return intel_readbuf_region(intel); return NULL; default: return NULL; @@ -84,35 +83,36 @@ get_teximage_source(struct intel_context *intel, GLenum internalFormat) } -static GLboolean do_copy_texsubimage( struct intel_context *intel, - struct intel_texture_image *intelImage, - GLenum internalFormat, - GLint dstx, GLint dsty, - GLint x, GLint y, - GLsizei width, GLsizei height ) +static GLboolean +do_copy_texsubimage(struct intel_context *intel, + struct intel_texture_image *intelImage, + GLenum internalFormat, + GLint dstx, GLint dsty, + GLint x, GLint y, GLsizei width, GLsizei height) { GLcontext *ctx = &intel->ctx; - const struct intel_region *src = get_teximage_source(intel, internalFormat); + const struct intel_region *src = + get_teximage_source(intel, internalFormat); if (!intelImage->mt || !src) return GL_FALSE; - + intelFlush(ctx); LOCK_HARDWARE(intel); { - GLuint image_offset = intel_miptree_image_offset(intelImage->mt, - intelImage->face, - intelImage->level); + GLuint image_offset = intel_miptree_image_offset(intelImage->mt, + intelImage->face, + intelImage->level); const GLint orig_x = x; const GLint orig_y = y; const struct gl_framebuffer *fb = ctx->DrawBuffer; if (_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax, &x, &y, &width, &height)) { - /* Update dst for clipped src. Need to also clip the source rect. - */ - dstx += x - orig_x; - dsty += y - orig_y; + /* Update dst for clipped src. Need to also clip the source rect. + */ + dstx += x - orig_x; + dsty += y - orig_y; if (ctx->ReadBuffer->Name == 0) { /* reading from a window, adjust x, y */ @@ -130,29 +130,24 @@ static GLboolean do_copy_texsubimage( struct intel_context *intel, } - /* A bit of fiddling to get the blitter to work with -ve - * pitches. But we get a nice inverted blit this way, so it's - * worth it: - */ - intelEmitCopyBlit( intel, - intelImage->mt->cpp, + /* A bit of fiddling to get the blitter to work with -ve + * pitches. But we get a nice inverted blit this way, so it's + * worth it: + */ + intelEmitCopyBlit(intel, + intelImage->mt->cpp, + -src->pitch, + src->buffer, + src->height * src->pitch * src->cpp, + intelImage->mt->pitch, + intelImage->mt->region->buffer, + image_offset, + x, y + height, dstx, dsty, width, height); - -src->pitch, - src->buffer, - src->height * src->pitch * src->cpp, - - intelImage->mt->pitch, - intelImage->mt->region->buffer, - image_offset, - - x, y + height, - dstx, dsty, - width, height ); - - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); } } - + UNLOCK_HARDWARE(intel); @@ -160,8 +155,7 @@ static GLboolean do_copy_texsubimage( struct intel_context *intel, /* GL_SGIS_generate_mipmap -- this can be accelerated now. * XXX Add a ctx->Driver.GenerateMipmaps() function? */ - if (level == texObj->BaseLevel && - texObj->GenerateMipmap) { + if (level == texObj->BaseLevel && texObj->GenerateMipmap) { intel_generate_mipmap(ctx, target, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], texObj); @@ -175,14 +169,17 @@ static GLboolean do_copy_texsubimage( struct intel_context *intel, -void intelCopyTexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, - GLint border ) +void +intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLint border) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level); + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_texture_object *texObj = + _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texUnit, target, level); if (border) goto fail; @@ -191,33 +188,34 @@ void intelCopyTexImage1D( GLcontext *ctx, GLenum target, GLint level, * image. Don't populate yet. */ ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, - GL_RGBA, CHAN_TYPE, NULL, - &ctx->DefaultPacking, texObj, texImage); + width, border, + GL_RGBA, CHAN_TYPE, NULL, + &ctx->DefaultPacking, texObj, texImage); - if (!do_copy_texsubimage(intel_context(ctx), - intel_texture_image(texImage), - internalFormat, - 0, 0, - x, y, - width, 1)) - goto fail; + if (!do_copy_texsubimage(intel_context(ctx), + intel_texture_image(texImage), + internalFormat, 0, 0, x, y, width, 1)) + goto fail; return; fail: - _swrast_copy_teximage1d( ctx, target, level, internalFormat, x, y, - width, border ); + _swrast_copy_teximage1d(ctx, target, level, internalFormat, x, y, + width, border); } -void intelCopyTexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) +void +intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level); + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_texture_object *texObj = + _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texUnit, target, level); if (border) goto fail; @@ -226,33 +224,32 @@ void intelCopyTexImage2D( GLcontext *ctx, GLenum target, GLint level, * image. Don't populate yet. */ ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_RGBA, CHAN_TYPE, NULL, - &ctx->DefaultPacking, texObj, texImage); + width, height, border, + GL_RGBA, CHAN_TYPE, NULL, + &ctx->DefaultPacking, texObj, texImage); - if (!do_copy_texsubimage(intel_context(ctx), - intel_texture_image(texImage), - internalFormat, - 0, 0, - x, y, - width, height)) - goto fail; + if (!do_copy_texsubimage(intel_context(ctx), + intel_texture_image(texImage), + internalFormat, 0, 0, x, y, width, height)) + goto fail; return; fail: - _swrast_copy_teximage2d( ctx, target, level, internalFormat, x, y, - width, height, border ); + _swrast_copy_teximage2d(ctx, target, level, internalFormat, x, y, + width, height, border); } -void intelCopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, - GLint x, GLint y, GLsizei width ) +void +intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level); + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texUnit, target, level); GLenum internalFormat = texImage->InternalFormat; /* XXX need to check as in above function? */ @@ -260,37 +257,35 @@ void intelCopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level, /* Need to check texture is compatible with source format. */ - if (!do_copy_texsubimage(intel_context(ctx), - intel_texture_image(texImage), - internalFormat, - xoffset, 0, - x, y, width, 1)) { - _swrast_copy_texsubimage1d( ctx, target, level, - xoffset, x, y, width ); + if (!do_copy_texsubimage(intel_context(ctx), + intel_texture_image(texImage), + internalFormat, xoffset, 0, x, y, width, 1)) { + _swrast_copy_texsubimage1d(ctx, target, level, xoffset, x, y, width); } } -void intelCopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) +void +intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level); + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texUnit, target, level); GLenum internalFormat = texImage->InternalFormat; /* Need to check texture is compatible with source format. */ - if (!do_copy_texsubimage(intel_context(ctx), - intel_texture_image(texImage), - internalFormat, - xoffset, yoffset, - x, y, width, height)) { - _swrast_copy_texsubimage2d( ctx, target, level, - xoffset, yoffset, - x, y, width, height ); + if (!do_copy_texsubimage(intel_context(ctx), + intel_texture_image(texImage), + internalFormat, + xoffset, yoffset, x, y, width, height)) { + _swrast_copy_texsubimage2d(ctx, target, level, + xoffset, yoffset, x, y, width, height); } } diff --git a/src/mesa/drivers/dri/i915/intel_tex_format.c b/src/mesa/drivers/dri/i915/intel_tex_format.c index fdc3df467c1..d7612dcbaab 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_format.c +++ b/src/mesa/drivers/dri/i915/intel_tex_format.c @@ -12,35 +12,34 @@ * immediately after sampling... */ const struct gl_texture_format * -intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, - GLenum format, GLenum type ) +intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat, + GLenum format, GLenum type) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); const GLboolean do32bpt = (intel->intelScreen->cpp == 4); - switch ( internalFormat ) { + switch (internalFormat) { case 4: case GL_RGBA: case GL_COMPRESSED_RGBA: - if ( format == GL_BGRA ) { - if ( type == GL_UNSIGNED_BYTE || - type == GL_UNSIGNED_INT_8_8_8_8_REV ) { - return &_mesa_texformat_argb8888; - } - else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { + if (format == GL_BGRA) { + if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) { + return &_mesa_texformat_argb8888; + } + else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { return &_mesa_texformat_argb4444; - } - else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { - return &_mesa_texformat_argb1555; - } + } + else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + return &_mesa_texformat_argb1555; + } } return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; case 3: case GL_RGB: case GL_COMPRESSED_RGB: - if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) { - return &_mesa_texformat_rgb565; + if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { + return &_mesa_texformat_rgb565; } return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565; @@ -105,29 +104,28 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, return &_mesa_texformat_i8; case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_BYTE) + if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) return &_mesa_texformat_ycbcr; else return &_mesa_texformat_ycbcr_rev; case GL_COMPRESSED_RGB_FXT1_3DFX: - return &_mesa_texformat_rgb_fxt1; + return &_mesa_texformat_rgb_fxt1; case GL_COMPRESSED_RGBA_FXT1_3DFX: - return &_mesa_texformat_rgba_fxt1; + return &_mesa_texformat_rgba_fxt1; case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return &_mesa_texformat_rgb_dxt1; + return &_mesa_texformat_rgb_dxt1; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return &_mesa_texformat_rgba_dxt1; + return &_mesa_texformat_rgba_dxt1; case GL_RGBA_S3TC: case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return &_mesa_texformat_rgba_dxt3; + return &_mesa_texformat_rgba_dxt3; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return &_mesa_texformat_rgba_dxt5; @@ -139,11 +137,10 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, return &_mesa_texformat_z16; default: - fprintf(stderr, "unexpected texture format %s in %s\n", - _mesa_lookup_enum_by_nr(internalFormat), - __FUNCTION__); + fprintf(stderr, "unexpected texture format %s in %s\n", + _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__); return NULL; } - return NULL; /* never get here */ + return NULL; /* never get here */ } diff --git a/src/mesa/drivers/dri/i915/intel_tex_image.c b/src/mesa/drivers/dri/i915/intel_tex_image.c index 26bd0003c3c..a9ff8640ef9 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_image.c +++ b/src/mesa/drivers/dri/i915/intel_tex_image.c @@ -33,7 +33,8 @@ */ -static int logbase2(int n) +static int +logbase2(int n) { GLint i = 1; GLint log2 = 0; @@ -57,9 +58,10 @@ static int logbase2(int n) * 0)..(1x1). Consider pruning this tree at a validation if the * saving is worth it. */ -static void guess_and_alloc_mipmap_tree( struct intel_context *intel, - struct intel_texture_object *intelObj, - struct intel_texture_image *intelImage ) +static void +guess_and_alloc_mipmap_tree(struct intel_context *intel, + struct intel_texture_object *intelObj, + struct intel_texture_image *intelImage) { GLuint firstLevel; GLuint lastLevel; @@ -76,10 +78,10 @@ static void guess_and_alloc_mipmap_tree( struct intel_context *intel, if (intelImage->level > intelObj->base.BaseLevel && (intelImage->base.Width == 1 || - (intelObj->base.Target != GL_TEXTURE_1D && - intelImage->base.Height == 1) || - (intelObj->base.Target == GL_TEXTURE_3D && - intelImage->base.Depth == 1))) + (intelObj->base.Target != GL_TEXTURE_1D && + intelImage->base.Height == 1) || + (intelObj->base.Target == GL_TEXTURE_3D && + intelImage->base.Depth == 1))) return; /* If this image disrespects BaseLevel, allocate from level zero. @@ -95,8 +97,10 @@ static void guess_and_alloc_mipmap_tree( struct intel_context *intel, */ for (i = intelImage->level; i > firstLevel; i--) { width <<= 1; - if (height != 1) height <<= 1; - if (depth != 1) depth <<= 1; + if (height != 1) + height <<= 1; + if (depth != 1) + depth <<= 1; } /* Guess a reasonable value for lastLevel. This is probably going @@ -104,8 +108,8 @@ static void guess_and_alloc_mipmap_tree( struct intel_context *intel, * resizable buffers, or require that buffers implement lazy * pagetable arrangements. */ - if ((intelObj->base.MinFilter == GL_NEAREST || - intelObj->base.MinFilter == GL_LINEAR) && + if ((intelObj->base.MinFilter == GL_NEAREST || + intelObj->base.MinFilter == GL_LINEAR) && intelImage->level == firstLevel) { lastLevel = firstLevel; } @@ -113,28 +117,29 @@ static void guess_and_alloc_mipmap_tree( struct intel_context *intel, l2width = logbase2(width); l2height = logbase2(height); l2depth = logbase2(depth); - lastLevel = firstLevel + MAX2(MAX2(l2width,l2height),l2depth); + lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth); } - + assert(!intelObj->mt); - intelObj->mt = intel_miptree_create( intel, - intelObj->base.Target, - intelImage->base.InternalFormat, - firstLevel, - lastLevel, - width, - height, - depth, - intelImage->base.TexFormat->TexelBytes, - intelImage->base.IsCompressed ); + intelObj->mt = intel_miptree_create(intel, + intelObj->base.Target, + intelImage->base.InternalFormat, + firstLevel, + lastLevel, + width, + height, + depth, + intelImage->base.TexFormat->TexelBytes, + intelImage->base.IsCompressed); DBG("%s - success\n", __FUNCTION__); } - -static GLuint target_to_face( GLenum target ) + +static GLuint +target_to_face(GLenum target) { switch (target) { case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: @@ -143,8 +148,7 @@ static GLuint target_to_face( GLenum target ) case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - return ((GLuint) target - - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X); + return ((GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X); default: return 0; } @@ -153,25 +157,25 @@ static GLuint target_to_face( GLenum target ) /* There are actually quite a few combinations this will work for, * more than what I've listed here. */ -static GLboolean check_pbo_format( GLint internalFormat, - GLenum format, GLenum type, - const struct gl_texture_format *mesa_format ) +static GLboolean +check_pbo_format(GLint internalFormat, + GLenum format, GLenum type, + const struct gl_texture_format *mesa_format) { switch (internalFormat) { case 4: case GL_RGBA: return (format == GL_BGRA && - (type == GL_UNSIGNED_BYTE || - type == GL_UNSIGNED_INT_8_8_8_8_REV) && - mesa_format == &_mesa_texformat_argb8888); + (type == GL_UNSIGNED_BYTE || + type == GL_UNSIGNED_INT_8_8_8_8_REV) && + mesa_format == &_mesa_texformat_argb8888); case 3: case GL_RGB: return (format == GL_RGB && - type == GL_UNSIGNED_SHORT_5_6_5 && - mesa_format == &_mesa_texformat_rgb565); + type == GL_UNSIGNED_SHORT_5_6_5 && + mesa_format == &_mesa_texformat_rgb565); case GL_YCBCR_MESA: - return (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_BYTE); + return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE); default: return GL_FALSE; } @@ -180,13 +184,13 @@ static GLboolean check_pbo_format( GLint internalFormat, /* XXX: Do this for TexSubImage also: */ -static GLboolean try_pbo_upload( struct intel_context *intel, - struct intel_texture_image *intelImage, - const struct gl_pixelstore_attrib *unpack, - GLint internalFormat, - GLint width, GLint height, - GLenum format, GLenum type, - const void *pixels) +static GLboolean +try_pbo_upload(struct intel_context *intel, + struct intel_texture_image *intelImage, + const struct gl_pixelstore_attrib *unpack, + GLint internalFormat, + GLint width, GLint height, + GLenum format, GLenum type, const void *pixels) { struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj); GLuint src_offset, src_stride; @@ -194,12 +198,11 @@ static GLboolean try_pbo_upload( struct intel_context *intel, if (!pbo || intel->ctx._ImageTransferState || - unpack->SkipPixels || - unpack->SkipRows) { + unpack->SkipPixels || unpack->SkipRows) { _mesa_printf("%s: failure 1\n", __FUNCTION__); return GL_FALSE; } - + src_offset = (GLuint) pixels; if (unpack->RowLength > 0) @@ -207,47 +210,44 @@ static GLboolean try_pbo_upload( struct intel_context *intel, else src_stride = width; - dst_offset = intel_miptree_image_offset(intelImage->mt, - intelImage->face, - intelImage->level); + dst_offset = intel_miptree_image_offset(intelImage->mt, + intelImage->face, + intelImage->level); dst_stride = intelImage->mt->pitch; - intelFlush( &intel->ctx ); - LOCK_HARDWARE( intel ); + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); { - struct buffer *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ); - struct buffer *dst_buffer = intel_region_buffer(intel, intelImage->mt->region, - INTEL_WRITE_FULL); + struct _DriBufferObject *src_buffer = + intel_bufferobj_buffer(intel, pbo, INTEL_READ); + struct _DriBufferObject *dst_buffer = + intel_region_buffer(intel, intelImage->mt->region, + INTEL_WRITE_FULL); - intelEmitCopyBlit( intel, - intelImage->mt->cpp, - src_stride, src_buffer, src_offset, - dst_stride, dst_buffer, dst_offset, - 0, - 0, - 0, - 0, - width, - height ); + intelEmitCopyBlit(intel, + intelImage->mt->cpp, + src_stride, src_buffer, src_offset, + dst_stride, dst_buffer, dst_offset, + 0, 0, 0, 0, width, height); - intel_batchbuffer_flush( intel->batch ); + intel_batchbuffer_flush(intel->batch); } - UNLOCK_HARDWARE( intel ); + UNLOCK_HARDWARE(intel); return GL_TRUE; } -static GLboolean try_pbo_zcopy( struct intel_context *intel, - struct intel_texture_image *intelImage, - const struct gl_pixelstore_attrib *unpack, - GLint internalFormat, - GLint width, GLint height, - GLenum format, GLenum type, - const void *pixels) +static GLboolean +try_pbo_zcopy(struct intel_context *intel, + struct intel_texture_image *intelImage, + const struct gl_pixelstore_attrib *unpack, + GLint internalFormat, + GLint width, GLint height, + GLenum format, GLenum type, const void *pixels) { struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj); GLuint src_offset, src_stride; @@ -255,12 +255,11 @@ static GLboolean try_pbo_zcopy( struct intel_context *intel, if (!pbo || intel->ctx._ImageTransferState || - unpack->SkipPixels || - unpack->SkipRows) { + unpack->SkipPixels || unpack->SkipRows) { _mesa_printf("%s: failure 1\n", __FUNCTION__); return GL_FALSE; } - + src_offset = (GLuint) pixels; if (unpack->RowLength > 0) @@ -268,41 +267,38 @@ static GLboolean try_pbo_zcopy( struct intel_context *intel, else src_stride = width; - dst_offset = intel_miptree_image_offset(intelImage->mt, - intelImage->face, - intelImage->level); + dst_offset = intel_miptree_image_offset(intelImage->mt, + intelImage->face, + intelImage->level); dst_stride = intelImage->mt->pitch; - if (src_stride != dst_stride || - dst_offset != 0 || - src_offset != 0) { + if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) { _mesa_printf("%s: failure 2\n", __FUNCTION__); return GL_FALSE; } - intel_region_attach_pbo( intel, - intelImage->mt->region, - pbo ); + intel_region_attach_pbo(intel, intelImage->mt->region, pbo); return GL_TRUE; } - - -static void intelTexImage(GLcontext *ctx, - GLint dims, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + + +static void +intelTexImage(GLcontext * ctx, + GLint dims, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *unpack, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { struct intel_context *intel = intel_context(ctx); struct intel_texture_object *intelObj = intel_texture_object(texObj); @@ -314,13 +310,11 @@ static void intelTexImage(GLcontext *ctx, DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(target), - level, - width, height, depth, border); + _mesa_lookup_enum_by_nr(target), level, width, height, depth, border); intelFlush(ctx); - intelImage->face = target_to_face( target ); + intelImage->face = target_to_face(target); intelImage->level = level; if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { @@ -329,8 +323,8 @@ static void intelTexImage(GLcontext *ctx, } /* choose the texture format */ - texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat, - format, type); + texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat, + format, type); assert(texImage->TexFormat); @@ -378,38 +372,38 @@ static void intelTexImage(GLcontext *ctx, * bmBufferData with NULL data to free the old block and avoid * waiting on any outstanding fences. */ - if (intelObj->mt && + if (intelObj->mt && intelObj->mt->first_level == level && intelObj->mt->last_level == level && intelObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB && !intel_miptree_match_image(intelObj->mt, &intelImage->base, - intelImage->face, intelImage->level)) { + intelImage->face, intelImage->level)) { DBG("release it\n"); - intel_miptree_release(intel, &intelObj->mt); + intel_miptree_release(intel, &intelObj->mt); assert(!intelObj->mt); } - + if (!intelObj->mt) { guess_and_alloc_mipmap_tree(intel, intelObj, intelImage); if (!intelObj->mt) { - if (INTEL_DEBUG & DEBUG_TEXTURE) - _mesa_printf("guess_and_alloc_mipmap_tree: failed\n"); + if (INTEL_DEBUG & DEBUG_TEXTURE) + _mesa_printf("guess_and_alloc_mipmap_tree: failed\n"); } } assert(!intelImage->mt); - if (intelObj->mt && + if (intelObj->mt && intel_miptree_match_image(intelObj->mt, &intelImage->base, - intelImage->face, intelImage->level)) { - + intelImage->face, intelImage->level)) { + intel_miptree_reference(&intelImage->mt, intelObj->mt); assert(intelImage->mt); } - if (!intelImage->mt) + if (!intelImage->mt) DBG("XXX: Image did not fit into tree - storing in local memory!\n"); /* PBO fastpaths: @@ -417,74 +411,75 @@ static void intelTexImage(GLcontext *ctx, if (dims <= 2 && intelImage->mt && intel_buffer_object(unpack->BufferObj) && - check_pbo_format(internalFormat, format, - type, intelImage->base.TexFormat)) { + check_pbo_format(internalFormat, format, + type, intelImage->base.TexFormat)) { DBG("trying pbo upload\n"); /* Attempt to texture directly from PBO data (zero copy upload). * This is about twice as fast as regular uploads: */ - if (intelObj->mt == intelImage->mt && - intelObj->mt->first_level == level && - intelObj->mt->last_level == level) { + if (intelObj->mt == intelImage->mt && + intelObj->mt->first_level == level && + intelObj->mt->last_level == level) { - if (try_pbo_zcopy(intel, intelImage, unpack, - internalFormat, - width, height, format, type, pixels)) { + if (try_pbo_zcopy(intel, intelImage, unpack, + internalFormat, + width, height, format, type, pixels)) { + + DBG("pbo zcopy upload succeeded\n"); + return; + } + } - DBG("pbo zcopy upload succeeded\n"); - return; - } - } - /* Otherwise, attempt to use the blitter for PBO image uploads. * This is about 20% faster than regular uploads: */ - if (try_pbo_upload(intel, intelImage, unpack, - internalFormat, - width, height, format, type, pixels)) { - DBG("pbo upload succeeded\n"); - return; + if (try_pbo_upload(intel, intelImage, unpack, + internalFormat, + width, height, format, type, pixels)) { + DBG("pbo upload succeeded\n"); + return; } DBG("pbo upload failed\n"); } - + /* intelCopyTexImage calls this function with pixels == NULL, with * the expectation that the mipmap tree will be set up but nothing * more will be done. This is where those calls return: */ - pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1, - format, type, - pixels, unpack, "glTexImage"); - if (!pixels) + pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1, + format, type, + pixels, unpack, "glTexImage"); + if (!pixels) return; - + LOCK_HARDWARE(intel); - + if (intelImage->mt) { - texImage->Data = intel_miptree_image_map(intel, - intelImage->mt, - intelImage->face, - intelImage->level, - &dstRowStride, - intelImage->base.ImageOffsets); + texImage->Data = intel_miptree_image_map(intel, + intelImage->mt, + intelImage->face, + intelImage->level, + &dstRowStride, + intelImage->base.ImageOffsets); } else { /* Allocate regular memory and store the image there temporarily. */ if (texImage->IsCompressed) { - sizeInBytes = texImage->CompressedSize; - dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,width); - assert(dims != 3); + sizeInBytes = texImage->CompressedSize; + dstRowStride = + _mesa_compressed_row_stride(texImage->InternalFormat, width); + assert(dims != 3); } else { dstRowStride = postConvWidth * texelBytes; - sizeInBytes = depth * dstRowStride * postConvHeight; + sizeInBytes = depth * dstRowStride * postConvHeight; } texImage->Data = malloc(sizeInBytes); @@ -492,23 +487,18 @@ static void intelTexImage(GLcontext *ctx, if (INTEL_DEBUG & DEBUG_TEXTURE) _mesa_printf("Upload image %dx%dx%d row_len %x " - "pitch %x\n", - width, height, depth, - width * texelBytes, dstRowStride); - + "pitch %x\n", + width, height, depth, width * texelBytes, dstRowStride); + /* Copy data. Would like to know when it's ok for us to eg. use * the blitter to copy. Or, use the hardware to do the format * conversion and copy: */ - if (!texImage->TexFormat->StoreImage(ctx, dims, - texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, unpack)) { + if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat, texImage->TexFormat, texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, unpack)) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); } @@ -524,8 +514,7 @@ static void intelTexImage(GLcontext *ctx, #if 0 /* GL_SGIS_generate_mipmap -- this can be accelerated now. */ - if (level == texObj->BaseLevel && - texObj->GenerateMipmap) { + if (level == texObj->BaseLevel && texObj->GenerateMipmap) { intel_generate_mipmap(ctx, target, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], texObj); @@ -533,51 +522,51 @@ static void intelTexImage(GLcontext *ctx, #endif } -void intelTexImage3D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexImage3D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *unpack, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { - intelTexImage( ctx, 3, target, level, - internalFormat, width, height, depth, border, - format, type, pixels, - unpack, texObj, texImage ); + intelTexImage(ctx, 3, target, level, + internalFormat, width, height, depth, border, + format, type, pixels, unpack, texObj, texImage); } -void intelTexImage2D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexImage2D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *unpack, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { - intelTexImage( ctx, 2, target, level, - internalFormat, width, height, 1, border, - format, type, pixels, - unpack, texObj, texImage ); + intelTexImage(ctx, 2, target, level, + internalFormat, width, height, 1, border, + format, type, pixels, unpack, texObj, texImage); } -void intelTexImage1D(GLcontext *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexImage1D(GLcontext * ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *unpack, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { - intelTexImage( ctx, 1, target, level, - internalFormat, width, 1, 1, border, - format, type, pixels, - unpack, texObj, texImage ); + intelTexImage(ctx, 1, target, level, + internalFormat, width, 1, 1, border, + format, type, pixels, unpack, texObj, texImage); } @@ -586,12 +575,13 @@ void intelTexImage1D(GLcontext *ctx, * Need to map texture image into memory before copying image data, * then unmap it. */ -void intelGetTexImage( GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) +void +intelGetTexImage(GLcontext * ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid * pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); /* Map */ @@ -599,8 +589,8 @@ void intelGetTexImage( GLcontext *ctx, GLenum target, GLint level, /* Image is stored in hardware format in a buffer managed by the * kernel. Need to explicitly map and unmap it. */ - intelImage->base.Data = - intel_miptree_image_map(intel, + intelImage->base.Data = + intel_miptree_image_map(intel, intelImage->mt, intelImage->face, intelImage->level, @@ -628,4 +618,3 @@ void intelGetTexImage( GLcontext *ctx, GLenum target, GLint level, intelImage->base.Data = NULL; } } - diff --git a/src/mesa/drivers/dri/i915/intel_tex_subimage.c b/src/mesa/drivers/dri/i915/intel_tex_subimage.c index 258316d1b36..e7c7220872f 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/i915/intel_tex_subimage.c @@ -37,15 +37,16 @@ #define FILE_DEBUG_FLAG DEBUG_TEXTURE -static void intelTexSubimage (GLcontext *ctx, - GLint dims, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +static void +intelTexSubimage(GLcontext * ctx, + GLint dims, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); @@ -53,15 +54,14 @@ static void intelTexSubimage (GLcontext *ctx, GLuint dstRowStride; DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(target), - level, - xoffset, yoffset, - width, height); + _mesa_lookup_enum_by_nr(target), + level, xoffset, yoffset, width, height); intelFlush(ctx); - pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format, type, - pixels, packing, "glTexSubImage2D"); + pixels = + _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format, + type, pixels, packing, "glTexSubImage2D"); if (!pixels) return; @@ -70,24 +70,24 @@ static void intelTexSubimage (GLcontext *ctx, /* Map buffer if necessary. Need to lock to prevent other contexts * from uploading the buffer under us. */ - if (intelImage->mt) - texImage->Data = intel_miptree_image_map(intel, - intelImage->mt, - intelImage->face, - intelImage->level, - &dstRowStride, - &dstImageStride ); - + if (intelImage->mt) + texImage->Data = intel_miptree_image_map(intel, + intelImage->mt, + intelImage->face, + intelImage->level, + &dstRowStride, + &dstImageStride); + assert(dstRowStride); if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, yoffset, zoffset, - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, packing)) { + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, zoffset, + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing)) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage"); } @@ -114,67 +114,67 @@ static void intelTexSubimage (GLcontext *ctx, -void intelTexSubImage3D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexSubImage3D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { intelTexSubimage(ctx, 3, - target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, pixels, packing, texObj, - texImage); + target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels, packing, texObj, texImage); } -void intelTexSubImage2D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexSubImage2D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { intelTexSubimage(ctx, 2, - target, level, - xoffset, yoffset, 0, - width, height, 1, - format, type, pixels, packing, texObj, - texImage); + target, level, + xoffset, yoffset, 0, + width, height, 1, + format, type, pixels, packing, texObj, texImage); } -void intelTexSubImage1D(GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +intelTexSubImage1D(GLcontext * ctx, + GLenum target, + GLint level, + GLint xoffset, + GLsizei width, + GLenum format, GLenum type, + const GLvoid * pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { intelTexSubimage(ctx, 1, - target, level, - xoffset, 0, 0, - width, 1, 1, - format, type, pixels, packing, texObj, - texImage); + target, level, + xoffset, 0, 0, + width, 1, 1, + format, type, pixels, packing, texObj, texImage); } diff --git a/src/mesa/drivers/dri/i915/intel_tex_validate.c b/src/mesa/drivers/dri/i915/intel_tex_validate.c index 0941bc1840c..b8cb7e88ea6 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_validate.c +++ b/src/mesa/drivers/dri/i915/intel_tex_validate.c @@ -4,7 +4,6 @@ #include "intel_context.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" -#include "intel_bufmgr.h" #define FILE_DEBUG_FLAG DEBUG_TEXTURE @@ -13,18 +12,19 @@ * This depends on the base image size, GL_TEXTURE_MIN_LOD, * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. */ -static void intel_calculate_first_last_level( struct intel_texture_object *intelObj ) +static void +intel_calculate_first_last_level(struct intel_texture_object *intelObj) { struct gl_texture_object *tObj = &intelObj->base; - const struct gl_texture_image * const baseImage = - tObj->Image[0][tObj->BaseLevel]; + const struct gl_texture_image *const baseImage = + tObj->Image[0][tObj->BaseLevel]; /* These must be signed values. MinLod and MaxLod can be negative numbers, * and having firstLevel and lastLevel as signed prevents the need for * extra sign checks. */ - int firstLevel; - int lastLevel; + int firstLevel; + int lastLevel; /* Yes, this looks overly complicated, but it's all needed. */ @@ -39,13 +39,13 @@ static void intel_calculate_first_last_level( struct intel_texture_object *intel firstLevel = lastLevel = tObj->BaseLevel; } else { - firstLevel = tObj->BaseLevel + (GLint)(tObj->MinLod + 0.5); - firstLevel = MAX2(firstLevel, tObj->BaseLevel); - lastLevel = tObj->BaseLevel + (GLint)(tObj->MaxLod + 0.5); - lastLevel = MAX2(lastLevel, tObj->BaseLevel); - lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = MIN2(lastLevel, tObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ + firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5); + firstLevel = MAX2(firstLevel, tObj->BaseLevel); + lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5); + lastLevel = MAX2(lastLevel, tObj->BaseLevel); + lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2); + lastLevel = MIN2(lastLevel, tObj->MaxLevel); + lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ } break; case GL_TEXTURE_RECTANGLE_NV: @@ -61,18 +61,18 @@ static void intel_calculate_first_last_level( struct intel_texture_object *intel intelObj->lastLevel = lastLevel; } -static void copy_image_data_to_tree( struct intel_context *intel, - struct intel_texture_object *intelObj, - struct intel_texture_image *intelImage ) +static void +copy_image_data_to_tree(struct intel_context *intel, + struct intel_texture_object *intelObj, + struct intel_texture_image *intelImage) { if (intelImage->mt) { /* Copy potentially with the blitter: */ intel_miptree_image_copy(intel, - intelObj->mt, - intelImage->face, - intelImage->level, - intelImage->mt); + intelObj->mt, + intelImage->face, + intelImage->level, intelImage->mt); intel_miptree_release(intel, &intelImage->mt); } @@ -82,12 +82,13 @@ static void copy_image_data_to_tree( struct intel_context *intel, /* More straightforward upload. */ intel_miptree_image_data(intel, - intelObj->mt, - intelImage->face, - intelImage->level, - intelImage->base.Data, - intelImage->base.RowStride, - intelImage->base.RowStride * intelImage->base.Height); + intelObj->mt, + intelImage->face, + intelImage->level, + intelImage->base.Data, + intelImage->base.RowStride, + intelImage->base.RowStride * + intelImage->base.Height); free(intelImage->base.Data); intelImage->base.Data = NULL; @@ -99,7 +100,8 @@ static void copy_image_data_to_tree( struct intel_context *intel, /* */ -GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) +GLuint +intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) { struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current; struct intel_texture_object *intelObj = intel_texture_object(tObj); @@ -114,14 +116,15 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) /* What levels must the tree include at a minimum? */ - intel_calculate_first_last_level( intelObj ); - firstImage = intel_texture_image(intelObj->base.Image[0][intelObj->firstLevel]); + intel_calculate_first_last_level(intelObj); + firstImage = + intel_texture_image(intelObj->base.Image[0][intelObj->firstLevel]); /* Fallback case: */ if (firstImage->base.Border) { if (intelObj->mt) { - intel_miptree_release(intel, &intelObj->mt); + intel_miptree_release(intel, &intelObj->mt); } return GL_FALSE; } @@ -137,8 +140,8 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) firstImage->mt->first_level <= intelObj->firstLevel && firstImage->mt->last_level >= intelObj->lastLevel) { - if (intelObj->mt) - intel_miptree_release(intel, &intelObj->mt); + if (intelObj->mt) + intel_miptree_release(intel, &intelObj->mt); intel_miptree_reference(&intelObj->mt, firstImage->mt); } @@ -154,25 +157,26 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) */ if (intelObj->mt && ((intelObj->mt->first_level > intelObj->firstLevel) || - (intelObj->mt->last_level < intelObj->lastLevel) || - (intelObj->mt->internal_format != firstImage->base.InternalFormat))) { + (intelObj->mt->last_level < intelObj->lastLevel) || + (intelObj->mt->internal_format != firstImage->base.InternalFormat))) { intel_miptree_release(intel, &intelObj->mt); } - + /* May need to create a new tree: */ if (!intelObj->mt) { intelObj->mt = intel_miptree_create(intel, - intelObj->base.Target, - firstImage->base.InternalFormat, - intelObj->firstLevel, - intelObj->lastLevel, - firstImage->base.Width, - firstImage->base.Height, - firstImage->base.Depth, - firstImage->base.TexFormat->TexelBytes, - firstImage->base.IsCompressed); + intelObj->base.Target, + firstImage->base.InternalFormat, + intelObj->firstLevel, + intelObj->lastLevel, + firstImage->base.Width, + firstImage->base.Height, + firstImage->base.Depth, + firstImage->base.TexFormat-> + TexelBytes, + firstImage->base.IsCompressed); } /* Pull in any images not in the object's tree: @@ -180,16 +184,14 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; for (face = 0; face < nr_faces; face++) { for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) { - struct intel_texture_image *intelImage = - intel_texture_image(intelObj->base.Image[face][i]); - - /* Need to import images in main memory or held in other trees. - */ - if (intelObj->mt != intelImage->mt) { - copy_image_data_to_tree(intel, - intelObj, - intelImage); - } + struct intel_texture_image *intelImage = + intel_texture_image(intelObj->base.Image[face][i]); + + /* Need to import images in main memory or held in other trees. + */ + if (intelObj->mt != intelImage->mt) { + copy_image_data_to_tree(intel, intelObj, intelImage); + } } } @@ -198,52 +200,54 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint unit ) -void intel_tex_map_images( struct intel_context *intel, - struct intel_texture_object *intelObj ) +void +intel_tex_map_images(struct intel_context *intel, + struct intel_texture_object *intelObj) { GLuint nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; GLuint face, i; - + DBG("%s\n", __FUNCTION__); for (face = 0; face < nr_faces; face++) { for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) { - struct intel_texture_image *intelImage = - intel_texture_image(intelObj->base.Image[face][i]); + struct intel_texture_image *intelImage = + intel_texture_image(intelObj->base.Image[face][i]); - if (intelImage->mt) { - intelImage->base.Data = - intel_miptree_image_map(intel, - intelImage->mt, - intelImage->face, - intelImage->level, - &intelImage->base.RowStride, - intelImage->base.ImageOffsets); + if (intelImage->mt) { + intelImage->base.Data = + intel_miptree_image_map(intel, + intelImage->mt, + intelImage->face, + intelImage->level, + &intelImage->base.RowStride, + intelImage->base.ImageOffsets); /* convert stride to texels, not bytes */ intelImage->base.RowStride /= intelImage->mt->cpp; /* intelImage->base.ImageStride /= intelImage->mt->cpp; */ - } + } } } } -void intel_tex_unmap_images( struct intel_context *intel, - struct intel_texture_object *intelObj ) +void +intel_tex_unmap_images(struct intel_context *intel, + struct intel_texture_object *intelObj) { GLuint nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; GLuint face, i; for (face = 0; face < nr_faces; face++) { for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) { - struct intel_texture_image *intelImage = - intel_texture_image(intelObj->base.Image[face][i]); + struct intel_texture_image *intelImage = + intel_texture_image(intelObj->base.Image[face][i]); - if (intelImage->mt) { - intel_miptree_image_unmap(intel, intelImage->mt); - intelImage->base.Data = NULL; - } + if (intelImage->mt) { + intel_miptree_image_unmap(intel, intelImage->mt); + intelImage->base.Data = NULL; + } } } } diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 695f2f78e8d..991382f0cf8 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -45,12 +45,14 @@ #include "intel_span.h" #include "intel_tex.h" -static void intelRenderPrimitive( GLcontext *ctx, GLenum prim ); -static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim ); +static void intelRenderPrimitive(GLcontext * ctx, GLenum prim); +static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim, + GLuint hwprim); /* */ -static void intel_flush_inline_primitive( struct intel_context *intel ) +static void +intel_flush_inline_primitive(struct intel_context *intel) { GLuint used = intel->batch->ptr - intel->prim.start_ptr; @@ -59,12 +61,11 @@ static void intel_flush_inline_primitive( struct intel_context *intel ) if (used < 8) goto do_discard; - *(int *)intel->prim.start_ptr = (_3DPRIMITIVE | - intel->prim.primitive | - (used/4-2)); + *(int *) intel->prim.start_ptr = (_3DPRIMITIVE | + intel->prim.primitive | (used / 4 - 2)); goto finished; - + do_discard: intel->batch->ptr -= used; @@ -77,49 +78,49 @@ static void intel_flush_inline_primitive( struct intel_context *intel ) /* Emit a primitive referencing vertices in a vertex buffer. */ -void intelStartInlinePrimitive( struct intel_context *intel, - GLuint prim, - GLuint batch_flags ) +void +intelStartInlinePrimitive(struct intel_context *intel, + GLuint prim, GLuint batch_flags) { BATCH_LOCALS; - + /* Emit a slot which will be filled with the inline primitive * command later. */ BEGIN_BATCH(2, batch_flags); - OUT_BATCH( 0 ); + OUT_BATCH(0); intel->prim.start_ptr = intel->batch->ptr; intel->prim.primitive = prim; intel->prim.flush = intel_flush_inline_primitive; - OUT_BATCH( 0 ); + OUT_BATCH(0); ADVANCE_BATCH(); } -void intelWrapInlinePrimitive( struct intel_context *intel ) +void +intelWrapInlinePrimitive(struct intel_context *intel) { GLuint prim = intel->prim.primitive; GLuint batchflags = intel->batch->flags; intel_flush_inline_primitive(intel); intel_batchbuffer_flush(intel->batch); - - intel->vtbl.emit_state( intel ); - intelStartInlinePrimitive( intel, prim, batchflags ); /* ??? */ + intel->vtbl.emit_state(intel); + intelStartInlinePrimitive(intel, prim, batchflags); /* ??? */ } -GLuint *intelExtendInlinePrimitive( struct intel_context *intel, - GLuint dwords ) +GLuint * +intelExtendInlinePrimitive(struct intel_context *intel, GLuint dwords) { GLuint sz = dwords * sizeof(GLuint); GLuint *ptr; - if (intel_batchbuffer_space(intel->batch) < sz) - intelWrapInlinePrimitive( intel ); + if (intel_batchbuffer_space(intel->batch) < sz) + intelWrapInlinePrimitive(intel); - ptr = (GLuint *)intel->batch->ptr; + ptr = (GLuint *) intel->batch->ptr; intel->batch->ptr += sz; return ptr; @@ -151,64 +152,62 @@ do { \ } while (0) #endif -static void intel_draw_quad( struct intel_context *intel, - intelVertexPtr v0, - intelVertexPtr v1, - intelVertexPtr v2, - intelVertexPtr v3 ) +static void +intel_draw_quad(struct intel_context *intel, + intelVertexPtr v0, + intelVertexPtr v1, intelVertexPtr v2, intelVertexPtr v3) { GLuint vertsize = intel->vertex_size; - GLuint *vb = intelExtendInlinePrimitive( intel, 6 * vertsize ); + GLuint *vb = intelExtendInlinePrimitive(intel, 6 * vertsize); int j; - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v3 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v2 ); - COPY_DWORDS( j, vb, vertsize, v3 ); + COPY_DWORDS(j, vb, vertsize, v0); + COPY_DWORDS(j, vb, vertsize, v1); + COPY_DWORDS(j, vb, vertsize, v3); + COPY_DWORDS(j, vb, vertsize, v1); + COPY_DWORDS(j, vb, vertsize, v2); + COPY_DWORDS(j, vb, vertsize, v3); } -static void intel_draw_triangle( struct intel_context *intel, - intelVertexPtr v0, - intelVertexPtr v1, - intelVertexPtr v2 ) +static void +intel_draw_triangle(struct intel_context *intel, + intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2) { GLuint vertsize = intel->vertex_size; - GLuint *vb = intelExtendInlinePrimitive( intel, 3 * vertsize ); + GLuint *vb = intelExtendInlinePrimitive(intel, 3 * vertsize); int j; - - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v2 ); + + COPY_DWORDS(j, vb, vertsize, v0); + COPY_DWORDS(j, vb, vertsize, v1); + COPY_DWORDS(j, vb, vertsize, v2); } -static void intel_draw_line( struct intel_context *intel, - intelVertexPtr v0, - intelVertexPtr v1 ) +static void +intel_draw_line(struct intel_context *intel, + intelVertexPtr v0, intelVertexPtr v1) { GLuint vertsize = intel->vertex_size; - GLuint *vb = intelExtendInlinePrimitive( intel, 2 * vertsize ); + GLuint *vb = intelExtendInlinePrimitive(intel, 2 * vertsize); int j; - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); + COPY_DWORDS(j, vb, vertsize, v0); + COPY_DWORDS(j, vb, vertsize, v1); } -static void intel_draw_point( struct intel_context *intel, - intelVertexPtr v0 ) +static void +intel_draw_point(struct intel_context *intel, intelVertexPtr v0) { GLuint vertsize = intel->vertex_size; - GLuint *vb = intelExtendInlinePrimitive( intel, vertsize ); + GLuint *vb = intelExtendInlinePrimitive(intel, vertsize); int j; /* Adjust for sub pixel position -- still required for conform. */ - *(float *)&vb[0] = v0->v.x - 0.125; - *(float *)&vb[1] = v0->v.y - 0.125; - for (j = 2 ; j < vertsize ; j++) - vb[j] = v0->ui[j]; + *(float *) &vb[0] = v0->v.x - 0.125; + *(float *) &vb[1] = v0->v.y - 0.125; + for (j = 2; j < vertsize; j++) + vb[j] = v0->ui[j]; } @@ -217,13 +216,14 @@ static void intel_draw_point( struct intel_context *intel, * Fixup for ARB_point_parameters * ***********************************************************************/ -static void intel_atten_point( struct intel_context *intel, intelVertexPtr v0 ) +static void +intel_atten_point(struct intel_context *intel, intelVertexPtr v0) { GLcontext *ctx = &intel->ctx; GLfloat psz[4], col[4], restore_psz, restore_alpha; - _tnl_get_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz ); - _tnl_get_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col ); + _tnl_get_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); + _tnl_get_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); restore_psz = psz[0]; restore_alpha = col[3]; @@ -241,19 +241,19 @@ static void intel_atten_point( struct intel_context *intel, intelVertexPtr v0 ) psz[0] = 1.0; if (restore_psz != psz[0] || restore_alpha != col[3]) { - _tnl_set_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); - _tnl_set_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col); - - intel_draw_point( intel, v0 ); + _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); + _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); + + intel_draw_point(intel, v0); psz[0] = restore_psz; col[3] = restore_alpha; - _tnl_set_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); - _tnl_set_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col); + _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); + _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); } else - intel_draw_point( intel, v0 ); + intel_draw_point(intel, v0); } @@ -266,45 +266,44 @@ static void intel_atten_point( struct intel_context *intel, intelVertexPtr v0 ) -static void intel_wpos_triangle( struct intel_context *intel, - intelVertexPtr v0, - intelVertexPtr v1, - intelVertexPtr v2 ) +static void +intel_wpos_triangle(struct intel_context *intel, + intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2) { GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; - - __memcpy( ((char *)v0) + offset, v0, size ); - __memcpy( ((char *)v1) + offset, v1, size ); - __memcpy( ((char *)v2) + offset, v2, size ); - intel_draw_triangle( intel, v0, v1, v2 ); + __memcpy(((char *) v0) + offset, v0, size); + __memcpy(((char *) v1) + offset, v1, size); + __memcpy(((char *) v2) + offset, v2, size); + + intel_draw_triangle(intel, v0, v1, v2); } -static void intel_wpos_line( struct intel_context *intel, - intelVertexPtr v0, - intelVertexPtr v1 ) +static void +intel_wpos_line(struct intel_context *intel, + intelVertexPtr v0, intelVertexPtr v1) { GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; - __memcpy( ((char *)v0) + offset, v0, size ); - __memcpy( ((char *)v1) + offset, v1, size ); + __memcpy(((char *) v0) + offset, v0, size); + __memcpy(((char *) v1) + offset, v1, size); - intel_draw_line( intel, v0, v1 ); + intel_draw_line(intel, v0, v1); } -static void intel_wpos_point( struct intel_context *intel, - intelVertexPtr v0 ) +static void +intel_wpos_point(struct intel_context *intel, intelVertexPtr v0) { GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; - __memcpy( ((char *)v0) + offset, v0, size ); + __memcpy(((char *) v0) + offset, v0, size); - intel_draw_point( intel, v0 ); + intel_draw_point(intel, v0); } @@ -361,11 +360,12 @@ do { \ #define INTEL_MAX_TRIFUNC 0x10 -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; +static struct +{ + tnl_points_func points; + tnl_line_func line; + tnl_triangle_func triangle; + tnl_quad_func quad; } rast_tab[INTEL_MAX_TRIFUNC]; @@ -437,7 +437,7 @@ do { \ * Helpers for rendering unfilled primitives * ***********************************************************************/ -static const GLuint hw_prim[GL_POLYGON+1] = { +static const GLuint hw_prim[GL_POLYGON + 1] = { PRIM3D_POINTLIST, PRIM3D_LINELIST, PRIM3D_LINELIST, @@ -527,7 +527,8 @@ static const GLuint hw_prim[GL_POLYGON+1] = { #include "tnl_dd/t_dd_tritmp.h" -static void init_rast_tab( void ) +static void +init_rast_tab(void) { init(); init_offset(); @@ -558,33 +559,30 @@ static void init_rast_tab( void ) * primitives. */ static void -intel_fallback_tri( struct intel_context *intel, - intelVertex *v0, - intelVertex *v1, - intelVertex *v2 ) +intel_fallback_tri(struct intel_context *intel, + intelVertex * v0, intelVertex * v1, intelVertex * v2) { GLcontext *ctx = &intel->ctx; SWvertex v[3]; if (0) fprintf(stderr, "\n%s\n", __FUNCTION__); - + if (intel->prim.flush) intel->prim.flush(intel); - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - _swsetup_Translate( ctx, v2, &v[2] ); - intelSpanRenderStart( ctx ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); - intelSpanRenderFinish( ctx ); + _swsetup_Translate(ctx, v0, &v[0]); + _swsetup_Translate(ctx, v1, &v[1]); + _swsetup_Translate(ctx, v2, &v[2]); + intelSpanRenderStart(ctx); + _swrast_Triangle(ctx, &v[0], &v[1], &v[2]); + intelSpanRenderFinish(ctx); } static void -intel_fallback_line( struct intel_context *intel, - intelVertex *v0, - intelVertex *v1 ) +intel_fallback_line(struct intel_context *intel, + intelVertex * v0, intelVertex * v1) { GLcontext *ctx = &intel->ctx; SWvertex v[2]; @@ -595,11 +593,11 @@ intel_fallback_line( struct intel_context *intel, if (intel->prim.flush) intel->prim.flush(intel); - _swsetup_Translate( ctx, v0, &v[0] ); - _swsetup_Translate( ctx, v1, &v[1] ); - intelSpanRenderStart( ctx ); - _swrast_Line( ctx, &v[0], &v[1] ); - intelSpanRenderFinish( ctx ); + _swsetup_Translate(ctx, v0, &v[0]); + _swsetup_Translate(ctx, v1, &v[1]); + intelSpanRenderStart(ctx); + _swrast_Line(ctx, &v[0], &v[1]); + intelSpanRenderFinish(ctx); } @@ -640,8 +638,8 @@ intel_fallback_line( struct intel_context *intel, -static void intelRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) +static void +intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) { struct intel_context *intel = intel_context(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -652,39 +650,40 @@ static void intelRenderClippedPoly( GLcontext *ctx, const GLuint *elts, */ { GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, - PRIM_BEGIN|PRIM_END ); + VB->Elts = (GLuint *) elts; + tnl->Driver.Render.PrimTabElts[GL_POLYGON] (ctx, 0, n, + PRIM_BEGIN | PRIM_END); VB->Elts = tmp; } /* Restore the render primitive */ if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); + tnl->Driver.Render.PrimitiveNotify(ctx, prim); } -static void intelRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) +static void +intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj) { TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); + tnl->Driver.Render.Line(ctx, ii, jj); } -static void intelFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) +static void +intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) { - struct intel_context *intel = intel_context( ctx ); + struct intel_context *intel = intel_context(ctx); const GLuint vertsize = intel->vertex_size; - GLuint *vb = intelExtendInlinePrimitive( intel, (n-2) * 3 * vertsize ); - GLubyte *vertptr = (GLubyte *)intel->verts; - const GLuint *start = (const GLuint *)V(elts[0]); - int i,j; + GLuint *vb = intelExtendInlinePrimitive(intel, (n - 2) * 3 * vertsize); + GLubyte *vertptr = (GLubyte *) intel->verts; + const GLuint *start = (const GLuint *) V(elts[0]); + int i, j; - for (i = 2 ; i < n ; i++) { - COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) ); - COPY_DWORDS( j, vb, vertsize, V(elts[i]) ); - COPY_DWORDS( j, vb, vertsize, start ); + for (i = 2; i < n; i++) { + COPY_DWORDS(j, vb, vertsize, V(elts[i - 1])); + COPY_DWORDS(j, vb, vertsize, V(elts[i])); + COPY_DWORDS(j, vb, vertsize, start); } } @@ -698,7 +697,8 @@ static void intelFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, #define ANY_FALLBACK_FLAGS (DD_LINE_STIPPLE | DD_TRI_STIPPLE | DD_POINT_ATTEN) #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_TRI_UNFILLED) -void intelChooseRenderState(GLcontext *ctx) +void +intelChooseRenderState(GLcontext * ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct intel_context *intel = intel_context(ctx); @@ -708,45 +708,47 @@ void intelChooseRenderState(GLcontext *ctx) GLuint index = 0; if (INTEL_DEBUG & DEBUG_STATE) - fprintf(stderr,"\n%s\n",__FUNCTION__); + fprintf(stderr, "\n%s\n", __FUNCTION__); - if ((flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) || have_wpos) { + if ((flags & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) || have_wpos) { if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= INTEL_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= INTEL_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= INTEL_UNFILLED_BIT; + if (flags & DD_TRI_LIGHT_TWOSIDE) + index |= INTEL_TWOSIDE_BIT; + if (flags & DD_TRI_OFFSET) + index |= INTEL_OFFSET_BIT; + if (flags & DD_TRI_UNFILLED) + index |= INTEL_UNFILLED_BIT; } if (have_wpos) { - intel->draw_point = intel_wpos_point; - intel->draw_line = intel_wpos_line; - intel->draw_tri = intel_wpos_triangle; + intel->draw_point = intel_wpos_point; + intel->draw_line = intel_wpos_line; + intel->draw_tri = intel_wpos_triangle; - /* Make sure these get called: - */ - index |= INTEL_FALLBACK_BIT; + /* Make sure these get called: + */ + index |= INTEL_FALLBACK_BIT; } else { - intel->draw_point = intel_draw_point; - intel->draw_line = intel_draw_line; - intel->draw_tri = intel_draw_triangle; + intel->draw_point = intel_draw_point; + intel->draw_line = intel_draw_line; + intel->draw_tri = intel_draw_triangle; } /* Hook in fallbacks for specific primitives. */ - if (flags & ANY_FALLBACK_FLAGS) - { - if (flags & DD_LINE_STIPPLE) - intel->draw_line = intel_fallback_line; + if (flags & ANY_FALLBACK_FLAGS) { + if (flags & DD_LINE_STIPPLE) + intel->draw_line = intel_fallback_line; - if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple) - intel->draw_tri = intel_fallback_tri; + if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple) + intel->draw_tri = intel_fallback_tri; - if (flags & DD_POINT_ATTEN) - intel->draw_point = intel_atten_point; + if (flags & DD_POINT_ATTEN) + intel->draw_point = intel_atten_point; - index |= INTEL_FALLBACK_BIT; + index |= INTEL_FALLBACK_BIT; } } @@ -759,20 +761,21 @@ void intelChooseRenderState(GLcontext *ctx) tnl->Driver.Render.Quad = rast_tab[index].quad; if (index == 0) { - tnl->Driver.Render.PrimTabVerts = intel_render_tab_verts; - tnl->Driver.Render.PrimTabElts = intel_render_tab_elts; - tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */ - tnl->Driver.Render.ClippedPolygon = intelFastRenderClippedPoly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = intelRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly; + tnl->Driver.Render.PrimTabVerts = intel_render_tab_verts; + tnl->Driver.Render.PrimTabElts = intel_render_tab_elts; + tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */ + tnl->Driver.Render.ClippedPolygon = intelFastRenderClippedPoly; + } + else { + tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; + tnl->Driver.Render.ClippedLine = intelRenderClippedLine; + tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly; } } } -static const GLenum reduced_prim[GL_POLYGON+1] = { +static const GLenum reduced_prim[GL_POLYGON + 1] = { GL_POINTS, GL_LINES, GL_LINES, @@ -793,40 +796,43 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { -static void intelRunPipeline( GLcontext *ctx ) +static void +intelRunPipeline(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); if (intel->NewGLState) { if (intel->NewGLState & _NEW_TEXTURE) { - intel->vtbl.update_texture_state( intel ); + intel->vtbl.update_texture_state(intel); } if (!intel->Fallback) { - if (intel->NewGLState & _INTEL_NEW_RENDERSTATE) - intelChooseRenderState( ctx ); + if (intel->NewGLState & _INTEL_NEW_RENDERSTATE) + intelChooseRenderState(ctx); } intel->NewGLState = 0; } - _tnl_run_pipeline( ctx ); + _tnl_run_pipeline(ctx); } -static void intelRenderStart( GLcontext *ctx ) +static void +intelRenderStart(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); - intel->vtbl.render_start( intel_context(ctx) ); - intel->vtbl.emit_state( intel ); + intel->vtbl.render_start(intel_context(ctx)); + intel->vtbl.emit_state(intel); } -static void intelRenderFinish( GLcontext *ctx ) +static void +intelRenderFinish(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); if (intel->RenderIndex & INTEL_FALLBACK_BIT) - _swrast_flush( ctx ); + _swrast_flush(ctx); if (intel->prim.flush) intel->prim.flush(intel); @@ -838,30 +844,32 @@ static void intelRenderFinish( GLcontext *ctx ) /* System to flush dma and emit state changes based on the rasterized * primitive. */ -static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim ) +static void +intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim) { struct intel_context *intel = intel_context(ctx); if (0) - fprintf(stderr, "%s %s %x\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(rprim), hwprim); + fprintf(stderr, "%s %s %x\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(rprim), hwprim); + + intel->vtbl.reduced_primitive_state(intel, rprim); - intel->vtbl.reduced_primitive_state( intel, rprim ); - /* Start a new primitive. Arrange to have it flushed later on. */ if (hwprim != intel->prim.primitive) { if (intel->prim.flush) - intel->prim.flush(intel); + intel->prim.flush(intel); - intelStartInlinePrimitive( intel, hwprim, INTEL_BATCH_CLIPRECTS ); + intelStartInlinePrimitive(intel, hwprim, INTEL_BATCH_CLIPRECTS); } } /* */ -static void intelRenderPrimitive( GLcontext *ctx, GLenum prim ) +static void +intelRenderPrimitive(GLcontext * ctx, GLenum prim) { struct intel_context *intel = intel_context(ctx); @@ -878,13 +886,13 @@ static void intelRenderPrimitive( GLcontext *ctx, GLenum prim ) * lower level functions in that case, potentially pingponging the * state: */ - if (reduced_prim[prim] == GL_TRIANGLES && + if (reduced_prim[prim] == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) return; /* Set some primitive-dependent state and Start? a new primitive. */ - intelRasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] ); + intelRasterPrimitive(ctx, reduced_prim[prim], hw_prim[prim]); } @@ -904,7 +912,8 @@ static char *fallbackStrings[] = { }; -static char *getFallbackString(GLuint bit) +static char * +getFallbackString(GLuint bit) { int i = 0; while (bit > 1) { @@ -916,7 +925,8 @@ static char *getFallbackString(GLuint bit) -void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode ) +void +intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode) { GLcontext *ctx = &intel->ctx; TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -925,65 +935,65 @@ void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode ) if (mode) { intel->Fallback |= bit; if (oldfallback == 0) { - intelFlush(ctx); - if (INTEL_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "ENTER FALLBACK %x: %s\n", - bit, getFallbackString( bit )); - _swsetup_Wakeup( ctx ); - intel->RenderIndex = ~0; + intelFlush(ctx); + if (INTEL_DEBUG & DEBUG_FALLBACKS) + fprintf(stderr, "ENTER FALLBACK %x: %s\n", + bit, getFallbackString(bit)); + _swsetup_Wakeup(ctx); + intel->RenderIndex = ~0; } } else { intel->Fallback &= ~bit; if (oldfallback == bit) { - _swrast_flush( ctx ); - if (INTEL_DEBUG & DEBUG_FALLBACKS) - fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit )); - tnl->Driver.Render.Start = intelRenderStart; - tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive; - tnl->Driver.Render.Finish = intelRenderFinish; - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.Interp = _tnl_interp; + _swrast_flush(ctx); + if (INTEL_DEBUG & DEBUG_FALLBACKS) + fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit)); + tnl->Driver.Render.Start = intelRenderStart; + tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive; + tnl->Driver.Render.Finish = intelRenderFinish; + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.Interp = _tnl_interp; - _tnl_invalidate_vertex_state( ctx, ~0 ); - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_install_attrs( ctx, - intel->vertex_attrs, - intel->vertex_attr_count, - intel->ViewportMatrix.m, 0 ); + _tnl_invalidate_vertex_state(ctx, ~0); + _tnl_invalidate_vertices(ctx, ~0); + _tnl_install_attrs(ctx, + intel->vertex_attrs, + intel->vertex_attr_count, + intel->ViewportMatrix.m, 0); - intel->NewGLState |= _INTEL_NEW_RENDERSTATE; + intel->NewGLState |= _INTEL_NEW_RENDERSTATE; } } } -union fi { - GLfloat f; - GLint i; +union fi +{ + GLfloat f; + GLint i; }; /**********************************************************************/ /* Used only with the metaops callbacks. */ /**********************************************************************/ -void intel_meta_draw_poly(struct intel_context *intel, - GLuint n, - GLfloat xy[][2], - GLfloat z, - GLuint color, - GLfloat tex[][2]) +void +intel_meta_draw_poly(struct intel_context *intel, + GLuint n, + GLfloat xy[][2], + GLfloat z, GLuint color, GLfloat tex[][2]) { union fi *vb; GLint i; - intel->vtbl.emit_state( intel ); + intel->vtbl.emit_state(intel); /* All 3d primitives should be emitted with INTEL_BATCH_CLIPRECTS, * otherwise the drawing origin (DR4) might not be set correctly. */ - intelStartInlinePrimitive( intel, PRIM3D_TRIFAN, INTEL_BATCH_CLIPRECTS ); - vb = (union fi *)intelExtendInlinePrimitive( intel, n * 6 ); + intelStartInlinePrimitive(intel, PRIM3D_TRIFAN, INTEL_BATCH_CLIPRECTS); + vb = (union fi *) intelExtendInlinePrimitive(intel, n * 6); for (i = 0; i < n; i++) { vb[0].f = xy[i][0]; @@ -999,26 +1009,34 @@ void intel_meta_draw_poly(struct intel_context *intel, intel->prim.flush(intel); } -void intel_meta_draw_quad(struct intel_context *intel, - GLfloat x0, GLfloat x1, - GLfloat y0, GLfloat y1, - GLfloat z, - GLuint color, - GLfloat s0, GLfloat s1, - GLfloat t0, GLfloat t1) +void +intel_meta_draw_quad(struct intel_context *intel, + GLfloat x0, GLfloat x1, + GLfloat y0, GLfloat y1, + GLfloat z, + GLuint color, + GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1) { GLfloat xy[4][2]; GLfloat tex[4][2]; - xy[0][0] = x0; xy[0][1] = y0; - xy[1][0] = x1; xy[1][1] = y0; - xy[2][0] = x1; xy[2][1] = y1; - xy[3][0] = x0; xy[3][1] = y1; + xy[0][0] = x0; + xy[0][1] = y0; + xy[1][0] = x1; + xy[1][1] = y0; + xy[2][0] = x1; + xy[2][1] = y1; + xy[3][0] = x0; + xy[3][1] = y1; - tex[0][0] = s0; tex[0][1] = t0; - tex[1][0] = s1; tex[1][1] = t0; - tex[2][0] = s1; tex[2][1] = t1; - tex[3][0] = s0; tex[3][1] = t1; + tex[0][0] = s0; + tex[0][1] = t0; + tex[1][0] = s1; + tex[1][1] = t0; + tex[2][0] = s1; + tex[2][1] = t1; + tex[3][0] = s0; + tex[3][1] = t1; intel_meta_draw_poly(intel, 4, xy, z, color, tex); } @@ -1030,7 +1048,8 @@ void intel_meta_draw_quad(struct intel_context *intel, /**********************************************************************/ -void intelInitTriFuncs( GLcontext *ctx ) +void +intelInitTriFuncs(GLcontext * ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); static int firsttime = 1; diff --git a/src/mesa/drivers/dri/i915/intel_tris.h b/src/mesa/drivers/dri/i915/intel_tris.h index b4c2f40708a..b7bae8cd3bc 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.h +++ b/src/mesa/drivers/dri/i915/intel_tris.h @@ -40,31 +40,29 @@ _NEW_PROGRAM | \ _NEW_POLYGONSTIPPLE) -extern void intelInitTriFuncs( GLcontext *ctx ); +extern void intelInitTriFuncs(GLcontext * ctx); -extern void intelChooseRenderState( GLcontext *ctx ); +extern void intelChooseRenderState(GLcontext * ctx); -extern void intelStartInlinePrimitive( struct intel_context *intel, GLuint prim, GLuint flags ); -extern void intelWrapInlinePrimitive( struct intel_context *intel ); +extern void intelStartInlinePrimitive(struct intel_context *intel, + GLuint prim, GLuint flags); +extern void intelWrapInlinePrimitive(struct intel_context *intel); -GLuint *intelExtendInlinePrimitive( struct intel_context *intel, - GLuint dwords ); +GLuint *intelExtendInlinePrimitive(struct intel_context *intel, + GLuint dwords); -void intel_meta_draw_quad(struct intel_context *intel, - GLfloat x0, GLfloat x1, - GLfloat y0, GLfloat y1, - GLfloat z, - GLuint color, - GLfloat s0, GLfloat s1, - GLfloat t0, GLfloat t1); +void intel_meta_draw_quad(struct intel_context *intel, + GLfloat x0, GLfloat x1, + GLfloat y0, GLfloat y1, + GLfloat z, + GLuint color, + GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1); -void intel_meta_draw_poly(struct intel_context *intel, - GLuint n, - GLfloat xy[][2], - GLfloat z, - GLuint color, - GLfloat tex[][2]); +void intel_meta_draw_poly(struct intel_context *intel, + GLuint n, + GLfloat xy[][2], + GLfloat z, GLuint color, GLfloat tex[][2]);