i915: Moved pipe_buffer and i915_winsys functions to a common folder

This commit is contained in:
Jakob Bornecrantz 2008-06-06 14:49:02 +02:00
parent 18953a8771
commit adbdabb85a
39 changed files with 1339 additions and 2617 deletions

View File

@ -71,6 +71,7 @@ PROGRAM_DIRS = demos redbook samples glsl xdemos
GALLIUM_AUXILIARY_DIRS = draw cso_cache pipebuffer tgsi sct translate rtasm util
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple failover
GALLIUM_WINSYS_COMMON_DIRS = intel_drm
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib

View File

@ -2,7 +2,7 @@ TOP = ../..
include $(TOP)/configs/current
SUBDIRS = auxiliary drivers
SUBDIRS = auxiliary drivers winsys/common
default: subdirs

View File

@ -0,0 +1,20 @@
TOP = ../../../..
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_COMMON_DIRS)
default: subdirs
subdirs:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
done
clean:
rm -f `find . -name \*.[oa]`

View File

@ -0,0 +1,64 @@
# -*-makefile-*-
# We still have a dependency on the "dri" buffer manager. Most likely
# the interface can be reused in non-dri environments, and also as a
# frontend to simpler memory managers.
#
COMMON_SOURCES =
OBJECTS = $(C_SOURCES:.c=.o) \
$(CPP_SOURCES:.cpp=.o) \
$(ASM_SOURCES:.S=.o)
### Include directories
INCLUDES = \
-I. \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/include \
$(DRIVER_INCLUDES)
##### RULES #####
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
.cpp.o:
$(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
##### TARGETS #####
default: depend symlinks $(LIBNAME)
$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/gallium/winsys/common/Makefile.template
$(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
$(ASM_SOURCES) 2> /dev/null
# Emacs tags
tags:
etags `find . -name \*.[ch]` `find ../include`
# Remove .o and backup files
clean::
-rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-rm -f depend depend.bak
include depend

View File

@ -0,0 +1,23 @@
TOP = ../../../../..
include $(TOP)/configs/current
LIBNAME = inteldrm
C_SOURCES = \
intel_be_batchbuffer.c \
intel_be_context.c \
intel_be_device.c \
ws_dri_bufmgr.c \
ws_dri_drmpool.c \
ws_dri_fencemgr.c \
ws_dri_mallocpool.c \
ws_dri_slabpool.c
include ../Makefile.template
DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
&& pkg-config libdrm --atleast-version=2.3.1 \
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
symlinks:

View File

@ -0,0 +1,359 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.2
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
/*
* Thread support for gl dispatch.
*
* Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
* and Christoph Poliwoda (poliwoda@volumegraphics.com)
* Revised by Keith Whitwell
* Adapted for new gl dispatcher by Brian Paul
*
*
*
* DOCUMENTATION
*
* This thread module exports the following types:
* _glthread_TSD Thread-specific data area
* _glthread_Thread Thread datatype
* _glthread_Mutex Mutual exclusion lock
*
* Macros:
* _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
* _glthread_INIT_MUTEX(name) Initialize a mutex
* _glthread_LOCK_MUTEX(name) Lock a mutex
* _glthread_UNLOCK_MUTEX(name) Unlock a mutex
*
* Functions:
* _glthread_GetID(v) Get integer thread ID
* _glthread_InitTSD() Initialize thread-specific data
* _glthread_GetTSD() Get thread-specific data
* _glthread_SetTSD() Set thread-specific data
*
*/
/*
* If this file is accidentally included by a non-threaded build,
* it should not cause the build to fail, or otherwise cause problems.
* In general, it should only be included when needed however.
*/
#ifndef GLTHREAD_H
#define GLTHREAD_H
#if defined(USE_MGL_NAMESPACE)
#define _glapi_Dispatch _mglapi_Dispatch
#endif
#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
&& !defined(THREADS)
# define THREADS
#endif
#ifdef VMS
#include <GL/vms_x_fix.h>
#endif
/*
* POSIX threads. This should be your choice in the Unix world
* whenever possible. When building with POSIX threads, be sure
* to enable any compiler flags which will cause the MT-safe
* libc (if one exists) to be used when linking, as well as any
* header macros for MT-safe errno, etc. For Solaris, this is the -mt
* compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
* proper compiling for MT-safe libc etc.
*/
#if defined(PTHREADS)
#include <pthread.h> /* POSIX threads headers */
typedef struct {
pthread_key_t key;
int initMagic;
} _glthread_TSD;
typedef pthread_t _glthread_Thread;
typedef pthread_mutex_t _glthread_Mutex;
#define _glthread_DECLARE_STATIC_MUTEX(name) \
static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
#define _glthread_INIT_MUTEX(name) \
pthread_mutex_init(&(name), NULL)
#define _glthread_DESTROY_MUTEX(name) \
pthread_mutex_destroy(&(name))
#define _glthread_LOCK_MUTEX(name) \
(void) pthread_mutex_lock(&(name))
#define _glthread_UNLOCK_MUTEX(name) \
(void) pthread_mutex_unlock(&(name))
typedef pthread_cond_t _glthread_Cond;
#define _glthread_DECLARE_STATIC_COND(name) \
static _glthread_Cond name = PTHREAD_COND_INITIALIZER
#define _glthread_INIT_COND(cond) \
pthread_cond_init(&(cond), NULL)
#define _glthread_DESTROY_COND(name) \
pthread_cond_destroy(&(name))
#define _glthread_COND_WAIT(cond, mutex) \
pthread_cond_wait(&(cond), &(mutex))
#define _glthread_COND_SIGNAL(cond) \
pthread_cond_signal(&(cond))
#define _glthread_COND_BROADCAST(cond) \
pthread_cond_broadcast(&(cond))
#else /* PTHREADS */
typedef unsigned int _glthread_Cond;
#define _glthread_DECLARE_STATIC_COND(name) \
// #warning Condition variables not implemented.
#define _glthread_INIT_COND(cond) \
abort();
#define _glthread_DESTROY_COND(name) \
abort();
#define _glthread_COND_WAIT(cond, mutex) \
abort();
#define _glthread_COND_SIGNAL(cond) \
abort();
#define _glthread_COND_BROADCAST(cond) \
abort();
#endif
/*
* Solaris threads. Use only up to Solaris 2.4.
* Solaris 2.5 and higher provide POSIX threads.
* Be sure to compile with -mt on the Solaris compilers, or
* use -D_REENTRANT if using gcc.
*/
#ifdef SOLARIS_THREADS
#include <thread.h>
typedef struct {
thread_key_t key;
mutex_t keylock;
int initMagic;
} _glthread_TSD;
typedef thread_t _glthread_Thread;
typedef mutex_t _glthread_Mutex;
/* XXX need to really implement mutex-related macros */
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
#define _glthread_INIT_MUTEX(name) (void) name
#define _glthread_DESTROY_MUTEX(name) (void) name
#define _glthread_LOCK_MUTEX(name) (void) name
#define _glthread_UNLOCK_MUTEX(name) (void) name
#endif /* SOLARIS_THREADS */
/*
* Windows threads. Should work with Windows NT and 95.
* IMPORTANT: Link with multithreaded runtime library when THREADS are
* used!
*/
#ifdef WIN32_THREADS
#include <windows.h>
typedef struct {
DWORD key;
int initMagic;
} _glthread_TSD;
typedef HANDLE _glthread_Thread;
typedef CRITICAL_SECTION _glthread_Mutex;
#define _glthread_DECLARE_STATIC_MUTEX(name) /*static*/ _glthread_Mutex name = {0,0,0,0,0,0}
#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name)
#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name)
#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name)
#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name)
#endif /* WIN32_THREADS */
/*
* XFree86 has its own thread wrapper, Xthreads.h
* We wrap it again for GL.
*/
#ifdef USE_XTHREADS
#include <X11/Xthreads.h>
typedef struct {
xthread_key_t key;
int initMagic;
} _glthread_TSD;
typedef xthread_t _glthread_Thread;
typedef xmutex_rec _glthread_Mutex;
#ifdef XMUTEX_INITIALIZER
#define _glthread_DECLARE_STATIC_MUTEX(name) \
static _glthread_Mutex name = XMUTEX_INITIALIZER
#else
#define _glthread_DECLARE_STATIC_MUTEX(name) \
static _glthread_Mutex name
#endif
#define _glthread_INIT_MUTEX(name) \
xmutex_init(&(name))
#define _glthread_DESTROY_MUTEX(name) \
xmutex_clear(&(name))
#define _glthread_LOCK_MUTEX(name) \
(void) xmutex_lock(&(name))
#define _glthread_UNLOCK_MUTEX(name) \
(void) xmutex_unlock(&(name))
#endif /* USE_XTHREADS */
/*
* BeOS threads. R5.x required.
*/
#ifdef BEOS_THREADS
#include <kernel/OS.h>
#include <support/TLS.h>
typedef struct {
int32 key;
int initMagic;
} _glthread_TSD;
typedef thread_id _glthread_Thread;
/* Use Benaphore, aka speeder semaphore */
typedef struct {
int32 lock;
sem_id sem;
} benaphore;
typedef benaphore _glthread_Mutex;
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 }
#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0
#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0
#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \
if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem)
#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem)
#endif /* BEOS_THREADS */
#ifndef THREADS
/*
* THREADS not defined
*/
typedef GLuint _glthread_TSD;
typedef GLuint _glthread_Thread;
typedef GLuint _glthread_Mutex;
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
#define _glthread_INIT_MUTEX(name) (void) name
#define _glthread_DESTROY_MUTEX(name) (void) name
#define _glthread_LOCK_MUTEX(name) (void) name
#define _glthread_UNLOCK_MUTEX(name) (void) name
#endif /* THREADS */
/*
* Platform independent thread specific data API.
*/
extern unsigned long
_glthread_GetID(void);
extern void
_glthread_InitTSD(_glthread_TSD *);
extern void *
_glthread_GetTSD(_glthread_TSD *);
extern void
_glthread_SetTSD(_glthread_TSD *, void *);
#if defined(GLX_USE_TLS)
extern __thread struct _glapi_table * _glapi_tls_Dispatch
__attribute__((tls_model("initial-exec")));
#define GET_DISPATCH() _glapi_tls_Dispatch
#elif !defined(GL_CALL)
# if defined(THREADS)
# define GET_DISPATCH() \
((__builtin_expect( _glapi_Dispatch != NULL, 1 )) \
? _glapi_Dispatch : _glapi_get_dispatch())
# else
# define GET_DISPATCH() _glapi_Dispatch
# endif /* defined(THREADS) */
#endif /* ndef GL_CALL */
#endif /* THREADS_H */

View File

