Merge branch 'master' into pipe-video
[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 "pipe/p_video_state.h"
6 #include "tgsi/tgsi_scan.h"
7 #include "nouveau/nouveau_statebuf.h"
8 #include "util/u_dynarray.h"
9 #include "util/u_linkage.h"
10
11 struct nvfx_vertex_program_exec {
12 uint32_t data[4];
13 };
14
15 struct nvfx_vertex_program_data {
16 int index; /* immediates == -1 */
17 float value[4];
18 };
19
20 struct nvfx_vertex_program {
21 unsigned long long id;
22
23 struct nvfx_vertex_program_exec *insns;
24 unsigned nr_insns;
25 struct nvfx_vertex_program_data *consts;
26 unsigned nr_consts;
27
28 char generic_to_fp_input[256];
29 int sprite_fp_input;
30
31 struct nouveau_resource *exec;
32 unsigned exec_start;
33 struct nouveau_resource *data;
34 unsigned data_start;
35 unsigned data_start_min;
36
37 uint32_t ir;
38 uint32_t or;
39 int clip_nr;
40
41 struct util_dynarray branch_relocs;
42 struct util_dynarray const_relocs;
43 };
44
45 #define NVFX_VP_FAILED ((struct nvfx_vertex_program*)-1)
46
47 struct nvfx_pipe_vertex_program {
48 struct pipe_shader_state pipe;
49 struct tgsi_shader_info info;
50
51 unsigned draw_elements;
52 boolean draw_no_elements;
53 struct draw_vertex_shader *draw_vs;
54 struct nvfx_vertex_program* draw_vp;
55
56 struct nvfx_vertex_program* vp;
57 };
58
59 struct nvfx_fragment_program_data {
60 unsigned offset;
61 unsigned index;
62 };
63
64 struct nvfx_fragment_program_bo {
65 struct nvfx_fragment_program_bo* next;
66 struct nouveau_bo* bo;
67 unsigned char* slots;
68 char insn[] __attribute__((aligned(16)));
69 };
70
71 struct nvfx_fragment_program {
72 unsigned samplers;
73 unsigned point_sprite_control;
74 unsigned or;
75 unsigned coord_conventions;
76
77 uint32_t *insn;
78 int insn_len;
79
80 struct nvfx_fragment_program_data *consts;
81 unsigned nr_consts;
82
83 /* the slot at num_slots is for the sprite coordinate, if any */
84 unsigned num_slots; /* how many input semantics? */
85 unsigned char slot_to_generic[10]; /* semantics */
86 unsigned char slot_to_fp_input[11]; /* current assignment of slots for each used semantic */
87 struct util_dynarray slot_relocations[11];
88
89 /* This is reset to progs on any relocation update, and decreases every time we
90 * move to a new prog due to a constant update
91 * When this is the same as progs, applying relocations is no longer necessary.
92 */
93 unsigned progs_left_with_obsolete_slot_assignments;
94
95 unsigned long long last_vp_id;
96 unsigned last_sprite_coord_enable;
97
98 uint32_t fp_control;
99
100 unsigned bo_prog_idx;
101 unsigned prog_size;
102 unsigned progs_per_bo;
103 unsigned progs;
104
105 struct nvfx_fragment_program_bo* fpbo;
106 };
107
108 struct nvfx_pipe_fragment_program {
109 struct pipe_shader_state pipe;
110 struct tgsi_shader_info info;
111
112 struct nvfx_fragment_program* fps[2];
113 };
114
115 #endif