feat(macos): suport Metal per GpuShaderPreset via spirv-cross
- CMakeLists: bloc if(APPLE) que transpila .spv → .spv.msl amb spirv-cross - gpu_shader_preset: carrega MSL (main0) a macOS, SPIR-V (main) a la resta - Afegeix null-terminator als buffers MSL (SDL3 els tracta com C-string) - README: secció de dependències de shaders per plataforma (Vulkan SDK, spirv-cross) - Inclou .spv.msl generats per ntsc-md-rainbows Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,33 @@ if(NOT APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# macOS: transpile .spv → .msl for GpuShaderPreset
|
||||
if(APPLE)
|
||||
find_program(SPIRV_CROSS spirv-cross)
|
||||
if(SPIRV_CROSS)
|
||||
file(GLOB_RECURSE DATA_SHADER_SPVS
|
||||
"${CMAKE_SOURCE_DIR}/data/shaders/*.vert.spv"
|
||||
"${CMAKE_SOURCE_DIR}/data/shaders/*.frag.spv"
|
||||
)
|
||||
set(DATA_SHADER_MSLS)
|
||||
foreach(SPV_FILE ${DATA_SHADER_SPVS})
|
||||
set(MSL_FILE "${SPV_FILE}.msl")
|
||||
add_custom_command(
|
||||
OUTPUT "${MSL_FILE}"
|
||||
COMMAND "${SPIRV_CROSS}" --msl --output "${MSL_FILE}" "${SPV_FILE}"
|
||||
DEPENDS "${SPV_FILE}"
|
||||
COMMENT "Transpiling ${SPV_FILE} to MSL"
|
||||
)
|
||||
list(APPEND DATA_SHADER_MSLS "${MSL_FILE}")
|
||||
endforeach()
|
||||
if(DATA_SHADER_MSLS)
|
||||
add_custom_target(data_shader_msls ALL DEPENDS ${DATA_SHADER_MSLS})
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "spirv-cross not found — GpuShaderPreset will not work on macOS (run: brew install spirv-cross)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Archivos fuente (excluir main_old.cpp)
|
||||
file(GLOB SOURCE_FILES source/*.cpp source/external/*.cpp source/boids_mgr/*.cpp source/gpu/*.cpp source/input/*.cpp source/scene/*.cpp source/shapes/*.cpp source/shapes_mgr/*.cpp source/state/*.cpp source/themes/*.cpp source/text/*.cpp source/ui/*.cpp)
|
||||
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_SOURCE_DIR}/source/main_old.cpp")
|
||||
@@ -138,6 +165,10 @@ if(NOT APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE AND TARGET data_shader_msls)
|
||||
add_dependencies(${PROJECT_NAME} data_shader_msls)
|
||||
endif()
|
||||
|
||||
# Tool: pack_resources
|
||||
add_executable(pack_resources tools/pack_resources.cpp source/resource_pack.cpp)
|
||||
target_include_directories(pack_resources PRIVATE ${CMAKE_SOURCE_DIR}/source)
|
||||
|
||||
Reference in New Issue
Block a user