nvfx: simplify and correct fragment program update logic
[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 struct pipe_shader_state pipe;
65 struct tgsi_shader_info info;
66
67 boolean translated;
68 unsigned samplers;
69 unsigned point_sprite_control;
70 unsigned or;
71
72 uint32_t *insn;
73 int insn_len;
74
75 struct nvfx_fragment_program_data *consts;
76 unsigned nr_consts;
77
78 unsigned num_slots; /* how many input semantics? */
79 unsigned char slot_to_generic[8]; /* semantics */
80 unsigned char slot_to_fp_input[8]; /* current assignment of slots for each used semantic */
81 struct util_dynarray slot_relocations[8];
82
83 /* This is reset to progs on any relocation update, and decreases every time we
84 * move to a new prog due to a constant update
85 * When this is the same as progs, applying relocations is no longer necessary.
86 */
87 unsigned progs_left_with_obsolete_slot_assignments;
88
89 unsigned long long last_vp_id;
90 unsigned last_sprite_coord_enable;
91
92 uint32_t fp_control;
93
94 unsigned bo_prog_idx;
95 unsigned prog_size;
96 unsigned progs_per_bo;
97 unsigned progs;
98
99 struct nvfx_fragment_program_bo* fpbo;
100 };
101
102
103 #endif