remove patch control points dynamic state (because runtime_info already depends on it)

This commit is contained in:
Frodo Baggins 2024-12-14 00:58:13 -08:00
parent b9148aa811
commit 34463e53c4
6 changed files with 4 additions and 36 deletions

View File

@ -119,9 +119,6 @@ struct HullRuntimeInfo {
// dumb situation. // dumb situation.
// In that case, it should be fine to assume passthrough and declare some extra // In that case, it should be fine to assume passthrough and declare some extra
// output control points and attributes that shouldnt be read by the TES anyways // output control points and attributes that shouldnt be read by the TES anyways
//
// TODO now having patch control points dynamic state is kind of pointless if we depend on
// num_input_control_points
bool IsPassthrough() const { bool IsPassthrough() const {
return hs_output_base == 0 && num_threads == 1; return hs_output_base == 0 && num_threads == 1;
}; };

View File

@ -31,7 +31,6 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
const vk::Device device = instance.GetDevice(); const vk::Device device = instance.GetDevice();
std::ranges::copy(infos, stages.begin()); std::ranges::copy(infos, stages.begin());
BuildDescSetLayout(); BuildDescSetLayout();
const bool uses_tessellation = stages[u32(Shader::LogicalStage::TessellationControl)];
const vk::PushConstantRange push_constants = { const vk::PushConstantRange push_constants = {
.stageFlags = gp_stage_flags, .stageFlags = gp_stage_flags,
@ -174,9 +173,6 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
} else { } else {
dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStrideEXT); dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStrideEXT);
} }
if (uses_tessellation && instance.IsPatchControlPointsDynamicState()) {
dynamic_states.push_back(vk::DynamicState::ePatchControlPointsEXT);
}
const vk::PipelineDynamicStateCreateInfo dynamic_info = { const vk::PipelineDynamicStateCreateInfo dynamic_info = {
.dynamicStateCount = static_cast<u32>(dynamic_states.size()), .dynamicStateCount = static_cast<u32>(dynamic_states.size()),
@ -326,9 +322,8 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.pStages = shader_stages.data(), .pStages = shader_stages.data(),
.pVertexInputState = !instance.IsVertexInputDynamicState() ? &vertex_input_info : nullptr, .pVertexInputState = !instance.IsVertexInputDynamicState() ? &vertex_input_info : nullptr,
.pInputAssemblyState = &input_assembly, .pInputAssemblyState = &input_assembly,
.pTessellationState = (uses_tessellation && !instance.IsPatchControlPointsDynamicState()) .pTessellationState =
? &tessellation_state stages[u32(Shader::LogicalStage::TessellationControl)] ? &tessellation_state : nullptr,
: nullptr,
.pViewportState = &viewport_info, .pViewportState = &viewport_info,
.pRasterizationState = &raster_state, .pRasterizationState = &raster_state,
.pMultisampleState = &multisampling, .pMultisampleState = &multisampling,

View File

@ -258,8 +258,6 @@ bool Instance::CreateDevice() {
add_extension(VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME); add_extension(VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME);
vertex_input_dynamic_state = add_extension(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); vertex_input_dynamic_state = add_extension(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME);
fragment_shader_barycentric = add_extension(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); fragment_shader_barycentric = add_extension(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME);
const bool extended_dynamic_state_2 =
add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME);
// The next two extensions are required to be available together in order to support write masks // The next two extensions are required to be available together in order to support write masks
color_write_en = add_extension(VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME); color_write_en = add_extension(VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME);
@ -381,9 +379,7 @@ bool Instance::CreateDevice() {
vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT{ vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT{
.extendedDynamicState = true, .extendedDynamicState = true,
}, },
vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT{ vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT{},
.extendedDynamicState2PatchControlPoints = true,
},
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT{ vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT{
.extendedDynamicState3ColorWriteMask = true, .extendedDynamicState3ColorWriteMask = true,
}, },
@ -459,16 +455,6 @@ bool Instance::CreateDevice() {
if (!legacy_vertex_attributes) { if (!legacy_vertex_attributes) {
device_chain.unlink<vk::PhysicalDeviceLegacyVertexAttributesFeaturesEXT>(); device_chain.unlink<vk::PhysicalDeviceLegacyVertexAttributesFeaturesEXT>();
} }
if (extended_dynamic_state_2) {
patch_control_points_dynamic_state =
feature_chain.get<vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT>()
.extendedDynamicState2PatchControlPoints;
device_chain.get<vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT>()
.extendedDynamicState2PatchControlPoints = patch_control_points_dynamic_state;
} else {
patch_control_points_dynamic_state = false;
device_chain.unlink<vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT>();
}
auto [device_result, dev] = physical_device.createDeviceUnique(device_chain.get()); auto [device_result, dev] = physical_device.createDeviceUnique(device_chain.get());
if (device_result != vk::Result::eSuccess) { if (device_result != vk::Result::eSuccess) {

View File

@ -133,10 +133,6 @@ public:
return vertex_input_dynamic_state; return vertex_input_dynamic_state;
} }
bool IsPatchControlPointsDynamicState() const {
return patch_control_points_dynamic_state;
}
/// Returns true when the nullDescriptor feature of VK_EXT_robustness2 is supported. /// Returns true when the nullDescriptor feature of VK_EXT_robustness2 is supported.
bool IsNullDescriptorSupported() const { bool IsNullDescriptorSupported() const {
return null_descriptor; return null_descriptor;
@ -337,7 +333,6 @@ private:
bool debug_utils_supported{}; bool debug_utils_supported{};
bool has_nsight_graphics{}; bool has_nsight_graphics{};
bool has_renderdoc{}; bool has_renderdoc{};
bool patch_control_points_dynamic_state{};
}; };
} // namespace Vulkan } // namespace Vulkan

View File

@ -306,7 +306,7 @@ bool PipelineCache::RefreshGraphicsKey() {
key.vertex_buffer_formats.fill(vk::Format::eUndefined); key.vertex_buffer_formats.fill(vk::Format::eUndefined);
key.patch_control_points = 0; key.patch_control_points = 0;
if (regs.stage_enable.hs_en.Value() && !instance.IsPatchControlPointsDynamicState()) { if (regs.stage_enable.hs_en.Value()) {
key.patch_control_points = regs.ls_hs_config.hs_input_control_points.Value(); key.patch_control_points = regs.ls_hs_config.hs_input_control_points.Value();
} }

View File

@ -929,11 +929,6 @@ void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) {
cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eBack, back.stencil_mask); cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eBack, back.stencil_mask);
} }
} }
if (instance.IsPatchControlPointsDynamicState()) {
if (regs.primitive_type == AmdGpu::PrimitiveType::PatchPrimitive) {
cmdbuf.setPatchControlPointsEXT(regs.ls_hs_config.hs_input_control_points);
}
}
} }
void Rasterizer::UpdateViewportScissorState() { void Rasterizer::UpdateViewportScissorState() {