summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-08-13 20:02:04 +1000
committerBen Skeggs <skeggsb@gmail.com>2007-08-15 14:31:25 +1000
commitb7c93de6d798d7ccfc7bfa12b9c8f474de955d55 (patch)
tree4a3e5c068dd79316789cfe4782b49de9a3dac8e0
parent40e8ce700b0e1711e08e9f33c297d495c43598b1 (diff)
nouveau: Split nouveau_buffers into nouveau_mem and nouveau_fbo
-rw-r--r--src/mesa/drivers/dri/nouveau/Makefile3
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c4
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h4
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.c (renamed from src/mesa/drivers/dri/nouveau/nouveau_buffers.c)142
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.h (renamed from src/mesa/drivers/dri/nouveau/nouveau_buffers.h)19
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_mem.c144
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_mem.h23
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_span.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.c6
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.h2
11 files changed, 182 insertions, 169 deletions
diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile
index 20d2de5eef..6ea4594f1e 100644
--- a/src/mesa/drivers/dri/nouveau/Makefile
+++ b/src/mesa/drivers/dri/nouveau/Makefile
@@ -9,12 +9,13 @@ MINIGLX_SOURCES =
DRIVER_SOURCES = \
nouveau_bufferobj.c \
- nouveau_buffers.c \
nouveau_card.c \
nouveau_context.c \
nouveau_driver.c \
+ nouveau_fbo.c \
nouveau_fifo.c \
nouveau_lock.c \
+ nouveau_mem.c \
nouveau_object.c \
nouveau_screen.c \
nouveau_span.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
index fc14060c04..be6455a01e 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
@@ -2,11 +2,11 @@
#include "enums.h"
#include "nouveau_bufferobj.h"
-#include "nouveau_buffers.h"
#include "nouveau_context.h"
#include "nouveau_drm.h"
-#include "nouveau_object.h"
+#include "nouveau_mem.h"
#include "nouveau_msg.h"
+#include "nouveau_object.h"
#define NOUVEAU_MEM_FREE(mem) do { \
nouveau_mem_free(ctx, (mem)); \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h
index 3439a35e7c..cbc89a151d 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h
@@ -2,7 +2,7 @@
#define __NOUVEAU_BUFFEROBJ_H__
#include "mtypes.h"
-#include "nouveau_buffers.h"
+#include "nouveau_mem.h"
#define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE)
#define NOUVEAU_BO_GART_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE)
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index fdbde51a72..03f778a13c 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -36,10 +36,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "mtypes.h"
#include "tnl/t_vertex.h"
+#include "nouveau_fbo.h"
#include "nouveau_screen.h"
-#include "nouveau_state_cache.h"
-#include "nouveau_buffers.h"
#include "nouveau_shader.h"
+#include "nouveau_state_cache.h"
#include "nouveau_sync.h"
#include "xmlconfig.h"
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index 7cf739fe47..54c0c26d08 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -4,147 +4,11 @@
#include "fbobject.h"
#include "nouveau_context.h"
-#include "nouveau_buffers.h"
-#include "nouveau_object.h"
+#include "nouveau_fbo.h"
#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
#include "nouveau_msg.h"
-
-#define MAX_MEMFMT_LENGTH 32768
-
-/* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */
-GLboolean
-nouveau_memformat_flat_emit(GLcontext * ctx,
- nouveau_mem * dst, nouveau_mem * src,
- GLuint dst_offset, GLuint src_offset,
- GLuint size)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- uint32_t src_handle, dst_handle;
- GLuint count;
-
- if (src_offset + size > src->size) {
- MESSAGE("src out of nouveau_mem bounds\n");
- return GL_FALSE;
- }
- if (dst_offset + size > dst->size) {
- MESSAGE("dst out of nouveau_mem bounds\n");
- return GL_FALSE;
- }
-
- src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
- dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
- src_offset += nouveau_mem_gpu_offset_get(ctx, src);
- dst_offset += nouveau_mem_gpu_offset_get(ctx, dst);
-
- BEGIN_RING_SIZE(NvSubMemFormat,
- NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2);
- OUT_RING(src_handle);
- OUT_RING(dst_handle);
-
- count = (size / MAX_MEMFMT_LENGTH) +
- ((size % MAX_MEMFMT_LENGTH) ? 1 : 0);
-
- while (count--) {
- GLuint length =
- (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size;
-
- BEGIN_RING_SIZE(NvSubMemFormat,
- NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
- OUT_RING(src_offset);
- OUT_RING(dst_offset);
- OUT_RING(0); /* pitch in */
- OUT_RING(0); /* pitch out */
- OUT_RING(length); /* line length */
- OUT_RING(1); /* number of lines */
- OUT_RING((1 << 8) /* dst_inc */ |(1 << 0) /* src_inc */ );
- OUT_RING(0); /* buffer notify? */
- FIRE_RING();
-
- src_offset += length;
- dst_offset += length;
- size -= length;
- }
-
- return GL_TRUE;
-}
-
-void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- struct drm_nouveau_mem_free memf;
-
- if (NOUVEAU_DEBUG & DEBUG_MEM) {
- fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n",
- __func__, mem->type, (GLuint) mem->offset,
- (GLuint) mem->size);
- }
-
- if (mem->map)
- drmUnmap(mem->map, mem->size);
- memf.flags = mem->type;
- memf.offset = mem->offset;
- drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf,
- sizeof(memf));
- FREE(mem);
-}
-
-nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, uint32_t flags, GLuint size,
- GLuint align)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- struct drm_nouveau_mem_alloc mema;
- nouveau_mem *mem;
- int ret;
-
- if (NOUVEAU_DEBUG & DEBUG_MEM) {
- fprintf(stderr,
- "%s: requested: flags=0x%x, size=0x%x, align=0x%x\n",
- __func__, flags, (GLuint) size, align);
- }
-
- mem = CALLOC(sizeof(nouveau_mem));
- if (!mem)
- return NULL;
-
- mema.flags = flags;
- mema.size = mem->size = size;
- mema.alignment = align;
- mem->map = NULL;
- ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC,
- &mema, sizeof(mema));
- if (ret) {
- FREE(mem);
- return NULL;
- }
- mem->offset = mema.offset;
- mem->type = mema.flags;
-
- if (NOUVEAU_DEBUG & DEBUG_MEM) {
- fprintf(stderr,
- "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n",
- __func__, mem->type, (GLuint) mem->offset,
- (GLuint) mem->size);
- }
-
- if (flags & NOUVEAU_MEM_MAPPED)
- ret = drmMap(nmesa->driFd, mema.map_handle, mem->size,
- &mem->map);
- if (ret) {
- mem->map = NULL;
- nouveau_mem_free(ctx, mem);
- mem = NULL;
- }
-
- return mem;
-}
-
-uint32_t nouveau_mem_gpu_offset_get(GLcontext * ctx, nouveau_mem * mem)
-{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
- return mem->offset;
-}
+#include "nouveau_object.h"
+#include "nouveau_reg.h"
static GLboolean
nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb,
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h
index f0987d2aa7..757a784f8f 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h
@@ -6,24 +6,7 @@
#include "utils.h"
#include "renderbuffer.h"
-typedef struct nouveau_mem_t {
- int type;
- uint64_t offset;
- uint64_t size;
- void *map;
-} nouveau_mem;
-
-extern nouveau_mem *nouveau_mem_alloc(GLcontext *, uint32_t flags,
- GLuint size, GLuint align);
-extern void nouveau_mem_free(GLcontext *, nouveau_mem *);
-extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *, nouveau_mem *);
-
-extern GLboolean nouveau_memformat_flat_emit(GLcontext *,
- nouveau_mem *dst,
- nouveau_mem *src,
- GLuint dst_offset,
- GLuint src_offset,
- GLuint size);
+#include "nouveau_mem.h"
typedef struct nouveau_renderbuffer_t {
struct gl_renderbuffer mesa; /* must be first! */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_mem.c b/src/mesa/drivers/dri/nouveau/nouveau_mem.c
new file mode 100644
index 0000000000..35c53268b0
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nouveau_mem.c
@@ -0,0 +1,144 @@
+#include "mtypes.h"
+
+#include "nouveau_context.h"
+#include "nouveau_fifo.h"
+#include "nouveau_mem.h"
+#include "nouveau_msg.h"
+#include "nouveau_object.h"
+#include "nouveau_reg.h"
+
+#define MAX_MEMFMT_LENGTH 32768
+
+/* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */
+GLboolean
+nouveau_memformat_flat_emit(GLcontext * ctx,
+ nouveau_mem * dst, nouveau_mem * src,
+ GLuint dst_offset, GLuint src_offset,
+ GLuint size)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ uint32_t src_handle, dst_handle;
+ GLuint count;
+
+ if (src_offset + size > src->size) {
+ MESSAGE("src out of nouveau_mem bounds\n");
+ return GL_FALSE;
+ }
+ if (dst_offset + size > dst->size) {
+ MESSAGE("dst out of nouveau_mem bounds\n");
+ return GL_FALSE;
+ }
+
+ src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
+ dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
+ src_offset += nouveau_mem_gpu_offset_get(ctx, src);
+ dst_offset += nouveau_mem_gpu_offset_get(ctx, dst);
+
+ BEGIN_RING_SIZE(NvSubMemFormat,
+ NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2);
+ OUT_RING(src_handle);
+ OUT_RING(dst_handle);
+
+ count = (size / MAX_MEMFMT_LENGTH) +
+ ((size % MAX_MEMFMT_LENGTH) ? 1 : 0);
+
+ while (count--) {
+ GLuint length =
+ (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size;
+
+ BEGIN_RING_SIZE(NvSubMemFormat,
+ NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
+ OUT_RING(src_offset);
+ OUT_RING(dst_offset);
+ OUT_RING(0); /* pitch in */
+ OUT_RING(0); /* pitch out */
+ OUT_RING(length); /* line length */
+ OUT_RING(1); /* number of lines */
+ OUT_RING((1 << 8) /* dst_inc */ |(1 << 0) /* src_inc */ );
+ OUT_RING(0); /* buffer notify? */
+ FIRE_RING();
+
+ src_offset += length;
+ dst_offset += length;
+ size -= length;
+ }
+
+ return GL_TRUE;
+}
+
+void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ struct drm_nouveau_mem_free memf;
+
+ if (NOUVEAU_DEBUG & DEBUG_MEM) {
+ fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n",
+ __func__, mem->type, (GLuint) mem->offset,
+ (GLuint) mem->size);
+ }
+
+ if (mem->map)
+ drmUnmap(mem->map, mem->size);
+ memf.flags = mem->type;
+ memf.offset = mem->offset;
+ drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf,
+ sizeof(memf));
+ FREE(mem);
+}
+
+nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, uint32_t flags, GLuint size,
+ GLuint align)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ struct drm_nouveau_mem_alloc mema;
+ nouveau_mem *mem;
+ int ret;
+
+ if (NOUVEAU_DEBUG & DEBUG_MEM) {
+ fprintf(stderr,
+ "%s: requested: flags=0x%x, size=0x%x, align=0x%x\n",
+ __func__, flags, (GLuint) size, align);
+ }
+
+ mem = CALLOC(sizeof(nouveau_mem));
+ if (!mem)
+ return NULL;
+
+ mema.flags = flags;
+ mema.size = mem->size = size;
+ mema.alignment = align;
+ mem->map = NULL;
+ ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC,
+ &mema, sizeof(mema));
+ if (ret) {
+ FREE(mem);
+ return NULL;
+ }
+ mem->offset = mema.offset;
+ mem->type = mema.flags;
+
+ if (NOUVEAU_DEBUG & DEBUG_MEM) {
+ fprintf(stderr,
+ "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n",
+ __func__, mem->type, (GLuint) mem->offset,
+ (GLuint) mem->size);
+ }
+
+ if (flags & NOUVEAU_MEM_MAPPED)
+ ret = drmMap(nmesa->driFd, mema.map_handle, mem->size,
+ &mem->map);
+ if (ret) {
+ mem->map = NULL;
+ nouveau_mem_free(ctx, mem);
+ mem = NULL;
+ }
+
+ return mem;
+}
+
+uint32_t nouveau_mem_gpu_offset_get(GLcontext * ctx, nouveau_mem * mem)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+ return mem->offset;
+}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_mem.h b/src/mesa/drivers/dri/nouveau/nouveau_mem.h
new file mode 100644
index 0000000000..6db73f4708
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nouveau_mem.h
@@ -0,0 +1,23 @@
+#ifndef __NOUVEAU_MEM_H__
+#define __NOUVEAU_MEM_H__
+
+typedef struct nouveau_mem_t {
+ int type;
+ uint64_t offset;
+ uint64_t size;
+ void *map;
+} nouveau_mem;
+
+extern nouveau_mem *nouveau_mem_alloc(GLcontext *, uint32_t flags,
+ GLuint size, GLuint align);
+extern void nouveau_mem_free(GLcontext *, nouveau_mem *);
+extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *, nouveau_mem *);
+
+extern GLboolean nouveau_memformat_flat_emit(GLcontext *,
+ nouveau_mem *dst,
+ nouveau_mem *src,
+ GLuint dst_offset,
+ GLuint src_offset,
+ GLuint size);
+
+#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.h b/src/mesa/drivers/dri/nouveau/nouveau_span.h
index bc39ecd17b..c4142a10ef 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_span.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_span.h
@@ -30,7 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define __NOUVEAU_SPAN_H__
#include "drirenderbuffer.h"
-#include "nouveau_buffers.h"
+#include "nouveau_fbo.h"
extern void nouveauSpanInitFunctions( GLcontext *ctx );
extern void nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
index 3f5f6d54e9..abb3088032 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
@@ -28,11 +28,11 @@
#include "vblank.h" /* for DO_USLEEP */
#include "nouveau_context.h"
-#include "nouveau_buffers.h"
-#include "nouveau_object.h"
#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
+#include "nouveau_mem.h"
#include "nouveau_msg.h"
+#include "nouveau_object.h"
+#include "nouveau_reg.h"
#include "nouveau_sync.h"
#define NOTIFIER(__v) \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h
index 1ff4eca325..fc37efbe6b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h
@@ -28,8 +28,6 @@
#ifndef __NOUVEAU_SYNC_H__
#define __NOUVEAU_SYNC_H__
-#include "nouveau_buffers.h"
-
#define NV_NOTIFIER_SIZE 32
#define NV_NOTIFY_TIME_0 0x00000000
#define NV_NOTIFY_TIME_1 0x00000004