فهرست منبع

metal: set the shader input type based on the colorspace, not the pixel format

Fixes https://github.com/libsdl-org/SDL/issues/10402
Sam Lantinga 8 ماه پیش
والد
کامیت
9fac7d7eb0
1فایلهای تغییر یافته به همراه11 افزوده شده و 11 حذف شده
  1. 11 11
      src/render/metal/SDL_render_metal.m

+ 11 - 11
src/render/metal/SDL_render_metal.m

@@ -1348,29 +1348,29 @@ static void SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand
         case SDL_PIXELFORMAT_YV12:
         case SDL_PIXELFORMAT_IYUV:
             constants->texture_type = TEXTURETYPE_YUV;
-            constants->input_type = INPUTTYPE_SRGB;
             break;
         case SDL_PIXELFORMAT_NV12:
             constants->texture_type = TEXTURETYPE_NV12;
-            constants->input_type = INPUTTYPE_SRGB;
             break;
         case SDL_PIXELFORMAT_NV21:
             constants->texture_type = TEXTURETYPE_NV21;
-            constants->input_type = INPUTTYPE_SRGB;
             break;
         case SDL_PIXELFORMAT_P010:
             constants->texture_type = TEXTURETYPE_NV12;
-            constants->input_type = INPUTTYPE_HDR10;
             break;
         default:
             constants->texture_type = TEXTURETYPE_RGB;
-            if (texture->colorspace == SDL_COLORSPACE_SRGB_LINEAR) {
-                constants->input_type = INPUTTYPE_SCRGB;
-            } else if (texture->colorspace == SDL_COLORSPACE_HDR10) {
-                constants->input_type = INPUTTYPE_HDR10;
-            } else {
-                constants->input_type = INPUTTYPE_UNSPECIFIED;
-            }
+        }
+
+        switch (SDL_COLORSPACETRANSFER(texture->colorspace)) {
+        case SDL_TRANSFER_CHARACTERISTICS_LINEAR:
+            constants->input_type = INPUTTYPE_SCRGB;
+            break;
+        case SDL_TRANSFER_CHARACTERISTICS_PQ:
+            constants->input_type = INPUTTYPE_HDR10;
+            break;
+        default:
+            constants->input_type = INPUTTYPE_SRGB;
             break;
         }