Metal (MTLRenderDevice) integration
Posted: 23 Aug 2020, 00:08
Hi,
We have been successfully using the GLRenderDevice with our own OpenGL context (thus not using GLRenderContext), by following documentation and calling the various methods and taking care of saving/restore gpu states where appropriate. Ending with something like:
but now we want to start using Metal, again with our already created and managed metal 'context' (device, layer, etc).
I have noticed this comment at the beginning of MTLRenderDevice.h:
but yet I can't get it to work. I'd assume all methods in MTLFactory are to be used somewhere too, but I have yet to figure when one should end up calling PreCreatePipeline.
Anyone has had succes integrating Metal rendering without using the application framework to manage the view and the context?
We have been successfully using the GLRenderDevice with our own OpenGL context (thus not using GLRenderContext), by following documentation and calling the various methods and taking care of saving/restore gpu states where appropriate. Ending with something like:
Code: Select all
void NoesisGUINode::update(float delta)
{
_time += delta;
_view->Update(_time);
_view->GetRenderer()->UpdateRenderTree();
// Offscreen pass
OpenGLState glState;
glState.Store();
if (_view->GetRenderer()->RenderOffscreen())
{
glState.Restore();
}
}
void NoesisGUINode::DrawUI() const
{
OpenGLState glState;
glState.Store();
_view->GetRenderer()->Render();
glState.Restore();
}
I have noticed this comment at the beginning of MTLRenderDevice.h:
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Apple Metal render device
///
/// Metal device requires setting a command buffer and a command encoder per frame. The command
/// buffer must be set before any rendering. Offscreen command encoders will be created there. The
/// command encoder is used for the on-screen rendering phase.
///
/// .. code-block:: c++
///
/// renderer->UpdateRenderTree();
/// device->SetCommandBuffer(commands);
/// renderer->RenderOffscreen();
///
/// commandEncoder = [commands renderCommandEncoderWithDescriptor:passDescriptor];
/// device->SetOnScreenEncoder(commandEncoder, colorFormat, stencilFormat, sampleCount);
/// renderer->Render();
///
////////////////////////////////////////////////////////////////////////////////////////////////////
Anyone has had succes integrating Metal rendering without using the application framework to manage the view and the context?