Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nv50_ir_driver.h 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * Copyright 2011 Christoph Bumiller
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __NV50_IR_DRIVER_H__
  23. #define __NV50_IR_DRIVER_H__
  24. #include "pipe/p_shader_tokens.h"
  25. #include "tgsi/tgsi_util.h"
  26. #include "tgsi/tgsi_parse.h"
  27. #include "tgsi/tgsi_scan.h"
  28. /*
  29. * This struct constitutes linkage information in TGSI terminology.
  30. *
  31. * It is created by the code generator and handed to the pipe driver
  32. * for input/output slot assignment.
  33. */
  34. struct nv50_ir_varying
  35. {
  36. uint8_t slot[4]; /* native slots for xyzw (addresses in 32-bit words) */
  37. unsigned mask : 4; /* vec4 mask */
  38. unsigned linear : 1; /* linearly interpolated if true (and not flat) */
  39. unsigned flat : 1;
  40. unsigned sc : 1; /* special colour interpolation mode (SHADE_MODEL) */
  41. unsigned centroid : 1;
  42. unsigned patch : 1; /* patch constant value */
  43. unsigned regular : 1; /* driver-specific meaning (e.g. input in sreg) */
  44. unsigned input : 1; /* indicates direction of system values */
  45. unsigned oread : 1; /* true if output is read from parallel TCP */
  46. ubyte id; /* TGSI register index */
  47. ubyte sn; /* TGSI semantic name */
  48. ubyte si; /* TGSI semantic index */
  49. };
  50. #define NV50_PROGRAM_IR_TGSI 0
  51. #define NV50_PROGRAM_IR_SM4 1
  52. #define NV50_PROGRAM_IR_GLSL 2
  53. #define NV50_PROGRAM_IR_LLVM 3
  54. #ifdef DEBUG
  55. # define NV50_IR_DEBUG_BASIC (1 << 0)
  56. # define NV50_IR_DEBUG_VERBOSE (2 << 0)
  57. # define NV50_IR_DEBUG_REG_ALLOC (1 << 2)
  58. #else
  59. # define NV50_IR_DEBUG_BASIC 0
  60. # define NV50_IR_DEBUG_VERBOSE 0
  61. # define NV50_IR_DEBUG_REG_ALLOC 0
  62. #endif
  63. #define NV50_SEMANTIC_CLIPDISTANCE (TGSI_SEMANTIC_COUNT + 0)
  64. #define NV50_SEMANTIC_TESSFACTOR (TGSI_SEMANTIC_COUNT + 7)
  65. #define NV50_SEMANTIC_TESSCOORD (TGSI_SEMANTIC_COUNT + 8)
  66. #define NV50_SEMANTIC_COUNT (TGSI_SEMANTIC_COUNT + 10)
  67. #define NV50_TESS_PART_FRACT_ODD 0
  68. #define NV50_TESS_PART_FRACT_EVEN 1
  69. #define NV50_TESS_PART_POW2 2
  70. #define NV50_TESS_PART_INTEGER 3
  71. #define NV50_PRIM_PATCHES PIPE_PRIM_MAX
  72. struct nv50_ir_prog_symbol
  73. {
  74. uint32_t label;
  75. uint32_t offset;
  76. };
  77. #define NVISA_GF100_CHIPSET_C0 0xc0
  78. #define NVISA_GF100_CHIPSET_D0 0xd0
  79. #define NVISA_GK104_CHIPSET 0xe0
  80. #define NVISA_GK20A_CHIPSET 0xea
  81. #define NVISA_GM107_CHIPSET 0x110
  82. struct nv50_ir_prog_info
  83. {
  84. uint16_t target; /* chipset (0x50, 0x84, 0xc0, ...) */
  85. uint8_t type; /* PIPE_SHADER */
  86. uint8_t optLevel; /* optimization level (0 to 3) */
  87. uint8_t dbgFlags;
  88. struct {
  89. int16_t maxGPR; /* may be -1 if none used */
  90. int16_t maxOutput;
  91. uint32_t tlsSpace; /* required local memory per thread */
  92. uint32_t *code;
  93. uint32_t codeSize;
  94. uint8_t sourceRep; /* NV50_PROGRAM_IR */
  95. const void *source;
  96. void *relocData;
  97. struct nv50_ir_prog_symbol *syms;
  98. uint16_t numSyms;
  99. } bin;
  100. struct nv50_ir_varying sv[PIPE_MAX_SHADER_INPUTS];
  101. struct nv50_ir_varying in[PIPE_MAX_SHADER_INPUTS];
  102. struct nv50_ir_varying out[PIPE_MAX_SHADER_OUTPUTS];
  103. uint8_t numInputs;
  104. uint8_t numOutputs;
  105. uint8_t numPatchConstants; /* also included in numInputs/numOutputs */
  106. uint8_t numSysVals;
  107. struct {
  108. uint32_t *buf; /* for IMMEDIATE_ARRAY */
  109. uint16_t bufSize; /* size of immediate array */
  110. uint16_t count; /* count of inline immediates */
  111. uint32_t *data; /* inline immediate data */
  112. uint8_t *type; /* for each vec4 (128 bit) */
  113. } immd;
  114. union {
  115. struct {
  116. uint32_t inputMask[4]; /* mask of attributes read (1 bit per scalar) */
  117. } vp;
  118. struct {
  119. uint8_t inputPatchSize;
  120. uint8_t outputPatchSize;
  121. uint8_t partitioning; /* PIPE_TESS_PART */
  122. int8_t winding; /* +1 (clockwise) / -1 (counter-clockwise) */
  123. uint8_t domain; /* PIPE_PRIM_{QUADS,TRIANGLES,LINES} */
  124. uint8_t outputPrim; /* PIPE_PRIM_{TRIANGLES,LINES,POINTS} */
  125. } tp;
  126. struct {
  127. uint8_t inputPrim;
  128. uint8_t outputPrim;
  129. unsigned instanceCount;
  130. unsigned maxVertices;
  131. } gp;
  132. struct {
  133. unsigned numColourResults;
  134. boolean writesDepth;
  135. boolean earlyFragTests;
  136. boolean separateFragData;
  137. boolean usesDiscard;
  138. } fp;
  139. struct {
  140. uint32_t inputOffset; /* base address for user args */
  141. uint32_t sharedOffset; /* reserved space in s[] */
  142. uint32_t gridInfoBase; /* base address for NTID,NCTAID */
  143. } cp;
  144. } prop;
  145. uint8_t numBarriers;
  146. struct {
  147. uint8_t clipDistance; /* index of first clip distance output */
  148. uint8_t clipDistanceMask; /* mask of clip distances defined */
  149. uint8_t cullDistanceMask; /* clip distance mode (1 bit per output) */
  150. int8_t genUserClip; /* request user clip planes for ClipVertex */
  151. uint16_t ucpBase; /* base address for UCPs */
  152. uint8_t ucpCBSlot; /* constant buffer index of UCP data */
  153. uint8_t pointSize; /* output index for PointSize */
  154. uint8_t instanceId; /* system value index of InstanceID */
  155. uint8_t vertexId; /* system value index of VertexID */
  156. uint8_t edgeFlagIn;
  157. uint8_t edgeFlagOut;
  158. int8_t viewportId; /* output index of ViewportIndex */
  159. uint8_t fragDepth; /* output index of FragDepth */
  160. uint8_t sampleMask; /* output index of SampleMask */
  161. boolean sampleInterp; /* perform sample interp on all fp inputs */
  162. uint8_t backFaceColor[2]; /* input/output indices of back face colour */
  163. uint8_t globalAccess; /* 1 for read, 2 for wr, 3 for rw */
  164. boolean nv50styleSurfaces; /* generate gX[] access for raw buffers */
  165. uint8_t resInfoCBSlot; /* cX[] used for tex handles, surface info */
  166. uint16_t texBindBase; /* base address for tex handles (nve4) */
  167. uint16_t suInfoBase; /* base address for surface info (nve4) */
  168. uint16_t sampleInfoBase; /* base address for sample positions */
  169. uint8_t msInfoCBSlot; /* cX[] used for multisample info */
  170. uint16_t msInfoBase; /* base address for multisample info */
  171. } io;
  172. /* driver callback to assign input/output locations */
  173. int (*assignSlots)(struct nv50_ir_prog_info *);
  174. void *driverPriv;
  175. };
  176. #ifdef __cplusplus
  177. extern "C" {
  178. #endif
  179. extern int nv50_ir_generate_code(struct nv50_ir_prog_info *);
  180. extern void nv50_ir_relocate_code(void *relocData, uint32_t *code,
  181. uint32_t codePos,
  182. uint32_t libPos,
  183. uint32_t dataPos);
  184. /* obtain code that will be shared among programs */
  185. extern void nv50_ir_get_target_library(uint32_t chipset,
  186. const uint32_t **code, uint32_t *size);
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190. #endif // __NV50_IR_DRIVER_H__