summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/nv50/nv50_context.c61
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h11
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c49
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.h5
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c4
5 files changed, 67 insertions, 63 deletions
diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c
index c937b8de6d4..980d066c844 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -10,10 +10,11 @@ static void
nv50_flush(struct pipe_context *pipe, unsigned flags)
{
struct nv50_context *nv50 = (struct nv50_context *)pipe;
- struct nouveau_winsys *nvws = nv50->nvws;
+ struct nv50_screen *screen = nv50->screen;
+ struct nouveau_winsys *nvws = screen->nvws;
if (flags & PIPE_FLUSH_WAIT) {
- nvws->notifier_reset(nv50->sync, 0);
+ nvws->notifier_reset(screen->sync, 0);
BEGIN_RING(tesla, 0x104, 1);
OUT_RING (0);
BEGIN_RING(tesla, 0x100, 1);
@@ -23,7 +24,7 @@ nv50_flush(struct pipe_context *pipe, unsigned flags)
FIRE_RING();
if (flags & PIPE_FLUSH_WAIT)
- nvws->notifier_wait(nv50->sync, 0, 0, 2000);
+ nvws->notifier_wait(screen->sync, 0, 0, 2000);
}
static void
@@ -35,66 +36,18 @@ nv50_destroy(struct pipe_context *pipe)
free(nv50);
}
-static boolean
-nv50_init_hwctx(struct nv50_context *nv50, int tesla_class)
-{
- struct nouveau_winsys *nvws = nv50->nvws;
- int ret;
-
- if ((ret = nvws->grobj_alloc(nvws, tesla_class, &nv50->tesla))) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return FALSE;
- }
-
- BEGIN_RING(tesla, NV50TCL_DMA_NOTIFY, 1);
- OUT_RING (nv50->sync->handle);
-
- FIRE_RING ();
- return TRUE;
-}
-
-#define GRCLASS5097_CHIPSETS 0x00000000
-#define GRCLASS8297_CHIPSETS 0x00000010
struct pipe_context *
nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
struct pipe_winsys *pipe_winsys = pscreen->winsys;
- struct nouveau_winsys *nvws = nv50_screen(pscreen)->nvws;
- unsigned chipset = nv50_screen(pscreen)->chipset;
+ struct nv50_screen *screen = nv50_screen(pscreen);
struct nv50_context *nv50;
- int tesla_class, ret;
-
- if ((chipset & 0xf0) != 0x50 && (chipset & 0xf0) != 0x80) {
- NOUVEAU_ERR("Not a G8x chipset\n");
- return NULL;
- }
-
- if (GRCLASS5097_CHIPSETS & (1 << (chipset & 0x0f))) {
- tesla_class = 0x5097;
- } else
- if (GRCLASS8297_CHIPSETS & (1 << (chipset & 0x0f))) {
- tesla_class = 0x8297;
- } else {
- NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
- return NULL;
- }
nv50 = CALLOC_STRUCT(nv50_context);
if (!nv50)
return NULL;
- nv50->chipset = chipset;
- nv50->nvws = nvws;
-
- if ((ret = nvws->notifier_alloc(nvws, 1, &nv50->sync))) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- free(nv50);
- return NULL;
- }
-
- if (!nv50_init_hwctx(nv50, tesla_class)) {
- free(nv50);
- return NULL;
- }
+ nv50->screen = screen;
+ nv50->pctx_id = pctx_id;
nv50->pipe.winsys = pipe_winsys;
nv50->pipe.screen = pscreen;
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index a529bf3c3e3..e2656bd539b 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -11,10 +11,11 @@
#include "nouveau/nouveau_gldefs.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
- struct nv50_context *ctx = nv50
+ struct nv50_screen *ctx = nv50->screen
#include "nouveau/nouveau_push.h"
#include "nv50_state.h"
+#include "nv50_screen.h"
#define NOUVEAU_ERR(fmt, args...) \
fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
@@ -23,13 +24,11 @@
struct nv50_context {
struct pipe_context pipe;
- struct nouveau_winsys *nvws;
- struct draw_context *draw;
+ struct nv50_screen *screen;
+ unsigned pctx_id;
- int chipset;
- struct nouveau_grobj *tesla;
- struct nouveau_notifier *sync;
+ struct draw_context *draw;
};
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 77ceb678f21..f8fd11dc5ff 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -4,6 +4,11 @@
#include "nv50_context.h"
#include "nv50_screen.h"
+#include "nouveau/nouveau_stateobj.h"
+
+#define GRCLASS5097_CHIPSETS 0x00000000
+#define GRCLASS8297_CHIPSETS 0x00000010
+
static boolean
nv50_screen_is_format_supported(struct pipe_screen *pscreen,
enum pipe_format format, uint type)
@@ -96,13 +101,55 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
unsigned chipset)
{
struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen);
+ struct nouveau_stateobj *so;
+ unsigned tesla_class = 0, ret;
if (!screen)
return NULL;
-
screen->chipset = chipset;
screen->nvws = nvws;
+ /* 3D object */
+ if ((chipset & 0xf0) != 0x50 && (chipset & 0xf0) != 0x80) {
+ NOUVEAU_ERR("Not a G8x chipset\n");
+ nv50_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ if (GRCLASS5097_CHIPSETS & (1 << (chipset & 0x0f))) {
+ tesla_class = 0x5097;
+ } else
+ if (GRCLASS8297_CHIPSETS & (1 << (chipset & 0x0f))) {
+ tesla_class = 0x8297;
+ } else {
+ NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
+ nv50_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla);
+ if (ret) {
+ NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
+ nv50_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ /* Sync notifier */
+ ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+ if (ret) {
+ NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
+ nv50_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ /* Static tesla init */
+ so = so_new(128, 0);
+ so_method(so, screen->tesla, NV50TCL_DMA_NOTIFY, 1);
+ so_data (so, screen->sync->handle);
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ nvws->push_flush(nvws->channel, 0);
+
screen->pipe.winsys = ws;
screen->pipe.destroy = nv50_screen_destroy;
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
index d664816a031..6e4120d6693 100644
--- a/src/gallium/drivers/nv50/nv50_screen.h
+++ b/src/gallium/drivers/nv50/nv50_screen.h
@@ -8,6 +8,11 @@ struct nv50_screen {
struct nouveau_winsys *nvws;
unsigned chipset;
+
+ unsigned cur_pctx;
+
+ struct nouveau_grobj *tesla;
+ struct nouveau_notifier *sync;
};
static INLINE struct nv50_screen *
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index 39cf675a57c..4e294198b07 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -40,7 +40,7 @@ nv50_surface_copy(struct pipe_context *pipe, unsigned flip,
unsigned width, unsigned height)
{
struct nv50_context *nv50 = (struct nv50_context *)pipe;
- struct nouveau_winsys *nvws = nv50->nvws;
+ struct nouveau_winsys *nvws = nv50->screen->nvws;
nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
width, height);
@@ -52,7 +52,7 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
unsigned height, unsigned value)
{
struct nv50_context *nv50 = (struct nv50_context *)pipe;
- struct nouveau_winsys *nvws = nv50->nvws;
+ struct nouveau_winsys *nvws = nv50->screen->nvws;
nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
}