Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 1 | #ifndef __NV50_CONTEXT_H__ |
| 2 | #define __NV50_CONTEXT_H__ |
| 3 | |
| 4 | #include "pipe/p_context.h" |
| 5 | #include "pipe/p_defines.h" |
| 6 | #include "pipe/p_state.h" |
Ben Skeggs | f302fca | 2008-09-11 06:41:18 +1000 | [diff] [blame] | 7 | #include "pipe/p_compiler.h" |
| 8 | |
| 9 | #include "util/u_memory.h" |
| 10 | #include "util/u_math.h" |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 11 | |
Ben Skeggs | 26add92 | 2008-02-16 17:23:12 +1100 | [diff] [blame] | 12 | #include "draw/draw_vertex.h" |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 13 | |
Ben Skeggs | 26add92 | 2008-02-16 17:23:12 +1100 | [diff] [blame] | 14 | #include "nouveau/nouveau_winsys.h" |
| 15 | #include "nouveau/nouveau_gldefs.h" |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 16 | #include "nouveau/nouveau_stateobj.h" |
Ben Skeggs | 35b98e2 | 2009-10-19 09:28:59 +1000 | [diff] [blame] | 17 | #include "nouveau/nouveau_context.h" |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 18 | |
Ben Skeggs | b2e48f8 | 2008-03-12 02:39:13 +1100 | [diff] [blame] | 19 | #include "nv50_screen.h" |
Ben Skeggs | 19a1e90 | 2008-06-11 14:59:19 +1000 | [diff] [blame] | 20 | #include "nv50_program.h" |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 21 | |
| 22 | #define NOUVEAU_ERR(fmt, args...) \ |
| 23 | fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); |
| 24 | #define NOUVEAU_MSG(fmt, args...) \ |
| 25 | fprintf(stderr, "nouveau: "fmt, ##args); |
| 26 | |
Ben Skeggs | 716c1cd | 2008-06-01 23:10:31 +1000 | [diff] [blame] | 27 | /* Constant buffer assignment */ |
Ben Skeggs | f50e78e | 2008-06-11 15:28:41 +1000 | [diff] [blame] | 28 | #define NV50_CB_PMISC 0 |
| 29 | #define NV50_CB_PVP 1 |
Ben Skeggs | 716c1cd | 2008-06-01 23:10:31 +1000 | [diff] [blame] | 30 | #define NV50_CB_PFP 2 |
| 31 | #define NV50_CB_PGP 3 |
| 32 | #define NV50_CB_TIC 4 |
| 33 | #define NV50_CB_TSC 5 |
Ben Skeggs | cae38d0 | 2008-06-16 16:29:40 +1000 | [diff] [blame] | 34 | #define NV50_CB_PUPLOAD 6 |
Ben Skeggs | 716c1cd | 2008-06-01 23:10:31 +1000 | [diff] [blame] | 35 | |
Ben Skeggs | 2fee5f7 | 2008-03-12 03:54:53 +1100 | [diff] [blame] | 36 | #define NV50_NEW_BLEND (1 << 0) |
| 37 | #define NV50_NEW_ZSA (1 << 1) |
| 38 | #define NV50_NEW_BLEND_COLOUR (1 << 2) |
| 39 | #define NV50_NEW_STIPPLE (1 << 3) |
| 40 | #define NV50_NEW_SCISSOR (1 << 4) |
| 41 | #define NV50_NEW_VIEWPORT (1 << 5) |
Ben Skeggs | cd85dc1 | 2008-03-12 04:29:58 +1100 | [diff] [blame] | 42 | #define NV50_NEW_RASTERIZER (1 << 6) |
Ben Skeggs | cd9ed05 | 2008-03-12 04:50:53 +1100 | [diff] [blame] | 43 | #define NV50_NEW_FRAMEBUFFER (1 << 7) |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 44 | #define NV50_NEW_VERTPROG (1 << 8) |
Ben Skeggs | 716c1cd | 2008-06-01 23:10:31 +1000 | [diff] [blame] | 45 | #define NV50_NEW_VERTPROG_CB (1 << 9) |
| 46 | #define NV50_NEW_FRAGPROG (1 << 10) |
| 47 | #define NV50_NEW_FRAGPROG_CB (1 << 11) |
| 48 | #define NV50_NEW_ARRAYS (1 << 12) |
Ben Skeggs | c0ed6a8 | 2008-06-13 12:09:46 +1000 | [diff] [blame] | 49 | #define NV50_NEW_SAMPLER (1 << 13) |
| 50 | #define NV50_NEW_TEXTURE (1 << 14) |
Ben Skeggs | 3250bac | 2008-03-12 02:56:10 +1100 | [diff] [blame] | 51 | |
| 52 | struct nv50_blend_stateobj { |
| 53 | struct pipe_blend_state pipe; |
| 54 | struct nouveau_stateobj *so; |
| 55 | }; |
| 56 | |
Ben Skeggs | 06bd7d7 | 2008-03-12 03:41:05 +1100 | [diff] [blame] | 57 | struct nv50_zsa_stateobj { |
| 58 | struct pipe_depth_stencil_alpha_state pipe; |
| 59 | struct nouveau_stateobj *so; |
| 60 | }; |
| 61 | |
Ben Skeggs | cd85dc1 | 2008-03-12 04:29:58 +1100 | [diff] [blame] | 62 | struct nv50_rasterizer_stateobj { |
| 63 | struct pipe_rasterizer_state pipe; |
| 64 | struct nouveau_stateobj *so; |
| 65 | }; |
| 66 | |
Ben Skeggs | 6c1627a | 2009-06-06 10:57:19 +1000 | [diff] [blame] | 67 | struct nv50_sampler_stateobj { |
Roland Scheidegger | 47c7801 | 2009-12-08 17:51:19 +0100 | [diff] [blame] | 68 | boolean normalized; |
Ben Skeggs | 6c1627a | 2009-06-06 10:57:19 +1000 | [diff] [blame] | 69 | unsigned tsc[8]; |
| 70 | }; |
| 71 | |
Christoph Bumiller | 040e1d0 | 2009-11-03 23:19:56 +0100 | [diff] [blame] | 72 | static INLINE unsigned |
| 73 | get_tile_height(uint32_t tile_mode) |
| 74 | { |
| 75 | return 1 << ((tile_mode & 0xf) + 2); |
| 76 | } |
| 77 | |
| 78 | static INLINE unsigned |
| 79 | get_tile_depth(uint32_t tile_mode) |
| 80 | { |
| 81 | return 1 << (tile_mode >> 4); |
| 82 | } |
| 83 | |
Ben Skeggs | 103020f | 2009-01-12 13:42:19 +1000 | [diff] [blame] | 84 | struct nv50_miptree_level { |
Ben Skeggs | 103020f | 2009-01-12 13:42:19 +1000 | [diff] [blame] | 85 | int *image_offset; |
Ben Skeggs | 63a3a37 | 2009-02-20 09:32:47 +1000 | [diff] [blame] | 86 | unsigned pitch; |
Christoph Bumiller | 442a5e4 | 2009-08-14 18:23:55 +0200 | [diff] [blame] | 87 | unsigned tile_mode; |
Ben Skeggs | 103020f | 2009-01-12 13:42:19 +1000 | [diff] [blame] | 88 | }; |
| 89 | |
Ben Skeggs | c0ed6a8 | 2008-06-13 12:09:46 +1000 | [diff] [blame] | 90 | struct nv50_miptree { |
Ben Skeggs | 02f3245 | 2009-08-31 13:00:34 +1000 | [diff] [blame] | 91 | struct nouveau_miptree base; |
Ben Skeggs | 17cbe45 | 2009-01-05 14:56:41 +1100 | [diff] [blame] | 92 | |
Ben Skeggs | 103020f | 2009-01-12 13:42:19 +1000 | [diff] [blame] | 93 | struct nv50_miptree_level level[PIPE_MAX_TEXTURE_LEVELS]; |
Ben Skeggs | 17cbe45 | 2009-01-05 14:56:41 +1100 | [diff] [blame] | 94 | int image_nr; |
| 95 | int total_size; |
Ben Skeggs | c0ed6a8 | 2008-06-13 12:09:46 +1000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | static INLINE struct nv50_miptree * |
| 99 | nv50_miptree(struct pipe_texture *pt) |
| 100 | { |
| 101 | return (struct nv50_miptree *)pt; |
| 102 | } |
| 103 | |
Ben Skeggs | 9b0add0 | 2008-07-11 22:45:11 +1000 | [diff] [blame] | 104 | struct nv50_surface { |
| 105 | struct pipe_surface base; |
Ben Skeggs | 9b0add0 | 2008-07-11 22:45:11 +1000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static INLINE struct nv50_surface * |
| 109 | nv50_surface(struct pipe_surface *pt) |
| 110 | { |
| 111 | return (struct nv50_surface *)pt; |
| 112 | } |
| 113 | |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 114 | struct nv50_state { |
| 115 | unsigned dirty; |
| 116 | |
| 117 | struct nouveau_stateobj *fb; |
| 118 | struct nouveau_stateobj *blend; |
| 119 | struct nouveau_stateobj *blend_colour; |
| 120 | struct nouveau_stateobj *zsa; |
| 121 | struct nouveau_stateobj *rast; |
| 122 | struct nouveau_stateobj *stipple; |
| 123 | struct nouveau_stateobj *scissor; |
Ben Skeggs | 035a04d | 2008-06-16 22:34:50 +1000 | [diff] [blame] | 124 | unsigned scissor_enabled; |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 125 | struct nouveau_stateobj *viewport; |
Ben Skeggs | 7a81ffa | 2008-07-11 01:53:28 +1000 | [diff] [blame] | 126 | unsigned viewport_bypass; |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 127 | struct nouveau_stateobj *tsc_upload; |
| 128 | struct nouveau_stateobj *tic_upload; |
Christoph Bumiller | 6a15ec9 | 2009-12-10 20:50:02 +0100 | [diff] [blame^] | 129 | unsigned miptree_nr[PIPE_SHADER_TYPES]; |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 130 | struct nouveau_stateobj *vertprog; |
| 131 | struct nouveau_stateobj *fragprog; |
Christoph Bumiller | 6516594 | 2009-09-14 20:23:39 +0200 | [diff] [blame] | 132 | struct nouveau_stateobj *programs; |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 133 | struct nouveau_stateobj *vtxfmt; |
| 134 | struct nouveau_stateobj *vtxbuf; |
Christoph Bumiller | d7c5555 | 2009-08-20 21:39:02 +0200 | [diff] [blame] | 135 | struct nouveau_stateobj *vtxattr; |
Christoph Bumiller | c0e80cf | 2009-10-14 21:23:29 +0200 | [diff] [blame] | 136 | unsigned vtxelt_nr; |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 137 | }; |
| 138 | |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 139 | struct nv50_context { |
| 140 | struct pipe_context pipe; |
Ben Skeggs | b2e48f8 | 2008-03-12 02:39:13 +1100 | [diff] [blame] | 141 | |
| 142 | struct nv50_screen *screen; |
| 143 | unsigned pctx_id; |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 144 | |
| 145 | struct draw_context *draw; |
Ben Skeggs | 3250bac | 2008-03-12 02:56:10 +1100 | [diff] [blame] | 146 | |
Ben Skeggs | bb9efb5 | 2008-06-16 22:24:16 +1000 | [diff] [blame] | 147 | struct nv50_state state; |
| 148 | |
Ben Skeggs | 3250bac | 2008-03-12 02:56:10 +1100 | [diff] [blame] | 149 | unsigned dirty; |
| 150 | struct nv50_blend_stateobj *blend; |
Ben Skeggs | 06bd7d7 | 2008-03-12 03:41:05 +1100 | [diff] [blame] | 151 | struct nv50_zsa_stateobj *zsa; |
Ben Skeggs | cd85dc1 | 2008-03-12 04:29:58 +1100 | [diff] [blame] | 152 | struct nv50_rasterizer_stateobj *rasterizer; |
Ben Skeggs | 2fee5f7 | 2008-03-12 03:54:53 +1100 | [diff] [blame] | 153 | struct pipe_blend_color blend_colour; |
| 154 | struct pipe_poly_stipple stipple; |
| 155 | struct pipe_scissor_state scissor; |
| 156 | struct pipe_viewport_state viewport; |
Ben Skeggs | cd9ed05 | 2008-03-12 04:50:53 +1100 | [diff] [blame] | 157 | struct pipe_framebuffer_state framebuffer; |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 158 | struct nv50_program *vertprog; |
| 159 | struct nv50_program *fragprog; |
| 160 | struct pipe_buffer *constbuf[PIPE_SHADER_TYPES]; |
| 161 | struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; |
| 162 | unsigned vtxbuf_nr; |
| 163 | struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; |
| 164 | unsigned vtxelt_nr; |
Christoph Bumiller | 6a15ec9 | 2009-12-10 20:50:02 +0100 | [diff] [blame^] | 165 | struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; |
| 166 | unsigned sampler_nr[PIPE_SHADER_TYPES]; |
| 167 | struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; |
| 168 | unsigned miptree_nr[PIPE_SHADER_TYPES]; |
Christoph Bumiller | c0e80cf | 2009-10-14 21:23:29 +0200 | [diff] [blame] | 169 | |
| 170 | uint16_t vbo_fifo; |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 171 | }; |
| 172 | |
Ben Skeggs | 3250bac | 2008-03-12 02:56:10 +1100 | [diff] [blame] | 173 | static INLINE struct nv50_context * |
| 174 | nv50_context(struct pipe_context *pipe) |
| 175 | { |
| 176 | return (struct nv50_context *)pipe; |
| 177 | } |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 178 | |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 179 | extern void nv50_init_surface_functions(struct nv50_context *nv50); |
| 180 | extern void nv50_init_state_functions(struct nv50_context *nv50); |
Ben Skeggs | b8965be | 2007-12-09 03:22:14 +1100 | [diff] [blame] | 181 | extern void nv50_init_query_functions(struct nv50_context *nv50); |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 182 | |
Ben Skeggs | 84cc07d | 2008-02-29 15:03:57 +1100 | [diff] [blame] | 183 | extern void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen); |
| 184 | |
Younes Manton | 32cd1a0 | 2009-02-07 12:53:30 -0500 | [diff] [blame] | 185 | extern int |
| 186 | nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst, |
| 187 | int dx, int dy, struct pipe_surface *src, int sx, int sy, |
| 188 | int w, int h); |
| 189 | |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 190 | /* nv50_draw.c */ |
| 191 | extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50); |
| 192 | |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 193 | /* nv50_vbo.c */ |
| 194 | extern boolean nv50_draw_arrays(struct pipe_context *, unsigned mode, |
| 195 | unsigned start, unsigned count); |
| 196 | extern boolean nv50_draw_elements(struct pipe_context *pipe, |
Ben Skeggs | 3e39bc3 | 2008-01-28 18:32:46 +1100 | [diff] [blame] | 197 | struct pipe_buffer *indexBuffer, |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 198 | unsigned indexSize, |
| 199 | unsigned mode, unsigned start, |
| 200 | unsigned count); |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 201 | extern void nv50_vbo_validate(struct nv50_context *nv50); |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 202 | |
| 203 | /* nv50_clear.c */ |
Michel Dänzer | eb168e2 | 2009-04-04 19:01:51 +0200 | [diff] [blame] | 204 | extern void nv50_clear(struct pipe_context *pipe, unsigned buffers, |
| 205 | const float *rgba, double depth, unsigned stencil); |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 206 | |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 207 | /* nv50_program.c */ |
| 208 | extern void nv50_vertprog_validate(struct nv50_context *nv50); |
| 209 | extern void nv50_fragprog_validate(struct nv50_context *nv50); |
Christoph Bumiller | 6516594 | 2009-09-14 20:23:39 +0200 | [diff] [blame] | 210 | extern void nv50_linkage_validate(struct nv50_context *nv50); |
Christoph Bumiller | 9831e1f | 2009-10-31 13:38:22 +0100 | [diff] [blame] | 211 | extern void nv50_program_destroy(struct nv50_context *nv50, |
| 212 | struct nv50_program *p); |
Ben Skeggs | f722fd9 | 2008-06-01 22:41:40 +1000 | [diff] [blame] | 213 | |
| 214 | /* nv50_state_validate.c */ |
Ben Skeggs | 9c29512 | 2008-03-12 02:59:20 +1100 | [diff] [blame] | 215 | extern boolean nv50_state_validate(struct nv50_context *nv50); |
Maarten Maathuis | db37279 | 2009-09-14 19:42:53 +0200 | [diff] [blame] | 216 | extern void nv50_state_flush_notify(struct nouveau_channel *chan); |
Ben Skeggs | 9c29512 | 2008-03-12 02:59:20 +1100 | [diff] [blame] | 217 | |
Christoph Bumiller | fba2eab | 2009-10-10 13:13:16 +0200 | [diff] [blame] | 218 | extern void nv50_so_init_sifc(struct nv50_context *nv50, |
| 219 | struct nouveau_stateobj *so, |
| 220 | struct nouveau_bo *bo, unsigned reloc, |
Christoph Bumiller | 6a15ec9 | 2009-12-10 20:50:02 +0100 | [diff] [blame^] | 221 | unsigned offset, unsigned size); |
Christoph Bumiller | fba2eab | 2009-10-10 13:13:16 +0200 | [diff] [blame] | 222 | |
Ben Skeggs | 6210069 | 2008-07-11 20:49:06 +1000 | [diff] [blame] | 223 | /* nv50_tex.c */ |
| 224 | extern void nv50_tex_validate(struct nv50_context *); |
| 225 | |
Christoph Bumiller | 9831e1f | 2009-10-31 13:38:22 +0100 | [diff] [blame] | 226 | /* nv50_transfer.c */ |
| 227 | extern void |
| 228 | nv50_upload_sifc(struct nv50_context *nv50, |
| 229 | struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc, |
| 230 | unsigned dst_format, int dst_w, int dst_h, int dst_pitch, |
| 231 | void *src, unsigned src_format, int src_pitch, |
| 232 | int x, int y, int w, int h, int cpp); |
| 233 | |
Ben Skeggs | 47b418b | 2007-12-05 14:01:01 +1100 | [diff] [blame] | 234 | #endif |