radeon_surface.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright © 2011 Red Hat All Rights Reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sub license, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  14. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
  16. * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  18. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *
  21. * The above copyright notice and this permission notice (including the
  22. * next paragraph) shall be included in all copies or substantial portions
  23. * of the Software.
  24. */
  25. /*
  26. * Authors:
  27. * Jérôme Glisse <jglisse@redhat.com>
  28. */
  29. #ifndef RADEON_SURFACE_H
  30. #define RADEON_SURFACE_H
  31. /* Note :
  32. *
  33. * For texture array, the n layer are stored one after the other within each
  34. * mipmap level. 0 value for field than can be hint is always valid.
  35. */
  36. #define RADEON_SURF_MAX_LEVEL 32
  37. #define RADEON_SURF_TYPE_MASK 0xFF
  38. #define RADEON_SURF_TYPE_SHIFT 0
  39. #define RADEON_SURF_TYPE_1D 0
  40. #define RADEON_SURF_TYPE_2D 1
  41. #define RADEON_SURF_TYPE_3D 2
  42. #define RADEON_SURF_TYPE_CUBEMAP 3
  43. #define RADEON_SURF_TYPE_1D_ARRAY 4
  44. #define RADEON_SURF_TYPE_2D_ARRAY 5
  45. #define RADEON_SURF_MODE_MASK 0xFF
  46. #define RADEON_SURF_MODE_SHIFT 8
  47. #define RADEON_SURF_MODE_LINEAR 0
  48. #define RADEON_SURF_MODE_LINEAR_ALIGNED 1
  49. #define RADEON_SURF_MODE_1D 2
  50. #define RADEON_SURF_MODE_2D 3
  51. #define RADEON_SURF_SCANOUT (1 << 16)
  52. #define RADEON_SURF_ZBUFFER (1 << 17)
  53. #define RADEON_SURF_SBUFFER (1 << 18)
  54. #define RADEON_SURF_Z_OR_SBUFFER (RADEON_SURF_ZBUFFER | RADEON_SURF_SBUFFER)
  55. #define RADEON_SURF_HAS_SBUFFER_MIPTREE (1 << 19)
  56. #define RADEON_SURF_HAS_TILE_MODE_INDEX (1 << 20)
  57. #define RADEON_SURF_FMASK (1 << 21)
  58. #define RADEON_SURF_GET(v, field) (((v) >> RADEON_SURF_ ## field ## _SHIFT) & RADEON_SURF_ ## field ## _MASK)
  59. #define RADEON_SURF_SET(v, field) (((v) & RADEON_SURF_ ## field ## _MASK) << RADEON_SURF_ ## field ## _SHIFT)
  60. #define RADEON_SURF_CLR(v, field) ((v) & ~(RADEON_SURF_ ## field ## _MASK << RADEON_SURF_ ## field ## _SHIFT))
  61. /* first field up to mode need to match r6 struct so that we can reuse
  62. * same function for linear & linear aligned
  63. */
  64. struct radeon_surface_level {
  65. uint64_t offset;
  66. uint64_t slice_size;
  67. uint32_t npix_x;
  68. uint32_t npix_y;
  69. uint32_t npix_z;
  70. uint32_t nblk_x;
  71. uint32_t nblk_y;
  72. uint32_t nblk_z;
  73. uint32_t pitch_bytes;
  74. uint32_t mode;
  75. };
  76. enum si_tiling_mode {
  77. SI_TILING_AUTO = 0,
  78. SI_TILING_COLOR_1D,
  79. SI_TILING_COLOR_1D_SCANOUT,
  80. SI_TILING_COLOR_2D_8BPP,
  81. SI_TILING_COLOR_2D_16BPP,
  82. SI_TILING_COLOR_2D_32BPP,
  83. SI_TILING_COLOR_2D_64BPP,
  84. SI_TILING_COLOR_2D_SCANOUT_16BPP,
  85. SI_TILING_COLOR_2D_SCANOUT_32BPP,
  86. SI_TILING_COLOR_LINEAR,
  87. SI_TILING_STENCIL_1D,
  88. SI_TILING_STENCIL_2D,
  89. SI_TILING_STENCIL_2D_2AA,
  90. SI_TILING_STENCIL_2D_4AA,
  91. SI_TILING_STENCIL_2D_8AA,
  92. SI_TILING_DEPTH_1D,
  93. SI_TILING_DEPTH_2D,
  94. SI_TILING_DEPTH_2D_2AA,
  95. SI_TILING_DEPTH_2D_4AA,
  96. SI_TILING_DEPTH_2D_8AA,
  97. SI_TILING_LAST_MODE,
  98. };
  99. struct radeon_surface {
  100. uint32_t npix_x;
  101. uint32_t npix_y;
  102. uint32_t npix_z;
  103. uint32_t blk_w;
  104. uint32_t blk_h;
  105. uint32_t blk_d;
  106. uint32_t array_size;
  107. uint32_t last_level;
  108. uint32_t bpe;
  109. uint32_t nsamples;
  110. uint32_t flags;
  111. /* Following is updated/fill by the allocator. It's allowed to
  112. * set some of the value but they are use as hint and can be
  113. * overridden (things lile bankw/bankh on evergreen for
  114. * instance).
  115. */
  116. uint64_t bo_size;
  117. uint64_t bo_alignment;
  118. /* apply to eg */
  119. uint32_t bankw;
  120. uint32_t bankh;
  121. uint32_t mtilea;
  122. uint32_t tile_split;
  123. uint32_t stencil_tile_split;
  124. uint64_t stencil_offset;
  125. struct radeon_surface_level level[RADEON_SURF_MAX_LEVEL];
  126. struct radeon_surface_level stencil_level[RADEON_SURF_MAX_LEVEL];
  127. uint32_t tiling_index[RADEON_SURF_MAX_LEVEL];
  128. uint32_t stencil_tiling_index[RADEON_SURF_MAX_LEVEL];
  129. };
  130. struct radeon_surface_manager *radeon_surface_manager_new(int fd);
  131. void radeon_surface_manager_free(struct radeon_surface_manager *surf_man);
  132. int radeon_surface_init(struct radeon_surface_manager *surf_man,
  133. struct radeon_surface *surf);
  134. int radeon_surface_best(struct radeon_surface_manager *surf_man,
  135. struct radeon_surface *surf);
  136. #endif