mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-06 12:13:57 +00:00
[vulkan] Set actual dynamic state handling for topology
This commit is contained in:
@@ -39,6 +39,24 @@ constexpr std::array POLYGON_OFFSET_ENABLE_LUT = {
|
|||||||
POLYGON, // Patches
|
POLYGON, // Patches
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr std::array TOPOLOGY_CLASS_REPRESENTATIVE_LUT = {
|
||||||
|
Maxwell::PrimitiveTopology::Points, // Points
|
||||||
|
Maxwell::PrimitiveTopology::Lines, // Lines
|
||||||
|
Maxwell::PrimitiveTopology::LineLoop, // LineLoop
|
||||||
|
Maxwell::PrimitiveTopology::LineStrip, // LineStrip
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // Triangles
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // TriangleStrip
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // TriangleFan
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // Quads
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // QuadStrip
|
||||||
|
Maxwell::PrimitiveTopology::Triangles, // Polygon
|
||||||
|
Maxwell::PrimitiveTopology::LinesAdjacency, // LinesAdjacency
|
||||||
|
Maxwell::PrimitiveTopology::LinesAdjacency, // LineStripAdjacency
|
||||||
|
Maxwell::PrimitiveTopology::TrianglesAdjacency, // TrianglesAdjacency
|
||||||
|
Maxwell::PrimitiveTopology::TrianglesAdjacency, // TriangleStripAdjacency
|
||||||
|
Maxwell::PrimitiveTopology::Patches, // Patches
|
||||||
|
};
|
||||||
|
|
||||||
void RefreshXfbState(VideoCommon::TransformFeedbackState& state, const Maxwell& regs) {
|
void RefreshXfbState(VideoCommon::TransformFeedbackState& state, const Maxwell& regs) {
|
||||||
std::ranges::transform(regs.transform_feedback.controls, state.layouts.begin(),
|
std::ranges::transform(regs.transform_feedback.controls, state.layouts.begin(),
|
||||||
[](const auto& layout) {
|
[](const auto& layout) {
|
||||||
@@ -71,7 +89,11 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
|
|||||||
tessellation_clockwise.Assign(regs.tessellation.params.output_primitives.Value() ==
|
tessellation_clockwise.Assign(regs.tessellation.params.output_primitives.Value() ==
|
||||||
Maxwell::Tessellation::OutputPrimitives::Triangles_CW);
|
Maxwell::Tessellation::OutputPrimitives::Triangles_CW);
|
||||||
patch_control_points_minus_one.Assign(regs.patch_vertices - 1);
|
patch_control_points_minus_one.Assign(regs.patch_vertices - 1);
|
||||||
topology.Assign(topology_);
|
const bool can_collapse_topology_class =
|
||||||
|
features.has_extended_dynamic_state && features.has_extended_dynamic_state_2;
|
||||||
|
topology.Assign(can_collapse_topology_class
|
||||||
|
? TOPOLOGY_CLASS_REPRESENTATIVE_LUT[static_cast<size_t>(topology_)]
|
||||||
|
: topology_);
|
||||||
msaa_mode.Assign(regs.anti_alias_samples_mode);
|
msaa_mode.Assign(regs.anti_alias_samples_mode);
|
||||||
|
|
||||||
raw2 = 0;
|
raw2 = 0;
|
||||||
|
|||||||
@@ -865,6 +865,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
|||||||
VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT,
|
VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT,
|
||||||
VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT,
|
VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT,
|
||||||
VK_DYNAMIC_STATE_STENCIL_OP_EXT,
|
VK_DYNAMIC_STATE_STENCIL_OP_EXT,
|
||||||
|
VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT,
|
||||||
};
|
};
|
||||||
dynamic_states.insert(dynamic_states.end(), extended.begin(), extended.end());
|
dynamic_states.insert(dynamic_states.end(), extended.begin(), extended.end());
|
||||||
|
|
||||||
|
|||||||
@@ -1011,12 +1011,12 @@ void RasterizerVulkan::UpdateDynamicStates() {
|
|||||||
auto& regs = maxwell3d->regs;
|
auto& regs = maxwell3d->regs;
|
||||||
auto& flags = maxwell3d->dirty.flags;
|
auto& flags = maxwell3d->dirty.flags;
|
||||||
const auto topology = maxwell3d->draw_manager.draw_state.topology;
|
const auto topology = maxwell3d->draw_manager.draw_state.topology;
|
||||||
if (state_tracker.ChangePrimitiveTopology(topology)) {
|
const bool topology_changed = state_tracker.ChangePrimitiveTopology(topology);
|
||||||
|
if (topology_changed) {
|
||||||
flags[Dirty::DepthBiasEnable] = true;
|
flags[Dirty::DepthBiasEnable] = true;
|
||||||
flags[Dirty::PrimitiveRestartEnable] = true;
|
flags[Dirty::PrimitiveRestartEnable] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Core Dynamic States (Vulkan 1.0) - Always active regardless of dyna_state setting
|
|
||||||
UpdateViewportsState(regs);
|
UpdateViewportsState(regs);
|
||||||
UpdateScissorsState(regs);
|
UpdateScissorsState(regs);
|
||||||
UpdateDepthBias(regs);
|
UpdateDepthBias(regs);
|
||||||
@@ -1025,7 +1025,6 @@ void RasterizerVulkan::UpdateDynamicStates() {
|
|||||||
UpdateStencilFaces(regs);
|
UpdateStencilFaces(regs);
|
||||||
UpdateLineWidth(regs);
|
UpdateLineWidth(regs);
|
||||||
|
|
||||||
// EDS1: CullMode, DepthCompare, FrontFace, StencilOp, DepthBoundsTest, DepthTest, DepthWrite, StencilTest
|
|
||||||
if (device.IsExtExtendedDynamicStateSupported()) {
|
if (device.IsExtExtendedDynamicStateSupported()) {
|
||||||
UpdateCullMode(regs);
|
UpdateCullMode(regs);
|
||||||
UpdateDepthCompareOp(regs);
|
UpdateDepthCompareOp(regs);
|
||||||
@@ -1037,21 +1036,24 @@ void RasterizerVulkan::UpdateDynamicStates() {
|
|||||||
UpdateDepthWriteEnable(regs);
|
UpdateDepthWriteEnable(regs);
|
||||||
UpdateStencilTestEnable(regs);
|
UpdateStencilTestEnable(regs);
|
||||||
}
|
}
|
||||||
|
if (topology_changed) {
|
||||||
|
scheduler.Record([topology_vk = MaxwellToVK::PrimitiveTopology(device, topology)](
|
||||||
|
vk::CommandBuffer cmdbuf) {
|
||||||
|
cmdbuf.SetPrimitiveTopologyEXT(topology_vk);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EDS2: PrimitiveRestart, RasterizerDiscard, DepthBias enable/disable
|
|
||||||
if (device.IsExtExtendedDynamicState2Supported()) {
|
if (device.IsExtExtendedDynamicState2Supported()) {
|
||||||
UpdatePrimitiveRestartEnable(regs);
|
UpdatePrimitiveRestartEnable(regs);
|
||||||
UpdateRasterizerDiscardEnable(regs);
|
UpdateRasterizerDiscardEnable(regs);
|
||||||
UpdateDepthBiasEnable(regs);
|
UpdateDepthBiasEnable(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EDS2 Extras: LogicOp operation selection
|
|
||||||
if (device.IsExtExtendedDynamicState2ExtrasSupported()) {
|
if (device.IsExtExtendedDynamicState2ExtrasSupported()) {
|
||||||
UpdateLogicOp(regs);
|
UpdateLogicOp(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EDS3 Enables: LogicOpEnable, DepthClamp, LineStipple, ConservativeRaster
|
|
||||||
if (device.IsExtExtendedDynamicState3EnablesSupported()) {
|
if (device.IsExtExtendedDynamicState3EnablesSupported()) {
|
||||||
using namespace Tegra::Engines;
|
using namespace Tegra::Engines;
|
||||||
// AMD Workaround: LogicOp incompatible with float render targets
|
// AMD Workaround: LogicOp incompatible with float render targets
|
||||||
@@ -1076,12 +1078,10 @@ void RasterizerVulkan::UpdateDynamicStates() {
|
|||||||
UpdateAlphaToOneEnable(regs);
|
UpdateAlphaToOneEnable(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EDS3 Blending: ColorBlendEnable, ColorBlendEquation, ColorWriteMask
|
|
||||||
if (device.IsExtExtendedDynamicState3BlendingSupported()) {
|
if (device.IsExtExtendedDynamicState3BlendingSupported()) {
|
||||||
UpdateBlending(regs);
|
UpdateBlending(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertex Input Dynamic State: Independent from EDS levels
|
|
||||||
if (device.IsExtVertexInputDynamicStateSupported()) {
|
if (device.IsExtVertexInputDynamicStateSupported()) {
|
||||||
if (auto* gp = pipeline_cache.CurrentGraphicsPipeline(); gp && gp->HasDynamicVertexInput()) {
|
if (auto* gp = pipeline_cache.CurrentGraphicsPipeline(); gp && gp->HasDynamicVertexInput()) {
|
||||||
UpdateVertexInput(regs);
|
UpdateVertexInput(regs);
|
||||||
|
|||||||
Reference in New Issue
Block a user