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 render info counters for the 2D renderer #85811

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Dec 5, 2023

This provides information for the debug monitors for 2D objects.

For now all the draw data is compiled together for the performance monitors to maintain consistency with previous versions, but it can be reported separately if the information is pulled from viewport_get_render_info().

Fixes: #8373 (6 year old bug report 👀)

RD renderer (note draw calls and objects drawn are the same):
Screenshot from 2023-12-05 16-46-45

Compatibility renderer:
Screenshot from 2023-12-05 16-40-40

@clayjohn clayjohn added this to the 4.3 milestone Dec 5, 2023
@clayjohn clayjohn requested a review from a team as a code owner December 5, 2023 23:55
@clayjohn clayjohn requested a review from a team as a code owner December 6, 2023 01:16
@Zireael07
Copy link
Contributor

Finally!

Copy link
Member

@lawnjelly lawnjelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

In long run would be nice to report separately from 3D as in the amazing work in 3.x.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally with all rendering methods, it works as expected.

image

It's interesting to note two things about 2D rendering (these apply to all rendering methods):

  • A Label with a single character thas has no font outline or shadow results in 6 primitives drawn. I'd expect 2 primitives to be drawn per character instead. An empty Label doesn't result in any primitives or draw calls as expected.
  • Invisible characters such as spaces add the same number of draw calls/primitives as visible characters. I'd expect these to not have to be drawn, though bitmap fonts could in theory make these visible (I'm not aware of any such fonts).

This provides information for the debug monitors
@clayjohn
Copy link
Member Author

clayjohn commented Dec 6, 2023

  • A Label with a single character thas has no font outline or shadow results in 6 primitives drawn. I'd expect 2 primitives to be drawn per character instead. An empty Label doesn't result in any primitives or draw calls as expected.

That was an oversight on my part. I forgot to add the conversion from Vertex/Index to "primitive"

  • Invisible characters such as spaces add the same number of draw calls/primitives as visible characters. I'd expect these to not have to be drawn, though bitmap fonts could in theory make these visible (I'm not aware of any such fonts).

That seems odd, but it must be coming from the font system as the renderer doesn't detect if the section of a texture being used is fully transparent

@Calinou
Copy link
Member

Calinou commented Dec 6, 2023

That seems odd, but it must be coming from the font system as the renderer doesn't detect if the section of a texture being used is fully transparent

@bruvzg Any ideas about this?

@akien-mga
Copy link
Member

That seems odd, but it must be coming from the font system as the renderer doesn't detect if the section of a texture being used is fully transparent

@bruvzg Any ideas about this?

I suggest opening a bug report about this, as I'll merge this PR now :)

@akien-mga akien-mga merged commit 3425315 into godotengine:master Dec 12, 2023
@akien-mga
Copy link
Member

Thanks!

@Ostreicher
Copy link

not working for me. i get zero objects drawn like here #74060 (comment)
print(get_viewport().get_render_info(Viewport.RENDER_INFO_TYPE_VISIBLE,Viewport.RENDER_INFO_DRAW_CALLS_IN_FRAME))
0

@AThousandShips
Copy link
Member

AThousandShips commented Mar 23, 2024

What version are you on? If you're on 4.2 or 4.1 this isn't available, this is 4.3 only

Also this one is different, this isn't the same, this isn't supported for that method at the moment, you should use:

print(RenderingServer.viewport_get_render_info(get_viewport().get_viewport_rid(), RenderingServer.VIEWPORT_RENDER_INFO_TYPE_CANVAS, RenderingServer.VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME))

@AThousandShips
Copy link
Member

I'll go ahead and open a PR for adding the equivalent to Viewport

@Ostreicher
Copy link

ty ! i am indeed using 4.2, didn't see it was 4.3 sorry. thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance monitors dont report any values for 2D projects
7 participants