summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c185
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h71
-rw-r--r--src/gallium/drivers/nv30/nv30_query.c23
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.c202
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.h17
-rw-r--r--src/gallium/drivers/nv30/nv30_vertprog.c31
6 files changed, 303 insertions, 226 deletions
diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
index b8e8b86d99..d38713e98a 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -26,198 +26,36 @@ static void
nv30_destroy(struct pipe_context *pipe)
{
struct nv30_context *nv30 = nv30_context(pipe);
- struct nouveau_winsys *nvws = nv30->nvws;
if (nv30->draw)
draw_destroy(nv30->draw);
-
- nvws->res_free(&nv30->vertprog.exec_heap);
- nvws->res_free(&nv30->vertprog.data_heap);
-
- nvws->res_free(&nv30->query_heap);
- nvws->notifier_free(&nv30->query);
-
- nvws->notifier_free(&nv30->sync);
-
- nvws->grobj_free(&nv30->rankine);
-
FREE(nv30);
}
-static boolean
-nv30_init_hwctx(struct nv30_context *nv30, int rankine_class)
-{
- struct nouveau_winsys *nvws = nv30->nvws;
- int ret;
- int i;
-
- ret = nvws->grobj_alloc(nvws, rankine_class, &nv30->rankine);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return FALSE;
- }
-
- BEGIN_RING(rankine, NV34TCL_DMA_NOTIFY, 1);
- OUT_RING (nv30->sync->handle);
- BEGIN_RING(rankine, NV34TCL_DMA_TEXTURE0, 2);
- OUT_RING (nvws->channel->vram->handle);
- OUT_RING (nvws->channel->gart->handle);
- BEGIN_RING(rankine, NV34TCL_DMA_COLOR1, 1);
- OUT_RING (nvws->channel->vram->handle);
- BEGIN_RING(rankine, NV34TCL_DMA_COLOR0, 2);
- OUT_RING (nvws->channel->vram->handle);
- OUT_RING (nvws->channel->vram->handle);
- BEGIN_RING(rankine, NV34TCL_DMA_VTXBUF0, 2);
- OUT_RING (nvws->channel->vram->handle);
- OUT_RING (nvws->channel->gart->handle);
-/* BEGIN_RING(rankine, NV34TCL_DMA_FENCE, 2);
- OUT_RING (0);
- OUT_RING (nv30->query->handle);*/
- BEGIN_RING(rankine, NV34TCL_DMA_IN_MEMORY7, 1);
- OUT_RING (nvws->channel->vram->handle);
- BEGIN_RING(rankine, NV34TCL_DMA_IN_MEMORY8, 1);
- OUT_RING (nvws->channel->vram->handle);
-
- for (i=1; i<8; i++) {
- BEGIN_RING(rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
- OUT_RING (0);
- BEGIN_RING(rankine, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
- OUT_RING (0);
- }
-
- BEGIN_RING(rankine, 0x220, 1);
- OUT_RING (1);
-
- BEGIN_RING(rankine, 0x03b0, 1);
- OUT_RING (0x00100000);
- BEGIN_RING(rankine, 0x1454, 1);
- OUT_RING (0);
- BEGIN_RING(rankine, 0x1d80, 1);
- OUT_RING (3);
- BEGIN_RING(rankine, 0x1450, 1);
- OUT_RING (0x00030004);
-
- /* NEW */
- BEGIN_RING(rankine, 0x1e98, 1);
- OUT_RING (0);
- BEGIN_RING(rankine, 0x17e0, 3);
- OUT_RING (0);
- OUT_RING (0);
- OUT_RING (0x3f800000);
- BEGIN_RING(rankine, 0x1f80, 16);
- OUT_RING (0); OUT_RING (0); OUT_RING (0); OUT_RING (0);
- OUT_RING (0); OUT_RING (0); OUT_RING (0); OUT_RING (0);
- OUT_RING (0x0000ffff);
- OUT_RING (0); OUT_RING (0); OUT_RING (0); OUT_RING (0);
- OUT_RING (0); OUT_RING (0); OUT_RING (0);
-
- BEGIN_RING(rankine, 0x120, 3);
- OUT_RING (0);
- OUT_RING (1);
- OUT_RING (2);
-
- BEGIN_RING(rankine, 0x1d88, 1);
- OUT_RING (0x00001200);
-
- BEGIN_RING(rankine, NV34TCL_RC_ENABLE, 1);
- OUT_RING (0);
-
- BEGIN_RING(rankine, NV34TCL_DEPTH_RANGE_NEAR, 2);
- OUT_RINGf (0.0);
- OUT_RINGf (1.0);
-
- BEGIN_RING(rankine, NV34TCL_MULTISAMPLE_CONTROL, 1);
- OUT_RING (0xffff0000);
-
- /* enables use of vp rather than fixed-function somehow */
- BEGIN_RING(rankine, 0x1e94, 1);
- OUT_RING (0x13);
-
- FIRE_RING (NULL);
- return TRUE;
-}
-
-#define NV30TCL_CHIPSET_3X_MASK 0x00000003
-#define NV34TCL_CHIPSET_3X_MASK 0x00000010
-#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
-
struct pipe_context *
-nv30_create(struct pipe_screen *screen, unsigned pctx_id)
+nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
- struct pipe_winsys *pipe_winsys = screen->winsys;
- struct nouveau_winsys *nvws = nv30_screen(screen)->nvws;
- unsigned chipset = nv30_screen(screen)->chipset;
+ struct nv30_screen *screen = nv30_screen(pscreen);
+ struct pipe_winsys *ws = pscreen->winsys;
struct nv30_context *nv30;
- int rankine_class = 0, ret;
+ unsigned chipset = screen->chipset;
+ struct nouveau_winsys *nvws = screen->nvws;
- if ((chipset & 0xf0) != 0x30) {
- NOUVEAU_ERR("Not a NV3X chipset\n");
- return NULL;
- }
-
- if (NV30TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) {
- rankine_class = 0x0397;
- } else if (NV34TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) {
- rankine_class = 0x0697;
- } else if (NV35TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) {
- rankine_class = 0x0497;
- } else {
- NOUVEAU_ERR("Unknown NV3X chipset: NV%02x\n", chipset);
- return NULL;
- }
-
- nv30 = CALLOC_STRUCT(nv30_context);
+ nv30 = CALLOC(1, sizeof(struct nv30_context));
if (!nv30)
return NULL;
+ nv30->screen = screen;
+ nv30->pctx_id = pctx_id;
+
nv30->chipset = chipset;
nv30->nvws = nvws;
- /* Notifier for sync purposes */
- ret = nvws->notifier_alloc(nvws, 1, &nv30->sync);
- if (ret) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- nv30_destroy(&nv30->pipe);
- return NULL;
- }
-
- /* Query objects */
- ret = nvws->notifier_alloc(nvws, 32, &nv30->query);
- if (ret) {
- NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
- nv30_destroy(&nv30->pipe);
- return NULL;
- }
-
- ret = nvws->res_init(&nv30->query_heap, 0, 32);
- if (ret) {
- NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
- nv30_destroy(&nv30->pipe);
- return NULL;
- }
-
- /* Vtxprog resources */
- if (nvws->res_init(&nv30->vertprog.exec_heap, 0, 256) ||
- nvws->res_init(&nv30->vertprog.data_heap, 0, 256)) {
- nv30_destroy(&nv30->pipe);
- return NULL;
- }
-
- /* Static rankine initialisation */
- if (!nv30_init_hwctx(nv30, rankine_class)) {
- nv30_destroy(&nv30->pipe);
- return NULL;
- }
-
- /* Pipe context setup */
- nv30->pipe.winsys = pipe_winsys;
- nv30->pipe.screen = screen;
-
+ nv30->pipe.winsys = ws;
+ nv30->pipe.screen = pscreen;
nv30->pipe.destroy = nv30_destroy;
-
nv30->pipe.draw_arrays = nv30_draw_arrays;
nv30->pipe.draw_elements = nv30_draw_elements;
nv30->pipe.clear = nv30_clear;
-
nv30->pipe.flush = nv30_flush;
nv30_init_query_functions(nv30);
@@ -226,7 +64,6 @@ nv30_create(struct pipe_screen *screen, unsigned pctx_id)
nv30_init_miptree_functions(nv30);
nv30->draw = draw_create();
- assert(nv30->draw);
draw_set_rasterize_stage(nv30->draw, nv30_draw_render_stage(nv30));
return &nv30->pipe;
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index c1cc3eca1e..180969731b 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -11,8 +11,9 @@
#include "nouveau/nouveau_gldefs.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
- struct nv30_context *ctx = nv30
+ struct nv30_screen *ctx = nv30->screen
#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_stateobj.h"
#include "nv30_state.h"
@@ -21,23 +22,70 @@
#define NOUVEAU_MSG(fmt, args...) \
fprintf(stderr, "nouveau: "fmt, ##args);
-#define NV30_NEW_VERTPROG (1 << 1)
-#define NV30_NEW_FRAGPROG (1 << 2)
-#define NV30_NEW_ARRAYS (1 << 3)
+enum nv30_state_index {
+ NV30_STATE_FB = 0,
+ NV30_STATE_VIEWPORT = 1,
+ NV30_STATE_BLEND = 2,
+ NV30_STATE_RAST = 3,
+ NV30_STATE_ZSA = 4,
+ NV30_STATE_BCOL = 5,
+ NV30_STATE_CLIP = 6,
+ NV30_STATE_SCISSOR = 7,
+ NV30_STATE_STIPPLE = 8,
+ NV30_STATE_FRAGPROG = 9,
+ NV30_STATE_VERTPROG = 10,
+ NV30_STATE_FRAGTEX0 = 11,
+ NV30_STATE_FRAGTEX1 = 12,
+ NV30_STATE_FRAGTEX2 = 13,
+ NV30_STATE_FRAGTEX3 = 14,
+ NV30_STATE_FRAGTEX4 = 15,
+ NV30_STATE_FRAGTEX5 = 16,
+ NV30_STATE_FRAGTEX6 = 17,
+ NV30_STATE_FRAGTEX7 = 18,
+ NV30_STATE_FRAGTEX8 = 19,
+ NV30_STATE_FRAGTEX9 = 20,
+ NV30_STATE_FRAGTEX10 = 21,
+ NV30_STATE_FRAGTEX11 = 22,
+ NV30_STATE_FRAGTEX12 = 23,
+ NV30_STATE_FRAGTEX13 = 24,
+ NV30_STATE_FRAGTEX14 = 25,
+ NV30_STATE_FRAGTEX15 = 26,
+ NV30_STATE_VERTTEX0 = 27,
+ NV30_STATE_VERTTEX1 = 28,
+ NV30_STATE_VERTTEX2 = 29,
+ NV30_STATE_VERTTEX3 = 30,
+ NV30_STATE_VTXBUF = 31,
+ NV30_STATE_VTXFMT = 32,
+ NV30_STATE_VTXATTR = 33,
+ NV30_STATE_MAX = 34
+};
+
+#include "nv30_screen.h"
+
+#define NV30_NEW_BLEND (1 << 0)
+#define NV30_NEW_RAST (1 << 1)
+#define NV30_NEW_ZSA (1 << 2)
+#define NV30_NEW_SAMPLER (1 << 3)
+#define NV30_NEW_FB (1 << 4)
+#define NV30_NEW_STIPPLE (1 << 5)
+#define NV30_NEW_SCISSOR (1 << 6)
+#define NV30_NEW_VIEWPORT (1 << 7)
+#define NV30_NEW_BCOL (1 << 8)
+#define NV30_NEW_VERTPROG (1 << 9)
+#define NV30_NEW_FRAGPROG (1 << 10)
+#define NV30_NEW_ARRAYS (1 << 11)
+#define NV30_NEW_UCP (1 << 12)
struct nv30_context {
struct pipe_context pipe;
+
struct nouveau_winsys *nvws;
+ struct nv30_screen *screen;
+ unsigned pctx_id;
struct draw_context *draw;
int chipset;
- struct nouveau_grobj *rankine;
- struct nouveau_notifier *sync;
-
- /* query objects */
- struct nouveau_notifier *query;
- struct nouveau_resource *query_heap;
uint32_t dirty;
@@ -63,9 +111,6 @@ struct nv30_context {
} vb[16];
struct {
- struct nouveau_resource *exec_heap;
- struct nouveau_resource *data_heap;
-
struct nv30_vertex_program *active;
struct nv30_vertex_program *current;
diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
index 0c2d941562..d40d75f264 100644
--- a/src/gallium/drivers/nv30/nv30_query.c
+++ b/src/gallium/drivers/nv30/nv30_query.c
@@ -1,5 +1,4 @@
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
#include "nv30_context.h"
@@ -10,7 +9,7 @@ struct nv30_query {
uint64_t result;
};
-static inline struct nv30_query *
+static INLINE struct nv30_query *
nv30_query(struct pipe_query *pipe)
{
return (struct nv30_query *)pipe;
@@ -46,9 +45,18 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
- if (nv30->nvws->res_alloc(nv30->query_heap, 1, NULL, &q->object))
+ /* Happens when end_query() is called, then another begin_query()
+ * without querying the result in-between. For now we'll wait for
+ * the existing query to notify completion, but it could be better.
+ */
+ if (q->object) {
+ uint64 tmp;
+ pipe->get_query_result(pipe, pq, 1, &tmp);
+ }
+
+ if (nv30->nvws->res_alloc(nv30->screen->query_heap, 1, NULL, &q->object))
assert(0);
- nv30->nvws->notifier_reset(nv30->query, q->object->start);
+ nv30->nvws->notifier_reset(nv30->screen->query, q->object->start);
BEGIN_RING(rankine, NV34TCL_QUERY_RESET, 1);
OUT_RING (1);
@@ -83,16 +91,17 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
if (!q->ready) {
unsigned status;
- status = nvws->notifier_status(nv30->query, q->object->start);
+ status = nvws->notifier_status(nv30->screen->query,
+ q->object->start);
if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
if (wait == FALSE)
return FALSE;
- nvws->notifier_wait(nv30->query, q->object->start,
+ nvws->notifier_wait(nv30->screen->query, q->object->start,
NV_NOTIFY_STATE_STATUS_COMPLETED,
0);
}
- q->result = nvws->notifier_retval(nv30->query,
+ q->result = nvws->notifier_retval(nv30->screen->query,
q->object->start);
q->ready = TRUE;
nvws->res_free(&q->object);
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index c7487b37bc..ce6c9ec523 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -4,24 +4,28 @@
#include "nv30_context.h"
#include "nv30_screen.h"
+#define NV30TCL_CHIPSET_3X_MASK 0x00000003
+#define NV34TCL_CHIPSET_3X_MASK 0x00000010
+#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
+
static const char *
-nv30_screen_get_name(struct pipe_screen *screen)
+nv30_screen_get_name(struct pipe_screen *pscreen)
{
- struct nv30_screen *nv30screen = nv30_screen(screen);
+ struct nv30_screen *screen = nv30_screen(pscreen);
static char buffer[128];
- snprintf(buffer, sizeof(buffer), "NV%02X", nv30screen->chipset);
+ snprintf(buffer, sizeof(buffer), "NV%02X", screen->chipset);
return buffer;
}
static const char *
-nv30_screen_get_vendor(struct pipe_screen *screen)
+nv30_screen_get_vendor(struct pipe_screen *pscreen)
{
return "nouveau";
}
static int
-nv30_screen_get_param(struct pipe_screen *screen, int param)
+nv30_screen_get_param(struct pipe_screen *pscreen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
@@ -60,7 +64,7 @@ nv30_screen_get_param(struct pipe_screen *screen, int param)
}
static float
-nv30_screen_get_paramf(struct pipe_screen *screen, int param)
+nv30_screen_get_paramf(struct pipe_screen *pscreen, int param)
{
switch (param) {
case PIPE_CAP_MAX_LINE_WIDTH:
@@ -82,8 +86,8 @@ nv30_screen_get_paramf(struct pipe_screen *screen, int param)
}
static boolean
-nv30_screen_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format, uint type)
+nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
+ enum pipe_format format, uint type)
{
switch (type) {
case PIPE_SURFACE:
@@ -122,36 +126,184 @@ nv30_screen_is_format_supported(struct pipe_screen *screen,
}
static void
-nv30_screen_destroy(struct pipe_screen *screen)
+nv30_screen_destroy(struct pipe_screen *pscreen)
{
- FREE(screen);
+ struct nv30_screen *screen = nv30_screen(pscreen);
+ struct nouveau_winsys *nvws = screen->nvws;
+
+ nvws->res_free(&screen->vp_exec_heap);
+ nvws->res_free(&screen->vp_data_heap);
+ nvws->res_free(&screen->query_heap);
+ nvws->notifier_free(&screen->query);
+ nvws->notifier_free(&screen->sync);
+ nvws->grobj_free(&screen->rankine);
+
+ FREE(pscreen);
}
struct pipe_screen *
-nv30_screen_create(struct pipe_winsys *winsys, struct nouveau_winsys *nvws,
+nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
unsigned chipset)
{
- struct nv30_screen *nv30screen = CALLOC_STRUCT(nv30_screen);
+ struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen);
+ struct nouveau_stateobj *so;
+ unsigned rankine_class = 0;
+ int ret, i;
+
+ if (!screen)
+ return NULL;
+ screen->chipset = chipset;
+ screen->nvws = nvws;
+
+ /* 3D object */
+ switch (chipset & 0xf0) {
+ case 0x30:
+ if (NV30TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+ rankine_class = 0x0397;
+ else
+ if (NV34TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+ rankine_class = 0x0697;
+ else
+ if (NV35TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+ rankine_class = 0x0497;
+ break;
+ default:
+ break;
+ }
- if (!nv30screen)
+ if (!rankine_class) {
+ NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", chipset);
return NULL;
+ }
+
+ ret = nvws->grobj_alloc(nvws, rankine_class, &screen->rankine);
+ if (ret) {
+ NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
+ return FALSE;
+ }
+
+ /* Notifier for sync purposes */
+ ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+ if (ret) {
+ NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
+ nv30_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ /* Query objects */
+ ret = nvws->notifier_alloc(nvws, 32, &screen->query);
+ if (ret) {
+ NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
+ nv30_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ ret = nvws->res_init(&screen->query_heap, 0, 32);
+ if (ret) {
+ NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
+ nv30_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ /* Vtxprog resources */
+ if (nvws->res_init(&screen->vp_exec_heap, 0, 256) ||
+ nvws->res_init(&screen->vp_data_heap, 0, 256)) {
+ nv30_screen_destroy(&screen->pipe);
+ return NULL;
+ }
+
+ /* Static rankine initialisation */
+ so = so_new(128, 0);
+ so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1);
+ so_data (so, screen->sync->handle);
+ so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);
+ so_data (so, nvws->channel->vram->handle);
+ so_data (so, nvws->channel->gart->handle);
+ so_method(so, screen->rankine, NV34TCL_DMA_COLOR1, 1);
+ so_data (so, nvws->channel->vram->handle);
+ so_method(so, screen->rankine, NV34TCL_DMA_COLOR0, 2);
+ so_data (so, nvws->channel->vram->handle);
+ so_data (so, nvws->channel->vram->handle);
+ so_method(so, screen->rankine, NV34TCL_DMA_VTXBUF0, 2);
+ so_data (so, nvws->channel->vram->handle);
+ so_data (so, nvws->channel->gart->handle);
+/* so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2);
+ so_data (so, 0);
+ so_data (so, screen->query->handle);*/
+ so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY7, 1);
+ so_data (so, nvws->channel->vram->handle);
+ so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY8, 1);
+ so_data (so, nvws->channel->vram->handle);
+
+ for (i=1; i<8; i++) {
+ so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
+ so_data (so, 0);
+ so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
+ so_data (so, 0);
+ }
+
+ so_method(so, screen->rankine, 0x220, 1);
+ so_data (so, 1);
+
+ so_method(so, screen->rankine, 0x03b0, 1);
+ so_data (so, 0x00100000);
+ so_method(so, screen->rankine, 0x1454, 1);
+ so_data (so, 0);
+ so_method(so, screen->rankine, 0x1d80, 1);
+ so_data (so, 3);
+ so_method(so, screen->rankine, 0x1450, 1);
+ so_data (so, 0x00030004);
+
+ /* NEW */
+ so_method(so, screen->rankine, 0x1e98, 1);
+ so_data (so, 0);
+ so_method(so, screen->rankine, 0x17e0, 3);
+ so_data (so, fui(0.0));
+ so_data (so, fui(0.0));
+ so_data (so, fui(1.0));
+ so_method(so, screen->rankine, 0x1f80, 16);
+ for (i=0; i<16; i++) {
+ so_data (so, (i==8) ? 0x0000ffff : 0);
+ }
+
+ so_method(so, screen->rankine, 0x120, 3);
+ so_data (so, 0);
+ so_data (so, 1);
+ so_data (so, 2);
+
+ so_method(so, screen->rankine, 0x1d88, 1);
+ so_data (so, 0x00001200);
+
+ so_method(so, screen->rankine, NV34TCL_RC_ENABLE, 1);
+ so_data (so, 0);
+
+ so_method(so, screen->rankine, NV34TCL_DEPTH_RANGE_NEAR, 2);
+ so_data (so, fui(0.0));
+ so_data (so, fui(1.0));
+
+ so_method(so, screen->rankine, NV34TCL_MULTISAMPLE_CONTROL, 1);
+ so_data (so, 0xffff0000);
+
+ /* enables use of vp rather than fixed-function somehow */
+ so_method(so, screen->rankine, 0x1e94, 1);
+ so_data (so, 0x13);
- nv30screen->chipset = chipset;
- nv30screen->nvws = nvws;
+ so_emit(nvws, so);
+ so_ref(NULL, &so);
+ nvws->push_flush(nvws, 0, NULL);
- nv30screen->screen.winsys = winsys;
+ screen->pipe.winsys = ws;
+ screen->pipe.destroy = nv30_screen_destroy;
- nv30screen->screen.destroy = nv30_screen_destroy;
+ screen->pipe.get_name = nv30_screen_get_name;
+ screen->pipe.get_vendor = nv30_screen_get_vendor;
+ screen->pipe.get_param = nv30_screen_get_param;
+ screen->pipe.get_paramf = nv30_screen_get_paramf;
- nv30screen->screen.get_name = nv30_screen_get_name;
- nv30screen->screen.get_vendor = nv30_screen_get_vendor;
- nv30screen->screen.get_param = nv30_screen_get_param;
- nv30screen->screen.get_paramf = nv30_screen_get_paramf;
- nv30screen->screen.is_format_supported =
- nv30_screen_is_format_supported;
+ screen->pipe.is_format_supported = nv30_screen_surface_format_supported;
- nv30_screen_init_miptree_functions(&nv30screen->screen);
+ nv30_screen_init_miptree_functions(&screen->pipe);
- return &nv30screen->screen;
+ return &screen->pipe;
}
diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
index f878f81e11..56f8776a17 100644
--- a/src/gallium/drivers/nv30/nv30_screen.h
+++ b/src/gallium/drivers/nv30/nv30_screen.h
@@ -4,10 +4,25 @@
#include "pipe/p_screen.h"
struct nv30_screen {
- struct pipe_screen screen;
+ struct pipe_screen pipe;
struct nouveau_winsys *nvws;
unsigned chipset;
+
+ /* HW graphics objects */
+ struct nouveau_grobj *rankine;
+ struct nouveau_notifier *sync;
+
+ /* Query object resources */
+ struct nouveau_notifier *query;
+ struct nouveau_resource *query_heap;
+
+ /* Vtxprog resources */
+ struct nouveau_resource *vp_exec_heap;
+ struct nouveau_resource *vp_data_heap;
+
+ /* Current 3D state of channel */
+ struct nouveau_stateobj *state[NV30_STATE_MAX];
};
static INLINE struct nv30_screen *
diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
index fe1a467565..71aea3a59c 100644
--- a/src/gallium/drivers/nv30/nv30_vertprog.c
+++ b/src/gallium/drivers/nv30/nv30_vertprog.c
@@ -1,7 +1,6 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/util/tgsi_parse.h"
@@ -654,7 +653,7 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
/* Allocate hw vtxprog exec slots */
if (!vp->exec) {
- struct nouveau_resource *heap = nv30->vertprog.exec_heap;
+ struct nouveau_resource *heap = nv30->screen->vp_exec_heap;
uint vplen = vp->nr_insns;
if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) {
@@ -674,7 +673,7 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
/* Allocate hw vtxprog const slots */
if (vp->nr_consts && !vp->data) {
- struct nouveau_resource *heap = nv30->vertprog.data_heap;
+ struct nouveau_resource *heap = nv30->screen->vp_data_heap;
if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) {
while (heap->next && heap->size < vp->nr_consts) {
@@ -789,9 +788,29 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
void
nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp)
{
- if (vp->nr_consts)
- FREE(vp->consts);
- if (vp->nr_insns)
+ struct nouveau_winsys *nvws = nv30->screen->nvws;
+
+ vp->translated = FALSE;
+
+ if (vp->nr_insns) {
FREE(vp->insns);
+ vp->insns = NULL;
+ vp->nr_insns = 0;
+ }
+
+ if (vp->nr_consts) {
+ FREE(vp->consts);
+ vp->consts = NULL;
+ vp->nr_consts = 0;
+ }
+
+ nvws->res_free(&vp->exec);
+ vp->exec_start = 0;
+ nvws->res_free(&vp->data);
+ vp->data_start = 0;
+ vp->data_start_min = 0;
+
+ /* vp->ir = vp->or = vp->clip_ctrl = 0;
+ so_ref(NULL, &vp->so); */
}