mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-01-08 08:00:44 +01:00
fix: present
This commit is contained in:
parent
d79d7fea63
commit
0d0152d6e0
@ -1,5 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.21.1)
|
cmake_minimum_required(VERSION 3.21.1)
|
||||||
|
|
||||||
|
# TODO: remove this
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
|
|
||||||
option(ENABLE_VCPKG "Enable the vcpkg package manager" ON)
|
option(ENABLE_VCPKG "Enable the vcpkg package manager" ON)
|
||||||
option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF)
|
option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF)
|
||||||
set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version
|
set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version
|
||||||
@ -23,7 +26,7 @@ if (ENABLE_VCPKG)
|
|||||||
OUTPUT_VARIABLE is_vcpkg_shallow
|
OUTPUT_VARIABLE is_vcpkg_shallow
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
if(is_vcpkg_shallow STREQUAL "true")
|
if(is_vcpkg_shallow STREQUAL "true")
|
||||||
message(STATUS "vcpkg is shallow. Unshallowing it now...")
|
message(STATUS "vcpkg is shallow. Unshallowing it now...")
|
||||||
execute_process(
|
execute_process(
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void* CreateMetalLayer(void* handle);
|
void* CreateMetalLayer(void* handle, float& scaleX, float& scaleY);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "Cafe/HW/Latte/Renderer/MetalView.h"
|
#include "Cafe/HW/Latte/Renderer/MetalView.h"
|
||||||
|
|
||||||
void* CreateMetalLayer(void* handle)
|
void* CreateMetalLayer(void* handle, float& scaleX, float& scaleY)
|
||||||
{
|
{
|
||||||
NSView* view = (NSView*)handle;
|
NSView* view = (NSView*)handle;
|
||||||
|
|
||||||
@ -12,5 +12,11 @@ void* CreateMetalLayer(void* handle)
|
|||||||
|
|
||||||
[view addSubview:childView];
|
[view addSubview:childView];
|
||||||
|
|
||||||
|
const NSRect points = [childView frame];
|
||||||
|
const NSRect pixels = [childView convertRectToBacking:points];
|
||||||
|
|
||||||
|
scaleX = (float)(pixels.size.width / points.size.width);
|
||||||
|
scaleY = (float)(pixels.size.height / points.size.height);
|
||||||
|
|
||||||
return childView.layer;
|
return childView.layer;
|
||||||
}
|
}
|
||||||
|
@ -138,13 +138,20 @@ MetalRenderer::~MetalRenderer()
|
|||||||
m_device->release();
|
m_device->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't ignore "mainWindow" argument and respect size
|
// TODO: don't ignore "mainWindow" argument
|
||||||
void MetalRenderer::InitializeLayer(const Vector2i& size, bool mainWindow)
|
void MetalRenderer::InitializeLayer(const Vector2i& size, bool mainWindow)
|
||||||
{
|
{
|
||||||
const auto& windowInfo = gui_getWindowInfo().window_main;
|
const auto& windowInfo = gui_getWindowInfo().window_main;
|
||||||
|
|
||||||
m_metalLayer = (CA::MetalLayer*)CreateMetalLayer(windowInfo.handle);
|
m_metalLayer = (CA::MetalLayer*)CreateMetalLayer(windowInfo.handle, m_layerScaleX, m_layerScaleY);
|
||||||
m_metalLayer->setDevice(m_device);
|
m_metalLayer->setDevice(m_device);
|
||||||
|
m_metalLayer->setDrawableSize(CGSize{(float)size.x * m_layerScaleX, (float)size.y * m_layerScaleY});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: don't ignore "mainWindow" argument
|
||||||
|
void MetalRenderer::ResizeLayer(const Vector2i& size, bool mainWindow)
|
||||||
|
{
|
||||||
|
m_metalLayer->setDrawableSize(CGSize{(float)size.x * m_layerScaleX, (float)size.y * m_layerScaleY});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalRenderer::Initialize()
|
void MetalRenderer::Initialize()
|
||||||
@ -215,6 +222,7 @@ void MetalRenderer::SwapBuffers(bool swapTV, bool swapDRC)
|
|||||||
m_memoryManager->ResetTemporaryBuffers();
|
m_memoryManager->ResetTemporaryBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use `shader` for drawing
|
||||||
void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutputShader* shader, bool useLinearTexFilter,
|
void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutputShader* shader, bool useLinearTexFilter,
|
||||||
sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight,
|
sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight,
|
||||||
bool padView, bool clearBackground)
|
bool padView, bool clearBackground)
|
||||||
@ -240,6 +248,9 @@ void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutput
|
|||||||
renderCommandEncoder->setFragmentTexture(presentTexture, 0);
|
renderCommandEncoder->setFragmentTexture(presentTexture, 0);
|
||||||
renderCommandEncoder->setFragmentSamplerState((useLinearTexFilter ? m_linearSampler : m_nearestSampler), 0);
|
renderCommandEncoder->setFragmentSamplerState((useLinearTexFilter ? m_linearSampler : m_nearestSampler), 0);
|
||||||
|
|
||||||
|
renderCommandEncoder->setViewport(MTL::Viewport{(double)imageX, (double)imageY, (double)imageWidth, (double)imageHeight, 0.0, 1.0});
|
||||||
|
renderCommandEncoder->setScissorRect(MTL::ScissorRect{(uint32)imageX, (uint32)imageY, (uint32)imageWidth, (uint32)imageHeight});
|
||||||
|
|
||||||
renderCommandEncoder->drawPrimitives(MTL::PrimitiveTypeTriangle, NS::UInteger(0), NS::UInteger(3));
|
renderCommandEncoder->drawPrimitives(MTL::PrimitiveTypeTriangle, NS::UInteger(0), NS::UInteger(3));
|
||||||
|
|
||||||
EndEncoding();
|
EndEncoding();
|
||||||
|
@ -141,6 +141,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitializeLayer(const Vector2i& size, bool mainWindow);
|
void InitializeLayer(const Vector2i& size, bool mainWindow);
|
||||||
|
void ResizeLayer(const Vector2i& size, bool mainWindow);
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
@ -330,6 +331,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CA::MetalLayer* m_metalLayer;
|
CA::MetalLayer* m_metalLayer;
|
||||||
|
float m_layerScaleX, m_layerScaleY;
|
||||||
|
|
||||||
class MetalMemoryManager* m_memoryManager;
|
class MetalMemoryManager* m_memoryManager;
|
||||||
class MetalPipelineCache* m_pipelineCache;
|
class MetalPipelineCache* m_pipelineCache;
|
||||||
|
@ -60,4 +60,7 @@ void MetalCanvas::OnResize(wxSizeEvent& event)
|
|||||||
|
|
||||||
const wxRect refreshRect(size);
|
const wxRect refreshRect(size);
|
||||||
RefreshRect(refreshRect, false);
|
RefreshRect(refreshRect, false);
|
||||||
|
|
||||||
|
auto metal_renderer = MetalRenderer::GetInstance();
|
||||||
|
metal_renderer->InitializeLayer({size.x, size.y}, m_is_main_window);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user