[D3D12] Non-indexed line loops

This commit is contained in:
Triang3l
2019-01-15 14:19:59 +03:00
parent 17dfd84f71
commit a1a1110784
24 changed files with 1009 additions and 918 deletions

View File

@@ -1237,11 +1237,6 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
} else {
adaptive_tessellation = false;
}
// TODO(Triang3l): Non-indexed line loops (by movc'ing zero to the vertex
// index if it's one beyond the end).
if (primitive_type == PrimitiveType::kLineLoop && !indexed) {
return false;
}
PrimitiveType primitive_type_converted =
PrimitiveConverter::GetReplacementPrimitiveType(primitive_type);
D3D_PRIMITIVE_TOPOLOGY primitive_topology;
@@ -1278,6 +1273,18 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
primitive_topology_ = primitive_topology;
deferred_command_list_->D3DIASetPrimitiveTopology(primitive_topology);
}
uint32_t line_loop_closing_index;
if (primitive_type == PrimitiveType::kLineLoop && !indexed &&
index_count >= 3) {
// Add a vertex to close the loop, and make the vertex shader replace its
// index (before adding the offset) with 0 to fetch the first vertex again.
// For indexed line loops, the primitive converter will add the vertex.
line_loop_closing_index = index_count;
++index_count;
} else {
// Replace index 0 with 0 (do nothing) otherwise.
line_loop_closing_index = 0;
}
// Update the textures - this may bind pipelines.
texture_cache_->RequestTextures(
@@ -1305,7 +1312,7 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
// Update system constants before uploading them.
UpdateSystemConstantValues(
memexport_used, primitive_type,
memexport_used, primitive_type, line_loop_closing_index,
indexed ? index_buffer_info->endianness : Endian::kUnspecified,
adaptive_tessellation ? (index_buffer_info->guest_base & 0x1FFFFFFC) : 0,
color_mask, pipeline_render_targets);
@@ -1886,7 +1893,8 @@ void D3D12CommandProcessor::UpdateFixedFunctionState() {
void D3D12CommandProcessor::UpdateSystemConstantValues(
bool shared_memory_is_uav, PrimitiveType primitive_type,
Endian index_endian, uint32_t edge_factor_base, uint32_t color_mask,
uint32_t line_loop_closing_index, Endian index_endian,
uint32_t edge_factor_base, uint32_t color_mask,
const RenderTargetCache::PipelineRenderTarget render_targets[4]) {
auto& regs = *register_file_;
@@ -2080,6 +2088,11 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
tessellation_factor_max;
system_constants_.tessellation_factor_range_max = tessellation_factor_max;
// Line loop closing index (or 0 when drawing other primitives or using an
// index buffer).
dirty |= system_constants_.line_loop_closing_index != line_loop_closing_index;
system_constants_.line_loop_closing_index = line_loop_closing_index;
// Vertex index offset.
dirty |= system_constants_.vertex_base_index != vgt_indx_offset;
system_constants_.vertex_base_index = vgt_indx_offset;