summaryrefslogtreecommitdiff
path: root/src/video_core/macro
diff options
context:
space:
mode:
authorGravatar Fernando S2022-12-08 12:41:39 +0100
committerGravatar GitHub2022-12-08 12:41:39 +0100
commit41461514d6f3ba59dc027dbc4a88c0ffb570ea49 (patch)
treec3cffc17ce63e66f5fa2921e4804c396140a9791 /src/video_core/macro
parentMerge pull request #9365 from liamwhite/val (diff)
parentvideo_core: Implement maxwell3d draw manager and split draw logic (diff)
downloadyuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.gz
yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.xz
yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.zip
Merge pull request #9401 from vonchenplus/draw_manager
video_core: Implement maxwell3d draw manager and split draw logic
Diffstat (limited to 'src/video_core/macro')
-rw-r--r--src/video_core/macro/macro_hle.cpp69
1 files changed, 17 insertions, 52 deletions
diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp
index 0f3262edb..8549db2e4 100644
--- a/src/video_core/macro/macro_hle.cpp
+++ b/src/video_core/macro/macro_hle.cpp
@@ -5,6 +5,7 @@
5#include <vector> 5#include <vector>
6#include "common/scope_exit.h" 6#include "common/scope_exit.h"
7#include "video_core/dirty_flags.h" 7#include "video_core/dirty_flags.h"
8#include "video_core/engines/draw_manager.h"
8#include "video_core/engines/maxwell_3d.h" 9#include "video_core/engines/maxwell_3d.h"
9#include "video_core/macro/macro.h" 10#include "video_core/macro/macro.h"
10#include "video_core/macro/macro_hle.h" 11#include "video_core/macro/macro_hle.h"
@@ -18,57 +19,33 @@ using HLEFunction = void (*)(Engines::Maxwell3D& maxwell3d, const std::vector<u3
18// HLE'd functions 19// HLE'd functions
19void HLE_771BB18C62444DA0(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { 20void HLE_771BB18C62444DA0(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
20 const u32 instance_count = parameters[2] & maxwell3d.GetRegisterValue(0xD1B); 21 const u32 instance_count = parameters[2] & maxwell3d.GetRegisterValue(0xD1B);
21 22 maxwell3d.draw_manager->DrawIndex(
22 maxwell3d.regs.draw.topology.Assign( 23 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0] & 0x3ffffff),
23 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0] & 0x3ffffff)); 24 parameters[4], parameters[1], parameters[3], parameters[5], instance_count);
24 maxwell3d.regs.global_base_instance_index = parameters[5];
25 maxwell3d.regs.global_base_vertex_index = parameters[3];
26 maxwell3d.regs.index_buffer.count = parameters[1];
27 maxwell3d.regs.index_buffer.first = parameters[4];
28
29 if (maxwell3d.ShouldExecute()) {
30 maxwell3d.Rasterizer().Draw(true, instance_count);
31 }
32 maxwell3d.regs.index_buffer.count = 0;
33} 25}
34 26
35void HLE_0D61FC9FAAC9FCAD(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { 27void HLE_0D61FC9FAAC9FCAD(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
36 const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]); 28 const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]);
37 29 maxwell3d.draw_manager->DrawArray(
38 maxwell3d.regs.vertex_buffer.first = parameters[3]; 30 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0]),
39 maxwell3d.regs.vertex_buffer.count = parameters[1]; 31 parameters[3], parameters[1], parameters[4], instance_count);
40 maxwell3d.regs.global_base_instance_index = parameters[4];
41 maxwell3d.regs.draw.topology.Assign(
42 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0]));
43
44 if (maxwell3d.ShouldExecute()) {
45 maxwell3d.Rasterizer().Draw(false, instance_count);
46 }
47 maxwell3d.regs.vertex_buffer.count = 0;
48} 32}
49 33
50void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { 34void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
51 const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]); 35 const u32 instance_count = (maxwell3d.GetRegisterValue(0xD1B) & parameters[2]);
52 const u32 element_base = parameters[4]; 36 const u32 element_base = parameters[4];
53 const u32 base_instance = parameters[5]; 37 const u32 base_instance = parameters[5];
54 maxwell3d.regs.index_buffer.first = parameters[3];
55 maxwell3d.regs.vertex_id_base = element_base; 38 maxwell3d.regs.vertex_id_base = element_base;
56 maxwell3d.regs.index_buffer.count = parameters[1];
57 maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; 39 maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
58 maxwell3d.regs.global_base_vertex_index = element_base;
59 maxwell3d.regs.global_base_instance_index = base_instance;
60 maxwell3d.CallMethod(0x8e3, 0x640, true); 40 maxwell3d.CallMethod(0x8e3, 0x640, true);
61 maxwell3d.CallMethod(0x8e4, element_base, true); 41 maxwell3d.CallMethod(0x8e4, element_base, true);
62 maxwell3d.CallMethod(0x8e5, base_instance, true); 42 maxwell3d.CallMethod(0x8e5, base_instance, true);
63 maxwell3d.regs.draw.topology.Assign( 43
64 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0])); 44 maxwell3d.draw_manager->DrawIndex(
65 if (maxwell3d.ShouldExecute()) { 45 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0]),
66 maxwell3d.Rasterizer().Draw(true, instance_count); 46 parameters[3], parameters[1], element_base, base_instance, instance_count);
67 } 47
68 maxwell3d.regs.vertex_id_base = 0x0; 48 maxwell3d.regs.vertex_id_base = 0x0;
69 maxwell3d.regs.index_buffer.count = 0;
70 maxwell3d.regs.global_base_vertex_index = 0x0;
71 maxwell3d.regs.global_base_instance_index = 0x0;
72 maxwell3d.CallMethod(0x8e3, 0x640, true); 49 maxwell3d.CallMethod(0x8e3, 0x640, true);
73 maxwell3d.CallMethod(0x8e4, 0x0, true); 50 maxwell3d.CallMethod(0x8e4, 0x0, true);
74 maxwell3d.CallMethod(0x8e5, 0x0, true); 51 maxwell3d.CallMethod(0x8e5, 0x0, true);
@@ -79,9 +56,6 @@ void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
79 SCOPE_EXIT({ 56 SCOPE_EXIT({
80 // Clean everything. 57 // Clean everything.
81 maxwell3d.regs.vertex_id_base = 0x0; 58 maxwell3d.regs.vertex_id_base = 0x0;
82 maxwell3d.regs.index_buffer.count = 0;
83 maxwell3d.regs.global_base_vertex_index = 0x0;
84 maxwell3d.regs.global_base_instance_index = 0x0;
85 maxwell3d.CallMethod(0x8e3, 0x640, true); 59 maxwell3d.CallMethod(0x8e3, 0x640, true);
86 maxwell3d.CallMethod(0x8e4, 0x0, true); 60 maxwell3d.CallMethod(0x8e4, 0x0, true);
87 maxwell3d.CallMethod(0x8e5, 0x0, true); 61 maxwell3d.CallMethod(0x8e5, 0x0, true);
@@ -93,9 +67,6 @@ void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
93 // Nothing to do. 67 // Nothing to do.
94 return; 68 return;
95 } 69 }
96 const auto topology =
97 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[2]);
98 maxwell3d.regs.draw.topology.Assign(topology);
99 const u32 padding = parameters[3]; 70 const u32 padding = parameters[3];
100 const std::size_t max_draws = parameters[4]; 71 const std::size_t max_draws = parameters[4];
101 72
@@ -106,23 +77,17 @@ void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
106 77
107 for (std::size_t index = first_draw; index < last_draw; index++) { 78 for (std::size_t index = first_draw; index < last_draw; index++) {
108 const std::size_t base = index * indirect_words + 5; 79 const std::size_t base = index * indirect_words + 5;
109 const u32 num_vertices = parameters[base];
110 const u32 instance_count = parameters[base + 1];
111 const u32 first_index = parameters[base + 2];
112 const u32 base_vertex = parameters[base + 3]; 80 const u32 base_vertex = parameters[base + 3];
113 const u32 base_instance = parameters[base + 4]; 81 const u32 base_instance = parameters[base + 4];
114 maxwell3d.regs.index_buffer.first = first_index;
115 maxwell3d.regs.vertex_id_base = base_vertex; 82 maxwell3d.regs.vertex_id_base = base_vertex;
116 maxwell3d.regs.index_buffer.count = num_vertices;
117 maxwell3d.regs.global_base_vertex_index = base_vertex;
118 maxwell3d.regs.global_base_instance_index = base_instance;
119 maxwell3d.CallMethod(0x8e3, 0x640, true); 83 maxwell3d.CallMethod(0x8e3, 0x640, true);
120 maxwell3d.CallMethod(0x8e4, base_vertex, true); 84 maxwell3d.CallMethod(0x8e4, base_vertex, true);
121 maxwell3d.CallMethod(0x8e5, base_instance, true); 85 maxwell3d.CallMethod(0x8e5, base_instance, true);
122 maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; 86 maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
123 if (maxwell3d.ShouldExecute()) { 87 maxwell3d.draw_manager->DrawIndex(
124 maxwell3d.Rasterizer().Draw(true, instance_count); 88 static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[2]),
125 } 89 parameters[base + 2], parameters[base], base_vertex, base_instance,
90 parameters[base + 1]);
126 } 91 }
127} 92}
128 93
@@ -136,7 +101,7 @@ void HLE_EAD26C3E2109B06B(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
136 ASSERT(clear_params.layer == 0); 101 ASSERT(clear_params.layer == 0);
137 102
138 maxwell3d.regs.clear_surface.raw = clear_params.raw; 103 maxwell3d.regs.clear_surface.raw = clear_params.raw;
139 maxwell3d.ProcessClearBuffers(num_layers); 104 maxwell3d.draw_manager->Clear(num_layers);
140} 105}
141 106
142constexpr std::array<std::pair<u64, HLEFunction>, 5> hle_funcs{{ 107constexpr std::array<std::pair<u64, HLEFunction>, 5> hle_funcs{{