util_texture.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2011-2016 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __UTIL_TEXTURE_H__
  17. #define __UTIL_TEXTURE_H__
  18. CCL_NAMESPACE_BEGIN
  19. /* Texture limits on devices. */
  20. #define TEX_NUM_MAX (INT_MAX >> 4)
  21. /* Color to use when textures are not found. */
  22. #define TEX_IMAGE_MISSING_R 1
  23. #define TEX_IMAGE_MISSING_G 0
  24. #define TEX_IMAGE_MISSING_B 1
  25. #define TEX_IMAGE_MISSING_A 1
  26. /* Texture type. */
  27. #define kernel_tex_type(tex) (tex & IMAGE_DATA_TYPE_MASK)
  28. /* Interpolation types for textures
  29. * cuda also use texture space to store other objects */
  30. typedef enum InterpolationType {
  31. INTERPOLATION_NONE = -1,
  32. INTERPOLATION_LINEAR = 0,
  33. INTERPOLATION_CLOSEST = 1,
  34. INTERPOLATION_CUBIC = 2,
  35. INTERPOLATION_SMART = 3,
  36. INTERPOLATION_NUM_TYPES,
  37. } InterpolationType;
  38. /* Texture types
  39. * Since we store the type in the lower bits of a flat index,
  40. * the shift and bit mask constant below need to be kept in sync. */
  41. typedef enum ImageDataType {
  42. IMAGE_DATA_TYPE_FLOAT4 = 0,
  43. IMAGE_DATA_TYPE_BYTE4 = 1,
  44. IMAGE_DATA_TYPE_HALF4 = 2,
  45. IMAGE_DATA_TYPE_FLOAT = 3,
  46. IMAGE_DATA_TYPE_BYTE = 4,
  47. IMAGE_DATA_TYPE_HALF = 5,
  48. IMAGE_DATA_TYPE_USHORT4 = 6,
  49. IMAGE_DATA_TYPE_USHORT = 7,
  50. IMAGE_DATA_NUM_TYPES
  51. } ImageDataType;
  52. /* Alpha types
  53. * How to treat alpha in images. */
  54. typedef enum ImageAlphaType {
  55. IMAGE_ALPHA_UNASSOCIATED = 0,
  56. IMAGE_ALPHA_ASSOCIATED = 1,
  57. IMAGE_ALPHA_CHANNEL_PACKED = 2,
  58. IMAGE_ALPHA_IGNORE = 3,
  59. IMAGE_ALPHA_AUTO = 4,
  60. IMAGE_ALPHA_NUM_TYPES,
  61. } ImageAlphaType;
  62. #define IMAGE_DATA_TYPE_SHIFT 3
  63. #define IMAGE_DATA_TYPE_MASK 0x7
  64. /* Extension types for textures.
  65. *
  66. * Defines how the image is extrapolated past its original bounds. */
  67. typedef enum ExtensionType {
  68. /* Cause the image to repeat horizontally and vertically. */
  69. EXTENSION_REPEAT = 0,
  70. /* Extend by repeating edge pixels of the image. */
  71. EXTENSION_EXTEND = 1,
  72. /* Clip to image size and set exterior pixels as transparent. */
  73. EXTENSION_CLIP = 2,
  74. EXTENSION_NUM_TYPES,
  75. } ExtensionType;
  76. typedef struct TextureInfo {
  77. /* Pointer, offset or texture depending on device. */
  78. uint64_t data;
  79. /* Buffer number for OpenCL. */
  80. uint cl_buffer;
  81. /* Interpolation and extension type. */
  82. uint interpolation, extension;
  83. /* Dimensions. */
  84. uint width, height, depth;
  85. } TextureInfo;
  86. CCL_NAMESPACE_END
  87. #endif /* __UTIL_TEXTURE_H__ */