@ -1,52 +1,16 @@
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "intel_batchbuffer.h"
#include "intel_context.h"
#include "intel_be_batchbuffer.h"
#include "intel_be_context.h"
#include "intel_be_device.h"
#include <errno.h>
#if 0
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, "END BATCH\n\n\n");
}
#endif
#include "xf86drm.h"
static void
intel_realloc_relocs(struct intel_batchbuffer *batch, int num_relocs)
static void
intel_realloc_relocs(struct intel_be_batchbuffer *batch, int num_relocs)
{
unsigned long size = num_relocs * I915_RELOC0_STRIDE + I915_RELOC_HEADER;
size *= sizeof(uint32_t);
batch->reloc = realloc(batch->reloc, size);
batch->reloc_size = num_relocs;
@ -54,20 +18,20 @@ intel_realloc_relocs(struct intel_batchbuffer *batch, int num_relocs)
void
intel_batchbuffer_reset(struct intel_batchbuffer *batch)
intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
{
/*
* Get a new, free batchbuffer.
*/
drmBO *bo;
struct drm_bo_info_req *req;
driBOUnrefUserList(batch->list);
driBOResetList(batch->list);
/* base.size is the size available to the i915simple driver */
batch->base.size = batch->intel->intelScreen->max_batch_size - BATCH_RESERVED;
batch->base.actual_size = batch->intel->intelScreen->max_batch_size;
batch->base.size = batch->device->max_batch_size - BATCH_RESERVED;
batch->base.actual_size = batch->device->max_batch_size;
driBOData(batch->buffer, batch->base.actual_size, NULL, NULL, 0);
/*
@ -98,9 +62,9 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
*/
if (batch->reloc_size > INTEL_MAX_RELOCS ||
batch->reloc == NULL)
batch->reloc == NULL)
intel_realloc_relocs(batch, INTEL_DEFAULT_RELOCS);
assert(batch->reloc != NULL);
batch->reloc[0] = 0; /* No relocs yet. */
batch->reloc[1] = 1; /* Reloc type 1 */
@ -119,29 +83,30 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
/*======================================================================
* Public functions
*/
struct intel_batchbuffer *
intel_batchbuffer_alloc(struct intel_context *intel)
struct intel_be_batchbuffer *
intel_be_batchbuffer_alloc(struct intel_be_context *intel)
{
struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
struct intel_be_batchbuffer *batch = calloc(sizeof(*batch), 1);
batch->intel = intel;
batch->device = intel->device;
driGenBuffers(intel->intelScreen->batchPool, "batchbuffer", 1,
driGenBuffers(intel->device->batchPool, "batchbuffer", 1,
&batch->buffer, 4096,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, 0);
batch->last_fence = NULL;
batch->list = driBOCreateList(20);
batch->reloc = NULL;
intel_batchbuffer_reset(batch);
intel_be_batchbuffer_reset(batch);
return batch;
}
void
intel_batchbuffer_free(struct intel_batchbuffer *batch)
intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch)
{
if (batch->last_fence) {
driFenceFinish(batch->last_fence,
DRM_FENCE_TYPE_EXE, GL_FALSE);
DRM_FENCE_TYPE_EXE, FALSE);
driFenceUnReference(&batch->last_fence);
}
if (batch->base.map) {
@ -157,7 +122,7 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch)
}
void
intel_offset_relocation(struct intel_batchbuffer *batch,
intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
unsigned pre_add,
struct _DriBufferObject *driBO,
uint64_t val_flags,
@ -167,7 +132,7 @@ intel_offset_relocation(struct intel_batchbuffer *batch,
struct _drmBONode *node;
uint32_t *reloc;
struct drm_bo_info_req *req;
driBOAddListItem(batch->list, driBO, val_flags, val_mask,
&itemLoc, &node);
req = &node->bo_arg.d.req.bo_req;
@ -184,17 +149,17 @@ intel_offset_relocation(struct intel_batchbuffer *batch,
driReadUnlockKernelBO();
req->hint = DRM_BO_HINT_PRESUMED_OFFSET;
}
pre_add += driBOPoolOffset(driBO);
if (batch->nr_relocs == batch->reloc_size)
intel_realloc_relocs(batch, batch->reloc_size * 2);
reloc = batch->reloc +
reloc = batch->reloc +
(I915_RELOC_HEADER + batch->nr_relocs * I915_RELOC0_STRIDE);
reloc[0] = ((uint8_t *)batch->base.ptr - batch->drmBOVirtual);
intel_batchbuffer_emit_dword(batch, req->presumed_offset + pre_add);
i915_batchbuffer_dword(&batch->base, req->presumed_offset + pre_add);
reloc[1] = pre_add;
reloc[2] = itemLoc;
reloc[3] = batch->dest_location;
@ -216,14 +181,14 @@ i915_drm_copy_reply(const struct drm_bo_info_rep * rep, drmBO * buf)
buf->pageAlignment = rep->page_alignment;
}
static int
i915_execbuf(struct intel_batchbuffer *batch,
GLuint used,
GLboolean ignore_cliprects,
static int
i915_execbuf(struct intel_be_batchbuffer *batch,
unsigned int used,
boolean ignore_cliprects,
drmBOList *list,
struct drm_i915_execbuffer *ea)
{
struct intel_context *intel = batch->intel;
// struct intel_be_context *intel = batch->intel;
drmBONode *node;
drmMMListHead *l;
struct drm_i915_op_arg *arg, *first;
@ -237,16 +202,16 @@ i915_execbuf(struct intel_batchbuffer *batch,
first = NULL;
for (l = list->list.next; l != &list->list; l = l->next) {
node = DRMLISTENTRY(drmBONode, l, head);
arg = &node->bo_arg;
req = &arg->d.req;
if (!first)
first = arg;
if (prevNext)
*prevNext = (unsigned long)arg;
prevNext = &arg->next;
req->bo_req.handle = node->buf->handle;
req->op = drm_bo_validate;
@ -279,7 +244,7 @@ i915_execbuf(struct intel_batchbuffer *batch,
//return -EFAULT;
do {
ret = drmCommandWriteRead(intel->driFd, DRM_I915_EXECBUFFER, ea,
ret = drmCommandWriteRead(batch->device->fd, DRM_I915_EXECBUFFER, ea,
sizeof(*ea));
} while (ret == -EAGAIN);
@ -306,11 +271,11 @@ i915_execbuf(struct intel_batchbuffer *batch,
/* TODO: Push this whole function into bufmgr.
*/
static struct _DriFenceObject *
do_flush_locked(struct intel_batchbuffer *batch,
GLuint used,
GLboolean ignore_cliprects, GLboolean allow_unlock)
do_flush_locked(struct intel_be_batchbuffer *batch,
unsigned int used,
boolean ignore_cliprects, boolean allow_unlock)
{
struct intel_context *intel = batch->intel;
struct intel_be_context *intel = batch->intel;
struct _DriFenceObject *fo;
drmFence fence;
drmBOList *boList;
@ -358,7 +323,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
fence.flags = ea.fence_arg.flags;
fence.signaled = ea.fence_arg.signaled;
fo = driBOFenceUserList(batch->intel->intelScreen->mgr, batch->list,
fo = driBOFenceUserList(batch->device->fenceMgr, batch->list,
"SuperFence", &fence);
if (driFenceType(fo) & DRM_I915_FENCE_TYPE_RW) {
@ -369,7 +334,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
*/
batch->last_fence = fo;
driFenceReference(fo);
}
}
out:
#if 0 /* ZZZ JB: fix this */
intel->vtbl.lost_hardware(intel);
@ -381,11 +346,11 @@ do_flush_locked(struct intel_batchbuffer *batch,
struct _DriFenceObject *
intel_batchbuffer_flush(struct intel_batchbuffer *batch)
intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch)
{
struct intel_context *intel = batch->intel;
GLuint used = batch->base.ptr - batch->base.map;
GLboolean was_locked = intel->locked;
struct intel_be_context *intel = batch->intel;
unsigned int used = batch->base.ptr - batch->base.map;
boolean was_locked = batch->intel->hardware_locked(intel);
struct _DriFenceObject *fence;
if (used == 0) {
@ -429,34 +394,36 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch)
* kernel.
*/
if (!was_locked)
LOCK_HARDWARE(intel);
intel->hardware_lock(intel);
fence = do_flush_locked(batch, used, !(batch->flags & INTEL_BATCH_CLIPRECTS),
GL_FALSE);
FALSE);
if (!was_locked)
UNLOCK_HARDWARE(intel);
intel->hardware_unlock(intel);
/* Reset the buffer:
*/
intel_batchbuffer_reset(batch);
intel_be_batchbuffer_reset(batch);
return fence;
}
void
intel_batchbuffer_finish(struct intel_batchbuffer *batch)
intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch)
{
struct _DriFenceObject *fence = intel_batchbuffer_flush(batch);
driFenceFinish(fence, driFenceType(fence), GL_FALSE);
struct _DriFenceObject *fence = intel_be_batchbuffer_flush(batch);
driFenceFinish(fence, driFenceType(fence), FALSE);
driFenceUnReference(&fence);
}
#if 0
void
intel_batchbuffer_data(struct intel_batchbuffer *batch,
const void *data, GLuint bytes, GLuint flags)
intel_be_batchbuffer_data(struct intel_be_batchbuffer *batch,
const void *data, unsigned int bytes, unsigned int flags)
{
assert((bytes & 3) == 0);
intel_batchbuffer_require_space(batch, bytes, flags);
memcpy(batch->base.ptr, data, bytes);
batch->base.ptr += bytes;
}
#endif

View File

@ -0,0 +1,69 @@
#ifndef INTEL_BE_BATCHBUFFER_H
#define INTEL_BE_BATCHBUFFER_H
#include "i915simple/i915_batch.h"
#include "ws_dri_bufmgr.h"
#define BATCH_RESERVED 16
#define INTEL_DEFAULT_RELOCS 100
#define INTEL_MAX_RELOCS 400
#define INTEL_BATCH_NO_CLIPRECTS 0x1
#define INTEL_BATCH_CLIPRECTS 0x2
struct intel_be_context;
struct intel_be_device;
struct intel_be_batchbuffer
{
struct i915_batchbuffer base;
struct intel_be_context *intel;
struct intel_be_device *device;
struct _DriBufferObject *buffer;
struct _DriFenceObject *last_fence;
uint32_t flags;
struct _DriBufferList *list;
size_t list_count;
uint32_t *reloc;
size_t reloc_size;
size_t nr_relocs;
uint32_t dirty_state;
uint32_t id;
uint32_t poolOffset;
uint8_t *drmBOVirtual;
struct _drmBONode *node; /* Validation list node for this buffer */
int dest_location; /* Validation list sequence for this buffer */
};
struct intel_be_batchbuffer *
intel_be_batchbuffer_alloc(struct intel_be_context *intel);
void
intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch);
void
intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch);
struct _DriFenceObject *
intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch);
void
intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch);
void
intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
unsigned pre_add,
struct _DriBufferObject *driBO,
uint64_t val_flags,
uint64_t val_mask);
#endif

View File

@ -0,0 +1,107 @@
/*
* Authors: Jakob Bornecrantz <jakob-at-tungstengraphics.com>
*/
#include "ws_dri_fencemgr.h"
#include "intel_be_device.h"
#include "intel_be_context.h"
#include "intel_be_batchbuffer.h"
static INLINE struct intel_be_context *
intel_be_context(struct i915_winsys *sws)
{
return (struct intel_be_context *)sws;
}
/* Simple batchbuffer interface:
*/
static struct i915_batchbuffer*
intel_i915_batch_get(struct i915_winsys *sws)
{
struct intel_be_context *intel = intel_be_context(sws);
return &intel->batch->base;
}
static void intel_i915_batch_reloc(struct i915_winsys *sws,
struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta)
{
struct intel_be_context *intel = intel_be_context(sws);
unsigned flags = DRM_BO_FLAG_MEM_TT;
unsigned mask = DRM_BO_MASK_MEM;
if (access_flags & I915_BUFFER_ACCESS_WRITE) {
flags |= DRM_BO_FLAG_WRITE;
mask |= DRM_BO_FLAG_WRITE;
}
if (access_flags & I915_BUFFER_ACCESS_READ) {
flags |= DRM_BO_FLAG_READ;
mask |= DRM_BO_FLAG_READ;
}
intel_be_offset_relocation(intel->batch,
delta,
dri_bo(buf),
flags,
mask);
}
static void intel_i915_batch_flush(struct i915_winsys *sws,
struct pipe_fence_handle **fence)
{
struct intel_be_context *intel = intel_be_context(sws);
union {
struct _DriFenceObject *dri;
struct pipe_fence_handle *pipe;
} fu;
if (fence)
assert(!*fence);
fu.dri = intel_be_batchbuffer_flush(intel->batch);
if (!fu.dri) {
assert(0);
*fence = NULL;
return;
}
if (fu.dri) {
if (fence)
*fence = fu.pipe;
else
driFenceUnReference(&fu.dri);
}
}
boolean
intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
{
assert(intel);
assert(device);
intel->device = device;
/* TODO move framebuffer createion to the driver */
intel->base.batch_get = intel_i915_batch_get;
intel->base.batch_reloc = intel_i915_batch_reloc;
intel->base.batch_flush = intel_i915_batch_flush;
intel->batch = intel_be_batchbuffer_alloc(intel);
return true;
}
void
intel_be_destroy_context(struct intel_be_context *intel)
{
intel_be_batchbuffer_free(intel->batch);
}

View File

@ -0,0 +1,40 @@
/* These need to be diffrent from the intel winsys */
#ifndef INTEL_BE_CONTEXT_H
#define INTEL_BE_CONTEXT_H
#include "i915simple/i915_winsys.h"
struct intel_be_context
{
/** Interface to i915simple driver */
struct i915_winsys base;
struct intel_be_device *device;
struct intel_be_batchbuffer *batch;
/*
* Hardware lock functions.
*
* Needs to be filled in by the winsys.
*/
void (*hardware_lock)(struct intel_be_context *context);
void (*hardware_unlock)(struct intel_be_context *context);
boolean (*hardware_locked)(struct intel_be_context *context);
};
/**
* Intialize a allocated intel_be_context struct.
*
* Remember to set the hardware_* functions.
*/
boolean
intel_be_init_context(struct intel_be_context *intel,
struct intel_be_device *device);
/**
* Destroy a intel_be_context.
* Does not free the struct that is up to the winsys.
*/
void
intel_be_destroy_context(struct intel_be_context *intel);
#endif

View File

@ -0,0 +1,257 @@
/*
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
* Jakob Bornecrantz <jakob-at-tungstengraphics-dot-com>
*/
#include "intel_be_device.h"
#include "ws_dri_bufmgr.h"
#include "ws_dri_bufpool.h"
#include "ws_dri_fencemgr.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
/* Turn a pipe winsys into an intel/pipe winsys:
*/
static INLINE struct intel_be_device *
intel_be_device( struct pipe_winsys *winsys )
{
return (struct intel_be_device *)winsys;
}
/*
* Buffer functions.
*
* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *intel_be_buffer_map(struct pipe_winsys *winsys,
struct pipe_buffer *buf,
unsigned flags )
{
unsigned drm_flags = 0;
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
drm_flags |= DRM_BO_FLAG_WRITE;
if (flags & PIPE_BUFFER_USAGE_CPU_READ)
drm_flags |= DRM_BO_FLAG_READ;
return driBOMap( dri_bo(buf), drm_flags, 0 );
}
static void intel_be_buffer_unmap(struct pipe_winsys *winsys,
struct pipe_buffer *buf)
{
driBOUnmap( dri_bo(buf) );
}
static void
intel_be_buffer_destroy(struct pipe_winsys *winsys,
struct pipe_buffer *buf)
{
driBOUnReference( dri_bo(buf) );
FREE(buf);
}
static struct pipe_buffer *
intel_be_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
unsigned usage,
unsigned size )
{
struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
struct intel_be_device *iws = intel_be_device(winsys);
unsigned flags = 0;
struct _DriBufferPool *pool;
buffer->base.refcount = 1;
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
pool = iws->mallocPool;
} else if (usage & PIPE_BUFFER_USAGE_CUSTOM) {
/* For vertex buffers */
flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
pool = iws->vertexPool;
} else {
flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
pool = iws->regionPool;
}
if (usage & PIPE_BUFFER_USAGE_GPU_READ)
flags |= DRM_BO_FLAG_READ;
if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
flags |= DRM_BO_FLAG_WRITE;
/* drm complains if we don't set any read/write flags.
*/
if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
buffer->pool = pool;
driGenBuffers( buffer->pool,
"pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
driBOData( buffer->driBO, size, NULL, buffer->pool, 0 );
return &buffer->base;
}
static struct pipe_buffer *
intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
struct intel_be_device *iws = intel_be_device(winsys);
driGenUserBuffer( iws->regionPool,
"pipe user buffer", &buffer->driBO, ptr, bytes );
buffer->base.refcount = 1;
return &buffer->base;
}
/*
* Surface functions.
*
* Deprecated!
*/
static struct pipe_surface *
intel_i915_surface_alloc(struct pipe_winsys *winsys)
{
assert((size_t)"intel_i915_surface_alloc is deprecated" & 0);
return NULL;
}
static int
intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
struct pipe_surface *surf,
unsigned width, unsigned height,
enum pipe_format format,
unsigned flags,
unsigned tex_usage)
{
assert((size_t)"intel_i915_surface_alloc_storage is deprecated" & 0);
return -1;
}
static void
intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
{
assert((size_t)"intel_i915_surface_release is deprecated" & 0);
}
/*
* Fence functions
*/
static void
intel_be_fence_reference( struct pipe_winsys *sws,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence )
{
if (*ptr)
driFenceUnReference((struct _DriFenceObject **)ptr);
if (fence)
*ptr = (struct pipe_fence_handle *)driFenceReference((struct _DriFenceObject *)fence);
}
static int
intel_be_fence_signalled( struct pipe_winsys *sws,
struct pipe_fence_handle *fence,
unsigned flag )
{
return driFenceSignaled((struct _DriFenceObject *)fence, flag);
}
static int
intel_be_fence_finish( struct pipe_winsys *sws,
struct pipe_fence_handle *fence,
unsigned flag )
{
return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
}
/*
* Misc functions
*/
boolean
intel_be_init_device(struct intel_be_device *dev, int fd)
{
dev->fd = fd;
dev->max_batch_size = 16 * 4096;
dev->max_vertex_size = 128 * 4096;
dev->base.buffer_create = intel_be_buffer_create;
dev->base.user_buffer_create = intel_be_user_buffer_create;
dev->base.buffer_map = intel_be_buffer_map;
dev->base.buffer_unmap = intel_be_buffer_unmap;
dev->base.buffer_destroy = intel_be_buffer_destroy;
dev->base.surface_alloc = intel_i915_surface_alloc;
dev->base.surface_alloc_storage = intel_i915_surface_alloc_storage;
dev->base.surface_release = intel_i915_surface_release;
dev->base.fence_reference = intel_be_fence_reference;
dev->base.fence_signalled = intel_be_fence_signalled;
dev->base.fence_finish = intel_be_fence_finish;
#if 0 /* Set by the winsys */
dev->base.flush_frontbuffer = intel_flush_frontbuffer;
dev->base.get_name = intel_get_name;
#endif
dev->fMan = driInitFreeSlabManager(10, 10);
dev->fenceMgr = driFenceMgrTTMInit(dev->fd);
dev->mallocPool = driMallocPoolInit();
dev->staticPool = driDRMPoolInit(dev->fd);
dev->regionPool = driDRMPoolInit(dev->fd);
dev->vertexPool = driSlabPoolInit(dev->fd,
DRM_BO_FLAG_READ |
DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_MEM_TT,
DRM_BO_FLAG_READ |
DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_MEM_TT,
dev->max_vertex_size,
1, 120, dev->max_vertex_size * 4, 0,
dev->fMan);
dev->batchPool = driSlabPoolInit(dev->fd,
DRM_BO_FLAG_EXE |
DRM_BO_FLAG_MEM_TT,
DRM_BO_FLAG_EXE |
DRM_BO_FLAG_MEM_TT,
dev->max_batch_size,
1, 40, dev->max_batch_size * 16, 0,
dev->fMan);
return true;
}
void
intel_be_destroy_device(struct intel_be_device *dev)
{
driPoolTakeDown(dev->mallocPool);
driPoolTakeDown(dev->staticPool);
driPoolTakeDown(dev->regionPool);
driPoolTakeDown(dev->vertexPool);
driPoolTakeDown(dev->batchPool);
/** TODO takedown fenceMgr and fMan */
}

