Fix: Vulkan: Incorrect framebuffer size
When a file is loaded with a minimized window the VKFramebuffer can contain incorrect texture/data that result in a crash when maximizing the window. Pull Request: https://projects.blender.org/blender/blender/pulls/145171
This commit is contained in:
@@ -644,7 +644,9 @@ GHOST_TSuccess GHOST_ContextVK::swapBuffers()
|
||||
/* Wait for previous time that the frame was used to finish rendering. Presenting can
|
||||
* still happen in parallel, but acquiring needs can only happen when the frame acquire semaphore
|
||||
* has been signaled and waited for. */
|
||||
vkWaitForFences(device, 1, &submission_frame_data.submission_fence, true, UINT64_MAX);
|
||||
if (submission_frame_data.submission_fence) {
|
||||
vkWaitForFences(device, 1, &submission_frame_data.submission_fence, true, UINT64_MAX);
|
||||
}
|
||||
submission_frame_data.discard_pile.destroy(device);
|
||||
bool use_hdr_swapchain = true;
|
||||
#ifdef WITH_GHOST_WAYLAND
|
||||
@@ -1227,10 +1229,8 @@ const char *GHOST_ContextVK::getPlatformSpecificSurfaceExtension() const
|
||||
|
||||
GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
||||
{
|
||||
bool use_hdr_swapchain = false;
|
||||
#ifdef _WIN32
|
||||
const bool use_window_surface = (hwnd_ != nullptr);
|
||||
use_hdr_swapchain = true;
|
||||
#elif defined(__APPLE__)
|
||||
const bool use_window_surface = (metal_layer_ != nullptr);
|
||||
#else /* UNIX/Linux */
|
||||
@@ -1244,9 +1244,6 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
||||
# ifdef WITH_GHOST_WAYLAND
|
||||
case GHOST_kVulkanPlatformWayland:
|
||||
use_window_surface = (wayland_display_ != nullptr) && (wayland_surface_ != nullptr);
|
||||
if (wayland_window_info_) {
|
||||
use_hdr_swapchain = wayland_window_info_->is_color_managed;
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
case GHOST_kVulkanPlatformHeadless:
|
||||
@@ -1399,9 +1396,9 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
||||
vulkan_device->users++;
|
||||
vulkan_device->ensure_device(required_device_extensions, optional_device_extensions);
|
||||
|
||||
if (use_window_surface) {
|
||||
recreateSwapchain(use_hdr_swapchain);
|
||||
}
|
||||
render_extent_ = {0, 0};
|
||||
render_extent_min_ = {0, 0};
|
||||
surface_format_ = {VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
|
||||
|
||||
active_context_ = this;
|
||||
return GHOST_kSuccess;
|
||||
|
||||
@@ -85,8 +85,8 @@ void VKContext::sync_backbuffer(bool cycle_resource_pool)
|
||||
vk_extent_.height = max_uu(vk_extent_.height, 1u);
|
||||
surface_texture_ = GPU_texture_create_2d(
|
||||
"back-left",
|
||||
swap_chain_data.extent.width,
|
||||
swap_chain_data.extent.height,
|
||||
vk_extent_.width,
|
||||
vk_extent_.height,
|
||||
1,
|
||||
to_gpu_format(swap_chain_data.surface_format.format),
|
||||
GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
|
||||
@@ -100,6 +100,14 @@ void VKFrameBuffer::render_area_update(VkRect2D &render_area) const
|
||||
render_area.extent.width = width_;
|
||||
render_area.extent.height = height_;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
const VKDevice &device = VKBackend::get().device;
|
||||
BLI_assert(render_area.offset.x + render_area.extent.width <=
|
||||
device.physical_device_properties_get().limits.maxFramebufferWidth);
|
||||
BLI_assert(render_area.offset.y + render_area.extent.height <=
|
||||
device.physical_device_properties_get().limits.maxFramebufferHeight);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VKFrameBuffer::vk_render_areas_append(Vector<VkRect2D> &r_render_areas) const
|
||||
|
||||
Reference in New Issue
Block a user