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

gl_DrawCalss from Renderables overdraws so much Dune2 mod #17130

Open
alexeik opened this issue Sep 19, 2019 · 9 comments

Comments

@alexeik
Copy link

commented Sep 19, 2019

blendmode

then this Flush disabled
we got constant batchrate=8 on left and variable batchrate on right with Enabled.
on bleed branch(assume it is left sided) we will have batchrate=11 not 8. because of prev issues for gl_DrawCalls in SmudgeLayers & BuildableTerrainLayer.

below animated gif.
2019-09-19_19h27_01

@pchote

This comment has been minimized.

Copy link
Member

commented Sep 19, 2019

What is the actual problem you are trying to raise with these issues?

When a mod switches drawing modes the engine is forced to flush the buffed draw calls. This is fundamental to the way rendering works, and is not a serious issue at small batch counts. The right hand plot shows an anomalously large batch count, but I don’t understand from your description what you have done to achieve this.

@alexeik

This comment has been minimized.

Copy link
Author

commented Sep 19, 2019

to make batch count value on right, just downloaded bleed branch and run.

@alexeik

This comment has been minimized.

Copy link
Author

commented Sep 19, 2019

im just do some stuff in dune2, and notice this anomalous.
now i rerun official mods and there are normal batches.
but in dune2 mod, its as on animation above.
Sprites comes with variable BlendMode and it forces to call gl_DrawCalls too much.

@alexeik alexeik changed the title gl_DrawCalss from Renderables overdraws so much) gl_DrawCalss from Renderables overdraws so much Dune2 mod Sep 19, 2019
@GraionDilach

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2019

@alexeik The default blendmode is not None but Alpha. So if an entry lacks the blendmode and another has None, the switch makes sense. Also, D2k also comes with different blending modes, so that should also be affected.

@pchote: What I interpret is that there are just too many context switches from the usage of different blendmodes. Could the renderables be reordered somehow to decrease the amount of flushing required, or would that interfere with the Z-ordering?

@alexeik

This comment has been minimized.

Copy link
Author

commented Sep 20, 2019

how to set BlendMode for sprite? yaml or what part ?
need some test to make a batch test of sprites in my Mod to decrease calling gl_DrawCalls.
I think that Dune2 even do not use BlendMode in drawing. That allows to turnoff completly this option.

@GraionDilach

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2019

BlendModes are set in YAML - https://github.com/OpenRA/d2/search?l=YAML&q=blendmode - which correspond to

switch (mode)
{
case BlendMode.None:
OpenGL.glDisable(OpenGL.GL_BLEND);
break;
case BlendMode.Alpha:
OpenGL.glEnable(OpenGL.GL_BLEND);
OpenGL.CheckGLError();
OpenGL.glBlendFunc(OpenGL.GL_ONE, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
break;
case BlendMode.Additive:
case BlendMode.Subtractive:
OpenGL.glEnable(OpenGL.GL_BLEND);
OpenGL.CheckGLError();
OpenGL.glBlendFunc(OpenGL.GL_ONE, OpenGL.GL_ONE);
if (mode == BlendMode.Subtractive)
{
OpenGL.CheckGLError();
OpenGL.glBlendEquationSeparate(OpenGL.GL_FUNC_REVERSE_SUBTRACT, OpenGL.GL_FUNC_ADD);
}
break;
case BlendMode.Multiply:
OpenGL.glEnable(OpenGL.GL_BLEND);
OpenGL.CheckGLError();
OpenGL.glBlendFunc(OpenGL.GL_DST_COLOR, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
OpenGL.CheckGLError();
break;
case BlendMode.Multiplicative:
OpenGL.glEnable(OpenGL.GL_BLEND);
OpenGL.CheckGLError();
OpenGL.glBlendFunc(OpenGL.GL_ZERO, OpenGL.GL_SRC_COLOR);
break;
case BlendMode.DoubleMultiplicative:
OpenGL.glEnable(OpenGL.GL_BLEND);
OpenGL.CheckGLError();
OpenGL.glBlendFunc(OpenGL.GL_DST_COLOR, OpenGL.GL_SRC_COLOR);
break;
.

@alexeik

This comment has been minimized.

Copy link
Author

commented Sep 20, 2019

its like a blend sprites between map tiles sprites?

@GraionDilach

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2019

@pchote Watching the main menu of the Dune 2 mod with pixel doubling mode leads to a constant 40 batches per second on my system after the harvesters arrive and start doing their job (both on OpenRA/d2#146 and on the release-20190314 version). No changes in code were made.

image

Ignore the huge rendering time, I have VSync enabled within the NVidia driver and that throws off the rendering graphs.

@alexeik

This comment has been minimized.

Copy link
Author

commented Sep 25, 2019

@GraionDilach the cause is Renderables with different BlendMode.
Wait till scenario of shellmap ends and u will see 9-11 batches constantly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.