| 31 | #include "SkrProfile/profile.h" |
| 32 | |
| 33 | CGPU_API CGPUInstanceId cgpu_create_instance(const CGPUInstanceDescriptor* desc) |
| 34 | { |
| 35 | SkrCZoneN(zz, "CGPUCreateInstance", 1); |
| 36 | |
| 37 | cgpu_assert((desc->backend == CGPU_BACKEND_VULKAN || desc->backend == CGPU_BACKEND_D3D12 || desc->backend == CGPU_BACKEND_METAL) && "CGPU support only vulkan & d3d12 & metal currently!"); |
| 38 | const CGPUProcTable* tbl = CGPU_NULLPTR; |
| 39 | const CGPUSurfacesProcTable* s_tbl = CGPU_NULLPTR; |
| 40 | |
| 41 | if (desc->backend == CGPU_BACKEND_COUNT) |
| 42 | { |
| 43 | } |
| 44 | #ifdef CGPU_USE_VULKAN |
| 45 | else if (desc->backend == CGPU_BACKEND_VULKAN) |
| 46 | { |
| 47 | tbl = CGPU_VulkanProcTable(); |
| 48 | s_tbl = CGPU_VulkanSurfacesProcTable(); |
| 49 | } |
| 50 | #endif |
| 51 | #ifdef CGPU_USE_METAL |
| 52 | else if (desc->backend == CGPU_BACKEND_METAL) |
| 53 | { |
| 54 | tbl = CGPU_MetalProcTable(); |
| 55 | s_tbl = CGPU_MetalSurfacesProcTable(); |
| 56 | } |
| 57 | #endif |
| 58 | #ifdef CGPU_USE_D3D12 |
| 59 | else if (desc->backend == CGPU_BACKEND_D3D12) |
| 60 | { |
| 61 | tbl = CGPU_D3D12ProcTable(); |
| 62 | s_tbl = CGPU_D3D12SurfacesProcTable(); |
| 63 | } |
| 64 | #endif |
| 65 | CGPUInstance* instance = (CGPUInstance*)tbl->create_instance(desc); |
| 66 | *(bool*)&instance->enable_set_name = desc->enable_set_name; |
| 67 | instance->backend = desc->backend; |
| 68 | instance->proc_table = tbl; |
| 69 | instance->surfaces_table = s_tbl; |
| 70 | if(!instance->runtime_table) |
| 71 | instance->runtime_table = cgpu_create_runtime_table(); |
| 72 | |
| 73 | SkrCZoneEnd(zz); |
| 74 | |
| 75 | return instance; |
| 76 | } |
| 77 | |
| 78 | CGPU_API ECGPUBackend cgpu_instance_get_backend(CGPUInstanceId instance) |
| 79 | { |
no test coverage detected