0
\$\begingroup\$

I have a java code (game) which runs at 3200 frames per second on my PC. On my laptop, it runs with 100 frames per second, despite the fact they have very similar hardware.

I think the issue might be related to the GPU, since on the laptop it never uses the dedicated GPU.

I know this is a complex question so I will try to give every information regarding this issue.

Originally, the laptop only had 30 FPS, which grow to 50 FPS after changing the preferred GPU in nvidia settings.

After fully disabling the integrated GPU, the FPS went from 50 to 100, still, is nowhere close to the PC.

The PC has around 30% GPU usage when running the game.

The laptop has 0% GPU usage when running the game.

Both machines have the same java version.

I tried it on a second laptop, with 1 integrated GPU and 1 dedicated GPU, it fully behaved like the first laptop. (no GPU usage, low FPS)

I do not understand.

Thank you.

EDIT:

The code below alone lags on the laptops.

int xStart = (int) Math.max(0, handler.getGameCamera().getxOffset() / Tile.TILEWIDTH);
    int xEnd = (int) Math.min(width, (handler.getGameCamera().getxOffset()
        + handler.getWidth()) / Tile.TILEWIDTH + 1);
    int yStart = (int) Math.max(0, handler.getGameCamera().getyOffset() / Tile.TILEHEIGHT);
    int yEnd = (int) Math.min(height, (handler.getGameCamera().getyOffset()
        + handler.getHeight()) / Tile.TILEHEIGHT + 1);


    for(int y = yStart; y < yEnd; y++) {
        for(int x = xStart; x < xEnd; x++) {
            getTile(x, y).render(g, (int) (x * Tile.TILEWIDTH
                - handler.getGameCamera().getxOffset()),
                (int) (y * Tile.TILEHEIGHT - handler.getGameCamera().getyOffset()));
        }
    }
```
\$\endgroup\$
9
  • \$\begingroup\$ Can you show us a snippet of how your game code leverages the GPU? \$\endgroup\$ Commented Sep 21, 2019 at 13:25
  • \$\begingroup\$ @DMGregory Sorry i think I misunderstood the question, how can I show you that? \$\endgroup\$ Commented Sep 21, 2019 at 16:44
  • \$\begingroup\$ What does getTile return? \$\endgroup\$ Commented Sep 21, 2019 at 16:49
  • \$\begingroup\$ Tile t = Tile.tiles[tiles[x][y]]; if(t == null) return Tile.grass_full; return t; \$\endgroup\$ Commented Sep 21, 2019 at 16:54
  • \$\begingroup\$ And thats the tile object's render method it's nothing special: g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); \$\endgroup\$ Commented Sep 21, 2019 at 16:55

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.