Skip to content

Commit 2e17af1

Browse files
committed
use metal on macos
1 parent fe57291 commit 2e17af1

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ CMakeLists.txt.user
77
CMakeSettings.json
88
*~
99
*.TMP
10+
.DS_Store

externals/dawn/CMakeLists.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ message(STATUS "dawn")
33
message(STATUS "----------------------------------------------------------------")
44

55
set(CMAKE_DISABLE_FIND_PACKAGE_Python3 OFF)
6+
if(APPLE)
7+
set(metal ON)
8+
set(vulkan OFF)
9+
else()
10+
set(metal OFF)
11+
set(vulkan ON)
12+
endif()
613

714
# dawn
815
set(DAWN_ENABLE_INSTALL ON CACHE INTERNAL "Enable install step for Dawn libraries" FORCE)
916
set(DAWN_ENABLE_D3D11 OFF CACHE INTERNAL "Enable compilation of the D3D11 backend" FORCE)
1017
set(DAWN_ENABLE_D3D12 OFF CACHE INTERNAL "Enable compilation of the D3D12 backend" FORCE)
11-
set(DAWN_ENABLE_METAL OFF CACHE INTERNAL "Enable compilation of the Metal backend" FORCE)
18+
set(DAWN_ENABLE_METAL ${metal} CACHE INTERNAL "Enable compilation of the Metal backend" FORCE)
1219
set(DAWN_ENABLE_NULL OFF CACHE INTERNAL "Enable compilation of the Null backend" FORCE)
1320
set(DAWN_ENABLE_WEBGPU_ON_WEBGPU OFF CACHE INTERNAL "Enable compilation of the WebGPU backend" FORCE)
1421
set(DAWN_ENABLE_DESKTOP_GL OFF CACHE INTERNAL "Enable compilation of the OpenGL backend" FORCE)
1522
set(DAWN_ENABLE_OPENGLES OFF CACHE INTERNAL "Enable compilation of the OpenGL ES backend" FORCE)
16-
set(DAWN_ENABLE_VULKAN ON CACHE INTERNAL "Enable compilation of the Vulkan backend" FORCE)
23+
set(DAWN_ENABLE_VULKAN ${vulkan} CACHE INTERNAL "Enable compilation of the Vulkan backend" FORCE)
1724
set(DAWN_FORCE_SYSTEM_COMPONENT_LOAD ON CACHE INTERNAL "Allow system component fallback" FORCE)
1825
set(DAWN_USE_WAYLAND OFF CACHE INTERNAL "Enable support for Wayland surface" FORCE)
1926
set(DAWN_USE_X11 OFF CACHE INTERNAL "Enable support for X11 surface" FORCE)
@@ -31,8 +38,8 @@ set(TINT_BUILD_WGSL_READER ON CACHE INTERNAL "Build the WGSL input reader" FORCE
3138
set(TINT_BUILD_GLSL_WRITER OFF CACHE INTERNAL "Build the GLSL output writer" FORCE)
3239
set(TINT_BUILD_GLSL_VALIDATOR OFF CACHE INTERNAL "Build the GLSL output validator" FORCE)
3340
set(TINT_BUILD_HLSL_WRITER OFF CACHE INTERNAL "Build the HLSL output writer" FORCE)
34-
set(TINT_BUILD_MSL_WRITER OFF CACHE INTERNAL "Build the MSL output writer" FORCE)
35-
set(TINT_BUILD_SPV_WRITER ON CACHE INTERNAL "Build the SPIR-V output writer" FORCE)
41+
set(TINT_BUILD_MSL_WRITER ${metal} CACHE INTERNAL "Build the MSL output writer" FORCE)
42+
set(TINT_BUILD_SPV_WRITER ${vulkan} CACHE INTERNAL "Build the SPIR-V output writer" FORCE)
3643
set(TINT_BUILD_WGSL_WRITER ON CACHE INTERNAL "Build the WGSL output writer" FORCE)
3744
set(TINT_ENABLE_INSTALL OFF CACHE INTERNAL "Enable install step for Tint libraries" FORCE)
3845
set(TINT_BUILD_CMD_TOOLS OFF CACHE INTERNAL "Build the Tint command line tools" FORCE)
@@ -43,12 +50,18 @@ set(TINT_ENABLE_IR_VALIDATION ON CACHE INTERNAL "Enable IR validation for backen
4350
# protobuf
4451
add_library(libprotobuf-mutator INTERFACE) # subvert unnecessary dependencies
4552

53+
unset(metal)
54+
unset(vulkan)
55+
4656
# add the externals
4757
add_subdirectory(dawn)
4858

4959
# dawn
5060
add_library(cage_dawn INTERFACE)
5161
target_link_libraries(cage_dawn INTERFACE $<TARGET_LINKER_FILE:webgpu_dawn> $<TARGET_LINKER_FILE:webgpu_glfw>)
62+
if(APPLE)
63+
target_link_libraries(cage_dawn INTERFACE "-framework Cocoa" "-framework IOKit" "-framework Foundation" "-framework IOSurface" "-framework QuartzCore" "-framework Metal")
64+
endif()
5265
target_include_directories(cage_dawn INTERFACE $<TARGET_PROPERTY:webgpu_dawn,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:webgpu_glfw,INTERFACE_INCLUDE_DIRECTORIES>)
5366
add_dependencies(cage_dawn webgpu_dawn webgpu_glfw)
5467
add_library(cage::dawn ALIAS cage_dawn)

sources/libengine/graphics/device.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace cage
9797
wgpu::Adapter adapter;
9898
{
9999
wgpu::RequestAdapterOptions opts = {};
100-
opts.backendType = wgpu::BackendType::Vulkan;
100+
//opts.backendType = wgpu::BackendType::Vulkan;
101101
opts.powerPreference = wgpu::PowerPreference::HighPerformance;
102102
if (config.compatibility)
103103
opts.compatibleSurface = getContext(config.compatibility)->surface;
@@ -169,7 +169,8 @@ namespace cage
169169
cfg.width = res[0];
170170
cfg.height = res[1];
171171
cfg.presentMode = wgpu::PresentMode::Mailbox;
172-
cfg.format = wgpu::TextureFormat::RGBA8Unorm;
172+
//cfg.format = wgpu::TextureFormat::RGBA8Unorm;
173+
cfg.format = wgpu::TextureFormat::BGRA8Unorm;
173174
//cfg.usage = wgpu::TextureUsage::RenderAttachment;
174175
context->surface.Configure(&cfg);
175176
context->resolution = res;

0 commit comments

Comments
 (0)