Blender V5.0
GHOST_ContextMTL Class Reference

#include <GHOST_ContextMTL.hh>

Inherits GHOST_Context.

Public Member Functions

 GHOST_ContextMTL (const GHOST_ContextParams &context_params, NSView *metalView, CAMetalLayer *metalLayer)
 ~GHOST_ContextMTL () override
GHOST_TSuccess swapBufferAcquire () override
GHOST_TSuccess swapBufferRelease () override
GHOST_TSuccess activateDrawingContext () override
GHOST_TSuccess releaseDrawingContext () override
unsigned int getDefaultFramebuffer () override
GHOST_TSuccess initializeDrawingContext () override
GHOST_TSuccess releaseNativeHandles () override
GHOST_TSuccess setSwapInterval (int interval) override
GHOST_TSuccess getSwapInterval (int &interval_out) override
GHOST_TSuccess updateDrawingContext () override
id< MTLTexture > metalOverlayTexture ()
MTLCommandQueue * metalCommandQueue ()
MTLDevice * metalDevice ()
void metalRegisterPresentCallback (void(*callback)(MTLRenderPassDescriptor *, id< MTLRenderPipelineState >, id< MTLTexture >, id< CAMetalDrawable >))
Public Member Functions inherited from GHOST_Context
 GHOST_Context (const GHOST_ContextParams &context_params)
 ~GHOST_Context () override
void * getUserData ()
void setUserData (void *user_data)
bool isStereoVisual () const
virtual GHOST_TVSyncModes getVSync ()
virtual bool isUpsideDown () const
Public Member Functions inherited from GHOST_IContext
virtual ~GHOST_IContext ()=default

Static Public Attributes

static const int max_command_buffer_count = 64

Additional Inherited Members

Static Public Member Functions inherited from GHOST_Context
static GHOST_ContextgetActiveDrawingContext ()
Static Public Member Functions inherited from GHOST_IContext
static GHOST_IContextgetActiveDrawingContext ()
Protected Attributes inherited from GHOST_Context
GHOST_ContextParams context_params_
void * user_data_ = nullptr
Static Protected Attributes inherited from GHOST_Context
static GHOST_Contextactive_context_

Detailed Description

Definition at line 24 of file GHOST_ContextMTL.hh.

Constructor & Destructor Documentation

◆ GHOST_ContextMTL()

GHOST_ContextMTL::GHOST_ContextMTL ( const GHOST_ContextParams & context_params,
NSView * metalView,
CAMetalLayer * metalLayer )

◆ ~GHOST_ContextMTL()

GHOST_ContextMTL::~GHOST_ContextMTL ( )
override

Destructor.

Definition at line 122 of file GHOST_ContextMTL.mm.

References assert.

Member Function Documentation

◆ activateDrawingContext()

GHOST_TSuccess GHOST_ContextMTL::activateDrawingContext ( )
overridevirtual

Activates the drawing context of this window.

Returns
A boolean success indicator.

Implements GHOST_Context.

Definition at line 161 of file GHOST_ContextMTL.mm.

References GHOST_Context::active_context_, and GHOST_kSuccess.

◆ getDefaultFramebuffer()

unsigned int GHOST_ContextMTL::getDefaultFramebuffer ( )
overridevirtual

Gets the OpenGL frame-buffer associated with the OpenGL context

Returns
The ID of an OpenGL frame-buffer object.

Reimplemented from GHOST_Context.

Definition at line 173 of file GHOST_ContextMTL.mm.

◆ getSwapInterval()

GHOST_TSuccess GHOST_ContextMTL::getSwapInterval ( int & interval_out)
overridevirtual

Gets the current swap interval for #swapBuffers.

Parameters
interval_outVariable to store the swap interval if it can be read.
Returns
Whether the swap interval can be read.

Reimplemented from GHOST_Context.

Definition at line 155 of file GHOST_ContextMTL.mm.

References GHOST_kSuccess.

◆ initializeDrawingContext()

GHOST_TSuccess GHOST_ContextMTL::initializeDrawingContext ( )
overridevirtual

