nvfx: refactor to support multiple fragment program versions
[mesa.git] / src / gallium / drivers / nvfx / nvfx_state.h
1 #ifndef __NVFX_STATE_H__
2 #define __NVFX_STATE_H__
3
4 #include "pipe/p_state.h"
5 #include "tgsi/tgsi_scan.h"
6 #include "nouveau/nouveau_statebuf.h"
7 #include "util/u_dynarray.h"
8 #include "util/u_linkage.h"
9
10 struct nvfx_vertex_program_exec {
11 uint32_t data[4];
12 };
13
14 struct nvfx_vertex_program_data {
15 int index; /* immediates == -1 */
16 float value[4];
17 };
18
19 struct nvfx_vertex_program {
20 struct pipe_shader_state pipe;
21 unsigned long long id;
22
23 struct draw_vertex_shader *draw;
24
25 boolean translated;
26
27 struct pipe_clip_state ucp;
28
29 struct nvfx_vertex_program_exec *insns;
30 unsigned nr_insns;
31 struct nvfx_vertex_program_data *consts;
32 unsigned nr_consts;
33
34 char generic_to_fp_input[256];
35 int sprite_fp_input;
36
37 struct nouveau_resource *exec;
38 unsigned exec_start;
39 struct nouveau_resource *data;
40 unsigned data_start;
41 unsigned data_start_min;
42
43 uint32_t ir;
44 uint32_t or;
45 uint32_t clip_ctrl;
46
47 struct util_dynarray branch_relocs;
48 struct util_dynarray const_relocs;
49 };
50
51 struct nvfx_fragment_program_data {
52 unsigned offset;
53 unsigned index;
54 };
55
56 struct nvfx_fragment_program_bo {
57 struct nvfx_fragment_program_bo* next;
58 struct nouveau_bo* bo;
59 unsigned char* slots;
60 char insn[] __attribute__((aligned(16)));
61 };
62
63 struct nvfx_fragment_program {
64 unsigned samplers;
65 unsigned point_sprite_control;
66 unsigned or;
67
68 uint32_t *insn;
69 int insn_len;
70
71 struct nvfx_fragment_program_data *consts;
72 unsigned nr_consts;
73
74 unsigned num_slots; /* how many input semantics? */
75 unsigned char slot_to_generic[8]; /* semantics */
76 unsigned char slot_to_fp_input[8]; /* current assignment of slots for each used semantic */
77 struct util_dynarray slot_relocations[8];
78
79 /* This is reset to progs on any relocation update, and decreases every time we
80 * move to a new prog due to a constant update
81 * When this is the same as progs, applying relocations is no longer necessary.
82 */
83 unsigned progs_left_with_obsolete_slot_assignments;
84
85 unsigned long long last_vp_id;
86 unsigned last_sprite_coord_enable;
87
88 uint32_t fp_control;
89
90 unsigned bo_prog_idx;
91 unsigned prog_size;
92 unsigned progs_per_bo;
93 unsigned progs;
94
95 struct nvfx_fragment_program_bo* fpbo;
96 };
97
98 struct nvfx_pipe_fragment_program {
99 struct pipe_shader_state pipe;
100 struct tgsi_shader_info info;
101
102 struct nvfx_fragment_program* fps[1];
103 };
104
105 #endif