Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal Rendering on macOS #1326

Merged
merged 165 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
a480ee4
Initial work to resync Metal work on master
colincornaby Aug 15, 2023
2144231
Setting more values to null to prevent crashes
colincornaby Feb 13, 2022
17b4d93
Moving aux spans back onto normal IHandleMaterial
colincornaby Feb 21, 2022
002bfc4
Fixing normalized co-ordinate identity crisis
colincornaby Feb 23, 2022
feac6b9
Fixing texture indexes
colincornaby Feb 23, 2022
286096c
Skipping spans with length 0
colincornaby Feb 23, 2022
8a72c86
Initial work on proper clear support
colincornaby Feb 27, 2022
c952b78
Fixes for fast material encoding
colincornaby Mar 1, 2022
bfd45ff
Integrating the optimized M1 Metal renderer
colincornaby Mar 19, 2022
1b1c2d5
Fixing crash on Intel graphics
colincornaby Mar 19, 2022
b1fbfa0
Initial version of avatar texture rendering
colincornaby Mar 21, 2022
4090cd8
Fixing missing license headers
colincornaby Mar 21, 2022
2826d1a
Fixes for clothing rendering
colincornaby Mar 21, 2022
b5fb8bb
Initial version of Metal device enumeration
colincornaby Mar 22, 2022
62bc4d0
Fixing CheckTextureRef
colincornaby Mar 22, 2022
b6397a4
Adding Metal pipeline as friend to AvatarClothing
colincornaby Mar 22, 2022
b889050
Adding Metal device picking
colincornaby Mar 22, 2022
702262b
Fixing clear color
colincornaby Mar 23, 2022
45b5013
Hacking in opacity support for plates
colincornaby Mar 25, 2022
2f7e6ca
Fixing self shadow bug, removing LUT
colincornaby Mar 27, 2022
207978b
Initial version of WaveDec1Lay_7
colincornaby Mar 27, 2022
793e9b9
Initial fixes for wave sets
colincornaby Mar 28, 2022
946f10f
Initial fixes for WaveDecEnv
colincornaby Mar 28, 2022
bec6acd
Fixes for wave shaders
colincornaby Mar 29, 2022
fc72800
Adjusting Z-Bias
colincornaby Mar 29, 2022
fdc6d27
More fixes to wave set shaders
colincornaby Mar 29, 2022
0ef446c
Shader was named wrong, fixing
colincornaby Mar 30, 2022
2b60361
Fixing unintentional overflow
colincornaby Mar 30, 2022
be97c72
Adding Wave Rip
colincornaby Mar 31, 2022
4e862c1
Fixing issue in WaveSet7
colincornaby Mar 31, 2022
831cbc9
Adding wave rip cmake
colincornaby Mar 31, 2022
79a26f8
Adding hardware single weight skinning
colincornaby Mar 31, 2022
59133aa
Fixing fog color and blend issues
colincornaby Apr 1, 2022
38ff4c6
Adding avatar tint colors
colincornaby Apr 1, 2022
6cb40d0
Fixing alpha threshold
colincornaby Apr 4, 2022
496f415
Fixing memory pile up during intro movie
colincornaby Jul 30, 2023
d1ba412
Improving state tracking
colincornaby Apr 9, 2022
8a6f194
Adding texture anisotropy support
colincornaby Apr 10, 2022
236c278
Adding missing “popRenderTarget”
colincornaby Apr 10, 2022
78b3145
Fixing performance with anisotropic texturing
colincornaby Apr 10, 2022
f182e96
Initial MSAA support
colincornaby Apr 11, 2022
0985736
Simplifying shader code
colincornaby Apr 12, 2022
0f4d76a
Fixing samplers
colincornaby Apr 12, 2022
b18d6a0
Moving drawable pass back down to single pass
colincornaby Apr 15, 2022
03b9616
Fixing rendering issues with state selection
colincornaby Apr 16, 2022
6f82663
Bug fixes and performance improvements for MSAA
colincornaby Apr 17, 2022
2e76abe
Fixing bug with aux spans and vertex buffers
colincornaby Apr 17, 2022
502ac98
Eliminating preshade colors from fragment pass
colincornaby Apr 17, 2022
50b301a
Implementing offscreen render support
colincornaby Apr 18, 2022
fd7c091
Fix for KI snapshots on discrete cards
colincornaby Apr 19, 2022
6d4fc83
Fixes for cubic target accidental recreation
colincornaby Apr 19, 2022
008dfb8
Fixing not using correct number of piggybacks
colincornaby Apr 23, 2022
7122c02
Fixing graphics options not working
colincornaby Apr 23, 2022
0df7b78
Implementing post processing/gamma
colincornaby Apr 25, 2022
d44b6b6
Small optimization for grass shader
colincornaby Apr 25, 2022
6a6d5c7
Fixes for shadowcasting
colincornaby Apr 25, 2022
f0bb4dd
Adding missing gamma correct shader
colincornaby Apr 25, 2022
d0266bf
Fixing menu going missing sometimes
colincornaby Apr 25, 2022
6220ac3
Fixing crashes on Intel integrated graphics. It was having trouble wi…
colincornaby Apr 27, 2022
603e9ac
Fixing postprocess texture options
colincornaby Apr 27, 2022
afdee69
Fixing render glitch due to sampleType length mixup
colincornaby May 11, 2022
6f1671a
Re-creating plate manager when reloading device
colincornaby May 20, 2022
1ed5e18
Removing logging
colincornaby May 20, 2022
0d680e3
Fixing device selection
colincornaby May 20, 2022
fb8a12f
Fixing water on Nvidia/MSL/Fast Math
May 29, 2022
138690b
Updating “fixed” shaders to remove const samplers
colincornaby May 30, 2022
6e7243a
Moving redering to main thread
colincornaby Jun 17, 2022
160cda0
Fixes for fog
colincornaby Jun 26, 2022
e183e50
Moving depth buffer to memoryless on Apple Silicon
colincornaby Jun 26, 2022
f84ff03
Fixing god rays in Kadish
colincornaby Jun 26, 2022
1d1f700
Fixes for problematic assets in Kadish
colincornaby Jun 26, 2022
e0e69c8
Fixing fog color getting mingled with projections
colincornaby Jun 26, 2022
c971b25
Moving opacity check after lighting calc
colincornaby Jul 6, 2022
1de1a58
Fixing infinite loop bug created by early return
colincornaby Jul 6, 2022
c25ee81
Adding ISetLayer
colincornaby Jul 11, 2022
711a6e8
Fixing state tracking
colincornaby Jul 13, 2022
4ffceed
Refactoring pass code
colincornaby Jul 18, 2022
0ff0d1a
Early version of Metal font rendering
colincornaby Jul 23, 2022
bbbab15
Hooking in font rendering
colincornaby Oct 2, 2023
e11c4dd
Making Metal text font a friend of pipeline
colincornaby Jul 23, 2022
9f24e42
Fixing reflections in K’veer
colincornaby Jul 23, 2022
64e6188
Fixes for age anomolies
colincornaby Jul 24, 2022
4f2e935
Simple changes for Gamma correction
colincornaby Jul 28, 2022
2920f37
Deleting numUVSrcs
colincornaby Jul 28, 2022
5620437
Initial version of shadow blurring
colincornaby Jul 28, 2022
22d96d0
More blurring
colincornaby Jul 28, 2022
9d551c0
Initial version of Metal over all projections
colincornaby Jul 28, 2022
006c91d
Initial version of private Metal textures
colincornaby Jul 28, 2022
45aa3f2
Fixing copy allocator for blur
colincornaby Jul 30, 2022
99ff520
Removing old fPipelineState
colincornaby Jul 30, 2022
6fa6565
Adding missing MPS link
colincornaby Jul 31, 2022
eb28191
Removing ranges import
colincornaby Jul 31, 2022
406fce4
Adding deep color support
colincornaby Sep 25, 2022
7a8f9d3
Removing Poisson Disk Shadow Treatment
colincornaby Aug 5, 2022
50d03ca
Enabling staging textures on all platforms
colincornaby Aug 5, 2022
56b11e6
Re-factoring how lights are encoded
colincornaby Aug 5, 2022
5ff886e
Fixes for memory leaks
colincornaby Aug 5, 2022
ed6d806
Fix for full screen being reversed
colincornaby Aug 7, 2022
85da7d9
Fixing render issues when MSAA disabled
colincornaby Aug 8, 2022
e57ad87
Trying to reduce register pressure in vs
colincornaby Aug 8, 2022
8cc5e33
Turning off main framebuffer viewport setting
colincornaby Aug 8, 2022
0af96b9
Fixing gamma texture descriptor
colincornaby Aug 8, 2022
d64b12c
Fixing MPS Blur
colincornaby Aug 9, 2022
4befb95
Binding samplers at encoder insetad of in shader
colincornaby Aug 9, 2022
ad2774b
Writing the bitmask correctly this time…
colincornaby Aug 9, 2022
f3e8184
Sampler states work again on projections
colincornaby Aug 12, 2022
0a1751a
Fixes for spot lighting
colincornaby Aug 12, 2022
73756ff
Culling redundant position calculations
colincornaby Aug 12, 2022
f04eeaa
Fixes for over all projects
colincornaby Aug 13, 2022
4dbc852
Fixing weird shadow flickering issues
colincornaby Aug 13, 2022
e626c9d
Fixing ghost avatars
colincornaby Aug 14, 2022
8e5fb97
Fixes for lighting
colincornaby Aug 31, 2022
da55553
Upping Metal lights max to 32
colincornaby Sep 1, 2022
261dc21
Sycronizing GPU state when correcting blend modes
colincornaby Sep 26, 2022
b0c1eab
Filtering available texture bindings by type
colincornaby Nov 23, 2022
0578e89
Fixing crash w aux spans and projections
colincornaby Dec 23, 2022
4309740
Fixing shadows not rendering on some hardware
colincornaby Dec 30, 2022
3155a3c
Fixes for WaveRip and vertex index streaming
colincornaby Jan 2, 2023
d68fbfa
Fixing Metal logging
colincornaby Feb 5, 2023
7433165
Getting rid of stray log
colincornaby Feb 17, 2023
eb1f3c8
Initial work on String Theory wrapper
colincornaby Feb 19, 2023
7d00365
Using target_include_directories
colincornaby Feb 19, 2023
ab16219
Removing extra manual clamp
colincornaby Feb 19, 2023
c4cec5c
Removing extra " from pfAllCreatables
colincornaby Feb 19, 2023
9bdea54
Removing Apple OpenAL support
colincornaby Feb 19, 2023
d36cdeb
Fixing missing shadows bug
colincornaby Feb 27, 2023
fbee202
Support for row major hsMatrix
colincornaby Feb 27, 2023
7460ded
Removing most double decs from Metal shader
colincornaby Jun 26, 2023
0c63875
Preventing redundant binds of samplers by tracking them locally
colincornaby Aug 20, 2023
1c25979
Adding light research from DX source
colincornaby Aug 20, 2023
d971982
Cleaning up sampler bug from optimizations
colincornaby Aug 20, 2023
a68ea2e
Moving shadow casting into lightless custom shader
colincornaby Sep 7, 2023
ac0884f
Fixing bug in projections. Projections altered the sampler state for …
colincornaby Sep 10, 2023
33e58a9
Adding graphics pipelines to pfFeatureInc
colincornaby Sep 11, 2023
b8cf163
Starting cleanup of shader binding names
colincornaby Sep 12, 2023
f0041e9
Fixing network error when status URL is not present
colincornaby Sep 15, 2023
99d3c98
Warning cleanup/general code cleanup
colincornaby Sep 23, 2023
fbffe17
Re-enabling the light prioritization path
colincornaby Oct 2, 2023
156fdbd
Adding clang-format
colincornaby Oct 15, 2023
b5f47c1
Updating code to match style
colincornaby Oct 19, 2023
a0277c6
Adding comment for Metal UBO encoding
colincornaby Oct 19, 2023
f45c306
Fixing header guards
colincornaby Oct 19, 2023
448fbc6
Documeting/cleaning up pipeline state header
colincornaby Oct 20, 2023
da3da39
Apply lint pass and adopting MTLSTR
colincornaby Nov 4, 2023
b0428cd
Moving some code to static_cast
colincornaby Nov 4, 2023
7bc5803
Fixing bundle identifier warning
colincornaby Nov 4, 2023
d9f0cb2
Removing delegate message filter for window size change. This was pre…
colincornaby Nov 4, 2023
9568467
First set of feedback changes
colincornaby Nov 4, 2023
8dab1e3
Another set of changes
colincornaby Nov 4, 2023
0705ab6
More feedback implementation
colincornaby Nov 4, 2023
ea39b7e
Work on sanitizing use of sizeof and buffer sizes
colincornaby Nov 6, 2023
168277f
Removing manual include of headers that are already public
colincornaby Nov 6, 2023
f65a5eb
Moving MPS link to public definition in Metal pipeline
colincornaby Nov 6, 2023
d662e4c
Implementing more review feedback
colincornaby Nov 9, 2023
b4899d7
Shader CMake cleanup
colincornaby Nov 10, 2023
da43aff
Code feedback
colincornaby Nov 11, 2023
db3c6d4
Giving renderer direct access to the Metal layer and removing drawabl…
colincornaby Nov 13, 2023
1570887
Indentation fixes for Obj-C pipeline files and Cyan header for shader
colincornaby Nov 13, 2023
986e8d3
More cleanup
colincornaby Nov 13, 2023
7b548f4
Fixes to fullscreen behavior on startup for Mac
colincornaby Nov 16, 2023
f3d9764
Removing setting of NSWindow for client window
colincornaby Nov 18, 2023
e34919f
Using stringWithSTString to set window title
colincornaby Nov 18, 2023
0df34e5
Fixing pink screen at start
colincornaby Nov 25, 2023
6c96be0
Review feedback updates
colincornaby Nov 27, 2023
245b00f
Removing clang format file
colincornaby Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ endif(PLASMA_EXTERNAL_RELEASE)
# Pipeline Renderers
cmake_dependent_option(PLASMA_PIPELINE_DX "Enable DirectX rendering pipeline?" ON "DirectX_FOUND" OFF)
cmake_dependent_option(PLASMA_PIPELINE_GL "Enable OpenGL rendering pipeline?" ON "TARGET epoxy::epoxy" OFF)
cmake_dependent_option(PLASMA_PIPELINE_METAL "Enable Metal rendering pipeline?" ON "APPLE" OFF)

