mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-05 14:52:41 +13:00
More iOS work
This commit is contained in:
parent
432eb0d2b3
commit
fb59320829
5 changed files with 14 additions and 28 deletions
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
void iosCreateEmulator();
|
||||
void iosRunFrame(void* drawable, void* drawableTexture);
|
||||
void iosRunFrame(void* drawable);
|
|
@ -87,8 +87,8 @@ class Renderer {
|
|||
virtual void setupGLES() {}
|
||||
|
||||
// Only relevant for Metal renderer on iOS
|
||||
// Passes a SwiftUI MTKView Drawable & its texture to the renderer
|
||||
virtual void setMTKDrawable(void* drawable, void* drawableTexture) {};
|
||||
// Passes a SwiftUI MTKView Drawable to the renderer
|
||||
virtual void setMTKDrawable(void* drawable) {};
|
||||
|
||||
// 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,13 +42,11 @@ class RendererMTL final : public Renderer {
|
|||
virtual void initGraphicsContext([[maybe_unused]] GL::Context* context) override {}
|
||||
#endif
|
||||
|
||||
virtual void setMTKDrawable(void* drawable, void* drawableTexture) override;
|
||||
virtual void setMTKDrawable(void* drawable) override;
|
||||
|
||||
private:
|
||||
CA::MetalLayer* metalLayer = nullptr;
|
||||
|
||||
CA::MetalDrawable* metalDrawable = nullptr;
|
||||
MTL::Texture* drawableTexture = nullptr;
|
||||
|
||||
MTL::Device* device = nullptr;
|
||||
MTL::CommandQueue* commandQueue = nullptr;
|
||||
|
@ -103,6 +101,7 @@ class RendererMTL final : public Renderer {
|
|||
void endRenderPass() {
|
||||
if (renderCommandEncoder) {
|
||||
renderCommandEncoder->endEncoding();
|
||||
renderCommandEncoder->release();
|
||||
renderCommandEncoder = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,39 +55,29 @@ void RendererMTL::reset() {
|
|||
colorRenderTargetCache.reset();
|
||||
}
|
||||
|
||||
void RendererMTL::setMTKDrawable(void* drawable, void* tex) {
|
||||
this->metalDrawable = (CA::MetalDrawable*)drawable;
|
||||
this->drawableTexture = (MTL::Texture*)tex;
|
||||
void RendererMTL::setMTKDrawable(void* drawable) {
|
||||
metalDrawable = (CA::MetalDrawable*)drawable;
|
||||
}
|
||||
|
||||
void RendererMTL::display() {
|
||||
static int frameCount = 0;
|
||||
frameCount++;
|
||||
|
||||
auto manager = MTL::CaptureManager::sharedCaptureManager();
|
||||
auto captureDescriptor = MTL::CaptureDescriptor::alloc()->init();
|
||||
if (frameCount == 200) {
|
||||
captureDescriptor->setCaptureObject(device);
|
||||
manager->startCapture(captureDescriptor, nullptr);
|
||||
}
|
||||
|
||||
#ifdef PANDA3DS_IOS
|
||||
CA::MetalDrawable* drawable = metalDrawable;
|
||||
if (!drawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
MTL::Texture* texture = drawableTexture;
|
||||
MTL::Texture* texture = drawable->texture();
|
||||
#else
|
||||
CA::MetalDrawable* drawable = metalLayer->nextDrawable();
|
||||
if (!drawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
MTL::Texture* texture = drawable->getTexture();
|
||||
MTL::Texture* texture = drawable->texture();
|
||||
#endif
|
||||
|
||||
using namespace PICA::ExternalRegs;
|
||||
printf("Device pointer: %p\nDrawable pointer: %p\nTexture pointer: %p\n", device, drawable, texture);
|
||||
|
||||
// Top screen
|
||||
const u32 topActiveFb = externalRegs[Framebuffer0Select] & 1;
|
||||
|
@ -149,11 +139,6 @@ void RendererMTL::display() {
|
|||
#ifndef PANDA3DS_IOS
|
||||
drawable->release();
|
||||
#endif
|
||||
|
||||
if (frameCount == 200) {
|
||||
manager->stopCapture();
|
||||
}
|
||||
captureDescriptor->release();
|
||||
}
|
||||
|
||||
void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
||||
|
|
|
@ -30,7 +30,9 @@ IOS_EXPORT void iosCreateEmulator() {
|
|||
printf("Created emulator\n");
|
||||
}
|
||||
|
||||
IOS_EXPORT void iosRunFrame(void* drawable, void* drawableTexture) {
|
||||
emulator->getRenderer()->setMTKDrawable(drawable, drawableTexture);
|
||||
IOS_EXPORT void iosRunFrame(void* drawable) {
|
||||
printf("Running a frame\n");
|
||||
emulator->getRenderer()->setMTKDrawable(drawable);
|
||||
emulator->runFrame();
|
||||
printf("Ran a frame\n");
|
||||
}
|
Loading…
Add table
Reference in a new issue