38#ifdef WITH_VULKAN_BACKEND
41#ifdef WITH_OPENGL_BACKEND
45#ifdef WITH_METAL_BACKEND
57using namespace blender::gpu;
141 this->
dummy_vbo = GPU_vertbuf_create_with_format(format);
445 device.
index =
U.gpu_preferred_index;
456 switch (backend_type) {
472#ifdef WITH_VULKAN_BACKEND
473void GPU_vulkan_supported_devices_print(FILE *fp)
482 static bool backend_type_detected =
false;
483 if (backend_type_detected) {
486 backend_type_detected =
true;
492#if defined(WITH_OPENGL_BACKEND)
494#elif defined(WITH_METAL_BACKEND)
498#if defined(WITH_VULKAN_BACKEND)
507 "Warning: '--gpu-device' is only supported for the Vulkan backend. "
508 "Ignoring the device override for the selected %s backend and falling back to the "
509 "stored GPU preference.\n",
531#ifdef WITH_OPENGL_BACKEND
537#ifdef WITH_VULKAN_BACKEND
543#ifdef WITH_METAL_BACKEND
570#ifdef WITH_OPENGL_BACKEND
572 g_backend = MEM_new<GLBackend>(__func__);
575#ifdef WITH_VULKAN_BACKEND
577 g_backend = MEM_new<VKBackend>(__func__);
580#ifdef WITH_METAL_BACKEND
582 g_backend = MEM_new<MTLBackend>(__func__);
586 g_backend = MEM_new<DummyBackend>(__func__);
616#ifdef WITH_OPENGL_BACKEND
622#ifdef WITH_METAL_BACKEND
628#ifdef WITH_VULKAN_BACKEND
658#ifdef WITH_OPENGL_BACKEND
660 return GHOST_kDrawingContextTypeOpenGL;
662#ifdef WITH_VULKAN_BACKEND
664 return GHOST_kDrawingContextTypeVulkan;
666#ifdef WITH_METAL_BACKEND
668 return GHOST_kDrawingContextTypeMetal;
718 if (main_thread_ghost_context) {
721 if (main_thread_gpu_context) {
730 data.ghost_context->activateDrawingContext();
737 data.ghost_context->releaseDrawingContext();
749 data.ghost_context->releaseDrawingContext();
756 if (cur_ghost_context && cur_ghost_context !=
data.ghost_context) {
759 if (cur_gpu_context !=
data.gpu_context) {
763 data.ghost_context =
nullptr;
764 data.gpu_context =
nullptr;
779 data_.ghost_context->releaseDrawingContext();
791 data_.ghost_context->activateDrawingContext();
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeNone
@ GHOST_gpuNoHWRaytracing
#define GPU_batch_create(primitive_type, vertex_buf, index_buf)
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
virtual GHOST_TSuccess releaseDrawingContext()=0
static GHOST_IContext * getActiveDrawingContext()
virtual GHOST_TSuccess activateDrawingContext()=0
virtual GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpu_settings)=0
virtual GHOST_TSuccess disposeContext(GHOST_IContext *context)=0
virtual GHOST_IContext * getDrawingContext()=0
Batch * procedural_lines_batch
Batch * procedural_triangles_batch
StateManager * state_manager
GPUMatrixState * matrix_state
bool shader_builtin_srgb_is_dirty
bool is_active_on_thread()
Batch * procedural_triangles_batch_get()
TexturePool * texture_pool
FrameBuffer * front_right
VertBuf * dummy_vbo_get()
Batch * procedural_triangle_strips_batch_get()
Batch * procedural_points_batch
bool debug_pipeline_creation
virtual void activate()=0
static std::atomic< int > context_counter
Batch * procedural_triangle_strips_batch
virtual void end_frame()=0
Batch * procedural_lines_batch_get()
virtual void begin_frame()=0
Batch * procedural_points_batch_get()
virtual void deactivate()=0
virtual void init_resources()=0
virtual void render_end()=0
virtual void render_step(bool force_resource_release=false)=0
virtual void delete_resources()=0
virtual void render_begin()=0
virtual TexturePool * texturepool_alloc()=0
virtual Context * context_alloc(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)=0
static GPUBackend * get()
static bool metal_is_supported()
static bool is_supported()
static void supported_devices_print(FILE *fp)
Simple API to draw debug shapes and log in the viewport.
void GPU_activate_secondary_context(const GPUSecondaryContextData &data)
GPUSecondaryContextData GPU_create_secondary_context()
static GHOST_TDrawingContextType ghost_context_type()
BLI_INLINE MTLTexture * unwrap(Texture *tex)
void printf_begin(Context *ctx)
void GPU_deactivate_secondary_context(const GPUSecondaryContextData &data)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void GPU_destroy_secondary_context(GPUSecondaryContextData &data)
void printf_end(Context *ctx)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void GPU_matrix_state_discard(GPUMatrixState *state)
static void gpu_backend_discard()
static GPUBackendType g_backend_type
GPUContext * GPU_context_create(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)
void GPU_context_main_unlock()
GPUBackendType GPU_backend_get_type()
void GPU_context_end_frame(GPUContext *ctx)
void GPU_render_step(bool force_resource_release=false)
bool GPU_backend_supported()
GHOST_ISystem * GPU_backend_ghost_system_get()
bool GPU_backend_type_selection_detect()
static int num_backend_users
static void gpu_backend_create()
int GPU_backend_vsync_get()
static std::optional< int > g_vsync_override
void GPU_context_active_set(GPUContext *)
bool GPU_backend_type_selection_is_overridden()
static std::optional< bool > g_backend_type_supported
void GPU_context_begin_frame(GPUContext *ctx)
static Mutex backend_users_mutex
@ G_DEBUG_GPU_BACKEND_NO_FALLBACK
@ G_DEBUG_GPU_NO_HW_RAYTRACING
@ G_DEBUG_GPU_DEVICE_NO_FALLBACK
static Mutex main_context_mutex
void GPU_pass_cache_update()
void gpu_backend_delete_resources()
static std::optional< GHOST_GPUDevice > g_preferred_device_override
static std::optional< GPUBackendType > g_backend_type_override
GPUBackendType GPU_backend_type_selection_get()
BMesh const char void * data
void GPU_backend_vsync_set_override(int vsync)
void GPU_backend_type_selection_set_override(GPUBackendType backend_type)
static bool gpu_backend_supported()
const char * GPU_backend_get_name()
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
GPUMatrixState * GPU_matrix_state_create()
static GHOST_ISystem * g_ghost_system
void gpu_backend_init_resources()
static Context * active_ctx
@ G_FLAG_GPU_BACKEND_FALLBACK
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
bool GPU_backend_vsync_is_overridden()
void GPU_backend_ghost_system_set(GHOST_ISystem *ghost_system_handle)
void GPU_context_debug_pipeline_creation(GPUContext *ctx, bool enable)
Enable shader create info pipeline state assert.
GHOST_GPUDevice GPU_backend_preferred_device_get()
void GPU_backend_preferred_device_set_override(int index, uint32_t vendor_id, uint32_t device_id)
static GPUBackend * g_backend
static const char * gpu_backend_type_name(const GPUBackendType backend_type)
void GPU_backend_type_selection_set(const GPUBackendType backend)
void GPU_context_main_lock()
GPUContext * GPU_context_active_get()
void GPU_context_discard(GPUContext *)
bool fail_on_invalid_override
GHOST_TDrawingContextType context_type
GHOST_GPUDevice preferred_device