summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv04
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2010-02-04 22:15:22 +0100
committerFrancisco Jerez <[email protected]>2010-02-04 22:15:22 +0100
commit5b6b67eb3ff714fbba8aed88a22a7646e1dbf655 (patch)
tree08483c937dc072aa4fab543cb16fc91d64ce2562 /src/gallium/drivers/nv04
parentbfb5dc68fcc9f5dee71f66d9499b8bdcde9627ea (diff)
Nuke the nv0x-nv2x gallium pipe drivers.
Diffstat (limited to 'src/gallium/drivers/nv04')
-rw-r--r--src/gallium/drivers/nv04/Makefile21
-rw-r--r--src/gallium/drivers/nv04/nv04_clear.c12
-rw-r--r--src/gallium/drivers/nv04/nv04_context.c112
-rw-r--r--src/gallium/drivers/nv04/nv04_context.h151
-rw-r--r--src/gallium/drivers/nv04/nv04_fragprog.c21
-rw-r--r--src/gallium/drivers/nv04/nv04_fragtex.c73
-rw-r--r--src/gallium/drivers/nv04/nv04_miptree.c146
-rw-r--r--src/gallium/drivers/nv04/nv04_prim_vbuf.c339
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.c222
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.h30
-rw-r--r--src/gallium/drivers/nv04/nv04_state.c459
-rw-r--r--src/gallium/drivers/nv04/nv04_state.h72
-rw-r--r--src/gallium/drivers/nv04/nv04_state_emit.c246
-rw-r--r--src/gallium/drivers/nv04/nv04_surface.c63
-rw-r--r--src/gallium/drivers/nv04/nv04_surface_2d.c547
-rw-r--r--src/gallium/drivers/nv04/nv04_surface_2d.h37
-rw-r--r--src/gallium/drivers/nv04/nv04_transfer.c178
-rw-r--r--src/gallium/drivers/nv04/nv04_vbo.c78
18 files changed, 0 insertions, 2807 deletions
diff --git a/src/gallium/drivers/nv04/Makefile b/src/gallium/drivers/nv04/Makefile
deleted file mode 100644
index 7c14bacb1de..00000000000
--- a/src/gallium/drivers/nv04/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nv04
-
-C_SOURCES = \
- nv04_surface_2d.c \
- nv04_clear.c \
- nv04_context.c \
- nv04_fragprog.c \
- nv04_fragtex.c \
- nv04_miptree.c \
- nv04_prim_vbuf.c \
- nv04_screen.c \
- nv04_state.c \
- nv04_state_emit.c \
- nv04_surface.c \
- nv04_transfer.c \
- nv04_vbo.c
-
-include ../../Makefile.template
diff --git a/src/gallium/drivers/nv04/nv04_clear.c b/src/gallium/drivers/nv04/nv04_clear.c
deleted file mode 100644
index 01cacd36fe1..00000000000
--- a/src/gallium/drivers/nv04/nv04_clear.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "nv04_context.h"
-
-void
-nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
-}
diff --git a/src/gallium/drivers/nv04/nv04_context.c b/src/gallium/drivers/nv04/nv04_context.c
deleted file mode 100644
index e91ffe0f5de..00000000000
--- a/src/gallium/drivers/nv04/nv04_context.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "util/u_simple_screen.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static void
-nv04_flush(struct pipe_context *pipe, unsigned flags,
- struct pipe_fence_handle **fence)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
-
- draw_flush(nv04->draw);
-
- FIRE_RING(chan);
- if (fence)
- *fence = NULL;
-}
-
-static void
-nv04_destroy(struct pipe_context *pipe)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- if (nv04->draw)
- draw_destroy(nv04->draw);
-
- FREE(nv04);
-}
-
-static boolean
-nv04_init_hwctx(struct nv04_context *nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- // requires a valid handle
-// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOTIFY, 1);
-// OUT_RING(0);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOP, 1);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, 0x40182800);
-// OUT_RING(1<<20/*no cull*/);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
-// OUT_RING(0x24|(1<<6)|(1<<8));
- OUT_RING(chan, 0x120001a4);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FORMAT, 1);
- OUT_RING(chan, 0x332213a1);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FILTER, 1);
- OUT_RING(chan, 0x11001010);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_COLORKEY, 1);
- OUT_RING(chan, 0x0);
-// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 1);
-// OUT_RING(SCREEN_OFFSET);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FOGCOLOR, 1);
- OUT_RING(chan, 0xff000000);
-
-
-
- FIRE_RING (chan);
- return TRUE;
-}
-
-struct pipe_context *
-nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
-{
- struct nv04_screen *screen = nv04_screen(pscreen);
- struct pipe_winsys *ws = pscreen->winsys;
- struct nv04_context *nv04;
- struct nouveau_winsys *nvws = screen->nvws;
-
- nv04 = CALLOC(1, sizeof(struct nv04_context));
- if (!nv04)
- return NULL;
- nv04->screen = screen;
- nv04->pctx_id = pctx_id;
-
- nv04->nvws = nvws;
-
- nv04->pipe.winsys = ws;
- nv04->pipe.screen = pscreen;
- nv04->pipe.destroy = nv04_destroy;
- nv04->pipe.draw_arrays = nv04_draw_arrays;
- nv04->pipe.draw_elements = nv04_draw_elements;
- nv04->pipe.clear = nv04_clear;
- nv04->pipe.flush = nv04_flush;
-
- nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
- nv04_init_surface_functions(nv04);
- nv04_init_state_functions(nv04);
-
- nv04->draw = draw_create();
- assert(nv04->draw);
- draw_wide_point_threshold(nv04->draw, 0.0);
- draw_wide_line_threshold(nv04->draw, 0.0);
- draw_enable_line_stipple(nv04->draw, FALSE);
- draw_enable_point_sprites(nv04->draw, FALSE);
- draw_set_rasterize_stage(nv04->draw, nv04_draw_vbuf_stage(nv04));
-
- nv04_init_hwctx(nv04);
-
- return &nv04->pipe;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_context.h b/src/gallium/drivers/nv04/nv04_context.h
deleted file mode 100644
index 83acb591878..00000000000
--- a/src/gallium/drivers/nv04/nv04_context.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef __NV04_CONTEXT_H__
-#define __NV04_CONTEXT_H__
-
-#include <stdio.h>
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_compiler.h"
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "util/u_inlines.h"
-
-#include "draw/draw_vertex.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_gldefs.h"
-#include "nouveau/nouveau_context.h"
-
-#include "nv04_state.h"
-
-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
-#define NOUVEAU_MSG(fmt, args...) \
- fprintf(stderr, "nouveau: "fmt, ##args);
-
-#include "nv04_screen.h"
-
-#define NV04_NEW_VERTPROG (1 << 1)
-#define NV04_NEW_FRAGPROG (1 << 2)
-#define NV04_NEW_BLEND (1 << 3)
-#define NV04_NEW_RAST (1 << 4)
-#define NV04_NEW_CONTROL (1 << 5)
-#define NV04_NEW_VIEWPORT (1 << 6)
-#define NV04_NEW_SAMPLER (1 << 7)
-#define NV04_NEW_FRAMEBUFFER (1 << 8)
-#define NV04_NEW_VTXARRAYS (1 << 9)
-
-struct nv04_context {
- struct pipe_context pipe;
-
- struct nouveau_winsys *nvws;
- struct nv04_screen *screen;
- unsigned pctx_id;
-
- struct draw_context *draw;
-
- int chipset;
- struct nouveau_notifier *sync;
-
- uint32_t dirty;
-
- struct nv04_blend_state *blend;
- struct nv04_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- struct nv04_fragtex_state fragtex;
- struct nv04_rasterizer_state *rast;
- struct nv04_depth_stencil_alpha_state *dsa;
-
- struct nv04_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
- unsigned dirty_samplers;
- unsigned fp_samplers;
- unsigned vp_samplers;
-
- uint32_t rt_enable;
- struct pipe_framebuffer_state *framebuffer;
- struct pipe_surface *rt;
- struct pipe_surface *zeta;
-
- struct {
- struct pipe_buffer *buffer;
- uint32_t format;
- } tex[16];
-
- unsigned vb_enable;
- struct {
- struct pipe_buffer *buffer;
- unsigned delta;
- } vb[16];
-
- float *constbuf[PIPE_SHADER_TYPES][32][4];
- unsigned constbuf_nr[PIPE_SHADER_TYPES];
-
- struct vertex_info vertex_info;
- struct {
-
- struct nouveau_resource *exec_heap;
- struct nouveau_resource *data_heap;
-
- struct nv04_vertex_program *active;
-
- struct nv04_vertex_program *current;
- struct pipe_buffer *constant_buf;
- } vertprog;
-
- struct {
- struct nv04_fragment_program *active;
-
- struct nv04_fragment_program *current;
- struct pipe_buffer *constant_buf;
- } fragprog;
-
- struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
- struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
-
- struct pipe_viewport_state viewport;
-};
-
-static INLINE struct nv04_context *
-nv04_context(struct pipe_context *pipe)
-{
- return (struct nv04_context *)pipe;
-}
-
-extern void nv04_init_state_functions(struct nv04_context *nv04);
-extern void nv04_init_surface_functions(struct nv04_context *nv04);
-extern void nv04_screen_init_miptree_functions(struct pipe_screen *screen);
-
-/* nv04_clear.c */
-extern void nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
-
-/* nv04_draw.c */
-extern struct draw_stage *nv04_draw_render_stage(struct nv04_context *nv04);
-
-/* nv04_fragprog.c */
-extern void nv04_fragprog_bind(struct nv04_context *,
- struct nv04_fragment_program *);
-extern void nv04_fragprog_destroy(struct nv04_context *,
- struct nv04_fragment_program *);
-
-/* nv04_fragtex.c */
-extern void nv04_fragtex_bind(struct nv04_context *);
-
-/* nv04_prim_vbuf.c */
-struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 );
-
-/* nv04_state.c and friends */
-extern void nv04_emit_hw_state(struct nv04_context *nv04);
-extern void nv04_state_tex_update(struct nv04_context *nv04);
-
-/* nv04_vbo.c */
-extern void nv04_draw_arrays(struct pipe_context *, unsigned mode,
- unsigned start, unsigned count);
-extern void nv04_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count);
-
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_fragprog.c b/src/gallium/drivers/nv04/nv04_fragprog.c
deleted file mode 100644
index 8a2af41fe06..00000000000
--- a/src/gallium/drivers/nv04/nv04_fragprog.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_util.h"
-
-#include "nv04_context.h"
-
-void
-nv04_fragprog_bind(struct nv04_context *nv04, struct nv04_fragment_program *fp)
-{
-}
-
-void
-nv04_fragprog_destroy(struct nv04_context *nv04,
- struct nv04_fragment_program *fp)
-{
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_fragtex.c b/src/gallium/drivers/nv04/nv04_fragtex.c
deleted file mode 100644
index c152b52119a..00000000000
--- a/src/gallium/drivers/nv04/nv04_fragtex.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "nv04_context.h"
-#include "nouveau/nouveau_util.h"
-
-#define _(m,tf) \
-{ \
- PIPE_FORMAT_##m, \
- NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_##tf, \
-}
-
-struct nv04_texture_format {
- uint pipe;
- int format;
-};
-
-static struct nv04_texture_format
-nv04_texture_formats[] = {
- _(A8R8G8B8_UNORM, A8R8G8B8),
- _(X8R8G8B8_UNORM, X8R8G8B8),
- _(A1R5G5B5_UNORM, A1R5G5B5),
- _(A4R4G4B4_UNORM, A4R4G4B4),
- _(L8_UNORM, Y8 ),
- _(A8_UNORM, Y8 ),
-};
-
-static uint32_t
-nv04_fragtex_format(uint pipe_format)
-{
- struct nv04_texture_format *tf = nv04_texture_formats;
- int i;
-
- for (i=0; i< sizeof(nv04_texture_formats)/sizeof(nv04_texture_formats[0]); i++) {
- if (tf->pipe == pipe_format)
- return tf->format;
- tf++;
- }
-
- NOUVEAU_ERR("unknown texture format %s\n", pf_name(pipe_format));
- return 0;
-}
-
-
-static void
-nv04_fragtex_build(struct nv04_context *nv04, int unit)
-{
- struct nv04_miptree *nv04mt = nv04->tex_miptree[unit];
- struct pipe_texture *pt = &nv04mt->base;
-
- switch (pt->target) {
- case PIPE_TEXTURE_2D:
- break;
- default:
- NOUVEAU_ERR("Unknown target %d\n", pt->target);
- return;
- }
-
- nv04->fragtex.format = NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER
- | NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER
- | nv04_fragtex_format(pt->format)
- | ( (pt->last_level + 1) << NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT )
- | ( log2i(pt->width0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT )
- | ( log2i(pt->height0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT )
- | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE
- | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE
- ;
-}
-
-
-void
-nv04_fragtex_bind(struct nv04_context *nv04)
-{
- nv04_fragtex_build(nv04, 0);
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c
deleted file mode 100644
index e4c38ac98e2..00000000000
--- a/src/gallium/drivers/nv04/nv04_miptree.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-#include "util/u_math.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static void
-nv04_miptree_layout(struct nv04_miptree *nv04mt)
-{
- struct pipe_texture *pt = &nv04mt->base;
- uint offset = 0;
- int nr_faces, l;
-
- nr_faces = 1;
-
- for (l = 0; l <= pt->last_level; l++) {
- nv04mt->level[l].pitch = pt->width0;
- nv04mt->level[l].pitch = (nv04mt->level[l].pitch + 63) & ~63;
- }
-
- for (l = 0; l <= pt->last_level; l++) {
- nv04mt->level[l].image_offset =
- CALLOC(nr_faces, sizeof(unsigned));
- /* XXX guess was obviously missing */
- nv04mt->level[l].image_offset[0] = offset;
- offset += nv04mt->level[l].pitch * u_minify(pt->height0, l);
- }
-
- nv04mt->total_size = offset;
-}
-
-static struct pipe_texture *
-nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
-{
- struct nv04_miptree *mt;
-
- mt = MALLOC(sizeof(struct nv04_miptree));
- if (!mt)
- return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
-
- //mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
-
- nv04_miptree_layout(mt);
-
- mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL |
- NOUVEAU_BUFFER_USAGE_TEXTURE,
- mt->total_size);
- if (!mt->buffer) {
- printf("failed %d byte alloc\n",mt->total_size);
- FREE(mt);
- return NULL;
- }
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static struct pipe_texture *
-nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
-{
- struct nv04_miptree *mt;
-
- /* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
- return NULL;
-
- mt = CALLOC_STRUCT(nv04_miptree);
- if (!mt)
- return NULL;
-
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
- mt->level[0].pitch = stride[0];
- mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
-
- pipe_buffer_reference(&mt->buffer, pb);
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static void
-nv04_miptree_destroy(struct pipe_texture *pt)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)pt;
- int l;
-
- pipe_buffer_reference(&mt->buffer, NULL);
- for (l = 0; l <= pt->last_level; l++) {
- if (mt->level[l].image_offset)
- FREE(mt->level[l].image_offset);
- }
-
- FREE(mt);
-}
-
-static struct pipe_surface *
-nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct nv04_miptree *nv04mt = (struct nv04_miptree *)pt;
- struct nv04_surface *ns;
-
- ns = CALLOC_STRUCT(nv04_surface);
- if (!ns)
- return NULL;
- pipe_texture_reference(&ns->base.texture, pt);
- ns->base.format = pt->format;
- ns->base.width = u_minify(pt->width0, level);
- ns->base.height = u_minify(pt->height0, level);
- ns->base.usage = flags;
- pipe_reference_init(&ns->base.reference, 1);
- ns->base.face = face;
- ns->base.level = level;
- ns->base.zslice = zslice;
- ns->pitch = nv04mt->level[level].pitch;
-
- ns->base.offset = nv04mt->level[level].image_offset[0];
-
- return &ns->base;
-}
-
-static void
-nv04_miptree_surface_del(struct pipe_surface *ps)
-{
- pipe_texture_reference(&ps->texture, NULL);
- FREE(ps);
-}
-
-void
-nv04_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nv04_miptree_create;
- pscreen->texture_blanket = nv04_miptree_blanket;
- pscreen->texture_destroy = nv04_miptree_destroy;
- pscreen->get_tex_surface = nv04_miptree_surface_new;
- pscreen->tex_surface_destroy = nv04_miptree_surface_del;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_prim_vbuf.c b/src/gallium/drivers/nv04/nv04_prim_vbuf.c
deleted file mode 100644
index 03438c7fcb9..00000000000
--- a/src/gallium/drivers/nv04/nv04_prim_vbuf.c
+++ /dev/null
@@ -1,339 +0,0 @@
-
-#include "util/u_debug.h"
-#include "util/u_inlines.h"
-#include "util/u_simple_screen.h"
-#include "pipe/p_compiler.h"
-
-#include "draw/draw_vbuf.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-#define VERTEX_SIZE 40
-#define VERTEX_BUFFER_SIZE (4096*VERTEX_SIZE) // 4096 vertices of 40 bytes each
-
-/**
- * Primitive renderer for nv04.
- */
-struct nv04_vbuf_render {
- struct vbuf_render base;
-
- struct nv04_context *nv04;
-
- /** Vertex buffer */
- unsigned char* buffer;
-
- /** Vertex size in bytes */
- unsigned vertex_size;
-
- /** Current primitive */
- unsigned prim;
-};
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct nv04_vbuf_render *
-nv04_vbuf_render( struct vbuf_render *render )
-{
- assert(render);
- return (struct nv04_vbuf_render *)render;
-}
-
-
-static const struct vertex_info *
-nv04_vbuf_render_get_vertex_info( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- struct nv04_context *nv04 = nv04_render->nv04;
- return &nv04->vertex_info;
-}
-
-
-static boolean
-nv04_vbuf_render_allocate_vertices( struct vbuf_render *render,
- ushort vertex_size,
- ushort nr_vertices )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- nv04_render->buffer = (unsigned char*) MALLOC(VERTEX_BUFFER_SIZE);
- assert(!nv04_render->buffer);
-
- return nv04_render->buffer ? TRUE : FALSE;
-}
-
-static void *
-nv04_vbuf_render_map_vertices( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- return nv04_render->buffer;
-}
-
-static void
-nv04_vbuf_render_unmap_vertices( struct vbuf_render *render,
- ushort min_index,
- ushort max_index )
-{
-}
-
-static boolean
-nv04_vbuf_render_set_primitive( struct vbuf_render *render,
- unsigned prim )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- if (prim <= PIPE_PRIM_LINE_STRIP)
- return FALSE;
-
- nv04_render->prim = prim;
- return TRUE;
-}
-
-static INLINE void nv04_2triangles(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA), 49);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v4,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v5,8);
- OUT_RING(chan, 0xFEDCBA);
-}
-
-static INLINE void nv04_1triangle(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD), 25);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RING(chan, 0xFED);
-}
-
-static INLINE void nv04_1quad(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC), 33);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
- OUT_RING(chan, 0xFECEDC);
-}
-
-static void nv04_vbuf_render_triangles_elts(struct nv04_vbuf_render * render, const ushort * indices, uint nr_indices)
-{
- unsigned char* buffer = render->buffer;
- struct nv04_context* nv04 = render->nv04;
- int i;
-
- for( i=0; i< nr_indices-5; i+=6)
- nv04_2triangles(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2],
- indices[i+3],
- indices[i+4],
- indices[i+5]
- );
- if (i != nr_indices)
- {
- nv04_1triangle(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2]
- );
- i+=3;
- }
- if (i != nr_indices)
- NOUVEAU_ERR("Houston, we have lost some vertices\n");
-}
-
-static void nv04_vbuf_render_tri_strip_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- const uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
- unsigned char* buffer = render->buffer;
- struct nv04_context *nv04 = render->nv04;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- int i,j;
-
- for(i = 0; i<nr_indices; i+=14)
- {
- int numvert = MIN2(16, nr_indices - i);
- int numtri = numvert - 2;
- if (numvert<3)
- break;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), numvert*8);
- for(j = 0; j<numvert; j++)
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices [i+j], 8 );
-
- BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2 );
- for(j = 0; j<numtri/2; j++ )
- OUT_RING(chan, striptbl[j]);
- if (numtri%2)
- OUT_RING(chan, striptbl[numtri/2]&0xFFF);
- }
-}
-
-static void nv04_vbuf_render_tri_fan_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- const uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
- unsigned char* buffer = render->buffer;
- struct nv04_context *nv04 = render->nv04;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- int i,j;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), 8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[0], 8);
-
- for(i = 1; i<nr_indices; i+=14)
- {
- int numvert=MIN2(15, nr_indices - i);
- int numtri=numvert-2;
- if (numvert < 3)
- break;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1), numvert*8);
-
- for(j=0;j<numvert;j++)
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[ i+j ], 8 );
-
- BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2);
- for(j = 0; j<numtri/2; j++)
- OUT_RING(chan, fantbl[j]);
- if (numtri%2)
- OUT_RING(chan, fantbl[numtri/2]&0xFFF);
- }
-}
-
-static void nv04_vbuf_render_quads_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- unsigned char* buffer = render->buffer;
- struct nv04_context* nv04 = render->nv04;
- int i;
-
- for(i = 0; i < nr_indices; i += 4)
- nv04_1quad(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2],
- indices[i+3]
- );
-}
-
-
-static void
-nv04_vbuf_render_draw( struct vbuf_render *render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- // emit the indices
- switch( nv04_render->prim )
- {
- case PIPE_PRIM_TRIANGLES:
- nv04_vbuf_render_triangles_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_QUAD_STRIP:
- case PIPE_PRIM_TRIANGLE_STRIP:
- nv04_vbuf_render_tri_strip_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_TRIANGLE_FAN:
- case PIPE_PRIM_POLYGON:
- nv04_vbuf_render_tri_fan_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_QUADS:
- nv04_vbuf_render_quads_elts(nv04_render, indices, nr_indices);
- break;
- default:
- NOUVEAU_ERR("You have to implement primitive %d, young padawan\n", nv04_render->prim);
- break;
- }
-}
-
-
-static void
-nv04_vbuf_render_release_vertices( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- free(nv04_render->buffer);
- nv04_render->buffer = NULL;
-}
-
-
-static void
-nv04_vbuf_render_destroy( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- FREE(nv04_render);
-}
-
-
-/**
- * Create a new primitive render.
- */
-static struct vbuf_render *
-nv04_vbuf_render_create( struct nv04_context *nv04 )
-{
- struct nv04_vbuf_render *nv04_render = CALLOC_STRUCT(nv04_vbuf_render);
-
- nv04_render->nv04 = nv04;
-
- nv04_render->base.max_vertex_buffer_bytes = VERTEX_BUFFER_SIZE;
- nv04_render->base.max_indices = 65536;
- nv04_render->base.get_vertex_info = nv04_vbuf_render_get_vertex_info;
- nv04_render->base.allocate_vertices = nv04_vbuf_render_allocate_vertices;
- nv04_render->base.map_vertices = nv04_vbuf_render_map_vertices;
- nv04_render->base.unmap_vertices = nv04_vbuf_render_unmap_vertices;
- nv04_render->base.set_primitive = nv04_vbuf_render_set_primitive;
- nv04_render->base.draw = nv04_vbuf_render_draw;
- nv04_render->base.release_vertices = nv04_vbuf_render_release_vertices;
- nv04_render->base.destroy = nv04_vbuf_render_destroy;
-
- return &nv04_render->base;
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 )
-{
- struct vbuf_render *render;
- struct draw_stage *stage;
-
- render = nv04_vbuf_render_create(nv04);
- if(!render)
- return NULL;
-
- stage = draw_vbuf_stage( nv04->draw, render );
- if(!stage) {
- render->destroy(render);
- return NULL;
- }
-
- return stage;
-}
diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c
deleted file mode 100644
index 212b47bc3d2..00000000000
--- a/src/gallium/drivers/nv04/nv04_screen.c
+++ /dev/null
@@ -1,222 +0,0 @@
-#include "pipe/p_screen.h"
-#include "util/u_inlines.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static int
-nv04_screen_get_param(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 1;
- case PIPE_CAP_NPOT_TEXTURES:
- return 0;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 0;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 10;
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 0;
- case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- return 0;
- case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
- return 0;
- case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
- return 1;
- case PIPE_CAP_TGSI_CONT_SUPPORTED:
- return 0;
- case PIPE_CAP_BLEND_EQUATION_SEPARATE:
- return 0;
- case NOUVEAU_CAP_HW_VTXBUF:
- case NOUVEAU_CAP_HW_IDXBUF:
- return 0;
- case PIPE_CAP_INDEP_BLEND_ENABLE:
- return 0;
- case PIPE_CAP_INDEP_BLEND_FUNC:
- return 0;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
- return 1;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
- return 0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0;
- }
-}
-
-static float
-nv04_screen_get_paramf(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 0.0;
- case PIPE_CAP_MAX_POINT_WIDTH:
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 0.0;
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 0.0;
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 0.0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0.0;
- }
-}
-
-static boolean
-nv04_screen_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
- enum pipe_texture_target target,
- unsigned tex_usage, unsigned geom_flags)
-{
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- return TRUE;
- default:
- break;
- }
- } else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
- switch (format) {
- case PIPE_FORMAT_Z16_UNORM:
- return TRUE;
- default:
- break;
- }
- } else {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_A8_UNORM:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-nv04_screen_destroy(struct pipe_screen *pscreen)
-{
- struct nv04_screen *screen = nv04_screen(pscreen);
-
- nouveau_notifier_free(&screen->sync);
- nouveau_grobj_free(&screen->fahrenheit);
- nv04_surface_2d_takedown(&screen->eng2d);
-
- nouveau_screen_fini(&screen->base);
-
- FREE(pscreen);
-}
-
-static struct pipe_buffer *
-nv04_surface_buffer(struct pipe_surface *surf)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)surf->texture;
-
- return mt->buffer;
-}
-
-struct pipe_screen *
-nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
-{
- struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen);
- struct nouveau_channel *chan;
- struct pipe_screen *pscreen;
- unsigned fahrenheit_class = 0, sub3d_class = 0;
- int ret;
-
- if (!screen)
- return NULL;
- pscreen = &screen->base.base;
-
- ret = nouveau_screen_init(&screen->base, dev);
- if (ret) {
- nv04_screen_destroy(pscreen);
- return NULL;
- }
- chan = screen->base.channel;
-
- pscreen->winsys = ws;
- pscreen->destroy = nv04_screen_destroy;
- pscreen->get_param = nv04_screen_get_param;
- pscreen->get_paramf = nv04_screen_get_paramf;
- pscreen->is_format_supported = nv04_screen_is_format_supported;
-
- nv04_screen_init_miptree_functions(pscreen);
- nv04_screen_init_transfer_functions(pscreen);
-
- if (dev->chipset >= 0x20) {
- fahrenheit_class = 0;
- sub3d_class = 0;
- } else if (dev->chipset >= 0x10) {
- fahrenheit_class = NV10_TEXTURED_TRIANGLE;
- sub3d_class = NV10_CONTEXT_SURFACES_3D;
- } else {
- fahrenheit_class=NV04_TEXTURED_TRIANGLE;
- sub3d_class = NV04_CONTEXT_SURFACES_3D;
- }
-
- if (!fahrenheit_class) {
- NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset);
- return NULL;
- }
-
- /* 3D object */
- ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class,
- &screen->fahrenheit);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return NULL;
- }
- BIND_RING(chan, screen->fahrenheit, 7);
-
- /* 3D surface object */
- ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,
- &screen->context_surfaces_3d);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret);
- return NULL;
- }
- BIND_RING(chan, screen->context_surfaces_3d, 6);
-
- /* 2D engine setup */
- screen->eng2d = nv04_surface_2d_init(&screen->base);
- screen->eng2d->buf = nv04_surface_buffer;
-
- /* Notifier for sync purposes */
- ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
- if (ret) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- nv04_screen_destroy(pscreen);
- return NULL;
- }
-
- return pscreen;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h
deleted file mode 100644
index 11466b9442c..00000000000
--- a/src/gallium/drivers/nv04/nv04_screen.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __NV04_SCREEN_H__
-#define __NV04_SCREEN_H__
-
-#include "nouveau/nouveau_screen.h"
-#include "nv04_surface_2d.h"
-
-struct nv04_screen {
- struct nouveau_screen base;
-
- struct nouveau_winsys *nvws;
- unsigned chipset;
-
- /* HW graphics objects */
- struct nv04_surface_2d *eng2d;
- struct nouveau_grobj *fahrenheit;
- struct nouveau_grobj *context_surfaces_3d;
- struct nouveau_notifier *sync;
-
-};
-
-static INLINE struct nv04_screen *
-nv04_screen(struct pipe_screen *screen)
-{
- return (struct nv04_screen *)screen;
-}
-
-void
-nv04_screen_init_transfer_functions(struct pipe_screen *pscreen);
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c
deleted file mode 100644
index 226aae35659..00000000000
--- a/src/gallium/drivers/nv04/nv04_state.c
+++ /dev/null
@@ -1,459 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "util/u_inlines.h"
-
-#include "tgsi/tgsi_parse.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-static void *
-nv04_blend_state_create(struct pipe_context *pipe,
- const struct pipe_blend_state *cso)
-{
- struct nv04_blend_state *cb;
-
- cb = MALLOC(sizeof(struct nv04_blend_state));
-
- cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
- cb->b_src = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
- cb->b_dst = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
-
-
- return (void *)cb;
-}
-
-static void
-nv04_blend_state_bind(struct pipe_context *pipe, void *blend)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->blend = (struct nv04_blend_state*)blend;
-
- nv04->dirty |= NV04_NEW_BLEND;
-}
-
-static void
-nv04_blend_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-
-static INLINE unsigned
-wrap_mode(unsigned wrap) {
- unsigned ret;
-
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT;
- break;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER;
- break;
- case PIPE_TEX_WRAP_CLAMP:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- default:
- NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
- }
- return ret >> NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT;
-}
-
-static void *
-nv04_sampler_state_create(struct pipe_context *pipe,
- const struct pipe_sampler_state *cso)
-{
-
- struct nv04_sampler_state *ss;
- uint32_t filter = 0;
-
- ss = MALLOC(sizeof(struct nv04_sampler_state));
-
- ss->format = ((wrap_mode(cso->wrap_s) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT) |
- (wrap_mode(cso->wrap_t) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_SHIFT));
-
- if (cso->max_anisotropy > 1.0) {
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE | NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE;
- }
-
- switch (cso->mag_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST;
- break;
- }
-
- switch (cso->min_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR;
- break;
- }
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST;
- break;
- }
- break;
- }
-
- ss->filter = filter;
-
- return (void *)ss;
-}
-
-static void
-nv04_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv04->sampler[unit] = sampler[unit];
- nv04->dirty_samplers |= (1 << unit);
- }
-}
-
-static void
-nv04_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static void
-nv04_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
- struct pipe_texture **miptree)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv04->tex_miptree[unit] = (struct nv04_miptree *)miptree[unit];
- nv04->dirty_samplers |= (1 << unit);
- }
-}
-
-static void *
-nv04_rasterizer_state_create(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *cso)
-{
- struct nv04_rasterizer_state *rs;
-
- /*XXX: ignored:
- * scissor
- * points/lines (no hw support, emulated with tris in gallium)
- */
- rs = MALLOC(sizeof(struct nv04_rasterizer_state));
-
- rs->blend = cso->flatshade ? NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT : NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
-
- return (void *)rs;
-}
-
-static void
-nv04_rasterizer_state_bind(struct pipe_context *pipe, void *rast)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->rast = (struct nv04_rasterizer_state*)rast;
-
- draw_set_rasterizer_state(nv04->draw, (nv04->rast ? nv04->rast->templ : NULL));
-
- nv04->dirty |= NV04_NEW_RAST | NV04_NEW_BLEND;
-}
-
-static void
-nv04_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static INLINE uint32_t nv04_compare_func(uint32_t f)
-{
- switch ( f ) {
- case PIPE_FUNC_NEVER: return 1;
- case PIPE_FUNC_LESS: return 2;
- case PIPE_FUNC_EQUAL: return 3;
- case PIPE_FUNC_LEQUAL: return 4;
- case PIPE_FUNC_GREATER: return 5;
- case PIPE_FUNC_NOTEQUAL: return 6;
- case PIPE_FUNC_GEQUAL: return 7;
- case PIPE_FUNC_ALWAYS: return 8;
- }
- NOUVEAU_MSG("Unable to find the function\n");
- return 0;
-}
-
-static void *
-nv04_depth_stencil_alpha_state_create(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *cso)
-{
- struct nv04_depth_stencil_alpha_state *hw;
-
- hw = MALLOC(sizeof(struct nv04_depth_stencil_alpha_state));
-
- hw->control = float_to_ubyte(cso->alpha.ref_value);
- hw->control |= ( nv04_compare_func(cso->alpha.func) << NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT );
- hw->control |= cso->alpha.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE : 0;
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN;
- hw->control |= cso->depth.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE : 0;
- hw->control |= ( nv04_compare_func(cso->depth.func)<< NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT );
- hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_SHIFT; // no culling, handled by the draw module
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE;
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE;
- hw->control |= cso->depth.writemask ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE : 0;
- hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_SHIFT; // integer zbuffer format
-
- return (void *)hw;
-}
-
-static void
-nv04_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->dsa = hwcso;
- nv04->dirty |= NV04_NEW_CONTROL;
-}
-
-static void
-nv04_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static void *
-nv04_vp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- return draw_create_vertex_shader(nv04->draw, templ);
-}
-
-static void
-nv04_vp_state_bind(struct pipe_context *pipe, void *shader)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- draw_bind_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader);
-
- nv04->dirty |= NV04_NEW_VERTPROG;
-}
-
-static void
-nv04_vp_state_delete(struct pipe_context *pipe, void *shader)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- draw_delete_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void *
-nv04_fp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *cso)
-{
- struct nv04_fragment_program *fp;
-
- fp = CALLOC(1, sizeof(struct nv04_fragment_program));
- fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
-
- return (void *)fp;
-}
-
-static void
-nv04_fp_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = hwcso;
-
- nv04->fragprog.current = fp;
- nv04->dirty |= NV04_NEW_FRAGPROG;
-}
-
-static void
-nv04_fp_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = hwcso;
-
- nv04_fragprog_destroy(nv04, fp);
- free((void*)fp->pipe.tokens);
- free(fp);
-}
-
-static void
-nv04_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *bcol)
-{
-}
-
-static void
-nv04_set_clip_state(struct pipe_context *pipe,
- const struct pipe_clip_state *clip)
-{
-}
-
-static void
-nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- if (buf) {
- void *mapped;
- if (buf && buf->size &&
- (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ)))
- {
- memcpy(nv04->constbuf[shader], mapped, buf->size);
- nv04->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
- pipe_buffer_unmap(pscreen, buf);
- }
- }
-}
-
-static void
-nv04_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->framebuffer = (struct pipe_framebuffer_state*)fb;
-
- nv04->dirty |= NV04_NEW_FRAMEBUFFER;
-}
-static void
-nv04_set_polygon_stipple(struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple)
-{
- NOUVEAU_ERR("line stipple hahaha\n");
-}
-
-static void
-nv04_set_scissor_state(struct pipe_context *pipe,
- const struct pipe_scissor_state *s)
-{
-/* struct nv04_context *nv04 = nv04_context(pipe);
-
- // XXX
- BEGIN_RING(fahrenheit, NV04_TEXTURED_TRIANGLE_SCISSOR_HORIZ, 2);
- OUT_RING (((s->maxx - s->minx) << 16) | s->minx);
- OUT_RING (((s->maxy - s->miny) << 16) | s->miny);*/
-}
-
-static void
-nv04_set_viewport_state(struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->viewport = *viewport;
-
- draw_set_viewport_state(nv04->draw, &nv04->viewport);
-}
-
-static void
-nv04_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_buffer *buffers)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- memcpy(nv04->vtxbuf, buffers, count * sizeof(buffers[0]));
- nv04->dirty |= NV04_NEW_VTXARRAYS;
-
- draw_set_vertex_buffers(nv04->draw, count, buffers);
-}
-
-static void
-nv04_set_vertex_elements(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_element *elements)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- memcpy(nv04->vtxelt, elements, sizeof(*elements) * count);
- nv04->dirty |= NV04_NEW_VTXARRAYS;
-
- draw_set_vertex_elements(nv04->draw, count, elements);
-}
-
-void
-nv04_init_state_functions(struct nv04_context *nv04)
-{
- nv04->pipe.create_blend_state = nv04_blend_state_create;
- nv04->pipe.bind_blend_state = nv04_blend_state_bind;
- nv04->pipe.delete_blend_state = nv04_blend_state_delete;
-
- nv04->pipe.create_sampler_state = nv04_sampler_state_create;
- nv04->pipe.bind_fragment_sampler_states = nv04_sampler_state_bind;
- nv04->pipe.delete_sampler_state = nv04_sampler_state_delete;
- nv04->pipe.set_fragment_sampler_textures = nv04_set_sampler_texture;
-
- nv04->pipe.create_rasterizer_state = nv04_rasterizer_state_create;
- nv04->pipe.bind_rasterizer_state = nv04_rasterizer_state_bind;
- nv04->pipe.delete_rasterizer_state = nv04_rasterizer_state_delete;
-
- nv04->pipe.create_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_create;
- nv04->pipe.bind_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_bind;
- nv04->pipe.delete_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_delete;
-
- nv04->pipe.create_vs_state = nv04_vp_state_create;
- nv04->pipe.bind_vs_state = nv04_vp_state_bind;
- nv04->pipe.delete_vs_state = nv04_vp_state_delete;
-
- nv04->pipe.create_fs_state = nv04_fp_state_create;
- nv04->pipe.bind_fs_state = nv04_fp_state_bind;
- nv04->pipe.delete_fs_state = nv04_fp_state_delete;
-
- nv04->pipe.set_blend_color = nv04_set_blend_color;
- nv04->pipe.set_clip_state = nv04_set_clip_state;
- nv04->pipe.set_constant_buffer = nv04_set_constant_buffer;
- nv04->pipe.set_framebuffer_state = nv04_set_framebuffer_state;
- nv04->pipe.set_polygon_stipple = nv04_set_polygon_stipple;
- nv04->pipe.set_scissor_state = nv04_set_scissor_state;
- nv04->pipe.set_viewport_state = nv04_set_viewport_state;
-
- nv04->pipe.set_vertex_buffers = nv04_set_vertex_buffers;
- nv04->pipe.set_vertex_elements = nv04_set_vertex_elements;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_state.h b/src/gallium/drivers/nv04/nv04_state.h
deleted file mode 100644
index 81d1d2ebaa9..00000000000
--- a/src/gallium/drivers/nv04/nv04_state.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __NV04_STATE_H__
-#define __NV04_STATE_H__
-
-#include "pipe/p_state.h"
-#include "tgsi/tgsi_scan.h"
-
-struct nv04_blend_state {
- uint32_t b_enable;
- uint32_t b_src;
- uint32_t b_dst;
-};
-
-struct nv04_fragtex_state {
- uint32_t format;
-};
-
-struct nv04_sampler_state {
- uint32_t filter;
- uint32_t format;
-};
-
-struct nv04_depth_stencil_alpha_state {
- uint32_t control;
-};
-
-struct nv04_rasterizer_state {
- uint32_t blend;
-
- const struct pipe_rasterizer_state *templ;
-};
-
-struct nv04_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-
- struct pipe_buffer *buffer;
- uint total_size;
-
- struct {
- uint pitch;
- uint *image_offset;
- } level[PIPE_MAX_TEXTURE_LEVELS];
-};
-
-struct nv04_fragment_program_data {
- unsigned offset;
- unsigned index;
-};
-
-struct nv04_fragment_program {
- struct pipe_shader_state pipe;
- struct tgsi_shader_info info;
-
- boolean translated;
- boolean on_hw;
- unsigned samplers;
-
- uint32_t *insn;
- int insn_len;
-
- struct nv04_fragment_program_data *consts;
- unsigned nr_consts;
-
- struct pipe_buffer *buffer;
-
- uint32_t fp_control;
- uint32_t fp_reg_control;
-};
-
-
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_state_emit.c b/src/gallium/drivers/nv04/nv04_state_emit.c
deleted file mode 100644
index b8d6dc560f0..00000000000
--- a/src/gallium/drivers/nv04/nv04_state_emit.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-static void nv04_vertex_layout(struct pipe_context* pipe)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = nv04->fragprog.current;
- uint32_t src = 0;
- int i;
- struct vertex_info vinfo;
-
- memset(&vinfo, 0, sizeof(vinfo));
-
- for (i = 0; i < fp->info.num_inputs; i++) {
- int isn = fp->info.input_semantic_name[i];
- int isi = fp->info.input_semantic_index[i];
- switch (isn) {
- case TGSI_SEMANTIC_POSITION:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- case TGSI_SEMANTIC_COLOR:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- default:
- case TGSI_SEMANTIC_GENERIC:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- case TGSI_SEMANTIC_FOG:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- }
- }
-
- printf("%d vertex input\n",fp->info.num_inputs);
- draw_compute_vertex_size(&vinfo);
-}
-
-static uint32_t nv04_blend_func(uint32_t f)
-{
- switch ( f ) {
- case PIPE_BLENDFACTOR_ZERO: return 0x1;
- case PIPE_BLENDFACTOR_ONE: return 0x2;
- case PIPE_BLENDFACTOR_SRC_COLOR: return 0x3;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR: return 0x4;
- case PIPE_BLENDFACTOR_SRC_ALPHA: return 0x5;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA: return 0x6;
- case PIPE_BLENDFACTOR_DST_ALPHA: return 0x7;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA: return 0x8;
- case PIPE_BLENDFACTOR_DST_COLOR: return 0x9;
- case PIPE_BLENDFACTOR_INV_DST_COLOR: return 0xA;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: return 0xB;
- }
- NOUVEAU_MSG("Unable to find the blend function 0x%x\n",f);
- return 0;
-}
-
-static void nv04_emit_control(struct nv04_context* nv04)
-{
- uint32_t control = nv04->dsa->control;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, control);
-}
-
-static void nv04_emit_blend(struct nv04_context* nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- uint32_t blend;
-
- blend=0x4; // texture MODULATE_ALPHA
- blend|=0x20; // alpha is MSB
- blend|=(2<<6); // flat shading
- blend|=(1<<8); // persp correct
- blend|=(0<<16); // no fog
- blend|=(nv04->blend->b_enable<<20);
- blend|=(nv04_blend_func(nv04->blend->b_src)<<24);
- blend|=(nv04_blend_func(nv04->blend->b_dst)<<28);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
- OUT_RING(chan, blend);
-}
-
-static void nv04_emit_sampler(struct nv04_context *nv04, int unit)
-{
- struct nv04_miptree *nv04mt = nv04->tex_miptree[unit];
- struct pipe_texture *pt = &nv04mt->base;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 3);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[unit]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- OUT_RING(chan, nv04->sampler[unit]->filter);
-}
-
-static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
-{
- struct pipe_framebuffer_state* fb = nv04->framebuffer;
- struct nv04_surface *rt, *zeta;
- uint32_t rt_format, w, h;
- int colour_format = 0, zeta_format = 0;
- struct nv04_miptree *nv04mt = 0;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
- struct nouveau_bo *bo;
-
- w = fb->cbufs[0]->width;
- h = fb->cbufs[0]->height;
- colour_format = fb->cbufs[0]->format;
- rt = (struct nv04_surface *)fb->cbufs[0];
-
- if (fb->zsbuf) {
- if (colour_format) {
- assert(w == fb->zsbuf->width);
- assert(h == fb->zsbuf->height);
- } else {
- w = fb->zsbuf->width;
- h = fb->zsbuf->height;
- }
-
- zeta_format = fb->zsbuf->format;
- zeta = (struct nv04_surface *)fb->zsbuf;
- }
-
- switch (colour_format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case 0:
- rt_format = 0x108;
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- rt_format = 0x103;
- break;
- default:
- assert(0);
- }
-
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
- OUT_RING(chan, rt_format);
-
- nv04mt = (struct nv04_miptree *)rt->base.texture;
- bo = nouveau_bo(nv04mt->buffer);
- /* FIXME pitches have to be aligned ! */
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(chan, rt->pitch|(zeta->pitch<<16));
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- if (fb->zsbuf) {
- nv04mt = (struct nv04_miptree *)zeta->base.texture;
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- }
-}
-
-void
-nv04_emit_hw_state(struct nv04_context *nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
- int i;
-
- if (nv04->dirty & NV04_NEW_VERTPROG) {
- //nv04_vertprog_bind(nv04, nv04->vertprog.current);
- nv04->dirty &= ~NV04_NEW_VERTPROG;
- }
-
- if (nv04->dirty & NV04_NEW_FRAGPROG) {
- nv04_fragprog_bind(nv04, nv04->fragprog.current);
- nv04->dirty &= ~NV04_NEW_FRAGPROG;
- nv04->dirty_samplers |= (1<<10);
- nv04->dirty_samplers = 0;
- }
-
- if (nv04->dirty & NV04_NEW_CONTROL) {
- nv04->dirty &= ~NV04_NEW_CONTROL;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, nv04->dsa->control);
- }
-
- if (nv04->dirty & NV04_NEW_BLEND) {
- nv04->dirty &= ~NV04_NEW_BLEND;
-
- nv04_emit_blend(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_VTXARRAYS) {
- nv04->dirty &= ~NV04_NEW_VTXARRAYS;
- nv04_vertex_layout(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_SAMPLER) {
- nv04->dirty &= ~NV04_NEW_SAMPLER;
-
- nv04_emit_sampler(nv04, 0);
- }
-
- if (nv04->dirty & NV04_NEW_VIEWPORT) {
- nv04->dirty &= ~NV04_NEW_VIEWPORT;
-// nv04_state_emit_viewport(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_FRAMEBUFFER) {
- nv04->dirty &= ~NV04_NEW_FRAMEBUFFER;
- nv04_state_emit_framebuffer(nv04);
- }
-
- /* Emit relocs for every referenced buffer.
- * This is to ensure the bufmgr has an accurate idea of how
- * the buffer is used. This isn't very efficient, but we don't
- * seem to take a significant performance hit. Will be improved
- * at some point. Vertex arrays are emitted by nv04_vbo.c
- */
-
- /* Render target */
- unsigned rt_pitch = ((struct nv04_surface *)nv04->rt)->pitch;
- unsigned zeta_pitch = ((struct nv04_surface *)nv04->zeta)->pitch;
-
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(chan, rt_pitch|(zeta_pitch<<16));
- OUT_RELOCl(chan, nouveau_bo(nv04->rt), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- if (nv04->zeta) {
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
- OUT_RELOCl(chan, nouveau_bo(nv04->zeta), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- }
-
- /* Texture images */
- for (i = 0; i < 1; i++) {
- if (!(nv04->fp_samplers & (1 << i)))
- continue;
- struct nv04_miptree *nv04mt = nv04->tex_miptree[i];
- struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 2);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[i]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- }
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_surface.c b/src/gallium/drivers/nv04/nv04_surface.c
deleted file mode 100644
index c5f8927c058..00000000000
--- a/src/gallium/drivers/nv04/nv04_surface.c
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/**************************************************************************
- *
- * 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
- * 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 "nv04_context.h"
-#include "pipe/p_defines.h"
-#include "util/u_simple_screen.h"
-#include "util/u_inlines.h"
-#include "util/u_tile.h"
-
-static void
-nv04_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
-
- eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
-
-static void
-nv04_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
-
- eng2d->fill(eng2d, dest, destx, desty, width, height, value);
-}
-
-void
-nv04_init_surface_functions(struct nv04_context *nv04)
-{
- nv04->pipe.surface_copy = nv04_surface_copy;
- nv04->pipe.surface_fill = nv04_surface_fill;
-}
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c
deleted file mode 100644
index 42c2ca932d8..00000000000
--- a/src/gallium/drivers/nv04/nv04_surface_2d.c
+++ /dev/null
@@ -1,547 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_format.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_util.h"
-#include "nouveau/nouveau_screen.h"
-#include "nv04_surface_2d.h"
-
-static INLINE int
-nv04_surface_format(enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_I8_UNORM:
- return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
- case PIPE_FORMAT_R16_SNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- case PIPE_FORMAT_A8L8_UNORM:
- return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
- return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
- default:
- return -1;
- }
-}
-
-static INLINE int
-nv04_rect_format(enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8_UNORM:
- return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_A8L8_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
- return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
- default:
- return -1;
- }
-}
-
-static INLINE int
-nv04_scaled_image_format(enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_I8_UNORM:
- return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_R16_SNORM:
- case PIPE_FORMAT_A8L8_UNORM:
- return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
- default:
- return -1;
- }
-}
-
-static INLINE unsigned
-nv04_swizzle_bits_square(unsigned x, unsigned y)
-{
- unsigned u = (x & 0x001) << 0 |
- (x & 0x002) << 1 |
- (x & 0x004) << 2 |
- (x & 0x008) << 3 |
- (x & 0x010) << 4 |
- (x & 0x020) << 5 |
- (x & 0x040) << 6 |
- (x & 0x080) << 7 |
- (x & 0x100) << 8 |
- (x & 0x200) << 9 |
- (x & 0x400) << 10 |
- (x & 0x800) << 11;
-
- unsigned v = (y & 0x001) << 1 |
- (y & 0x002) << 2 |
- (y & 0x004) << 3 |
- (y & 0x008) << 4 |
- (y & 0x010) << 5 |
- (y & 0x020) << 6 |
- (y & 0x040) << 7 |
- (y & 0x080) << 8 |
- (y & 0x100) << 9 |
- (y & 0x200) << 10 |
- (y & 0x400) << 11 |
- (y & 0x800) << 12;
- return v | u;
-}
-
-/* rectangular swizzled textures are linear concatenations of swizzled square tiles */
-static INLINE unsigned
-nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h)
-{
- unsigned s = MIN2(w, h);
- unsigned m = s - 1;
- return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m);
-}
-
-static int
-nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
- struct pipe_surface *dst, int dx, int dy,
- struct pipe_surface *src, int sx, int sy,
- int w, int h)
-{
- struct nouveau_channel *chan = ctx->swzsurf->channel;
- struct nouveau_grobj *swzsurf = ctx->swzsurf;
- struct nouveau_grobj *sifm = ctx->sifm;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
- const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
- /* Max width & height may not be the same on all HW, but must be POT */
- const unsigned max_w = 1024;
- const unsigned max_h = 1024;
- unsigned sub_w = w > max_w ? max_w : w;
- unsigned sub_h = h > max_h ? max_h : h;
- unsigned x;
- unsigned y;
-
- /* Swizzled surfaces must be POT */
- assert(util_is_pot(dst->width) && util_is_pot(dst->height));
-
- /* If area is too large to copy in one shot we must copy it in POT chunks to meet alignment requirements */
- assert(sub_w == w || util_is_pot(sub_w));
- assert(sub_h == h || util_is_pot(sub_h));
-
- MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 +
- ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2);
-
- BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
- OUT_RELOCo(chan, dst_bo,
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1);
- OUT_RING (chan, nv04_surface_format(dst->format) |
- log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
- log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
-
- BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
- OUT_RELOCo(chan, src_bo,
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
- BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
- OUT_RING (chan, swzsurf->handle);
-
- for (y = 0; y < h; y += sub_h) {
- sub_h = MIN2(sub_h, h - y);
-
- for (x = 0; x < w; x += sub_w) {
- sub_w = MIN2(sub_w, w - x);
-
- assert(!(dst->offset & 63));
-
- BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
- OUT_RELOCl(chan, dst_bo, dst->offset,
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
- OUT_RING (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
- OUT_RING (chan, nv04_scaled_image_format(src->format));
- OUT_RING (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
- OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
- OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
- OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
- OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
- OUT_RING (chan, 1 << 20);
- OUT_RING (chan, 1 << 20);
-
- BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
- OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w);
- OUT_RING (chan, src_pitch |
- NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
- NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
- OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
- OUT_RING (chan, 0);
- }
- }
-
- return 0;
-}
-
-static int
-nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
- struct pipe_surface *dst, int dx, int dy,
- struct pipe_surface *src, int sx, int sy, int w, int h)
-{
- struct nouveau_channel *chan = ctx->m2mf->channel;
- struct nouveau_grobj *m2mf = ctx->m2mf;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
- unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
- unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
- unsigned dst_offset = dst->offset + dy * dst_pitch +
- dx * util_format_get_blocksize(dst->texture->format);
- unsigned src_offset = src->offset + sy * src_pitch +
- sx * util_format_get_blocksize(src->texture->format);
-
- MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2);
- BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
- OUT_RELOCo(chan, src_bo,
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
- OUT_RELOCo(chan, dst_bo,
- NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- while (h) {
- int count = (h > 2047) ? 2047 : h;
-
- BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
- OUT_RELOCl(chan, src_bo, src_offset,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCl(chan, dst_bo, dst_offset,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
- OUT_RING (chan, src_pitch);
- OUT_RING (chan, dst_pitch);
- OUT_RING (chan, w * util_format_get_blocksize(src->texture->format));
- OUT_RING (chan, count);
- OUT_RING (chan, 0x0101);
- OUT_RING (chan, 0);
-
- h -= count;
- src_offset += src_pitch * count;
- dst_offset += dst_pitch * count;
- }
-
- return 0;
-}
-
-static int
-nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
- int dx, int dy, struct pipe_surface *src, int sx, int sy,
- int w, int h)
-{
- struct nouveau_channel *chan = ctx->surf2d->channel;
- struct nouveau_grobj *surf2d = ctx->surf2d;
- struct nouveau_grobj *blit = ctx->blit;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
- unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
- unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
- int format;
-
- format = nv04_surface_format(dst->format);
- if (format < 0)
- return 1;
-
- MARK_RING (chan, 12, 4);
- BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
- OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
- OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
- OUT_RING (chan, format);
- OUT_RING (chan, (dst_pitch << 16) | src_pitch);
- OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
- OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- BEGIN_RING(chan, blit, 0x0300, 3);
- OUT_RING (chan, (sy << 16) | sx);
- OUT_RING (chan, (dy << 16) | dx);
- OUT_RING (chan, ( h << 16) | w);
-
- return 0;
-}
-
-static void
-nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
- int dx, int dy, struct pipe_surface *src, int sx, int sy,
- int w, int h)
-{
- unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
- unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
- int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
- int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
-
- assert(src->format == dst->format);
-
- /* Setup transfer to swizzle the texture to vram if needed */
- if (src_linear && !dst_linear && w > 1 && h > 1) {
- nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
- return;
- }
-
- /* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
- * to NV_MEMORY_TO_MEMORY_FORMAT in this case.
- */
- if ((src->offset & 63) || (dst->offset & 63) ||
- (src_pitch & 63) || (dst_pitch & 63)) {
- nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
- return;
- }
-
- nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h);
-}
-
-static void
-nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
- int dx, int dy, int w, int h, unsigned value)
-{
- struct nouveau_channel *chan = ctx->surf2d->channel;
- struct nouveau_grobj *surf2d = ctx->surf2d;
- struct nouveau_grobj *rect = ctx->rect;
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
- unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
- int cs2d_format, gdirect_format;
-
- cs2d_format = nv04_surface_format(dst->format);
- assert(cs2d_format >= 0);
-
- gdirect_format = nv04_rect_format(dst->format);
- assert(gdirect_format >= 0);
-
- MARK_RING (chan, 16, 4);
- BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
- OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
- OUT_RING (chan, cs2d_format);
- OUT_RING (chan, (dst_pitch << 16) | dst_pitch);
- OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1);
- OUT_RING (chan, gdirect_format);
- BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1);
- OUT_RING (chan, value);
- BEGIN_RING(chan, rect,
- NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2);
- OUT_RING (chan, (dx << 16) | dy);
- OUT_RING (chan, ( w << 16) | h);
-}
-
-void
-nv04_surface_2d_takedown(struct nv04_surface_2d **pctx)
-{
- struct nv04_surface_2d *ctx;
-
- if (!pctx || !*pctx)
- return;
- ctx = *pctx;
- *pctx = NULL;
-
- nouveau_notifier_free(&ctx->ntfy);
- nouveau_grobj_free(&ctx->m2mf);
- nouveau_grobj_free(&ctx->surf2d);
- nouveau_grobj_free(&ctx->swzsurf);
- nouveau_grobj_free(&ctx->rect);
- nouveau_grobj_free(&ctx->blit);
- nouveau_grobj_free(&ctx->sifm);
-
- FREE(ctx);
-}
-
-struct nv04_surface_2d *
-nv04_surface_2d_init(struct nouveau_screen *screen)
-{
- struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d);
- struct nouveau_channel *chan = screen->channel;
- unsigned handle = 0x88000000, class;
- int ret;
-
- if (!ctx)
- return NULL;
-
- ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
- OUT_RING (chan, ctx->ntfy->handle);
-
- if (chan->device->chipset < 0x10)
- class = NV04_CONTEXT_SURFACES_2D;
- else
- class = NV10_CONTEXT_SURFACES_2D;
-
- ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- BEGIN_RING(chan, ctx->surf2d,
- NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->vram->handle);
-
- if (chan->device->chipset < 0x10)
- class = NV04_IMAGE_BLIT;
- else
- class = NV12_IMAGE_BLIT;
-
- ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1);
- OUT_RING (chan, ctx->ntfy->handle);
- BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1);
- OUT_RING (chan, ctx->surf2d->handle);
- BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1);
- OUT_RING (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY);
-
- ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
- &ctx->rect);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
- OUT_RING (chan, ctx->ntfy->handle);
- BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
- OUT_RING (chan, ctx->surf2d->handle);
- BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
- OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY);
- BEGIN_RING(chan, ctx->rect,
- NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
- OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
-
- switch (chan->device->chipset & 0xf0) {
- case 0x00:
- case 0x10:
- class = NV04_SWIZZLED_SURFACE;
- break;
- case 0x20:
- class = NV20_SWIZZLED_SURFACE;
- break;
- case 0x30:
- class = NV30_SWIZZLED_SURFACE;
- break;
- case 0x40:
- case 0x60:
- class = NV40_SWIZZLED_SURFACE;
- break;
- default:
- /* Famous last words: this really can't happen.. */
- assert(0);
- break;
- }
-
- ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- switch (chan->device->chipset & 0xf0) {
- case 0x10:
- case 0x20:
- class = NV10_SCALED_IMAGE_FROM_MEMORY;
- break;
- case 0x30:
- class = NV30_SCALED_IMAGE_FROM_MEMORY;
- break;
- case 0x40:
- case 0x60:
- class = NV40_SCALED_IMAGE_FROM_MEMORY;
- break;
- default:
- class = NV04_SCALED_IMAGE_FROM_MEMORY;
- break;
- }
-
- ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm);
- if (ret) {
- nv04_surface_2d_takedown(&ctx);
- return NULL;
- }
-
- ctx->copy = nv04_surface_copy;
- ctx->fill = nv04_surface_fill;
- return ctx;
-}
-
-struct nv04_surface*
-nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
-{
- int temp_flags;
-
- // printf("creating temp, flags is %i!\n", flags);
-
- if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
- {
- temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
- }
- else
- {
- temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
- }
-
- struct nv40_screen* screen = (struct nv40_screen*)pscreen;
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
-
- struct pipe_texture templ;
- memset(&templ, 0, sizeof(templ));
- templ.format = ns->base.texture->format;
- templ.target = PIPE_TEXTURE_2D;
- templ.width0 = ns->base.width;
- templ.height0 = ns->base.height;
- templ.depth0 = 1;
- templ.last_level = 0;
-
- // TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
- templ.nr_samples = ns->base.texture->nr_samples;
-
- templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
-
- struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
- struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
- temp_ns->backing = ns;
-
- if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
- eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
-
- return temp_ns;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nv04/nv04_surface_2d.h
deleted file mode 100644
index ce696a11a39..00000000000
--- a/src/gallium/drivers/nv04/nv04_surface_2d.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __NV04_SURFACE_2D_H__
-#define __NV04_SURFACE_2D_H__
-
-struct nv04_surface {
- struct pipe_surface base;
- unsigned pitch;
- struct nv04_surface* backing;
-};
-
-struct nv04_surface_2d {
- struct nouveau_notifier *ntfy;
- struct nouveau_grobj *surf2d;
- struct nouveau_grobj *swzsurf;
- struct nouveau_grobj *m2mf;
- struct nouveau_grobj *rect;
- struct nouveau_grobj *blit;
- struct nouveau_grobj *sifm;
-
- struct pipe_buffer *(*buf)(struct pipe_surface *);
-
- void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst,
- int dx, int dy, struct pipe_surface *src, int sx, int sy,
- int w, int h);
- void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst,
- int dx, int dy, int w, int h, unsigned value);
-};
-
-struct nv04_surface_2d *
-nv04_surface_2d_init(struct nouveau_screen *screen);
-
-void
-nv04_surface_2d_takedown(struct nv04_surface_2d **);
-
-struct nv04_surface*
-nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns);
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c
deleted file mode 100644
index 2e151483851..00000000000
--- a/src/gallium/drivers/nv04/nv04_transfer.c
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <pipe/p_state.h>
-#include <pipe/p_defines.h>
-#include <util/u_inlines.h>
-#include <util/u_format.h>
-#include <util/u_memory.h>
-#include <util/u_math.h>
-#include <nouveau/nouveau_winsys.h>
-#include "nv04_context.h"
-#include "nv04_screen.h"
-#include "nv04_state.h"
-
-struct nv04_transfer {
- struct pipe_transfer base;
- struct pipe_surface *surface;
- boolean direct;
-};
-
-static void
-nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
- struct pipe_texture *template)
-{
- memset(template, 0, sizeof(struct pipe_texture));
- template->target = pt->target;
- template->format = pt->format;
- template->width0 = width;
- template->height0 = height;
- template->depth0 = 1;
- template->last_level = 0;
- template->nr_samples = pt->nr_samples;
-
- template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
-}
-
-static struct pipe_transfer *
-nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)pt;
- struct nv04_transfer *tx;
- struct pipe_texture tx_tex_template, *tx_tex;
-
- tx = CALLOC_STRUCT(nv04_transfer);
- if (!tx)
- return NULL;
-
- pipe_texture_reference(&tx->base.texture, pt);
- tx->base.x = x;
- tx->base.y = y;
- tx->base.width = w;
- tx->base.height = h;
- tx->base.stride = mt->level[level].pitch;
- tx->base.usage = usage;
- tx->base.face = face;
- tx->base.level = level;
- tx->base.zslice = zslice;
-
- /* Direct access to texture */
- if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC ||
- debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) &&
- pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
- {
- tx->direct = true;
- tx->surface = pscreen->get_tex_surface(pscreen, pt,
- 0, 0, 0,
- pipe_transfer_buffer_flags(&tx->base));
- return &tx->base;
- }
-
- tx->direct = false;
-
- nv04_compatible_transfer_tex(pt, w, h, &tx_tex_template);
-
- tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
- if (!tx_tex)
- {
- FREE(tx);
- return NULL;
- }
-
- tx->base.stride = ((struct nv04_miptree*)tx_tex)->level[0].pitch;
-
- tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
- face, level, zslice,
- pipe_transfer_buffer_flags(&tx->base));
-
- pipe_texture_reference(&tx_tex, NULL);
-
- if (!tx->surface)
- {
- pipe_surface_reference(&tx->surface, NULL);
- FREE(tx);
- return NULL;
- }
-
- if (usage & PIPE_TRANSFER_READ) {
- struct nv04_screen *nvscreen = nv04_screen(pscreen);
- struct pipe_surface *src;
-
- src = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- /* TODO: Check if SIFM can un-swizzle */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- tx->surface, 0, 0,
- src, x, y,
- w, h);
-
- pipe_surface_reference(&src, NULL);
- }
-
- return &tx->base;
-}
-
-static void
-nv04_transfer_del(struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
-
- if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_screen *pscreen = ptx->texture->screen;
- struct nv04_screen *nvscreen = nv04_screen(pscreen);
- struct pipe_surface *dst;
-
- dst = pscreen->get_tex_surface(pscreen, ptx->texture,
- ptx->face, ptx->level, ptx->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- dst, tx->base.x, tx->base.y,
- tx->surface, 0, 0,
- tx->base.width, tx->base.height);
-
- pipe_surface_reference(&dst, NULL);
- }
-
- pipe_surface_reference(&tx->surface, NULL);
- pipe_texture_reference(&ptx->texture, NULL);
- FREE(ptx);
-}
-
-static void *
-nv04_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
- struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
- struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture;
- void *map = pipe_buffer_map(pscreen, mt->buffer,
- pipe_transfer_buffer_flags(ptx));
-
- if(!tx->direct)
- return map + ns->base.offset;
- else
- return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
-}
-
-static void
-nv04_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
- struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture;
-
- pipe_buffer_unmap(pscreen, mt->buffer);
-}
-
-void
-nv04_screen_init_transfer_functions(struct pipe_screen *pscreen)
-{
- pscreen->get_tex_transfer = nv04_transfer_new;
- pscreen->tex_transfer_destroy = nv04_transfer_del;
- pscreen->transfer_map = nv04_transfer_map;
- pscreen->transfer_unmap = nv04_transfer_unmap;
-}
diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c
deleted file mode 100644
index 606ce65fabd..00000000000
--- a/src/gallium/drivers/nv04/nv04_vbo.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "util/u_inlines.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-#include "nouveau/nouveau_channel.h"
-#include "nouveau/nouveau_pushbuf.h"
-
-void nv04_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct pipe_screen *pscreen = pipe->screen;
- struct nv04_context *nv04 = nv04_context( pipe );
- struct draw_context *draw = nv04->draw;
- unsigned i;
-
- nv04_emit_hw_state(nv04);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv04->vtxbuf[i].buffer) {
- void *buf
- = pipe_buffer_map(pscreen,
- nv04->vtxbuf[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe_buffer_map(pscreen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
- nv04->constbuf[PIPE_SHADER_VERTEX],
- nv04->constbuf_nr[PIPE_SHADER_VERTEX]);
-
- /* draw! */
- draw_arrays(nv04->draw, prim, start, count);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv04->vtxbuf[i].buffer) {
- pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (indexBuffer) {
- pipe_buffer_unmap(pscreen, indexBuffer);
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-}
-
-void nv04_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- printf("coucou in draw arrays\n");
- nv04_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-