Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

etnaviv_compiler.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2012-2015 Etnaviv Project
  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, sub license,
  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 (including the
  12. * next paragraph) shall be included in all copies or substantial portions
  13. * of the 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Wladimir J. van der Laan <laanwj@gmail.com>
  25. */
  26. #ifndef H_ETNAVIV_COMPILER
  27. #define H_ETNAVIV_COMPILER
  28. #include "etnaviv_context.h"
  29. #include "etnaviv_internal.h"
  30. #include "etnaviv_shader.h"
  31. #include "pipe/p_compiler.h"
  32. #include "pipe/p_shader_tokens.h"
  33. /* XXX some of these are pretty arbitrary limits, may be better to switch
  34. * to dynamic allocation at some point.
  35. */
  36. #define ETNA_MAX_TEMPS (64) /* max temp register count of all Vivante hw */
  37. #define ETNA_MAX_TOKENS (2048)
  38. #define ETNA_MAX_IMM (1024) /* max const+imm in 32-bit words */
  39. #define ETNA_MAX_DECL (2048) /* max declarations */
  40. #define ETNA_MAX_DEPTH (32)
  41. #define ETNA_MAX_INSTRUCTIONS (2048)
  42. /* compiler output per input/output */
  43. struct etna_shader_inout {
  44. int reg; /* native register */
  45. struct tgsi_declaration_semantic semantic; /* tgsi semantic name and index */
  46. int num_components;
  47. };
  48. struct etna_shader_io_file {
  49. size_t num_reg;
  50. struct etna_shader_inout reg[ETNA_NUM_INPUTS];
  51. };
  52. /* shader object, for linking */
  53. struct etna_shader_variant {
  54. uint32_t id; /* for debug */
  55. uint processor; /* TGSI_PROCESSOR_... */
  56. uint32_t code_size; /* code size in uint32 words */
  57. uint32_t *code;
  58. unsigned num_loops;
  59. unsigned num_temps;
  60. struct etna_shader_uniform_info uniforms;
  61. /* ETNA_DIRTY_* flags that, when set in context dirty, mean that the
  62. * uniforms have to get (partial) reloaded. */
  63. uint32_t uniforms_dirty_bits;
  64. /* inputs (for linking) for fs, the inputs must be in register 1..N */
  65. struct etna_shader_io_file infile;
  66. /* outputs (for linking) */
  67. struct etna_shader_io_file outfile;
  68. /* index into outputs (for linking) */
  69. int output_count_per_semantic[TGSI_SEMANTIC_COUNT];
  70. struct etna_shader_inout * *output_per_semantic_list; /* list of pointers to outputs */
  71. struct etna_shader_inout **output_per_semantic[TGSI_SEMANTIC_COUNT];
  72. /* special outputs (vs only) */
  73. int vs_pos_out_reg; /* VS position output */
  74. int vs_pointsize_out_reg; /* VS point size output */
  75. uint32_t vs_load_balancing;
  76. /* special outputs (ps only) */
  77. int ps_color_out_reg; /* color output register */
  78. int ps_depth_out_reg; /* depth output register */
  79. /* unknown input property (XX_INPUT_COUNT, field UNK8) */
  80. uint32_t input_count_unk8;
  81. /* shader variants form a linked list */
  82. struct etna_shader_variant *next;
  83. /* replicated here to avoid passing extra ptrs everywhere */
  84. struct etna_shader *shader;
  85. struct etna_shader_key key;
  86. };
  87. struct etna_varying {
  88. uint32_t pa_attributes;
  89. uint8_t num_components;
  90. uint8_t use[4];
  91. uint8_t reg;
  92. };
  93. struct etna_shader_link_info {
  94. /* each PS input is annotated with the VS output reg */
  95. unsigned num_varyings;
  96. struct etna_varying varyings[ETNA_NUM_INPUTS];
  97. };
  98. bool
  99. etna_compile_shader(struct etna_shader_variant *shader);
  100. void
  101. etna_dump_shader(const struct etna_shader_variant *shader);
  102. bool
  103. etna_link_shader(struct etna_shader_link_info *info,
  104. const struct etna_shader_variant *vs, const struct etna_shader_variant *fs);
  105. void
  106. etna_destroy_shader(struct etna_shader_variant *shader);
  107. #endif