Use fetch content on macOS for SPIRV-Cross, and fix compilation using the new Windows changes
This commit is contained in:
parent
c42bde8830
commit
0e008a1beb
8 changed files with 29 additions and 43 deletions
|
@ -14,16 +14,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/Common.cmake)
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/AddPlatformExecutable.cmake)
|
||||
include(FetchContent)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND NOT IOS)
|
||||
message("macOS build detected!")
|
||||
|
||||
set(ENABLE_METAL TRUE)
|
||||
set(ENABLE_DARWIN TRUE)
|
||||
set(ENABLE_MACOS TRUE)
|
||||
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME OFF)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
message("Linux build detected!")
|
||||
|
||||
|
@ -83,6 +73,18 @@ macro(manual_download)
|
|||
set(CMAKE_FOLDER "")
|
||||
endmacro()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND NOT IOS)
|
||||
message("macOS build detected!")
|
||||
|
||||
set(ENABLE_METAL TRUE)
|
||||
set(ENABLE_DARWIN TRUE)
|
||||
set(ENABLE_MACOS TRUE)
|
||||
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME OFF)
|
||||
|
||||
manual_download()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
||||
message("iOS build detected!")
|
||||
|
||||
|
@ -120,7 +122,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
|
|||
manual_download()
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_IOS AND NOT ENABLE_TVOS AND NOT ENABLE_WINDOWS)
|
||||
if(NOT TARGET spirv-cross-cpp)
|
||||
find_package(spirv_cross_core REQUIRED)
|
||||
find_package(spirv_cross_glsl REQUIRED)
|
||||
find_package(spirv_cross_cpp REQUIRED)
|
||||
|
|
|
@ -431,7 +431,7 @@ GFXPipeline* GFXMetal::create_graphics_pipeline(const GFXGraphicsPipelineCreateI
|
|||
{
|
||||
std::string vertex_src;
|
||||
if(info.shaders.vertex_path.empty()) {
|
||||
vertex_src = info.shaders.vertex_src;
|
||||
vertex_src = std::get<std::string>(info.shaders.vertex_src);
|
||||
} else {
|
||||
const auto vertex_path = utility::format("{}.msl", info.shaders.vertex_path);
|
||||
|
||||
|
@ -453,7 +453,7 @@ GFXPipeline* GFXMetal::create_graphics_pipeline(const GFXGraphicsPipelineCreateI
|
|||
{
|
||||
std::string fragment_src;
|
||||
if(info.shaders.fragment_path.empty()) {
|
||||
fragment_src = info.shaders.fragment_src;
|
||||
fragment_src = std::get<std::string>(info.shaders.fragment_src);
|
||||
} else {
|
||||
const auto fragment_path = utility::format("{}.msl", info.shaders.fragment_path);
|
||||
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
#include "shadercompiler.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(PLATFORM_IOS) || defined(PLATFORM_TVOS) || defined(PLATFORM_WINDOWS)
|
||||
#include <spirv_cpp.hpp>
|
||||
#include <spirv_msl.hpp>
|
||||
#include <SPIRV/GlslangToSpv.h>
|
||||
#else
|
||||
#include <spirv_cross/spirv_cpp.hpp>
|
||||
#include <spirv_cross/spirv_msl.hpp>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <SPIRV/GlslangToSpv.h>
|
||||
#endif
|
||||
|
||||
#include "file.hpp"
|
||||
#include "log.hpp"
|
||||
|
|
|
@ -294,13 +294,13 @@ CGRect toTopLeftSpace(NSRect frame) {
|
|||
return NSRectToCGRect(frame);
|
||||
}
|
||||
|
||||
Rectangle platform::get_monitor_resolution() {
|
||||
prism::Rectangle platform::get_monitor_resolution() {
|
||||
auto frame = toTopLeftSpace([[NSScreen mainScreen] frame]);
|
||||
|
||||
return {static_cast<int32_t>(frame.origin.x), static_cast<int32_t>(frame.origin.y), static_cast<uint32_t>(frame.size.width), static_cast<uint32_t>(frame.size.height)};
|
||||
}
|
||||
|
||||
Rectangle platform::get_monitor_work_area() {
|
||||
prism::Rectangle platform::get_monitor_work_area() {
|
||||
auto frame = toTopLeftSpace([[NSScreen mainScreen] visibleFrame]);
|
||||
|
||||
return {static_cast<int32_t>(frame.origin.x), static_cast<int32_t>(frame.origin.y), static_cast<uint32_t>(frame.size.width), static_cast<uint32_t>(frame.size.height)};
|
||||
|
@ -310,11 +310,11 @@ NSPoint get_fixed_cursor_point(NSPoint point) {
|
|||
return {point.x, std::max(windows[0]->currentHeight - point.y, 0.0)};
|
||||
}
|
||||
|
||||
Offset platform::get_cursor_position() {
|
||||
prism::Offset platform::get_cursor_position() {
|
||||
return {static_cast<int32_t>(windows[0]->currentMousePos.x), static_cast<int32_t>(windows[0]->currentMousePos.y)};
|
||||
}
|
||||
|
||||
Offset platform::get_screen_cursor_position() {
|
||||
prism::Offset platform::get_screen_cursor_position() {
|
||||
return {static_cast<int32_t>([NSEvent mouseLocation].x), static_cast<int32_t>([[NSScreen mainScreen] frame].size.height - [NSEvent mouseLocation].y)};
|
||||
}
|
||||
|
||||
|
@ -330,17 +330,17 @@ std::tuple<float, float> platform::get_right_stick_position() {
|
|||
return {rightX, rightY};
|
||||
}
|
||||
|
||||
Extent platform::get_window_size(const int index) {
|
||||
prism::Extent platform::get_window_size(const int index) {
|
||||
auto window = get_window(index);
|
||||
return {static_cast<uint32_t>(window->currentWidth), static_cast<uint32_t>(window->currentHeight)};
|
||||
}
|
||||
|
||||
Extent platform::get_window_drawable_size(const int index) {
|
||||
prism::Extent platform::get_window_drawable_size(const int index) {
|
||||
auto window = get_window(index);
|
||||
return {static_cast<uint32_t>(window->currentWidth * window->window.backingScaleFactor), static_cast<uint32_t>(window->currentHeight * window->window.backingScaleFactor)};
|
||||
}
|
||||
|
||||
Offset platform::get_window_position(const int index) {
|
||||
prism::Offset platform::get_window_position(const int index) {
|
||||
auto window = get_window(index);
|
||||
|
||||
auto frame = toTopLeftSpace([window->window contentRectForFrameRect:[window->window frame]]);
|
||||
|
@ -363,7 +363,7 @@ bool platform::get_mouse_button_down(const int button) {
|
|||
return (button + 1) & [NSEvent pressedMouseButtons];
|
||||
}
|
||||
|
||||
void platform::set_window_position(const int index, const Offset offset) {
|
||||
void platform::set_window_position(const int index, const prism::Offset offset) {
|
||||
auto window = get_window(index);
|
||||
|
||||
NSPoint p;
|
||||
|
@ -373,7 +373,7 @@ void platform::set_window_position(const int index, const Offset offset) {
|
|||
[window->window setFrameTopLeftPoint:p];
|
||||
}
|
||||
|
||||
void platform::set_window_size(const int index, const Extent extent) {
|
||||
void platform::set_window_size(const int index, const prism::Extent extent) {
|
||||
auto window = get_window(index);
|
||||
|
||||
NSSize size;
|
||||
|
@ -391,7 +391,7 @@ void platform::set_window_title(const int index, const std::string_view title) {
|
|||
void platform::mute_output() {}
|
||||
void platform::unmute_output() {}
|
||||
|
||||
int platform::open_window(const std::string_view title, const Rectangle rect, const WindowFlags flags) {
|
||||
int platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
NativeWindow* native = new NativeWindow();
|
||||
native->index = windows.size();
|
||||
GameView* del = [[GameView alloc] init];
|
||||
|
|
|
@ -47,7 +47,7 @@ class DebugPass : public Pass {
|
|||
public:
|
||||
void initialize() override;
|
||||
|
||||
void resize(const Extent extent) override;
|
||||
void resize(const prism::Extent extent) override;
|
||||
|
||||
void render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) override;
|
||||
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
private:
|
||||
void createOffscreenResources();
|
||||
|
||||
Extent extent;
|
||||
prism::Extent extent;
|
||||
|
||||
std::vector<SelectableObject> selectable_objects;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "gfx.hpp"
|
||||
#include "gfx_commandbuffer.hpp"
|
||||
#include "imgui_utility.hpp"
|
||||
#include "screen.hpp"
|
||||
|
||||
const std::map<ImGuiKey, InputButton> imToPl = {
|
||||
{ImGuiKey_Tab, InputButton::Tab},
|
||||
|
|
|
@ -162,7 +162,7 @@ void DebugPass::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
void DebugPass::resize(const Extent extent) {
|
||||
void DebugPass::resize(const prism::Extent extent) {
|
||||
this->extent = extent;
|
||||
|
||||
createOffscreenResources();
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#include <spirv_cpp.hpp>
|
||||
#include <spirv_msl.hpp>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <SPIRV/GlslangToSpv.h>
|
||||
#else
|
||||
#include <spirv_cross/spirv_cpp.hpp>
|
||||
#include <spirv_cross/spirv_msl.hpp>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <SPIRV/GlslangToSpv.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "DirStackIncluder.h"
|
||||
#include "log.hpp"
|
||||
|
|
Reference in a new issue