summaryrefslogtreecommitdiffstats
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2022-03-05 08:01:13 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2023-01-01 22:43:57 +0100
commitc541559767c3912940ee3d73a122530b3edde9f1 (patch)
tree9924302d2b8e383ce8824ccc219da42417bbc6d4 /src/video_core/engines
parentMacroHLE: Implement DrawIndexedIndirect & DrawArraysIndirect. (diff)
downloadyuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar.gz
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar.bz2
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar.lz
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar.xz
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.tar.zst
yuzu-c541559767c3912940ee3d73a122530b3edde9f1.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/engines/draw_manager.cpp6
-rw-r--r--src/video_core/engines/draw_manager.h2
-rw-r--r--src/video_core/engines/maxwell_3d.cpp37
-rw-r--r--src/video_core/engines/maxwell_3d.h21
4 files changed, 63 insertions, 3 deletions
diff --git a/src/video_core/engines/draw_manager.cpp b/src/video_core/engines/draw_manager.cpp
index c60f32aad..183d5403c 100644
--- a/src/video_core/engines/draw_manager.cpp
+++ b/src/video_core/engines/draw_manager.cpp
@@ -91,6 +91,12 @@ void DrawManager::DrawIndex(PrimitiveTopology topology, u32 index_first, u32 ind
ProcessDraw(true, num_instances);
}
+void DrawManager::DrawArrayIndirect(PrimitiveTopology topology) {
+ draw_state.topology = topology;
+
+ ProcessDrawIndirect(true);
+}
+
void DrawManager::DrawIndexedIndirect(PrimitiveTopology topology, u32 index_first, u32 index_count) {
const auto& regs{maxwell3d->regs};
draw_state.topology = topology;
diff --git a/src/video_core/engines/draw_manager.h b/src/video_core/engines/draw_manager.h
index 437990162..49a4fca48 100644
--- a/src/video_core/engines/draw_manager.h
+++ b/src/video_core/engines/draw_manager.h
@@ -56,6 +56,8 @@ public:
void DrawIndex(PrimitiveTopology topology, u32 index_first, u32 index_count, u32 base_index,
u32 base_instance, u32 num_instances);
+ void DrawArrayIndirect(PrimitiveTopology topology);
+
void DrawIndexedIndirect(PrimitiveTopology topology, u32 index_first, u32 index_count);
const State& GetDrawState() const {
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index cd6274a9b..b998a8e69 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -133,15 +133,52 @@ void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool
for (size_t i = 0; i < amount; i++) {
macro_addresses.push_back(current_dma_segment + i * sizeof(u32));
}
+ macro_segments.emplace_back(current_dma_segment, amount);
// Call the macro when there are no more parameters in the command buffer
if (is_last_call) {
CallMacroMethod(executing_macro, macro_params);
macro_params.clear();
macro_addresses.clear();
+ macro_segments.clear();
}
}
+void Maxwell3D::RefreshParameters() {
+ size_t current_index = 0;
+ for (auto& segment : macro_segments) {
+ if (segment.first == 0) {
+ current_index += segment.second;
+ continue;
+ }
+ memory_manager.ReadBlock(segment.first, &macro_params[current_index],
+ sizeof(u32) * segment.second);
+ current_index += segment.second;
+ }
+}
+
+u32 Maxwell3D::GetMaxCurrentVertices() {
+ u32 num_vertices = 0;
+ for (size_t index = 0; index < Regs::NumVertexArrays; ++index) {
+ const auto& array = regs.vertex_streams[index];
+ if (array.enable == 0) {
+ continue;
+ }
+ const auto& attribute = regs.vertex_attrib_format[index];
+ if (attribute.constant) {
+ num_vertices = std::max(num_vertices, 1U);
+ continue;
+ }
+ const auto& limit = regs.vertex_stream_limits[index];
+ const GPUVAddr gpu_addr_begin = array.Address();
+ const GPUVAddr gpu_addr_end = limit.Address() + 1;
+ const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
+ num_vertices = std::max(
+ num_vertices, address_size / std::max(attribute.SizeInBytes(), array.stride.Value()));
+ }
+ return num_vertices;
+}
+
u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
// Keep track of the register value in shadow_state when requested.
const auto control = shadow_state.shadow_ram_control;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index ac5e87563..e2256594d 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -3068,10 +3068,14 @@ public:
friend class DrawManager;
std::vector<u8> inline_index_draw_indexes;
- std::vector<GPUVAddr> macro_addresses;
- Core::System& system;
- MemoryManager& memory_manager;
+ GPUVAddr getMacroAddress(size_t index) const {
+ return macro_addresses[index];
+ }
+
+ void RefreshParameters();
+
+ u32 GetMaxCurrentVertices();
/// Handles a write to the CLEAR_BUFFERS register.
void ProcessClearBuffers(u32 layer_count);
@@ -3135,6 +3139,9 @@ private:
/// Returns a query's value or an empty object if the value will be deferred through a cache.
std::optional<u64> GetQueryResult();
+ Core::System& system;
+ MemoryManager& memory_manager;
+
VideoCore::RasterizerInterface* rasterizer = nullptr;
/// Start offsets of each macro in macro_memory
@@ -3151,6 +3158,14 @@ private:
Upload::State upload_state;
bool execute_on{true};
+
+ std::array<bool, Regs::NUM_REGS> draw_command{};
+ std::vector<u32> deferred_draw_method;
+ enum class DrawMode : u32 { General = 0, Instance, InlineIndex };
+ DrawMode draw_mode{DrawMode::General};
+ bool draw_indexed{};
+ std::vector<std::pair<GPUVAddr, size_t>> macro_segments;
+ std::vector<GPUVAddr> macro_addresses;
};
#define ASSERT_REG_POSITION(field_name, position) \