if(PLASMA_PIPELINE_DX)
add_definitions(-DPLASMA_PIPELINE_DX)
Expand All @@ -156,6 +157,10 @@ if(PLASMA_PIPELINE_GL)
add_definitions(-DPLASMA_PIPELINE_GL)
endif(PLASMA_PIPELINE_GL)

if(PLASMA_PIPELINE_METAL)
add_definitions(-DPLASMA_PIPELINE_METAL)
endif(PLASMA_PIPELINE_METAL)
colincornaby marked this conversation as resolved.
Show resolved Hide resolved

# Allow us to disable certain parts of the build
option(PLASMA_BUILD_CLIENT "Do we want to build plClient?" ON)
cmake_dependent_option(PLASMA_BUILD_MAX_PLUGIN "Do we want to build the 3ds Max plugin?" OFF "TARGET 3dsm" OFF)
Expand Down
12 changes: 11 additions & 1 deletion Sources/Plasma/Apps/plClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>"
Expand Down
6 changes: 6 additions & 0 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSServerStatus.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ - (void)loadServerStatus
{
NSString* urlString = [NSString stringWithSTString:GetServerStatusUrl()];
NSURL* url = [NSURL URLWithString:urlString];

if (!url || !url.host) {
self.serverStatusString = @"";
return;
}

NSURLSessionConfiguration* URLSessionConfiguration =
[NSURLSessionConfiguration ephemeralSessionConfiguration];
NSURLSession* session = [NSURLSession sessionWithConfiguration:URLSessionConfiguration
Expand Down
6 changes: 0 additions & 6 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ - (void)resizeDrawable:(CGFloat)scaleFactor
}

#if PLASMA_PIPELINE_METAL
if (newSize.width == _metalLayer.drawableSize.width &&
newSize.height == _metalLayer.drawableSize.height)
{
return;
}

_metalLayer.drawableSize = newSize;
#endif
[self.delegate renderView:self
Expand Down
67 changes: 58 additions & 9 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@

// System Frameworks
#import <Cocoa/Cocoa.h>
#ifdef PLASMA_PIPELINE_GL
#import <OpenGL/gl.h>
#endif
#ifdef PLASMA_PIPELINE_METAL
#import <Metal/Metal.h>
#endif
#import <QuartzCore/QuartzCore.h>

// Cocoa client
Expand All @@ -63,7 +69,13 @@
#include "plCmdParser.h"
#include "pfConsoleCore/pfConsoleEngine.h"
#include "pfGameGUIMgr/pfGameGUIMgr.h"
#ifdef PLASMA_PIPELINE_GL
#include "pfGLPipeline/plGLPipeline.h"
#endif
#include "plInputCore/plInputDevice.h"
#ifdef PLASMA_PIPELINE_METAL
#include "pfMetalPipeline/plMetalPipeline.h"
#endif
#include "plMessage/plDisplayScaleChangedMsg.h"
#include "plMessageBox/hsMessageBox.h"
#include "plNetClient/plNetClientMgr.h"
Expand Down Expand Up @@ -162,6 +174,8 @@ @interface AppDelegate : NSWindowController <NSApplicationDelegate,

@implementation AppDelegate

static void* const DeviceDidChangeContext = (void*)&DeviceDidChangeContext;

- (id)init
{
// Style flags
Expand All @@ -181,6 +195,9 @@ - (id)init
self.plsView = view;
window.contentView = view;
[window setDelegate:self];

gClient.SetClientWindow((__bridge void *)view.layer);
colincornaby marked this conversation as resolved.
Show resolved Hide resolved
gClient.SetClientDisplay((hsWindowHndl)NULL);

self = [super initWithWindow:window];
self.window.acceptsMouseMovedEvents = YES;
Expand Down Expand Up @@ -445,17 +462,15 @@ - (void)startClient

// Window controller
[self.window setContentSize:NSMakeSize(800, 600)];
// #if 0
// allow this executation path to start in full screen
//[self.window toggleFullScreen:self];
// #endif
[self.window center];
[self.window makeKeyAndOrderFront:self];
self.renderLayer = self.window.contentView.layer;

gClient.SetClientWindow((hsWindowHndl)(__bridge void*)self.window);
gClient.SetClientDisplay((hsWindowHndl)NULL);


[self.renderLayer addObserver:self
forKeyPath:@"device"
options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial
context:DeviceDidChangeContext];

if (!gClient) {
exit(0);
}
Expand All @@ -473,8 +488,25 @@ - (void)startClient

- (void)updateWindowTitle
{
NSString* productTitle = [NSString stringWithSTString:plProduct::LongName()];
#ifdef PLASMA_PIPELINE_METAL
NSString *productTitle = [NSString stringWithSTString:plProduct::LongName()];
id<MTLDevice> device = ((CAMetalLayer *) self.window.contentView.layer).device;
#ifdef HS_DEBUGGING
[self.window setTitle:[NSString stringWithFormat:@"%@ - %@, %@",
productTitle,
#ifdef __arm64__
@"ARM64",
#else
@"x86_64",
#endif
device.name]];
#else
[self.window setTitle:productTitle];
#endif

#else
[NSString stringWithSTString:plProduct::LongName()];
#endif
}

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
Expand Down Expand Up @@ -517,6 +549,23 @@ - (NSApplicationPresentationOptions)window:(NSWindow*)window
NSApplicationPresentationAutoHideMenuBar;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context == DeviceDidChangeContext) {
// this may not happen on the main queue
dispatch_async(dispatch_get_main_queue(), ^{
[self updateWindowTitle];
});
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}

- (void)dealloc
{
[_renderLayer removeObserver:self forKeyPath:@"device" context:DeviceDidChangeContext];
}

@end

void PumpMessageQueueProc()
Expand Down
8 changes: 8 additions & 0 deletions Sources/Plasma/Apps/plClient/plClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/Plasma/CoreLib/HeadSpin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/CoreLib/plQuality.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class plQuality
friend class plClient;
friend class plQualitySlider;
friend class plDXPipeline;
friend class plMetalPipeline;

// Set by the app according to user preference.
static void SetQuality(int q);
Expand Down
3 changes: 3 additions & 0 deletions Sources/Plasma/FeatureLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ add_subdirectory(pfGameScoreMgr)
if(PLASMA_PIPELINE_GL)
add_subdirectory(pfGLPipeline)
endif()
if(PLASMA_PIPELINE_METAL)
add_subdirectory(pfMetalPipeline)
endif()
add_subdirectory(pfJournalBook)
add_subdirectory(pfLocalizationMgr)
add_subdirectory(pfMessage)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Plasma/FeatureLib/inc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ target_link_libraries(pfFeatureInc
pfGameMgr
pfJournalBook
pfMessage
$<$<BOOL:${PLASMA_PIPELINE_DX}>:pfDXPipeline>
$<$<BOOL:${PLASMA_PIPELINE_GL}>:pfGLPipeline>
$<$<BOOL:${PLASMA_PIPELINE_METAL}>:pfMetalPipeline>
pfPython
pfSurface
)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Plasma/FeatureLib/inc/pfAllCreatables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
82 changes: 82 additions & 0 deletions Sources/Plasma/FeatureLib/pfMetalPipeline/CMakeLists.txt
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})
Loading