Call immediately after new to initialize. If this fails then immediately delete the object.

Returns
Indication as to whether initialization has succeeded.

Implements GHOST_Context.

Definition at line 216 of file GHOST_ContextMTL.mm.

References GHOST_Context::active_context_, and GHOST_kSuccess.

◆ metalCommandQueue()

MTLCommandQueue * GHOST_ContextMTL::metalCommandQueue ( )

Return a pointer to the Metal command queue used by this context.

Definition at line 200 of file GHOST_ContextMTL.mm.

◆ metalDevice()

MTLDevice * GHOST_ContextMTL::metalDevice ( )

Return a pointer to the Metal device associated with this context.

Definition at line 204 of file GHOST_ContextMTL.mm.

Referenced by GHOST_ContextMTL().

◆ metalOverlayTexture()

id< MTLTexture > GHOST_ContextMTL::metalOverlayTexture ( )

Returns a texture that Metal code can use as a render target. The current contents of this texture will be composited on top of the frame-buffer each time swapBuffers is called.

Definition at line 188 of file GHOST_ContextMTL.mm.

References updateDrawingContext().

◆ metalRegisterPresentCallback()

void GHOST_ContextMTL::metalRegisterPresentCallback ( void(* callback )(MTLRenderPassDescriptor *, id< MTLRenderPipelineState >, id< MTLTexture >, id< CAMetalDrawable >))

Register present callback

Definition at line 210 of file GHOST_ContextMTL.mm.

◆ releaseDrawingContext()

GHOST_TSuccess GHOST_ContextMTL::releaseDrawingContext ( )
overridevirtual

Release the drawing context of the calling thread.

Returns
A boolean success indicator.

Implements GHOST_Context.

Definition at line 167 of file GHOST_ContextMTL.mm.

References GHOST_Context::active_context_, and GHOST_kSuccess.

◆ releaseNativeHandles()

GHOST_TSuccess GHOST_ContextMTL::releaseNativeHandles ( )
overridevirtual

Removes references to native handles from this context and then returns

Returns
GHOST_kSuccess if it is OK for the parent to release the handles and GHOST_kFailure if releasing the handles will interfere with sharing

Implements GHOST_Context.

Definition at line 227 of file GHOST_ContextMTL.mm.

References GHOST_kSuccess.

◆ setSwapInterval()

GHOST_TSuccess GHOST_ContextMTL::setSwapInterval ( int interval)
overridevirtual

Sets the swap interval for #swapBuffers.

Parameters
intervalThe swap interval to use.
Returns
A boolean success indicator.

Reimplemented from GHOST_Context.

Definition at line 149 of file GHOST_ContextMTL.mm.

References GHOST_kSuccess.

◆ swapBufferAcquire()

GHOST_TSuccess GHOST_ContextMTL::swapBufferAcquire ( )
inlineoverridevirtual

Implements GHOST_Context.

Definition at line 54 of file GHOST_ContextMTL.hh.

References GHOST_kSuccess.

◆ swapBufferRelease()

GHOST_TSuccess GHOST_ContextMTL::swapBufferRelease ( )
overridevirtual

Swaps front and back buffers of a window.

Returns
A boolean success indicator.

Implements GHOST_Context.

Definition at line 141 of file GHOST_ContextMTL.mm.

References GHOST_kSuccess.

◆ updateDrawingContext()

GHOST_TSuccess GHOST_ContextMTL::updateDrawingContext ( )
overridevirtual

Updates the drawing context of this window. Needed whenever the window is changed.

Returns
Indication of success.

Reimplemented from GHOST_Context.

Definition at line 179 of file GHOST_ContextMTL.mm.

References GHOST_kFailure, and GHOST_kSuccess.

Referenced by metalOverlayTexture().

Member Data Documentation

◆ max_command_buffer_count

const int GHOST_ContextMTL::max_command_buffer_count = 64
static

Definition at line 38 of file GHOST_ContextMTL.hh.

Referenced by blender::gpu::MTLCommandBufferManager::submit().


The documentation for this class was generated from the following files: