Browse Source

Fixed Xcode warnings

Sam Lantinga 7 months ago
parent
commit
481203c074

+ 36 - 14
src/gpu/metal/SDL_gpu_metal.m

@@ -1198,8 +1198,10 @@ static void METAL_InsertDebugLabel(
             [metalCommandBuffer->computeEncoder insertDebugSignpost:label];
         } else {
             // Metal doesn't have insertDebugSignpost for command buffers...
-            [metalCommandBuffer->handle pushDebugGroup:label];
-            [metalCommandBuffer->handle popDebugGroup];
+            if (@available(macOS 10.13, *)) {
+                [metalCommandBuffer->handle pushDebugGroup:label];
+                [metalCommandBuffer->handle popDebugGroup];
+            }
         }
     }
 }
@@ -1219,7 +1221,9 @@ static void METAL_PushDebugGroup(
         } else if (metalCommandBuffer->computeEncoder) {
             [metalCommandBuffer->computeEncoder pushDebugGroup:label];
         } else {
-            [metalCommandBuffer->handle pushDebugGroup:label];
+            if (@available(macOS 10.13, *)) {
+                [metalCommandBuffer->handle pushDebugGroup:label];
+            }
         }
     }
 }
@@ -1237,7 +1241,9 @@ static void METAL_PopDebugGroup(
         } else if (metalCommandBuffer->computeEncoder) {
             [metalCommandBuffer->computeEncoder popDebugGroup];
         } else {
-            [metalCommandBuffer->handle popDebugGroup];
+            if (@available(macOS 10.13, *)) {
+                [metalCommandBuffer->handle popDebugGroup];
+            }
         }
     }
 }
@@ -1321,11 +1327,15 @@ static MetalTexture *METAL_INTERNAL_CreateTexture(
     textureDescriptor.pixelFormat = SDLToMetal_SurfaceFormat[createinfo->format];
     // This format isn't natively supported so let's swizzle!
     if (createinfo->format == SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM) {
-        textureDescriptor.swizzle = MTLTextureSwizzleChannelsMake(
-            MTLTextureSwizzleBlue,
-            MTLTextureSwizzleGreen,
-            MTLTextureSwizzleRed,
-            MTLTextureSwizzleAlpha);
+        if (@available(macOS 10.15, *)) {
+            textureDescriptor.swizzle = MTLTextureSwizzleChannelsMake(MTLTextureSwizzleBlue,
+                                                                      MTLTextureSwizzleGreen,
+                                                                      MTLTextureSwizzleRed,
+                                                                      MTLTextureSwizzleAlpha);
+        } else {
+            SDL_SetError("SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM is not supported");
+            return NULL;
+        }
     }
 
     textureDescriptor.width = createinfo->width;
@@ -3409,7 +3419,9 @@ static Uint8 METAL_INTERNAL_CreateSwapchain(
     windowData->layer = (__bridge CAMetalLayer *)(SDL_Metal_GetLayer(windowData->view));
     windowData->layer.device = renderer->device;
 #ifdef SDL_PLATFORM_MACOS
-    windowData->layer.displaySyncEnabled = (presentMode != SDL_GPU_PRESENTMODE_IMMEDIATE);
+    if (@available(macOS 10.13, *)) {
+        windowData->layer.displaySyncEnabled = (presentMode != SDL_GPU_PRESENTMODE_IMMEDIATE);
+    }
 #endif
     windowData->layer.pixelFormat = SDLToMetal_SurfaceFormat[SwapchainCompositionToFormat[swapchainComposition]];
 #ifndef SDL_PLATFORM_TVOS
@@ -3632,7 +3644,9 @@ static bool METAL_SetSwapchainParameters(
         METAL_Wait(driverData);
 
 #ifdef SDL_PLATFORM_MACOS
-        windowData->layer.displaySyncEnabled = (presentMode != SDL_GPU_PRESENTMODE_IMMEDIATE);
+        if (@available(macOS 10.13, *)) {
+            windowData->layer.displaySyncEnabled = (presentMode != SDL_GPU_PRESENTMODE_IMMEDIATE);
+        }
 #endif
         windowData->layer.pixelFormat = SDLToMetal_SurfaceFormat[SwapchainCompositionToFormat[swapchainComposition]];
 #ifndef SDL_PLATFORM_TVOS
@@ -3763,8 +3777,12 @@ static bool METAL_SupportsTextureFormat(
 
         // Cube arrays are not supported on older iOS devices
         if (type == SDL_GPU_TEXTURETYPE_CUBE_ARRAY) {
-            if (!([renderer->device supportsFamily:MTLGPUFamilyCommon2] ||
-                  [renderer->device supportsFamily:MTLGPUFamilyApple4])) {
+            if (@available(macOS 10.15, *)) {
+                if (!([renderer->device supportsFamily:MTLGPUFamilyCommon2] ||
+                      [renderer->device supportsFamily:MTLGPUFamilyApple4])) {
+                    return false;
+                }
+            } else {
                 return false;
             }
         }
@@ -3774,7 +3792,11 @@ static bool METAL_SupportsTextureFormat(
         case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM:
         case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM:
         case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM:
-            return [renderer->device supportsFamily:MTLGPUFamilyApple1];
+                if (@available(macOS 10.15, *)) {
+                    return [renderer->device supportsFamily:MTLGPUFamilyApple1];
+                } else {
+                    return false;
+                }
 
         // Requires BC compression support
         case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:

+ 1 - 1
src/hidapi/mac/hid.c

@@ -1572,7 +1572,7 @@ int HID_API_EXPORT_CALL hid_get_report_descriptor(hid_device *dev, unsigned char
 		}
 
 		memcpy(buf, descriptor_buf, copy_len);
-		return copy_len;
+		return (int)copy_len;
 	}
 	else {
 		register_device_error(dev, "Failed to get kIOHIDReportDescriptorKey property");

+ 1 - 1
src/process/posix/SDL_posixprocess.c

@@ -143,7 +143,7 @@ static bool AddFileDescriptorCloseActions(posix_spawn_file_actions_t *fa)
         }
         closedir(dir);
     } else {
-        for (int fd = sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; --fd) {
+        for (int fd = (int)(sysconf(_SC_OPEN_MAX) - 1); fd > STDERR_FILENO; --fd) {
             int flags = fcntl(fd, F_GETFD);
             if (flags < 0 || (flags & FD_CLOEXEC)) {
                 continue;

+ 1 - 1
src/video/cocoa/SDL_cocoapen.m

@@ -115,7 +115,7 @@ static void Cocoa_HandlePenProximityEvent(SDL_CocoaWindowData *_data, NSEvent *e
 
 static void Cocoa_HandlePenPointEvent(SDL_CocoaWindowData *_data, NSEvent *event)
 {
-    const Uint32 timestamp = Cocoa_GetEventTimestamp([event timestamp]);
+    const Uint64 timestamp = Cocoa_GetEventTimestamp([event timestamp]);
     Cocoa_PenHandle *handle = Cocoa_FindPenByDeviceID([event deviceID], [event pointingDeviceID]);
     if (!handle) {
         return;

+ 5 - 5
src/video/uikit/SDL_uikitviewcontroller.m

@@ -404,7 +404,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         break;
     case SDL_TEXTINPUT_TYPE_TEXT_USERNAME:
         textField.keyboardType = UIKeyboardTypeDefault;
-        if (@available(iOS 11.0, *)) {
+        if (@available(iOS 11.0, tvOS 11.0, *)) {
             textField.textContentType = UITextContentTypeUsername;
         } else {
             textField.textContentType = nil;
@@ -412,7 +412,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         break;
     case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN:
         textField.keyboardType = UIKeyboardTypeDefault;
-        if (@available(iOS 11.0, *)) {
+        if (@available(iOS 11.0, tvOS 11.0, *)) {
             textField.textContentType = UITextContentTypePassword;
         } else {
             textField.textContentType = nil;
@@ -421,7 +421,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         break;
     case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE:
         textField.keyboardType = UIKeyboardTypeDefault;
-        if (@available(iOS 11.0, *)) {
+        if (@available(iOS 11.0, tvOS 11.0, *)) {
             textField.textContentType = UITextContentTypePassword;
         } else {
             textField.textContentType = nil;
@@ -433,7 +433,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         break;
     case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN:
         textField.keyboardType = UIKeyboardTypeNumberPad;
-        if (@available(iOS 12.0, *)) {
+        if (@available(iOS 12.0, tvOS 12.0, *)) {
             textField.textContentType = UITextContentTypeOneTimeCode;
         } else {
             textField.textContentType = nil;
@@ -442,7 +442,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
         break;
     case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE:
         textField.keyboardType = UIKeyboardTypeNumberPad;
-        if (@available(iOS 12.0, *)) {
+        if (@available(iOS 12.0, tvOS 12.0, *)) {
             textField.textContentType = UITextContentTypeOneTimeCode;
         } else {
             textField.textContentType = nil;