Skip to content

Commit

Permalink
layer: Move strict -> ensure
Browse files Browse the repository at this point in the history
Matches Mesa behaviour, I'm a bit scared of breaking other broken games with this sweeping change.
  • Loading branch information
misyltoad committed Dec 9, 2024
1 parent 91f9755 commit 6330a32
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions layer/VkLayer_FROG_gamescope_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ namespace GamescopeWSILayer {
return s_minImageCount;
}

static bool getStrictImageCount() {
static bool s_strictImageCount = []() -> bool {
if (auto strict = parseEnv<bool>("GAMESCOPE_WSI_STRICT_IMAGE_COUNT")) {
return *strict;
static bool getEnsureMinImageCount() {
static bool s_ensureMinImageCount = []() -> bool {
if (auto ensure = parseEnv<bool>("GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT")) {
return *ensure;
}
if (auto strict = parseEnv<bool>("vk_x11_strict_image_count")) {
return *strict;
if (auto ensure = parseEnv<bool>("vk_x11_ensure_min_image_count")) {
return *ensure;
}
return false;
}();
return s_strictImageCount;
return s_ensureMinImageCount;
}

// Taken from Mesa, licensed under MIT.
Expand Down Expand Up @@ -1146,15 +1146,15 @@ namespace GamescopeWSILayer {
// We always send MAILBOX to the driver.
swapchainInfo.presentMode = VK_PRESENT_MODE_MAILBOX_KHR;

uint32_t imageCount = swapchainInfo.minImageCount;
if (!getStrictImageCount())
imageCount = std::max(getMinImageCount(), imageCount);
swapchainInfo.minImageCount = imageCount;
uint32_t minImageCount = swapchainInfo.minImageCount;
if (getEnsureMinImageCount())
minImageCount = std::max(getMinImageCount(), minImageCount);
swapchainInfo.minImageCount = minImageCount;

fprintf(stderr, "[Gamescope WSI] Creating swapchain for xid: 0x%0x - provided minImageCount: %u - imageCount: %u - format: %s - colorspace: %s - flip: %s\n",
fprintf(stderr, "[Gamescope WSI] Creating swapchain for xid: 0x%0x - provided minImageCount: %u - minImageCount: %u - format: %s - colorspace: %s - flip: %s\n",
gamescopeSurface->window,
pCreateInfo->minImageCount,
imageCount,
minImageCount,
vkroots::helpers::enumString(pCreateInfo->imageFormat),
vkroots::helpers::enumString(pCreateInfo->imageColorSpace),
canBypass ? "true" : "false");
Expand Down

0 comments on commit 6330a32

Please sign in to comment.