[vk] reorganize and properly categorize stipple and conraster

Signed-off-by: crueter <crueter@crueter.xyz>
This commit is contained in:
crueter 2025-07-14 02:00:41 -04:00
parent 124858eda2
commit 82c84df204
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
5 changed files with 23 additions and 11 deletions

View file

@ -806,12 +806,12 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
.pAttachments = cb_attachments.data(), .pAttachments = cb_attachments.data(),
.blendConstants = {} .blendConstants = {}
}; };
static_vector<VkDynamicState, 38> dynamic_states{ static_vector<VkDynamicState, 34> dynamic_states{
VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR,
VK_DYNAMIC_STATE_DEPTH_BIAS, VK_DYNAMIC_STATE_BLEND_CONSTANTS, VK_DYNAMIC_STATE_DEPTH_BIAS, VK_DYNAMIC_STATE_BLEND_CONSTANTS,
VK_DYNAMIC_STATE_DEPTH_BOUNDS, VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK, VK_DYNAMIC_STATE_DEPTH_BOUNDS, VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
VK_DYNAMIC_STATE_STENCIL_WRITE_MASK, VK_DYNAMIC_STATE_STENCIL_REFERENCE, VK_DYNAMIC_STATE_STENCIL_WRITE_MASK, VK_DYNAMIC_STATE_STENCIL_REFERENCE,
VK_DYNAMIC_STATE_LINE_WIDTH, VK_DYNAMIC_STATE_LINE_STIPPLE, VK_DYNAMIC_STATE_LINE_WIDTH,
}; };
if (key.state.extended_dynamic_state) { if (key.state.extended_dynamic_state) {
static constexpr std::array extended{ static constexpr std::array extended{

View file

@ -935,7 +935,8 @@ void RasterizerVulkan::UpdateDynamicStates() {
UpdateDepthBounds(regs); UpdateDepthBounds(regs);
UpdateStencilFaces(regs); UpdateStencilFaces(regs);
UpdateLineWidth(regs); UpdateLineWidth(regs);
// UpdateLineStipple(regs); // TODO // TODO: updating line stipple causes the cmdbuf to die
// UpdateLineStipple(regs);
const u8 dynamic_state = Settings::values.dyna_state.GetValue(); const u8 dynamic_state = Settings::values.dyna_state.GetValue();
@ -1353,7 +1354,7 @@ void RasterizerVulkan::UpdateConservativeRasterizationMode(Tegra::Engines::Maxwe
scheduler.Record([enable = regs.conservative_raster_enable](vk::CommandBuffer cmdbuf) { scheduler.Record([enable = regs.conservative_raster_enable](vk::CommandBuffer cmdbuf) {
cmdbuf.SetConservativeRasterizationModeEXT( cmdbuf.SetConservativeRasterizationModeEXT(
enable ? VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT enable ? VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT
: VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT); : VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT);
}); });
} }
@ -1371,12 +1372,12 @@ void RasterizerVulkan::UpdateLineStippleEnable(Tegra::Engines::Maxwell3D::Regs&
void RasterizerVulkan::UpdateLineStipple(Tegra::Engines::Maxwell3D::Regs& regs) void RasterizerVulkan::UpdateLineStipple(Tegra::Engines::Maxwell3D::Regs& regs)
{ {
if (!state_tracker.TouchLineStippleEnable()) { if (!state_tracker.TouchLineStipple()) {
return; return;
} }
scheduler.Record([params = regs.line_stipple_params](vk::CommandBuffer cmdbuf) { scheduler.Record([params = regs.line_stipple_params](vk::CommandBuffer cmdbuf) {
cmdbuf.SetLineStippleEXT(params.factor, u16(params.pattern)); cmdbuf.SetLineStippleEXT(params.factor, static_cast<uint16_t>(params.pattern));
}); });
} }

View file

@ -153,6 +153,7 @@ private:
TypedCommand& operator=(TypedCommand&&) = delete; TypedCommand& operator=(TypedCommand&&) = delete;
void Execute(vk::CommandBuffer cmdbuf, vk::CommandBuffer upload_cmdbuf) const override { void Execute(vk::CommandBuffer cmdbuf, vk::CommandBuffer upload_cmdbuf) const override {
command(cmdbuf, upload_cmdbuf); command(cmdbuf, upload_cmdbuf);
} }

View file

@ -52,7 +52,6 @@ Flags MakeInvalidationFlags() {
VertexInput, VertexInput,
StateEnable, StateEnable,
PrimitiveRestartEnable, PrimitiveRestartEnable,
LineStippleParams,
DepthBiasEnable, DepthBiasEnable,
LogicOpEnable, LogicOpEnable,
DepthClampEnable, DepthClampEnable,
@ -61,6 +60,9 @@ Flags MakeInvalidationFlags() {
ColorMask, ColorMask,
BlendEquations, BlendEquations,
BlendEnable, BlendEnable,
ConservativeRasterizationMode,
LineStippleEnable,
LineStippleParams,
}; };
Flags flags{}; Flags flags{};
for (const int flag : INVALIDATION_FLAGS) { for (const int flag : INVALIDATION_FLAGS) {
@ -140,14 +142,12 @@ void SetupDirtyStateEnable(Tables& tables) {
setup(OFF(stencil_enable), StencilTestEnable); setup(OFF(stencil_enable), StencilTestEnable);
setup(OFF(primitive_restart.enabled), PrimitiveRestartEnable); setup(OFF(primitive_restart.enabled), PrimitiveRestartEnable);
setup(OFF(rasterize_enable), RasterizerDiscardEnable); setup(OFF(rasterize_enable), RasterizerDiscardEnable);
setup(OFF(conservative_raster_enable), ConservativeRasterizationMode);
setup(OFF(line_stipple_enable), LineStippleEnable);
setup(OFF(line_stipple_params), LineStippleParams);
setup(OFF(polygon_offset_point_enable), DepthBiasEnable); setup(OFF(polygon_offset_point_enable), DepthBiasEnable);
setup(OFF(polygon_offset_line_enable), DepthBiasEnable); setup(OFF(polygon_offset_line_enable), DepthBiasEnable);
setup(OFF(polygon_offset_fill_enable), DepthBiasEnable); setup(OFF(polygon_offset_fill_enable), DepthBiasEnable);
setup(OFF(logic_op.enable), LogicOpEnable); setup(OFF(logic_op.enable), LogicOpEnable);
setup(OFF(viewport_clip_control.geometry_clip), DepthClampEnable); setup(OFF(viewport_clip_control.geometry_clip), DepthClampEnable);
setup(OFF(line_stipple_enable), LineStippleEnable);
} }
void SetupDirtyDepthCompareOp(Tables& tables) { void SetupDirtyDepthCompareOp(Tables& tables) {
@ -220,6 +220,13 @@ void SetupDirtyVertexBindings(Tables& tables) {
tables[1][OFF(vertex_streams) + i * NUM(vertex_streams[0]) + divisor_offset] = flag; tables[1][OFF(vertex_streams) + i * NUM(vertex_streams[0]) + divisor_offset] = flag;
} }
} }
void SetupRasterModes(Tables &tables) {
auto& table = tables[0];
table[OFF(line_stipple_params)] = LineStippleParams;
table[OFF(conservative_raster_enable)] = ConservativeRasterizationMode;
}
} // Anonymous namespace } // Anonymous namespace
void StateTracker::SetupTables(Tegra::Control::ChannelState& channel_state) { void StateTracker::SetupTables(Tegra::Control::ChannelState& channel_state) {
@ -242,6 +249,7 @@ void StateTracker::SetupTables(Tegra::Control::ChannelState& channel_state) {
SetupDirtyVertexAttributes(tables); SetupDirtyVertexAttributes(tables);
SetupDirtyVertexBindings(tables); SetupDirtyVertexBindings(tables);
SetupDirtySpecialOps(tables); SetupDirtySpecialOps(tables);
SetupRasterModes(tables);
} }
void StateTracker::ChangeChannel(Tegra::Control::ChannelState& channel_state) { void StateTracker::ChangeChannel(Tegra::Control::ChannelState& channel_state) {

View file

@ -211,7 +211,9 @@ public:
return Exchange(Dirty::ConservativeRasterizationMode, false); return Exchange(Dirty::ConservativeRasterizationMode, false);
} }
bool TouchLineStippleEnable() { return Exchange(Dirty::ConservativeRasterizationMode, false); } bool TouchLineStippleEnable() { return Exchange(Dirty::LineStippleEnable, false); }
bool TouchLineStipple() { return Exchange(Dirty::LineStippleParams, false); }
bool TouchDepthBiasEnable() { return Exchange(Dirty::DepthBiasEnable, false); } bool TouchDepthBiasEnable() { return Exchange(Dirty::DepthBiasEnable, false); }