vk: Optionally ignore depth bounds testing on hardware that does not

support it.
This commit is contained in:
kd-11 2019-10-29 00:07:38 +03:00 committed by kd-11
parent 7a5c20ef85
commit eda09489b2
3 changed files with 56 additions and 15 deletions

View file

@ -973,14 +973,17 @@ void VKGSRender::update_draw_state()
} }
} }
if (rsx::method_registers.depth_bounds_test_enabled()) if (m_device->get_depth_bounds_support())
{ {
//Update depth bounds min/max if (rsx::method_registers.depth_bounds_test_enabled())
vkCmdSetDepthBounds(*m_current_command_buffer, rsx::method_registers.depth_bounds_min(), rsx::method_registers.depth_bounds_max()); {
} //Update depth bounds min/max
else vkCmdSetDepthBounds(*m_current_command_buffer, rsx::method_registers.depth_bounds_min(), rsx::method_registers.depth_bounds_max());
{ }
vkCmdSetDepthBounds(*m_current_command_buffer, 0.f, 1.f); else
{
vkCmdSetDepthBounds(*m_current_command_buffer, 0.f, 1.f);
}
} }
bind_viewport(); bind_viewport();
@ -2480,7 +2483,7 @@ bool VKGSRender::load_program()
properties.state.set_front_face(vk::get_front_face(rsx::method_registers.front_face_mode())); properties.state.set_front_face(vk::get_front_face(rsx::method_registers.front_face_mode()));
properties.state.enable_depth_clamp(rsx::method_registers.depth_clamp_enabled() || !rsx::method_registers.depth_clip_enabled()); properties.state.enable_depth_clamp(rsx::method_registers.depth_clamp_enabled() || !rsx::method_registers.depth_clip_enabled());
properties.state.enable_depth_bias(true); properties.state.enable_depth_bias(true);
properties.state.enable_depth_bounds_test(true); properties.state.enable_depth_bounds_test(m_device->get_depth_bounds_support());
if (rsx::method_registers.depth_test_enabled()) if (rsx::method_registers.depth_test_enabled())
{ {

View file

@ -770,16 +770,44 @@ private:
// 1. Anisotropic sampling // 1. Anisotropic sampling
// 2. DXT support // 2. DXT support
// 3. Indexable storage buffers // 3. Indexable storage buffers
VkPhysicalDeviceFeatures available_features = pgpu->features; VkPhysicalDeviceFeatures enabled_features{};
if (pgpu->shader_types_support.allow_float16) if (pgpu->shader_types_support.allow_float16)
{ {
requested_extensions.push_back(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME); requested_extensions.push_back(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
} }
available_features.depthBounds = VK_TRUE; enabled_features.robustBufferAccess = VK_TRUE;
available_features.samplerAnisotropy = VK_TRUE; enabled_features.fullDrawIndexUint32 = VK_TRUE;
available_features.textureCompressionBC = VK_TRUE; enabled_features.independentBlend = VK_TRUE;
available_features.shaderStorageBufferArrayDynamicIndexing = VK_TRUE; enabled_features.logicOp = VK_TRUE;
enabled_features.depthClamp = VK_TRUE;
enabled_features.depthBounds = VK_TRUE;
enabled_features.wideLines = VK_TRUE;
enabled_features.largePoints = VK_TRUE;
if (g_cfg.video.antialiasing_level != msaa_level::none)
{
// MSAA features
enabled_features.alphaToOne = VK_TRUE;
enabled_features.shaderStorageImageMultisample = VK_TRUE;
// enabled_features.shaderStorageImageReadWithoutFormat = VK_TRUE; // Unused currently, may be needed soon
enabled_features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
}
// enabled_features.shaderSampledImageArrayDynamicIndexing = TRUE; // Unused currently but will be needed soon
enabled_features.shaderClipDistance = VK_TRUE;
// enabled_features.shaderCullDistance = VK_TRUE; // Alt notation of clip distance
enabled_features.samplerAnisotropy = VK_TRUE;
enabled_features.textureCompressionBC = VK_TRUE;
enabled_features.shaderStorageBufferArrayDynamicIndexing = VK_TRUE;
// Optionally disable unsupported stuff
if (!pgpu->features.depthBounds)
{
LOG_ERROR(RSX, "Your GPU does not support depth bounds testing. Graphics may not work correctly.");
enabled_features.depthBounds = VK_FALSE;
}
VkDeviceCreateInfo device = {}; VkDeviceCreateInfo device = {};
device.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; device.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
@ -790,7 +818,7 @@ private:
device.ppEnabledLayerNames = nullptr; // Deprecated device.ppEnabledLayerNames = nullptr; // Deprecated
device.enabledExtensionCount = (u32)requested_extensions.size(); device.enabledExtensionCount = (u32)requested_extensions.size();
device.ppEnabledExtensionNames = requested_extensions.data(); device.ppEnabledExtensionNames = requested_extensions.data();
device.pEnabledFeatures = &available_features; device.pEnabledFeatures = &enabled_features;
VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{}; VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{};
if (pgpu->shader_types_support.allow_float16) if (pgpu->shader_types_support.allow_float16)
@ -898,6 +926,11 @@ private:
return pgpu->stencil_export_support; return pgpu->stencil_export_support;
} }
bool get_depth_bounds_support() const
{
return pgpu->features.depthBounds != VK_FALSE;
}
mem_allocator_base* get_allocator() const mem_allocator_base* get_allocator() const
{ {
return m_allocator.get(); return m_allocator.get();

View file

@ -126,12 +126,17 @@ struct VKTraits
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_LINE_WIDTH; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_LINE_WIDTH;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BOUNDS;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_BLEND_CONSTANTS; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_WRITE_MASK; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_WRITE_MASK;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE;
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BIAS; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BIAS;
if (vk::get_current_renderer()->get_depth_bounds_support())
{
dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BOUNDS;
}
dynamic_state_info.pDynamicStates = dynamic_state_descriptors; dynamic_state_info.pDynamicStates = dynamic_state_descriptors;
VkPipelineVertexInputStateCreateInfo vi = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; VkPipelineVertexInputStateCreateInfo vi = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO };