4 Commits ab19d09939 ... 04d8a654d8

Tác giả SHA1 Thông báo Ngày
  Frank Praznik 04d8a654d8 wayland: Ensure the viewport size is always non-zero 4 ngày trước cách đây
  Frank Praznik ba3577f584 wayland: Ensure window dimensions are greater than zero after adjusting for aspect 5 ngày trước cách đây
  cosmonaut c8feb29746 GPU: Clarify VK_KHR_maintenance9 comment 4 ngày trước cách đây
  Susko3 2949a0d6d5 Enable text editing events in checkkeys 4 ngày trước cách đây
3 tập tin đã thay đổi với 25 bổ sung17 xóa
  1. 4 2
      src/gpu/vulkan/SDL_gpu_vulkan.c
  2. 18 15
      src/video/wayland/SDL_waylandwindow.c
  3. 3 0
      test/checkkeys.c

+ 4 - 2
src/gpu/vulkan/SDL_gpu_vulkan.c

@@ -2744,8 +2744,10 @@ static void VULKAN_INTERNAL_TextureSubresourceMemoryBarrier(
     memoryBarrier.subresourceRange.baseArrayLayer = textureSubresource->layer;
     memoryBarrier.subresourceRange.layerCount = 1;
 
-    // VK_KHR_maintenance9 adds the ability to independently transition arbitrary subsets of slices in a 3D texture,
-    // we need to extend the barrier layer count in order to preserve intended behaviour when that extension is enabled.
+    // VK_KHR_maintenance9 adds the ability to independently transition arbitrary subsets of slices in a 3D texture
+    // but otherwise it is not necessarily supported by the driver.
+    // As a workaround we have to transition the whole texture instead of just the subresource.
+    // If VK_KHR_maintenance9 becomes widely supported, this can be removed.
     // See https://docs.vulkan.org/features/latest/features/proposals/VK_KHR_maintenance9.html#_barriers_with_2d_array_compatible_3d_images
     if (textureSubresource->parent->container->header.info.type == SDL_GPU_TEXTURETYPE_3D) {
         memoryBarrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;

+ 18 - 15
src/video/wayland/SDL_waylandwindow.c

@@ -397,26 +397,26 @@ static void ConfigureWindowGeometry(SDL_Window *window)
 
         if (data->viewport && data->waylandData->subcompositor && !data->is_fullscreen) {
             if (window->min_w) {
-                window_width = viewport_width = SDL_max(viewport_width, window->min_w);
+                viewport_width = SDL_max(viewport_width, window->min_w);
             }
             if (window->min_h) {
-                window_height = viewport_height = SDL_max(viewport_height, window->min_h);
+                viewport_height = SDL_max(viewport_height, window->min_h);
             }
             if (window->max_w) {
-                window_width = viewport_width = SDL_min(viewport_width, window->max_w);
+                viewport_width = SDL_min(viewport_width, window->max_w);
             }
             if (window->max_h) {
-                window_height = viewport_height = SDL_min(viewport_height, window->max_h);
+                viewport_height = SDL_min(viewport_height, window->max_h);
             }
 
             float aspect = (float)viewport_width / (float)viewport_height;
             if (window->min_aspect != 0.f && aspect < window->min_aspect) {
-                viewport_height = SDL_lroundf((float)viewport_width / window->min_aspect);
+                viewport_height = SDL_max(SDL_lroundf((float)viewport_width / window->min_aspect), 1);
             } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
-                viewport_width = SDL_lroundf((float)viewport_height * window->max_aspect);
+                viewport_width = SDL_max(SDL_lroundf((float)viewport_height * window->max_aspect), 1);
             }
 
-            // At this point, the viewport matches the window dimensions, but the viewport might be clamped to window dimensions beyond here.
+            // At this point, the viewport matches the virtual window dimensions, but the viewport might be clamped to the output window dimensions beyond here.
             window_width = viewport_width;
             window_height = viewport_height;
 
@@ -446,6 +446,9 @@ static void ConfigureWindowGeometry(SDL_Window *window)
                     }
                 }
             }
+
+            viewport_width = SDL_max(viewport_width, 1);
+            viewport_height = SDL_max(viewport_height, 1);
         } else {
             window_width = viewport_width;
             window_height = viewport_height;
@@ -1107,9 +1110,9 @@ static void handle_xdg_toplevel_configure(void *data,
                 const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
 
                 if (window->min_aspect != 0.f && aspect < window->min_aspect) {
-                    wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
+                    wind->requested.logical_height = SDL_max(SDL_lroundf((float)wind->requested.logical_width / window->min_aspect), 1);
                 } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
-                    wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
+                    wind->requested.logical_width = SDL_max(SDL_lroundf((float)wind->requested.logical_height * window->max_aspect), 1);
                 }
             } else {
                 if (window->max_w > 0) {
@@ -1126,9 +1129,9 @@ static void handle_xdg_toplevel_configure(void *data,
                 const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
 
                 if (window->min_aspect != 0.f && aspect < window->min_aspect) {
-                    wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
+                    wind->requested.pixel_height = SDL_max(SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect), 1);
                 } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
-                    wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
+                    wind->requested.pixel_width = SDL_max(SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect), 1);
                 }
 
                 wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);
@@ -1594,9 +1597,9 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
                 const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
 
                 if (window->min_aspect != 0.f && aspect < window->min_aspect) {
-                    wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
+                    wind->requested.logical_height = SDL_max(SDL_lroundf((float)wind->requested.logical_width / window->min_aspect), 1);
                 } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
-                    wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
+                    wind->requested.logical_width = SDL_max(SDL_lroundf((float)wind->requested.logical_height * window->max_aspect), 1);
                 }
             } else {
                 if (window->max_w > 0) {
@@ -1613,9 +1616,9 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
                 const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
 
                 if (window->min_aspect != 0.f && aspect < window->min_aspect) {
-                    wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
+                    wind->requested.pixel_height = SDL_max(SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect), 1);
                 } else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
-                    wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
+                    wind->requested.pixel_width = SDL_max(SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect), 1);
                 }
 
                 wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);

+ 3 - 0
test/checkkeys.c

@@ -467,6 +467,9 @@ int main(int argc, char *argv[])
     /* Disable mouse emulation */
     SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
 
+    /* Enable text editing events and tell SDL that we'll handle rendering compositions. */
+    SDL_SetHint(SDL_HINT_IME_IMPLEMENTED_UI, "composition");
+
     /* Initialize SDL */
     if (!SDLTest_CommonInit(state)) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());