mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 04:38:18 +07:00
Experimental: mitigate texture swapping with TextureArraySpriteBatch (#8604)
* Performance optimization: less texture swapping * Added experimental setting to Options-Display --------- Co-authored-by: tunerzinc@gmail.com <vfylfhby>
This commit is contained in:
@ -1359,6 +1359,8 @@ Show unit movement arrows =
|
|||||||
# Requires translation!
|
# Requires translation!
|
||||||
Continuous rendering =
|
Continuous rendering =
|
||||||
# Requires translation!
|
# Requires translation!
|
||||||
|
Experimental rendering improvements =
|
||||||
|
# Requires translation!
|
||||||
When disabled, saves battery life but certain animations will be suspended =
|
When disabled, saves battery life but certain animations will be suspended =
|
||||||
# Requires translation!
|
# Requires translation!
|
||||||
Order trade offers by amount =
|
Order trade offers by amount =
|
||||||
|
@ -732,6 +732,7 @@ Enable display cutout (requires restart) =
|
|||||||
Show tile yields =
|
Show tile yields =
|
||||||
Show unit movement arrows =
|
Show unit movement arrows =
|
||||||
Continuous rendering =
|
Continuous rendering =
|
||||||
|
Experimental rendering improvements =
|
||||||
When disabled, saves battery life but certain animations will be suspended =
|
When disabled, saves battery life but certain animations will be suspended =
|
||||||
Order trade offers by amount =
|
Order trade offers by amount =
|
||||||
Ask for confirmation when pressing next turn =
|
Ask for confirmation when pressing next turn =
|
||||||
|
@ -62,6 +62,7 @@ class GameSettings {
|
|||||||
val showPixelUnits: Boolean get() = unitSet != null
|
val showPixelUnits: Boolean get() = unitSet != null
|
||||||
var showPixelImprovements: Boolean = true
|
var showPixelImprovements: Boolean = true
|
||||||
var continuousRendering = false
|
var continuousRendering = false
|
||||||
|
var experimentalRendering = false
|
||||||
var orderTradeOffersByAmount = true
|
var orderTradeOffersByAmount = true
|
||||||
var confirmNextTurn = false
|
var confirmNextTurn = false
|
||||||
var windowState = WindowState()
|
var windowState = WindowState()
|
||||||
|
@ -1,18 +1,37 @@
|
|||||||
package com.unciv.ui
|
package com.unciv.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.math.Rectangle
|
import com.badlogic.gdx.math.Rectangle
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport
|
import com.badlogic.gdx.utils.viewport.Viewport
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.event.Event
|
import com.unciv.logic.event.Event
|
||||||
import com.unciv.logic.event.EventBus
|
import com.unciv.logic.event.EventBus
|
||||||
import com.unciv.ui.crashhandling.wrapCrashHandling
|
import com.unciv.ui.crashhandling.wrapCrashHandling
|
||||||
import com.unciv.ui.crashhandling.wrapCrashHandlingUnit
|
import com.unciv.ui.crashhandling.wrapCrashHandlingUnit
|
||||||
|
import com.unciv.ui.utils.TextureArraySpriteBatch
|
||||||
import com.unciv.utils.Log
|
import com.unciv.utils.Log
|
||||||
|
|
||||||
|
|
||||||
/** Main stage for the game. Catches all exceptions or errors thrown by event handlers, calling [com.unciv.UncivGame.handleUncaughtThrowable] with the thrown exception or error. */
|
/** Main stage for the game. Catches all exceptions or errors thrown by event handlers, calling [com.unciv.UncivGame.handleUncaughtThrowable] with the thrown exception or error. */
|
||||||
class UncivStage(viewport: Viewport) : Stage(viewport) {
|
class UncivStage(viewport: Viewport) : Stage(viewport, getBatch()) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getBatch(size: Int=1000): Batch {
|
||||||
|
// If for some reason it fails, we resort to usual SpriteBatch
|
||||||
|
return if (UncivGame.Current.settings.experimentalRendering) {
|
||||||
|
try {
|
||||||
|
TextureArraySpriteBatch(size)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
SpriteBatch(size)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SpriteBatch(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables/disables sending pointer enter/exit events to actors on this stage.
|
* Enables/disables sending pointer enter/exit events to actors on this stage.
|
||||||
|
@ -69,6 +69,11 @@ fun displayTab(
|
|||||||
continuousRenderingLabel.wrap = true
|
continuousRenderingLabel.wrap = true
|
||||||
add(continuousRenderingLabel).colspan(2).padTop(10f).row()
|
add(continuousRenderingLabel).colspan(2).padTop(10f).row()
|
||||||
|
|
||||||
|
optionsPopup.addCheckbox(this, "Experimental rendering improvements", settings.experimentalRendering) {
|
||||||
|
settings.experimentalRendering = it
|
||||||
|
onChange()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMinimapSizeSlider(table: Table, settings: GameSettings, selectBoxMinWidth: Float) {
|
private fun addMinimapSizeSlider(table: Table, settings: GameSettings, selectBoxMinWidth: Float) {
|
||||||
|
1440
core/src/com/unciv/ui/utils/TextureArraySpriteBatch.java
Normal file
1440
core/src/com/unciv/ui/utils/TextureArraySpriteBatch.java
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user