Skip to content

Commit

Permalink
Make the ArrayTexture and TextureArray demos...
Browse files Browse the repository at this point in the history
... actually comparable to the non-array-based demo, including emoji in a TypingSelectBox. Only ArrayTextureSpriteBatch seems significantly faster most of the time; TextureArraySpriteBatch sometimes starts off weirdly-slowly and never catches up.
  • Loading branch information
tommyettinger committed Mar 3, 2025
1 parent be9a807 commit cd05145
Show file tree
Hide file tree
Showing 42 changed files with 149 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.StringBuilder;
import java.util.ArrayList;

import static com.badlogic.gdx.math.MathUtils.round;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.github.tommyettinger.textra.utils.ColorUtils;

import java.lang.StringBuilder;
import java.util.Arrays;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.StringBuilder;
import java.util.ArrayList;

import static com.badlogic.gdx.math.MathUtils.round;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
Expand All @@ -47,12 +46,12 @@ public class GSTypingUITest extends InputAdapter implements ApplicationListener
Texture texture1;
Texture texture2;
TypingLabel fpsLabel;
GLProfiler profiler;
// GLProfiler profiler;

@Override
public void create () {
profiler = new GLProfiler(Gdx.graphics);
profiler.enable();
// profiler = new GLProfiler(Gdx.graphics);
// profiler.enable();
skin = new FreeTypistSkin(Gdx.files.internal("gs/skin.json"));
texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
Expand Down Expand Up @@ -211,7 +210,7 @@ public void changed (ChangeEvent event, Actor actor) {

@Override
public void render () {
profiler.reset();
// profiler.reset();
ScreenUtils.clear(0.2f, 0.2f, 0.2f, 1);

String s = String.valueOf(Gdx.graphics.getFramesPerSecond());
Expand All @@ -225,10 +224,10 @@ public void render () {
fpsLabel.rotateBy(Gdx.graphics.getDeltaTime() * 25f);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
if(Gdx.input.isKeyJustPressed(Keys.SPACE))
System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
profiler.getCalls(), profiler.getDrawCalls(),
profiler.getShaderSwitches(), profiler.getTextureBindings());
// if(Gdx.input.isKeyJustPressed(Keys.SPACE))
// System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
// profiler.getCalls(), profiler.getDrawCalls(),
// profiler.getShaderSwitches(), profiler.getTextureBindings());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.backends.headless.HeadlessApplication;
import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

public class HeadlessTest extends ApplicationAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
package com.github.tommyettinger.textra;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.ScreenUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
Expand All @@ -47,12 +46,12 @@ public class MBTypingUITest extends InputAdapter implements ApplicationListener
Texture texture1;
Texture texture2;
TypingLabel fpsLabel;
GLProfiler profiler;
// GLProfiler profiler;

@Override
public void create () {
profiler = new GLProfiler(Gdx.graphics);
profiler.enable();
// profiler = new GLProfiler(Gdx.graphics);
// profiler.enable();
skin = new FWSkin(Gdx.files.internal("mb/eight.json"));
texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
Expand Down Expand Up @@ -219,7 +218,7 @@ public void changed (ChangeEvent event, Actor actor) {

@Override
public void render () {
profiler.reset();
// profiler.reset();
ScreenUtils.clear(0.2f, 0.2f, 0.2f, 1);

String s = String.valueOf(Gdx.graphics.getFramesPerSecond());
Expand All @@ -233,10 +232,10 @@ public void render () {
fpsLabel.rotateBy(Gdx.graphics.getDeltaTime() * 25f);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
if(Gdx.input.isKeyJustPressed(Keys.SPACE))
System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
profiler.getCalls(), profiler.getDrawCalls(),
profiler.getShaderSwitches(), profiler.getTextureBindings());
// if(Gdx.input.isKeyJustPressed(Keys.SPACE))
// System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
// profiler.getCalls(), profiler.getDrawCalls(),
// profiler.getShaderSwitches(), profiler.getTextureBindings());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
Expand All @@ -49,12 +48,12 @@ public class NewTextraUITest extends InputAdapter implements ApplicationListener
Texture texture1;
Texture texture2;
TextraLabel fpsLabel;
GLProfiler profiler;
// GLProfiler profiler;

@Override
public void create () {
profiler = new GLProfiler(Gdx.graphics);
profiler.enable();
// profiler = new GLProfiler(Gdx.graphics);
// profiler.enable();
skin = new FreeTypistSkin(Gdx.files.internal("uiskin2.json"));
texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
Expand Down Expand Up @@ -202,18 +201,18 @@ public void changed (ChangeEvent event, Actor actor) {

@Override
public void render () {
profiler.reset();
// profiler.reset();
ScreenUtils.clear(0.2f, 0.2f, 0.2f, 1);

fpsLabel.getFont().markup("fps: " + Gdx.graphics.getFramesPerSecond() + "[^][SKY][[citation needed]", fpsLabel.layout.clear());
fpsLabel.rotateBy(Gdx.graphics.getDeltaTime() * 25f);

stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
if(Gdx.input.isKeyJustPressed(Keys.SPACE))
System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
profiler.getCalls(), profiler.getDrawCalls(),
profiler.getShaderSwitches(), profiler.getTextureBindings());
// if(Gdx.input.isKeyJustPressed(Keys.SPACE))
// System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
// profiler.getCalls(), profiler.getDrawCalls(),
// profiler.getShaderSwitches(), profiler.getTextureBindings());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
Expand All @@ -47,12 +46,12 @@ public class NewTypingUITest extends InputAdapter implements ApplicationListener
Texture texture1;
Texture texture2;
TypingLabel fpsLabel;
GLProfiler profiler;
// GLProfiler profiler;

@Override
public void create () {
profiler = new GLProfiler(Gdx.graphics);
profiler.enable();
// profiler = new GLProfiler(Gdx.graphics);
// profiler.enable();
skin = new FreeTypistSkin(Gdx.files.internal("uiskin2.json"));
texture1 = new Texture(Gdx.files.internal("badlogicsmall.jpg"));
texture2 = new Texture(Gdx.files.internal("badlogic.jpg"));
Expand Down Expand Up @@ -200,7 +199,7 @@ public void changed (ChangeEvent event, Actor actor) {

@Override
public void render () {
profiler.reset();
// profiler.reset();
ScreenUtils.clear(0.2f, 0.2f, 0.2f, 1);

String s = String.valueOf(Gdx.graphics.getFramesPerSecond());
Expand All @@ -214,10 +213,10 @@ public void render () {
fpsLabel.rotateBy(Gdx.graphics.getDeltaTime() * 25f);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
if(Gdx.input.isKeyJustPressed(Keys.SPACE))
System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
profiler.getCalls(), profiler.getDrawCalls(),
profiler.getShaderSwitches(), profiler.getTextureBindings());
// if(Gdx.input.isKeyJustPressed(Keys.SPACE))
// System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d\n",
// profiler.getCalls(), profiler.getDrawCalls(),
// profiler.getShaderSwitches(), profiler.getTextureBindings());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
Expand All @@ -50,12 +49,12 @@ public class RafaTypingUITest extends InputAdapter implements ApplicationListene
Texture texture2;
com.rafaskoberg.gdx.typinglabel.TypingLabel fpsLabel;
TextTooltip ttt;
GLProfiler profiler;
// GLProfiler profiler;

@Override
public void create () {
profiler = new GLProfiler(Gdx.graphics);
profiler.enable();
// profiler = new GLProfiler(Gdx.graphics);
// profiler.enable();
skin = new FreeTypistSkin(Gdx.files.internal("uiskin2.json"));
// skin = new FWSkin(Gdx.files.internal("uiskin3.json"));
// skin = new FWSkin(Gdx.files.internal("uiskin4.json"));
Expand Down Expand Up @@ -204,7 +203,7 @@ public void changed (ChangeEvent event, Actor actor) {

@Override
public void render () {
profiler.reset();
// profiler.reset();
ScreenUtils.clear(0.2f, 0.2f, 0.2f, 1);

fpsLabel.restart(String.valueOf(Gdx.graphics.getFramesPerSecond()));
Expand All @@ -222,11 +221,11 @@ public void render () {
// }
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
if(Gdx.input.isKeyJustPressed(Keys.SPACE))
System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d, FPS: %d\n",
profiler.getCalls(), profiler.getDrawCalls(),
profiler.getShaderSwitches(), profiler.getTextureBindings(),
Gdx.graphics.getFramesPerSecond());
// if(Gdx.input.isKeyJustPressed(Keys.SPACE))
// System.out.printf("Calls: %d, draw calls: %d, shader switches: %d, texture bindings: %d, FPS: %d\n",
// profiler.getCalls(), profiler.getDrawCalls(),
// profiler.getShaderSwitches(), profiler.getTextureBindings(),
// Gdx.graphics.getFramesPerSecond());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.badlogic.gdx.scenes.scene2d.ui.Value;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

public class ResizeTestApplication extends ApplicationAdapter {
Expand Down
Loading

0 comments on commit cd05145

Please sign in to comment.