9 #include <Cocoa/Cocoa.h>
10 #include <Metal/Metal.h>
11 #include <QuartzCore/QuartzCore.h>
23 @class MTLCommandQueue;
24 @class MTLRenderPipelineState;
55 this->input_data_type + this->output_data_type +
56 std::to_string((this->component_count_input << 8) + this->component_count_output));
111 return (
uint64_t)string_hasher(this->input_data_type + this->output_data_type +
113 this->component_count_output +
114 (this->depth_format_mode << 28)));
136 return (this->state == other.
state);
160 MTL_TEXTURE_MODE_DEFAULT,
161 MTL_TEXTURE_MODE_EXTERNAL,
162 MTL_TEXTURE_MODE_VBO,
163 MTL_TEXTURE_MODE_TEXTURE_VIEW
170 MTLTextureDescriptor *texture_descriptor_;
171 id<MTLTexture> texture_;
172 MTLTextureUsage usage_;
175 id<MTLBuffer> texture_buffer_;
180 uint blit_fb_slice_ = 0;
181 uint blit_fb_mip_ = 0;
198 enum TextureViewDirtyState {
199 TEXTURE_VIEW_NOT_DIRTY = 0,
200 TEXTURE_VIEW_SWIZZLE_DIRTY = (1 << 0),
201 TEXTURE_VIEW_MIP_DIRTY = (1 << 1)
203 id<MTLTexture> mip_swizzle_view_;
204 char tex_swizzle_mask_[4];
205 MTLTextureSwizzleChannels mtl_swizzle_mask_;
206 bool mip_range_dirty_ =
false;
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;
214 int mtl_max_mips_ = 1;
217 MTLVertBuf *vert_buffer_;
218 id<MTLBuffer> vert_buffer_mtl_;
219 int vert_buffer_offset_;
234 id<MTLTexture> metal_texture);
243 void swizzle_set(
const char swizzle_mask[4])
override;
264 int layer_offset)
override;
268 void mtl_texture_init();
272 void prepare_internal();
279 void ensure_mipmaps(
int miplvl);
282 void add_subresource(
uint level);
284 void read_internal(
int mip,
292 int num_output_components,
295 void bake_mip_swizzle_view();
297 id<MTLTexture> get_metal_handle();
298 id<MTLTexture> get_metal_handle_base();
300 void blit(id<MTLBlitCommandEncoder> blit_encoder,
327 MEM_CXX_CLASS_ALLOC_FUNCS(
"gpu::MTLTexture")
358 struct TextureUpdateParams {
362 uint unpack_row_length;
365 id<MTLComputePipelineState> texture_update_1d_get_kernel(
367 id<MTLComputePipelineState> texture_update_1d_array_get_kernel(
369 id<MTLComputePipelineState> texture_update_2d_get_kernel(
371 id<MTLComputePipelineState> texture_update_2d_array_get_kernel(
373 id<MTLComputePipelineState> texture_update_3d_get_kernel(
376 id<MTLComputePipelineState> mtl_texture_update_impl(
379 &specialisation_cache,
389 void update_sub_depth_2d(
393 struct TextureReadParams {
399 id<MTLComputePipelineState> texture_read_1d_get_kernel(
401 id<MTLComputePipelineState> texture_read_1d_array_get_kernel(
403 id<MTLComputePipelineState> texture_read_2d_get_kernel(
405 id<MTLComputePipelineState> texture_read_2d_array_get_kernel(
407 id<MTLComputePipelineState> texture_read_3d_get_kernel(
410 id<MTLComputePipelineState> mtl_texture_read_impl(
413 &specialisation_cache,
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:
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:
512 return MTLPixelFormatInvalid;
513 case MTLPixelFormatBGR10A2Unorm:
517 return MTLPixelFormatInvalid;
518 case MTLPixelFormatDepth24Unorm_Stencil8:
522 return MTLPixelFormatInvalid;
533 switch (tex_format) {
578 BLI_assert(
false &&
"Texture not yet handled");
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
struct GPUTexture GPUTexture
struct GPUVertBuf GPUVertBuf
Read Guarded memory(de)allocation.
uint gl_bindcode_get() const override
void swizzle_set(const char swizzle_mask[4]) override
MTLTexture(const char *name)
void stencil_texture_mode_set(bool use_stencil) override
void generate_mipmap() override
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
bool init_internal() override
void clear(eGPUDataFormat format, const void *data) override
void copy_to(Texture *dst) override
char name_[DEBUG_NAME_LEN]
Texture(const char *name)
SyclQueue void void * src
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
@ MTL_DEPTH_UPDATE_MODE_INT32
@ MTL_DEPTH_UPDATE_MODE_INT24
@ MTL_DEPTH_UPDATE_MODE_FLOAT
MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format)
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)
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)
eGPUDataFormat to_mtl_internal_data_format(eGPUTextureFormat tex_format)
static const int MTL_MAX_MIPMAP_COUNT
const MTLSamplerState DEFAULT_SAMPLER_STATE
bool mtl_format_supports_blending(MTLPixelFormat format)
int get_mtl_format_bytesize(MTLPixelFormat tex_format)
std::string to_string(const T &n)
unsigned __int64 uint64_t
DepthTextureUpdateMode data_mode
bool operator==(const DepthTextureUpdateRoutineSpecialisation &other) const
std::string output_data_type
std::string input_data_type
int component_count_input
int component_count_output
bool operator==(const TextureReadRoutineSpecialisation &other) const
int component_count_output
int component_count_input
std::string input_data_type
std::string output_data_type
bool operator==(const TextureUpdateRoutineSpecialisation &other) const
bool operator==(const MTLSamplerState &other) const