nouveau_bo_state.c \
nouveau_texture.c \
nouveau_surface.c \
+ nouveau_scratch.c \
nv04_context.c \
nv04_render.c \
nv04_state_fb.c \
nouveau_state_init(ctx);
nouveau_bo_state_init(ctx);
+ nouveau_scratch_init(ctx);
_mesa_meta_init(ctx);
_swrast_CreateContext(ctx);
_vbo_CreateContext(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);
}
#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"
struct nouveau_hw_state hw;
struct nouveau_bo_state bo;
struct nouveau_render_state render;
+ struct nouveau_scratch_state scratch;
struct {
GLboolean clear_blocked;
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;
int attr_count;
int vertex_size;
- struct nouveau_scratch_state scratch;
struct nouveau_swtnl_state swtnl;
};
}
}
-/*
- * 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.
*/
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;
--- /dev/null
+/*
+ * 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]);
+}
--- /dev/null
+/*
+ * 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
#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) {
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;
}
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); \
\
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);
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)) {
} 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. */