mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-23 08:50:57 +01:00
vk_graphics_pipeline: Implement conservative rendering
This commit is contained in:
parent
ecd6b4356b
commit
4f052a1f39
6 changed files with 44 additions and 10 deletions
|
@ -910,7 +910,11 @@ public:
|
||||||
|
|
||||||
u32 fill_rectangle;
|
u32 fill_rectangle;
|
||||||
|
|
||||||
INSERT_PADDING_WORDS_NOINIT(0x8);
|
INSERT_PADDING_WORDS_NOINIT(0x2);
|
||||||
|
|
||||||
|
u32 conservative_raster_enable;
|
||||||
|
|
||||||
|
INSERT_PADDING_WORDS_NOINIT(0x5);
|
||||||
|
|
||||||
std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format;
|
std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format;
|
||||||
|
|
||||||
|
@ -1615,6 +1619,7 @@ ASSERT_REG_POSITION(zeta, 0x3F8);
|
||||||
ASSERT_REG_POSITION(render_area, 0x3FD);
|
ASSERT_REG_POSITION(render_area, 0x3FD);
|
||||||
ASSERT_REG_POSITION(clear_flags, 0x43E);
|
ASSERT_REG_POSITION(clear_flags, 0x43E);
|
||||||
ASSERT_REG_POSITION(fill_rectangle, 0x44F);
|
ASSERT_REG_POSITION(fill_rectangle, 0x44F);
|
||||||
|
ASSERT_REG_POSITION(conservative_raster_enable, 0x452);
|
||||||
ASSERT_REG_POSITION(vertex_attrib_format, 0x458);
|
ASSERT_REG_POSITION(vertex_attrib_format, 0x458);
|
||||||
ASSERT_REG_POSITION(multisample_sample_locations, 0x478);
|
ASSERT_REG_POSITION(multisample_sample_locations, 0x478);
|
||||||
ASSERT_REG_POSITION(multisample_coverage_to_color, 0x47E);
|
ASSERT_REG_POSITION(multisample_coverage_to_color, 0x47E);
|
||||||
|
|
|
@ -87,6 +87,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d,
|
||||||
depth_format.Assign(static_cast<u32>(regs.zeta.format));
|
depth_format.Assign(static_cast<u32>(regs.zeta.format));
|
||||||
y_negate.Assign(regs.screen_y_control.y_negate != 0 ? 1 : 0);
|
y_negate.Assign(regs.screen_y_control.y_negate != 0 ? 1 : 0);
|
||||||
provoking_vertex_last.Assign(regs.provoking_vertex_last != 0 ? 1 : 0);
|
provoking_vertex_last.Assign(regs.provoking_vertex_last != 0 ? 1 : 0);
|
||||||
|
conservative_raster_enable.Assign(regs.conservative_raster_enable != 0 ? 1 : 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < regs.rt.size(); ++i) {
|
for (size_t i = 0; i < regs.rt.size(); ++i) {
|
||||||
color_formats[i] = static_cast<u8>(regs.rt[i].format);
|
color_formats[i] = static_cast<u8>(regs.rt[i].format);
|
||||||
|
|
|
@ -194,6 +194,7 @@ struct FixedPipelineState {
|
||||||
BitField<6, 5, u32> depth_format;
|
BitField<6, 5, u32> depth_format;
|
||||||
BitField<11, 1, u32> y_negate;
|
BitField<11, 1, u32> y_negate;
|
||||||
BitField<12, 1, u32> provoking_vertex_last;
|
BitField<12, 1, u32> provoking_vertex_last;
|
||||||
|
BitField<13, 1, u32> conservative_raster_enable;
|
||||||
};
|
};
|
||||||
std::array<u8, Maxwell::NumRenderTargets> color_formats;
|
std::array<u8, Maxwell::NumRenderTargets> color_formats;
|
||||||
|
|
||||||
|
|
|
@ -599,16 +599,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
||||||
.pScissors = nullptr,
|
.pScissors = nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT provoking_vertex{
|
VkPipelineRasterizationStateCreateInfo rasterization_ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.provokingVertexMode = key.state.provoking_vertex_last != 0
|
|
||||||
? VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT
|
|
||||||
: VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT,
|
|
||||||
};
|
|
||||||
const VkPipelineRasterizationStateCreateInfo rasterization_ci{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||||
.pNext = device.IsExtProvokingVertexSupported() ? &provoking_vertex : nullptr,
|
.pNext = nullptr,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.depthClampEnable =
|
.depthClampEnable =
|
||||||
static_cast<VkBool32>(key.state.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE),
|
static_cast<VkBool32>(key.state.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE),
|
||||||
|
@ -625,6 +618,28 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
||||||
.depthBiasSlopeFactor = 0.0f,
|
.depthBiasSlopeFactor = 0.0f,
|
||||||
.lineWidth = 1.0f,
|
.lineWidth = 1.0f,
|
||||||
};
|
};
|
||||||
|
VkPipelineRasterizationConservativeStateCreateInfoEXT conservative_raster{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.conservativeRasterizationMode = key.state.conservative_raster_enable != 0
|
||||||
|
? VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT
|
||||||
|
: VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT,
|
||||||
|
.extraPrimitiveOverestimationSize = 0.0f,
|
||||||
|
};
|
||||||
|
VkPipelineRasterizationProvokingVertexStateCreateInfoEXT provoking_vertex{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.provokingVertexMode = key.state.provoking_vertex_last != 0
|
||||||
|
? VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT
|
||||||
|
: VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT,
|
||||||
|
};
|
||||||
|
if (device.IsExtConservativeRasterizationSupported()) {
|
||||||
|
conservative_raster.pNext = std::exchange(rasterization_ci.pNext, &conservative_raster);
|
||||||
|
}
|
||||||
|
if (device.IsExtProvokingVertexSupported()) {
|
||||||
|
provoking_vertex.pNext = std::exchange(rasterization_ci.pNext, &provoking_vertex);
|
||||||
|
}
|
||||||
|
|
||||||
const VkPipelineMultisampleStateCreateInfo multisample_ci{
|
const VkPipelineMultisampleStateCreateInfo multisample_ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||||
|
|
|
@ -412,6 +412,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
||||||
LOG_INFO(Render_Vulkan, "Device doesn't support extended dynamic state");
|
LOG_INFO(Render_Vulkan, "Device doesn't support extended dynamic state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ext_conservative_rasterization) {
|
||||||
|
LOG_INFO(Render_Vulkan, "Device doesn't support conservative rasterization");
|
||||||
|
}
|
||||||
|
|
||||||
VkPhysicalDeviceProvokingVertexFeaturesEXT provoking_vertex;
|
VkPhysicalDeviceProvokingVertexFeaturesEXT provoking_vertex;
|
||||||
if (ext_provoking_vertex) {
|
if (ext_provoking_vertex) {
|
||||||
provoking_vertex = {
|
provoking_vertex = {
|
||||||
|
@ -776,6 +780,8 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) {
|
||||||
true);
|
true);
|
||||||
test(ext_tooling_info, VK_EXT_TOOLING_INFO_EXTENSION_NAME, true);
|
test(ext_tooling_info, VK_EXT_TOOLING_INFO_EXTENSION_NAME, true);
|
||||||
test(ext_shader_stencil_export, VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, true);
|
test(ext_shader_stencil_export, VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, true);
|
||||||
|
test(ext_conservative_rasterization, VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME,
|
||||||
|
true);
|
||||||
test(has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, false);
|
test(has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, false);
|
||||||
test(has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, false);
|
test(has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, false);
|
||||||
test(has_ext_extended_dynamic_state, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false);
|
test(has_ext_extended_dynamic_state, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false);
|
||||||
|
|
|
@ -264,6 +264,11 @@ public:
|
||||||
return ext_shader_stencil_export;
|
return ext_shader_stencil_export;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the device supports VK_EXT_conservative_rasterization.
|
||||||
|
bool IsExtConservativeRasterizationSupported() const {
|
||||||
|
return ext_conservative_rasterization;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_provoking_vertex.
|
/// Returns true if the device supports VK_EXT_provoking_vertex.
|
||||||
bool IsExtProvokingVertexSupported() const {
|
bool IsExtProvokingVertexSupported() const {
|
||||||
return ext_provoking_vertex;
|
return ext_provoking_vertex;
|
||||||
|
@ -374,6 +379,7 @@ private:
|
||||||
bool ext_vertex_input_dynamic_state{}; ///< Support for VK_EXT_vertex_input_dynamic_state.
|
bool ext_vertex_input_dynamic_state{}; ///< Support for VK_EXT_vertex_input_dynamic_state.
|
||||||
bool ext_shader_stencil_export{}; ///< Support for VK_EXT_shader_stencil_export.
|
bool ext_shader_stencil_export{}; ///< Support for VK_EXT_shader_stencil_export.
|
||||||
bool ext_shader_atomic_int64{}; ///< Support for VK_KHR_shader_atomic_int64.
|
bool ext_shader_atomic_int64{}; ///< Support for VK_KHR_shader_atomic_int64.
|
||||||
|
bool ext_conservative_rasterization{}; ///< Support for VK_EXT_conservative_rasterization.
|
||||||
bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex.
|
bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex.
|
||||||
bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config.
|
bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config.
|
||||||
bool has_renderdoc{}; ///< Has RenderDoc attached
|
bool has_renderdoc{}; ///< Has RenderDoc attached
|
||||||
|
|
Loading…
Reference in a new issue