mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 06:05:40 +12:00
ios: Simplify MTKView interface (still doesn't work though)
This commit is contained in:
parent
fb59320829
commit
e378a52b5a
4 changed files with 11 additions and 21 deletions
|
@ -87,8 +87,8 @@ class Renderer {
|
|||
virtual void setupGLES() {}
|
||||
|
||||
// Only relevant for Metal renderer on iOS
|
||||
// Passes a SwiftUI MTKView Drawable to the renderer
|
||||
virtual void setMTKDrawable(void* drawable) {};
|
||||
// Passes a SwiftUI MTKView's layer (CAMetalLayer) to the renderer
|
||||
virtual void setMTKLayer(void* layer) {};
|
||||
|
||||
// This function is called on every draw call before parsing vertex data.
|
||||
// It is responsible for things like looking up which vertex/fragment shaders to use, recompiling them if they don't exist, choosing between
|
||||
|
|
|
@ -42,11 +42,10 @@ class RendererMTL final : public Renderer {
|
|||
virtual void initGraphicsContext([[maybe_unused]] GL::Context* context) override {}
|
||||
#endif
|
||||
|
||||
virtual void setMTKDrawable(void* drawable) override;
|
||||
virtual void setMTKLayer(void* layer) override;
|
||||
|
||||
private:
|
||||
CA::MetalLayer* metalLayer = nullptr;
|
||||
CA::MetalDrawable* metalDrawable = nullptr;
|
||||
|
||||
MTL::Device* device = nullptr;
|
||||
MTL::CommandQueue* commandQueue = nullptr;
|
||||
|
|
|
@ -55,29 +55,21 @@ void RendererMTL::reset() {
|
|||
colorRenderTargetCache.reset();
|
||||
}
|
||||
|
||||
void RendererMTL::setMTKDrawable(void* drawable) {
|
||||
metalDrawable = (CA::MetalDrawable*)drawable;
|
||||
void RendererMTL::setMTKLayer(void* layer) {
|
||||
metalLayer = (CA::MetalLayer*)layer;
|
||||
// metalLayer->retain();
|
||||
}
|
||||
|
||||
void RendererMTL::display() {
|
||||
#ifdef PANDA3DS_IOS
|
||||
CA::MetalDrawable* drawable = metalDrawable;
|
||||
if (!drawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
MTL::Texture* texture = drawable->texture();
|
||||
#else
|
||||
CA::MetalDrawable* drawable = metalLayer->nextDrawable();
|
||||
if (!drawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
MTL::Texture* texture = drawable->texture();
|
||||
#endif
|
||||
|
||||
using namespace PICA::ExternalRegs;
|
||||
printf("Device pointer: %p\nDrawable pointer: %p\nTexture pointer: %p\n", device, drawable, texture);
|
||||
printf("Layer pointer: %p\nDevice pointer: %p\nDrawable pointer: %p\nTexture pointer: %p\n", metalLayer, device, drawable, texture);
|
||||
|
||||
// Top screen
|
||||
const u32 topActiveFb = externalRegs[Framebuffer0Select] & 1;
|
||||
|
@ -134,10 +126,9 @@ void RendererMTL::display() {
|
|||
|
||||
// Inform the vertex buffer cache that the frame ended
|
||||
vertexBufferCache.endFrame();
|
||||
|
||||
// Release the drawable (not on iOS cause SwiftUI handles it there)
|
||||
#ifndef PANDA3DS_IOS
|
||||
drawable->release();
|
||||
#ifdef PANDA3DS_IOS
|
||||
// metalLayer->release();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ IOS_EXPORT void iosCreateEmulator() {
|
|||
printf("Created emulator\n");
|
||||
}
|
||||
|
||||
IOS_EXPORT void iosRunFrame(void* drawable) {
|
||||
IOS_EXPORT void iosRunFrame(void* layer) {
|
||||
printf("Running a frame\n");
|
||||
emulator->getRenderer()->setMTKDrawable(drawable);
|
||||
emulator->getRenderer()->setMTKLayer(layer);
|
||||
emulator->runFrame();
|
||||
printf("Ran a frame\n");
|
||||
}
|
Loading…
Add table
Reference in a new issue