summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nvc0/nvc0_program.h
blob: 2e84caecc9eead8de24edb40f8ec3725c1473c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

#ifndef __NVC0_PROGRAM_H__
#define __NVC0_PROGRAM_H__

#include "pipe/p_state.h"
#include "tgsi/tgsi_scan.h"

#define NVC0_CAP_MAX_PROGRAM_TEMPS 64

#define NVC0_SHADER_HEADER_SIZE (20 * 4)

struct nvc0_program {
   struct pipe_shader_state pipe;

   ubyte type;
   boolean translated;
   ubyte max_gpr;

   uint32_t *code;
   unsigned code_base;
   unsigned code_size;
   unsigned parm_size;

   uint32_t hdr[20];

   uint32_t flags[2];

   struct {
      uint8_t edgeflag;
      uint8_t num_ucps;
   } vp;
   struct {
      uint8_t early_z;
   } fp;

   void *relocs;
   unsigned num_relocs;

   struct nouveau_resource *res;
};

/* first 2 bits are written into the program header, for each input */
#define NVC0_INTERP_FLAT          (1 << 0)
#define NVC0_INTERP_PERSPECTIVE   (2 << 0)
#define NVC0_INTERP_LINEAR        (3 << 0)
#define NVC0_INTERP_CENTROID      (1 << 2)

/* analyze TGSI and see which TEMP[] are used as subroutine inputs/outputs */
struct nvc0_subroutine {
   unsigned id;
   unsigned first_insn;
   uint32_t argv[NVC0_CAP_MAX_PROGRAM_TEMPS][4];
   uint32_t retv[NVC0_CAP_MAX_PROGRAM_TEMPS][4];
};

struct nvc0_translation_info {
   struct nvc0_program *prog;
   struct tgsi_full_instruction *insns;
   unsigned num_insns;
   ubyte input_file;
   ubyte output_file;
   ubyte fp_depth_output;
   uint16_t input_loc[PIPE_MAX_SHADER_INPUTS][4];
   uint16_t output_loc[PIPE_MAX_SHADER_OUTPUTS][4];
   uint16_t sysval_loc[TGSI_SEMANTIC_COUNT];
   int input_access[PIPE_MAX_SHADER_INPUTS][4];
   int output_access[PIPE_MAX_SHADER_OUTPUTS][4];
   ubyte interp_mode[PIPE_MAX_SHADER_INPUTS];
   boolean indirect_inputs;
   boolean indirect_outputs;
   boolean require_stores;
   boolean global_stores;
   uint32_t *immd32;
   ubyte *immd32_ty;
   unsigned immd32_nr;
   ubyte edgeflag_out;
   struct nvc0_subroutine *subr;
   unsigned num_subrs;
   boolean append_ucp;
   struct tgsi_shader_info scan;
};

int nvc0_generate_code(struct nvc0_translation_info *);

void nvc0_relocate_program(struct nvc0_program *,
                           uint32_t code_base, uint32_t data_base);

#endif