mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 06:05:40 +12: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
|
#pragma once
|
||||||
|
|
||||||
void iosCreateEmulator();
|
void iosCreateEmulator();
|
||||||
void iosRunFrame(void* drawable, void* drawableTexture);
|
void iosRunFrame(void* drawable);
|
|
@ -87,8 +87,8 @@ class Renderer {
|
||||||
virtual void setupGLES() {}
|
virtual void setupGLES() {}
|
||||||
|
|
||||||
// Only relevant for Metal renderer on iOS
|
// Only relevant for Metal renderer on iOS
|
||||||
// Passes a SwiftUI MTKView Drawable & its texture to the renderer
|
// Passes a SwiftUI MTKView Drawable to the renderer
|
||||||
virtual void setMTKDrawable(void* drawable, void* drawableTexture) {};
|
virtual void setMTKDrawable(void* drawable) {};
|
||||||
|
|
||||||
// This function is called on every draw call before parsing vertex data.
|
// 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
|
// 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 {}
|
virtual void initGraphicsContext([[maybe_unused]] GL::Context* context) override {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void setMTKDrawable(void* drawable, void* drawableTexture) override;
|
virtual void setMTKDrawable(void* drawable) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CA::MetalLayer* metalLayer = nullptr;
|
CA::MetalLayer* metalLayer = nullptr;
|
||||||
|
|
||||||
CA::MetalDrawable* metalDrawable = nullptr;
|
CA::MetalDrawable* metalDrawable = nullptr;
|
||||||
MTL::Texture* drawableTexture = nullptr;
|
|
||||||
|
|
||||||
MTL::Device* device = nullptr;
|
MTL::Device* device = nullptr;
|
||||||
MTL::CommandQueue* commandQueue = nullptr;
|
MTL::CommandQueue* commandQueue = nullptr;
|
||||||
|
@ -103,6 +101,7 @@ class RendererMTL final : public Renderer {
|
||||||
void endRenderPass() {
|
void endRenderPass() {
|
||||||
if (renderCommandEncoder) {
|
if (renderCommandEncoder) {
|
||||||
renderCommandEncoder->endEncoding();
|
renderCommandEncoder->endEncoding();
|
||||||
|
renderCommandEncoder->release();
|
||||||
renderCommandEncoder = nullptr;
|
renderCommandEncoder = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,39 +55,29 @@ void RendererMTL::reset() {
|
||||||
colorRenderTargetCache.reset();
|
colorRenderTargetCache.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::setMTKDrawable(void* drawable, void* tex) {
|
void RendererMTL::setMTKDrawable(void* drawable) {
|
||||||
this->metalDrawable = (CA::MetalDrawable*)drawable;
|
metalDrawable = (CA::MetalDrawable*)drawable;
|
||||||
this->drawableTexture = (MTL::Texture*)tex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::display() {
|
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
|
#ifdef PANDA3DS_IOS
|
||||||
CA::MetalDrawable* drawable = metalDrawable;
|
CA::MetalDrawable* drawable = metalDrawable;
|
||||||
if (!drawable) {
|
if (!drawable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTL::Texture* texture = drawableTexture;
|
MTL::Texture* texture = drawable->texture();
|
||||||
#else
|
#else
|
||||||
CA::MetalDrawable* drawable = metalLayer->nextDrawable();
|
CA::MetalDrawable* drawable = metalLayer->nextDrawable();
|
||||||
if (!drawable) {
|
if (!drawable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTL::Texture* texture = drawable->getTexture();
|
MTL::Texture* texture = drawable->texture();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace PICA::ExternalRegs;
|
using namespace PICA::ExternalRegs;
|
||||||
|
printf("Device pointer: %p\nDrawable pointer: %p\nTexture pointer: %p\n", device, drawable, texture);
|
||||||
|
|
||||||
// Top screen
|
// Top screen
|
||||||
const u32 topActiveFb = externalRegs[Framebuffer0Select] & 1;
|
const u32 topActiveFb = externalRegs[Framebuffer0Select] & 1;
|
||||||
|
@ -149,11 +139,6 @@ void RendererMTL::display() {
|
||||||
#ifndef PANDA3DS_IOS
|
#ifndef PANDA3DS_IOS
|
||||||
drawable->release();
|
drawable->release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (frameCount == 200) {
|
|
||||||
manager->stopCapture();
|
|
||||||
}
|
|
||||||
captureDescriptor->release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
||||||
|
|
|
@ -30,7 +30,9 @@ IOS_EXPORT void iosCreateEmulator() {
|
||||||
printf("Created emulator\n");
|
printf("Created emulator\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
IOS_EXPORT void iosRunFrame(void* drawable, void* drawableTexture) {
|
IOS_EXPORT void iosRunFrame(void* drawable) {
|
||||||
emulator->getRenderer()->setMTKDrawable(drawable, drawableTexture);
|
printf("Running a frame\n");
|
||||||
|
emulator->getRenderer()->setMTKDrawable(drawable);
|
||||||
emulator->runFrame();
|
emulator->runFrame();
|
||||||
|
printf("Ran a frame\n");
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue