summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/nouveau/Makefile1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_render.h13
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_render_t.c60
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_scratch.c98
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_scratch.h51
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c10
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c6
9 files changed, 165 insertions, 78 deletions
diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile
index 7be19b26fd..57e46974c2 100644
--- a/src/mesa/drivers/dri/nouveau/Makefile
+++ b/src/mesa/drivers/dri/nouveau/Makefile
@@ -19,6 +19,7 @@ DRIVER_SOURCES = \
nouveau_bo_state.c \
nouveau_texture.c \
nouveau_surface.c \
+ nouveau_scratch.c \
nv04_context.c \
nv04_render.c \
nv04_state_fb.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index c6cf78150c..f681f06805 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -119,6 +119,7 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen,
nouveau_state_init(ctx);
nouveau_bo_state_init(ctx);
+ nouveau_scratch_init(ctx);
_mesa_meta_init(ctx);
_swrast_CreateContext(ctx);
_vbo_CreateContext(ctx);
@@ -163,6 +164,7 @@ nouveau_context_deinit(struct gl_context *ctx)
if (nctx->hw.chan)
nouveau_channel_free(&nctx->hw.chan);
+ nouveau_scratch_destroy(ctx);
nouveau_bo_state_destroy(ctx);
_mesa_free_context_data(ctx);
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index 23a8725672..7ebc676379 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -30,6 +30,7 @@
#include "nouveau_screen.h"
#include "nouveau_state.h"
#include "nouveau_bo_state.h"
+#include "nouveau_scratch.h"
#include "nouveau_render.h"
#include "main/bitset.h"
@@ -67,6 +68,7 @@ struct nouveau_context {
struct nouveau_hw_state hw;
struct nouveau_bo_state bo;
struct nouveau_render_state render;
+ struct nouveau_scratch_state scratch;
struct {
GLboolean clear_blocked;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render.h b/src/mesa/drivers/dri/nouveau/nouveau_render.h
index 81c6119fcc..a9e8e90faf 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_render.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_render.h
@@ -55,19 +55,9 @@ struct nouveau_array_state {
extract_f_t extract_f;
};
-#define RENDER_SCRATCH_COUNT 2
-#define RENDER_SCRATCH_SIZE 2*1024*1024
-
-struct nouveau_scratch_state {
- struct nouveau_bo *bo[RENDER_SCRATCH_COUNT];
-
- int index;
- int offset;
- void *buf;
-};
-
struct nouveau_swtnl_state {
struct nouveau_bo *vbo;
+ unsigned offset;
void *buf;
unsigned vertex_count;
GLenum primitive;
@@ -89,7 +79,6 @@ struct nouveau_render_state {
int attr_count;
int vertex_size;
- struct nouveau_scratch_state scratch;
struct nouveau_swtnl_state swtnl;
};
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
index 26126ce553..ce5cd82ed7 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
@@ -200,56 +200,6 @@ get_array_extract(struct nouveau_array_state *a,
}
/*
- * Returns a pointer to a chunk of <size> bytes long GART memory. <bo>
- * will be updated with the buffer object the memory is located in.
- *
- * If <offset> is provided, it will be updated with the offset within
- * <bo> of the allocated memory. Otherwise the returned memory will
- * always be located right at the beginning of <bo>.
- */
-static inline void *
-get_scratch_vbo(struct gl_context *ctx, unsigned size, struct nouveau_bo **bo,
- unsigned *offset)
-{
- struct nouveau_scratch_state *scratch = &to_render_state(ctx)->scratch;
- void *buf;
-
- if (scratch->buf && offset &&
- size <= RENDER_SCRATCH_SIZE - scratch->offset) {
- nouveau_bo_ref(scratch->bo[scratch->index], bo);
-
- buf = scratch->buf + scratch->offset;
- *offset = scratch->offset;
- scratch->offset += size;
-
- } else if (size <= RENDER_SCRATCH_SIZE) {
- scratch->index = (scratch->index + 1) % RENDER_SCRATCH_COUNT;
- nouveau_bo_ref(scratch->bo[scratch->index], bo);
-
- nouveau_bo_map(*bo, NOUVEAU_BO_WR);
- buf = scratch->buf = (*bo)->map;
- nouveau_bo_unmap(*bo);
-
- if (offset)
- *offset = 0;
- scratch->offset = size;
-
- } else {
- nouveau_bo_new(context_dev(ctx),
- NOUVEAU_BO_MAP | NOUVEAU_BO_GART, 0, size, bo);
-
- nouveau_bo_map(*bo, NOUVEAU_BO_WR);
- buf = (*bo)->map;
- nouveau_bo_unmap(*bo);
-
- if (offset)
- *offset = 0;
- }
-
- return buf;
-}
-
-/*
* Returns how many vertices you can draw using <n> pushbuf dwords.
*/
static inline unsigned
@@ -337,15 +287,7 @@ void
TAG(render_init)(struct gl_context *ctx)
{
struct nouveau_render_state *render = to_render_state(ctx);
- struct nouveau_scratch_state *scratch = &render->scratch;
- int ret, i;
-
- for (i = 0; i < RENDER_SCRATCH_COUNT; i++) {
- ret = nouveau_bo_new(context_dev(ctx),
- NOUVEAU_BO_MAP | NOUVEAU_BO_GART,
- 0, RENDER_SCRATCH_SIZE, &scratch->bo[i]);
- assert(!ret);
- }
+ int i;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
render->map[i] = -1;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_scratch.c b/src/mesa/drivers/dri/nouveau/nouveau_scratch.c
new file mode 100644
index 0000000000..ddda67b2f1
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nouveau_scratch.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2009-2010 Francisco Jerez.
+ * 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 (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 NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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 "nouveau_driver.h"
+#include "nouveau_context.h"
+
+/*
+ * Returns a pointer to a chunk of 'size' bytes long GART memory. 'bo'
+ * and 'offset' will point to the returned memory.
+ */
+void *
+nouveau_get_scratch(struct gl_context *ctx, unsigned size,
+ struct nouveau_bo **bo, unsigned *offset)
+{
+ struct nouveau_scratch_state *scratch =
+ &to_nouveau_context(ctx)->scratch;
+ void *buf;
+
+ if (scratch->buf && size <= NOUVEAU_SCRATCH_SIZE - scratch->offset) {
+ nouveau_bo_ref(scratch->bo[scratch->index], bo);
+
+ buf = scratch->buf + scratch->offset;
+ *offset = scratch->offset;
+ scratch->offset += size;
+
+ } else if (size <= NOUVEAU_SCRATCH_SIZE) {
+ scratch->index = (scratch->index + 1) % NOUVEAU_SCRATCH_COUNT;
+ nouveau_bo_ref(scratch->bo[scratch->index], bo);
+
+ nouveau_bo_map(*bo, NOUVEAU_BO_WR);
+ buf = scratch->buf = (*bo)->map;
+ nouveau_bo_unmap(*bo);
+
+ *offset = 0;
+ scratch->offset = size;
+
+ } else {
+ nouveau_bo_new(context_dev(ctx),
+ NOUVEAU_BO_MAP | NOUVEAU_BO_GART, 0, size, bo);
+
+ nouveau_bo_map(*bo, NOUVEAU_BO_WR);
+ buf = (*bo)->map;
+ nouveau_bo_unmap(*bo);
+
+ *offset = 0;
+ }
+
+ return buf;
+}
+
+void
+nouveau_scratch_init(struct gl_context *ctx)
+{
+ struct nouveau_scratch_state *scratch =
+ &to_nouveau_context(ctx)->scratch;
+ int ret, i;
+
+ for (i = 0; i < NOUVEAU_SCRATCH_COUNT; i++) {
+ ret = nouveau_bo_new(context_dev(ctx),
+ NOUVEAU_BO_MAP | NOUVEAU_BO_GART,
+ 0, NOUVEAU_SCRATCH_SIZE, &scratch->bo[i]);
+ assert(!ret);
+ }
+}
+
+void
+nouveau_scratch_destroy(struct gl_context *ctx)
+{
+ struct nouveau_scratch_state *scratch =
+ &to_nouveau_context(ctx)->scratch;
+ int i;
+
+ for (i = 0; i < NOUVEAU_SCRATCH_COUNT; i++)
+ nouveau_bo_ref(NULL, &scratch->bo[i]);
+}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_scratch.h b/src/mesa/drivers/dri/nouveau/nouveau_scratch.h
new file mode 100644
index 0000000000..b60b33dd1a
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nouveau_scratch.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009-2010 Francisco Jerez.
+ * 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 (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 NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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.
+ *
+ */
+
+#ifndef __NOUVEAU_SCRATCH_H__
+#define __NOUVEAU_SCRATCH_H__
+
+#define NOUVEAU_SCRATCH_COUNT 2
+#define NOUVEAU_SCRATCH_SIZE 3*1024*1024
+
+struct nouveau_scratch_state {
+ struct nouveau_bo *bo[NOUVEAU_SCRATCH_COUNT];
+
+ int index;
+ int offset;
+ void *buf;
+};
+
+void *
+nouveau_get_scratch(struct gl_context *ctx, unsigned size,
+ struct nouveau_bo **bo, unsigned *offset);
+
+void
+nouveau_scratch_init(struct gl_context *ctx);
+
+void
+nouveau_scratch_destroy(struct gl_context *ctx);
+
+#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c
index b3588e8fd3..db69e562e7 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c
@@ -28,6 +28,8 @@
#include "tnl/t_pipeline.h"
#include "tnl/t_vertex.h"
+#define SWTNL_VBO_SIZE 65536
+
static enum tnl_attr_format
swtnl_get_format(int type, int fields) {
switch (type) {
@@ -158,8 +160,8 @@ swtnl_alloc_vertices(struct gl_context *ctx)
struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl;
nouveau_bo_ref(NULL, &swtnl->vbo);
- swtnl->buf = get_scratch_vbo(ctx, RENDER_SCRATCH_SIZE,
- &swtnl->vbo, NULL);
+ swtnl->buf = nouveau_get_scratch(ctx, SWTNL_VBO_SIZE, &swtnl->vbo,
+ &swtnl->offset);
swtnl->vertex_count = 0;
}
@@ -260,7 +262,7 @@ swtnl_reset_stipple(struct gl_context *ctx)
struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl; \
int vertex_len = TNL_CONTEXT(ctx)->clipspace.vertex_size; \
\
- if (swtnl->vertex_count + (n) > swtnl->vbo->size/vertex_len \
+ if (swtnl->vertex_count + (n) > SWTNL_VBO_SIZE/vertex_len \
|| (swtnl->vertex_count && swtnl->primitive != p)) \
swtnl_flush_vertices(ctx); \
\
@@ -280,7 +282,7 @@ swtnl_points(struct gl_context *ctx, GLuint first, GLuint last)
while (first < last) {
BEGIN_PRIMITIVE(GL_POINTS, last - first);
- count = MIN2(swtnl->vbo->size / vertex_len, last - first);
+ count = MIN2(SWTNL_VBO_SIZE / vertex_len, last - first);
for (i = 0; i < count; i++)
OUT_VERTEX(first + i);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 394f3c9b50..4565fcc353 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -295,7 +295,7 @@ vbo_maybe_split(struct gl_context *ctx, const struct gl_client_array **arrays,
if (render->mode == VBO &&
(stride = get_max_client_stride(ctx, arrays)))
vert_avail = MIN2(vert_avail,
- RENDER_SCRATCH_SIZE / stride);
+ NOUVEAU_SCRATCH_SIZE / stride);
if (max_index - min_index > vert_avail ||
(ib && ib->count > idx_avail)) {
@@ -337,8 +337,8 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_client_array **arrays,
} else {
int j, n = max_index - min_index + 1;
char *sp = (char *)array->Ptr + delta;
- char *dp = get_scratch_vbo(ctx, n * a->stride,
- &a->bo, &a->offset);
+ char *dp = nouveau_get_scratch(
+ ctx, n * a->stride, &a->bo, &a->offset);
/* Array in client memory, move it to
* a scratch buffer obj. */