View File

@ -0,0 +1,58 @@
#ifndef INTEL_DRM_DEVICE_H
#define INTEL_DRM_DEVICE_H
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
/*
* Device
*/
struct intel_be_device
{
struct pipe_winsys base;
int fd; /**< Drm file discriptor */
size_t max_batch_size;
size_t max_vertex_size;
struct _DriFenceMgr *fenceMgr;
struct _DriBufferPool *batchPool;
struct _DriBufferPool *regionPool;
struct _DriBufferPool *mallocPool;
struct _DriBufferPool *vertexPool;
struct _DriBufferPool *staticPool;
struct _DriFreeSlabManager *fMan;
};
boolean
intel_be_init_device(struct intel_be_device *device, int fd);
void
intel_be_destroy_device(struct intel_be_device *dev);
/*
* Buffer
*/
struct intel_be_buffer {
struct pipe_buffer base;
struct _DriBufferPool *pool;
struct _DriBufferObject *driBO;
};
static INLINE struct intel_be_buffer *
intel_be_buffer( struct pipe_buffer *buf )
{
return (struct intel_be_buffer *)buf;
}
static INLINE struct _DriBufferObject *
dri_bo( struct pipe_buffer *buf )
{
return intel_be_buffer(buf)->driBO;
}
#endif

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,20 +10,20 @@
* 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
* 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 <thomas-at-tungstengraphics-dot-com>
@ -32,20 +32,22 @@
#include <xf86drm.h>
#include <stdlib.h>
#include <stdio.h>
#include "glthread.h"
#include "errno.h"
#include "ws_dri_bufmgr.h"
#include "string.h"
#include "imports.h"
#include "pipe/p_debug.h"
#include "ws_dri_bufpool.h"
#include "ws_dri_fencemgr.h"
/*
* This lock is here to protect drmBO structs changing underneath us during a
* validate list call, since validatelist cannot take individiual locks for
* each drmBO. Validatelist takes this lock in write mode. Any access to an
* individual drmBO should take this lock in read mode, since in that case, the
* driBufferObject mutex will protect the access. Locking order is
* driBufferObject mutex will protect the access. Locking order is
* driBufferObject mutex - > this rw lock.
*/
@ -84,7 +86,7 @@ static void *drmBOListNext(drmBOList *list, void *iterator)
return ret;
}
static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
uint64_t arg0,
uint64_t arg1)
{
@ -110,8 +112,8 @@ static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
list->numOnList++;
return node;
}
static int drmAddValidateItem(drmBOList *list, drmBO *buf, uint64_t flags,
static int drmAddValidateItem(drmBOList *list, drmBO *buf, uint64_t flags,
uint64_t mask, int *newItem)
{
drmBONode *node, *cur;
@ -243,11 +245,11 @@ void driWriteLockKernelBO(void)
while(kernelReaders != 0)
_glthread_COND_WAIT(bmCond, bmMutex);
}
void driWriteUnlockKernelBO(void)
{
_glthread_UNLOCK_MUTEX(bmMutex);
}
}
void driReadLockKernelBO(void)
{
@ -268,7 +270,7 @@ void driReadUnlockKernelBO(void)
/*
* TODO: Introduce fence pools in the same way as
* TODO: Introduce fence pools in the same way as
* buffer object pools.
*/
@ -298,11 +300,11 @@ typedef struct _DriBufferList {
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);
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
abort();
#else
@ -353,7 +355,7 @@ driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
_glthread_LOCK_MUTEX(buf->mutex);
assert(buf->private != NULL);
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
&buf->mutex, &virtual);
_glthread_UNLOCK_MUTEX(buf->mutex);
@ -398,7 +400,7 @@ driBOPoolOffset(struct _DriBufferObject *buf)
return ret;
}
uint64_t
uint64_t
driBOFlags(struct _DriBufferObject *buf)
{
uint64_t ret;
@ -448,7 +450,7 @@ driBOUnReference(struct _DriBufferObject *buf)
else
num_buffers--;
free(buf);
} else
} else
_glthread_UNLOCK_MUTEX(buf->mutex);
}
@ -456,8 +458,8 @@ driBOUnReference(struct _DriBufferObject *buf)
int
driBOData(struct _DriBufferObject *buf,
unsigned size, const void *data,
DriBufferPool *newPool,
unsigned size, const void *data,
DriBufferPool *newPool,
uint64_t flags)
{
void *virtual = NULL;
@ -478,8 +480,7 @@ driBOData(struct _DriBufferObject *buf,
newPool = pool;
if (!pool->create) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"driBOData called on invalid buffer\n");
assert((size_t)"driBOData called on invalid buffer\n" & 0);
BM_CKFATAL(-EINVAL);
}
@ -492,9 +493,7 @@ driBOData(struct _DriBufferObject *buf,
if (newBuffer) {
if (buf->createdByReference) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"driBOData requiring resizing called on "
"shared buffer.\n");
assert((size_t)"driBOData requiring resizing called on shared buffer.\n" & 0);
BM_CKFATAL(-EINVAL);
}
@ -531,7 +530,7 @@ driBOData(struct _DriBufferObject *buf,
DRM_BO_FLAG_WRITE, 0, &buf->mutex, &virtual);
} else {
uint64_t flag_diff = flags ^ buf->flags;
/*
* We might need to change buffer flags.
*/
@ -558,7 +557,7 @@ driBOData(struct _DriBufferObject *buf,
out:
_glthread_UNLOCK_MUTEX(buf->mutex);
return retval;
}
@ -605,23 +604,20 @@ driBOSetReferenced(struct _DriBufferObject *buf,
{
_glthread_LOCK_MUTEX(buf->mutex);
if (buf->private != NULL) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"Invalid buffer for setReferenced\n");
assert((size_t)"Invalid buffer for setReferenced\n" & 0);
BM_CKFATAL(-EINVAL);
}
if (buf->pool->reference == NULL) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"Invalid buffer pool for setReferenced\n");
assert((size_t)"Invalid buffer pool for setReferenced\n" & 0);
BM_CKFATAL(-EINVAL);
}
buf->private = buf->pool->reference(buf->pool, handle);
if (!buf->private) {
_mesa_error(NULL, GL_OUT_OF_MEMORY,
"Invalid buffer pool for setStatic\n");
assert((size_t)"Invalid buffer pool for setStatic\n" & 0);
BM_CKFATAL(-ENOMEM);
}
buf->createdByReference = GL_TRUE;
buf->createdByReference = TRUE;
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
_glthread_UNLOCK_MUTEX(buf->mutex);
}
@ -769,7 +765,7 @@ driAddListItem(drmBOList * list, drmBO * item,
static int
driAddValidateItem(drmBOList * list, drmBO * buf, uint64_t flags,
uint64_t mask, int *itemLoc,
uint64_t mask, int *itemLoc,
struct _drmBONode **pnode)
{
drmBONode *node, *cur;
@ -817,18 +813,18 @@ driAddValidateItem(drmBOList * list, drmBO * buf, uint64_t flags,
void
driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
uint64_t flags, uint64_t mask, int *itemLoc,
uint64_t flags, uint64_t mask, int *itemLoc,
struct _drmBONode **node)
{
int newItem;
_glthread_LOCK_MUTEX(buf->mutex);
BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
buf->pool->kernel(buf->pool, buf->private),
flags, mask, itemLoc, node));
BM_CKFATAL(drmAddValidateItem(&list->driBuffers, (drmBO *) buf,
flags, mask, &newItem));
if (newItem)
if (newItem)
buf->refCount++;
_glthread_UNLOCK_MUTEX(buf->mutex);
@ -897,7 +893,7 @@ driBOFenceUserList(struct _DriFenceMgr *mgr,
driBOResetList(list);
return fence;
}
void
driBOValidateUserList(struct _DriBufferList * list)
{
@ -928,7 +924,7 @@ driPoolTakeDown(struct _DriBufferPool *pool)
}
unsigned long
unsigned long
driBOSize(struct _DriBufferObject *buf)
{
unsigned long size;
@ -950,4 +946,4 @@ drmBOList *driBOGetDRIBuffers(struct _DriBufferList *list)
{
return &list->driBuffers;
}

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,20 +10,20 @@
* 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
* 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 <thomas-at-tungstengraphics-dot-com>
@ -76,7 +76,7 @@ extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
extern void driBOUnReference(struct _DriBufferObject *buf);
extern int driBOData(struct _DriBufferObject *r_buf,
unsigned size, const void *data,
unsigned size, const void *data,
struct _DriBufferPool *pool, uint64_t flags);
extern void driBOSubData(struct _DriBufferObject *buf,
@ -98,7 +98,7 @@ extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
extern void driInitBufMgr(int fd);
extern struct _DriBufferList *driBOCreateList(int target);
extern int driBOResetList(struct _DriBufferList * list);
extern void driBOAddListItem(struct _DriBufferList * list,
extern void driBOAddListItem(struct _DriBufferList * list,
struct _DriBufferObject *buf,
uint64_t flags, uint64_t mask, int *itemLoc,
struct _drmBONode **node);

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,20 +10,20 @@
* 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
* 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 <thomas-at-tungstengraphics-dot-com>
@ -40,7 +40,7 @@ typedef struct _DriBufferPool
{
int fd;
int (*map) (struct _DriBufferPool * pool, void *private,
unsigned flags, int hint, _glthread_Mutex *mutex,
unsigned flags, int hint, _glthread_Mutex *mutex,
void **virtual);
int (*unmap) (struct _DriBufferPool * pool, void *private);
int (*destroy) (struct _DriBufferPool * pool, void *private);

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,20 +10,20 @@
* 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
* 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 <thomas-at-tungstengraphics-dot-com>
@ -117,7 +117,7 @@ pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
{
drmBO *buf = (drmBO *) private;
int ret;
driReadLockKernelBO();
ret = drmBOMap(pool->fd, buf, flags, hint, virtual);
driReadUnlockKernelBO();
@ -133,7 +133,7 @@ pool_unmap(struct _DriBufferPool *pool, void *private)
driReadLockKernelBO();
ret = drmBOUnmap(pool->fd, buf);
driReadUnlockKernelBO();
return ret;
}
@ -144,7 +144,7 @@ pool_offset(struct _DriBufferPool *pool, void *private)
unsigned long offset;
driReadLockKernelBO();
assert(buf->flags & DRM_BO_FLAG_NO_MOVE);
assert(buf->flags & DRM_BO_FLAG_NO_MOVE);
offset = buf->offset;
driReadUnlockKernelBO();
@ -202,7 +202,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
}
static int
pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
int lazy)
{
drmBO *buf = (drmBO *) private;
@ -215,7 +215,7 @@ pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex
return ret;
}
static void
pool_takedown(struct _DriBufferPool *pool)
{
@ -223,7 +223,7 @@ pool_takedown(struct _DriBufferPool *pool)
}
/*static int
pool_setStatus(struct _DriBufferPool *pool, void *private,
pool_setStatus(struct _DriBufferPool *pool, void *private,
uint64_t flag_diff, uint64_t old_flags)
{
drmBO *buf = (drmBO *) private;

View File

@ -261,7 +261,7 @@ driFenceReference(struct _DriFenceObject *fence)
void
driFenceUnReference(struct _DriFenceObject **pFence)
{
struct _DriFenceMgr *mgr;
struct _DriFenceMgr *mgr;
if (*pFence == NULL)
return;

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., 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
@ -10,20 +10,20 @@
* 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
* 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 <thomas-at-tungstengraphics-dot-com>
@ -32,11 +32,10 @@
#include <xf86drm.h>
#include <stdlib.h>
#include <errno.h>
#include "imports.h"
#include "pipe/p_debug.h"
#include "glthread.h"
#include "ws_dri_bufpool.h"
#include "ws_dri_bufmgr.h"
#include "intel_screen.h"
static void *
pool_create(struct _DriBufferPool *pool,
@ -60,7 +59,7 @@ pool_destroy(struct _DriBufferPool *pool, void *private)
}
static int
pool_waitIdle(struct _DriBufferPool *pool, void *private,
pool_waitIdle(struct _DriBufferPool *pool, void *private,
_glthread_Mutex *mutex, int lazy)
{
return 0;

View File

@ -636,7 +636,7 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
}
static int
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
_glthread_Mutex *mutex, int lazy)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
@ -688,7 +688,7 @@ pool_unmap(struct _DriBufferPool *pool, void *private)
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
--buf->mapCount;
if (buf->mapCount == 0 && buf->isSlabBuffer)
if (buf->mapCount == 0 && buf->isSlabBuffer)
_glthread_COND_BROADCAST(buf->event);
return 0;
@ -774,14 +774,14 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
}
static int
pool_validate(struct _DriBufferPool *pool, void *private,
pool_validate(struct _DriBufferPool *pool, void *private,
_glthread_Mutex *mutex)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
if (!buf->isSlabBuffer)
if (!buf->isSlabBuffer)
return 0;
while(buf->mapCount != 0)
_glthread_COND_WAIT(buf->event, *mutex);

View File

@ -54,6 +54,7 @@ SHARED_INCLUDES = \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/gallium/winsys/common \
-I$(TOP)/src/mesa \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/mesa/glapi \

View File

@ -4,26 +4,17 @@ include $(TOP)/configs/current
LIBNAME = i915_dri.so
MINIGLX_SOURCES = server/intel_dri.c
PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/i915simple/libi915simple.a
$(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
$(TOP)/src/gallium/winsys/common/intel_drm/libinteldrm.a
DRIVER_SOURCES = \
intel_winsys_pipe.c \
intel_winsys_softpipe.c \
intel_winsys_i915.c \
intel_batchbuffer.c \
intel_swapbuffers.c \
intel_context.c \
intel_lock.c \
intel_screen.c \
ws_dri_bufmgr.c \
ws_dri_drmpool.c \
ws_dri_fencemgr.c \
ws_dri_mallocpool.c \
ws_dri_slabpool.c
intel_screen.c
C_SOURCES = \
$(COMMON_GALLIUM_SOURCES) \
@ -36,6 +27,6 @@ DRIVER_DEFINES = -I$(TOP)/src/mesa/drivers/dri/intel $(shell pkg-config libdrm -
include ../Makefile.template
intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c
#intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c
symlinks:

View File

@ -1,137 +1,24 @@
#ifndef INTEL_BATCHBUFFER_H
#define INTEL_BATCHBUFFER_H
#include "mtypes.h"
#include "ws_dri_bufmgr.h"
#include "i915simple/i915_batch.h"
#include "intel_drm/intel_be_batchbuffer.h"
struct intel_context;
#define BATCH_SZ 16384
#define BATCH_RESERVED 16
#define INTEL_DEFAULT_RELOCS 100
#define INTEL_MAX_RELOCS 400
#define INTEL_BATCH_NO_CLIPRECTS 0x1
#define INTEL_BATCH_CLIPRECTS 0x2
struct intel_batchbuffer
{
struct i915_batchbuffer base;
struct intel_context *intel;
struct _DriBufferObject *buffer;
struct _DriFenceObject *last_fence;
GLuint flags;
struct _DriBufferList *list;
GLuint list_count;
uint32_t *reloc;
GLuint reloc_size;
GLuint nr_relocs;
GLuint dirty_state;
GLuint id;
uint32_t poolOffset;
uint8_t *drmBOVirtual;
struct _drmBONode *node; /* Validation list node for this buffer */
int dest_location; /* Validation list sequence for this buffer */
};
struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context
*intel);
void intel_batchbuffer_free(struct intel_batchbuffer *batch);
void intel_batchbuffer_finish(struct intel_batchbuffer *batch);
struct _DriFenceObject *intel_batchbuffer_flush(struct intel_batchbuffer
*batch);
void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
/* Unlike bmBufferData, this currently requires the buffer be mapped.
* Consider it a convenience function wrapping multple
* intel_buffer_dword() calls.
/*
* Need to redefine the BATCH defines
*/
void intel_batchbuffer_data(struct intel_batchbuffer *batch,
const void *data, GLuint bytes, GLuint flags);
void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
GLuint bytes);
void
intel_offset_relocation(struct intel_batchbuffer *batch,
unsigned pre_add,
struct _DriBufferObject *driBO,
uint64_t val_flags,
uint64_t val_mask);
/* 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)
{
return (batch->base.size - BATCH_RESERVED) - (batch->base.ptr - batch->base.map);
}
static INLINE void
intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, GLuint dword)
{
assert(batch->base.map);
assert(intel_batchbuffer_space(batch) >= 4);
*(GLuint *) (batch->base.ptr) = dword;
batch->base.ptr += 4;
}
static INLINE void
intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
GLuint sz, GLuint flags)
{
struct _DriFenceObject *fence;
assert(sz < batch->base.size - 8);
if (intel_batchbuffer_space(batch) < sz ||
(batch->flags != 0 && flags != 0 && batch->flags != flags)) {
fence = intel_batchbuffer_flush(batch);
driFenceUnReference(&fence);
}
batch->flags |= flags;
}
/* Here are the crusty old macros, to be removed:
*/
#undef BATCH_LOCALS
#define BATCH_LOCALS
#undef BEGIN_BATCH
#define BEGIN_BATCH(n, flags) do { \
assert(!intel->prim.flush); \
intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
} while (0)
#define BEGIN_BATCH(dwords, relocs) \
(i915_batchbuffer_check(&intel->base.batch->base, dwords, relocs))
#undef OUT_BATCH
#define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
#define OUT_BATCH(d) \
i915_batchbuffer_dword(&intel->base.batch->base, d)
#undef OUT_RELOC
#define OUT_RELOC(buf,flags,mask,delta) do { \
#define OUT_RELOC(buf,flags,mask,delta) do { \
assert((delta) >= 0); \
intel_offset_relocation(intel->batch, delta, buf, flags, mask); \
intel_be_offset_relocation(intel->base.batch, delta, buf, flags, mask); \
} while (0)
#undef ADVANCE_BATCH
#define ADVANCE_BATCH() do { } while(0)
#endif

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* 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.
*
*
**************************************************************************/
@ -31,8 +31,10 @@
#include "intel_screen.h"
#include "intel_context.h"
#include "intel_swapbuffers.h"
#include "intel_winsys.h"
#include "intel_batchbuffer.h"
#include "intel_winsys_softpipe.h"
#include "i915simple/i915_screen.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
@ -132,6 +134,46 @@ static const struct dri_debug_control debug_control[] = {
/**
* Create i915 hardware rendering context.
*/
static struct pipe_context *
intel_create_i915simple(struct intel_context *intel,
struct pipe_winsys *winsys)
{
struct pipe_screen *screen;
/* Fill in this struct with callbacks that i915simple will need to
* communicate with the window system, buffer manager, etc.
*/
screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
/* Create the i915simple context:
*/
return i915_create_context(screen, winsys, &intel->base.base );
}
static void
intel_lock_hardware(struct intel_be_context *context)
{
struct intel_context *intel = (struct intel_context *)context;
LOCK_HARDWARE(intel);
}
static void
intel_unlock_hardware(struct intel_be_context *context)
{
struct intel_context *intel = (struct intel_context *)context;
UNLOCK_HARDWARE(intel);
}
static boolean
intel_locked_hardware(struct intel_be_context *context)
{
struct intel_context *intel = (struct intel_context *)context;
return intel->locked ? TRUE : FALSE;
}
GLboolean
intelCreateContext(const __GLcontextModes * visual,
__DRIcontextPrivate * driContextPriv,
@ -179,20 +221,24 @@ intelCreateContext(const __GLcontextModes * visual,
intel->iw.irq_seq = -1;
intel->irqsEmitted = 0;
intel->batch = intel_batchbuffer_alloc(intel);
intel->last_swap_fence = NULL;
intel->first_swap_fence = NULL;
#ifdef DEBUG
__intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
#endif
intel->base.hardware_lock = intel_lock_hardware;
intel->base.hardware_unlock = intel_unlock_hardware;
intel->base.hardware_locked = intel_locked_hardware;
intel_be_init_context(&intel->base, &intelScreen->base);
/*
* Pipe-related setup
*/
if (getenv("INTEL_SP")) {
/* use softpipe driver instead of hw */
pipe = intel_create_softpipe( intel, intelScreen->winsys );
pipe = intel_create_softpipe( intel, &intelScreen->base.base );
}
else {
switch (intel->intelScreen->deviceID) {
@ -204,13 +250,13 @@ intelCreateContext(const __GLcontextModes * visual,
case PCI_CHIP_Q35_G:
case PCI_CHIP_I915_G:
case PCI_CHIP_I915_GM:
pipe = intel_create_i915simple( intel, intelScreen->winsys );
pipe = intel_create_i915simple( intel, &intelScreen->base.base );
break;
default:
fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
intel->intelScreen->deviceID, __FUNCTION__);
pipe = intel_create_softpipe( intel, intelScreen->winsys );
pipe = intel_create_softpipe( intel, &intelScreen->base.base );
break;
}
}
@ -234,8 +280,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
if (intel) {
st_finish(intel->st);
intel_batchbuffer_free(intel->batch);
if (intel->last_swap_fence) {
driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
driFenceUnReference(&intel->last_swap_fence);
@ -251,6 +295,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
intel->intelScreen->dummyContext = NULL;
st_destroy_context(intel->st);
intel_be_destroy_context(&intel->base);
free(intel);
}
}

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#ifndef INTEL_CONTEXT_H
@ -36,6 +36,8 @@
#include "intel_screen.h"
#include "i915_drm.h"
#include "intel_drm/intel_be_context.h"
struct pipe_context;
struct intel_context;
@ -50,12 +52,13 @@ struct st_context;
*/
struct intel_context
{
struct intel_be_context base;
struct st_context *st;
struct _DriFenceObject *last_swap_fence;
struct _DriFenceObject *first_swap_fence;
struct intel_batchbuffer *batch;
// struct intel_batchbuffer *batch;
boolean locked;
char *prevLockFile;
@ -123,7 +126,7 @@ extern int __intel_debug;
} while(0)
#else
#define DBG(flag, ...)
#define DBG(flag, ...)
#endif

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* 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.
*
*
**************************************************************************/
@ -87,7 +87,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
}
/* Unlock the hardware using the global current context
/* Unlock the hardware using the global current context
*/
void UNLOCK_HARDWARE( struct intel_context *intel )
{
@ -99,4 +99,4 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
_glthread_UNLOCK_MUTEX(lockMutex);
DBG(LOCK, "%s - unlocked\n", __progname);
}
}

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* 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.
*
*
**************************************************************************/

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#include "utils.h"
@ -32,12 +32,10 @@
#include "intel_context.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
//#include "intel_batchpool.h"
#include "intel_swapbuffers.h"
#include "intel_winsys.h"
#include "i830_dri.h"
#include "ws_dri_bufpool.h"
#include "intel_drm/ws_dri_bufpool.h"
#include "pipe/p_context.h"
#include "state_tracker/st_public.h"
@ -152,16 +150,16 @@ intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_MOVE |
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
driBOSetStatic(intelScreen->front.buffer,
intelScreen->front.offset,
intelScreen->front.pitch * intelScreen->front.height,
driBOSetStatic(intelScreen->front.buffer,
intelScreen->front.offset,
intelScreen->front.pitch * intelScreen->front.height,
intelScreen->front.map, 0);
}
#else
if (intelScreen->staticPool) {
if (intelScreen->base.staticPool) {
if (intelScreen->front.buffer)
driBOUnReference(intelScreen->front.buffer);
driGenBuffers(intelScreen->staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
driBOSetReferenced(intelScreen->front.buffer, sarea->front_bo_handle);
}
#endif
@ -177,33 +175,6 @@ intelCreatePools(__DRIscreenPrivate * sPriv)
if (intelScreen->havePools)
return GL_TRUE;
#if 0 /* ZZZ JB fix this */
intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd);
if (!intelScreen->staticPool)
return GL_FALSE;
batchPoolSize /= BATCH_SZ;
intelScreen->batchPool = driBatchPoolInit(sPriv->fd,
DRM_BO_FLAG_EXE |
DRM_BO_FLAG_MEM_TT |
DRM_BO_FLAG_MEM_LOCAL,
BATCH_SZ,
batchPoolSize, 5);
if (!intelScreen->batchPool) {
fprintf(stderr, "Failed to initialize batch pool - possible incorrect agpgart installed\n");
return GL_FALSE;
}
#else
intelScreen->staticPool = driDRMPoolInit(sPriv->fd);
intelScreen->batchPool = driSlabPoolInit(sPriv->fd,
DRM_BO_FLAG_EXE |
DRM_BO_FLAG_MEM_TT,
DRM_BO_FLAG_EXE |
DRM_BO_FLAG_MEM_TT,
intelScreen->max_batch_size,
1, 40, intelScreen->max_batch_size * 16, 0,
intelScreen->fMan);
#endif
intelScreen->havePools = GL_TRUE;
intelUpdateScreenRotation(sPriv, intelScreen->sarea);
@ -211,6 +182,27 @@ intelCreatePools(__DRIscreenPrivate * sPriv)
return GL_TRUE;
}
static const char *
intel_get_name( struct pipe_winsys *winsys )
{
return "Intel/DRI/ttm";
}
/*
* The state tracker (should!) keep track of whether the fake
* frontbuffer has been touched by any rendering since the last time
* we copied its contents to the real frontbuffer. Our task is easy:
*/
static void
intel_flush_frontbuffer( struct pipe_winsys *winsys,
struct pipe_surface *surf,
void *context_private)
{
struct intel_context *intel = (struct intel_context *) context_private;
__DRIdrawablePrivate *dPriv = intel->driDrawable;
intelDisplaySurface(dPriv, surf, NULL);
}
static boolean
intelInitDriver(__DRIscreenPrivate * sPriv)
@ -231,7 +223,7 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
/* Allocate the private area */
intelScreen = CALLOC_STRUCT(intel_screen);
if (!intelScreen)
if (!intelScreen)
return GL_FALSE;
/* parse information in __driConfigOptions */
@ -262,26 +254,9 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
(*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
}
intelScreen->max_batch_size = 16 * 4096;
#if 1 // ZZZ JB
intelScreen->mgr = driFenceMgrTTMInit(sPriv->fd);
if (!intelScreen->mgr) {
fprintf(stderr, "Failed to create fence manager.\n");
return GL_FALSE;
}
intelScreen->fMan = driInitFreeSlabManager(10, 10);
if (!intelScreen->fMan) {
fprintf(stderr, "Failed to create free slab manager.\n");
return GL_FALSE;
}
if (!intelCreatePools(sPriv))
return GL_FALSE;
#endif
intelScreen->winsys = intel_create_pipe_winsys(sPriv->fd, intelScreen->fMan);
intel_be_init_device(&intelScreen->base, sPriv->fd);
intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
intelScreen->base.base.get_name = intel_get_name;
return GL_TRUE;
}
@ -292,12 +267,9 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
{
struct intel_screen *intelScreen = intel_screen(sPriv);
intel_be_destroy_device(&intelScreen->base);
/* intelUnmapScreenRegions(intelScreen); */
if (intelScreen->havePools) {
driPoolTakeDown(intelScreen->staticPool);
driPoolTakeDown(intelScreen->batchPool);
}
FREE(intelScreen);
sPriv->private = NULL;
}
@ -518,8 +490,8 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
* This routine also fills in the linked list pointed to by \c driver_modes
* with the \c __GLcontextModes that the driver can support for windows or
* pbuffers.
*
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
*
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
* failure.
*/
PUBLIC void *

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#ifndef _INTEL_SCREEN_H_
@ -31,13 +31,16 @@
#include "dri_util.h"
#include "i830_common.h"
#include "xmlconfig.h"
#include "ws_dri_bufpool.h"
#include "intel_drm/ws_dri_bufpool.h"
#include "pipe/p_compiler.h"
#include "intel_drm/intel_be_device.h"
struct intel_screen
{
struct intel_be_device base;
struct {
drm_handle_t handle;
@ -51,7 +54,7 @@ struct intel_screen
int width;
int height;
int size;
int cpp; /* for front and back buffers */
int cpp; /* for front and back buffers */
} front;
int deviceID;
@ -64,8 +67,6 @@ struct intel_screen
*/
driOptionCache optionCache;
struct _DriBufferPool *batchPool;
struct _DriBufferPool *staticPool; /** for the X screen/framebuffer */
boolean havePools;
/**
@ -74,13 +75,11 @@ struct intel_screen
*/
struct intel_context *dummyContext;
/*
/*
* New stuff form the i915tex integration
*/
struct _DriFenceMgr *mgr;
struct _DriFreeSlabManager *fMan;
unsigned batch_id;
unsigned max_batch_size;
struct pipe_winsys *winsys;
};

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,21 +22,22 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#include "intel_screen.h"
#include "intel_context.h"
#include "intel_swapbuffers.h"
#include "intel_batchbuffer.h"
#include "intel_reg.h"
#include "intel_winsys.h"
#include "pipe/p_context.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_cb_fbo.h"
#include "intel_drm/ws_dri_bufmgr.h"
#include "intel_batchbuffer.h"
/**
* Display a colorbuffer surface in an X window.
@ -114,7 +115,7 @@ intelDisplaySurface(__DRIdrawablePrivate *dPriv,
if (pbox->x1 > pbox->x2 ||
pbox->y1 > pbox->y2 ||
pbox->x2 > intelScreen->front.width ||
pbox->x2 > intelScreen->front.width ||
pbox->y2 > intelScreen->front.height) {
/* invalid cliprect, skip it */
continue;
@ -159,13 +160,22 @@ intelDisplaySurface(__DRIdrawablePrivate *dPriv,
assert(box.y1 < box.y2);
/* XXX this could be done with pipe->surface_copy() */
BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
/* XXX should have its own batch buffer */
if (!BEGIN_BATCH(8, 2)) {
/*
* Since we share this batch buffer with a context
* we can't flush it since that risks a GPU lockup
*/
assert(0);
continue;
}
OUT_BATCH(CMD);
OUT_BATCH(BR13);
OUT_BATCH((box.y1 << 16) | box.x1);
OUT_BATCH((box.y2 << 16) | box.x2);
OUT_RELOC(intelScreen->front.buffer,
OUT_RELOC(intelScreen->front.buffer,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
OUT_BATCH((sbox.y1 << 16) | sbox.x1);
@ -174,12 +184,11 @@ intelDisplaySurface(__DRIdrawablePrivate *dPriv,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
ADVANCE_BATCH();
}
if (intel->first_swap_fence)
driFenceUnReference(&intel->first_swap_fence);
intel->first_swap_fence = intel_batchbuffer_flush(intel->batch);
intel->first_swap_fence = intel_be_batchbuffer_flush(intel->base.batch);
}
UNLOCK_HARDWARE(intel);

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,7 +22,7 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#ifndef INTEL_SWAPBUFFERS_H

View File

@ -1,156 +0,0 @@
/**************************************************************************
*
* 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: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#include <stdlib.h>
#include <xf86drm.h>
#include "ws_dri_bufpool.h"
#include "ws_dri_bufmgr.h"
#include "intel_context.h"
#include "intel_batchbuffer.h"
#include "intel_winsys.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "i915simple/i915_winsys.h"
#include "i915simple/i915_screen.h"
struct intel_i915_winsys {
struct i915_winsys winsys; /**< batch buffer funcs */
struct pipe_winsys *pws;
struct intel_context *intel;
};
/* Turn a i915simple winsys into an intel/i915simple winsys:
*/
static inline struct intel_i915_winsys *
intel_i915_winsys( struct i915_winsys *sws )
{
return (struct intel_i915_winsys *)sws;
}
/* Simple batchbuffer interface:
*/
static struct i915_batchbuffer*
intel_i915_batch_get( struct i915_winsys *sws )
{
struct intel_context *intel = intel_i915_winsys(sws)->intel;
return &intel->batch->base;
}
static void intel_i915_batch_reloc( struct i915_winsys *sws,
struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta )
{
struct intel_context *intel = intel_i915_winsys(sws)->intel;
unsigned flags = DRM_BO_FLAG_MEM_TT;
unsigned mask = DRM_BO_MASK_MEM;
if (access_flags & I915_BUFFER_ACCESS_WRITE) {
flags |= DRM_BO_FLAG_WRITE;
mask |= DRM_BO_FLAG_WRITE;
}
if (access_flags & I915_BUFFER_ACCESS_READ) {
flags |= DRM_BO_FLAG_READ;
mask |= DRM_BO_FLAG_READ;
}
intel_offset_relocation( intel->batch,
delta,
dri_bo( buf ),
flags,
mask );
}
static void intel_i915_batch_flush( struct i915_winsys *sws,
struct pipe_fence_handle **fence )
{
struct intel_i915_winsys *iws = intel_i915_winsys(sws);
struct intel_context *intel = iws->intel;
union {
struct _DriFenceObject *dri;
struct pipe_fence_handle *pipe;
} fu;
if (fence)
assert(!*fence);
fu.dri = intel_batchbuffer_flush( intel->batch );
if (!fu.dri) {
assert(0);
*fence = NULL;
return;
}
if (fu.dri) {
if (fence)
*fence = fu.pipe;
else
driFenceUnReference(&fu.dri);
}
}
/**
* Create i915 hardware rendering context.
*/
struct pipe_context *
intel_create_i915simple( struct intel_context *intel,
struct pipe_winsys *winsys )
{
struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
struct pipe_screen *screen;
/* Fill in this struct with callbacks that i915simple will need to
* communicate with the window system, buffer manager, etc.
*/
iws->winsys.batch_get = intel_i915_batch_get;
iws->winsys.batch_reloc = intel_i915_batch_reloc;
iws->winsys.batch_flush = intel_i915_batch_flush;
iws->pws = winsys;
iws->intel = intel;
screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
/* Create the i915simple context:
*/
return i915_create_context( screen,
winsys,
&iws->winsys );
}

View File

@ -1,318 +0,0 @@
/**************************************************************************
*
* 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: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#include <stdlib.h>
#include <xf86drm.h>
#include "intel_context.h"
#include "intel_winsys.h"
#include "intel_swapbuffers.h"
#include "intel_batchbuffer.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
struct intel_pipe_winsys {
struct pipe_winsys winsys;
struct _DriBufferPool *regionPool;
struct _DriBufferPool *mallocPool;
struct _DriBufferPool *vertexPool;
struct _DriFreeSlabManager *fMan; /** shared between all pipes */
};
/* Turn a pipe winsys into an intel/pipe winsys:
*/
static inline struct intel_pipe_winsys *
intel_pipe_winsys( struct pipe_winsys *winsys )
{
return (struct intel_pipe_winsys *)winsys;
}
/*
* Buffer functions.
*
* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *intel_buffer_map(struct pipe_winsys *winsys,
struct pipe_buffer *buf,
unsigned flags )
{
unsigned drm_flags = 0;
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
drm_flags |= DRM_BO_FLAG_WRITE;
if (flags & PIPE_BUFFER_USAGE_CPU_READ)
drm_flags |= DRM_BO_FLAG_READ;
return driBOMap( dri_bo(buf), drm_flags, 0 );
}
static void intel_buffer_unmap(struct pipe_winsys *winsys,
struct pipe_buffer *buf)
{
driBOUnmap( dri_bo(buf) );
}
static void
intel_buffer_destroy(struct pipe_winsys *winsys,
struct pipe_buffer *buf)
{
driBOUnReference( dri_bo(buf) );
FREE(buf);
}
static struct pipe_buffer *
intel_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
unsigned usage,
unsigned size )
{
struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
unsigned flags = 0;
struct _DriBufferPool *pool;
buffer->base.refcount = 1;
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
pool = iws->mallocPool;
} else if (usage & PIPE_BUFFER_USAGE_CUSTOM) {
/* For vertex buffers */
flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
pool = iws->vertexPool;
} else {
flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
pool = iws->regionPool;
}
if (usage & PIPE_BUFFER_USAGE_GPU_READ)
flags |= DRM_BO_FLAG_READ;
if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
flags |= DRM_BO_FLAG_WRITE;
/* drm complains if we don't set any read/write flags.
*/
if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
#if 0
if (flags & IWS_BUFFER_USAGE_EXE)
flags |= DRM_BO_FLAG_EXE;
if (usage & IWS_BUFFER_USAGE_CACHED)
flags |= DRM_BO_FLAG_CACHED;
#endif
buffer->pool = pool;
driGenBuffers( buffer->pool,
"pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
driBOData( buffer->driBO, size, NULL, buffer->pool, 0 );
return &buffer->base;
}
static struct pipe_buffer *
intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
driGenUserBuffer( iws->regionPool,
"pipe user buffer", &buffer->driBO, ptr, bytes );
buffer->base.refcount = 1;
return &buffer->base;
}
/*
* Surface functions.
*
* Deprecated!
*/
static struct pipe_surface *
intel_i915_surface_alloc(struct pipe_winsys *winsys)
{
assert("intel_i915_surface_alloc is deprecated" & 0);
return NULL;
}
static int
intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
struct pipe_surface *surf,
unsigned width, unsigned height,
enum pipe_format format,
unsigned flags,
unsigned tex_usage)
{
assert("intel_i915_surface_alloc_storage is deprecated" & 0);
return -1;
}
static void
intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
{
assert("intel_i915_surface_release is deprecated" & 0);
}
/*
* Fence functions
*/
static void
intel_fence_reference( struct pipe_winsys *sws,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence )
{
if (*ptr)
driFenceUnReference((struct _DriFenceObject **)ptr);
if (fence)
*ptr = (struct pipe_fence_handle *)driFenceReference((struct _DriFenceObject *)fence);
}
static int
intel_fence_signalled( struct pipe_winsys *sws,
struct pipe_fence_handle *fence,
unsigned flag )
{
return driFenceSignaled((struct _DriFenceObject *)fence, flag);
}
static int
intel_fence_finish( struct pipe_winsys *sws,
struct pipe_fence_handle *fence,
unsigned flag )
{
return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
}
/*
* Mixed functions
*/
static const char *
intel_get_name( struct pipe_winsys *winsys )
{
return "Intel/DRI/ttm";
}
/*
* The state tracker (should!) keep track of whether the fake
* frontbuffer has been touched by any rendering since the last time
* we copied its contents to the real frontbuffer. Our task is easy:
*/
static void
intel_flush_frontbuffer( struct pipe_winsys *winsys,
struct pipe_surface *surf,
void *context_private)
{
struct intel_context *intel = (struct intel_context *) context_private;
__DRIdrawablePrivate *dPriv = intel->driDrawable;
intelDisplaySurface(dPriv, surf, NULL);
}
struct pipe_winsys *
intel_create_pipe_winsys( int fd, struct _DriFreeSlabManager *fMan )
{
struct intel_pipe_winsys *iws = CALLOC_STRUCT( intel_pipe_winsys );
/* Fill in this struct with callbacks that pipe will need to
* communicate with the window system, buffer manager, etc.
*
* Pipe would be happy with a malloc based memory manager, but
* the SwapBuffers implementation in this winsys driver requires
* that rendering be done to an appropriate _DriBufferObject.
*/
iws->winsys.buffer_create = intel_buffer_create;
iws->winsys.user_buffer_create = intel_user_buffer_create;
iws->winsys.buffer_map = intel_buffer_map;
iws->winsys.buffer_unmap = intel_buffer_unmap;
iws->winsys.buffer_destroy = intel_buffer_destroy;
iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
iws->winsys.get_name = intel_get_name;
iws->winsys.surface_alloc = intel_i915_surface_alloc;
iws->winsys.surface_alloc_storage = intel_i915_surface_alloc_storage;
iws->winsys.surface_release = intel_i915_surface_release;
iws->winsys.fence_reference = intel_fence_reference;
iws->winsys.fence_signalled = intel_fence_signalled;
iws->winsys.fence_finish = intel_fence_finish;
if (fd) {
iws->regionPool = driDRMPoolInit(fd);
iws->vertexPool = driSlabPoolInit(fd,
DRM_BO_FLAG_READ |
DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_MEM_TT,
DRM_BO_FLAG_READ |
DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_MEM_TT,
128 * 4096,
1, 120, 128 * 4096 * 4, 0,
fMan);
}
iws->mallocPool = driMallocPoolInit();
return &iws->winsys;
}
void
intel_destroy_pipe_winsys( struct pipe_winsys *winsys )
{
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
if (iws->regionPool) {
driPoolTakeDown(iws->regionPool);
}
if (iws->mallocPool) {
driPoolTakeDown(iws->mallocPool);
}
free(iws);
}

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,27 +10,27 @@
* 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
* 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: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#include "intel_context.h"
#include "intel_winsys.h"
#include "intel_winsys_softpipe.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "pipe/p_format.h"
@ -69,9 +69,9 @@ intel_create_softpipe( struct intel_context *intel,
{
struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
struct pipe_screen *screen = softpipe_create_screen(winsys);
/* Fill in this struct with callbacks that softpipe will need to
* communicate with the window system, buffer manager, etc.
* communicate with the window system, buffer manager, etc.
*/
isws->sws.is_format_supported = intel_is_format_supported;
isws->intel = intel;

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@ -22,52 +22,18 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#ifndef INTEL_WINSYS_H
#define INTEL_WINSYS_H
#ifndef INTEL_SOFTPIPE_H
#define INTEL_SOFTPIPE_H
#include "pipe/p_state.h"
struct intel_context;
struct pipe_context;
struct pipe_winsys;
struct pipe_buffer;
struct _DriBufferObject;
struct pipe_winsys *
intel_create_pipe_winsys( int fd, struct _DriFreeSlabManager *fMan );
void
intel_destroy_pipe_winsys( struct pipe_winsys *winsys );
struct pipe_context;
struct intel_context;
struct pipe_context *
intel_create_softpipe( struct intel_context *intel,
struct pipe_winsys *winsys );
struct pipe_context *
intel_create_i915simple( struct intel_context *intel,
struct pipe_winsys *winsys );
struct intel_buffer {
struct pipe_buffer base;
struct _DriBufferPool *pool;
struct _DriBufferObject *driBO;
};
static INLINE struct intel_buffer *
intel_buffer( struct pipe_buffer *buf )
{
return (struct intel_buffer *)buf;
}
static INLINE struct _DriBufferObject *
dri_bo( struct pipe_buffer *buf )
{
return intel_buffer(buf)->driBO;
}
#endif

View File

@ -88,9 +88,9 @@ typedef struct {
/** Last context that used the buffer manager. */
int texAge;
int pf_enabled; /* is pageflipping allowed? */
int pf_active;
int pf_active;
int pf_current_page; /* which buffer is being displayed? */
int perf_boxes; /* performance boxes to be displayed */
int perf_boxes; /* performance boxes to be displayed */
int width, height; /* screen size in pixels */
drm_handle_t front_handle;
@ -173,7 +173,7 @@ typedef struct {
int num_cliprects; /* mulitpass with multiple cliprects? */
drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
} drmI830CmdBuffer;
typedef struct {
int *irq_seq;
} drmI830IrqEmit;
@ -188,7 +188,7 @@ typedef struct {
} drmI830GetParam;
#define I830_PARAM_IRQ_ACTIVE 1
#define I830_PARAM_ALLOW_BATCHBUFFER 2
#define I830_PARAM_ALLOW_BATCHBUFFER 2
typedef struct {
int param;

View File

@ -40,7 +40,7 @@ typedef struct _I830DRIRec {
int bitsPerPixel;
int unused11[8]; /* was front/back/depth/rotated offset/pitch */
int unused12; /* logTextureGranularity */
int unused13; /* textureOffset */

View File

@ -1,331 +0,0 @@
#ifndef _INTEL_H_
#define _INTEL_H_
#include "xf86drm.h" /* drm_handle_t, etc */
/* Intel */
#ifndef PCI_CHIP_I810
#define PCI_CHIP_I810 0x7121
#define PCI_CHIP_I810_DC100 0x7123
#define PCI_CHIP_I810_E 0x7125
#define PCI_CHIP_I815 0x1132
#define PCI_CHIP_I810_BRIDGE 0x7120
#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
#define PCI_CHIP_I810_E_BRIDGE 0x7124
#define PCI_CHIP_I815_BRIDGE 0x1130
#endif
#define PCI_CHIP_845_G 0x2562
#define PCI_CHIP_I830_M 0x3577
#ifndef PCI_CHIP_I855_GM
#define PCI_CHIP_I855_GM 0x3582
#define PCI_CHIP_I855_GM_BRIDGE 0x3580
#endif
#ifndef PCI_CHIP_I865_G
#define PCI_CHIP_I865_G 0x2572
#define PCI_CHIP_I865_G_BRIDGE 0x2570
#endif
#ifndef PCI_CHIP_I915_G
#define PCI_CHIP_I915_G 0x2582
#define PCI_CHIP_I915_G_BRIDGE 0x2580
#endif
#ifndef PCI_CHIP_I915_GM
#define PCI_CHIP_I915_GM 0x2592
#define PCI_CHIP_I915_GM_BRIDGE 0x2590
#endif
#ifndef PCI_CHIP_E7221_G
#define PCI_CHIP_E7221_G 0x258A
/* Same as I915_G_BRIDGE */
#define PCI_CHIP_E7221_G_BRIDGE 0x2580
#endif
#ifndef PCI_CHIP_I945_G
#define PCI_CHIP_I945_G 0x2772
#define PCI_CHIP_I945_G_BRIDGE 0x2770
#endif
#ifndef PCI_CHIP_I945_GM
#define PCI_CHIP_I945_GM 0x27A2
#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
#endif
#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 || \
pI810->Chipset == PCI_CHIP_I810_DC100 || \
pI810->Chipset == PCI_CHIP_I810_E)
#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
#define IS_I85X(pI810) (pI810->Chipset == PCI_CHIP_I855_GM)
#define IS_I852(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
#define IS_I855(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
#define I830_GMCH_CTRL 0x52
#define I830_GMCH_MEM_MASK 0x1
#define I830_GMCH_MEM_64M 0x1
#define I830_GMCH_MEM_128M 0
#define I830_GMCH_GMS_MASK 0x70
#define I830_GMCH_GMS_DISABLED 0x00
#define I830_GMCH_GMS_LOCAL 0x10
#define I830_GMCH_GMS_STOLEN_512 0x20
#define I830_GMCH_GMS_STOLEN_1024 0x30
#define I830_GMCH_GMS_STOLEN_8192 0x40
#define I855_GMCH_GMS_MASK (0x7 << 4)
#define I855_GMCH_GMS_DISABLED 0x00
#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4)
#define I855_GMCH_GMS_STOLEN_4M (0x2 << 4)
#define I855_GMCH_GMS_STOLEN_8M (0x3 << 4)
#define I855_GMCH_GMS_STOLEN_16M (0x4 << 4)
#define I855_GMCH_GMS_STOLEN_32M (0x5 << 4)
#define I915G_GMCH_GMS_STOLEN_48M (0x6 << 4)
#define I915G_GMCH_GMS_STOLEN_64M (0x7 << 4)
typedef unsigned char Bool;
#define TRUE 1
#define FALSE 0
#define PIPE_NONE 0<<0
#define PIPE_CRT 1<<0
#define PIPE_TV 1<<1
#define PIPE_DFP 1<<2
#define PIPE_LFP 1<<3
#define PIPE_CRT2 1<<4
#define PIPE_TV2 1<<5
#define PIPE_DFP2 1<<6
#define PIPE_LFP2 1<<7
typedef struct _I830MemPool *I830MemPoolPtr;
typedef struct _I830MemRange *I830MemRangePtr;
typedef struct _I830MemRange {
long Start;
long End;
long Size;
unsigned long Physical;
unsigned long Offset; /* Offset of AGP-allocated portion */
unsigned long Alignment;
drm_handle_t Key;
unsigned long Pitch; // add pitch
I830MemPoolPtr Pool;
} I830MemRange;
typedef struct _I830MemPool {
I830MemRange Total;
I830MemRange Free;
I830MemRange Fixed;
I830MemRange Allocated;
} I830MemPool;
typedef struct {
int tail_mask;
I830MemRange mem;
unsigned char *virtual_start;
int head;
int tail;
int space;
} I830RingBuffer;
typedef struct _I830Rec {
unsigned char *MMIOBase;
unsigned char *FbBase;
int cpp;
uint32_t aper_size;
unsigned int bios_version;
/* These are set in PreInit and never changed. */
long FbMapSize;
long TotalVideoRam;
I830MemRange StolenMemory; /* pre-allocated memory */
long BIOSMemorySize; /* min stolen pool size */
int BIOSMemSizeLoc;
/* These change according to what has been allocated. */
long FreeMemory;
I830MemRange MemoryAperture;
I830MemPool StolenPool;
long allocatedMemory;
/* Regions allocated either from the above pools, or from agpgart. */
/* for single and dual head configurations */
I830MemRange FrontBuffer;
I830MemRange FrontBuffer2;
I830MemRange Scratch;
I830MemRange Scratch2;
I830RingBuffer *LpRing;
I830MemRange BackBuffer;
I830MemRange DepthBuffer;
I830MemRange TexMem;
int TexGranularity;
I830MemRange ContextMem;
int drmMinor;
Bool have3DWindows;
Bool NeedRingBufferLow;
Bool allowPageFlip;
Bool disableTiling;
int Chipset;
unsigned long LinearAddr;
unsigned long MMIOAddr;
drmSize registerSize; /**< \brief MMIO register map size */
drm_handle_t registerHandle; /**< \brief MMIO register map handle */
// IOADDRESS ioBase;
int irq; /**< \brief IRQ number */
int GttBound;
drm_handle_t ring_map;
unsigned int Fence[8];
} I830Rec;
/*
* 12288 is set as the maximum, chosen because it is enough for
* 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
*/
#define I830_MAXIMUM_VBIOS_MEM 12288
#define I830_DEFAULT_VIDEOMEM_2D (MB(32) / 1024)
#define I830_DEFAULT_VIDEOMEM_3D (MB(64) / 1024)
/* Flags for memory allocation function */
#define FROM_ANYWHERE 0x00000000
#define FROM_POOL_ONLY 0x00000001
#define FROM_NEW_ONLY 0x00000002
#define FROM_MASK 0x0000000f
#define ALLOCATE_AT_TOP 0x00000010
#define ALLOCATE_AT_BOTTOM 0x00000020
#define FORCE_GAPS 0x00000040
#define NEED_PHYSICAL_ADDR 0x00000100
#define ALIGN_BOTH_ENDS 0x00000200
#define FORCE_LOW 0x00000400
#define ALLOC_NO_TILING 0x00001000
#define ALLOC_INITIAL 0x00002000
#define ALLOCATE_DRY_RUN 0x80000000
/* Chipset registers for VIDEO BIOS memory RW access */
#define _855_DRAM_RW_CONTROL 0x58
#define _845_DRAM_RW_CONTROL 0x90
#define DRAM_WRITE 0x33330000
#define KB(x) ((x) * 1024)
#define MB(x) ((x) * KB(1024))
#define GTT_PAGE_SIZE KB(4)
#define ROUND_TO(x, y) (((x) + (y) - 1) / (y) * (y))
#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
#define ROUND_TO_PAGE(x) ROUND_TO((x), GTT_PAGE_SIZE)
#define ROUND_TO_MB(x) ROUND_TO((x), MB(1))
#define PRIMARY_RINGBUFFER_SIZE KB(128)
/* Ring buffer registers, p277, overview p19
*/
#define LP_RING 0x2030
#define HP_RING 0x2040
#define RING_TAIL 0x00
#define TAIL_ADDR 0x000FFFF8
#define I830_TAIL_MASK 0x001FFFF8
#define RING_HEAD 0x04
#define HEAD_WRAP_COUNT 0xFFE00000
#define HEAD_WRAP_ONE 0x00200000
#define HEAD_ADDR 0x001FFFFC
#define I830_HEAD_MASK 0x001FFFFC
#define RING_START 0x08
#define START_ADDR 0x03FFFFF8
#define I830_RING_START_MASK 0xFFFFF000
#define RING_LEN 0x0C
#define RING_NR_PAGES 0x001FF000
#define I830_RING_NR_PAGES 0x001FF000
#define RING_REPORT_MASK 0x00000006
#define RING_REPORT_64K 0x00000002
#define RING_REPORT_128K 0x00000004
#define RING_NO_REPORT 0x00000000
#define RING_VALID_MASK 0x00000001
#define RING_VALID 0x00000001
#define RING_INVALID 0x00000000
/* Fence/Tiling ranges [0..7]
*/
#define FENCE 0x2000
#define FENCE_NR 8
#define I915G_FENCE_START_MASK 0x0ff00000
#define I830_FENCE_START_MASK 0x07f80000
#define FENCE_START_MASK 0x03F80000
#define FENCE_X_MAJOR 0x00000000
#define FENCE_Y_MAJOR 0x00001000
#define FENCE_SIZE_MASK 0x00000700
#define FENCE_SIZE_512K 0x00000000
#define FENCE_SIZE_1M 0x00000100
#define FENCE_SIZE_2M 0x00000200
#define FENCE_SIZE_4M 0x00000300
#define FENCE_SIZE_8M 0x00000400
#define FENCE_SIZE_16M 0x00000500
#define FENCE_SIZE_32M 0x00000600
#define FENCE_SIZE_64M 0x00000700
#define I915G_FENCE_SIZE_1M 0x00000000
#define I915G_FENCE_SIZE_2M 0x00000100
#define I915G_FENCE_SIZE_4M 0x00000200
#define I915G_FENCE_SIZE_8M 0x00000300
#define I915G_FENCE_SIZE_16M 0x00000400
#define I915G_FENCE_SIZE_32M 0x00000500
#define I915G_FENCE_SIZE_64M 0x00000600
#define I915G_FENCE_SIZE_128M 0x00000700
#define FENCE_PITCH_1 0x00000000
#define FENCE_PITCH_2 0x00000010
#define FENCE_PITCH_4 0x00000020
#define FENCE_PITCH_8 0x00000030
#define FENCE_PITCH_16 0x00000040
#define FENCE_PITCH_32 0x00000050
#define FENCE_PITCH_64 0x00000060
#define FENCE_VALID 0x00000001
#include <mmio.h>
# define MMIO_IN8(base, offset) \
*(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
# define MMIO_IN32(base, offset) \
read_MMIO_LE32(base, offset)
# define MMIO_OUT8(base, offset, val) \
*(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
# define MMIO_OUT32(base, offset, val) \
*(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = CPU_TO_LE32(val)
/* Memory mapped register access macros */
#define INREG8(addr) MMIO_IN8(MMIO, addr)
#define INREG(addr) MMIO_IN32(MMIO, addr)
#define OUTREG8(addr, val) MMIO_OUT8(MMIO, addr, val)
#define OUTREG(addr, val) MMIO_OUT32(MMIO, addr, val)
#define DSPABASE 0x70184
#endif

File diff suppressed because it is too large Load Diff