Clone of mesa.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

radeon_compiler.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright 2009 Nicolai Hähnle <nhaehnle@gmail.com>
  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. * on the rights to use, copy, modify, merge, publish, distribute, sub
  8. * license, and/or sell copies of the Software, and to permit persons to whom
  9. * the Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  19. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21. * USE OR OTHER DEALINGS IN THE SOFTWARE. */
  22. #ifndef RADEON_COMPILER_H
  23. #define RADEON_COMPILER_H
  24. #include "main/mtypes.h"
  25. #include "shader/prog_instruction.h"
  26. #include "memory_pool.h"
  27. #define R300_PFS_MAX_ALU_INST 64
  28. #define R300_PFS_MAX_TEX_INST 32
  29. #define R300_PFS_MAX_TEX_INDIRECT 4
  30. #define R300_PFS_NUM_TEMP_REGS 32
  31. #define R300_PFS_NUM_CONST_REGS 32
  32. #define R500_PFS_MAX_INST 512
  33. #define R500_PFS_NUM_TEMP_REGS 128
  34. #define R500_PFS_NUM_CONST_REGS 256
  35. #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
  36. #define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
  37. /**
  38. * Stores state that influences the compilation of a fragment program.
  39. */
  40. struct r300_fragment_program_external_state {
  41. struct {
  42. /**
  43. * If the sampler is used as a shadow sampler,
  44. * this field is:
  45. * 0 - GL_LUMINANCE
  46. * 1 - GL_INTENSITY
  47. * 2 - GL_ALPHA
  48. * depending on the depth texture mode.
  49. */
  50. GLuint depth_texture_mode : 2;
  51. /**
  52. * If the sampler is used as a shadow sampler,
  53. * this field is (texture_compare_func - GL_NEVER).
  54. * [e.g. if compare function is GL_LEQUAL, this field is 3]
  55. *
  56. * Otherwise, this field is 0.
  57. */
  58. GLuint texture_compare_func : 3;
  59. } unit[16];
  60. };
  61. struct r300_fragment_program_node {
  62. int tex_offset; /**< first tex instruction */
  63. int tex_end; /**< last tex instruction, relative to tex_offset */
  64. int alu_offset; /**< first ALU instruction */
  65. int alu_end; /**< last ALU instruction, relative to alu_offset */
  66. int flags;
  67. };
  68. /**
  69. * Stores an R300 fragment program in its compiled-to-hardware form.
  70. */
  71. struct r300_fragment_program_code {
  72. struct {
  73. int length; /**< total # of texture instructions used */
  74. GLuint inst[R300_PFS_MAX_TEX_INST];
  75. } tex;
  76. struct {
  77. int length; /**< total # of ALU instructions used */
  78. struct {
  79. GLuint inst0;
  80. GLuint inst1;
  81. GLuint inst2;
  82. GLuint inst3;
  83. } inst[R300_PFS_MAX_ALU_INST];
  84. } alu;
  85. struct r300_fragment_program_node node[4];
  86. int cur_node;
  87. int first_node_has_tex;
  88. /**
  89. * Remember which program register a given hardware constant
  90. * belongs to.
  91. */
  92. struct prog_src_register constant[R300_PFS_NUM_CONST_REGS];
  93. int const_nr;
  94. int max_temp_idx;
  95. };
  96. struct r500_fragment_program_code {
  97. struct {
  98. GLuint inst0;
  99. GLuint inst1;
  100. GLuint inst2;
  101. GLuint inst3;
  102. GLuint inst4;
  103. GLuint inst5;
  104. } inst[R500_PFS_MAX_INST];
  105. int inst_offset;
  106. int inst_end;
  107. /**
  108. * Remember which program register a given hardware constant
  109. * belongs to.
  110. */
  111. struct prog_src_register constant[R500_PFS_NUM_CONST_REGS];
  112. int const_nr;
  113. int max_temp_idx;
  114. };
  115. struct rX00_fragment_program_code {
  116. union {
  117. struct r300_fragment_program_code r300;
  118. struct r500_fragment_program_code r500;
  119. } code;
  120. GLboolean writes_depth;
  121. /* attribute that we are sending the WPOS in */
  122. gl_frag_attrib wpos_attr;
  123. /* attribute that we are sending the fog coordinate in */
  124. gl_frag_attrib fog_attr;
  125. };
  126. struct rc_instruction {
  127. struct rc_instruction * Prev;
  128. struct rc_instruction * Next;
  129. struct prog_instruction I;
  130. };
  131. struct rc_program {
  132. /**
  133. * Instructions.Next points to the first instruction,
  134. * Instructions.Prev points to the last instruction.
  135. */
  136. struct rc_instruction Instructions;
  137. GLbitfield InputsRead;
  138. GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
  139. };
  140. struct radeon_compiler {
  141. struct memory_pool Pool;
  142. struct rc_program Program;
  143. GLboolean Debug;
  144. };
  145. void rc_init(struct radeon_compiler * c);
  146. void rc_destroy(struct radeon_compiler * c);
  147. struct r300_fragment_program_compiler {
  148. struct radeon_compiler Base;
  149. struct rX00_fragment_program_code *code;
  150. struct gl_program *program;
  151. struct r300_fragment_program_external_state state;
  152. GLboolean is_r500;
  153. };
  154. GLboolean r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c);
  155. #endif /* RADEON_COMPILER_H */