Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a MME Draw commands Inliner and correct host instance drawing #2870

Merged
merged 7 commits into from Sep 22, 2019

Conversation

@FernandoS27
Copy link
Contributor

commented Sep 18, 2019

This PR aims to accumulate draw calls sent through MME(Macro Interpreter) and flush then once either a sync is required or the program has ended. This heavily increases performance in certain games like SMO, PLGE which use instance drawing heavily. In the pokemon mansion in PLGE performance went from 12fps all the way to 50fps. Some kingdoms in SMO got a significant 5fps boost(changes depending on your computer).

Special thanks to fincs, since he discovered how MME's worked to do instance drawing and suggested this method.

@@ -778,11 +725,98 @@ void RasterizerOpenGL::DrawArrays() {
if (texture_cache.TextureBarrier()) {
glTextureBarrier();
}
}

struct DrawParams {

This comment has been minimized.

Copy link
@ogniK5377

ogniK5377 Sep 18, 2019

Contributor

Initialize all members here

This comment has been minimized.

Copy link
@FernandoS27

FernandoS27 Sep 18, 2019

Author Contributor

Done.

auto& maxwell3d = system.GPU().Maxwell3D();
const auto& regs = maxwell3d.regs;
const auto& draw_setup = maxwell3d.mme_draw;
DrawParams draw_call;

This comment has been minimized.

Copy link
@ogniK5377

ogniK5377 Sep 18, 2019

Contributor
Suggested change
DrawParams draw_call;
DrawParams draw_call{};
@FernandoS27 FernandoS27 force-pushed the FernandoS27:multi-draw branch from 2ad19d0 to 7761e44 Sep 19, 2019
…t stop a draw call from executing
Copy link
Contributor

left a comment

Good work. Some small changes are required, but nothing major. This helps a lot both performance and debuggability.

: MMMEDrawMode::Indexed;
const u32 count = method_call.argument;
while (true) {
if (mme_draw.current_mode == MMMEDrawMode::Undefined) {

This comment has been minimized.

Copy link
@ReinUsesLisp

ReinUsesLisp Sep 21, 2019

Contributor

This should go inside a separated function:

bool StepInstance(MMEDrawMode expected_mode, u32 count) {
    if (mme_draw.current_mode == MMEDrawMode::Undefined) {
        // ...
        return false;
    }
    if (mme_draw.current_mode == expected_mode) {
        // ...
        return false;
    }
    FlushMMEInlineDraw();
    return true;
}
@@ -1263,6 +1269,21 @@ class Maxwell3D final {
return execute_on;
}

enum class MMMEDrawMode : u32 {

This comment has been minimized.

Copy link
@ReinUsesLisp

ReinUsesLisp Sep 21, 2019

Contributor

Typo for MMEDrawMode?


auto& maxwell3d = system.GPU().Maxwell3D();
if (!maxwell3d.ShouldExecute()) {
return false;

This comment has been minimized.

Copy link
@ReinUsesLisp

ReinUsesLisp Sep 21, 2019

Contributor

This should return true, since we are "accelerating" (whatever that means nowadays) the draw. I would do two things:

  1. Move this check to Maxwell3D and remove ShouldExecute.
  2. Make DrawBatch return void. If we ever write a software backend, it would be with the same interface as RasterizerOpenGL, it won't be implemented in the caller.
@ReinUsesLisp ReinUsesLisp added the opengl label Sep 21, 2019
virtual void DrawArrays() = 0;
virtual bool DrawBatch(bool is_indexed) = 0;

/// Draw the current batch of multiple instasnces of vertex arrays

This comment has been minimized.

Copy link
@MysticExile

MysticExile Sep 21, 2019

Contributor
Suggested change
/// Draw the current batch of multiple instasnces of vertex arrays
/// Draw the current batch of multiple instances of vertex arrays

Nit: Spelling error

Copy link
Contributor

left a comment

lgtm

@ogniK5377 ogniK5377 merged commit 9d69206 into yuzu-emu:master Sep 22, 2019
5 checks passed
5 checks passed
yuzu verify Build #20190922.18 succeeded
Details
yuzu verify (build standard linux) build standard linux succeeded
Details
yuzu verify (build standard windows) build standard windows succeeded
Details
yuzu verify (build testing windows) build testing windows succeeded
Details
yuzu verify (format clang) format clang succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.