Blender V5.3
mtl_texture.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_assert.hh"
12#include "BLI_map.hh"
13#include "GPU_texture.hh"
14#include "MEM_guardedalloc.h"
15
17
18#include <mutex>
19#include <string>
20#include <thread>
21
22#include <Cocoa/Cocoa.h>
23#include <Metal/Metal.h>
24#include <QuartzCore/QuartzCore.h>
25
26@class CAMetalLayer;
27@class MTLCommandQueue;
28@class MTLRenderPipelineState;
29
30namespace blender {
31
32namespace gpu {
33class FrameBuffer;
34} // namespace gpu
35
36/* Texture Update system structs. */
38
39 /* The METAL type of data in input array, e.g. half, float, short, int */
40 std::string input_data_type;
41
42 /* The type of the texture data texture2d<T,..>, e.g. T=float, half, int etc. */
43 std::string output_data_type;
44
45 /* Number of image channels provided in input texture data array (min=1, max=4). */
47
48 /* Number of channels the destination texture has (min=1, max=4). */
50
51 /* Whether the update routine is a clear, and only the first texel of the input data buffer will
52 * be read. */
54
63
64 uint64_t hash() const
65 {
66 DefaultHash<std::string> string_hasher;
67 return uint64_t(string_hasher(this->input_data_type + this->output_data_type +
68 std::to_string((this->component_count_input << 9) |
69 (this->component_count_output << 5) |
70 (this->is_clear ? 1 : 0))));
71 }
72};
73
74/* Type of data is being written to the depth target:
75 * 0 = floating point (0.0 - 1.0)
76 * 1 = 24 bit integer (0 - 2^24)
77 * 2 = 32 bit integer (0 - 2^32) */
78
84
87
89 {
90 return ((data_mode == other.data_mode));
91 }
92
93 uint64_t hash() const
94 {
95 return uint64_t(this->data_mode);
96 }
97};
98
99/* Texture Read system structs. */
101 std::string input_data_type;
102 std::string output_data_type;
105
106 /* Format for depth data.
107 * 0 = Not a Depth format,
108 * 1 = FLOAT DEPTH,
109 * 2 = 24Bit Integer Depth,
110 * 4 = 32bit Unsigned-Integer Depth. */
112
121
123 {
124 DefaultHash<std::string> string_hasher;
125 return uint64_t(string_hasher(this->input_data_type + this->output_data_type +
126 std::to_string((this->component_count_input << 8) +
127 this->component_count_output +
128 (this->depth_format_mode << 28))));
129 }
130};
131
132namespace gpu {
133
134class MTLContext;
135class MTLVertBuf;
136class MTLStorageBuf;
137class MTLBuffer;
138
139/* Metal Texture internal implementation. */
140static const int MTL_MAX_MIPMAP_COUNT = 15; /* Max: 16384x16384 */
141static const int MTL_MAX_FBO_ATTACHED = 16;
142
143/* Samplers */
146
147 /* Mip min and mip max on sampler state always the same.
148 * Level range now controlled with textureView to be consistent with GL baseLevel. */
149 bool operator==(const MTLSamplerState &other) const
150 {
151 /* Add other parameters as needed. */
152 return (this->state == other.state);
153 }
154
155 operator uint() const
156 {
157 uint integer_representation = 0;
158 integer_representation |= this->state.filtering;
159 integer_representation |= this->state.extend_x << 8;
160 integer_representation |= this->state.extend_yz << 12;
161 integer_representation |= this->state.custom_type << 16;
162 integer_representation |= this->state.type << 24;
163 return integer_representation;
164 }
165
166 operator uint64_t() const
167 {
168 uint64_t integer_representation = 0;
169 integer_representation |= this->state.filtering;
170 integer_representation |= this->state.extend_x << 8;
171 integer_representation |= this->state.extend_yz << 12;
172 integer_representation |= this->state.custom_type << 16;
173 integer_representation |= this->state.type << 24;
174 return integer_representation;
175 }
176};
177
179
180class MTLTexture : public Texture {
181 friend class MTLContext;
182 friend class MTLStateManager;
183 friend class MTLFrameBuffer;
184 friend class MTLStorageBuf;
185 friend class MTLTexturePool;
186
187 /* Special case: The XR blitting function needs access to the Metal blit encoder and handles
188 * for directly blitting from an UNORM to an SRGB texture without color space conversion. */
189 friend void xr_blit(id<MTLTexture> metal_xr_texture, int ofsx, int ofsy, int width, int height);
190
191 private:
192 /* Where the textures data comes from. */
193 enum {
194 MTL_TEXTURE_MODE_DEFAULT, /* Texture is self-initialized (Standard). */
195 MTL_TEXTURE_MODE_EXTERNAL, /* Texture source from external id<MTLTexture> handle */
196 MTL_TEXTURE_MODE_VBO, /* Texture source initialized from VBO */
197 MTL_TEXTURE_MODE_TEXTURE_VIEW /* Texture is a view into an existing texture. */
198 } resource_mode_;
199
200 /* 'baking' refers to the generation of GPU-backed resources. This flag ensures GPU resources are
201 * ready. Baking is generally deferred until as late as possible, to ensure all associated
202 * resource state has been specified up-front. */
203 bool is_baked_ = false;
204 MTLTextureDescriptor *texture_descriptor_ = nullptr;
205 id<MTLTexture> texture_ = nil;
206
207 /* Texture Storage. */
208 size_t aligned_w_ = 0;
209
210 /* Storage buffer view.
211 * Buffer backed textures can be wrapped with a storage buffer instance for direct data
212 * reading/writing. Required for atomic operations on texture data when texture atomics are
213 * unsupported.
214 *
215 * tex_buffer_metadata_ packs 4 parameters required by the shader to perform texture space
216 * remapping: (x, y, z) = (width, height, depth/layers) (w) = aligned width. */
217 MTLBuffer *backing_buffer_ = nullptr;
218 MTLStorageBuf *storage_buffer_ = nullptr;
219 int tex_buffer_metadata_[4];
220
221 /* Blit Frame-buffer. */
222 gpu::FrameBuffer *blit_fb_ = nullptr;
223 uint blit_fb_slice_ = 0;
224 uint blit_fb_mip_ = 0;
225
226 /* Non-SRGB texture view, used for when a framebuffer is bound with SRGB disabled. */
227 id<MTLTexture> texture_no_srgb_ = nil;
228
229 /* Texture view properties */
230 /* In Metal, we use texture views to either limit mipmap ranges,
231 * , apply a swizzle mask, or both.
232 *
233 * We apply the mip limit in the view rather than in the sampler, as
234 * certain effects and functionality such as textureSize rely on the base level
235 * being modified.
236 *
237 * Texture views can also point to external textures, rather than the owned
238 * texture if MTL_TEXTURE_MODE_TEXTURE_VIEW is used.
239 * If this mode is used, source_texture points to a gpu::Texture from which
240 * we pull their texture handle as a root.
241 */
242
243 enum TextureViewDirtyState {
244 TEXTURE_VIEW_NOT_DIRTY = 0,
245 TEXTURE_VIEW_SWIZZLE_DIRTY = (1 << 0),
246 TEXTURE_VIEW_MIP_DIRTY = (1 << 1)
247 };
248 id<MTLTexture> mip_swizzle_view_ = nil;
249 char tex_swizzle_mask_[4];
250 MTLTextureSwizzleChannels mtl_swizzle_mask_;
251 bool mip_range_dirty_ = false;
252
253 bool texture_view_stencil_ = false;
254 int texture_view_dirty_flags_ = TEXTURE_VIEW_NOT_DIRTY;
255
256 /* Max mip-maps for currently allocated texture resource. */
257 int mtl_max_mips_ = 1;
258 bool has_generated_mips_ = false;
259
260 /* We may modify the requested usage flags so store them separately. */
261 eGPUTextureUsage internal_gpu_image_usage_flags_;
262
263 /* VBO. */
264 MTLVertBuf *vert_buffer_;
265 id<MTLBuffer> vert_buffer_mtl_;
266
267 /* Whether the texture's properties or state has changed (e.g. mipmap range), and re-baking of
268 * GPU resource is required. */
269 bool is_dirty_;
270
271 public:
272 MTLTexture(const char *name);
273 MTLTexture(const char *name,
274 TextureFormat format,
275 GPUTextureType type,
276 id<MTLTexture> metal_texture);
277 ~MTLTexture() override;
278
279 void update_sub(int mip,
280 int offset[3],
281 int extent[3],
282 eGPUDataFormat type,
283 const void *data,
284 const uint unpack_row_length) override;
285 void update_sub(int offset[3],
286 int extent[3],
287 eGPUDataFormat format,
288 GPUPixelBuffer *pixbuf) override;
289
290 void generate_mipmap() override;
291 void copy_to(Texture *dst, IndexRange mip_levels) override;
292 void clear(const double4 data) override;
293 void swizzle_set(const char swizzle_mask[4]) override;
294 void read(int mip, eGPUDataFormat type, void *data) override;
295
296 bool is_format_srgb();
297 bool texture_is_baked();
298 const char *get_name()
299 {
300 return name_.c_str();
301 }
302
304 {
305 return (mtl_swizzle_mask_.red != MTLTextureSwizzleRed ||
306 mtl_swizzle_mask_.green != MTLTextureSwizzleGreen ||
307 mtl_swizzle_mask_.blue != MTLTextureSwizzleBlue ||
308 mtl_swizzle_mask_.alpha != MTLTextureSwizzleAlpha);
309 }
310
312 {
313 if (resource_mode_ == MTL_TEXTURE_MODE_VBO) {
314 return vert_buffer_mtl_;
315 }
316 return nil;
317 }
318
320
321 const int *get_texture_metadata_ptr() const
322 {
323 return tex_buffer_metadata_;
324 }
325
330
331 protected:
332 bool init_internal() override;
333 bool init_internal(VertBuf *vbo) override;
334 bool init_internal(gpu::Texture *src, bool use_stencil) override; /* Texture View */
335
336 private:
337 /* Common Constructor, default initialization. */
338 void mtl_texture_init();
339
340 /* Post-construction and member initialization, prior to baking.
341 * Called during init_internal */
342 void prepare_internal();
343
344 /* Generate Metal GPU resources and upload data if needed */
345 void ensure_baked();
346
347 /* Delete associated Metal GPU resources. */
348 void reset();
349
350 void mip_range_set(int min, int max);
351 void ensure_mipmaps(int miplvl);
352
353 /* Flags a given mip level as being used. */
354 void add_subresource(uint level);
355
356 void read_internal(int mip,
357 int x_off,
358 int y_off,
359 int z_off,
360 int width,
361 int height,
362 int depth,
363 eGPUDataFormat desired_output_format,
364 int num_output_components,
365 size_t debug_data_size,
366 void *r_data);
367 void bake_mip_swizzle_view();
368
369 void blit(id<MTLBlitCommandEncoder> blit_encoder,
370 uint src_x_offset,
371 uint src_y_offset,
372 uint src_z_offset,
373 uint src_slice,
374 uint src_mip,
375 gpu::MTLTexture *dst,
376 uint dst_x_offset,
377 uint dst_y_offset,
378 uint dst_z_offset,
379 uint dst_slice,
380 uint dst_mip,
381 uint width,
382 uint height,
383 uint depth);
384 void blit(gpu::MTLTexture *dst,
385 uint src_x_offset,
386 uint src_y_offset,
387 uint dst_x_offset,
388 uint dst_y_offset,
389 uint src_mip,
390 uint dst_mip,
391 uint dst_slice,
392 int width,
393 int height);
394 gpu::FrameBuffer *get_blit_framebuffer(int dst_slice, uint dst_mip);
395 /* Texture Update function Utilities. */
396 /* Metal texture updating does not provide the same range of functionality for type conversion
397 * and format compatibility as are available in OpenGL. To achieve the same level of
398 * functionality, we need to instead use compute kernels to perform texture data conversions
399 * where appropriate.
400 * There are a number of different inputs which affect permutations and thus require different
401 * shaders and PSOs, such as:
402 * - Texture format
403 * - Texture type (e.g. 2D, 3D, 2D Array, Depth etc;)
404 * - Source data format and component count (e.g. floating point)
405 *
406 * MECHANISM:
407 *
408 * map<INPUT DEFINES STRUCT, compute PSO> update_2d_array_kernel_psos;
409 * - Generate compute shader with configured kernel below with variable parameters depending
410 * on input/output format configurations. Do not need to keep source or descriptors around,
411 * just PSO, as same input defines will always generate the same code.
412 *
413 * - IF datatype IS an exact match e.g. :
414 * - Per-component size matches (e.g. GPU_DATA_UBYTE)
415 * OR GPU_DATA_10_11_11_REV && GPU_R11G11B10 (equiv)
416 * OR D24S8 and GPU_DATA_UINT_24_8_DEPRECATED
417 * We can use BLIT ENCODER.
418 *
419 * OTHERWISE TRIGGER COMPUTE:
420 * - Compute sizes will vary. Threads per grid WILL match 'extent'.
421 * Dimensions will vary depending on texture type.
422 * - Will use setBytes with 'TextureUpdateParams' struct to pass in useful member params.
423 */
424 struct TextureUpdateParams {
425 int mip_index;
426 int extent[3]; /* Width, Height, Slice on 2D Array tex. */
427 int offset[3]; /* Width, Height, Slice on 2D Array tex. */
428 int unpack_row_length; /* Number of pixels between bytes in input data. */
429 };
430
431 id<MTLComputePipelineState> texture_update_1d_get_kernel(
433 id<MTLComputePipelineState> texture_update_1d_array_get_kernel(
435 id<MTLComputePipelineState> texture_update_2d_get_kernel(
437 id<MTLComputePipelineState> texture_update_2d_array_get_kernel(
439 id<MTLComputePipelineState> texture_update_3d_get_kernel(
441
442 id<MTLComputePipelineState> mtl_texture_update_impl(
443 TextureUpdateRoutineSpecialization specialization_params,
445 GPUTextureType texture_type);
446
447 /* Depth Update Utilities */
448 /* Depth texture updates are not directly supported with Blit operations, similarly, we cannot
449 * use a compute shader to write to depth, so we must instead render to a depth target.
450 * These processes use vertex/fragment shaders to render texture data from an intermediate
451 * source, in order to prime the depth buffer. */
452 gpu::Shader *depth_2d_update_sh_get(DepthTextureUpdateRoutineSpecialization specialization);
453
454 void update_sub_depth_2d(
455 int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data);
456
457 /* Texture Read function utilities -- Follows a similar mechanism to the updating routines */
458 struct TextureReadParams {
459 int mip_index;
460 int extent[3]; /* Width, Height, Slice on 2D Array tex. */
461 int offset[3]; /* Width, Height, Slice on 2D Array tex. */
462 };
463
464 id<MTLComputePipelineState> texture_read_1d_get_kernel(
465 TextureReadRoutineSpecialization specialization);
466 id<MTLComputePipelineState> texture_read_1d_array_get_kernel(
467 TextureReadRoutineSpecialization specialization);
468 id<MTLComputePipelineState> texture_read_2d_get_kernel(
469 TextureReadRoutineSpecialization specialization);
470 id<MTLComputePipelineState> texture_read_2d_array_get_kernel(
471 TextureReadRoutineSpecialization specialization);
472 id<MTLComputePipelineState> texture_read_3d_get_kernel(
473 TextureReadRoutineSpecialization specialization);
474
475 id<MTLComputePipelineState> mtl_texture_read_impl(
476 TextureReadRoutineSpecialization specialization_params,
477 Map<TextureReadRoutineSpecialization, id<MTLComputePipelineState>> &specialization_cache,
478 GPUTextureType texture_type);
479
480 /* fullscreen blit utilities. */
481 gpu::Shader *fullscreen_blit_sh_get();
482
483 MEM_CXX_CLASS_ALLOC_FUNCS("MTLTexture")
484};
485
487 private:
488 id<MTLBuffer> buffer_ = nil;
489
490 public:
491 MTLPixelBuffer(size_t size);
493
494 void *map() override;
495 void unmap() override;
497 size_t get_size() override;
498
500
501 MEM_CXX_CLASS_ALLOC_FUNCS("MTLPixelBuffer")
502};
503
504/* Utility */
505MTLPixelFormat gpu_texture_format_to_metal(TextureFormat tex_format);
506size_t get_mtl_format_bytesize(MTLPixelFormat tex_format);
507int get_mtl_format_num_components(MTLPixelFormat tex_format);
508bool mtl_format_supports_blending(MTLPixelFormat format);
509
510/* The type used to define the per-component data in the input buffer. */
512{
513 switch (type) {
514 case GPU_DATA_FLOAT:
515 return "float";
517 return "half";
518 case GPU_DATA_INT:
519 return "int";
520 case GPU_DATA_UINT:
521 return "uint";
522 case GPU_DATA_UBYTE:
523 return "uchar";
525 return "uint"; /* Problematic type - but will match alignment. */
528 return "float"; /* Problematic type - each component will be read as a float. */
529 default:
530 BLI_assert(false);
531 break;
532 }
533 return "";
534}
535
536/* The type T which goes into texture2d<T, access>. */
538{
539 switch (type) {
540 case GPU_DATA_FLOAT:
541 return "float";
543 return "half";
544 case GPU_DATA_INT:
545 return "int";
546 case GPU_DATA_UINT:
547 return "uint";
548 case GPU_DATA_UBYTE:
549 return "ushort";
551 return "uint"; /* Problematic type. */
554 return "float"; /* Problematic type. */
555 default:
556 BLI_assert(false);
557 break;
558 }
559 return "";
560}
561
562/* Fetch Metal texture type from GPU texture type. */
563inline MTLTextureType to_metal_type(GPUTextureType type)
564{
565 switch (type) {
566 case GPU_TEXTURE_1D:
567 return MTLTextureType1D;
568 case GPU_TEXTURE_2D:
569 return MTLTextureType2D;
570 case GPU_TEXTURE_3D:
571 return MTLTextureType3D;
572 case GPU_TEXTURE_CUBE:
573 return MTLTextureTypeCube;
575 return MTLTextureTypeTextureBuffer;
577 return MTLTextureType1DArray;
579 return MTLTextureType2DArray;
581 return MTLTextureTypeCubeArray;
582 default:
584 }
585 return MTLTextureType2D;
586}
587
588/* Determine whether format is writable or not. Use mtl_format_get_writeable_view_format(..) for
589 * these. */
590inline bool mtl_format_is_writable(MTLPixelFormat format)
591{
592 switch (format) {
593 case MTLPixelFormatRGBA8Unorm_sRGB:
594 case MTLPixelFormatBGRA8Unorm_sRGB:
595 case MTLPixelFormatDepth16Unorm:
596 case MTLPixelFormatDepth32Float:
597 case MTLPixelFormatDepth32Float_Stencil8:
598 case MTLPixelFormatBGR10A2Unorm:
599 case MTLPixelFormatDepth24Unorm_Stencil8:
600 return false;
601 default:
602 return true;
603 }
604 return true;
605}
606
607/* For the cases where a texture format is unwritable, we can create a texture view of a similar
608 * format */
609inline MTLPixelFormat mtl_format_get_writeable_view_format(MTLPixelFormat format)
610{
611 switch (format) {
612 case MTLPixelFormatRGBA8Unorm_sRGB:
613 return MTLPixelFormatRGBA8Unorm;
614 case MTLPixelFormatBGRA8Unorm_sRGB:
615 return MTLPixelFormatBGRA8Unorm;
616 case MTLPixelFormatDepth16Unorm:
617 return MTLPixelFormatR16Unorm;
618 case MTLPixelFormatDepth32Float:
619 return MTLPixelFormatR32Float;
620 case MTLPixelFormatDepth32Float_Stencil8:
621 // return MTLPixelFormatRG32Float;
622 /* No alternative mirror format. This should not be used for
623 * manual data upload */
624 return MTLPixelFormatInvalid;
625 case MTLPixelFormatBGR10A2Unorm:
626 // return MTLPixelFormatBGRA8Unorm;
627 /* No alternative mirror format. This should not be used for
628 * manual data upload */
629 return MTLPixelFormatInvalid;
630 case MTLPixelFormatDepth24Unorm_Stencil8:
631 /* No direct format, but we'll just mirror the bytes -- `Uint`
632 * should ensure bytes are not re-normalized or manipulated */
633 // return MTLPixelFormatR32Uint;
634 return MTLPixelFormatInvalid;
635 default:
636 return format;
637 }
638 return format;
639}
640
641inline MTLTextureUsage mtl_usage_from_gpu(eGPUTextureUsage usage)
642{
643 MTLTextureUsage mtl_usage = MTLTextureUsageUnknown;
644 if (usage == GPU_TEXTURE_USAGE_GENERAL) {
645 return MTLTextureUsageUnknown;
646 }
647 /* Host read implies general read support, as the compute-based host read routine requires
648 * reading of texture data. */
650 mtl_usage = mtl_usage | MTLTextureUsageShaderRead;
651 }
652 if (usage & GPU_TEXTURE_USAGE_SHADER_WRITE) {
653 mtl_usage = mtl_usage | MTLTextureUsageShaderWrite;
654 }
655 if (usage & GPU_TEXTURE_USAGE_ATTACHMENT) {
656 mtl_usage = mtl_usage | MTLTextureUsageRenderTarget;
657 }
658 if (usage & GPU_TEXTURE_USAGE_FORMAT_VIEW) {
659 mtl_usage = mtl_usage | MTLTextureUsagePixelFormatView;
660 }
661#if defined(MAC_OS_VERSION_14_0)
662 if (@available(macOS 14.0, *)) {
663 if (usage & GPU_TEXTURE_USAGE_ATOMIC) {
664 mtl_usage = mtl_usage | MTLTextureUsageShaderAtomic;
665 }
666 }
667#endif
668 return mtl_usage;
669}
670
671inline eGPUTextureUsage gpu_usage_from_mtl(MTLTextureUsage mtl_usage)
672{
674 if (mtl_usage == MTLTextureUsageUnknown) {
676 }
677 if (mtl_usage & MTLTextureUsageShaderRead) {
678 usage = usage | GPU_TEXTURE_USAGE_SHADER_READ;
679 }
680 if (mtl_usage & MTLTextureUsageShaderWrite) {
681 usage = usage | GPU_TEXTURE_USAGE_SHADER_WRITE;
682 }
683 if (mtl_usage & MTLTextureUsageRenderTarget) {
684 usage = usage | GPU_TEXTURE_USAGE_ATTACHMENT;
685 }
686 if (mtl_usage & MTLTextureUsagePixelFormatView) {
687 usage = usage | GPU_TEXTURE_USAGE_FORMAT_VIEW;
688 }
689 return usage;
690}
691
693{
694 return static_cast<MTLTexture *>(tex);
695}
696
698{
699 return static_cast<Texture *>(texture);
700}
701
702} // namespace gpu
703} // namespace blender
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define BLI_INLINE
btScalar max
void reset()
GPUPixelBufferNativeHandle get_native_handle() override
id< MTLBuffer > get_metal_buffer()
void update_sub(int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data, const uint unpack_row_length) override
id< MTLTexture > get_non_srgb_handle()
id< MTLTexture > get_metal_handle()
friend void xr_blit(id< MTLTexture > metal_xr_texture, int ofsx, int ofsy, int width, int height)
MTLTexture(const char *name)
MTLSamplerState get_sampler_state()
void read(int mip, eGPUDataFormat type, void *data) override
id< MTLTexture > get_metal_handle_base()
MTLStorageBuf * get_storagebuf()
const int * get_texture_metadata_ptr() const
void generate_mipmap() override
bool init_internal() override
void swizzle_set(const char swizzle_mask[4]) override
id< MTLBuffer > get_vertex_buffer() const
void clear(const double4 data) override
void copy_to(Texture *dst, IndexRange mip_levels) override
Texture(const char *name)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
size_t get_mtl_format_bytesize(MTLPixelFormat tex_format)
MTLPixelFormat gpu_texture_format_to_metal(TextureFormat tex_format)
static Context * unwrap(GPUContext *ctx)
static const int MTL_MAX_FBO_ATTACHED
std::string tex_data_format_to_msl_type_str(eGPUDataFormat type)
bool mtl_format_is_writable(MTLPixelFormat format)
static GPUContext * wrap(Context *ctx)
std::string tex_data_format_to_msl_texture_template_type(eGPUDataFormat type)
MTLPixelFormat mtl_format_get_writeable_view_format(MTLPixelFormat format)
int get_mtl_format_num_components(MTLPixelFormat tex_format)
static const int MTL_MAX_MIPMAP_COUNT
const MTLSamplerState DEFAULT_SAMPLER_STATE
MTLTextureUsage mtl_usage_from_gpu(eGPUTextureUsage usage)
MTLTextureType to_metal_type(GPUTextureType type)
bool mtl_format_supports_blending(MTLPixelFormat format)
eGPUTextureUsage gpu_usage_from_mtl(MTLTextureUsage mtl_usage)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
Definition BKE_text.h:91
unsigned int uint
Definition BKE_text.h:55
@ GPU_DATA_2_10_10_10_REV
@ GPU_DATA_HALF_FLOAT
@ GPU_DATA_10_11_11_REV
@ GPU_DATA_UINT_24_8_DEPRECATED
DepthTextureUpdateMode
@ MTL_DEPTH_UPDATE_MODE_INT32
@ MTL_DEPTH_UPDATE_MODE_INT24
@ MTL_DEPTH_UPDATE_MODE_FLOAT
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_GENERAL
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATOMIC
@ GPU_TEXTURE_USAGE_ATTACHMENT
BMesh const char void * data
VecBase< double, 4 > double4
#define min(a, b)
Definition sort.cc:38
bool operator==(const DepthTextureUpdateRoutineSpecialization &other) const
GPUSamplerStateType type
GPUSamplerExtendMode extend_yz
GPUSamplerFiltering filtering
GPUSamplerCustomType custom_type
GPUSamplerExtendMode extend_x
static constexpr GPUSamplerState default_sampler()
bool operator==(const TextureReadRoutineSpecialization &other) const
bool operator==(const TextureUpdateRoutineSpecialization &other) const
bool operator==(const MTLSamplerState &other) const