Vulkan: Make GatherSurfaceInfo use ResultOrError
Bug: dawn:269 Change-Id: I80ac5ce170b2e7630d8524cd34375bf0f1c67a60 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17961 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
97ec825cde
commit
a44221d05b
|
@ -83,8 +83,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeSwapChainImpl::UpdateSurfaceConfig() {
|
void NativeSwapChainImpl::UpdateSurfaceConfig() {
|
||||||
if (mDevice->ConsumedError(
|
if (mDevice->ConsumedError(GatherSurfaceInfo(*ToBackend(mDevice->GetAdapter()), mSurface),
|
||||||
GatherSurfaceInfo(*ToBackend(mDevice->GetAdapter()), mSurface, &mInfo))) {
|
&mInfo)) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,21 +324,22 @@ namespace dawn_native { namespace vulkan {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError GatherSurfaceInfo(const Adapter& adapter,
|
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter,
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface) {
|
||||||
VulkanSurfaceInfo* info) {
|
VulkanSurfaceInfo info = {};
|
||||||
|
|
||||||
VkPhysicalDevice physicalDevice = adapter.GetPhysicalDevice();
|
VkPhysicalDevice physicalDevice = adapter.GetPhysicalDevice();
|
||||||
const VulkanFunctions& vkFunctions = adapter.GetBackend()->GetFunctions();
|
const VulkanFunctions& vkFunctions = adapter.GetBackend()->GetFunctions();
|
||||||
|
|
||||||
// Get the surface capabilities
|
// Get the surface capabilities
|
||||||
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceCapabilitiesKHR(
|
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||||
physicalDevice, surface, &info->capabilities),
|
physicalDevice, surface, &info.capabilities),
|
||||||
"vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
|
"vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
|
||||||
|
|
||||||
// Query which queue families support presenting this surface
|
// Query which queue families support presenting this surface
|
||||||
{
|
{
|
||||||
size_t nQueueFamilies = adapter.GetDeviceInfo().queueFamilies.size();
|
size_t nQueueFamilies = adapter.GetDeviceInfo().queueFamilies.size();
|
||||||
info->supportedQueueFamilies.resize(nQueueFamilies, false);
|
info.supportedQueueFamilies.resize(nQueueFamilies, false);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < nQueueFamilies; ++i) {
|
for (uint32_t i = 0; i < nQueueFamilies; ++i) {
|
||||||
VkBool32 supported = VK_FALSE;
|
VkBool32 supported = VK_FALSE;
|
||||||
|
@ -346,7 +347,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
physicalDevice, i, surface, &supported),
|
physicalDevice, i, surface, &supported),
|
||||||
"vkGetPhysicalDeviceSurfaceSupportKHR"));
|
"vkGetPhysicalDeviceSurfaceSupportKHR"));
|
||||||
|
|
||||||
info->supportedQueueFamilies[i] = (supported == VK_TRUE);
|
info.supportedQueueFamilies[i] = (supported == VK_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,9 +360,9 @@ namespace dawn_native { namespace vulkan {
|
||||||
return DAWN_DEVICE_LOST_ERROR("vkGetPhysicalDeviceSurfaceFormatsKHR");
|
return DAWN_DEVICE_LOST_ERROR("vkGetPhysicalDeviceSurfaceFormatsKHR");
|
||||||
}
|
}
|
||||||
|
|
||||||
info->formats.resize(count);
|
info.formats.resize(count);
|
||||||
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceFormatsKHR(
|
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceFormatsKHR(
|
||||||
physicalDevice, surface, &count, info->formats.data()),
|
physicalDevice, surface, &count, info.formats.data()),
|
||||||
"vkGetPhysicalDeviceSurfaceFormatsKHR"));
|
"vkGetPhysicalDeviceSurfaceFormatsKHR"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,13 +376,13 @@ namespace dawn_native { namespace vulkan {
|
||||||
return DAWN_DEVICE_LOST_ERROR("vkGetPhysicalDeviceSurfacePresentModesKHR");
|
return DAWN_DEVICE_LOST_ERROR("vkGetPhysicalDeviceSurfacePresentModesKHR");
|
||||||
}
|
}
|
||||||
|
|
||||||
info->presentModes.resize(count);
|
info.presentModes.resize(count);
|
||||||
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfacePresentModesKHR(
|
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfacePresentModesKHR(
|
||||||
physicalDevice, surface, &count, info->presentModes.data()),
|
physicalDevice, surface, &count, info.presentModes.data()),
|
||||||
"vkGetPhysicalDeviceSurfacePresentModesKHR"));
|
"vkGetPhysicalDeviceSurfacePresentModesKHR"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace dawn_native::vulkan
|
}} // namespace dawn_native::vulkan
|
||||||
|
|
|
@ -122,9 +122,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const Backend& backend);
|
ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const Backend& backend);
|
||||||
ResultOrError<std::vector<VkPhysicalDevice>> GetPhysicalDevices(const Backend& backend);
|
ResultOrError<std::vector<VkPhysicalDevice>> GetPhysicalDevices(const Backend& backend);
|
||||||
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter);
|
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter);
|
||||||
MaybeError GatherSurfaceInfo(const Adapter& adapter,
|
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter,
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface);
|
||||||
VulkanSurfaceInfo* info);
|
|
||||||
}} // namespace dawn_native::vulkan
|
}} // namespace dawn_native::vulkan
|
||||||
|
|
||||||
#endif // DAWNNATIVE_VULKAN_VULKANINFO_H_
|
#endif // DAWNNATIVE_VULKAN_VULKANINFO_H_
|
||||||
|
|
Loading…
Reference in New Issue