Skip to content

Commit

Permalink
layer: Fix 32-bit layer crash
Browse files Browse the repository at this point in the history
Some fprintf pointers added in "layer: Fix oldSwapchain when going in/out
of XWayland bypassing" will crash when executed in the 32-bit WSI layer.

GCC also warns about the pointer usage with:

```
 1085 |       fprintf(stderr, "[Gamescope WSI] Destroying swapchain: %p\n", swapchain);
      |                                                              ~^     ~~~~~~~~~
      |                                                               |     |
      |                                                               void* VkSwapchainKHR {aka long long unsigned int}
      |                                                              %lld

 1087 |       fprintf(stderr, "[Gamescope WSI] Destroyed swapchain: %p\n", swapchain);
      |                                                             ~^     ~~~~~~~~~
      |                                                              |     |
      |                                                              void* VkSwapchainKHR {aka long long unsigned int}
      |                                                             %lld

 1167 |       fprintf(stderr, "[Gamescope WSI] Creating swapchain for xid: 0x%0x - oldSwapchain: %p - provided minImageCount: %u - minImageCount: %u - format: %s - colorspace: %s - flip: %s\n",
      |                                                                                          ~^
      |                                                                                           |
      |                                                                                           void*
      |                                                                                          %lld
 1168 |         gamescopeSurface->window,
 1169 |         pCreateInfo->oldSwapchain,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      long long unsigned int

 1248 |       fprintf(stderr, "[Gamescope WSI] Created swapchain for xid: 0x%0x swapchain: %p - imageCount: %u\n",
      |                                                                                    ~^
      |                                                                                     |
      |                                                                                     void*
      |                                                                                    %lld
 1249 |         gamescopeSurface->window,
 1250 |         *pSwapchain,
      |         ~~~~~~~~~~~
      |         |
      |         VkSwapchainKHR {aka long long unsigned int}
```

To keep it simple, let's just cast the problematic pointers to void*.

Closes:  ValveSoftware#1718
Closes:  ValveSoftware#1736
  • Loading branch information
matte-schwartz committed Feb 1, 2025
1 parent ef1e8db commit 499811e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions layer/VkLayer_FROG_gamescope_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ namespace GamescopeWSILayer {
gamescope_swapchain_destroy(state->object);
}
GamescopeSwapchain::remove(swapchain);
fprintf(stderr, "[Gamescope WSI] Destroying swapchain: %p\n", swapchain);
fprintf(stderr, "[Gamescope WSI] Destroying swapchain: %p\n", (void*)swapchain);
pDispatch->DestroySwapchainKHR(device, swapchain, pAllocator);
fprintf(stderr, "[Gamescope WSI] Destroyed swapchain: %p\n", swapchain);
fprintf(stderr, "[Gamescope WSI] Destroyed swapchain: %p\n", (void*)swapchain);
}

static VkResult CreateSwapchainKHR(
Expand Down Expand Up @@ -1166,7 +1166,7 @@ namespace GamescopeWSILayer {

fprintf(stderr, "[Gamescope WSI] Creating swapchain for xid: 0x%0x - oldSwapchain: %p - provided minImageCount: %u - minImageCount: %u - format: %s - colorspace: %s - flip: %s\n",
gamescopeSurface->window,
pCreateInfo->oldSwapchain,
(void*)pCreateInfo->oldSwapchain,
pCreateInfo->minImageCount,
minImageCount,
vkroots::helpers::enumString(pCreateInfo->imageFormat),
Expand Down Expand Up @@ -1247,7 +1247,7 @@ namespace GamescopeWSILayer {

fprintf(stderr, "[Gamescope WSI] Created swapchain for xid: 0x%0x swapchain: %p - imageCount: %u\n",
gamescopeSurface->window,
*pSwapchain,
(void*)*pSwapchain,
imageCount);

gamescope_swapchain_swapchain_feedback(
Expand Down

0 comments on commit 499811e

Please sign in to comment.