yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Merge pull request #4099 from MerryMage/macOS-build

Fix compilation on macOS
This commit is contained in:
bunnei 2020-06-19 23:31:04 -04:00 committed by GitHub
commit 7d1dca4c98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 19 deletions

View File

@ -23,7 +23,7 @@ VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name)
std::vector<u8> bfttf(Size + sizeof(u64)); std::vector<u8> bfttf(Size + sizeof(u64));
u64 offset = 0; size_t offset = 0;
Service::NS::EncryptSharedFont(vec, bfttf, offset); Service::NS::EncryptSharedFont(vec, bfttf, offset);
return std::make_shared<VectorVfsFile>(std::move(bfttf), name); return std::make_shared<VectorVfsFile>(std::move(bfttf), name);
} }

View File

@ -104,7 +104,7 @@ ResultCode MemoryManager::Allocate(PageLinkedList& page_list, std::size_t num_pa
// Ensure that we don't leave anything un-freed // Ensure that we don't leave anything un-freed
auto group_guard = detail::ScopeExit([&] { auto group_guard = detail::ScopeExit([&] {
for (const auto& it : page_list.Nodes()) { for (const auto& it : page_list.Nodes()) {
const auto min_num_pages{std::min( const auto min_num_pages{std::min<size_t>(
it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)};
chosen_manager.Free(it.GetAddress(), min_num_pages); chosen_manager.Free(it.GetAddress(), min_num_pages);
} }
@ -165,7 +165,7 @@ ResultCode MemoryManager::Free(PageLinkedList& page_list, std::size_t num_pages,
// Free all of the pages // Free all of the pages
for (const auto& it : page_list.Nodes()) { for (const auto& it : page_list.Nodes()) {
const auto min_num_pages{std::min( const auto min_num_pages{std::min<size_t>(
it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)};
chosen_manager.Free(it.GetAddress(), min_num_pages); chosen_manager.Free(it.GetAddress(), min_num_pages);
} }

View File

@ -220,8 +220,8 @@ private:
return cache_begin < addr_end && addr_begin < cache_end; return cache_begin < addr_end && addr_begin < cache_end;
}; };
const u64 page_end = addr_end >> PAGE_SHIFT; const u64 page_end = addr_end >> PAGE_BITS;
for (u64 page = addr_begin >> PAGE_SHIFT; page <= page_end; ++page) { for (u64 page = addr_begin >> PAGE_BITS; page <= page_end; ++page) {
const auto& it = cached_queries.find(page); const auto& it = cached_queries.find(page);
if (it == std::end(cached_queries)) { if (it == std::end(cached_queries)) {
continue; continue;
@ -242,14 +242,14 @@ private:
/// Registers the passed parameters as cached and returns a pointer to the stored cached query. /// Registers the passed parameters as cached and returns a pointer to the stored cached query.
CachedQuery* Register(VideoCore::QueryType type, VAddr cpu_addr, u8* host_ptr, bool timestamp) { CachedQuery* Register(VideoCore::QueryType type, VAddr cpu_addr, u8* host_ptr, bool timestamp) {
rasterizer.UpdatePagesCachedCount(cpu_addr, CachedQuery::SizeInBytes(timestamp), 1); rasterizer.UpdatePagesCachedCount(cpu_addr, CachedQuery::SizeInBytes(timestamp), 1);
const u64 page = static_cast<u64>(cpu_addr) >> PAGE_SHIFT; const u64 page = static_cast<u64>(cpu_addr) >> PAGE_BITS;
return &cached_queries[page].emplace_back(static_cast<QueryCache&>(*this), type, cpu_addr, return &cached_queries[page].emplace_back(static_cast<QueryCache&>(*this), type, cpu_addr,
host_ptr); host_ptr);
} }
/// Tries to a get a cached query. Returns nullptr on failure. /// Tries to a get a cached query. Returns nullptr on failure.
CachedQuery* TryGet(VAddr addr) { CachedQuery* TryGet(VAddr addr) {
const u64 page = static_cast<u64>(addr) >> PAGE_SHIFT; const u64 page = static_cast<u64>(addr) >> PAGE_BITS;
const auto it = cached_queries.find(page); const auto it = cached_queries.find(page);
if (it == std::end(cached_queries)) { if (it == std::end(cached_queries)) {
return nullptr; return nullptr;
@ -268,7 +268,7 @@ private:
} }
static constexpr std::uintptr_t PAGE_SIZE = 4096; static constexpr std::uintptr_t PAGE_SIZE = 4096;
static constexpr unsigned PAGE_SHIFT = 12; static constexpr unsigned PAGE_BITS = 12;
Core::System& system; Core::System& system;
VideoCore::RasterizerInterface& rasterizer; VideoCore::RasterizerInterface& rasterizer;

View File

@ -13,6 +13,7 @@
#include <fmt/format.h> #include <fmt/format.h>
#include "common/dynamic_library.h" #include "common/dynamic_library.h"
#include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/telemetry.h" #include "common/telemetry.h"
#include "core/core.h" #include "core/core.h"
@ -76,7 +77,8 @@ Common::DynamicLibrary OpenVulkanLibrary() {
char* libvulkan_env = getenv("LIBVULKAN_PATH"); char* libvulkan_env = getenv("LIBVULKAN_PATH");
if (!libvulkan_env || !library.Open(libvulkan_env)) { if (!libvulkan_env || !library.Open(libvulkan_env)) {
// Use the libvulkan.dylib from the application bundle. // Use the libvulkan.dylib from the application bundle.
std::string filename = File::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib"; const std::string filename =
FileUtil::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib";
library.Open(filename.c_str()); library.Open(filename.c_str());
} }
#else #else

View File

@ -870,7 +870,7 @@ void RasterizerVulkan::BeginTransformFeedback() {
UNIMPLEMENTED_IF(binding.buffer_offset != 0); UNIMPLEMENTED_IF(binding.buffer_offset != 0);
const GPUVAddr gpu_addr = binding.Address(); const GPUVAddr gpu_addr = binding.Address();
const std::size_t size = binding.buffer_size; const auto size = static_cast<VkDeviceSize>(binding.buffer_size);
const auto [buffer, offset] = buffer_cache.UploadMemory(gpu_addr, size, 4, true); const auto [buffer, offset] = buffer_cache.UploadMemory(gpu_addr, size, 4, true);
scheduler.Record([buffer = buffer, offset = offset, size](vk::CommandBuffer cmdbuf) { scheduler.Record([buffer = buffer, offset = offset, size](vk::CommandBuffer cmdbuf) {

View File

@ -66,12 +66,12 @@ ProgramCode GetShaderCode(Tegra::MemoryManager& memory_manager, GPUVAddr gpu_add
u64 GetUniqueIdentifier(Tegra::Engines::ShaderType shader_type, bool is_a, const ProgramCode& code, u64 GetUniqueIdentifier(Tegra::Engines::ShaderType shader_type, bool is_a, const ProgramCode& code,
const ProgramCode& code_b) { const ProgramCode& code_b) {
u64 unique_identifier = boost::hash_value(code); size_t unique_identifier = boost::hash_value(code);
if (is_a) { if (is_a) {
// VertexA programs include two programs // VertexA programs include two programs
boost::hash_combine(unique_identifier, boost::hash_value(code_b)); boost::hash_combine(unique_identifier, boost::hash_value(code_b));
} }
return unique_identifier; return static_cast<u64>(unique_identifier);
} }
} // namespace VideoCommon::Shader } // namespace VideoCommon::Shader

View File

@ -19,7 +19,7 @@ namespace VideoCommon {
template <class T> template <class T>
class ShaderCache { class ShaderCache {
static constexpr u64 PAGE_SHIFT = 14; static constexpr u64 PAGE_BITS = 14;
struct Entry { struct Entry {
VAddr addr_start; VAddr addr_start;
@ -87,8 +87,8 @@ protected:
const VAddr addr_end = addr + size; const VAddr addr_end = addr + size;
Entry* const entry = NewEntry(addr, addr_end, data.get()); Entry* const entry = NewEntry(addr, addr_end, data.get());
const u64 page_end = addr_end >> PAGE_SHIFT; const u64 page_end = addr_end >> PAGE_BITS;
for (u64 page = addr >> PAGE_SHIFT; page <= page_end; ++page) { for (u64 page = addr >> PAGE_BITS; page <= page_end; ++page) {
invalidation_cache[page].push_back(entry); invalidation_cache[page].push_back(entry);
} }
@ -108,8 +108,8 @@ private:
/// @pre invalidation_mutex is locked /// @pre invalidation_mutex is locked
void InvalidatePagesInRegion(VAddr addr, std::size_t size) { void InvalidatePagesInRegion(VAddr addr, std::size_t size) {
const VAddr addr_end = addr + size; const VAddr addr_end = addr + size;
const u64 page_end = addr_end >> PAGE_SHIFT; const u64 page_end = addr_end >> PAGE_BITS;
for (u64 page = addr >> PAGE_SHIFT; page <= page_end; ++page) { for (u64 page = addr >> PAGE_BITS; page <= page_end; ++page) {
const auto it = invalidation_cache.find(page); const auto it = invalidation_cache.find(page);
if (it == invalidation_cache.end()) { if (it == invalidation_cache.end()) {
continue; continue;

View File

@ -208,6 +208,10 @@ if (MSVC)
copy_yuzu_unicorn_deps(yuzu) copy_yuzu_unicorn_deps(yuzu)
endif() endif()
if (NOT APPLE)
target_compile_definitions(yuzu PRIVATE HAS_OPENGL)
endif()
if (ENABLE_VULKAN) if (ENABLE_VULKAN)
target_include_directories(yuzu PRIVATE ../../externals/Vulkan-Headers/include) target_include_directories(yuzu PRIVATE ../../externals/Vulkan-Headers/include)
target_compile_definitions(yuzu PRIVATE HAS_VULKAN) target_compile_definitions(yuzu PRIVATE HAS_VULKAN)

View File

@ -8,13 +8,16 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMessageBox> #include <QMessageBox>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QPainter> #include <QPainter>
#include <QScreen> #include <QScreen>
#include <QStringList> #include <QStringList>
#include <QWindow> #include <QWindow>
#ifdef HAS_OPENGL
#include <QOffscreenSurface>
#include <QOpenGLContext>
#endif
#if !defined(WIN32) && HAS_VULKAN #if !defined(WIN32) && HAS_VULKAN
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#endif #endif
@ -98,6 +101,7 @@ void EmuThread::run() {
#endif #endif
} }
#ifdef HAS_OPENGL
class OpenGLSharedContext : public Core::Frontend::GraphicsContext { class OpenGLSharedContext : public Core::Frontend::GraphicsContext {
public: public:
/// Create the original context that should be shared from /// Create the original context that should be shared from
@ -183,6 +187,7 @@ private:
std::unique_ptr<QOffscreenSurface> offscreen_surface{}; std::unique_ptr<QOffscreenSurface> offscreen_surface{};
QSurface* surface; QSurface* surface;
}; };
#endif
class DummyContext : public Core::Frontend::GraphicsContext {}; class DummyContext : public Core::Frontend::GraphicsContext {};
@ -473,6 +478,7 @@ void GRenderWindow::resizeEvent(QResizeEvent* event) {
} }
std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const { std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const {
#ifdef HAS_OPENGL
if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) { if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
auto c = static_cast<OpenGLSharedContext*>(main_context.get()); auto c = static_cast<OpenGLSharedContext*>(main_context.get());
// Bind the shared contexts to the main surface in case the backend wants to take over // Bind the shared contexts to the main surface in case the backend wants to take over
@ -480,6 +486,7 @@ std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedCont
return std::make_unique<OpenGLSharedContext>(c->GetShareContext(), return std::make_unique<OpenGLSharedContext>(c->GetShareContext(),
child_widget->windowHandle()); child_widget->windowHandle());
} }
#endif
return std::make_unique<DummyContext>(); return std::make_unique<DummyContext>();
} }
@ -560,6 +567,7 @@ void GRenderWindow::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal
} }
bool GRenderWindow::InitializeOpenGL() { bool GRenderWindow::InitializeOpenGL() {
#ifdef HAS_OPENGL
// TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
// WA_DontShowOnScreen, WA_DeleteOnClose // WA_DontShowOnScreen, WA_DeleteOnClose
auto child = new OpenGLRenderWidget(this); auto child = new OpenGLRenderWidget(this);
@ -571,6 +579,11 @@ bool GRenderWindow::InitializeOpenGL() {
std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle())); std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle()));
return true; return true;
#else
QMessageBox::warning(this, tr("OpenGL not available!"),
tr("yuzu has not been compiled with OpenGL support."));
return false;
#endif
} }
bool GRenderWindow::InitializeVulkan() { bool GRenderWindow::InitializeVulkan() {