summaryrefslogtreecommitdiffstats
path: root/src/video_core/engines/maxwell_3d.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-09-15 17:48:54 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-09-19 17:41:27 +0200
commitba02d564f8a0b0167b96f247b6ad9d2bde05b6c8 (patch)
tree015edafb7deacabf4fea3c547534bb00ed60781f /src/video_core/engines/maxwell_3d.cpp
parentMerge pull request #2784 from ReinUsesLisp/smem (diff)
downloadyuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar.gz
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar.bz2
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar.lz
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar.xz
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.tar.zst
yuzu-ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8.zip
Diffstat (limited to 'src/video_core/engines/maxwell_3d.cpp')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index c7a3c85a0..48fc1a9e1 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -92,6 +92,10 @@ void Maxwell3D::InitializeRegisterDefaults() {
// Some games (like Super Mario Odyssey) assume that SRGB is enabled.
regs.framebuffer_srgb = 1;
+ mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_end_gl)] = true;
+ mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)] = true;
+ mme_inline[MAXWELL3D_REG_INDEX(vertex_buffer.count)] = true;
+ mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true;
}
#define DIRTY_REGS_POS(field_name) (offsetof(Maxwell3D::DirtyRegs, field_name))
@@ -416,6 +420,76 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
}
}
+void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) {
+ const u32 method = method_call.method;
+ if (mme_inline[method]) {
+ regs.reg_array[method] = method_call.argument;
+ if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) ||
+ method == MAXWELL3D_REG_INDEX(index_array.count)) {
+ MMMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count)
+ ? MMMEDrawMode::Array
+ : MMMEDrawMode::Indexed;
+ u32 count = method_call.argument;
+ while (true) {
+ if (mme_draw.current_mode == MMMEDrawMode::Undefined) {
+ mme_draw.current_mode = expected_mode;
+ mme_draw.current_count = count;
+ mme_draw.instance_count = 1;
+ break;
+ } else {
+ if (mme_draw.current_mode == expected_mode && count == mme_draw.current_count) {
+ mme_draw.instance_count++;
+ break;
+ } else {
+ FlushMMEInlineDraw();
+ }
+ }
+ }
+ }
+ } else {
+ if (mme_draw.current_mode != MMMEDrawMode::Undefined) {
+ FlushMMEInlineDraw();
+ }
+ CallMethod(method_call);
+ }
+}
+
+void Maxwell3D::FlushMMEInlineDraw() {
+ LOG_DEBUG(HW_GPU, "called, topology={}, count={}", static_cast<u32>(regs.draw.topology.Value()),
+ regs.vertex_buffer.count);
+ ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?");
+
+ auto debug_context = system.GetGPUDebugContext();
+
+ if (debug_context) {
+ debug_context->OnEvent(Tegra::DebugContext::Event::IncomingPrimitiveBatch, nullptr);
+ }
+
+ // Both instance configuration registers can not be set at the same time.
+ ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont,
+ "Illegal combination of instancing parameters");
+
+ const bool is_indexed = mme_draw.current_mode == MMMEDrawMode::Indexed;
+ rasterizer.AccelerateDrawMultiBatch(is_indexed);
+
+ if (debug_context) {
+ debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr);
+ }
+
+ // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
+ // the game is trying to draw indexed or direct mode. This needs to be verified on HW still -
+ // it's possible that it is incorrect and that there is some other register used to specify the
+ // drawing mode.
+ if (is_indexed) {
+ regs.index_array.count = 0;
+ } else {
+ regs.vertex_buffer.count = 0;
+ }
+ mme_draw.current_mode = MMMEDrawMode::Undefined;
+ mme_draw.current_count = 0;
+ mme_draw.instance_count = 0;
+}
+
void Maxwell3D::ProcessMacroUpload(u32 data) {
ASSERT_MSG(regs.macros.upload_address < macro_memory.size(),
"upload_address exceeded macro_memory size!");