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

WIP: Metal backend #1287

Open
wants to merge 302 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
302 commits
Select commit Hold shift + click to select a range
caba20d
apply gamma correction
SamoZ256 Aug 11, 2024
c6ab45a
fix: vertex buffer leaks
SamoZ256 Aug 11, 2024
eb573fc
fix: color write mask and unpackHalf2x16
SamoZ256 Aug 11, 2024
8316cee
prepare for surface copy
SamoZ256 Aug 11, 2024
5bc9913
implement surface copy
SamoZ256 Aug 11, 2024
7fb3e1b
support cubemap arrays
SamoZ256 Aug 12, 2024
8496fc1
Merge branch 'main' into metal
SamoZ256 Aug 12, 2024
5e748cd
support surface copy parameters
SamoZ256 Aug 12, 2024
34d8076
fix: srgb
SamoZ256 Aug 12, 2024
0c73ff8
use multiple command buffers per frame
SamoZ256 Aug 12, 2024
3f52f3a
fix: cubemap sampling
SamoZ256 Aug 13, 2024
4b7c01e
fix: 3D texture copies & fix: present filter
SamoZ256 Aug 13, 2024
5e9537c
fix: render pass mess
SamoZ256 Aug 13, 2024
27925a4
do vertex buffer restride in a void vertex function
SamoZ256 Aug 13, 2024
bba2bbc
use buffer allocator for restrided vertex buffers
SamoZ256 Aug 13, 2024
13834ca
correct comment
SamoZ256 Aug 14, 2024
53efb9e
prepare for shader cache
SamoZ256 Aug 14, 2024
3c1a747
save pipelines to a binary archive
SamoZ256 Aug 14, 2024
52062bd
Merge branch 'main' into metal
SamoZ256 Aug 14, 2024
d48de5b
fix: buffer cache crash on shutdown
SamoZ256 Aug 14, 2024
c4688e1
stringify utility shader source
SamoZ256 Aug 14, 2024
0bb99aa
set depth bias
SamoZ256 Aug 14, 2024
be98734
fix: incorrect roundEven implementation
SamoZ256 Aug 14, 2024
ed7354f
reset depth bias
SamoZ256 Aug 14, 2024
9a215e0
don't bind textures and buffers which are already bound
SamoZ256 Aug 15, 2024
9982ac7
remove more unnecessary rebinds
SamoZ256 Aug 15, 2024
d79d7fe
implement sampler cache
SamoZ256 Aug 15, 2024
0d0152d
fix: present
SamoZ256 Aug 16, 2024
502d5b8
include debug information
SamoZ256 Aug 16, 2024
83a08b2
fix: some Metal validation errors
SamoZ256 Aug 17, 2024
b8e9bb3
fix: GPU hangs (hack)
SamoZ256 Aug 17, 2024
07989d8
fix: performance regression
SamoZ256 Aug 17, 2024
2657857
rework buffer allocator
SamoZ256 Aug 18, 2024
269e072
move buffer allocators to separate file & fix: high memory usage
SamoZ256 Aug 18, 2024
485a652
use managed storage mode when dedicated memory
SamoZ256 Aug 18, 2024
be0a69a
do texture load on GPU if no unified memory
SamoZ256 Aug 18, 2024
9bb7479
use more efficient cpu cache mode when possible
SamoZ256 Aug 18, 2024
9aa72e6
report vram usage
SamoZ256 Aug 18, 2024
e2f66b8
fix: streamout
SamoZ256 Aug 19, 2024
b59dbfc
hack: increase xfb ring buffer size
SamoZ256 Aug 19, 2024
69a3624
do GPU texture loading on non-apple GPUs
SamoZ256 Aug 19, 2024
ca256eb
check for pixel format support
SamoZ256 Aug 19, 2024
6b13604
emit object shaders
SamoZ256 Aug 20, 2024
b10bcd4
emit mesh shaders
SamoZ256 Aug 20, 2024
46269c0
fix: mesh shader errors
SamoZ256 Aug 20, 2024
9679c6b
set primitive count in mesh shaders
SamoZ256 Aug 20, 2024
2f4ceb3
patch object and mesh shaders
SamoZ256 Aug 20, 2024
97f441e
draw with geometry shaders
SamoZ256 Aug 20, 2024
76cf3de
disable vertex buffer restride for object shaders
SamoZ256 Aug 20, 2024
7500a54
fix: geometry shaders
SamoZ256 Aug 21, 2024
a832bc2
support rect primitive emulation
SamoZ256 Aug 21, 2024
339af5c
support formats with X components
SamoZ256 Aug 21, 2024
4f7288d
fix: rect mesh shader errors
SamoZ256 Aug 21, 2024
3d0055a
end render pass if attachment is being read
SamoZ256 Aug 21, 2024
67a64c9
rework the binding system
SamoZ256 Aug 22, 2024
c05b2d0
don't stringify shader source & move vertex buffer bindings by 1
SamoZ256 Aug 22, 2024
b332d63
Merge pull request #1 from SamoZ256/metal-geo-shaders
SamoZ256 Aug 22, 2024
8e87b96
fix: missing lod parameter
SamoZ256 Aug 22, 2024
28aef85
fix: texture readback
SamoZ256 Aug 23, 2024
6bb1912
simplify texture readback
SamoZ256 Aug 23, 2024
d4a1074
rework the present system
SamoZ256 Aug 23, 2024
7499c3f
add: ImGui support
SamoZ256 Aug 24, 2024
c4a26d4
report total vram correctly
SamoZ256 Aug 24, 2024
6bf3406
implement IsPadWindowActive
SamoZ256 Aug 24, 2024
b105a38
add: basic debug overlay
SamoZ256 Aug 24, 2024
c905399
fix: ImGui issues
SamoZ256 Aug 25, 2024
96d6168
add: additional debug info
SamoZ256 Aug 25, 2024
a693bf5
fix: issues on Intel Macs
SamoZ256 Aug 25, 2024
6c8947d
fix: temporary buffer allocator
SamoZ256 Aug 26, 2024
b7f88d0
implement buffer locking system
SamoZ256 Aug 26, 2024
cd8b74b
fix: buffer allocator leaks
SamoZ256 Aug 26, 2024
3439b32
uncomment drc swap buffer
SamoZ256 Aug 27, 2024
b7a1ade
clip mode
SamoZ256 Aug 27, 2024
a1b20fd
Merge pull request #2 from SamoZ256/metal-intel-macs
SamoZ256 Aug 27, 2024
4572f90
fix: infinite command buffer wait
SamoZ256 Aug 27, 2024
0e61471
skip draws when pipeline is invalid
SamoZ256 Aug 27, 2024
366be04
fix: validation errors
SamoZ256 Aug 28, 2024
163eeea
use texture views for surface copies
SamoZ256 Aug 28, 2024
1b44269
simplify flush
SamoZ256 Aug 28, 2024
be76dad
do surface copy properly
SamoZ256 Aug 28, 2024
35740c5
always do texture copies on gpu
SamoZ256 Aug 28, 2024
a6c8d83
release unused buffers
SamoZ256 Aug 28, 2024
bbed007
hack: don't attempt to compile shaders with errors
SamoZ256 Aug 28, 2024
64610c1
limit buffer allocation size
SamoZ256 Aug 28, 2024
b011d75
adjust texture swizzle
SamoZ256 Aug 29, 2024
7a28985
properly implement 0 stride vertex buffers
SamoZ256 Aug 29, 2024
074f9f6
align buffer stride after setting to min stride
SamoZ256 Aug 29, 2024
ccd72bf
implement gather sampling
SamoZ256 Aug 29, 2024
a4ff855
do buffer copying in a void vertex function
SamoZ256 Aug 29, 2024
2403cf9
always use blit commands for buffer copies on non-apple GPUs
SamoZ256 Aug 29, 2024
1cfb841
do buffer cache uploading on the GPU
SamoZ256 Aug 29, 2024
2f822d0
support game pad view in a separate window
SamoZ256 Aug 30, 2024
41ee2e7
Merge branch 'main' into metal
SamoZ256 Aug 30, 2024
1412d1e
enable triangle fan support
SamoZ256 Aug 30, 2024
9c29acc
synchronize buffer copying correctly
SamoZ256 Aug 30, 2024
cda4799
disable writes for color attachments which are not in the active FBO
SamoZ256 Aug 30, 2024
a9a4d7b
disable depth write if active FBO doesn't have a depth attachment
SamoZ256 Aug 30, 2024
5eb3026
skip unnecessary draws
SamoZ256 Aug 31, 2024
f9f6260
monitor clears
SamoZ256 Aug 31, 2024
5d07d11
emulate unsupported shadow sampler types
SamoZ256 Sep 1, 2024
491ac69
fix: object shader error when used with rect primitive
SamoZ256 Sep 1, 2024
45737e8
disable shader write usage on textures
SamoZ256 Sep 2, 2024
c4eb195
make all textures be at least 1x1x1
SamoZ256 Sep 2, 2024
953975f
don't jit compile vertex shaders
SamoZ256 Sep 3, 2024
2ee92e5
use the correct fetch shader
SamoZ256 Sep 3, 2024
b13ba58
correct the object shader hash
SamoZ256 Sep 4, 2024
8a74445
don't compile fragment shaders just-in-time
SamoZ256 Sep 4, 2024
cd72ad8
include color format data types in ps hash
SamoZ256 Sep 5, 2024
4251f3f
check for invalid color formats
SamoZ256 Sep 6, 2024
6a3bdd4
refactor pixel format support
SamoZ256 Sep 6, 2024
548ffb6
add: todo notices
SamoZ256 Sep 6, 2024
5e50592
Merge pull request #3 from SamoZ256/metal-shaders
SamoZ256 Sep 6, 2024
3dc233f
support rasterization kill
SamoZ256 Sep 7, 2024
cf56024
optimize rasterization kill
SamoZ256 Sep 7, 2024
8404981
make binary archives device and os version specific
SamoZ256 Sep 7, 2024
e8f726e
use lcr
SamoZ256 Sep 7, 2024
395cd1c
handle rasterization kill for mesh shaders
SamoZ256 Sep 11, 2024
950f04d
support instancing for mesh shaders
SamoZ256 Sep 11, 2024
e7f8f0e
simplify uniform names
SamoZ256 Sep 11, 2024
a328c5e
use uchar for index type
SamoZ256 Sep 11, 2024
4cce369
put query object into a separate file
SamoZ256 Sep 12, 2024
eb7c10e
implement occlusion queries
SamoZ256 Sep 13, 2024
fd16488
improve command buffer sync
SamoZ256 Sep 13, 2024
934b1f8
handle occlusion queries with no draws
SamoZ256 Sep 13, 2024
e89efed
request soon commit instead of committing directly
SamoZ256 Sep 13, 2024
e5dcd93
Merge pull request #4 from SamoZ256/metal-occlusion-queries
SamoZ256 Sep 14, 2024
b5954d8
release command buffers properly
SamoZ256 Sep 14, 2024
25a1d7e
Merge branch 'cemu-project:main' into metal
SamoZ256 Sep 14, 2024
02254d4
set pixel format view usage for textures
SamoZ256 Sep 14, 2024
008c11c
allocate special buffers only when needed
SamoZ256 Sep 14, 2024
2961151
correct comment
SamoZ256 Sep 14, 2024
358567a
make a workaround for streamout with no fbo
SamoZ256 Sep 14, 2024
8ac90ce
use correct stages for buffer sync
SamoZ256 Sep 16, 2024
535107e
fix: invalid surface copy depth
SamoZ256 Sep 16, 2024
aa81070
refactor pixel formats
SamoZ256 Sep 16, 2024
f03c0a2
only set buffer offset if needed
SamoZ256 Sep 19, 2024
a460a5d
do vertex restride on the CPU
SamoZ256 Sep 21, 2024
7ad57f5
add the option to disable accurate barriers
SamoZ256 Sep 21, 2024
4b548f9
never disable accurate barriers for certain shaders
SamoZ256 Sep 21, 2024
8b68df0
use correct texture decoders
SamoZ256 Sep 22, 2024
3cf831d
do vertex restride on the GPU & don't over-sync
SamoZ256 Sep 23, 2024
3de2b03
only enable metal on apple platforms by default
SamoZ256 Sep 28, 2024
ed5f72a
include texture decoder in pixel format info
SamoZ256 Sep 28, 2024
f9e71e9
implement ABGR4 texture decoders
SamoZ256 Sep 28, 2024
810168b
use alternative texture decoders for unsupported formats
SamoZ256 Sep 28, 2024
8c30bc8
use RG8Unorm format if ABGR4Unorm is not available
SamoZ256 Sep 28, 2024
6c8cd5c
use private storage mode when possible
SamoZ256 Sep 30, 2024
b088ddc
implement output shaders
SamoZ256 Sep 30, 2024
28e553e
cache output shaders
SamoZ256 Sep 30, 2024
07cb8b8
set output shader uniforms
SamoZ256 Sep 30, 2024
778037f
remove useless print statement
SamoZ256 Sep 30, 2024
c65123b
use logging instead of printing
SamoZ256 Sep 30, 2024
5d01c77
rename hybrid pipeline to void vertex pipeline
SamoZ256 Sep 30, 2024
a3bfde8
remove old present pipelines
SamoZ256 Sep 30, 2024
94e8ed5
fetch vertices manually if needed
SamoZ256 Oct 1, 2024
f2096de
remove vertex restriding code
SamoZ256 Oct 1, 2024
50175fc
report manual vertex fetch draws per frame
SamoZ256 Oct 1, 2024
6dc8f9a
Merge pull request #5 from SamoZ256/metal-no-vertex-restride
SamoZ256 Oct 1, 2024
2fb4d83
don't set verticesPerInstance twice
SamoZ256 Oct 1, 2024
6ba6157
properly implement ABGR4 decoder
SamoZ256 Oct 1, 2024
ebcb62a
add: an option to turn fast math off
SamoZ256 Oct 2, 2024
6b784ad
log relevant settings
SamoZ256 Oct 2, 2024
756470f
remove CMake hacks
SamoZ256 Oct 9, 2024
bfd9059
remove the -g flag on debug builds
SamoZ256 Oct 9, 2024
bdfac96
implement async shader compilation
SamoZ256 Oct 10, 2024
03bc647
prepone compilation for rect geometry shaders
SamoZ256 Oct 10, 2024
641ef71
count compiled shaders properly
SamoZ256 Oct 10, 2024
fabaf16
Merge pull request #6 from SamoZ256/metal-async
SamoZ256 Oct 11, 2024
8b783e6
refactor pipeline cache
SamoZ256 Oct 13, 2024
e9e510d
add: base for pipeline caching
SamoZ256 Oct 14, 2024
6b47d4f
implement pipeline cache serializing
SamoZ256 Oct 15, 2024
cd21d95
refactor fbos
SamoZ256 Oct 15, 2024
944cc8b
store loaded pipelines
SamoZ256 Oct 15, 2024
79f5586
report pipeline compilation count
SamoZ256 Oct 15, 2024
d1c69e9
set shader just before compiling
SamoZ256 Oct 15, 2024
cbde7f9
force compile shaders if needed
SamoZ256 Oct 15, 2024
4dcb858
check if pipeline is eligible for serializing
SamoZ256 Oct 15, 2024
7d9194a
don't overshadow error
SamoZ256 Oct 15, 2024
8f2385a
use lcr instead of contextNew
SamoZ256 Oct 16, 2024
15eb6bb
fix: pipeline cache with mesh shaders
SamoZ256 Oct 19, 2024
295a6ed
only add pipeline to cache if compilation was attempted
SamoZ256 Oct 19, 2024
1750715
retrieve ps input table without using global variable
SamoZ256 Oct 19, 2024
b8021b6
fix: incorrect texture usages
SamoZ256 Oct 24, 2024
665eb23
fix: incorrect pipeline compilation time report
SamoZ256 Oct 28, 2024
bca32c4
refactor the way pipelines are stored
SamoZ256 Oct 28, 2024
4e3f94e
compile pipelines async
SamoZ256 Oct 28, 2024
7906733
don't compile certain pipelines async
SamoZ256 Oct 28, 2024
228fd34
Merge pull request #9 from SamoZ256/metal-async-pipelines
SamoZ256 Oct 29, 2024
85db0dc
cache all pipelines
SamoZ256 Oct 29, 2024
a61d0f0
Merge pull request #7 from SamoZ256/metal-pipeline-cache
SamoZ256 Oct 29, 2024
00256e5
only set blend color when changed
SamoZ256 Oct 29, 2024
e7ac199
make occlusion queries accumulate with draws
SamoZ256 Oct 30, 2024
7eb8508
fix: CI when metal is disabled
SamoZ256 Oct 31, 2024
927c52e
implement calculate texture lod
SamoZ256 Nov 1, 2024
6eb46ed
remove 'Vulkan' from cache loading message
SamoZ256 Nov 1, 2024
61de5a3
only log todo for vulkan output shader
SamoZ256 Nov 1, 2024
ed48fbf
Merge branch 'main' into metal
SamoZ256 Nov 1, 2024
ab41de4
use host memory instead of buffer cache when possible
SamoZ256 Nov 3, 2024
03d4e86
add an option to use the host memory instead of buffer cache
SamoZ256 Nov 3, 2024
b38ca6a
add an option to choose buffer cache type
SamoZ256 Nov 3, 2024
b008ace
Merge pull request #10 from SamoZ256/metal-host-buffer
SamoZ256 Nov 3, 2024
31c10bd
move fast math option to game profile
SamoZ256 Nov 3, 2024
e00d244
remove unused code
SamoZ256 Nov 3, 2024
fbea328
correctly report memory usage for host buffer cache
SamoZ256 Nov 3, 2024
a00d409
improve host and device shared buffer cache modes
SamoZ256 Nov 4, 2024
2e93b08
rename buffer cache type to buffer cache mode
SamoZ256 Nov 4, 2024
2790200
separate metal shader cache
SamoZ256 Nov 4, 2024
07c62d5
release texture upload buffer
SamoZ256 Nov 5, 2024
ea0a30b
handle special state 8 and 5
SamoZ256 Nov 5, 2024
552c490
implement occlusion query flush
SamoZ256 Nov 5, 2024
c46c821
refactor command buffers
SamoZ256 Nov 5, 2024
fc1580f
remove outdated todo notices
SamoZ256 Nov 5, 2024
798da38
Merge branch 'main' into metal
SamoZ256 Nov 6, 2024
763e50c
Merge branch 'main' into metal
SamoZ256 Nov 7, 2024
2c9f627
remove MetalLogging log type
SamoZ256 Nov 8, 2024
f264957
implement screenshots
SamoZ256 Nov 8, 2024
6897abd
fix: a typo in the attribute decoder
SamoZ256 Nov 8, 2024
f1db7d5
don't log texture allocation warnings
SamoZ256 Nov 9, 2024
02c36d9
add: blit todo notice
SamoZ256 Nov 9, 2024
97be576
cast texture slice to uint
SamoZ256 Nov 10, 2024
ed32feb
rint texture slice & explicitly specify texture lod
SamoZ256 Nov 10, 2024
a52095b
sync between command buffers
SamoZ256 Nov 10, 2024
326d344
cleanup the buffer allocator
SamoZ256 Nov 11, 2024
4b58ac1
check if verticesPerInstance uniform is used
SamoZ256 Nov 11, 2024
a1b9164
don't mask ps inputs with 0x7F
SamoZ256 Nov 11, 2024
6ea6ad3
use verticesPerInstance for rect vertex shaders
SamoZ256 Nov 11, 2024
5b7a0fa
warn about invalid primitive mode
SamoZ256 Nov 14, 2024
c9b18ef
don't transform depth to 0...1
SamoZ256 Nov 14, 2024
d732416
invalidate index buffers when a command buffer finishes
SamoZ256 Nov 14, 2024
38cbd3e
handle halfZ in the shader decompiler
SamoZ256 Nov 15, 2024
a721364
log instead of printf
SamoZ256 Nov 15, 2024
a81ee79
maximize concurrent shader compilation when loading shader cache
SamoZ256 Nov 15, 2024
2890819
fix: triangle fan index count
SamoZ256 Nov 16, 2024
8a80373
rework the command buffer system
SamoZ256 Nov 16, 2024
b486568
limit height to 1 for 1D textures
SamoZ256 Nov 19, 2024
b140984
fix: texture sample gradient errors
SamoZ256 Nov 19, 2024
c5bef60
save pipeline even if compilation failed
SamoZ256 Nov 19, 2024
7f5040a
don't release autoreleased objects
SamoZ256 Nov 19, 2024
cabf568
Merge branch 'main' into metal
SamoZ256 Nov 19, 2024
fda2f40
fix: output shader issues
SamoZ256 Nov 19, 2024
9095035
only set array length for texture arrays
SamoZ256 Nov 20, 2024
d9f857b
only set array length for texture view arrays
SamoZ256 Nov 20, 2024
732e3be
explicitly make integer constants int
SamoZ256 Nov 20, 2024
66ad59d
implement state 5 through a draw call
SamoZ256 Nov 22, 2024
00857b2
support arbitrary pixel formats for state 5
SamoZ256 Nov 22, 2024
14258cd
Revert "only set array length for texture view arrays"
SamoZ256 Nov 23, 2024
06f43b4
Merge branch 'metal' into metal-state5
SamoZ256 Nov 23, 2024
009dab8
remove useless includes
SamoZ256 Nov 23, 2024
4c54f4b
Merge pull request #12 from SamoZ256/metal-state5
SamoZ256 Nov 23, 2024
05b603d
fix: incorrect texture read coord type
SamoZ256 Nov 23, 2024
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
path = dependencies/imgui
url = https://github.com/ocornut/imgui
shallow = true
[submodule "dependencies/metal-cpp"]
path = dependencies/metal-cpp
url = https://github.com/bkaradzic/metal-cpp.git
shallow = true
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (ENABLE_VCPKG)
OUTPUT_VARIABLE is_vcpkg_shallow
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(is_vcpkg_shallow STREQUAL "true")
message(STATUS "vcpkg is shallow. Unshallowing it now...")
execute_process(
Expand Down Expand Up @@ -100,10 +100,20 @@ if (UNIX AND NOT APPLE)
option(ENABLE_FERAL_GAMEMODE "Enables Feral Interactive GameMode Support" ON)
endif()

if (APPLE)
set(ENABLE_METAL_DEFAULT ON)
else()
set(ENABLE_METAL_DEFAULT OFF)
endif()

option(ENABLE_OPENGL "Enables the OpenGL backend" ON)
option(ENABLE_VULKAN "Enables the Vulkan backend" ON)
option(ENABLE_METAL "Enables the Metal backend" ${ENABLE_METAL_DEFAULT})
option(ENABLE_DISCORD_RPC "Enables the Discord Rich Presence feature" ON)

if (ENABLE_METAL AND NOT APPLE)
message(FATAL_ERROR "Metal backend is only supported on Apple platforms")
endif()

# input backends
if (WIN32)
Expand Down Expand Up @@ -189,6 +199,12 @@ if (ENABLE_OPENGL)
find_package(OpenGL REQUIRED)
endif()

if (ENABLE_METAL)
include_directories(${CMAKE_SOURCE_DIR}/dependencies/metal-cpp)

add_definitions(-DENABLE_METAL=1)
endif()

if (ENABLE_DISCORD_RPC)
add_compile_definitions(ENABLE_DISCORD_RPC)
add_subdirectory(dependencies/discord-rpc EXCLUDE_FROM_ALL)
Expand All @@ -215,7 +231,7 @@ endif()

if (ENABLE_CUBEB)
if (NOT ENABLE_VCPKG)
find_package(cubeb)
find_package(cubeb)
endif()
if (NOT cubeb_FOUND)
option(BUILD_TESTS "" OFF)
Expand Down
1 change: 1 addition & 0 deletions dependencies/metal-cpp
Submodule metal-cpp added at a63bd1
64 changes: 63 additions & 1 deletion src/Cafe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,69 @@ add_library(CemuCafe
)

if(APPLE)
target_sources(CemuCafe PRIVATE "HW/Latte/Renderer/Vulkan/CocoaSurface.mm")
target_sources(CemuCafe PRIVATE
HW/Latte/Renderer/Vulkan/CocoaSurface.mm
HW/Latte/Renderer/MetalView.mm
HW/Latte/Renderer/MetalView.h
)
endif()

if(ENABLE_METAL)
# TODO: sort alphabetically
target_sources(CemuCafe PRIVATE
HW/Latte/Renderer/Metal/MetalRenderer.cpp
HW/Latte/Renderer/Metal/MetalRenderer.h
HW/Latte/Renderer/Metal/MetalCommon.h
HW/Latte/Renderer/Metal/MetalCppImpl.cpp
HW/Latte/Renderer/Metal/MetalLayer.mm
HW/Latte/Renderer/Metal/MetalLayer.h
HW/Latte/Renderer/Metal/MetalLayerHandle.cpp
HW/Latte/Renderer/Metal/MetalLayerHandle.h
HW/Latte/Renderer/Metal/LatteToMtl.cpp
HW/Latte/Renderer/Metal/LatteToMtl.h
HW/Latte/Renderer/Metal/LatteTextureMtl.cpp
HW/Latte/Renderer/Metal/LatteTextureMtl.h
HW/Latte/Renderer/Metal/LatteTextureViewMtl.cpp
HW/Latte/Renderer/Metal/LatteTextureViewMtl.h
HW/Latte/Renderer/Metal/LatteTextureReadbackMtl.cpp
HW/Latte/Renderer/Metal/LatteTextureReadbackMtl.h
HW/Latte/Renderer/Metal/RendererShaderMtl.cpp
HW/Latte/Renderer/Metal/RendererShaderMtl.h
HW/Latte/Renderer/Metal/CachedFBOMtl.cpp
HW/Latte/Renderer/Metal/CachedFBOMtl.h
HW/Latte/Renderer/Metal/MetalAttachmentsInfo.cpp
HW/Latte/Renderer/Metal/MetalAttachmentsInfo.h
HW/Latte/Renderer/Metal/MetalBufferAllocator.h
HW/Latte/Renderer/Metal/MetalMemoryManager.cpp
HW/Latte/Renderer/Metal/MetalMemoryManager.h
HW/Latte/Renderer/Metal/MetalOutputShaderCache.cpp
HW/Latte/Renderer/Metal/MetalOutputShaderCache.h
HW/Latte/Renderer/Metal/MetalPipelineCompiler.cpp
HW/Latte/Renderer/Metal/MetalPipelineCompiler.h
HW/Latte/Renderer/Metal/MetalPipelineCache.cpp
HW/Latte/Renderer/Metal/MetalPipelineCache.h
HW/Latte/Renderer/Metal/MetalDepthStencilCache.cpp
HW/Latte/Renderer/Metal/MetalDepthStencilCache.h
HW/Latte/Renderer/Metal/MetalSamplerCache.cpp
HW/Latte/Renderer/Metal/MetalSamplerCache.h
HW/Latte/Renderer/Metal/MetalVoidVertexPipeline.cpp
HW/Latte/Renderer/Metal/MetalVoidVertexPipeline.h
HW/Latte/Renderer/Metal/MetalQuery.cpp
HW/Latte/Renderer/Metal/MetalQuery.h
HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h
HW/Latte/Renderer/Metal/UtilityShaderSource.h
)

target_sources(CemuCafe PRIVATE
HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLAttrDecoder.cpp
HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp
HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp
)

#target_link_libraries(CemuCafe PRIVATE
# "-framework Metal"
# "-framework QuartzCore"
#)
endif()

set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down
12 changes: 10 additions & 2 deletions src/Cafe/CafeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ void InfoLog_PrintActiveSettings()
if (ActiveSettings::GetGraphicsAPI() == GraphicAPI::kVulkan)
{
cemuLog_log(LogType::Force, "Async compile: {}", GetConfig().async_compile.GetValue() ? "true" : "false");
if(!GetConfig().vk_accurate_barriers.GetValue())
if (!GetConfig().vk_accurate_barriers.GetValue())
cemuLog_log(LogType::Force, "Accurate barriers are disabled!");
}
else if (ActiveSettings::GetGraphicsAPI() == GraphicAPI::kMetal)
{
cemuLog_log(LogType::Force, "Async compile: {}", GetConfig().async_compile.GetValue() ? "true" : "false");
cemuLog_log(LogType::Force, "Fast math: {}", g_current_game_profile->GetFastMath() ? "true" : "false");
cemuLog_log(LogType::Force, "Buffer cache type: {}", g_current_game_profile->GetBufferCacheMode());
if (!GetConfig().vk_accurate_barriers.GetValue())
cemuLog_log(LogType::Force, "Accurate barriers are disabled!");
}
cemuLog_log(LogType::Force, "Console language: {}", stdx::to_underlying(config.console_language.GetValue()));
Expand Down Expand Up @@ -1013,7 +1021,7 @@ namespace CafeSystem
{
// starting with Cemu 1.27.0 /vol/storage_mlc01/ is virtualized, meaning that it doesn't point to one singular host os folder anymore
// instead it now uses a more complex solution to source titles with various formats (folder, wud, wua) from the game paths and host mlc path

// todo - mount /vol/storage_mlc01/ with base priority to the host mlc?

// since mounting titles is an expensive operation we have to avoid mounting all titles at once
Expand Down
18 changes: 13 additions & 5 deletions src/Cafe/GameProfile/GameProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool gameProfile_loadIntegerOption(IniParser& iniParser, const char* optionName,
{
cemuLog_log(LogType::Force, "Value '{}' is out of range for option '{}' in game profile", *option_value, optionName);
return false;
}
}
}

template<typename T>
Expand Down Expand Up @@ -224,8 +224,10 @@ bool GameProfile::Load(uint64_t title_id)
gameProfile_loadIntegerOption(&iniParser, "graphics_api", &graphicsApi, -1, 0, 1);
if (graphicsApi.value != -1)
m_graphics_api = (GraphicAPI)graphicsApi.value;

gameProfile_loadEnumOption(iniParser, "accurateShaderMul", m_accurateShaderMul);
gameProfile_loadBooleanOption2(iniParser, "fastMath", m_fastMath);
gameProfile_loadEnumOption(iniParser, "bufferCacheMode", m_bufferCacheMode);

// legacy support
auto option_precompiledShaders = iniParser.FindOption("precompiledShaders");
Expand Down Expand Up @@ -277,7 +279,7 @@ bool GameProfile::Load(uint64_t title_id)
void GameProfile::Save(uint64_t title_id)
{
auto gameProfileDir = ActiveSettings::GetConfigPath("gameProfiles");
if (std::error_code ex_ec; !fs::exists(gameProfileDir, ex_ec))
if (std::error_code ex_ec; !fs::exists(gameProfileDir, ex_ec))
fs::create_directories(gameProfileDir, ex_ec);
auto gameProfilePath = gameProfileDir / fmt::format("{:016x}.ini", title_id);
FileStream* fs = FileStream::createFile2(gameProfilePath);
Expand Down Expand Up @@ -308,6 +310,8 @@ void GameProfile::Save(uint64_t title_id)

fs->writeLine("[Graphics]");
WRITE_ENTRY(accurateShaderMul);
WRITE_ENTRY(fastMath);
WRITE_ENTRY(bufferCacheMode);
WRITE_OPTIONAL_ENTRY(precompiledShaders);
WRITE_OPTIONAL_ENTRY(graphics_api);
fs->writeLine("");
Expand Down Expand Up @@ -337,6 +341,8 @@ void GameProfile::ResetOptional()

// graphic settings
m_accurateShaderMul = AccurateShaderMulOption::True;
m_fastMath = true;
m_bufferCacheMode = BufferCacheMode::DevicePrivate;
// cpu settings
m_threadQuantum = kThreadQuantumDefault;
m_cpuMode.reset(); // CPUModeOption::kSingleCoreRecompiler;
Expand All @@ -354,9 +360,11 @@ void GameProfile::Reset()
// general settings
m_loadSharedLibraries = true;
m_startWithPadView = false;

// graphic settings
m_accurateShaderMul = AccurateShaderMulOption::True;
m_fastMath = true;
m_bufferCacheMode = BufferCacheMode::DevicePrivate;
m_precompiledShaders = PrecompiledShaderOption::Auto;
// cpu settings
m_threadQuantum = kThreadQuantumDefault;
Expand All @@ -366,4 +374,4 @@ void GameProfile::Reset()
// controller settings
for (auto& profile : m_controllerProfile)
profile.reset();
}
}
4 changes: 4 additions & 0 deletions src/Cafe/GameProfile/GameProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class GameProfile

[[nodiscard]] const std::optional<GraphicAPI>& GetGraphicsAPI() const { return m_graphics_api; }
[[nodiscard]] const AccurateShaderMulOption& GetAccurateShaderMul() const { return m_accurateShaderMul; }
[[nodiscard]] bool GetFastMath() const { return m_fastMath; }
[[nodiscard]] BufferCacheMode GetBufferCacheMode() const { return m_bufferCacheMode; }
[[nodiscard]] const std::optional<PrecompiledShaderOption>& GetPrecompiledShadersState() const { return m_precompiledShaders; }

[[nodiscard]] uint32 GetThreadQuantum() const { return m_threadQuantum; }
Expand All @@ -54,6 +56,8 @@ class GameProfile
// graphic settings
std::optional<GraphicAPI> m_graphics_api{};
AccurateShaderMulOption m_accurateShaderMul = AccurateShaderMulOption::True;
bool m_fastMath = false;
BufferCacheMode m_bufferCacheMode = BufferCacheMode::DevicePrivate;
std::optional<PrecompiledShaderOption> m_precompiledShaders{};
// cpu settings
uint32 m_threadQuantum = kThreadQuantumDefault; // values: 20000 45000 60000 80000 100000
Expand Down
Loading