nv10: fix some more state, work on the vertex emission code.

This commit is contained in:
Stephane Marchesin 2008-04-02 18:26:49 +02:00
parent 8f26e975ca
commit fb19b3393f
7 changed files with 68 additions and 67 deletions

View file

@ -508,6 +508,7 @@ void draw_update_vertex_fetch( struct draw_context *draw )
draw->vertex_fetch.nr_attrs = nr_attrs;
draw->vertex_fetch.fetch_func = generic_vertex_fetch;
printf("pouet vertex fetch %x\n",draw->vertex_fetch.fetch_func);
switch (nr_attrs) {
case 2:
@ -524,5 +525,6 @@ void draw_update_vertex_fetch( struct draw_context *draw )
default:
break;
}
printf("pouet vertex fetch %x\n",draw->vertex_fetch.fetch_func);
}

View file

@ -21,17 +21,16 @@
#define NOUVEAU_MSG(fmt, args...) \
fprintf(stderr, "nouveau: "fmt, ##args);
#define NV10_NEW_VERTPROG (1 << 1)
#define NV10_NEW_FRAGPROG (1 << 2)
#define NV10_NEW_ARRAYS (1 << 3)
#define NV10_NEW_VTXFMT (1 << 4)
#define NV10_NEW_BLEND (1 << 5)
#define NV10_NEW_BLENDCOL (1 << 6)
#define NV10_NEW_RAST (1 << 7)
#define NV10_NEW_DSA (1 << 8)
#define NV10_NEW_VIEWPORT (1 << 9)
#define NV10_NEW_SCISSOR (1 << 9)
#define NV10_NEW_FRAMEBUFFER (1 << 10)
#define NV10_NEW_VERTPROG (1 << 0)
#define NV10_NEW_FRAGPROG (1 << 1)
#define NV10_NEW_VTXARRAYS (1 << 2)
#define NV10_NEW_BLEND (1 << 3)
#define NV10_NEW_BLENDCOL (1 << 4)
#define NV10_NEW_RAST (1 << 5)
#define NV10_NEW_DSA (1 << 6)
#define NV10_NEW_VIEWPORT (1 << 7)
#define NV10_NEW_SCISSOR (1 << 8)
#define NV10_NEW_FRAMEBUFFER (1 << 9)
#include "nv10_screen.h"

View file

@ -72,6 +72,7 @@ nv10_fragtex_format(uint pipe_format)
static void
nv10_fragtex_build(struct nv10_context *nv10, int unit)
{
#if 0
struct nv10_sampler_state *ps = nv10->tex_sampler[unit];
struct nv10_miptree *nv10mt = nv10->tex_miptree[unit];
struct pipe_texture *pt = &nv10mt->base;
@ -115,11 +116,13 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit)
OUT_RING (ps->filt | 0x2000 /* magic */);
OUT_RING ((pt->width[0] << 16) | pt->height[0]);
OUT_RING (ps->bcol);
#endif
}
void
nv10_fragtex_bind(struct nv10_context *nv10)
{
#if 0
struct nv10_fragment_program *fp = nv10->fragprog.active;
unsigned samplers, unit;
@ -141,5 +144,6 @@ nv10_fragtex_bind(struct nv10_context *nv10)
}
nv10->fp_samplers = fp->samplers;
#endif
}

View file

@ -94,6 +94,9 @@ nv10_vbuf_render_get_vertex_info( struct vbuf_render *render )
{
struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
struct nv10_context *nv10 = nv10_render->nv10;
nv10_emit_hw_state(nv10);
return &nv10->vertex_info;
}
@ -111,7 +114,7 @@ nv10_vbuf_render_allocate_vertices( struct vbuf_render *render,
assert(!nv10_render->buffer);
nv10_render->buffer = winsys->buffer_create(winsys, 64, PIPE_BUFFER_USAGE_VERTEX, size);
nv10->dirty |= NV10_NEW_ARRAYS;
nv10->dirty |= NV10_NEW_VTXARRAYS;
return winsys->buffer_map(winsys,
nv10_render->buffer,
@ -137,6 +140,8 @@ nv10_vbuf_render_draw( struct vbuf_render *render,
struct nv10_context *nv10 = nv10_render->nv10;
int push, i;
nv10_emit_hw_state(nv10);
BEGIN_RING(celsius, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
OUT_RELOCl(nv10_render->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);

View file

@ -1,3 +1,4 @@
#include "draw/draw_context.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
@ -7,38 +8,6 @@
#include "nv10_context.h"
#include "nv10_state.h"
static void nv10_vertex_layout(struct pipe_context* pipe)
{
struct nv10_context *nv10 = nv10_context(pipe);
struct nv10_fragment_program *fp = nv10->fragprog.current;
uint32_t src = 0;
int i;
struct vertex_info vinfo;
memset(&vinfo, 0, sizeof(vinfo));
for (i = 0; i < fp->info.num_inputs; i++) {
switch (fp->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
break;
case TGSI_SEMANTIC_COLOR:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
break;
default:
case TGSI_SEMANTIC_GENERIC:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
break;
case TGSI_SEMANTIC_FOG:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
break;
}
}
draw_compute_vertex_size(&vinfo);
nv10->dirty |= NV10_NEW_VTXFMT;
}
static void *
nv10_blend_state_create(struct pipe_context *pipe,
const struct pipe_blend_state *cso)
@ -406,34 +375,29 @@ nv10_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
static void *
nv10_vp_state_create(struct pipe_context *pipe,
const struct pipe_shader_state *cso)
const struct pipe_shader_state *templ)
{
struct nv10_vertex_program *vp;
struct nv10_context *nv10 = nv10_context(pipe);
vp = CALLOC(1, sizeof(struct nv10_vertex_program));
vp->pipe = cso;
return (void *)vp;
return draw_create_vertex_shader(nv10->draw, templ);
}
static void
nv10_vp_state_bind(struct pipe_context *pipe, void *hwcso)
nv10_vp_state_bind(struct pipe_context *pipe, void *shader)
{
struct nv10_context *nv10 = nv10_context(pipe);
struct nv10_vertex_program *vp = hwcso;
nv10->vertprog.current = vp;
draw_bind_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader);
nv10->dirty |= NV10_NEW_VERTPROG;
}
static void
nv10_vp_state_delete(struct pipe_context *pipe, void *hwcso)
nv10_vp_state_delete(struct pipe_context *pipe, void *shader)
{
//struct nv10_context *nv10 = nv10_context(pipe);
struct nv10_vertex_program *vp = hwcso;
struct nv10_context *nv10 = nv10_context(pipe);
//nv10_vertprog_destroy(nv10, vp);
FREE(vp);
draw_delete_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader);
}
static void *
@ -550,7 +514,7 @@ nv10_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
struct nv10_context *nv10 = nv10_context(pipe);
memcpy(nv10->vtxbuf, vb, sizeof(*vb) * count);
nv10->dirty |= NV10_NEW_ARRAYS;
nv10->dirty |= NV10_NEW_VTXARRAYS;
}
static void
@ -560,7 +524,7 @@ nv10_set_vertex_elements(struct pipe_context *pipe, unsigned count,
struct nv10_context *nv10 = nv10_context(pipe);
memcpy(nv10->vtxelt, ve, sizeof(*ve) * count);
nv10->dirty |= NV10_NEW_ARRAYS;
nv10->dirty |= NV10_NEW_VTXARRAYS;
}
void

View file

@ -154,6 +154,35 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
OUT_RING (((h - 1) << 16) | 0);
}
static void nv10_vertex_layout(struct nv10_context *nv10)
{
struct nv10_fragment_program *fp = nv10->fragprog.current;
uint32_t src = 0;
int i;
struct vertex_info vinfo;
memset(&vinfo, 0, sizeof(vinfo));
for (i = 0; i < fp->info.num_inputs; i++) {
switch (fp->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
break;
case TGSI_SEMANTIC_COLOR:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
break;
default:
case TGSI_SEMANTIC_GENERIC:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
break;
case TGSI_SEMANTIC_FOG:
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
break;
}
}
draw_compute_vertex_size(&vinfo);
}
void
nv10_emit_hw_state(struct nv10_context *nv10)
{
@ -176,13 +205,9 @@ nv10_emit_hw_state(struct nv10_context *nv10)
nv10->dirty &= ~NV10_NEW_FRAGPROG;
}
if (nv10->dirty & NV10_NEW_ARRAYS) {
nv10->dirty &= ~NV10_NEW_ARRAYS;
// array state will be put here once it's not emitted at each frame
}
if (nv10->dirty & NV10_NEW_VTXFMT) {
nv10->dirty &= ~NV10_NEW_VTXFMT;
if (nv10->dirty & NV10_NEW_VTXARRAYS) {
nv10->dirty &= ~NV10_NEW_VTXARRAYS;
nv10_vertex_layout(nv10);
nv10_vtxbuf_bind(nv10);
}

View file

@ -18,6 +18,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
struct draw_context *draw = nv10->draw;
unsigned i;
nv10_emit_hw_state(nv10);
/*
* Map vertex buffers
*/