+#include "draw/draw_context.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#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)
*/
rs = malloc(sizeof(struct nv10_rasterizer_state));
+ rs->templ = cso;
+
rs->shade_model = cso->flatshade ? 0x1d00 : 0x1d01;
rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff;
nv10->rast = (struct nv10_rasterizer_state*)rast;
+ draw_set_rasterizer_state(nv10->draw, (nv10->rast ? nv10->rast->templ : NULL));
+
nv10->dirty |= NV10_NEW_RAST;
}
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;
-
- vp = CALLOC(1, sizeof(struct nv10_vertex_program));
- vp->pipe = cso;
+ struct nv10_context *nv10 = nv10_context(pipe);
- 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 *
nv10_set_clip_state(struct pipe_context *pipe,
const struct pipe_clip_state *clip)
{
+ struct nv10_context *nv10 = nv10_context(pipe);
+
+ draw_set_clip_state(nv10->draw, clip);
}
static void
const struct pipe_constant_buffer *buf )
{
struct nv10_context *nv10 = nv10_context(pipe);
-
- if (shader == PIPE_SHADER_VERTEX) {
- nv10->vertprog.constant_buf = buf->buffer;
- nv10->dirty |= NV10_NEW_VERTPROG;
- } else
- if (shader == PIPE_SHADER_FRAGMENT) {
- nv10->fragprog.constant_buf = buf->buffer;
- nv10->dirty |= NV10_NEW_FRAGPROG;
+ struct pipe_winsys *ws = pipe->winsys;
+
+ assert(shader < PIPE_SHADER_TYPES);
+ assert(index == 0);
+
+ if (buf) {
+ void *mapped;
+ if (buf->size && (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+ {
+ memcpy(nv10->constbuf[shader], mapped, buf->size);
+ nv10->constbuf_nr[shader] =
+ buf->size / (4 * sizeof(float));
+ ws->buffer_unmap(ws, buf->buffer);
+ }
}
}
nv10->viewport = (struct pipe_viewport_state*)vpt;
+ draw_set_viewport_state(nv10->draw, nv10->viewport);
+
nv10->dirty |= NV10_NEW_VIEWPORT;
}
struct nv10_context *nv10 = nv10_context(pipe);
memcpy(nv10->vtxbuf, vb, sizeof(*vb) * count);
- nv10->dirty |= NV10_NEW_ARRAYS;
+ nv10->dirty |= NV10_NEW_VTXARRAYS;
+
+ draw_set_vertex_buffers(nv10->draw, count, vb);
}
static void
struct nv10_context *nv10 = nv10_context(pipe);
memcpy(nv10->vtxelt, ve, sizeof(*ve) * count);
- nv10->dirty |= NV10_NEW_ARRAYS;
+ nv10->dirty |= NV10_NEW_VTXARRAYS;
+
+ draw_set_vertex_elements(nv10->draw, count, ve);
}
void