st/mesa: fix incorrect RowStride computation
[mesa.git] / src / gallium / drivers / nv30 / nv30_context.h
index 4a6c1d2f47ba200c57a6efe1fd996eb55fa23b03..ea259aadf359f28222d68a5f089098c2afab467e 100644 (file)
@@ -1,18 +1,22 @@
 #ifndef __NV30_CONTEXT_H__
 #define __NV30_CONTEXT_H__
 
+#include <stdio.h>
+
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_compiler.h"
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_inlines.h"
 
 #include "draw/draw_vertex.h"
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
-
-#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
-       struct nv30_screen *ctx = nv30->screen
-#include "nouveau/nouveau_push.h"
+#include "nouveau/nouveau_context.h"
 #include "nouveau/nouveau_stateobj.h"
 
 #include "nv30_state.h"
@@ -57,7 +61,8 @@ enum nv30_state_index {
        NV30_STATE_VTXBUF = 31,
        NV30_STATE_VTXFMT = 32,
        NV30_STATE_VTXATTR = 33,
-       NV30_STATE_MAX = 34
+       NV30_STATE_SR = 34,
+       NV30_STATE_MAX = 35
 };
 
 #include "nv30_screen.h"
@@ -75,9 +80,9 @@ enum nv30_state_index {
 #define NV30_NEW_FRAGPROG      (1 << 10)
 #define NV30_NEW_ARRAYS                (1 << 11)
 #define NV30_NEW_UCP           (1 << 12)
+#define NV30_NEW_SR            (1 << 13)
 
-/* TODO: rename when removing the old state emitter */
-struct nv30_rasterizer_state_new {
+struct nv30_rasterizer_state {
        struct pipe_rasterizer_state pipe;
        struct nouveau_stateobj *so;
 };
@@ -87,8 +92,7 @@ struct nv30_zsa_state {
        struct nouveau_stateobj *so;
 };
 
-/* TODO: rename when removing the old state emitter */
-struct nv30_blend_state_new {
+struct nv30_blend_state {
        struct pipe_blend_state pipe;
        struct nouveau_stateobj *so;
 };
@@ -97,7 +101,7 @@ struct nv30_blend_state_new {
 struct nv30_state {
        unsigned scissor_enabled;
        unsigned stipple_enabled;
-       unsigned viewport_bypass;
+       unsigned fp_samplers;
 
        uint64_t dirty;
        struct nouveau_stateobj *hw[NV30_STATE_MAX];
@@ -108,62 +112,38 @@ struct nv30_context {
 
        struct nouveau_winsys *nvws;
        struct nv30_screen *screen;
-       unsigned pctx_id;
 
        struct draw_context *draw;
 
        /* HW state derived from pipe states */
        struct nv30_state state;
-       struct pipe_scissor_state scissor;
-
-       uint32_t dirty;
-
-       struct nv30_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
-       struct nv30_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
-       unsigned dirty_samplers;
-       unsigned fp_samplers;
-       unsigned vp_samplers;
 
        /* Context state */
-       struct nv30_blend_state_new *blend;
+       unsigned dirty;
+       struct pipe_scissor_state scissor;
+       unsigned stipple[32];
+       struct nv30_vertex_program *vertprog;
+       struct nv30_fragment_program *fragprog;
+       struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
+       unsigned constbuf_nr[PIPE_SHADER_TYPES];
+       struct nv30_rasterizer_state *rasterizer;
+       struct nv30_zsa_state *zsa;
+       struct nv30_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 nv30_rasterizer_state_new *rasterizer;
-       struct nv30_zsa_state *zsa;
-       unsigned stipple[32];
-
-       uint32_t rt_enable;
-       struct pipe_buffer *rt[2];
-       struct pipe_buffer *zeta;
-
-       /*struct {
-               struct pipe_buffer *buffer;
-               uint32_t format;
-       } tex[16];*/
-
-       unsigned vb_enable;
-       struct {
-               struct pipe_buffer *buffer;
-               unsigned delta;
-       } vb[16];
-
-       struct {
-               struct nv30_vertex_program *active;
-
-               struct nv30_vertex_program *current;
-               struct pipe_buffer *constant_buf;
-       } vertprog;
-
-       struct {
-               struct nv30_fragment_program *active;
-
-               struct nv30_fragment_program *current;
-               struct pipe_buffer *constant_buf;
-       } fragprog;
-
-       struct pipe_vertex_buffer  vtxbuf[PIPE_MAX_ATTRIBS];
+       struct pipe_buffer *idxbuf;
+       unsigned idxbuf_format;
+       struct nv30_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
+       struct nv30_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
+       unsigned nr_samplers;
+       unsigned nr_textures;
+       unsigned dirty_samplers;
+       struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
+       unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
+       unsigned vtxelt_nr;
 };
 
 static INLINE struct nv30_context *
@@ -190,18 +170,10 @@ extern void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen);
 extern struct draw_stage *nv30_draw_render_stage(struct nv30_context *nv30);
 
 /* nv30_vertprog.c */
-extern void nv30_vertprog_translate(struct nv30_context *,
-                                   struct nv30_vertex_program *);
-extern void nv30_vertprog_bind(struct nv30_context *,
-                              struct nv30_vertex_program *);
 extern void nv30_vertprog_destroy(struct nv30_context *,
                                  struct nv30_vertex_program *);
 
 /* nv30_fragprog.c */
-extern void nv30_fragprog_translate(struct nv30_context *,
-                                   struct nv30_fragment_program *);
-extern void nv30_fragprog_bind(struct nv30_context *,
-                              struct nv30_fragment_program *);
 extern void nv30_fragprog_destroy(struct nv30_context *,
                                  struct nv30_fragment_program *);
 
@@ -210,21 +182,37 @@ extern void nv30_fragtex_bind(struct nv30_context *);
 
 /* nv30_state.c and friends */
 extern boolean nv30_state_validate(struct nv30_context *nv30);
-extern void nv30_emit_hw_state(struct nv30_context *nv30);
-extern void nv30_state_tex_update(struct nv30_context *nv30);
+extern void nv30_state_emit(struct nv30_context *nv30);
+extern void nv30_state_flush_notify(struct nouveau_channel *chan);
+extern struct nv30_state_entry nv30_state_rasterizer;
+extern struct nv30_state_entry nv30_state_scissor;
+extern struct nv30_state_entry nv30_state_stipple;
+extern struct nv30_state_entry nv30_state_fragprog;
+extern struct nv30_state_entry nv30_state_vertprog;
+extern struct nv30_state_entry nv30_state_blend;
+extern struct nv30_state_entry nv30_state_blend_colour;
+extern struct nv30_state_entry nv30_state_zsa;
+extern struct nv30_state_entry nv30_state_viewport;
 extern struct nv30_state_entry nv30_state_framebuffer;
+extern struct nv30_state_entry nv30_state_fragtex;
+extern struct nv30_state_entry nv30_state_vbo;
+extern struct nv30_state_entry nv30_state_sr;
 
 /* nv30_vbo.c */
-extern boolean nv30_draw_arrays(struct pipe_context *, unsigned mode,
+extern void nv30_draw_arrays(struct pipe_context *, unsigned mode,
                                unsigned start, unsigned count);
-extern boolean nv30_draw_elements(struct pipe_context *pipe,
+extern void nv30_draw_elements(struct pipe_context *pipe,
                                  struct pipe_buffer *indexBuffer,
                                  unsigned indexSize,
                                  unsigned mode, unsigned start,
                                  unsigned count);
 
 /* nv30_clear.c */
-extern void nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps,
-                      unsigned clearValue);
+extern void nv30_clear(struct pipe_context *pipe, unsigned buffers,
+                      const float *rgba, double depth, unsigned stencil);
+
+/* nv30_context.c */
+struct pipe_context *
+nv30_create(struct pipe_screen *pscreen, void *priv);
 
 #endif