mirror of
https://github.com/glfw/glfw.git
synced 2024-11-11 04:53:50 +00:00
Fail Vulkan surface creation if window has context
OpenGL / OpenGL ES cannot share presentation on a window with Vulkan. This adds an error to `glfwCreateWindowSurface` when it is called on a window without the GLFW_CLIENT_API hint set to GLFW_NO_API. This prevents undefined bahevior and hard to debug crashes. Fixes #1194. Closes #1205.
This commit is contained in:
parent
525ad7bfb8
commit
8a8eefa0d8
@ -178,6 +178,8 @@ information on what to include when reporting a bug.
|
|||||||
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
|
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
|
||||||
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
|
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
|
||||||
- Added `GenerateMappings.cmake` script for updating gamepad mappings
|
- Added `GenerateMappings.cmake` script for updating gamepad mappings
|
||||||
|
- Made `glfwCreateWindowSurface` emit an error when the window has a context
|
||||||
|
(#1194,#1205)
|
||||||
- Deprecated window parameter of clipboard string functions
|
- Deprecated window parameter of clipboard string functions
|
||||||
- Deprecated charmods callback
|
- Deprecated charmods callback
|
||||||
- Removed `GLFW_USE_RETINA` compile-time option
|
- Removed `GLFW_USE_RETINA` compile-time option
|
||||||
@ -442,6 +444,7 @@ skills.
|
|||||||
- Ricardo Vieira
|
- Ricardo Vieira
|
||||||
- Nicholas Vitovitch
|
- Nicholas Vitovitch
|
||||||
- Simon Voordouw
|
- Simon Voordouw
|
||||||
|
- Corentin Wallez
|
||||||
- Torsten Walluhn
|
- Torsten Walluhn
|
||||||
- Patrick Walton
|
- Patrick Walton
|
||||||
- Xo Wang
|
- Xo Wang
|
||||||
|
@ -230,6 +230,10 @@ if (err)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
If an OpenGL or OpenGL ES context was created on the window, the context has
|
||||||
|
ownership of the presentation on the window and a Vulkan surface cannot be
|
||||||
|
created.
|
||||||
|
|
||||||
It is your responsibility to destroy the surface. GLFW does not destroy it for
|
It is your responsibility to destroy the surface. GLFW does not destroy it for
|
||||||
you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it.
|
you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it.
|
||||||
|
|
||||||
|
@ -5441,6 +5441,11 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
|||||||
* glfwGetRequiredInstanceExtensions to check what instance extensions are
|
* glfwGetRequiredInstanceExtensions to check what instance extensions are
|
||||||
* required.
|
* required.
|
||||||
*
|
*
|
||||||
|
* The window surface cannot be shared with another API so the window must
|
||||||
|
* have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
|
||||||
|
* set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
|
||||||
|
* and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
|
||||||
|
*
|
||||||
* The window surface must be destroyed before the specified Vulkan instance.
|
* The window surface must be destroyed before the specified Vulkan instance.
|
||||||
* It is the responsibility of the caller to destroy the window surface. GLFW
|
* It is the responsibility of the caller to destroy the window surface. GLFW
|
||||||
* does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
|
* does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
|
||||||
@ -5456,7 +5461,7 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
|||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
* GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
|
||||||
*
|
*
|
||||||
* @remark If an error occurs before the creation call is made, GLFW returns
|
* @remark If an error occurs before the creation call is made, GLFW returns
|
||||||
* the Vulkan error code most appropriate for the error. Appropriate use of
|
* the Vulkan error code most appropriate for the error. Appropriate use of
|
||||||
|
@ -317,6 +317,13 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
|||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->context.client != GLFW_NO_API)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
"Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
|
||||||
|
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
|
||||||
|
}
|
||||||
|
|
||||||
return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
|
return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user