Metal: Ensure baking to binary sets minimum target OS

Co-authored-by: Travis Lange <travislange12@gmail.com>
This commit is contained in:
Stuart Carnie 2025-09-05 10:05:29 +10:00
parent 6c9aa4c7d3
commit b7aac81366
14 changed files with 250 additions and 44 deletions

View file

@ -34,7 +34,7 @@
#include <windows.h>
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformD3D12::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) {
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformD3D12::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) {
if (lib_d3d12 == nullptr) {
lib_d3d12 = LoadLibraryW(L"D3D12.dll");
ERR_FAIL_NULL_V_MSG(lib_d3d12, nullptr, "Unable to load D3D12.dll.");

View file

@ -39,7 +39,7 @@ private:
void *lib_d3d12 = nullptr;
public:
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) override;
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) override;
virtual bool matches_driver(const String &p_driver) override;
virtual ~ShaderBakerExportPluginPlatformD3D12() override;
};

View file

@ -32,18 +32,22 @@
#include "drivers/metal/rendering_shader_container_metal.h"
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformMetal::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) {
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformMetal::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) {
const String &os_name = p_platform->get_os_name();
const MetalDeviceProfile *profile;
String min_os_version;
if (os_name == U"macOS") {
profile = MetalDeviceProfile::get_profile(MetalDeviceProfile::Platform::macOS, MetalDeviceProfile::GPU::Apple7);
// Godot metal doesn't support x86_64 mac so no need to worry about that version
min_os_version = p_preset->get("application/min_macos_version_arm64");
} else if (os_name == U"iOS") {
profile = MetalDeviceProfile::get_profile(MetalDeviceProfile::Platform::iOS, MetalDeviceProfile::GPU::Apple7);
min_os_version = p_preset->get("application/min_ios_version");
} else {
ERR_FAIL_V_MSG(nullptr, vformat("Unsupported platform: %s", os_name));
}
return memnew(RenderingShaderContainerFormatMetal(profile, true));
return memnew(RenderingShaderContainerFormatMetal(profile, true, min_os_version));
}
bool ShaderBakerExportPluginPlatformMetal::matches_driver(const String &p_driver) {

View file

@ -34,6 +34,6 @@
class ShaderBakerExportPluginPlatformMetal : public ShaderBakerExportPluginPlatform {
public:
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) override;
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) override;
virtual bool matches_driver(const String &p_driver) override;
};

View file

@ -32,7 +32,7 @@
#include "drivers/vulkan/rendering_shader_container_vulkan.h"
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformVulkan::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) {
RenderingShaderContainerFormat *ShaderBakerExportPluginPlatformVulkan::create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) {
return memnew(RenderingShaderContainerFormatVulkan);
}

View file

@ -36,6 +36,6 @@ class ShaderBakerExportPluginPlatformVulkan : public ShaderBakerExportPluginPlat
GDCLASS(ShaderBakerExportPluginPlatformVulkan, ShaderBakerExportPluginPlatform);
public:
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform) override;
virtual RenderingShaderContainerFormat *create_shader_container_format(const Ref<EditorExportPlatform> &p_platform, const Ref<EditorExportPreset> &p_preset) override;
virtual bool matches_driver(const String &p_driver) override;
};