nvc0: support user clip planes
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_program.h
1
2 #ifndef __NVC0_PROGRAM_H__
3 #define __NVC0_PROGRAM_H__
4
5 #include "pipe/p_state.h"
6 #include "tgsi/tgsi_scan.h"
7
8 #define NVC0_CAP_MAX_PROGRAM_TEMPS 64
9
10 #define NVC0_SHADER_HEADER_SIZE (20 * 4)
11
12 struct nvc0_program {
13 struct pipe_shader_state pipe;
14
15 ubyte type;
16 boolean translated;
17 ubyte max_gpr;
18
19 uint32_t *code;
20 unsigned code_base;
21 unsigned code_size;
22 unsigned parm_size;
23
24 uint32_t hdr[20];
25
26 uint32_t flags[2]; /* FP_ZORDER */
27
28 struct {
29 uint8_t edgeflag;
30 uint8_t num_ucps;
31 } vp;
32
33 void *relocs;
34 unsigned num_relocs;
35
36 struct nouveau_resource *res;
37 };
38
39 /* first 2 bits are written into the program header, for each input */
40 #define NVC0_INTERP_FLAT (1 << 0)
41 #define NVC0_INTERP_PERSPECTIVE (2 << 0)
42 #define NVC0_INTERP_LINEAR (3 << 0)
43 #define NVC0_INTERP_CENTROID (1 << 2)
44
45 /* analyze TGSI and see which TEMP[] are used as subroutine inputs/outputs */
46 struct nvc0_subroutine {
47 unsigned id;
48 unsigned first_insn;
49 uint32_t argv[NVC0_CAP_MAX_PROGRAM_TEMPS][4];
50 uint32_t retv[NVC0_CAP_MAX_PROGRAM_TEMPS][4];
51 };
52
53 struct nvc0_translation_info {
54 struct nvc0_program *prog;
55 struct tgsi_full_instruction *insns;
56 unsigned num_insns;
57 ubyte input_file;
58 ubyte output_file;
59 ubyte fp_depth_output;
60 uint16_t input_loc[PIPE_MAX_SHADER_INPUTS][4];
61 uint16_t output_loc[PIPE_MAX_SHADER_OUTPUTS][4];
62 uint16_t sysval_loc[TGSI_SEMANTIC_COUNT];
63 int input_access[PIPE_MAX_SHADER_INPUTS][4];
64 int output_access[PIPE_MAX_SHADER_OUTPUTS][4];
65 ubyte interp_mode[PIPE_MAX_SHADER_INPUTS];
66 boolean indirect_inputs;
67 boolean indirect_outputs;
68 boolean require_stores;
69 uint32_t *immd32;
70 ubyte *immd32_ty;
71 unsigned immd32_nr;
72 ubyte edgeflag_out;
73 struct nvc0_subroutine *subr;
74 unsigned num_subrs;
75 boolean append_ucp;
76 struct tgsi_shader_info scan;
77 };
78
79 int nvc0_generate_code(struct nvc0_translation_info *);
80
81 void nvc0_relocate_program(struct nvc0_program *,
82 uint32_t code_base, uint32_t data_base);
83
84 #endif