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

midgard_compile.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (C) 2018-2019 Alyssa Rosenzweig <alyssa@rosenzweig.io>
  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 (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 NONINFRINGEMENT. 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 FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. #ifndef __MIDGARD_H_
  24. #define __MIDGARD_H_
  25. #include "compiler/nir/nir.h"
  26. #include "util/u_dynarray.h"
  27. /* Define the general compiler entry point */
  28. #define MAX_SYSVAL_COUNT 32
  29. /* Allow 2D of sysval IDs, while allowing nonparametric sysvals to equal
  30. * their class for equal comparison */
  31. #define PAN_SYSVAL(type, no) ((no << 16) | PAN_SYSVAL_##type)
  32. /* Define some common types. We start at one for easy indexing of hash
  33. * tables internal to the compiler */
  34. enum {
  35. PAN_SYSVAL_VIEWPORT_SCALE = 1,
  36. PAN_SYSVAL_VIEWPORT_OFFSET = 2,
  37. } pan_sysval;
  38. typedef struct {
  39. int work_register_count;
  40. int uniform_count;
  41. int uniform_cutoff;
  42. int attribute_count;
  43. int varying_count;
  44. /* Prepended before uniforms, mapping to SYSVAL_ names for the
  45. * sysval */
  46. unsigned sysval_count;
  47. unsigned sysvals[MAX_SYSVAL_COUNT];
  48. unsigned varyings[32];
  49. /* Boolean properties of the program */
  50. bool can_discard;
  51. bool writes_point_size;
  52. int first_tag;
  53. struct util_dynarray compiled;
  54. /* For a blend shader using a constant color -- patch point. If
  55. * negative, there's no constant. */
  56. int blend_patch_offset;
  57. /* IN: For a fragment shader with a lowered alpha test, the ref value */
  58. float alpha_ref;
  59. } midgard_program;
  60. int
  61. midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend);
  62. /* NIR options are shared between the standalone compiler and the online
  63. * compiler. Defining it here is the simplest, though maybe not the Right
  64. * solution. */
  65. static const nir_shader_compiler_options midgard_nir_options = {
  66. .lower_ffma = true,
  67. .lower_sub = true,
  68. .lower_scmp = true,
  69. .lower_flrp32 = true,
  70. .lower_flrp64 = true,
  71. .lower_ffract = true,
  72. .lower_fmod32 = true,
  73. .lower_fmod64 = true,
  74. .lower_fdiv = true,
  75. .lower_idiv = true,
  76. .lower_isign = true,
  77. .lower_fpow = true,
  78. .lower_find_lsb = true,
  79. /* TODO: We have native ops to help here, which we'll want to look into
  80. * eventually */
  81. .lower_fsign = true,
  82. .vertex_id_zero_based = true,
  83. .lower_extract_byte = true,
  84. .lower_extract_word = true,
  85. };
  86. #endif