Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #ifndef __NV30_CONTEXT_H__
  2. #define __NV30_CONTEXT_H__
  3.  
  4. #include "pipe/p_format.h"
  5. #include "util/u_blitter.h"
  6.  
  7. #include "nv30_screen.h"
  8. #include "nv30_state.h"
  9.  
  10. #include "nouveau/nouveau_context.h"
  11.  
  12. #define BUFCTX_FB          0
  13. #define BUFCTX_VTXTMP      1
  14. #define BUFCTX_VTXBUF      2
  15. #define BUFCTX_IDXBUF      3
  16. #define BUFCTX_VERTTEX(n) (4 + (n))
  17. #define BUFCTX_FRAGPROG    8
  18. #define BUFCTX_FRAGTEX(n) (9 + (n))
  19.  
  20. #define NV30_NEW_BLEND        (1 << 0)
  21. #define NV30_NEW_RASTERIZER   (1 << 1)
  22. #define NV30_NEW_ZSA          (1 << 2)
  23. #define NV30_NEW_VERTPROG     (1 << 3)
  24. #define NV30_NEW_VERTCONST    (1 << 4)
  25. #define NV30_NEW_FRAGPROG     (1 << 5)
  26. #define NV30_NEW_FRAGCONST    (1 << 6)
  27. #define NV30_NEW_BLEND_COLOUR (1 << 7)
  28. #define NV30_NEW_STENCIL_REF  (1 << 8)
  29. #define NV30_NEW_CLIP         (1 << 9)
  30. #define NV30_NEW_SAMPLE_MASK  (1 << 10)
  31. #define NV30_NEW_FRAMEBUFFER  (1 << 11)
  32. #define NV30_NEW_STIPPLE      (1 << 12)
  33. #define NV30_NEW_SCISSOR      (1 << 13)
  34. #define NV30_NEW_VIEWPORT     (1 << 14)
  35. #define NV30_NEW_ARRAYS       (1 << 15)
  36. #define NV30_NEW_VERTEX       (1 << 16)
  37. #define NV30_NEW_CONSTBUF     (1 << 17)
  38. #define NV30_NEW_FRAGTEX      (1 << 18)
  39. #define NV30_NEW_VERTTEX      (1 << 19)
  40. #define NV30_NEW_SWTNL        (1 << 31)
  41. #define NV30_NEW_ALL          0x000fffff
  42.  
  43. struct nv30_context {
  44.    struct nouveau_context base;
  45.    struct nv30_screen *screen;
  46.    struct blitter_context *blitter;
  47.  
  48.    struct nouveau_bufctx *bufctx;
  49.  
  50.    struct {
  51.       unsigned rt_enable;
  52.       unsigned scissor_off;
  53.       unsigned num_vtxelts;
  54.       boolean  prim_restart;
  55.       struct nv30_fragprog *fragprog;
  56.    } state;
  57.  
  58.    uint32_t dirty;
  59.  
  60.    struct draw_context *draw;
  61.    uint32_t draw_flags;
  62.    uint32_t draw_dirty;
  63.  
  64.    struct nv30_blend_stateobj *blend;
  65.    struct nv30_rasterizer_stateobj *rast;
  66.    struct nv30_zsa_stateobj *zsa;
  67.    struct nv30_vertex_stateobj *vertex;
  68.  
  69.    struct {
  70.       unsigned filter;
  71.       unsigned aniso;
  72.    } config;
  73.  
  74.    struct {
  75.       struct nv30_vertprog *program;
  76.  
  77.       struct pipe_resource *constbuf;
  78.       unsigned constbuf_nr;
  79.  
  80.       struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];
  81.       unsigned num_textures;
  82.       struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];
  83.       unsigned num_samplers;
  84.       unsigned dirty_samplers;
  85.    } vertprog;
  86.  
  87.    struct {
  88.       struct nv30_fragprog *program;
  89.  
  90.       struct pipe_resource *constbuf;
  91.       unsigned constbuf_nr;
  92.  
  93.       struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];
  94.       unsigned num_textures;
  95.       struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];
  96.       unsigned num_samplers;
  97.       unsigned dirty_samplers;
  98.    } fragprog;
  99.  
  100.    struct pipe_framebuffer_state framebuffer;
  101.    struct pipe_blend_color blend_colour;
  102.    struct pipe_stencil_ref stencil_ref;
  103.    struct pipe_poly_stipple stipple;
  104.    struct pipe_scissor_state scissor;
  105.    struct pipe_viewport_state viewport;
  106.    struct pipe_clip_state clip;
  107.  
  108.    unsigned sample_mask;
  109.  
  110.    struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
  111.    unsigned num_vtxbufs;
  112.    struct pipe_index_buffer idxbuf;
  113.    uint32_t vbo_fifo;
  114.    uint32_t vbo_user;
  115.    unsigned vbo_min_index;
  116.    unsigned vbo_max_index;
  117.    boolean  vbo_push_hint;
  118.  
  119.    struct nouveau_heap  *blit_vp;
  120.    struct pipe_resource *blit_fp;
  121.  
  122.    /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
  123.    unsigned is_nv4x;
  124.    unsigned use_nv4x;
  125.    bool hw_pointsprite_control;
  126.    enum {
  127.       HW,
  128.    } render_mode;
  129.  
  130.    struct pipe_query *render_cond_query;
  131.    unsigned render_cond_mode;
  132.    boolean render_cond_cond;
  133. };
  134.  
  135. static INLINE struct nv30_context *
  136. nv30_context(struct pipe_context *pipe)
  137. {
  138.    return (struct nv30_context *)pipe;
  139. }
  140.  
  141. struct pipe_context *
  142. nv30_context_create(struct pipe_screen *pscreen, void *priv);
  143.  
  144. void
  145. nv30_vbo_init(struct pipe_context *pipe);
  146.  
  147. void
  148. nv30_vbo_validate(struct nv30_context *nv30);
  149.  
  150. void
  151. nv30_query_init(struct pipe_context *pipe);
  152.  
  153. void
  154. nv30_state_init(struct pipe_context *pipe);
  155.  
  156. void
  157. nv30_clear_init(struct pipe_context *pipe);
  158.  
  159. void
  160. nv30_vertprog_init(struct pipe_context *pipe);
  161.  
  162. void
  163. nv30_vertprog_validate(struct nv30_context *nv30);
  164.  
  165. void
  166. nv30_fragprog_init(struct pipe_context *pipe);
  167.  
  168. void
  169. nv30_fragprog_validate(struct nv30_context *nv30);
  170.  
  171. void
  172. nv30_texture_init(struct pipe_context *pipe);
  173.  
  174. void
  175. nv30_texture_validate(struct nv30_context *nv30);
  176.  
  177. void
  178. nv30_fragtex_init(struct pipe_context *pipe);
  179.  
  180. void
  181. nv30_fragtex_validate(struct nv30_context *nv30);
  182.  
  183. void
  184. nv40_verttex_init(struct pipe_context *pipe);
  185.  
  186. void
  187. nv40_verttex_validate(struct nv30_context *nv30);
  188.  
  189. void
  190. nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info);
  191.  
  192. void
  193. nv30_draw_init(struct pipe_context *pipe);
  194.  
  195. void
  196. nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info);
  197.  
  198. boolean
  199. nv30_state_validate(struct nv30_context *nv30, boolean hwtnl);
  200.  
  201. void
  202. nv30_state_release(struct nv30_context *nv30);
  203.  
  204. //XXX: needed to make it build, clean this up!
  205. void
  206. _nvfx_fragprog_translate(struct nv30_context *nvfx, struct nv30_fragprog *fp,
  207.          boolean emulate_sprite_flipping);
  208.  
  209. boolean
  210. _nvfx_vertprog_translate(struct nv30_context *nv30, struct nv30_vertprog *vp);
  211.  
  212. #ifdef NV30_3D_VERTEX_BEGIN_END
  213. #define NV30_PRIM_GL_CASE(n) \
  214.    case PIPE_PRIM_##n: return NV30_3D_VERTEX_BEGIN_END_##n
  215.  
  216. static INLINE unsigned
  217. nv30_prim_gl(unsigned prim)
  218. {
  219.    switch (prim) {
  220.    NV30_PRIM_GL_CASE(POINTS);
  221.    NV30_PRIM_GL_CASE(LINES);
  222.    NV30_PRIM_GL_CASE(LINE_LOOP);
  223.    NV30_PRIM_GL_CASE(LINE_STRIP);
  224.    NV30_PRIM_GL_CASE(TRIANGLES);
  225.    NV30_PRIM_GL_CASE(TRIANGLE_STRIP);
  226.    NV30_PRIM_GL_CASE(TRIANGLE_FAN);
  227.    NV30_PRIM_GL_CASE(QUADS);
  228.    NV30_PRIM_GL_CASE(QUAD_STRIP);
  229.    NV30_PRIM_GL_CASE(POLYGON);
  230.    default:
  231.       return NV30_3D_VERTEX_BEGIN_END_POINTS;
  232.       break;
  233.    }
  234. }
  235. #endif
  236.  
  237. #endif
  238.