forked from H-uru/Plasma
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request H-uru#1326 from colincornaby/apple-metal
Metal Rendering on macOS
- Loading branch information
Showing
57 changed files
with
13,172 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,6 @@ elseif(APPLE) | |
Mac-Cocoa/PLSServerStatus.h | ||
) | ||
list(APPEND plClient_RESOURCES | ||
Mac-Cocoa/Assets.xcassets | ||
Mac-Cocoa/banner.png | ||
Mac-Cocoa/[email protected] | ||
Mac-Cocoa/MainMenu.xib | ||
|
@@ -158,8 +157,17 @@ if(APPLE) | |
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/Mac-Cocoa/plClient.entitlements" | ||
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES" | ||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES" | ||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER org.Huru.UruExplorer | ||
) | ||
target_compile_options(plClient PRIVATE -fobjc-arc) | ||
target_sources(plClient PRIVATE Mac-Cocoa/Assets.xcassets) | ||
set_source_files_properties(Mac-Cocoa/Assets.xcassets ${RESOURCES} PROPERTIES | ||
MACOSX_PACKAGE_LOCATION Resources | ||
) | ||
install( | ||
TARGETS plClient | ||
DESTINATION client | ||
) | ||
|
||
if(PLASMA_APPLE_DEVELOPMENT_TEAM_ID) | ||
set_target_properties(plClient PROPERTIES | ||
|
@@ -229,6 +237,8 @@ target_link_libraries( | |
pfPython | ||
$<$<BOOL:${PLASMA_PIPELINE_DX}>:pfDXPipeline> | ||
$<$<BOOL:${PLASMA_PIPELINE_GL}>:pfGLPipeline> | ||
$<$<BOOL:${PLASMA_PIPELINE_METAL}>:pfMetalPipeline> | ||
$<$<BOOL:${PLASMA_PIPELINE_METAL}>:pfMetalPipelineShaders> | ||
CURL::libcurl | ||
"$<$<PLATFORM_ID:Darwin>:-framework Cocoa>" | ||
"$<$<PLATFORM_ID:Darwin>:-framework QuartzCore>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,9 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#ifdef PLASMA_PIPELINE_GL | ||
#include "pfGLPipeline/plGLPipeline.h" | ||
#endif | ||
#ifdef PLASMA_PIPELINE_METAL | ||
#include "pfMetalPipeline/plMetalPipeline.h" | ||
#endif | ||
#include "pfJournalBook/pfJournalBook.h" | ||
#include "pfLocalizationMgr/pfLocalizationMgr.h" | ||
#include "pfMoviePlayer/plMoviePlayer.h" | ||
|
@@ -428,6 +431,11 @@ plPipeline* plClient::ICreatePipeline(hsWindowHndl disp, hsWindowHndl hWnd, cons | |
if (renderer == hsG3DDeviceSelector::kDevTypeOpenGL) | ||
return new plGLPipeline(disp, hWnd, devMode); | ||
#endif | ||
|
||
#ifdef PLASMA_PIPELINE_METAL | ||
if (renderer == hsG3DDeviceSelector::kDevTypeMetal) | ||
return new plMetalPipeline(disp, hWnd, devMode); | ||
#endif | ||
|
||
return new plNullPipeline(disp, hWnd, devMode); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,9 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
typedef HINSTANCE HMODULE; | ||
typedef long HRESULT; | ||
typedef void* HANDLE; | ||
#elif HS_BUILD_FOR_MACOS | ||
typedef void* hsWindowHndl; | ||
typedef void* hsWindowInst; | ||
#else | ||
typedef int32_t* hsWindowHndl; | ||
typedef int32_t* hsWindowInst; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,10 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "pfGLPipeline/pfGLPipelineCreatable.h" | ||
#endif | ||
|
||
#ifdef PLASMA_PIPELINE_METAL | ||
#include "pfMetalPipeline/pfMetalPipelineCreatable.h" | ||
#endif | ||
|
||
#include "pfJournalBook/pfJournalBookCreatable.h" | ||
#include "pfMessage/pfMessageCreatable.h" | ||
#include "pfPython/pfPythonCreatable.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
metalcpp | ||
URL_HASH_SHA256 0afd87ca851465191ae4e3980aa036c7e9e02fe32e7c760ac1a74244aae6023b | ||
URL "https://developer.apple.com/metal/cpp/files/metal-cpp_macOS13.3_iOS16.4.zip" | ||
) | ||
|
||
FetchContent_MakeAvailable(metalcpp) | ||
|
||
set(pfMetalPipeline_SOURCES | ||
plMetalDevice.cpp | ||
plMetalDeviceRefs.cpp | ||
plMetalMaterialShaderRef.cpp | ||
plMetalPipeline.cpp | ||
plMetalPipelineState.cpp | ||
plMetalPlateManager.cpp | ||
plMetalShader.cpp | ||
plMetalFragmentShader.cpp | ||
plMetalVertexShader.cpp | ||
plMetalTextFont.cpp | ||
plMetalEnumerate.mm | ||
plMetalDevicePerformanceShaders.mm | ||
) | ||
|
||
set(pfMetalPipeline_HEADERS | ||
plMetalDevice.h | ||
plMetalDeviceRef.h | ||
plMetalMaterialShaderRef.h | ||
plMetalPipeline.h | ||
plMetalPipelineState.h | ||
plMetalPlateManager.h | ||
plMetalShader.h | ||
plMetalTextFont.h | ||
plMetalFragmentShader.h | ||
plMetalVertexShader.h | ||
ShaderSrc/ShaderTypes.h | ||
ShaderSrc/ShaderVertex.h | ||
pfMetalPipelineCreatable.h | ||
) | ||
|
||
plasma_library(pfMetalPipeline SOURCES ${pfMetalPipeline_SOURCES} ${pfMetalPipeline_HEADERS}) | ||
target_link_libraries(pfMetalPipeline | ||
PUBLIC | ||
CoreLib | ||
pnNucleusInc | ||
plPipeline | ||
"-framework Metal" | ||
"-framework MetalPerformanceShaders" | ||
PRIVATE | ||
plStatusLog | ||
INTERFACE | ||
pnFactory | ||
) | ||
|
||
target_include_directories(pfMetalPipeline PUBLIC ${metalcpp_SOURCE_DIR}) | ||
target_include_directories(pfMetalPipeline PUBLIC "ShaderSrc") | ||
|
||
source_group("Source Files" FILES ${pfMetalPipeline_SOURCES}) | ||
source_group("Header Files" FILES ${pfMetalPipeline_HEADERS}) | ||
|
||
add_library(pfMetalPipelineShaders INTERFACE) | ||
set(pfMetalPipeline_SHADERS | ||
ShaderSrc/FixedPipelineShaders.metal | ||
ShaderSrc/PlateShaders.metal | ||
ShaderSrc/BiasNormals.metal | ||
ShaderSrc/CompCosines.metal | ||
ShaderSrc/WaveSet7.metal | ||
ShaderSrc/Grass.metal | ||
ShaderSrc/WaveDecEnv.metal | ||
ShaderSrc/Avatar.metal | ||
ShaderSrc/WaveDec1Lay_7.metal | ||
ShaderSrc/WaveRip.metal | ||
ShaderSrc/Clear.metal | ||
ShaderSrc/GammaCorrection.metal | ||
ShaderSrc/TextFontShader.metal | ||
) | ||
set_source_files_properties(${pfMetalPipeline_SHADERS} TARGET_DIRECTORY plClient PROPERTIES LANGUAGE METAL) | ||
# source group does not work with an interface library in Xcode, but maybe someday... | ||
source_group("Metal Shaders" FILES ${pfMetalPipeline_SHADERS}) | ||
|
||
target_sources(pfMetalPipelineShaders INTERFACE ${pfMetalPipeline_SHADERS}) |
Oops, something went wrong.