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

Further optimize rendering methods #579

Merged
merged 11 commits into from
Apr 3, 2024

Conversation

BenCheung0422
Copy link
Member

This change performs well together with #523 and #524.
As a minor change, there is no longer an error popup when there is any explicitly or implicitly incompatible images regarding their sizes. Instead, a warning message is rendered in the terminal.
Due to the change to the compatibility of the rendering of the on-screen keyboard, the textures of the special keys are updated and saved as assets instead of being constructed on demand in runtime. It is mainly because the visibility of Screen#pixels is decreased,
There is no longer a light screen constructed with Screen. Instead, an object representing the overlay is present in the screen object.
Other minor changes:

  • Screen is constructed with a parameter of BufferedImage instead of using the initialization method #init(int[]) to initialize the pixel array.
  • Screen now stores BufferedImage for the ability to render through Graphics2D on the image object.
  • Most of the rendering methods except sprite rendering (compatibility problem) are replaced by using Graphics2D provided method.
  • Methods to render an arbitrary size of area of MinicraftImage are added, because of the change to the on-screen keyboard.
  • All methods to render now add queues instead of being rendered instantaneously. All the renderings are executed only when Screen#flush() is called and all processes before the latest screen clean rendering are eliminated.
  • The drop in FPS on the world surface is significantly diminished.

Some methods may be still using array looping to render.

As a result, the CPU run time has been improved.
The below comparison is tested based on my personal computer.
Comparing with the current implementation (with #523):

  • Before entering a world: improved by around 50%
  • In world: improved by around 30%
    Comparing with Add hardware acceleration setting #524 added (comparing without this pull request):
  • Before entering a world: improved by around 60%
  • In world: no obvious change

Aparapi Kernel transformation of rendering methods: stage 1
Added appropriate exceptions and handles for compatibility validation.
Aparapi Kernel transformation of rendering methods: stage 2
Aparapi is removed by the efficiency and necessarity.
All the rendering funtions are replaced with either Graphics2D API or raw array looping.
# Conflicts:
#	src/client/java/minicraft/gfx/MinicraftImage.java
#	src/client/java/minicraft/gfx/Screen.java
#	src/client/java/minicraft/screen/OnScreenKeyboardMenu.java
#	src/client/java/minicraft/screen/QuestsDisplay.java
#	src/client/java/minicraft/screen/SkinDisplay.java
#	src/client/java/minicraft/screen/TutorialDisplayHandler.java
@Litorom
Copy link
Member

Litorom commented Apr 2, 2024

Fix Conflicts and I’ll merge

BenCheung0422 and others added 4 commits April 3, 2024 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants