Merge pull request #78550 from BastiaanOlij/fix_openxr_depth_buffer
Fix incorrect depth buffer option in OpenXR
This commit is contained in:
commit
1d41ce76ca
|
@ -233,9 +233,9 @@ void OpenXRVulkanExtension::get_usable_swapchain_formats(Vector<int64_t> &p_usab
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenXRVulkanExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) {
|
void OpenXRVulkanExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) {
|
||||||
p_usable_swap_chains.push_back(VK_FORMAT_R32_SFLOAT);
|
|
||||||
p_usable_swap_chains.push_back(VK_FORMAT_D24_UNORM_S8_UINT);
|
p_usable_swap_chains.push_back(VK_FORMAT_D24_UNORM_S8_UINT);
|
||||||
p_usable_swap_chains.push_back(VK_FORMAT_D32_SFLOAT_S8_UINT);
|
p_usable_swap_chains.push_back(VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||||
|
p_usable_swap_chains.push_back(VK_FORMAT_D32_SFLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
|
bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
|
||||||
|
@ -308,8 +308,8 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
||||||
format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UINT;
|
format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UINT;
|
||||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
break;
|
break;
|
||||||
case VK_FORMAT_R32_SFLOAT:
|
case VK_FORMAT_D32_SFLOAT:
|
||||||
format = RenderingDevice::DATA_FORMAT_R32_SFLOAT;
|
format = RenderingDevice::DATA_FORMAT_D32_SFLOAT;
|
||||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
break;
|
break;
|
||||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||||
|
|
|
@ -855,18 +855,19 @@ bool OpenXRAPI::create_swapchains() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swapchain_format_to_use == 0) {
|
if (swapchain_format_to_use == 0) {
|
||||||
swapchain_format_to_use = usable_swapchain_formats[0]; // just use the first one and hope for the best...
|
print_line("Couldn't find usable depth swap chain format, depth buffer will not be submitted.");
|
||||||
print_line("Couldn't find usable depth swap chain format, using", get_swapchain_format_name(swapchain_format_to_use), "instead.");
|
|
||||||
} else {
|
} else {
|
||||||
print_verbose(String("Using depth swap chain format:") + get_swapchain_format_name(swapchain_format_to_use));
|
print_verbose(String("Using depth swap chain format:") + get_swapchain_format_name(swapchain_format_to_use));
|
||||||
}
|
|
||||||
|
|
||||||
if (!create_swapchain(XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, swapchain_format_to_use, recommended_size.width, recommended_size.height, view_configuration_views[0].recommendedSwapchainSampleCount, view_count, swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain, &swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain_graphics_data)) {
|
// Note, if VK_FORMAT_D32_SFLOAT is used here but we're using the forward+ renderer, we should probably output a warning.
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
depth_views = (XrCompositionLayerDepthInfoKHR *)memalloc(sizeof(XrCompositionLayerDepthInfoKHR) * view_count);
|
if (!create_swapchain(XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, swapchain_format_to_use, recommended_size.width, recommended_size.height, view_configuration_views[0].recommendedSwapchainSampleCount, view_count, swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain, &swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain_graphics_data)) {
|
||||||
ERR_FAIL_NULL_V_MSG(depth_views, false, "OpenXR Couldn't allocate memory for depth views");
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
depth_views = (XrCompositionLayerDepthInfoKHR *)memalloc(sizeof(XrCompositionLayerDepthInfoKHR) * view_count);
|
||||||
|
ERR_FAIL_NULL_V_MSG(depth_views, false, "OpenXR Couldn't allocate memory for depth views");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We create our velocity swapchain if:
|
// We create our velocity swapchain if:
|
||||||
|
@ -1837,6 +1838,7 @@ RID OpenXRAPI::get_color_texture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
RID OpenXRAPI::get_depth_texture() {
|
RID OpenXRAPI::get_depth_texture() {
|
||||||
|
// Note, image will not be acquired if we didn't have a suitable swap chain format.
|
||||||
if (submit_depth_buffer && swapchains[OPENXR_SWAPCHAIN_DEPTH].image_acquired) {
|
if (submit_depth_buffer && swapchains[OPENXR_SWAPCHAIN_DEPTH].image_acquired) {
|
||||||
return graphics_extension->get_texture(swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain_graphics_data, swapchains[OPENXR_SWAPCHAIN_DEPTH].image_index);
|
return graphics_extension->get_texture(swapchains[OPENXR_SWAPCHAIN_DEPTH].swapchain_graphics_data, swapchains[OPENXR_SWAPCHAIN_DEPTH].image_index);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue