summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/nouveau
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
-rw-r--r--src/mesa/drivers/dri/nouveau/Makefile3
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c70
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h24
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_driver.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c42
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.h16
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_context.c202
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_context.h7
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_driver.h8
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_screen.c211
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_state_fb.c8
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_surface.c134
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_context.c343
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_driver.h11
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_screen.c364
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_context.c463
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_driver.h11
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_screen.c483
18 files changed, 1124 insertions, 1278 deletions
diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile
index 7c895a2e4b9..43bc9f95161 100644
--- a/src/mesa/drivers/dri/nouveau/Makefile
+++ b/src/mesa/drivers/dri/nouveau/Makefile
@@ -22,7 +22,6 @@ DRIVER_SOURCES = \
nouveau_texture.c \
nouveau_surface.c \
nv04_context.c \
- nv04_screen.c \
nv04_render.c \
nv04_state_fb.c \
nv04_state_raster.c \
@@ -30,7 +29,6 @@ DRIVER_SOURCES = \
nv04_state_frag.c \
nv04_surface.c \
nv10_context.c \
- nv10_screen.c \
nv10_render.c \
nv10_state_fb.c \
nv10_state_polygon.c \
@@ -39,7 +37,6 @@ DRIVER_SOURCES = \
nv10_state_frag.c \
nv10_state_tnl.c \
nv20_context.c \
- nv20_screen.c \
nv20_render.c \
nv20_state_fb.c \
nv20_state_polygon.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 6117f68bcf7..b1b0e816431 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Francisco Jerez.
+ * Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -36,8 +36,10 @@
#include "drivers/common/meta.h"
#include "drivers/common/driverfuncs.h"
#include "swrast/swrast.h"
+#include "swrast/s_context.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
+#include "tnl/t_context.h"
#define need_GL_EXT_framebuffer_object
#define need_GL_EXT_fog_coord
@@ -56,6 +58,16 @@ static const struct dri_extension nouveau_extensions[] = {
{ NULL, NULL }
};
+static void
+nouveau_channel_flush_notify(struct nouveau_channel *chan)
+{
+ struct nouveau_context *nctx = chan->user_private;
+ GLcontext *ctx = &nctx->base;
+
+ if (nctx->fallback < SWRAST && ctx->DrawBuffer)
+ nouveau_state_emit(&nctx->base);
+}
+
GLboolean
nouveau_context_create(const __GLcontextModes *visual, __DRIcontext *dri_ctx,
void *share_ctx)
@@ -82,18 +94,19 @@ nouveau_context_init(GLcontext *ctx, struct nouveau_screen *screen,
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct dd_function_table functions;
+ int ret;
nctx->screen = screen;
nctx->fallback = HWTNL;
- /* Initialize the function pointers */
+ /* Initialize the function pointers. */
_mesa_init_driver_functions(&functions);
nouveau_driver_functions_init(&functions);
nouveau_bufferobj_functions_init(&functions);
nouveau_texture_functions_init(&functions);
nouveau_fbo_functions_init(&functions);
- /* Initialize the mesa context */
+ /* Initialize the mesa context. */
_mesa_initialize_context(ctx, visual, share_ctx, &functions, NULL);
nouveau_state_init(ctx);
@@ -105,26 +118,53 @@ nouveau_context_init(GLcontext *ctx, struct nouveau_screen *screen,
nouveau_span_functions_init(ctx);
_mesa_allow_light_in_model(ctx, GL_FALSE);
- /* Enable any supported extensions */
+ /* Allocate a hardware channel. */
+ ret = nouveau_channel_alloc(context_dev(ctx), 0xbeef0201, 0xbeef0202,
+ &nctx->hw.chan);
+ if (ret) {
+ nouveau_error("Error initializing the FIFO.\n");
+ return GL_FALSE;
+ }
+
+ nctx->hw.chan->flush_notify = nouveau_channel_flush_notify;
+ nctx->hw.chan->user_private = nctx;
+
+ /* Enable any supported extensions. */
driInitExtensions(ctx, nouveau_extensions, GL_TRUE);
return GL_TRUE;
}
void
+nouveau_context_deinit(GLcontext *ctx)
+{
+ struct nouveau_context *nctx = to_nouveau_context(ctx);
+
+ if (TNL_CONTEXT(ctx))
+ _tnl_DestroyContext(ctx);
+
+ if (vbo_context(ctx))
+ _vbo_DestroyContext(ctx);
+
+ if (SWRAST_CONTEXT(ctx))
+ _swrast_DestroyContext(ctx);
+
+ if (ctx->Meta)
+ _mesa_meta_free(ctx);
+
+ if (nctx->hw.chan)
+ nouveau_channel_free(&nctx->hw.chan);
+
+ nouveau_bo_state_destroy(ctx);
+ _mesa_free_context_data(ctx);
+}
+
+void
nouveau_context_destroy(__DRIcontext *dri_ctx)
{
struct nouveau_context *nctx = dri_ctx->driverPrivate;
GLcontext *ctx = &nctx->base;
- if (nctx->screen->context == nctx)
- nctx->screen->context = NULL;
-
- _tnl_DestroyContext(ctx);
- _vbo_DestroyContext(ctx);
- _swrast_DestroyContext(ctx);
- _mesa_meta_free(ctx);
- nouveau_bo_state_destroy(ctx);
context_drv(ctx)->context_destroy(ctx);
}
@@ -220,12 +260,10 @@ nouveau_context_make_current(__DRIcontext *dri_ctx, __DRIdrawable *dri_draw,
struct nouveau_context *nctx = dri_ctx->driverPrivate;
GLcontext *ctx = &nctx->base;
- if (nctx->screen->context == nctx)
+ if (dri_draw->driverPrivate == ctx->WinSysDrawBuffer &&
+ dri_read->driverPrivate == ctx->WinSysReadBuffer)
return GL_TRUE;
- nctx->screen->context = nctx;
- BITSET_ONES(nctx->dirty);
-
/* Ask the X server for new renderbuffers. */
nouveau_update_renderbuffers(dri_ctx, dri_draw,
&nctx->drawable.d_stamp);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index 9812963e1a8..efe3e5148b1 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -40,6 +40,22 @@ enum nouveau_fallback {
SWRAST,
};
+struct nouveau_hw_state {
+ struct nouveau_channel *chan;
+
+ struct nouveau_notifier *ntfy;
+ struct nouveau_grobj *eng3d;
+ struct nouveau_grobj *eng3dm;
+ struct nouveau_grobj *surf3d;
+ struct nouveau_grobj *m2mf;
+ struct nouveau_grobj *surf2d;
+ struct nouveau_grobj *rop;
+ struct nouveau_grobj *patt;
+ struct nouveau_grobj *rect;
+ struct nouveau_grobj *swzsurf;
+ struct nouveau_grobj *sifm;
+};
+
struct nouveau_drawable_state {
GLboolean dirty;
unsigned int d_stamp;
@@ -54,6 +70,7 @@ struct nouveau_context {
BITSET_DECLARE(dirty, MAX_NOUVEAU_STATE);
enum nouveau_fallback fallback;
+ struct nouveau_hw_state hw;
struct nouveau_bo_state bo;
struct nouveau_render_state render;
struct nouveau_drawable_state drawable;
@@ -66,9 +83,9 @@ struct nouveau_context {
#define context_chipset(ctx) \
(context_dev(ctx)->chipset)
#define context_chan(ctx) \
- (to_nouveau_context(ctx)->screen->chan)
+ (to_nouveau_context(ctx)->hw.chan)
#define context_eng3d(ctx) \
- (to_nouveau_context(ctx)->screen->eng3d)
+ (to_nouveau_context(ctx)->hw.eng3d)
#define context_drv(ctx) \
(to_nouveau_context(ctx)->screen->driver)
#define context_dirty(ctx, s) \
@@ -85,6 +102,9 @@ nouveau_context_init(GLcontext *ctx, struct nouveau_screen *screen,
const GLvisual *visual, GLcontext *share_ctx);
void
+nouveau_context_deinit(GLcontext *ctx);
+
+void
nouveau_context_destroy(__DRIcontext *dri_ctx);
GLboolean
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h
index 3b4d332d749..54bf981a0f5 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.h
@@ -51,8 +51,6 @@
#define DRIVER_AUTHOR "Nouveau"
struct nouveau_driver {
- void (*screen_destroy)(struct nouveau_screen *screen);
-
GLcontext *(*context_create)(struct nouveau_screen *screen,
const GLvisual *visual,
GLcontext *share_ctx);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 3f9f3a3567a..71e57e17e67 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -40,16 +40,6 @@ static const __DRIextension *nouveau_screen_extensions[];
static void
nouveau_destroy_screen(__DRIscreen *dri_screen);
-static void
-nouveau_channel_flush_notify(struct nouveau_channel *chan)
-{
- struct nouveau_screen *screen = chan->user_private;
- struct nouveau_context *nctx = screen->context;
-
- if (nctx && nctx->fallback < SWRAST)
- nouveau_state_emit(&nctx->base);
-}
-
static const __DRIconfig **
nouveau_get_configs(void)
{
@@ -118,39 +108,24 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
goto fail;
}
- ret = nouveau_channel_alloc(screen->device, 0xbeef0201, 0xbeef0202,
- &screen->chan);
- if (ret) {
- nouveau_error("Error initializing the FIFO.\n");
- goto fail;
- }
- screen->chan->flush_notify = nouveau_channel_flush_notify;
- screen->chan->user_private = screen;
-
- /* Do the card specific initialization */
+ /* Choose the card specific function pointers. */
switch (screen->device->chipset & 0xf0) {
case 0x00:
- ret = nv04_screen_init(screen);
+ screen->driver = &nv04_driver;
break;
case 0x10:
- ret = nv10_screen_init(screen);
+ screen->driver = &nv10_driver;
break;
case 0x20:
- ret = nv20_screen_init(screen);
+ screen->driver = &nv20_driver;
break;
default:
assert(0);
}
- if (!ret) {
- nouveau_error("Error initializing the hardware.\n");
- goto fail;
- }
configs = nouveau_get_configs();
- if (!configs) {
- nouveau_error("Error creating the framebuffer configs.\n");
+ if (!configs)
goto fail;
- }
return configs;
fail:
@@ -167,13 +142,6 @@ nouveau_destroy_screen(__DRIscreen *dri_screen)
if (!screen)
return;
- screen->driver->screen_destroy(screen);
-
- if (screen->chan) {
- screen->chan->flush_notify = NULL;
- nouveau_channel_free(&screen->chan);
- }
-
if (screen->device)
nouveau_device_close(&screen->device);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.h b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
index 5d45039b9ed..bcf57e21f28 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
@@ -31,24 +31,8 @@ struct nouveau_context;
struct nouveau_screen {
__DRIscreen *dri_screen;
-
struct nouveau_device *device;
- struct nouveau_channel *chan;
-
- struct nouveau_notifier *ntfy;
- struct nouveau_grobj *eng3d;
- struct nouveau_grobj *eng3dm;
- struct nouveau_grobj *surf3d;
- struct nouveau_grobj *m2mf;
- struct nouveau_grobj *surf2d;
- struct nouveau_grobj *rop;
- struct nouveau_grobj *patt;
- struct nouveau_grobj *rect;
- struct nouveau_grobj *swzsurf;
- struct nouveau_grobj *sifm;
-
const struct nouveau_driver *driver;
- struct nouveau_context *context;
};
#endif
diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c
index 5548286a73e..1056171342c 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Francisco Jerez.
+ * Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -35,16 +35,16 @@ struct nouveau_grobj *
nv04_context_engine(GLcontext *ctx)
{
struct nv04_context *nctx = to_nv04_context(ctx);
- struct nouveau_screen *screen = nctx->base.screen;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
struct nouveau_grobj *fahrenheit;
if (ctx->Texture.Unit[0].EnvMode == GL_COMBINE ||
ctx->Texture.Unit[0].EnvMode == GL_BLEND ||
ctx->Texture.Unit[1]._ReallyEnabled ||
ctx->Stencil.Enabled)
- fahrenheit = screen->eng3dm;
+ fahrenheit = hw->eng3dm;
else
- fahrenheit = screen->eng3d;
+ fahrenheit = hw->eng3d;
if (fahrenheit != nctx->eng3d) {
nctx->eng3d = fahrenheit;
@@ -69,6 +69,57 @@ nv04_context_engine(GLcontext *ctx)
}
static void
+nv04_channel_flush_notify(struct nouveau_channel *chan)
+{
+ struct nouveau_context *nctx = chan->user_private;
+ GLcontext *ctx = &nctx->base;
+
+ if (nctx->fallback < SWRAST && ctx->DrawBuffer) {
+ GLcontext *ctx = &nctx->base;
+
+ /* Flushing seems to clobber the engine context. */
+ context_dirty_i(ctx, TEX_OBJ, 0);
+ context_dirty_i(ctx, TEX_OBJ, 1);
+ context_dirty_i(ctx, TEX_ENV, 0);
+ context_dirty_i(ctx, TEX_ENV, 1);
+ context_dirty(ctx, CONTROL);
+ context_dirty(ctx, BLEND);
+
+ nouveau_state_emit(ctx);
+ }
+}
+
+static void
+nv04_hwctx_init(GLcontext *ctx)
+{
+ struct nouveau_channel *chan = context_chan(ctx);
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *surf3d = hw->surf3d;
+ struct nouveau_grobj *eng3d = hw->eng3d;
+ struct nouveau_grobj *eng3dm = hw->eng3dm;
+
+ BIND_RING(chan, surf3d, 7);
+ BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY, 3);
+ OUT_RING(chan, hw->ntfy->handle);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->vram->handle);
+
+ BEGIN_RING(chan, eng3d, NV04_TEXTURED_TRIANGLE_DMA_NOTIFY, 4);
+ OUT_RING(chan, hw->ntfy->handle);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->gart->handle);
+ OUT_RING(chan, surf3d->handle);
+
+ BEGIN_RING(chan, eng3dm, NV04_MULTITEX_TRIANGLE_DMA_NOTIFY, 4);
+ OUT_RING(chan, hw->ntfy->handle);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->gart->handle);
+ OUT_RING(chan, surf3d->handle);
+
+ FIRE_RING(chan);
+}
+
+static void
init_dummy_texture(GLcontext *ctx)
{
struct nouveau_surface *s = &to_nv04_context(ctx)->dummy_texture;
@@ -82,37 +133,158 @@ init_dummy_texture(GLcontext *ctx)
nouveau_bo_unmap(s->bo);
}
-GLcontext *
+static void
+nv04_context_destroy(GLcontext *ctx)
+{
+ struct nouveau_context *nctx = to_nouveau_context(ctx);
+
+ nv04_surface_takedown(ctx);
+ nv04_render_destroy(ctx);
+ nouveau_surface_ref(NULL, &to_nv04_context(ctx)->dummy_texture);
+
+ nouveau_grobj_free(&nctx->hw.eng3d);
+ nouveau_grobj_free(&nctx->hw.eng3dm);
+ nouveau_grobj_free(&nctx->hw.surf3d);
+
+ nouveau_context_deinit(ctx);
+ FREE(ctx);
+}
+
+static GLcontext *
nv04_context_create(struct nouveau_screen *screen, const GLvisual *visual,
GLcontext *share_ctx)
{
struct nv04_context *nctx;
+ struct nouveau_hw_state *hw;
GLcontext *ctx;
+ int ret;
nctx = CALLOC_STRUCT(nv04_context);
if (!nctx)
return NULL;
ctx = &nctx->base.base;
- nouveau_context_init(ctx, screen, visual, share_ctx);
+ hw = &nctx->base.hw;
+
+ if (!nouveau_context_init(ctx, screen, visual, share_ctx))
+ goto fail;
+ hw->chan->flush_notify = nv04_channel_flush_notify;
+
+ /* GL constants. */
ctx->Const.MaxTextureCoordUnits = NV04_TEXTURE_UNITS;
ctx->Const.MaxTextureImageUnits = NV04_TEXTURE_UNITS;
ctx->Const.MaxTextureUnits = NV04_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 2;
ctx->Const.MaxTextureLodBias = 15;
- init_dummy_texture(ctx);
+ /* 2D engine. */
+ ret = nv04_surface_init(ctx);
+ if (!ret)
+ goto fail;
+
+ /* 3D engine. */
+ ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001,
+ NV04_TEXTURED_TRIANGLE, &hw->eng3d);
+ if (ret)
+ goto fail;
+
+ ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0002,
+ NV04_MULTITEX_TRIANGLE, &hw->eng3dm);
+ if (ret)
+ goto fail;
+
+ ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0003,
+ NV04_CONTEXT_SURFACES_3D, &hw->surf3d);
+ if (ret)
+ goto fail;
+
+ nv04_hwctx_init(ctx);
nv04_render_init(ctx);
+ init_dummy_texture(ctx);
return ctx;
-}
-
-void
-nv04_context_destroy(GLcontext *ctx)
-{
- nv04_render_destroy(ctx);
- nouveau_surface_ref(NULL, &to_nv04_context(ctx)->dummy_texture);
- FREE(ctx);
+fail:
+ nv04_context_destroy(ctx);
+ return NULL;
}
+
+const struct nouveau_driver nv04_driver = {
+ .context_create = nv04_context_create,
+ .context_destroy = nv04_context_destroy,
+ .surface_copy = nv04_surface_copy,
+ .surface_fill = nv04_surface_fill,
+ .emit = (nouveau_state_func[]) {
+ nv04_defer_control,
+ nouveau_emit_nothing,
+ nv04_defer_blend,
+ nv04_defer_blend,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv04_defer_control,
+ nouveau_emit_nothing,
+ nv04_defer_control,
+ nouveau_emit_nothing,
+ nv04_defer_control,
+ nv04_defer_control,
+ nouveau_emit_nothing,
+ nv04_emit_framebuffer,
+ nv04_defer_blend,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv04_emit_scissor,
+ nv04_defer_blend,
+ nv04_defer_control,
+ nv04_defer_control,
+ nv04_defer_control,
+ nv04_emit_tex_env,
+ nv04_emit_tex_env,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv04_emit_tex_obj,
+ nv04_emit_tex_obj,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv04_emit_blend,
+ nv04_emit_control,
+ },
+ .num_emit = NUM_NV04_STATE,
+};
diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.h b/src/mesa/drivers/dri/nouveau/nv04_context.h
index ed4eec9865f..ccd3b61e267 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_context.h
+++ b/src/mesa/drivers/dri/nouveau/nv04_context.h
@@ -42,11 +42,6 @@ struct nv04_context {
struct nouveau_grobj *
nv04_context_engine(GLcontext *ctx);
-GLcontext *
-nv04_context_create(struct nouveau_screen *screen, const GLvisual *visual,
- GLcontext *share_ctx);
-
-void
-nv04_context_destroy(GLcontext *ctx);
+extern const struct nouveau_driver nv04_driver;
#endif
diff --git a/src/mesa/drivers/dri/nouveau/nv04_driver.h b/src/mesa/drivers/dri/nouveau/nv04_driver.h
index 00668710acc..4d599e683a6 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_driver.h
+++ b/src/mesa/drivers/dri/nouveau/nv04_driver.h
@@ -37,10 +37,6 @@ enum {
#define NV04_TEXTURE_UNITS 2
-/* nv04_screen.c */
-GLboolean
-nv04_screen_init(struct nouveau_screen *screen);
-
/* nv04_render.c */
void
nv04_render_init(GLcontext *ctx);
@@ -50,10 +46,10 @@ nv04_render_destroy(GLcontext *ctx);
/* nv04_surface.c */
GLboolean
-nv04_surface_init(struct nouveau_screen *screen);
+nv04_surface_init(GLcontext *ctx);
void
-nv04_surface_takedown(struct nouveau_screen *screen);
+nv04_surface_takedown(GLcontext *ctx);
void
nv04_surface_copy(GLcontext *ctx,
diff --git a/src/mesa/drivers/dri/nouveau/nv04_screen.c b/src/mesa/drivers/dri/nouveau/nv04_screen.c
deleted file mode 100644
index 0fc0f4c3911..00000000000
--- a/src/mesa/drivers/dri/nouveau/nv04_screen.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2009 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_screen.h"
-#include "nouveau_class.h"
-#include "nv04_driver.h"
-
-static const struct nouveau_driver nv04_driver;
-
-static void
-nv04_hwctx_init(struct nouveau_screen *screen)
-{
- struct nouveau_channel *chan = screen->chan;
- struct nouveau_grobj *surf3d = screen->surf3d;
- struct nouveau_grobj *eng3d = screen->eng3d;
- struct nouveau_grobj *eng3dm = screen->eng3dm;
-
- BIND_RING(chan, surf3d, 7);
- BEGIN_RING(chan, surf3d, NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY, 3);
- OUT_RING(chan, screen->ntfy->handle);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->vram->handle);
-
- BEGIN_RING(chan, eng3d, NV04_TEXTURED_TRIANGLE_DMA_NOTIFY, 4);
- OUT_RING(chan, screen->ntfy->handle);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->gart->handle);
- OUT_RING(chan, surf3d->handle);
-
- BEGIN_RING(chan, eng3dm, NV04_MULTITEX_TRIANGLE_DMA_NOTIFY, 4);
- OUT_RING(chan, screen->ntfy->handle);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->gart->handle);
- OUT_RING(chan, surf3d->handle);
-
- FIRE_RING(chan);
-}
-
-static void
-nv04_channel_flush_notify(struct nouveau_channel *chan)
-{
- struct nouveau_screen *screen = chan->user_private;
- struct nouveau_context *nctx = screen->context;
-
- if (nctx && nctx->fallback < SWRAST) {
- GLcontext *ctx = &nctx->base;
-
- /* Flushing seems to clobber the engine context. */
- context_dirty_i(ctx, TEX_OBJ, 0);
- context_dirty_i(ctx, TEX_OBJ, 1);
- context_dirty_i(ctx, TEX_ENV, 0);
- context_dirty_i(ctx, TEX_ENV, 1);
- context_dirty(ctx, CONTROL);
- context_dirty(ctx, BLEND);
-
- nouveau_state_emit(ctx);
- }
-}
-
-GLboolean
-nv04_screen_init(struct nouveau_screen *screen)
-{
- int ret;
-
- screen->driver = &nv04_driver;
- screen->chan->flush_notify = nv04_channel_flush_notify;
-
- /* 2D engine. */
- ret = nv04_surface_init(screen);
- if (!ret)
- return GL_FALSE;
-
- /* 3D engine. */
- ret = nouveau_grobj_alloc(screen->chan, 0xbeef0001,
- NV04_TEXTURED_TRIANGLE, &screen->eng3d);
- if (ret)
- return GL_FALSE;
-
- ret = nouveau_grobj_alloc(screen->chan, 0xbeef0002,
- NV04_MULTITEX_TRIANGLE, &screen->eng3dm);
- if (ret)
- return GL_FALSE;
-
- ret = nouveau_grobj_alloc(screen->chan, 0xbeef0003,
- NV04_CONTEXT_SURFACES_3D, &screen->surf3d);
- if (ret)
- return GL_FALSE;
-
- nv04_hwctx_init(screen);
-
- return GL_TRUE;
-}
-
-static void
-nv04_screen_destroy(struct nouveau_screen *screen)
-{
- if (screen->eng3d)
- nouveau_grobj_free(&screen->eng3d);
-
- if (screen->eng3dm)
- nouveau_grobj_free(&screen->eng3dm);
-
- if (screen->surf3d)
- nouveau_grobj_free(&screen->surf3d);
-
- nv04_surface_takedown(screen);
-}
-
-static const struct nouveau_driver nv04_driver = {
- .screen_destroy = nv04_screen_destroy,
- .context_create = nv04_context_create,
- .context_destroy = nv04_context_destroy,
- .surface_copy = nv04_surface_copy,
- .surface_fill = nv04_surface_fill,
- .emit = (nouveau_state_func[]) {
- nv04_defer_control,
- nouveau_emit_nothing,
- nv04_defer_blend,
- nv04_defer_blend,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv04_defer_control,
- nouveau_emit_nothing,
- nv04_defer_control,
- nouveau_emit_nothing,
- nv04_defer_control,
- nv04_defer_control,
- nouveau_emit_nothing,
- nv04_emit_framebuffer,
- nv04_defer_blend,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv04_emit_scissor,
- nv04_defer_blend,
- nv04_defer_control,
- nv04_defer_control,
- nv04_defer_control,
- nv04_emit_tex_env,
- nv04_emit_tex_env,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv04_emit_tex_obj,
- nv04_emit_tex_obj,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv04_emit_blend,
- nv04_emit_control,
- },
- .num_emit = NUM_NV04_STATE,
-};
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
index e97eb2a03b9..aad1e491d2f 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
@@ -50,8 +50,8 @@ void
nv04_emit_framebuffer(GLcontext *ctx, int emit)
{
struct nouveau_channel *chan = context_chan(ctx);
- struct nouveau_screen *screen = to_nouveau_context(ctx)->screen;
- struct nouveau_grobj *surf3d = screen->surf3d;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *surf3d = hw->surf3d;
struct nouveau_bo_context *bctx = context_bctx(ctx, FRAMEBUFFER);
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct nouveau_surface *s;
@@ -100,8 +100,8 @@ void
nv04_emit_scissor(GLcontext *ctx, int emit)
{
struct nouveau_channel *chan = context_chan(ctx);
- struct nouveau_screen *screen = to_nouveau_context(ctx)->screen;
- struct nouveau_grobj *surf3d = screen->surf3d;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *surf3d = hw->surf3d;
int x, y, w, h;
get_scissors(ctx->DrawBuffer, &x, &y, &w, &h);
diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c b/src/mesa/drivers/dri/nouveau/nv04_surface.c
index 0d403493452..86fa1dcd7a6 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_surface.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c
@@ -198,9 +198,9 @@ nv04_surface_copy_swizzle(GLcontext *ctx,
int w, int h)
{
struct nouveau_channel *chan = context_chan(ctx);
- struct nouveau_screen *screen = to_nouveau_context(ctx)->screen;
- struct nouveau_grobj *swzsurf = screen->swzsurf;
- struct nouveau_grobj *sifm = screen->sifm;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *swzsurf = hw->swzsurf;
+ struct nouveau_grobj *sifm = hw->sifm;
struct nouveau_bo_context *bctx = context_bctx(ctx, SURFACE);
const unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART;
/* Max width & height may not be the same on all HW, but must be POT */
@@ -283,8 +283,8 @@ nv04_surface_copy_m2mf(GLcontext *ctx,
int w, int h)
{
struct nouveau_channel *chan = context_chan(ctx);
- struct nouveau_screen *screen = to_nouveau_context(ctx)->screen;
- struct nouveau_grobj *m2mf = screen->m2mf;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *m2mf = hw->m2mf;
struct nouveau_bo_context *bctx = context_bctx(ctx, SURFACE);
const unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART;
unsigned dst_offset = dst->offset + dy * dst->pitch + dx * dst->cpp;
@@ -349,10 +349,10 @@ nv04_surface_fill(GLcontext *ctx,
int dx, int dy, int w, int h)
{
struct nouveau_channel *chan = context_chan(ctx);
- struct nouveau_screen *screen = to_nouveau_context(ctx)->screen;
- struct nouveau_grobj *surf2d = screen->surf2d;
- struct nouveau_grobj *patt = screen->patt;
- struct nouveau_grobj *rect = screen->rect;
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ struct nouveau_grobj *surf2d = hw->surf2d;
+ struct nouveau_grobj *patt = hw->patt;
+ struct nouveau_grobj *rect = hw->rect;
unsigned bo_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART;
MARK_RING (chan, 19, 4);
@@ -385,80 +385,78 @@ nv04_surface_fill(GLcontext *ctx,
}
void
-nv04_surface_takedown(struct nouveau_screen *screen)
+nv04_surface_takedown(GLcontext *ctx)
{
- nouveau_grobj_free(&screen->swzsurf);
- nouveau_grobj_free(&screen->sifm);
- nouveau_grobj_free(&screen->rect);
- nouveau_grobj_free(&screen->rop);
- nouveau_grobj_free(&screen->patt);
- nouveau_grobj_free(&screen->surf2d);
- nouveau_grobj_free(&screen->m2mf);
- nouveau_notifier_free(&screen->ntfy);
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+
+ nouveau_grobj_free(&hw->swzsurf);
+ nouveau_grobj_free(&hw->sifm);
+ nouveau_grobj_free(&hw->rect);
+ nouveau_grobj_free(&hw->rop);
+ nouveau_grobj_free(&hw->patt);
+ nouveau_grobj_free(&hw->surf2d);
+ nouveau_grobj_free(&hw->m2mf);
+ nouveau_notifier_free(&hw->ntfy);
}
GLboolean
-nv04_surface_init(struct nouveau_screen *screen)
+nv04_surface_init(GLcontext *ctx)
{
- struct nouveau_channel *chan = screen->chan;
- const unsigned chipset = screen->device->chipset;
+ struct nouveau_channel *chan = context_chan(ctx);
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
unsigned handle = 0x88000000, class;
int ret;
/* Notifier object. */
- ret = nouveau_notifier_alloc(chan, handle++, 1, &screen->ntfy);
+ ret = nouveau_notifier_alloc(chan, handle++, 1, &hw->ntfy);
if (ret)
goto fail;
/* Memory to memory format. */
ret = nouveau_grobj_alloc(chan, handle++, NV04_MEMORY_TO_MEMORY_FORMAT,
- &screen->m2mf);
+ &hw->m2mf);
if (ret)
goto fail;
- BEGIN_RING(chan, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->ntfy->handle);
+ BEGIN_RING(chan, hw->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
+ OUT_RING (chan, hw->ntfy->handle);
/* Context surfaces 2D. */
- if (chan->device->chipset < 0x10)
+ if (context_chipset(ctx) < 0x10)
class = NV04_CONTEXT_SURFACES_2D;
else
class = NV10_CONTEXT_SURFACES_2D;
- ret = nouveau_grobj_alloc(chan, handle++, class, &screen->surf2d);
+ ret = nouveau_grobj_alloc(chan, handle++, class, &hw->surf2d);
if (ret)
goto fail;
/* Raster op. */
- ret = nouveau_grobj_alloc(chan, handle++, NV03_CONTEXT_ROP,
- &screen->rop);
+ ret = nouveau_grobj_alloc(chan, handle++, NV03_CONTEXT_ROP, &hw->rop);
if (ret)
goto fail;
- BEGIN_RING(chan, screen->rop, NV03_CONTEXT_ROP_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->ntfy->handle);
+ BEGIN_RING(chan, hw->rop, NV03_CONTEXT_ROP_DMA_NOTIFY, 1);
+ OUT_RING (chan, hw->ntfy->handle);
- BEGIN_RING(chan, screen->rop, NV03_CONTEXT_ROP_ROP, 1);
+ BEGIN_RING(chan, hw->rop, NV03_CONTEXT_ROP_ROP, 1);
OUT_RING (chan, 0xca); /* DPSDxax in the GDI speech. */
/* Image pattern. */
ret = nouveau_grobj_alloc(chan, handle++, NV04_IMAGE_PATTERN,
- &screen->patt);
+ &hw->patt);
if (ret)
goto fail;
- BEGIN_RING(chan, screen->patt,
- NV04_IMAGE_PATTERN_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->ntfy->handle);
+ BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_DMA_NOTIFY, 1);
+ OUT_RING (chan, hw->ntfy->handle);
- BEGIN_RING(chan, screen->patt,
- NV04_IMAGE_PATTERN_MONOCHROME_FORMAT, 3);
+ BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT, 3);
OUT_RING (chan, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE);
OUT_RING (chan, NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8);
OUT_RING (chan, NV04_IMAGE_PATTERN_PATTERN_SELECT_MONO);
- BEGIN_RING(chan, screen->patt,
- NV04_IMAGE_PATTERN_MONOCHROME_COLOR0, 4);
+ BEGIN_RING(chan, hw->patt, NV04_IMAGE_PATTERN_MONOCHROME_COLOR0, 4);
OUT_RING (chan, 0);
OUT_RING (chan, 0);
OUT_RING (chan, ~0);
@@ -466,27 +464,27 @@ nv04_surface_init(struct nouveau_screen *screen)
/* GDI rectangle text. */
ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
- &screen->rect);
+ &hw->rect);
if (ret)
goto fail;
- BEGIN_RING(chan, screen->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->ntfy->handle);
- BEGIN_RING(chan, screen->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
- OUT_RING (chan, screen->surf2d->handle);
- BEGIN_RING(chan, screen->rect, NV04_GDI_RECTANGLE_TEXT_ROP, 1);
- OUT_RING (chan, screen->rop->handle);
- BEGIN_RING(chan, screen->rect, NV04_GDI_RECTANGLE_TEXT_PATTERN, 1);
- OUT_RING (chan, screen->patt->handle);
+ BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
+ OUT_RING (chan, hw->ntfy->handle);
+ BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
+ OUT_RING (chan, hw->surf2d->handle);
+ BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_ROP, 1);
+ OUT_RING (chan, hw->rop->handle);
+ BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_PATTERN, 1);
+ OUT_RING (chan, hw->patt->handle);
- BEGIN_RING(chan, screen->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
+ BEGIN_RING(chan, hw->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_ROP_AND);
- BEGIN_RING(chan, screen->rect,
+ BEGIN_RING(chan, hw->rect,
NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
/* Swizzled surface. */
- switch (chan->device->chipset & 0xf0) {
+ switch (context_chipset(ctx) & 0xf0) {
case 0x00:
case 0x10:
class = NV04_SWIZZLED_SURFACE;
@@ -494,47 +492,33 @@ nv04_surface_init(struct nouveau_screen *screen)
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, &screen->swzsurf);
+ ret = nouveau_grobj_alloc(chan, handle++, class, &hw->swzsurf);
if (ret)
goto fail;
/* Scaled image from memory. */
- switch (chan->device->chipset & 0xf0) {
+ switch (context_chipset(ctx) & 0xf0) {
+ case 0x00:
+ class = NV04_SCALED_IMAGE_FROM_MEMORY;
+ break;
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, &screen->sifm);
+ ret = nouveau_grobj_alloc(chan, handle++, class, &hw->sifm);
if (ret)
goto fail;
- if (chipset >= 0x10) {
- BEGIN_RING(chan, screen->sifm,
+ if (context_chipset(ctx) >= 0x10) {
+ BEGIN_RING(chan, hw->sifm,
NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 1);
OUT_RING(chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
}
@@ -542,6 +526,6 @@ nv04_surface_init(struct nouveau_screen *screen)
return GL_TRUE;
fail:
- nv04_surface_takedown(screen);
+ nv04_surface_takedown(ctx);
return GL_FALSE;
}
diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c
index d1afa87c8aa..d80d99caa80 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Francisco Jerez.
+ * Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -29,6 +29,7 @@
#include "nouveau_fbo.h"
#include "nouveau_util.h"
#include "nouveau_class.h"
+#include "nv04_driver.h"
#include "nv10_driver.h"
static void
@@ -56,20 +57,251 @@ nv10_clear(GLcontext *ctx, GLbitfield buffers)
nouveau_clear(ctx, buffers);
}
-GLcontext *
+static void
+nv10_hwctx_init(GLcontext *ctx)
+{
+ struct nouveau_channel *chan = context_chan(ctx);
+ struct nouveau_grobj *celsius = context_eng3d(ctx);
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ int i;
+
+ BEGIN_RING(chan, celsius, NV10TCL_DMA_NOTIFY, 1);
+ OUT_RING(chan, hw->ntfy->handle);
+
+ BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY0, 3);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->gart->handle);
+ OUT_RING(chan, chan->gart->handle);
+ BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY2, 2);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->vram->handle);
+
+ BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
+ OUT_RING(chan, 0x7ff << 16 | 0x800);
+ BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1);
+ OUT_RING(chan, 0x7ff << 16 | 0x800);
+
+ for (i = 1; i < 8; i++) {
+ BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1);
+ OUT_RING(chan, 0);
+ }
+
+ BEGIN_RING(chan, celsius, 0x290, 1);
+ OUT_RING(chan, 0x10 << 16 | 1);
+ BEGIN_RING(chan, celsius, 0x3f4, 1);
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+ OUT_RING(chan, 0);
+
+ if (context_chipset(ctx) >= 0x17) {
+ BEGIN_RING(chan, celsius, NV17TCL_DMA_IN_MEMORY4, 2);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->vram->handle);
+
+ BEGIN_RING(chan, celsius, 0xd84, 1);
+ OUT_RING(chan, 0x3);
+
+ BEGIN_RING(chan, celsius, NV17TCL_COLOR_MASK_ENABLE, 1);
+ OUT_RING(chan, 1);
+ }
+
+ if (context_chipset(ctx) >= 0x11) {
+ BEGIN_RING(chan, celsius, 0x120, 3);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 1);
+ OUT_RING(chan, 2);
+
+ BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+ OUT_RING(chan, 0);
+ }
+
+ BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+ OUT_RING(chan, 0);
+
+ /* Set state */
+ BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 2);
+ OUT_RING(chan, 0x207);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(0), 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 2);
+ OUT_RING(chan, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_SRC, 4);
+ OUT_RING(chan, 1);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0x8006);
+ BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 8);
+ OUT_RING(chan, 0xff);
+ OUT_RING(chan, 0x207);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0xff);
+ OUT_RING(chan, 0x1e00);
+ OUT_RING(chan, 0x1e00);
+ OUT_RING(chan, 0x1e00);
+ OUT_RING(chan, 0x1d01);
+ BEGIN_RING(chan, celsius, NV10TCL_NORMALIZE_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_SEPARATE_SPECULAR_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_ENABLED_LIGHTS, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
+ OUT_RING(chan, 0x201);
+ BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
+ OUT_RING(chan, 8);
+ BEGIN_RING(chan, celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_LINE_WIDTH, 1);
+ OUT_RING(chan, 8);
+ BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
+ OUT_RING(chan, 0x1b02);
+ OUT_RING(chan, 0x1b02);
+ BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
+ OUT_RING(chan, 0x405);
+ OUT_RING(chan, 0x901);
+ BEGIN_RING(chan, celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8);
+ for (i = 0; i < 8; i++)
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(0), 2);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
+ OUT_RING(chan, 0x3fc00000); /* -1.50 */
+ OUT_RING(chan, 0xbdb8aa0a); /* -0.09 */
+ OUT_RING(chan, 0); /* 0.00 */
+
+ BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, celsius, NV10TCL_FOG_MODE, 2);
+ OUT_RING(chan, 0x802);
+ OUT_RING(chan, 2);
+ /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when
+ * using texturing, except when using the texture matrix
+ */
+ BEGIN_RING(chan, celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1);
+ OUT_RING(chan, 6);
+ BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
+ OUT_RING(chan, 0x01010101);
+
+ /* Set vertex component */
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL_4F_R, 4);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL2_3F_R, 3);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_NOR_3F_X, 3);
+ OUT_RING(chan, 0);
+ OUT_RING(chan, 0);
+ OUT_RINGf(chan, 1.0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX0_4F_S, 4);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX1_4F_S, 4);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ BEGIN_RING(chan, celsius, NV10TCL_VERTEX_FOG_1F, 1);
+ OUT_RINGf(chan, 0.0);
+ BEGIN_RING(chan, celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
+ OUT_RING(chan, 1);
+
+ BEGIN_RING(chan, celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
+ OUT_RING(chan, 0.0);
+ OUT_RINGf(chan, 16777216.0);
+
+ FIRE_RING(chan);
+}
+
+static void
+nv10_context_destroy(GLcontext *ctx)
+{
+ struct nouveau_context *nctx = to_nouveau_context(ctx);
+
+ nv04_surface_takedown(ctx);
+ nv10_render_destroy(ctx);
+
+ nouveau_grobj_free(&nctx->hw.eng3d);
+
+ nouveau_context_deinit(ctx);
+ FREE(ctx);
+}
+
+static GLcontext *
nv10_context_create(struct nouveau_screen *screen, const GLvisual *visual,
GLcontext *share_ctx)
{
struct nouveau_context *nctx;
GLcontext *ctx;
+ unsigned celsius_class;
+ int ret;
nctx = CALLOC_STRUCT(nouveau_context);
if (!nctx)
return NULL;
ctx = &nctx->base;
- nouveau_context_init(ctx, screen, visual, share_ctx);
+ if (!nouveau_context_init(ctx, screen, visual, share_ctx))
+ goto fail;
+
+ /* GL constants. */
ctx->Const.MaxTextureLevels = 12;
ctx->Const.MaxTextureCoordUnits = NV10_TEXTURE_UNITS;
ctx->Const.MaxTextureImageUnits = NV10_TEXTURE_UNITS;
@@ -78,14 +310,107 @@ nv10_context_create(struct nouveau_screen *screen, const GLvisual *visual,
ctx->Const.MaxTextureLodBias = 15;
ctx->Driver.Clear = nv10_clear;
+ /* 2D engine. */
+ ret = nv04_surface_init(ctx);
+ if (!ret)
+ goto fail;
+
+ /* 3D engine. */
+ if (context_chipset(ctx) >= 0x17)
+ celsius_class = NV17TCL;
+ else if (context_chipset(ctx) >= 0x11)
+ celsius_class = NV11TCL;
+ else
+ celsius_class = NV10TCL;
+
+ ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001, celsius_class,
+ &nctx->hw.eng3d);
+ if (ret)
+ goto fail;
+
+ nv10_hwctx_init(ctx);
nv10_render_init(ctx);
return ctx;
-}
-void
-nv10_context_destroy(GLcontext *ctx)
-{
- nv10_render_destroy(ctx);
- FREE(ctx);
+fail:
+ nv10_context_destroy(ctx);
+ return NULL;
}
+
+const struct nouveau_driver nv10_driver = {
+ .context_create = nv10_context_create,
+ .context_destroy = nv10_context_destroy,
+ .surface_copy = nv04_surface_copy,
+ .surface_fill = nv04_surface_fill,
+ .emit = (nouveau_state_func[]) {
+ nv10_emit_alpha_func,
+ nv10_emit_blend_color,
+ nv10_emit_blend_equation,
+ nv10_emit_blend_func,
+ nv10_emit_clip_plane,
+ nv10_emit_clip_plane,
+ nv10_emit_clip_plane,
+ nv10_emit_clip_plane,
+ nv10_emit_clip_plane,
+ nv10_emit_clip_plane,
+ nv10_emit_color_mask,
+ nv10_emit_color_material,
+ nv10_emit_cull_face,
+ nv10_emit_front_face,
+ nv10_emit_depth,
+ nv10_emit_dither,
+ nv10_emit_frag,
+ nv10_emit_framebuffer,
+ nv10_emit_fog,
+ nv10_emit_index_mask,
+ nv10_emit_light_enable,
+ nv10_emit_light_model,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_light_source,
+ nv10_emit_line_stipple,
+ nv10_emit_line_mode,
+ nv10_emit_logic_opcode,
+ nv10_emit_material_ambient,
+ nouveau_emit_nothing,
+ nv10_emit_material_diffuse,
+ nouveau_emit_nothing,
+ nv10_emit_material_specular,
+ nouveau_emit_nothing,
+ nv10_emit_material_shininess,
+ nouveau_emit_nothing,
+ nv10_emit_modelview,
+ nv10_emit_point_mode,
+ nv10_emit_point_parameter,
+ nv10_emit_polygon_mode,
+ nv10_emit_polygon_offset,
+ nv10_emit_polygon_stipple,
+ nv10_emit_projection,
+ nv10_emit_render_mode,
+ nv10_emit_scissor,
+ nv10_emit_shade_model,
+ nv10_emit_stencil_func,
+ nv10_emit_stencil_mask,
+ nv10_emit_stencil_op,
+ nv10_emit_tex_env,
+ nv10_emit_tex_env,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv10_emit_tex_gen,
+ nv10_emit_tex_gen,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv10_emit_tex_obj,
+ nv10_emit_tex_obj,
+ nouveau_emit_nothing,
+ nouveau_emit_nothing,
+ nv10_emit_viewport
+ },
+ .num_emit = NUM_NOUVEAU_STATE,
+};
diff --git a/src/mesa/drivers/dri/nouveau/nv10_driver.h b/src/mesa/drivers/dri/nouveau/nv10_driver.h
index 2a1ef7b08e9..4c220b0373f 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_driver.h
+++ b/src/mesa/drivers/dri/nouveau/nv10_driver.h
@@ -29,17 +29,8 @@
#define NV10_TEXTURE_UNITS 2
-/* nv10_screen.c */
-GLboolean
-nv10_screen_init(struct nouveau_screen *screen);
-
/* nv10_context.c */
-GLcontext *
-nv10_context_create(struct nouveau_screen *screen, const GLvisual *visual,
- GLcontext *share_ctx);
-
-void
-nv10_context_destroy(GLcontext *ctx);
+extern const struct nouveau_driver nv10_driver;
/* nv10_render.c */
void
diff --git a/src/mesa/drivers/dri/nouveau/nv10_screen.c b/src/mesa/drivers/dri/nouveau/nv10_screen.c
deleted file mode 100644
index 8665ad14107..00000000000
--- a/src/mesa/drivers/dri/nouveau/nv10_screen.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (C) 2009 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_screen.h"
-#include "nouveau_class.h"
-#include "nv04_driver.h"
-#include "nv10_driver.h"
-
-static const struct nouveau_driver nv10_driver;
-
-static void
-nv10_hwctx_init(struct nouveau_screen *screen)
-{
- struct nouveau_channel *chan = screen->chan;
- struct nouveau_grobj *celsius = screen->eng3d;
- const unsigned chipset = screen->device->chipset;
- int i;
-
- BEGIN_RING(chan, celsius, NV10TCL_DMA_NOTIFY, 1);
- OUT_RING(chan, screen->ntfy->handle);
-
- BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY0, 3);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->gart->handle);
- OUT_RING(chan, chan->gart->handle);
- BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY2, 2);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->vram->handle);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
- OUT_RING(chan, 0x7ff << 16 | 0x800);
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1);
- OUT_RING(chan, 0x7ff << 16 | 0x800);
-
- for (i = 1; i < 8; i++) {
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1);
- OUT_RING(chan, 0);
- }
-
- BEGIN_RING(chan, celsius, 0x290, 1);
- OUT_RING(chan, 0x10 << 16 | 1);
- BEGIN_RING(chan, celsius, 0x3f4, 1);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING(chan, 0);
-
- if (chipset >= 0x17) {
- BEGIN_RING(chan, celsius, NV17TCL_DMA_IN_MEMORY4, 2);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->vram->handle);
-
- BEGIN_RING(chan, celsius, 0xd84, 1);
- OUT_RING(chan, 0x3);
-
- BEGIN_RING(chan, celsius, NV17TCL_COLOR_MASK_ENABLE, 1);
- OUT_RING(chan, 1);
- }
-
- if (chipset >= 0x11) {
- BEGIN_RING(chan, celsius, 0x120, 3);
- OUT_RING(chan, 0);
- OUT_RING(chan, 1);
- OUT_RING(chan, 2);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING(chan, 0);
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING(chan, 0);
-
- /* Set state */
- BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 2);
- OUT_RING(chan, 0x207);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(0), 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 2);
- OUT_RING(chan, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_SRC, 4);
- OUT_RING(chan, 1);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0x8006);
- BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 8);
- OUT_RING(chan, 0xff);
- OUT_RING(chan, 0x207);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0xff);
- OUT_RING(chan, 0x1e00);
- OUT_RING(chan, 0x1e00);
- OUT_RING(chan, 0x1e00);
- OUT_RING(chan, 0x1d01);
- BEGIN_RING(chan, celsius, NV10TCL_NORMALIZE_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_SEPARATE_SPECULAR_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ENABLED_LIGHTS, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
- OUT_RING(chan, 0x201);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
- OUT_RING(chan, 8);
- BEGIN_RING(chan, celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_WIDTH, 1);
- OUT_RING(chan, 8);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING(chan, 0x1b02);
- OUT_RING(chan, 0x1b02);
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
- OUT_RING(chan, 0x405);
- OUT_RING(chan, 0x901);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8);
- for (i = 0; i < 8; i++)
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(0), 2);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
- OUT_RING(chan, 0x3fc00000); /* -1.50 */
- OUT_RING(chan, 0xbdb8aa0a); /* -0.09 */
- OUT_RING(chan, 0); /* 0.00 */
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_FOG_MODE, 2);
- OUT_RING(chan, 0x802);
- OUT_RING(chan, 2);
- /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when
- * using texturing, except when using the texture matrix
- */
- BEGIN_RING(chan, celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1);
- OUT_RING(chan, 6);
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
- OUT_RING(chan, 0x01010101);
-
- /* Set vertex component */
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL_4F_R, 4);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL2_3F_R, 3);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_NOR_3F_X, 3);
- OUT_RING(chan, 0);
- OUT_RING(chan, 0);
- OUT_RINGf(chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX0_4F_S, 4);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX1_4F_S, 4);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_FOG_1F, 1);
- OUT_RINGf(chan, 0.0);
- BEGIN_RING(chan, celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
- OUT_RING(chan, 1);
-
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
- OUT_RING(chan, 0.0);
- OUT_RINGf(chan, 16777216.0);
-
- FIRE_RING(chan);
-}
-
-GLboolean
-nv10_screen_init(struct nouveau_screen *screen)
-{
- unsigned chipset = screen->device->chipset;
- unsigned celsius_class;
- int ret;
-
- screen->driver = &nv10_driver;
-
- /* 2D engine. */
- ret = nv04_surface_init(screen);
- if (!ret)
- return GL_FALSE;
-
- /* 3D engine. */
- if (chipset >= 0x17)
- celsius_class = NV17TCL;
- else if (chipset >= 0x11)
- celsius_class = NV11TCL;
- else
- celsius_class = NV10TCL;
-
- ret = nouveau_grobj_alloc(screen->chan, 0xbeef0001, celsius_class,
- &screen->eng3d);
- if (ret)
- return GL_FALSE;
-
- nv10_hwctx_init(screen);
-
- return GL_TRUE;
-}
-
-static void
-nv10_screen_destroy(struct nouveau_screen *screen)
-{
- if (screen->eng3d)
- nouveau_grobj_free(&screen->eng3d);
-
- nv04_surface_takedown(screen);
-}
-
-static const struct nouveau_driver nv10_driver = {
- .screen_destroy = nv10_screen_destroy,
- .context_create = nv10_context_create,
- .context_destroy = nv10_context_destroy,
- .surface_copy = nv04_surface_copy,
- .surface_fill = nv04_surface_fill,
- .emit = (nouveau_state_func[]) {
- nv10_emit_alpha_func,
- nv10_emit_blend_color,
- nv10_emit_blend_equation,
- nv10_emit_blend_func,
- nv10_emit_clip_plane,
- nv10_emit_clip_plane,
- nv10_emit_clip_plane,
- nv10_emit_clip_plane,
- nv10_emit_clip_plane,
- nv10_emit_clip_plane,
- nv10_emit_color_mask,
- nv10_emit_color_material,
- nv10_emit_cull_face,
- nv10_emit_front_face,
- nv10_emit_depth,
- nv10_emit_dither,
- nv10_emit_frag,
- nv10_emit_framebuffer,
- nv10_emit_fog,
- nv10_emit_index_mask,
- nv10_emit_light_enable,
- nv10_emit_light_model,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_light_source,
- nv10_emit_line_stipple,
- nv10_emit_line_mode,
- nv10_emit_logic_opcode,
- nv10_emit_material_ambient,
- nouveau_emit_nothing,
- nv10_emit_material_diffuse,
- nouveau_emit_nothing,
- nv10_emit_material_specular,
- nouveau_emit_nothing,
- nv10_emit_material_shininess,
- nouveau_emit_nothing,
- nv10_emit_modelview,
- nv10_emit_point_mode,
- nv10_emit_point_parameter,
- nv10_emit_polygon_mode,
- nv10_emit_polygon_offset,
- nv10_emit_polygon_stipple,
- nv10_emit_projection,
- nv10_emit_render_mode,
- nv10_emit_scissor,
- nv10_emit_shade_model,
- nv10_emit_stencil_func,
- nv10_emit_stencil_mask,
- nv10_emit_stencil_op,
- nv10_emit_tex_env,
- nv10_emit_tex_env,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv10_emit_tex_gen,
- nv10_emit_tex_gen,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv10_emit_tex_obj,
- nv10_emit_tex_obj,
- nouveau_emit_nothing,
- nouveau_emit_nothing,
- nv10_emit_viewport
- },
- .num_emit = NUM_NOUVEAU_STATE,
-};
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c
index 698b83431be..82a13fb6ff0 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Francisco Jerez.
+ * Copyright (C) 2009-2010 Francisco Jerez.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -26,36 +26,481 @@
#include "nouveau_driver.h"
#include "nouveau_context.h"
+#include "nouveau_class.h"
+#include "nv04_driver.h"
+#include "nv10_driver.h"
#include "nv20_driver.h"
-GLcontext *
+static void
+nv20_hwctx_init(GLcontext *ctx)
+{
+ struct nouveau_channel *chan = context_chan(ctx);
+ struct nouveau_grobj *kelvin = context_eng3d(ctx);
+ struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw;
+ int i;
+
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_NOTIFY, 1);
+ OUT_RING (chan, hw->ntfy->handle);
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_TEXTURE0, 2);
+ OUT_RING (chan, chan->vram->handle);
+ OUT_RING (chan, chan->gart->handle);
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 2);
+ OUT_RING (chan, chan->vram->handle);
+ OUT_RING (chan, chan->vram->handle);
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_VTXBUF0, 2);
+ OUT_RING(chan, chan->vram->handle);
+ OUT_RING(chan, chan->gart->handle);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_QUERY, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
+ OUT_RING (chan, 0xfff << 16 | 0x0);
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1);
+ OUT_RING (chan, 0xfff << 16 | 0x0);
+
+ for (i = 1; i < NV20TCL_VIEWPORT_CLIP_HORIZ__SIZE; i++) {
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1);
+ OUT_RING (chan, 0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, 0x17e0, 3);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 1.0);
+
+ if (context_chipset(ctx) >= 0x25) {
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
+ OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL | 0xdb0);
+ } else {
+ BEGIN_RING(chan, kelvin, 0x1e68, 1);
+ OUT_RING (chan, 0x4b800000); /* 16777216.000000 */
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
+ OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL);
+ }
+
+ BEGIN_RING(chan, kelvin, 0x290, 1);
+ OUT_RING (chan, 0x10 << 16 | 1);
+ BEGIN_RING(chan, kelvin, 0x9fc, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, 0x1d80, 1);
+ OUT_RING (chan, 1);
+ BEGIN_RING(chan, kelvin, 0x9f8, 1);
+ OUT_RING (chan, 4);
+ BEGIN_RING(chan, kelvin, 0x17ec, 3);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 1.0);
+ OUT_RINGf (chan, 0.0);
+
+ if (context_chipset(ctx) >= 0x25) {
+ BEGIN_RING(chan, kelvin, 0x1d88, 1);
+ OUT_RING (chan, 3);
+
+ BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
+ OUT_RING (chan, chan->vram->handle);
+ BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
+ OUT_RING (chan, chan->vram->handle);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_DMA_FENCE, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, 0x1e98, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_NOTIFY, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, 0x120, 3);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 1);
+ OUT_RING (chan, 2);
+
+ if (context_chipset(ctx) >= 0x25) {
+ BEGIN_RING(chan, kelvin, 0x022c, 2);
+ OUT_RING (chan, 0x280);
+ OUT_RING (chan, 0x07d28000);
+
+ BEGIN_RING(chan, kelvin, 0x1da4, 1);
+ OUT_RING (chan, 0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
+ OUT_RING (chan, 0 << 16 | 0);
+ OUT_RING (chan, 0 << 16 | 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2);
+ OUT_RING (chan, NV20TCL_ALPHA_FUNC_FUNC_ALWAYS);
+ OUT_RING (chan, 0);
+
+ for (i = 0; i < NV20TCL_TX_ENABLE__SIZE; i++) {
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1);
+ OUT_RING (chan, 0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_OP, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_ALPHA(0), 4);
+ OUT_RING (chan, 0x30d410d0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_RGB(0), 4);
+ OUT_RING (chan, 0x00000c00);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_ENABLE, 1);
+ OUT_RING (chan, 0x00011101);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_FINAL0, 2);
+ OUT_RING (chan, 0x130e0300);
+ OUT_RING (chan, 0x0c091c80);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_ALPHA(0), 4);
+ OUT_RING (chan, 0x00000c00);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_RGB(0), 4);
+ OUT_RING (chan, 0x20c400c0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_COLOR0, 2);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4);
+ OUT_RING (chan, 0x035125a0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0x40002000);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1);
+ OUT_RING (chan, 0xffff0000);
+ BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 4);
+ OUT_RING (chan, NV20TCL_BLEND_FUNC_SRC_ONE);
+ OUT_RING (chan, NV20TCL_BLEND_FUNC_DST_ZERO);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, NV20TCL_BLEND_EQUATION_FUNC_ADD);
+ BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
+ OUT_RING (chan, 0xff);
+ OUT_RING (chan, NV20TCL_STENCIL_FUNC_FUNC_ALWAYS);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0xff);
+ OUT_RING (chan, NV20TCL_STENCIL_OP_FAIL_KEEP);
+ OUT_RING (chan, NV20TCL_STENCIL_OP_ZFAIL_KEEP);
+ OUT_RING (chan, NV20TCL_STENCIL_OP_ZPASS_KEEP);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, NV20TCL_COLOR_LOGIC_OP_OP_COPY);
+ BEGIN_RING(chan, kelvin, 0x17cc, 1);
+ OUT_RING (chan, 0);
+ if (context_chipset(ctx) >= 0x25) {
+ BEGIN_RING(chan, kelvin, 0x1d84, 1);
+ OUT_RING (chan, 1);
+ }
+ BEGIN_RING(chan, kelvin, NV20TCL_LIGHTING_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL, 1);
+ OUT_RING (chan, NV20TCL_LIGHT_MODEL_VIEWER_NONLOCAL);
+ BEGIN_RING(chan, kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_ENABLED_LIGHTS, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_NORMALIZE_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0),
+ NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE);
+ for (i = 0; i < NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE; i++) {
+ OUT_RING(chan, 0xffffffff);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
+ OUT_RING (chan, NV20TCL_DEPTH_FUNC_LESS);
+ BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 0.0);
+ BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
+ OUT_RING (chan, 1);
+ if (context_chipset(ctx) < 0x25) {
+ BEGIN_RING(chan, kelvin, 0x1d84, 1);
+ OUT_RING (chan, 3);
+ }
+ BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
+ if (context_chipset(ctx) >= 0x25)
+ OUT_RINGf (chan, 1.0);
+ else
+ OUT_RING (chan, 8);
+
+ if (context_chipset(ctx) >= 0x25) {
+ BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, 0x0a1c, 1);
+ OUT_RING (chan, 0x800);
+ } else {
+ BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_LINE_WIDTH, 1);
+ OUT_RING (chan, 8);
+ BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
+ OUT_RING (chan, NV20TCL_POLYGON_MODE_FRONT_FILL);
+ OUT_RING (chan, NV20TCL_POLYGON_MODE_BACK_FILL);
+ BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
+ OUT_RING (chan, NV20TCL_CULL_FACE_BACK);
+ OUT_RING (chan, NV20TCL_FRONT_FACE_CCW);
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
+ OUT_RING (chan, 0);
+ BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 1);
+ OUT_RING (chan, NV20TCL_SHADE_MODEL_SMOOTH);
+ BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0),
+ 4 * NV20TCL_TX_GEN_S__SIZE);
+ for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; i++)
+ OUT_RING(chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
+ OUT_RINGf (chan, 1.5);
+ OUT_RINGf (chan, -0.090168);
+ OUT_RINGf (chan, 0.0);
+ BEGIN_RING(chan, kelvin, NV20TCL_FOG_MODE, 2);
+ OUT_RING (chan, NV20TCL_FOG_MODE_EXP_SIGNED);
+ OUT_RING (chan, NV20TCL_FOG_COORD_FOG);
+ BEGIN_RING(chan, kelvin, NV20TCL_FOG_ENABLE, 2);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_ENGINE, 1);
+ OUT_RING (chan, NV20TCL_ENGINE_FIXED);
+
+ for (i = 0; i < NV20TCL_TX_MATRIX_ENABLE__SIZE; i++) {
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+ OUT_RING (chan, 0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 1.0);
+ OUT_RINGf(chan, 1.0);
+ for (i = 0; i < 12; i++) {
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 0.0);
+ OUT_RINGf(chan, 1.0);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_EDGEFLAG_ENABLE, 1);
+ OUT_RING (chan, 1);
+ BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
+ OUT_RING (chan, 0x00010101);
+ BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1);
+ OUT_RING (chan, 0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 16777216.0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 16777215.0);
+
+ BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_SCALE_X, 4);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 0.0);
+ OUT_RINGf (chan, 16777215.0 * 0.5);
+ OUT_RINGf (chan, 65535.0);
+
+ FIRE_RING(chan);
+}
+
+static void
+nv20_context_destroy(GLcontext *ctx)
+{
+ struct nouveau_context *nctx = to_nouveau_context(ctx);
+
+ nv04_surface_takedown(ctx);
+ nv20_render_destroy(ctx);
+
+ nouveau_grobj_free(&nctx->hw.eng3d);
+
+ nouveau_context_deinit(ctx);
+ FREE(ctx);
+}
+
+static GLcontext *
nv20_context_create(struct nouveau_screen *screen, const GLvisual *visual,
GLcontext *share_ctx)
{
struct nouveau_context *nctx;
GLcontext *ctx;
+ unsigned kelvin_class;
+ int ret;
nctx = CALLOC_STRUCT(nouveau_context);
if (!nctx)
return NULL;
ctx = &nctx->base;
- nouveau_context_init(ctx, screen, visual, share_ctx);
+ if (!nouveau_context_init(ctx, screen, visual, share_ctx))
+ goto fail;
+
+ /* GL constants. */
ctx->Const.MaxTextureCoordUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureImageUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 8;
ctx->Const.MaxTextureLodBias = 15;
+ /* 2D engine. */
+ ret = nv04_surface_init(ctx);
+ if (!ret)
+ goto fail;
+
+ /* 3D engine. */
+ if (context_chipset(ctx) >= 0x25)
+ kelvin_class = NV25TCL;
+ else
+ kelvin_class = NV20TCL;
+
+ ret = nouveau_grobj_alloc(context_chan(ctx), 0xbeef0001, kelvin_class,
+ &nctx->hw.eng3d);
+ if (ret)
+ goto fail;
+
+ nv20_hwctx_init(ctx);
nv20_render_init(ctx);
return ctx;
-}
-void
-nv20_context_destroy(GLcontext *ctx)
-{
- nv20_render_destroy(ctx);
- FREE(ctx);
+fail:
+ nv20_context_destroy(ctx);
+ return NULL;
}
+
+const struct nouveau_driver nv20_driver = {
+ .context_create = nv20_context_create,
+ .context_destroy = nv20_context_destroy,
+ .surface_copy = nv04_surface_copy,
+ .surface_fill = nv04_surface_fill,
+ .emit = (nouveau_state_func[]) {
+ nv10_emit_alpha_func,
+ nv10_emit_blend_color,
+ nv10_emit_blend_equation,
+ nv10_emit_blend_func,
+ nv20_emit_clip_plane,
+ nv20_emit_clip_plane,
+ nv20_emit_clip_plane,
+ nv20_emit_clip_plane,
+ nv20_emit_clip_plane,
+ nv20_emit_clip_plane,
+ nv10_emit_color_mask,
+ nv20_emit_color_material,
+ nv10_emit_cull_face,
+ nv10_emit_front_face,
+ nv10_emit_depth,
+ nv10_emit_dither,
+ nv10_emit_frag,
+ nv20_emit_framebuffer,
+ nv20_emit_fog,
+ nv10_emit_index_mask,
+ nv10_emit_light_enable,
+ nv20_emit_light_model,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv20_emit_light_source,
+ nv10_emit_line_stipple,
+ nv10_emit_line_mode,
+ nv20_emit_logic_opcode,
+ nv20_emit_material_ambient,
+ nv20_emit_material_ambient,
+ nv20_emit_material_diffuse,
+ nv20_emit_material_diffuse,
+ nv20_emit_material_specular,
+ nv20_emit_material_specular,
+ nv20_emit_material_shininess,
+ nv20_emit_material_shininess,
+ nv20_emit_modelview,
+ nv20_emit_point_mode,
+ nv10_emit_point_parameter,
+ nv10_emit_polygon_mode,
+ nv10_emit_polygon_offset,
+ nv10_emit_polygon_stipple,
+ nv20_emit_projection,
+ nv10_emit_render_mode,
+ nv10_emit_scissor,
+ nv10_emit_shade_model,
+ nv10_emit_stencil_func,
+ nv10_emit_stencil_mask,
+ nv10_emit_stencil_op,
+ nv10_emit_tex_env,
+ nv10_emit_tex_env,
+ nv10_emit_tex_env,
+ nv10_emit_tex_env,
+ nv10_emit_tex_gen,
+ nv10_emit_tex_gen,
+ nv10_emit_tex_gen,
+ nv10_emit_tex_gen,
+ nv20_emit_tex_obj,
+ nv20_emit_tex_obj,
+ nv20_emit_tex_obj,
+ nv20_emit_tex_obj,
+ nv20_emit_viewport,
+ nv20_emit_tex_shader
+ },
+ .num_emit = NUM_NV20_STATE,
+};
diff --git a/src/mesa/drivers/dri/nouveau/nv20_driver.h b/src/mesa/drivers/dri/nouveau/nv20_driver.h
index 2de18ee4af1..f82a292cf7a 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_driver.h
+++ b/src/mesa/drivers/dri/nouveau/nv20_driver.h
@@ -34,17 +34,8 @@ enum {
#define NV20_TEXTURE_UNITS 4
-/* nv20_screen.c */
-GLboolean
-nv20_screen_init(struct nouveau_screen *screen);
-
/* nv20_context.c */
-GLcontext *
-nv20_context_create(struct nouveau_screen *screen, const GLvisual *visual,
- GLcontext *share_ctx);
-
-void
-nv20_context_destroy(GLcontext *ctx);
+extern const struct nouveau_driver nv20_driver;
/* nv20_render.c */
void
diff --git a/src/mesa/drivers/dri/nouveau/nv20_screen.c b/src/mesa/drivers/dri/nouveau/nv20_screen.c
deleted file mode 100644
index 1d29fc9976c..00000000000
--- a/src/mesa/drivers/dri/nouveau/nv20_screen.c
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Copyright (C) 2009 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_screen.h"
-#include "nouveau_class.h"
-#include "nv04_driver.h"
-#include "nv10_driver.h"
-#include "nv20_driver.h"
-
-static const struct nouveau_driver nv20_driver;
-
-static void
-nv20_hwctx_init(struct nouveau_screen *screen)
-{
- struct nouveau_channel *chan = screen->chan;
- struct nouveau_grobj *kelvin = screen->eng3d;
- const unsigned chipset = screen->device->chipset;
- int i;
-
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->ntfy->handle);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_TEXTURE0, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->gart->handle);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->vram->handle);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_VTXBUF0, 2);
- OUT_RING(chan, chan->vram->handle);
- OUT_RING(chan, chan->gart->handle);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_QUERY, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
- OUT_RING (chan, 0xfff << 16 | 0x0);
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1);
- OUT_RING (chan, 0xfff << 16 | 0x0);
-
- for (i = 1; i < NV20TCL_VIEWPORT_CLIP_HORIZ__SIZE; i++) {
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, 0x17e0, 3);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
-
- if (chipset >= 0x25) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
- OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL | 0xdb0);
- } else {
- BEGIN_RING(chan, kelvin, 0x1e68, 1);
- OUT_RING (chan, 0x4b800000); /* 16777216.000000 */
- BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
- OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL);
- }
-
- BEGIN_RING(chan, kelvin, 0x290, 1);
- OUT_RING (chan, 0x10 << 16 | 1);
- BEGIN_RING(chan, kelvin, 0x9fc, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, 0x1d80, 1);
- OUT_RING (chan, 1);
- BEGIN_RING(chan, kelvin, 0x9f8, 1);
- OUT_RING (chan, 4);
- BEGIN_RING(chan, kelvin, 0x17ec, 3);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
- OUT_RINGf (chan, 0.0);
-
- if (chipset >= 0x25) {
- BEGIN_RING(chan, kelvin, 0x1d88, 1);
- OUT_RING (chan, 3);
-
- BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
- OUT_RING (chan, chan->vram->handle);
- BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
- OUT_RING (chan, chan->vram->handle);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_FENCE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, 0x1e98, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_NOTIFY, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, 0x120, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 2);
-
- if (chipset >= 0x25) {
- BEGIN_RING(chan, kelvin, 0x022c, 2);
- OUT_RING (chan, 0x280);
- OUT_RING (chan, 0x07d28000);
-
- BEGIN_RING(chan, kelvin, 0x1da4, 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
- OUT_RING (chan, 0 << 16 | 0);
- OUT_RING (chan, 0 << 16 | 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2);
- OUT_RING (chan, NV20TCL_ALPHA_FUNC_FUNC_ALWAYS);
- OUT_RING (chan, 0);
-
- for (i = 0; i < NV20TCL_TX_ENABLE__SIZE; i++) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_OP, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_ALPHA(0), 4);
- OUT_RING (chan, 0x30d410d0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_RGB(0), 4);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_ENABLE, 1);
- OUT_RING (chan, 0x00011101);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_FINAL0, 2);
- OUT_RING (chan, 0x130e0300);
- OUT_RING (chan, 0x0c091c80);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_ALPHA(0), 4);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_RGB(0), 4);
- OUT_RING (chan, 0x20c400c0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_COLOR0, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4);
- OUT_RING (chan, 0x035125a0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x40002000);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1);
- OUT_RING (chan, 0xffff0000);
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 4);
- OUT_RING (chan, NV20TCL_BLEND_FUNC_SRC_ONE);
- OUT_RING (chan, NV20TCL_BLEND_FUNC_DST_ZERO);
- OUT_RING (chan, 0);
- OUT_RING (chan, NV20TCL_BLEND_EQUATION_FUNC_ADD);
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
- OUT_RING (chan, 0xff);
- OUT_RING (chan, NV20TCL_STENCIL_FUNC_FUNC_ALWAYS);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0xff);
- OUT_RING (chan, NV20TCL_STENCIL_OP_FAIL_KEEP);
- OUT_RING (chan, NV20TCL_STENCIL_OP_ZFAIL_KEEP);
- OUT_RING (chan, NV20TCL_STENCIL_OP_ZPASS_KEEP);
-
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, NV20TCL_COLOR_LOGIC_OP_OP_COPY);
- BEGIN_RING(chan, kelvin, 0x17cc, 1);
- OUT_RING (chan, 0);
- if (chipset >= 0x25) {
- BEGIN_RING(chan, kelvin, 0x1d84, 1);
- OUT_RING (chan, 1);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHTING_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL, 1);
- OUT_RING (chan, NV20TCL_LIGHT_MODEL_VIEWER_NONLOCAL);
- BEGIN_RING(chan, kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_ENABLED_LIGHTS, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_NORMALIZE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0),
- NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE);
- for (i = 0; i < NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE; i++) {
- OUT_RING(chan, 0xffffffff);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
- OUT_RING (chan, NV20TCL_DEPTH_FUNC_LESS);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
- OUT_RING (chan, 1);
- if (chipset < 0x25) {
- BEGIN_RING(chan, kelvin, 0x1d84, 1);
- OUT_RING (chan, 3);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
- if (chipset >= 0x25)
- OUT_RINGf (chan, 1.0);
- else
- OUT_RING (chan, 8);
-
- if (chipset >= 0x25) {
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, 0x0a1c, 1);
- OUT_RING (chan, 0x800);
- } else {
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_LINE_WIDTH, 1);
- OUT_RING (chan, 8);
- BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING (chan, NV20TCL_POLYGON_MODE_FRONT_FILL);
- OUT_RING (chan, NV20TCL_POLYGON_MODE_BACK_FILL);
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
- OUT_RING (chan, NV20TCL_CULL_FACE_BACK);
- OUT_RING (chan, NV20TCL_FRONT_FACE_CCW);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 1);
- OUT_RING (chan, NV20TCL_SHADE_MODEL_SMOOTH);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0),
- 4 * NV20TCL_TX_GEN_S__SIZE);
- for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; i++)
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
- OUT_RINGf (chan, 1.5);
- OUT_RINGf (chan, -0.090168);
- OUT_RINGf (chan, 0.0);
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_MODE, 2);
- OUT_RING (chan, NV20TCL_FOG_MODE_EXP_SIGNED);
- OUT_RING (chan, NV20TCL_FOG_COORD_FOG);
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_ENGINE, 1);
- OUT_RING (chan, NV20TCL_ENGINE_FIXED);
-
- for (i = 0; i < NV20TCL_TX_MATRIX_ENABLE__SIZE; i++) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0);
- for (i = 0; i < 12; i++) {
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_EDGEFLAG_ENABLE, 1);
- OUT_RING (chan, 1);
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
- OUT_RING (chan, 0x00010101);
- BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 16777216.0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 16777215.0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_SCALE_X, 4);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 16777215.0 * 0.5);
- OUT_RINGf (chan, 65535.0);
-
- FIRE_RING(chan);
-}
-
-GLboolean
-nv20_screen_init(struct nouveau_screen *screen)
-{
- unsigned chipset = screen->device->chipset;
- unsigned kelvin_class;
- int ret;
-
- screen->driver = &nv20_driver;
-
- /* 2D engine */
- ret = nv04_surface_init(screen);
- if (!ret)
- return GL_FALSE;
-
- /* 3D engine. */
- if (chipset >= 0x25)
- kelvin_class = NV25TCL;
- else
- kelvin_class = NV20TCL;
-
- ret = nouveau_grobj_alloc(screen->chan, 0xbeef0001, kelvin_class,
- &screen->eng3d);
- if (ret)
- return GL_FALSE;
-
- nv20_hwctx_init(screen);
-
- return GL_TRUE;
-}
-
-static void
-nv20_screen_destroy(struct nouveau_screen *screen)
-{
- if (screen->eng3d)
- nouveau_grobj_free(&screen->eng3d);
-
- nv04_surface_takedown(screen);
-}
-
-static const struct nouveau_driver nv20_driver = {
- .screen_destroy = nv20_screen_destroy,
- .context_create = nv20_context_create,
- .context_destroy = nv20_context_destroy,
- .surface_copy = nv04_surface_copy,
- .surface_fill = nv04_surface_fill,
- .emit = (nouveau_state_func[]) {
- nv10_emit_alpha_func,
- nv10_emit_blend_color,
- nv10_emit_blend_equation,
- nv10_emit_blend_func,
- nv20_emit_clip_plane,
- nv20_emit_clip_plane,
- nv20_emit_clip_plane,
- nv20_emit_clip_plane,
- nv20_emit_clip_plane,
- nv20_emit_clip_plane,
- nv10_emit_color_mask,
- nv20_emit_color_material,
- nv10_emit_cull_face,
- nv10_emit_front_face,
- nv10_emit_depth,
- nv10_emit_dither,
- nv10_emit_frag,
- nv20_emit_framebuffer,
- nv20_emit_fog,
- nv10_emit_index_mask,
- nv10_emit_light_enable,
- nv20_emit_light_model,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv20_emit_light_source,
- nv10_emit_line_stipple,
- nv10_emit_line_mode,
- nv20_emit_logic_opcode,
- nv20_emit_material_ambient,
- nv20_emit_material_ambient,
- nv20_emit_material_diffuse,
- nv20_emit_material_diffuse,
- nv20_emit_material_specular,
- nv20_emit_material_specular,
- nv20_emit_material_shininess,
- nv20_emit_material_shininess,
- nv20_emit_modelview,
- nv20_emit_point_mode,
- nv10_emit_point_parameter,
- nv10_emit_polygon_mode,
- nv10_emit_polygon_offset,
- nv10_emit_polygon_stipple,
- nv20_emit_projection,
- nv10_emit_render_mode,
- nv10_emit_scissor,
- nv10_emit_shade_model,
- nv10_emit_stencil_func,
- nv10_emit_stencil_mask,
- nv10_emit_stencil_op,
- nv10_emit_tex_env,
- nv10_emit_tex_env,
- nv10_emit_tex_env,
- nv10_emit_tex_env,
- nv10_emit_tex_gen,
- nv10_emit_tex_gen,
- nv10_emit_tex_gen,
- nv10_emit_tex_gen,
- nv20_emit_tex_obj,
- nv20_emit_tex_obj,
- nv20_emit_tex_obj,
- nv20_emit_tex_obj,
- nv20_emit_viewport,
- nv20_emit_tex_shader
- },
- .num_emit = NUM_NV20_STATE,
-};