summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv40
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv40')
-rw-r--r--src/gallium/drivers/nv40/nv40_context.h6
-rw-r--r--src/gallium/drivers/nv40/nv40_draw.c5
-rw-r--r--src/gallium/drivers/nv40/nv40_fragtex.c4
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c37
-rw-r--r--src/gallium/drivers/nv40/nv40_state_emit.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_state_zsa.c24
-rw-r--r--src/gallium/drivers/nv40/nv40_vbo.c15
8 files changed, 70 insertions, 25 deletions
diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index 958a48f2a4..4861924dac 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -61,7 +61,8 @@ enum nv40_state_index {
NV40_STATE_VTXBUF = 31,
NV40_STATE_VTXFMT = 32,
NV40_STATE_VTXATTR = 33,
- NV40_STATE_MAX = 34
+ NV40_STATE_SR = 34,
+ NV40_STATE_MAX = 35
};
#include "nv40_screen.h"
@@ -79,6 +80,7 @@ enum nv40_state_index {
#define NV40_NEW_FRAGPROG (1 << 10)
#define NV40_NEW_ARRAYS (1 << 11)
#define NV40_NEW_UCP (1 << 12)
+#define NV40_NEW_SR (1 << 13)
struct nv40_rasterizer_state {
struct pipe_rasterizer_state pipe;
@@ -144,6 +146,7 @@ struct nv40_context {
struct nv40_zsa_state *zsa;
struct nv40_blend_state *blend;
struct pipe_blend_color blend_colour;
+ struct pipe_stencil_ref stencil_ref;
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state framebuffer;
struct pipe_buffer *idxbuf;
@@ -215,6 +218,7 @@ extern struct nv40_state_entry nv40_state_framebuffer;
extern struct nv40_state_entry nv40_state_fragtex;
extern struct nv40_state_entry nv40_state_vbo;
extern struct nv40_state_entry nv40_state_vtxfmt;
+extern struct nv40_state_entry nv40_state_sr;
/* nv40_vbo.c */
extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
index 60ab49fad1..48bd84d16c 100644
--- a/src/gallium/drivers/nv40/nv40_draw.c
+++ b/src/gallium/drivers/nv40/nv40_draw.c
@@ -88,12 +88,11 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
struct nv40_screen *screen = nv40->screen;
struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_pushbuf *pb = chan->pushbuf;
struct nouveau_grobj *curie = screen->curie;
unsigned i;
/* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
- if (pb->remaining < ((count * 20) + 6)) {
+ if (AVAIL_RING(chan) < ((count * 20) + 6)) {
if (rs->prim != NV40TCL_BEGIN_END_STOP) {
NOUVEAU_ERR("AIII, missed flush\n");
assert(0);
@@ -121,7 +120,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
/* If it's likely we'll need to empty the push buffer soon, finish
* off the primitive now.
*/
- if (pb->remaining < ((count * 20) + 6)) {
+ if (AVAIL_RING(chan) < ((count * 20) + 6)) {
BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
OUT_RING (chan, NV40TCL_BEGIN_END_STOP);
rs->prim = NV40TCL_BEGIN_END_STOP;
diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
index aad9198210..7a28d577b1 100644
--- a/src/gallium/drivers/nv40/nv40_fragtex.c
+++ b/src/gallium/drivers/nv40/nv40_fragtex.c
@@ -1,3 +1,5 @@
+#include "util/u_format.h"
+
#include "nv40_context.h"
#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw) \
@@ -53,7 +55,7 @@ nv40_fragtex_format(uint pipe_format)
tf++;
}
- NOUVEAU_ERR("unknown texture format %s\n", pf_name(pipe_format));
+ NOUVEAU_ERR("unknown texture format %s\n", util_format_name(pipe_format));
return NULL;
}
diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
index 001147e752..edee4b9a3a 100644
--- a/src/gallium/drivers/nv40/nv40_screen.c
+++ b/src/gallium/drivers/nv40/nv40_screen.c
@@ -62,6 +62,8 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param)
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
return 0;
+ case PIPE_CAP_MAX_COMBINED_SAMPLERS:
+ return 16;
default:
NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
return 0;
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 51b40e51e4..4f28675e64 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -132,26 +132,26 @@ nv40_sampler_state_create(struct pipe_context *pipe,
(wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT));
ps->en = 0;
- if (cso->max_anisotropy >= 2.0) {
+ if (cso->max_anisotropy >= 2) {
/* no idea, binary driver sets it, works without it.. meh.. */
ps->wrap |= (1 << 5);
- if (cso->max_anisotropy >= 16.0) {
+ if (cso->max_anisotropy >= 16) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
} else
- if (cso->max_anisotropy >= 12.0) {
+ if (cso->max_anisotropy >= 12) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
} else
- if (cso->max_anisotropy >= 10.0) {
+ if (cso->max_anisotropy >= 10) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
} else
- if (cso->max_anisotropy >= 8.0) {
+ if (cso->max_anisotropy >= 8) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
} else
- if (cso->max_anisotropy >= 6.0) {
+ if (cso->max_anisotropy >= 6) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
} else
- if (cso->max_anisotropy >= 4.0) {
+ if (cso->max_anisotropy >= 4) {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
} else {
ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
{
struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
- struct nouveau_stateobj *so = so_new(8, 18, 0);
+ struct nouveau_stateobj *so = so_new(9, 19, 0);
struct nouveau_grobj *curie = nv40->screen->curie;
/*XXX: ignored:
@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
{
struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
- struct nouveau_stateobj *so = so_new(4, 21, 0);
+ struct nouveau_stateobj *so = so_new(6, 20, 0);
struct nouveau_grobj *curie = nv40->screen->curie;
so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);
@@ -459,11 +459,11 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
so_data (so, float_to_ubyte(cso->alpha.ref_value));
if (cso->stencil[0].enabled) {
- so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 8);
+ so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 3);
so_data (so, cso->stencil[0].enabled ? 1 : 0);
so_data (so, cso->stencil[0].writemask);
so_data (so, nvgl_comparison_op(cso->stencil[0].func));
- so_data (so, cso->stencil[0].ref_value);
+ so_method(so, curie, NV40TCL_STENCIL_FRONT_FUNC_MASK, 4);
so_data (so, cso->stencil[0].valuemask);
so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op));
so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
@@ -474,11 +474,11 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
}
if (cso->stencil[1].enabled) {
- so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 8);
+ so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 3);
so_data (so, cso->stencil[1].enabled ? 1 : 0);
so_data (so, cso->stencil[1].writemask);
so_data (so, nvgl_comparison_op(cso->stencil[1].func));
- so_data (so, cso->stencil[1].ref_value);
+ so_method(so, curie, NV40TCL_STENCIL_BACK_FUNC_MASK, 4);
so_data (so, cso->stencil[1].valuemask);
so_data (so, nvgl_stencil_op(cso->stencil[1].fail_op));
so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
@@ -592,6 +592,16 @@ nv40_set_blend_color(struct pipe_context *pipe,
nv40->dirty |= NV40_NEW_BCOL;
}
+ static void
+nv40_set_stencil_ref(struct pipe_context *pipe,
+ const struct pipe_stencil_ref *sr)
+{
+ struct nv40_context *nv40 = nv40_context(pipe);
+
+ nv40->stencil_ref = *sr;
+ nv40->dirty |= NV40_NEW_SR;
+}
+
static void
nv40_set_clip_state(struct pipe_context *pipe,
const struct pipe_clip_state *clip)
@@ -719,6 +729,7 @@ nv40_init_state_functions(struct nv40_context *nv40)
nv40->pipe.delete_fs_state = nv40_fp_state_delete;
nv40->pipe.set_blend_color = nv40_set_blend_color;
+ nv40->pipe.set_stencil_ref = nv40_set_stencil_ref;
nv40->pipe.set_clip_state = nv40_set_clip_state;
nv40->pipe.set_constant_buffer = nv40_set_constant_buffer;
nv40->pipe.set_framebuffer_state = nv40_set_framebuffer_state;
diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c
index 1c4007a129..8990f303ce 100644
--- a/src/gallium/drivers/nv40/nv40_state_emit.c
+++ b/src/gallium/drivers/nv40/nv40_state_emit.c
@@ -13,6 +13,7 @@ static struct nv40_state_entry *render_states[] = {
&nv40_state_blend,
&nv40_state_blend_colour,
&nv40_state_zsa,
+ &nv40_state_sr,
&nv40_state_viewport,
&nv40_state_vbo,
NULL
@@ -29,6 +30,7 @@ static struct nv40_state_entry *swtnl_states[] = {
&nv40_state_blend,
&nv40_state_blend_colour,
&nv40_state_zsa,
+ &nv40_state_sr,
&nv40_state_viewport,
&nv40_state_vtxfmt,
NULL
diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c
index fb760677c8..9cbe7da6db 100644
--- a/src/gallium/drivers/nv40/nv40_state_zsa.c
+++ b/src/gallium/drivers/nv40/nv40_state_zsa.c
@@ -15,3 +15,27 @@ struct nv40_state_entry nv40_state_zsa = {
.hw = NV40_STATE_ZSA
}
};
+
+static boolean
+nv40_state_sr_validate(struct nv40_context *nv40)
+{
+ struct nouveau_stateobj *so = so_new(2, 2, 0);
+ struct pipe_stencil_ref *sr = &nv40->stencil_ref;
+
+ so_method(so, nv40->screen->curie, NV40TCL_STENCIL_FRONT_FUNC_REF, 1);
+ so_data (so, sr->ref_value[0]);
+ so_method(so, nv40->screen->curie, NV40TCL_STENCIL_BACK_FUNC_REF, 1);
+ so_data (so, sr->ref_value[1]);
+
+ so_ref(so, &nv40->state.hw[NV40_STATE_SR]);
+ so_ref(NULL, &so);
+ return TRUE;
+}
+
+struct nv40_state_entry nv40_state_sr = {
+ .validate = nv40_state_sr_validate,
+ .dirty = {
+ .pipe = NV40_NEW_SR,
+ .hw = NV40_STATE_SR
+ }
+};
diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
index 1e14edc56a..7812460d2e 100644
--- a/src/gallium/drivers/nv40/nv40_vbo.c
+++ b/src/gallium/drivers/nv40/nv40_vbo.c
@@ -1,6 +1,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_inlines.h"
+#include "util/u_format.h"
#include "nv40_context.h"
#include "nv40_state.h"
@@ -34,7 +35,7 @@ nv40_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
*fmt = NV40TCL_VTXFMT_TYPE_USHORT;
break;
default:
- NOUVEAU_ERR("Unknown format %s\n", pf_name(pipe));
+ NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
return 1;
}
@@ -60,7 +61,7 @@ nv40_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
*ncomp = 4;
break;
default:
- NOUVEAU_ERR("Unknown format %s\n", pf_name(pipe));
+ NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
return 1;
}
@@ -186,7 +187,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
nv40_state_emit(nv40);
- vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
+ vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
mode, start, count, &restart);
if (!vc) {
FIRE_RING(chan);
@@ -240,7 +241,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
nv40_state_emit(nv40);
- vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
+ vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
mode, start, count, &restart);
if (vc == 0) {
FIRE_RING(chan);
@@ -291,7 +292,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
nv40_state_emit(nv40);
- vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 2,
+ vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
mode, start, count, &restart);
if (vc == 0) {
FIRE_RING(chan);
@@ -342,7 +343,7 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
nv40_state_emit(nv40);
- vc = nouveau_vbuf_split(chan->pushbuf->remaining, 5, 1,
+ vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
mode, start, count, &restart);
if (vc == 0) {
FIRE_RING(chan);
@@ -418,7 +419,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
nv40_state_emit(nv40);
- vc = nouveau_vbuf_split(chan->pushbuf->remaining, 6, 256,
+ vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
mode, start, count, &restart);
if (!vc) {
FIRE_RING(chan);