Blender  V3.3
mtl_texture.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <Cocoa/Cocoa.h>
10 #include <Metal/Metal.h>
11 #include <QuartzCore/QuartzCore.h>
12 
13 #include "BLI_assert.h"
14 #include "MEM_guardedalloc.h"
15 #include "gpu_texture_private.hh"
16 
17 #include "BLI_map.hh"
18 #include "GPU_texture.h"
19 #include <mutex>
20 #include <thread>
21 
22 @class CAMetalLayer;
23 @class MTLCommandQueue;
24 @class MTLRenderPipelineState;
25 
26 struct GPUFrameBuffer;
27 
28 /* Texture Update system structs. */
30 
31  /* The METAL type of data in input array, e.g. half, float, short, int */
32  std::string input_data_type;
33 
34  /* The type of the texture data texture2d<T,..>, e.g. T=float, half, int etc. */
35  std::string output_data_type;
36 
37  /* Number of image channels provided in input texture data array (min=1, max=4). */
39 
40  /* Number of channels the destination texture has (min=1, max=4). */
42 
44  {
45  return ((input_data_type == other.input_data_type) &&
49  }
50 
51  uint64_t hash() const
52  {
54  return (uint64_t)string_hasher(
55  this->input_data_type + this->output_data_type +
56  std::to_string((this->component_count_input << 8) + this->component_count_output));
57  }
58 };
59 
60 /* Type of data is being written to the depth target:
61  * 0 = floating point (0.0 - 1.0)
62  * 1 = 24 bit integer (0 - 2^24)
63  * 2 = 32 bit integer (0 - 2^32) */
64 
65 typedef enum {
70 
73 
75  {
76  return ((data_mode == other.data_mode));
77  }
78 
79  uint64_t hash() const
80  {
81  return (uint64_t)(this->data_mode);
82  }
83 };
84 
85 /* Texture Read system structs. */
87  std::string input_data_type;
88  std::string output_data_type;
91 
92  /* Format for depth data.
93  * 0 = Not a Depth format,
94  * 1 = FLOAT DEPTH,
95  * 2 = 24Bit Integer Depth,
96  * 4 = 32bit Unsigned-Integer Depth. */
98 
100  {
101  return ((input_data_type == other.input_data_type) &&
102  (output_data_type == other.output_data_type) &&
106  }
107 
108  uint64_t hash() const
109  {
110  blender::DefaultHash<std::string> string_hasher;
111  return (uint64_t)string_hasher(this->input_data_type + this->output_data_type +
112  std::to_string((this->component_count_input << 8) +
113  this->component_count_output +
114  (this->depth_format_mode << 28)));
115  }
116 };
117 
118 namespace blender::gpu {
119 
120 class MTLContext;
121 class MTLVertBuf;
122 
123 /* Metal Texture internal implementation. */
124 static const int MTL_MAX_MIPMAP_COUNT = 15; /* Max: 16384x16384 */
125 static const int MTL_MAX_FBO_ATTACHED = 16;
126 
127 /* Samplers */
130 
131  /* Mip min and mip max on sampler state always the same.
132  * Level range now controlled with textureView to be consistent with GL baseLevel. */
133  bool operator==(const MTLSamplerState &other) const
134  {
135  /* Add other parameters as needed. */
136  return (this->state == other.state);
137  }
138 
139  operator uint() const
140  {
141  return (uint)state;
142  }
143 
144  operator uint64_t() const
145  {
146  return (uint64_t)state;
147  }
148 };
149 
151 
152 class MTLTexture : public Texture {
153  friend class MTLContext;
154  friend class MTLStateManager;
155  friend class MTLFrameBuffer;
156 
157  private:
158  /* Where the textures data comes from. */
159  enum {
160  MTL_TEXTURE_MODE_DEFAULT, /* Texture is self-initialized (Standard). */
161  MTL_TEXTURE_MODE_EXTERNAL, /* Texture source from external id<MTLTexture> handle */
162  MTL_TEXTURE_MODE_VBO, /* Texture source initialized from VBO */
163  MTL_TEXTURE_MODE_TEXTURE_VIEW /* Texture is a view into an existing texture. */
164  } resource_mode_;
165 
166  /* 'baking' refers to the generation of GPU-backed resources. This flag ensures GPU resources are
167  * ready. Baking is generally deferred until as late as possible, to ensure all associated
168  * resource state has been specified up-front. */
169  bool is_baked_;
170  MTLTextureDescriptor *texture_descriptor_;
171  id<MTLTexture> texture_;
172  MTLTextureUsage usage_;
173 
174  /* Texture Storage. */
175  id<MTLBuffer> texture_buffer_;
176  uint aligned_w_ = 0;
177 
178  /* Blit Frame-buffer. */
179  GPUFrameBuffer *blit_fb_ = nullptr;
180  uint blit_fb_slice_ = 0;
181  uint blit_fb_mip_ = 0;
182 
183  /* Texture view properties */
184  /* In Metal, we use texture views to either limit mipmap ranges,
185  * , apply a swizzle mask, or both.
186  *
187  * We apply the mip limit in the view rather than in the sampler, as
188  * certain effects and functionality such as textureSize rely on the base level
189  * being modified.
190  *
191  * Texture views can also point to external textures, rather than the owned
192  * texture if MTL_TEXTURE_MODE_TEXTURE_VIEW is used.
193  * If this mode is used, source_texture points to a GPUTexture from which
194  * we pull their texture handle as a root.
195  */
196  const GPUTexture *source_texture_ = nullptr;
197 
198  enum TextureViewDirtyState {
199  TEXTURE_VIEW_NOT_DIRTY = 0,
200  TEXTURE_VIEW_SWIZZLE_DIRTY = (1 << 0),
201  TEXTURE_VIEW_MIP_DIRTY = (1 << 1)
202  };
203  id<MTLTexture> mip_swizzle_view_;
204  char tex_swizzle_mask_[4];
205  MTLTextureSwizzleChannels mtl_swizzle_mask_;
206  bool mip_range_dirty_ = false;
207 
208  int mip_texture_base_level_ = 0;
209  int mip_texture_max_level_ = 1000;
210  int mip_texture_base_layer_ = 0;
211  int texture_view_dirty_flags_ = TEXTURE_VIEW_NOT_DIRTY;
212 
213  /* Max mip-maps for currently allocated texture resource. */
214  int mtl_max_mips_ = 1;
215 
216  /* VBO. */
217  MTLVertBuf *vert_buffer_;
218  id<MTLBuffer> vert_buffer_mtl_;
219  int vert_buffer_offset_;
220 
221  /* Core parameters and sub-resources. */
222  eGPUTextureUsage gpu_image_usage_flags_;
223 
224  /* Whether the texture's properties or state has changed (e.g. mipmap range), and re-baking of
225  * GPU resource is required. */
226  bool is_dirty_;
227  bool is_bound_;
228 
229  public:
230  MTLTexture(const char *name);
231  MTLTexture(const char *name,
234  id<MTLTexture> metal_texture);
235  ~MTLTexture();
236 
237  void update_sub(
238  int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data) override;
239 
240  void generate_mipmap() override;
241  void copy_to(Texture *dst) override;
242  void clear(eGPUDataFormat format, const void *data) override;
243  void swizzle_set(const char swizzle_mask[4]) override;
244  void stencil_texture_mode_set(bool use_stencil) override{
245  /* TODO(Metal): implement. */
246  };
247  void mip_range_set(int min, int max) override;
248  void *read(int mip, eGPUDataFormat type) override;
249 
250  /* Remove once no longer required -- will just return 0 for now in MTL path*/
251  uint gl_bindcode_get() const override;
252 
253  bool texture_is_baked();
254  const char *get_name()
255  {
256  return name_;
257  }
258 
259  protected:
260  bool init_internal() override;
261  bool init_internal(GPUVertBuf *vbo) override;
262  bool init_internal(const GPUTexture *src,
263  int mip_offset,
264  int layer_offset) override; /* Texture View */
265 
266  private:
267  /* Common Constructor, default initialization. */
268  void mtl_texture_init();
269 
270  /* Post-construction and member initialization, prior to baking.
271  * Called during init_internal */
272  void prepare_internal();
273 
274  /* Generate Metal GPU resources and upload data if needed */
275  void ensure_baked();
276 
277  /* Delete associated Metal GPU resources. */
278  void reset();
279  void ensure_mipmaps(int miplvl);
280 
281  /* Flags a given mip level as being used. */
282  void add_subresource(uint level);
283 
284  void read_internal(int mip,
285  int x_off,
286  int y_off,
287  int z_off,
288  int width,
289  int height,
290  int depth,
291  eGPUDataFormat desired_output_format,
292  int num_output_components,
293  int debug_data_size,
294  void *r_data);
295  void bake_mip_swizzle_view();
296 
297  id<MTLTexture> get_metal_handle();
298  id<MTLTexture> get_metal_handle_base();
299  MTLSamplerState get_sampler_state();
300  void blit(id<MTLBlitCommandEncoder> blit_encoder,
301  uint src_x_offset,
302  uint src_y_offset,
303  uint src_z_offset,
304  uint src_slice,
305  uint src_mip,
307  uint dst_x_offset,
308  uint dst_y_offset,
309  uint dst_z_offset,
310  uint dst_slice,
311  uint dst_mip,
312  uint width,
313  uint height,
314  uint depth);
315  void blit(gpu::MTLTexture *dest,
316  uint src_x_offset,
317  uint src_y_offset,
318  uint dst_x_offset,
319  uint dst_y_offset,
320  uint src_mip,
321  uint dst_mip,
322  uint dst_slice,
323  int width,
324  int height);
325  GPUFrameBuffer *get_blit_framebuffer(uint dst_slice, uint dst_mip);
326 
327  MEM_CXX_CLASS_ALLOC_FUNCS("gpu::MTLTexture")
328 
329  /* Texture Update function Utilities. */
330  /* Metal texture updating does not provide the same range of functionality for type conversion
331  * and format compatibility as are available in OpenGL. To achieve the same level of
332  * functionality, we need to instead use compute kernels to perform texture data conversions
333  * where appropriate.
334  * There are a number of different inputs which affect permutations and thus require different
335  * shaders and PSOs, such as:
336  * - Texture format
337  * - Texture type (e.g. 2D, 3D, 2D Array, Depth etc;)
338  * - Source data format and component count (e.g. floating point)
339  *
340  * MECHANISM:
341  *
342  * blender::map<INPUT DEFINES STRUCT, compute PSO> update_2d_array_kernel_psos;
343  * - Generate compute shader with configured kernel below with variable parameters depending
344  * on input/output format configurations. Do not need to keep source or descriptors around,
345  * just PSO, as same input defines will always generate the same code.
346  *
347  * - IF datatype IS an exact match e.g. :
348  * - Per-component size matches (e.g. GPU_DATA_UBYTE)
349  * OR GPU_DATA_10_11_11_REV && GPU_R11G11B10 (equiv)
350  * OR D24S8 and GPU_DATA_UINT_24_8
351  * We can use BLIT ENCODER.
352  *
353  * OTHERWISE TRIGGER COMPUTE:
354  * - Compute sizes will vary. Threads per grid WILL match 'extent'.
355  * Dimensions will vary depending on texture type.
356  * - Will use setBytes with 'TextureUpdateParams' struct to pass in useful member params.
357  */
358  struct TextureUpdateParams {
359  int mip_index;
360  int extent[3]; /* Width, Height, Slice on 2D Array tex*/
361  int offset[3]; /* Width, Height, Slice on 2D Array tex*/
362  uint unpack_row_length; /* Number of pixels between bytes in input data */
363  };
364 
365  id<MTLComputePipelineState> texture_update_1d_get_kernel(
366  TextureUpdateRoutineSpecialisation specialisation);
367  id<MTLComputePipelineState> texture_update_1d_array_get_kernel(
368  TextureUpdateRoutineSpecialisation specialisation);
369  id<MTLComputePipelineState> texture_update_2d_get_kernel(
370  TextureUpdateRoutineSpecialisation specialisation);
371  id<MTLComputePipelineState> texture_update_2d_array_get_kernel(
372  TextureUpdateRoutineSpecialisation specialisation);
373  id<MTLComputePipelineState> texture_update_3d_get_kernel(
374  TextureUpdateRoutineSpecialisation specialisation);
375 
376  id<MTLComputePipelineState> mtl_texture_update_impl(
377  TextureUpdateRoutineSpecialisation specialisation_params,
378  blender::Map<TextureUpdateRoutineSpecialisation, id<MTLComputePipelineState>>
379  &specialisation_cache,
380  eGPUTextureType texture_type);
381 
382  /* Depth Update Utilities */
383  /* Depth texture updates are not directly supported with Blit operations, similarly, we cannot
384  * use a compute shader to write to depth, so we must instead render to a depth target.
385  * These processes use vertex/fragment shaders to render texture data from an intermediate
386  * source, in order to prime the depth buffer*/
387  GPUShader *depth_2d_update_sh_get(DepthTextureUpdateRoutineSpecialisation specialisation);
388 
389  void update_sub_depth_2d(
390  int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data);
391 
392  /* Texture Read function utilities -- Follows a similar mechanism to the updating routines */
393  struct TextureReadParams {
394  int mip_index;
395  int extent[3]; /* Width, Height, Slice on 2D Array tex*/
396  int offset[3]; /* Width, Height, Slice on 2D Array tex*/
397  };
398 
399  id<MTLComputePipelineState> texture_read_1d_get_kernel(
400  TextureReadRoutineSpecialisation specialisation);
401  id<MTLComputePipelineState> texture_read_1d_array_get_kernel(
402  TextureReadRoutineSpecialisation specialisation);
403  id<MTLComputePipelineState> texture_read_2d_get_kernel(
404  TextureReadRoutineSpecialisation specialisation);
405  id<MTLComputePipelineState> texture_read_2d_array_get_kernel(
406  TextureReadRoutineSpecialisation specialisation);
407  id<MTLComputePipelineState> texture_read_3d_get_kernel(
408  TextureReadRoutineSpecialisation specialisation);
409 
410  id<MTLComputePipelineState> mtl_texture_read_impl(
411  TextureReadRoutineSpecialisation specialisation_params,
412  blender::Map<TextureReadRoutineSpecialisation, id<MTLComputePipelineState>>
413  &specialisation_cache,
414  eGPUTextureType texture_type);
415 
416  /* fullscreen blit utilities. */
417  GPUShader *fullscreen_blit_sh_get();
418 };
419 
420 /* Utility */
421 MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format);
422 int get_mtl_format_bytesize(MTLPixelFormat tex_format);
423 int get_mtl_format_num_components(MTLPixelFormat tex_format);
424 bool mtl_format_supports_blending(MTLPixelFormat format);
425 
426 /* The type used to define the per-component data in the input buffer. */
428 {
429  switch (type) {
430  case GPU_DATA_FLOAT:
431  return "float";
432  case GPU_DATA_HALF_FLOAT:
433  return "half";
434  case GPU_DATA_INT:
435  return "int";
436  case GPU_DATA_UINT:
437  return "uint";
438  case GPU_DATA_UBYTE:
439  return "uchar";
440  case GPU_DATA_UINT_24_8:
441  return "uint"; /* Problematic type - but will match alignment. */
443  return "float"; /* Problematic type - each component will be read as a float. */
444  default:
445  BLI_assert(false);
446  break;
447  }
448  return "";
449 }
450 
451 /* The type T which goes into texture2d<T, access>. */
453 {
454  switch (type) {
455  case GPU_DATA_FLOAT:
456  return "float";
457  case GPU_DATA_HALF_FLOAT:
458  return "half";
459  case GPU_DATA_INT:
460  return "int";
461  case GPU_DATA_UINT:
462  return "uint";
463  case GPU_DATA_UBYTE:
464  return "ushort";
465  case GPU_DATA_UINT_24_8:
466  return "uint"; /* Problematic type. */
468  return "float"; /* Problematic type. */
469  default:
470  BLI_assert(false);
471  break;
472  }
473  return "";
474 }
475 
476 /* Determine whether format is writable or not. Use mtl_format_get_writeable_view_format(..) for
477  * these. */
478 inline bool mtl_format_is_writable(MTLPixelFormat format)
479 {
480  switch (format) {
481  case MTLPixelFormatRGBA8Unorm_sRGB:
482  case MTLPixelFormatBGRA8Unorm_sRGB:
483  case MTLPixelFormatDepth16Unorm:
484  case MTLPixelFormatDepth32Float:
485  case MTLPixelFormatDepth32Float_Stencil8:
486  case MTLPixelFormatBGR10A2Unorm:
487  case MTLPixelFormatDepth24Unorm_Stencil8:
488  return false;
489  default:
490  return true;
491  }
492  return true;
493 }
494 
495 /* For the cases where a texture format is unwritable, we can create a texture view of a similar
496  * format */
497 inline MTLPixelFormat mtl_format_get_writeable_view_format(MTLPixelFormat format)
498 {
499  switch (format) {
500  case MTLPixelFormatRGBA8Unorm_sRGB:
501  return MTLPixelFormatRGBA8Unorm;
502  case MTLPixelFormatBGRA8Unorm_sRGB:
503  return MTLPixelFormatBGRA8Unorm;
504  case MTLPixelFormatDepth16Unorm:
505  return MTLPixelFormatR16Unorm;
506  case MTLPixelFormatDepth32Float:
507  return MTLPixelFormatR32Float;
508  case MTLPixelFormatDepth32Float_Stencil8:
509  /* return MTLPixelFormatRG32Float; */
510  /* No alternative mirror format. This should not be used for
511  * manual data upload */
512  return MTLPixelFormatInvalid;
513  case MTLPixelFormatBGR10A2Unorm:
514  /* return MTLPixelFormatBGRA8Unorm; */
515  /* No alternative mirror format. This should not be used for
516  * manual data upload */
517  return MTLPixelFormatInvalid;
518  case MTLPixelFormatDepth24Unorm_Stencil8:
519  /* No direct format, but we'll just mirror the bytes -- Uint
520  * should ensure bytes are not re-normalized or manipulated */
521  /* return MTLPixelFormatR32Uint; */
522  return MTLPixelFormatInvalid;
523  default:
524  return format;
525  }
526  return format;
527 }
528 
529 /* Returns the associated engine data type with a given texture:
530  * Definitely not complete, edit according to the METAL specification. */
532 {
533  switch (tex_format) {
534  case GPU_RGBA8:
535  case GPU_RGBA32F:
536  case GPU_RGBA16F:
537  case GPU_RGBA16:
538  case GPU_RG8:
539  case GPU_RG32F:
540  case GPU_RG16F:
541  case GPU_RG16:
542  case GPU_R8:
543  case GPU_R32F:
544  case GPU_R16F:
545  case GPU_R16:
546  case GPU_RGB16F:
550  case GPU_SRGB8_A8:
551  return GPU_DATA_FLOAT;
554  return GPU_DATA_UINT_24_8;
555  case GPU_RGBA8UI:
556  case GPU_RGBA32UI:
557  case GPU_RGBA16UI:
558  case GPU_RG8UI:
559  case GPU_RG32UI:
560  case GPU_R8UI:
561  case GPU_R16UI:
562  case GPU_RG16UI:
563  case GPU_R32UI:
564  return GPU_DATA_UINT;
565  case GPU_R8I:
566  case GPU_RG8I:
567  case GPU_R16I:
568  case GPU_R32I:
569  case GPU_RG16I:
570  case GPU_RGBA8I:
571  case GPU_RGBA32I:
572  case GPU_RGBA16I:
573  case GPU_RG32I:
574  return GPU_DATA_INT;
575  case GPU_R11F_G11F_B10F:
576  return GPU_DATA_10_11_11_REV;
577  default:
578  BLI_assert(false && "Texture not yet handled");
579  return GPU_DATA_FLOAT;
580  }
581 }
582 
583 } // namespace blender::gpu
#define BLI_assert(a)
Definition: BLI_assert.h:46
unsigned int uint
Definition: BLI_sys_types.h:67
struct GPUFrameBuffer GPUFrameBuffer
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct GPUShader GPUShader
Definition: GPU_shader.h:20
eGPUSamplerState
Definition: GPU_texture.h:25
@ GPU_SAMPLER_DEFAULT
Definition: GPU_texture.h:26
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
eGPUDataFormat
Definition: GPU_texture.h:170
@ GPU_DATA_HALF_FLOAT
Definition: GPU_texture.h:178
@ GPU_DATA_UINT_24_8
Definition: GPU_texture.h:175
@ GPU_DATA_INT
Definition: GPU_texture.h:172
@ GPU_DATA_10_11_11_REV
Definition: GPU_texture.h:176
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
@ GPU_DATA_UINT
Definition: GPU_texture.h:173
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
eGPUTextureUsage
Definition: GPU_texture.h:181
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_R16UI
Definition: GPU_texture.h:111
@ GPU_RG16F
Definition: GPU_texture.h:103
@ GPU_DEPTH32F_STENCIL8
Definition: GPU_texture.h:119
@ GPU_R16I
Definition: GPU_texture.h:112
@ GPU_SRGB8_A8
Definition: GPU_texture.h:121
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_R32I
Definition: GPU_texture.h:109
@ GPU_RG8UI
Definition: GPU_texture.h:95
@ GPU_R16F
Definition: GPU_texture.h:113
@ GPU_RG8I
Definition: GPU_texture.h:96
@ GPU_RG16I
Definition: GPU_texture.h:102
@ GPU_RG32UI
Definition: GPU_texture.h:98
@ GPU_RGBA32F
Definition: GPU_texture.h:90
@ GPU_RG8
Definition: GPU_texture.h:97
@ GPU_RG32I
Definition: GPU_texture.h:99
@ GPU_RG16
Definition: GPU_texture.h:104
@ GPU_RGBA32UI
Definition: GPU_texture.h:88
@ GPU_R8I
Definition: GPU_texture.h:106
@ GPU_R16
Definition: GPU_texture.h:114
@ GPU_RG16UI
Definition: GPU_texture.h:101
@ GPU_RGBA8I
Definition: GPU_texture.h:86
@ GPU_RGBA8UI
Definition: GPU_texture.h:85
@ GPU_RGBA16UI
Definition: GPU_texture.h:91
@ GPU_RGBA16I
Definition: GPU_texture.h:92
@ GPU_R8UI
Definition: GPU_texture.h:105
@ GPU_RGBA16
Definition: GPU_texture.h:94
@ GPU_RG32F
Definition: GPU_texture.h:100
@ GPU_R8
Definition: GPU_texture.h:107
@ GPU_DEPTH_COMPONENT24
Definition: GPU_texture.h:166
@ GPU_RGB16F
Definition: GPU_texture.h:127
@ GPU_R32UI
Definition: GPU_texture.h:108
@ GPU_RGBA32I
Definition: GPU_texture.h:89
@ GPU_DEPTH_COMPONENT32F
Definition: GPU_texture.h:165
@ GPU_DEPTH_COMPONENT16
Definition: GPU_texture.h:167
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:118
@ GPU_RGBA8
Definition: GPU_texture.h:87
struct GPUVertBuf GPUVertBuf
Read Guarded memory(de)allocation.
uint gl_bindcode_get() const override
const char * get_name()
Definition: mtl_texture.hh:254
void swizzle_set(const char swizzle_mask[4]) override
MTLTexture(const char *name)
Definition: mtl_texture.mm:67
void stencil_texture_mode_set(bool use_stencil) override
Definition: mtl_texture.hh:244
void generate_mipmap() override
Definition: mtl_texture.mm:901
void mip_range_set(int min, int max) override
void * read(int mip, eGPUDataFormat type) override
void update_sub(int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data) override
Definition: mtl_texture.mm:396
bool init_internal() override
void clear(eGPUDataFormat format, const void *data) override
void copy_to(Texture *dst) override
Definition: mtl_texture.mm:945
char name_[DEBUG_NAME_LEN]
Texture(const char *name)
Definition: gpu_texture.cc:25
SyclQueue void void * src
SyclQueue void * dest
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx GPU_R32F
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_gpu_kernel_postfix ccl_global float int int int int float bool reset
clear internal cached data and reset random seed
format
Definition: logImageCore.h:38
DepthTextureUpdateMode
Definition: mtl_texture.hh:65
@ MTL_DEPTH_UPDATE_MODE_INT32
Definition: mtl_texture.hh:68
@ MTL_DEPTH_UPDATE_MODE_INT24
Definition: mtl_texture.hh:67
@ MTL_DEPTH_UPDATE_MODE_FLOAT
Definition: mtl_texture.hh:66
MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format)
static const int MTL_MAX_FBO_ATTACHED
Definition: mtl_texture.hh:125
std::string tex_data_format_to_msl_type_str(eGPUDataFormat type)
Definition: mtl_texture.hh:427
bool mtl_format_is_writable(MTLPixelFormat format)
Definition: mtl_texture.hh:478
std::string tex_data_format_to_msl_texture_template_type(eGPUDataFormat type)
Definition: mtl_texture.hh:452
MTLPixelFormat mtl_format_get_writeable_view_format(MTLPixelFormat format)
Definition: mtl_texture.hh:497
int get_mtl_format_num_components(MTLPixelFormat tex_format)
eGPUDataFormat to_mtl_internal_data_format(eGPUTextureFormat tex_format)
Definition: mtl_texture.hh:531
static const int MTL_MAX_MIPMAP_COUNT
Definition: mtl_texture.hh:124
const MTLSamplerState DEFAULT_SAMPLER_STATE
Definition: mtl_texture.hh:150
bool mtl_format_supports_blending(MTLPixelFormat format)
int get_mtl_format_bytesize(MTLPixelFormat tex_format)
std::string to_string(const T &n)
#define min(a, b)
Definition: sort.c:35
unsigned __int64 uint64_t
Definition: stdint.h:90
bool operator==(const DepthTextureUpdateRoutineSpecialisation &other) const
Definition: mtl_texture.hh:74
bool operator==(const TextureReadRoutineSpecialisation &other) const
Definition: mtl_texture.hh:99
bool operator==(const TextureUpdateRoutineSpecialisation &other) const
Definition: mtl_texture.hh:43
bool operator==(const MTLSamplerState &other) const
Definition: mtl_texture.hh:133
float max