10 # include "device/metal/bvh.h"
16 # include <Metal/Metal.h>
22 class MetalDevice :
public Device {
24 id<MTLDevice> mtlDevice = nil;
25 id<MTLLibrary> mtlLibrary[PSO_NUM] = {nil};
26 id<MTLArgumentEncoder> mtlBufferKernelParamsEncoder =
28 id<MTLCommandQueue> mtlGeneralCommandQueue = nil;
29 id<MTLArgumentEncoder> mtlAncillaryArgEncoder =
31 string source[PSO_NUM];
32 string source_md5[PSO_NUM];
34 bool capture_enabled =
false;
39 BVHMetal *bvhMetalRT =
nullptr;
40 bool motion_blur =
false;
41 id<MTLArgumentEncoder> mtlASArgEncoder =
45 MetalGPUVendor device_vendor;
48 MTLResourceOptions default_storage_mode;
49 int max_threads_per_threadgroup;
52 bool first_error =
true;
56 int pointer_index = -1;
57 id<MTLBuffer> mtlBuffer = nil;
58 id<MTLTexture> mtlTexture = nil;
61 void *hostPtr =
nullptr;
64 typedef map<device_memory *, unique_ptr<MetalMem>> MetalMemMap;
65 MetalMemMap metal_mem_map;
66 std::vector<id<MTLResource>> delayed_free_list;
67 std::recursive_mutex metal_mem_map_mutex;
71 bool need_texture_info;
72 id<MTLArgumentEncoder> mtlTextureArgEncoder = nil;
73 id<MTLBuffer> texture_bindings_2d = nil;
74 id<MTLBuffer> texture_bindings_3d = nil;
75 std::vector<id<MTLTexture>> texture_slot_map;
77 bool use_metalrt =
false;
78 MetalPipelineType kernel_specialization_level = PSO_GENERIC;
79 std::atomic_bool async_compile_and_load =
false;
87 virtual ~MetalDevice();
89 bool support_device(
const uint );
93 bool use_adaptive_compilation();
95 void make_source(MetalPipelineType pso_type,
const uint kernel_features);
99 void reserve_local_memory(
const uint kernel_features);
101 void init_host_memory();
103 void load_texture_info();
115 bool compile_and_load(MetalPipelineType pso_type);
154 void flush_delayed_free_list();
_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 y
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
virtual void optimize_for_scene(Scene *)
virtual BVHLayoutMask get_bvh_layout_mask() const =0
virtual void const_copy_to(const char *name, void *host, size_t size)=0
virtual void mem_zero(device_memory &mem)=0
virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)=0
virtual unique_ptr< DeviceQueue > gpu_queue_create()
virtual void build_bvh(BVH *bvh, Progress &progress, bool refit)
virtual bool load_kernels(uint)
virtual bool check_peer_access(Device *)
virtual void mem_free(device_memory &mem)=0
virtual void set_error(const string &error)
virtual void mem_copy_to(device_memory &mem)=0
virtual device_ptr mem_alloc_sub_ptr(device_memory &, size_t, size_t)
virtual void mem_alloc(device_memory &mem)=0
virtual bool should_use_graphics_interop()
#define CCL_NAMESPACE_END
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static void error(const char *str)
unsigned __int64 uint64_t