Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nvc0_context.h 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #ifndef __NVC0_CONTEXT_H__
  2. #define __NVC0_CONTEXT_H__
  3. #include <stdio.h>
  4. #include "pipe/p_context.h"
  5. #include "pipe/p_defines.h"
  6. #include "pipe/p_state.h"
  7. #include "util/u_memory.h"
  8. #include "util/u_math.h"
  9. #include "util/u_inlines.h"
  10. #include "util/u_dynarray.h"
  11. #include "draw/draw_vertex.h"
  12. #include "nvc0_winsys.h"
  13. #include "nvc0_stateobj.h"
  14. #include "nvc0_screen.h"
  15. #include "nvc0_program.h"
  16. #include "nvc0_resource.h"
  17. #include "nvc0_3ddefs.xml.h"
  18. #include "nvc0_3d.xml.h"
  19. #include "nvc0_2d.xml.h"
  20. #include "nvc0_m2mf.xml.h"
  21. #define NOUVEAU_ERR(fmt, args...) \
  22. fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args);
  23. #ifdef NOUVEAU_DEBUG
  24. # define NOUVEAU_DBG(args...) printf(args);
  25. #else
  26. # define NOUVEAU_DBG(args...)
  27. #endif
  28. #define NVC0_NEW_BLEND (1 << 0)
  29. #define NVC0_NEW_RASTERIZER (1 << 1)
  30. #define NVC0_NEW_ZSA (1 << 2)
  31. #define NVC0_NEW_VERTPROG (1 << 3)
  32. #define NVC0_NEW_TCTLPROG (1 << 4)
  33. #define NVC0_NEW_TEVLPROG (1 << 5)
  34. #define NVC0_NEW_GMTYPROG (1 << 6)
  35. #define NVC0_NEW_FRAGPROG (1 << 7)
  36. #define NVC0_NEW_BLEND_COLOUR (1 << 8)
  37. #define NVC0_NEW_STENCIL_REF (1 << 9)
  38. #define NVC0_NEW_CLIP (1 << 10)
  39. #define NVC0_NEW_SAMPLE_MASK (1 << 11)
  40. #define NVC0_NEW_FRAMEBUFFER (1 << 12)
  41. #define NVC0_NEW_STIPPLE (1 << 13)
  42. #define NVC0_NEW_SCISSOR (1 << 14)
  43. #define NVC0_NEW_VIEWPORT (1 << 15)
  44. #define NVC0_NEW_ARRAYS (1 << 16)
  45. #define NVC0_NEW_VERTEX (1 << 17)
  46. #define NVC0_NEW_CONSTBUF (1 << 18)
  47. #define NVC0_NEW_TEXTURES (1 << 19)
  48. #define NVC0_NEW_SAMPLERS (1 << 20)
  49. #define NVC0_BUFCTX_CONSTANT 0
  50. #define NVC0_BUFCTX_FRAME 1
  51. #define NVC0_BUFCTX_VERTEX 2
  52. #define NVC0_BUFCTX_TEXTURES 3
  53. #define NVC0_BUFCTX_COUNT 4
  54. struct nvc0_context {
  55. struct pipe_context pipe;
  56. struct nvc0_screen *screen;
  57. struct util_dynarray residents[NVC0_BUFCTX_COUNT];
  58. uint32_t dirty;
  59. struct {
  60. uint32_t instance_bits;
  61. uint32_t instance_base;
  62. int32_t index_bias;
  63. boolean prim_restart;
  64. uint8_t num_vtxbufs;
  65. uint8_t num_vtxelts;
  66. uint8_t num_textures[5];
  67. uint8_t num_samplers[5];
  68. uint16_t scissor;
  69. uint8_t uniform_buffer_bound; /* workaround */
  70. } state;
  71. struct nvc0_blend_stateobj *blend;
  72. struct nvc0_rasterizer_stateobj *rast;
  73. struct nvc0_zsa_stateobj *zsa;
  74. struct nvc0_vertex_stateobj *vertex;
  75. struct nvc0_program *vertprog;
  76. struct nvc0_program *tctlprog;
  77. struct nvc0_program *tevlprog;
  78. struct nvc0_program *gmtyprog;
  79. struct nvc0_program *fragprog;
  80. struct pipe_resource *constbuf[5][16];
  81. uint16_t constbuf_dirty[5];
  82. struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
  83. unsigned num_vtxbufs;
  84. struct pipe_index_buffer idxbuf;
  85. uint32_t vbo_fifo;
  86. struct pipe_sampler_view *textures[5][PIPE_MAX_SAMPLERS];
  87. unsigned num_textures[5];
  88. struct nvc0_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
  89. unsigned num_samplers[5];
  90. struct pipe_framebuffer_state framebuffer;
  91. struct pipe_blend_color blend_colour;
  92. struct pipe_stencil_ref stencil_ref;
  93. struct pipe_poly_stipple stipple;
  94. struct pipe_scissor_state scissor;
  95. struct pipe_viewport_state viewport;
  96. struct pipe_clip_state clip;
  97. unsigned sample_mask;
  98. boolean vbo_dirty;
  99. boolean vbo_push_hint;
  100. struct draw_context *draw;
  101. };
  102. static INLINE struct nvc0_context *
  103. nvc0_context(struct pipe_context *pipe)
  104. {
  105. return (struct nvc0_context *)pipe;
  106. }
  107. struct nvc0_surface {
  108. struct pipe_surface pipe;
  109. };
  110. static INLINE struct nvc0_surface *
  111. nvc0_surface(struct pipe_surface *ps)
  112. {
  113. return (struct nvc0_surface *)ps;
  114. }
  115. static INLINE void
  116. nvc0_make_bo_resident(struct nvc0_context *nvc0, struct nouveau_bo *bo,
  117. unsigned flags)
  118. {
  119. nouveau_reloc_emit(nvc0->screen->base.channel,
  120. NULL, 0, NULL, bo, 0, 0, flags, 0, 0);
  121. }
  122. static INLINE void
  123. nvc0_make_buffer_resident(struct nvc0_context *nvc0,
  124. struct nvc0_resource *res, unsigned flags)
  125. {
  126. nvc0_resource_validate(res, flags);
  127. nvc0_make_bo_resident(nvc0, res->bo, flags);
  128. }
  129. /* nvc0_context.c */
  130. struct pipe_context *nvc0_create(struct pipe_screen *, void *);
  131. void nvc0_bufctx_emit_relocs(struct nvc0_context *);
  132. void nvc0_bufctx_reset(struct nvc0_context *, int ctx);
  133. void nvc0_bufctx_add_resident(struct nvc0_context *, int ctx,
  134. struct nvc0_resource *, uint32_t flags);
  135. void nvc0_bufctx_del_resident(struct nvc0_context *, int ctx,
  136. struct nvc0_resource *);
  137. /* nvc0_draw.c */
  138. extern struct draw_stage *nvc0_draw_render_stage(struct nvc0_context *);
  139. /* nvc0_program.c */
  140. boolean nvc0_program_translate(struct nvc0_program *);
  141. void nvc0_program_destroy(struct nvc0_context *, struct nvc0_program *);
  142. /* nvc0_shader_state.c */
  143. void nvc0_vertprog_validate(struct nvc0_context *);
  144. void nvc0_tctlprog_validate(struct nvc0_context *);
  145. void nvc0_tevlprog_validate(struct nvc0_context *);
  146. void nvc0_gmtyprog_validate(struct nvc0_context *);
  147. void nvc0_fragprog_validate(struct nvc0_context *);
  148. /* nvc0_state.c */
  149. extern void nvc0_init_state_functions(struct nvc0_context *);
  150. /* nvc0_state_validate.c */
  151. extern boolean nvc0_state_validate(struct nvc0_context *);
  152. /* nvc0_surface.c */
  153. extern void nvc0_clear(struct pipe_context *, unsigned buffers,
  154. const float *rgba, double depth, unsigned stencil);
  155. extern void nvc0_init_surface_functions(struct nvc0_context *);
  156. /* nvc0_tex.c */
  157. void nvc0_validate_textures(struct nvc0_context *);
  158. void nvc0_validate_samplers(struct nvc0_context *);
  159. struct pipe_sampler_view *
  160. nvc0_create_sampler_view(struct pipe_context *,
  161. struct pipe_resource *,
  162. const struct pipe_sampler_view *);
  163. /* nvc0_transfer.c */
  164. void
  165. nvc0_m2mf_push_linear(struct nvc0_context *nvc0,
  166. struct nouveau_bo *dst, unsigned domain, int offset,
  167. unsigned size, void *data);
  168. void
  169. nvc0_m2mf_copy_linear(struct nvc0_context *nvc0,
  170. struct nouveau_bo *dst, unsigned dstoff, unsigned dstdom,
  171. struct nouveau_bo *src, unsigned srcoff, unsigned srcdom,
  172. unsigned size);
  173. /* nvc0_vbo.c */
  174. void nvc0_draw_vbo(struct pipe_context *, const struct pipe_draw_info *);
  175. void *
  176. nvc0_vertex_state_create(struct pipe_context *pipe,
  177. unsigned num_elements,
  178. const struct pipe_vertex_element *elements);
  179. void
  180. nvc0_vertex_state_delete(struct pipe_context *pipe, void *hwcso);
  181. void nvc0_vertex_arrays_validate(struct nvc0_context *nvc0);
  182. /* nvc0_push.c */
  183. void nvc0_push_vbo(struct nvc0_context *, const struct pipe_draw_info *);
  184. void nvc0_push_vbo2(struct nvc0_context *, const struct pipe_draw_info *);
  185. #endif