Skip to content

Commit

Permalink
Fix full screen mode playback issue
Browse files Browse the repository at this point in the history
For some trace files captured on some title full screen mode, playback may
fail because the call to vkAcquireFullScreenExclusiveModeEXT failed. The
change fixes the issue.
  • Loading branch information
mizhen committed Apr 16, 2024
1 parent 656e8fd commit 78866db
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
12 changes: 11 additions & 1 deletion framework/application/win32_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool Win32Window::Create(const std::string& title,
int32_t x = xpos;
int32_t y = ypos;
fullscreen_ = false;
force_windowed_ = force_windowed;

if ((screen_height_ <= ypos) || (screen_width_ <= xpos))
{
Expand Down Expand Up @@ -213,9 +214,18 @@ void Win32Window::SetSize(const uint32_t width, const uint32_t height)
screen_height_);
}

uint32_t swp_flags = SWP_NOMOVE | SWP_NOZORDER;
uint32_t swp_flags = SWP_NOMOVE | SWP_NOZORDER;

uint32_t current_window_style = GetWindowLong(hwnd_, GWL_STYLE);
uint32_t window_style = fullscreen_ ? (WS_VISIBLE | kFullscreenStyle) : (WS_VISIBLE | kWindowedStyle);

if (((current_window_style & kFullscreenStyle) != kFullscreenStyle) && (force_windowed_ == false))
{
window_style = WS_VISIBLE | kFullscreenStyle;
SetWindowLong(hwnd_, GWL_STYLE, window_style);
swp_flags |= SWP_FRAMECHANGED;
}

AdjustWindowRect(&wr, window_style, FALSE);

// Keep window current position when resizing.
Expand Down
1 change: 1 addition & 0 deletions framework/application/win32_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Win32Window : public decode::Window
uint32_t screen_height_;
bool fullscreen_;
HINSTANCE hinstance_;
bool force_windowed_;
};

class Win32WindowFactory : public decode::WindowFactory
Expand Down
6 changes: 4 additions & 2 deletions framework/decode/vulkan_virtual_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,9 @@ VkResult VulkanVirtualSwapchain::AcquireNextImageKHR(VkResult o
}

result = func(device, swapchain, timeout, semaphore, fence, image_index);
if (result != VK_SUCCESS)
if ((result != VK_SUCCESS) && (result != VK_SUBOPTIMAL_KHR))
{
// TODO: Add some handling of optimization with VK_SUBOPTIMAL_KHR.
GFXRECON_LOG_ERROR("Virtual swapchain failed AcquireNextImageKHR 0x%08x for swapchain (ID = %" PRIu64 ")",
result,
swapchain_info->capture_id);
Expand All @@ -640,8 +641,9 @@ VkResult VulkanVirtualSwapchain::AcquireNextImage2KHR(VkResult
}

VkResult result = func(device, acquire_info, image_index);
if (result != VK_SUCCESS)
if ((result != VK_SUCCESS) && (result != VK_SUBOPTIMAL_KHR))
{
// TODO: Add some handling of optimization with VK_SUBOPTIMAL_KHR.
GFXRECON_LOG_ERROR("Virtual swapchain failed AcquireNextImage2KHR 0x%08x for swapchain (ID = %" PRIu64 ")",
result,
swapchain_info->capture_id);
Expand Down
4 changes: 2 additions & 2 deletions framework/generated/generated_vulkan_replay_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7267,9 +7267,9 @@ void VulkanReplayConsumer::Process_vkAcquireFullScreenExclusiveModeEXT(
format::HandleId device,
format::HandleId swapchain)
{
if (options_.swapchain_option == util::SwapchainOption::kOffscreen)
if ((options_.swapchain_option == util::SwapchainOption::kOffscreen) || (options_.force_windowed_origin == true) || (options_.force_windowed == true))
{
GFXRECON_LOG_DEBUG("Skip vkAcquireFullScreenExclusiveModeEXT for offscreen.");
GFXRECON_LOG_DEBUG("Skip vkAcquireFullScreenExclusiveModeEXT for offscreen or force windowed mode.");
return;
}
VkDevice in_device = MapHandle<DeviceInfo>(device, &VulkanObjectInfoTable::GetDeviceInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,15 @@ def make_consumer_func_body(self, return_type, name, values):
for value in values:
for key in self.SKIP_FUNCTIONS_OFFSCREEN:
if self.is_has_specific_key_word_in_type(value, key):
body += ' if (options_.swapchain_option == util::SwapchainOption::kOffscreen)\n'
if name == 'vkAcquireFullScreenExclusiveModeEXT':
body += ' if ((options_.swapchain_option == util::SwapchainOption::kOffscreen) || (options_.force_windowed_origin == true) || (options_.force_windowed == true))\n'
else:
body += ' if (options_.swapchain_option == util::SwapchainOption::kOffscreen)\n'
body += ' {\n'
body += ' GFXRECON_LOG_DEBUG("Skip ' + name + ' for offscreen.");\n'
if name == 'vkAcquireFullScreenExclusiveModeEXT':
body += ' GFXRECON_LOG_DEBUG("Skip ' + name + ' for offscreen or force windowed mode.");\n'
else:
body += ' GFXRECON_LOG_DEBUG("Skip ' + name + ' for offscreen.");\n'
body += ' return;\n'
body += ' }\n'
is_print = True
Expand Down

0 comments on commit 78866db

Please sign in to comment.