Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3

Author Topic: DF Accelerator, Windows edition  (Read 4509 times)

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
DF Accelerator, Windows edition
« on: November 08, 2008, 06:36:38 pm »

« Last Edit: November 25, 2008, 04:26:48 am by Baughn »
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #1 on: November 08, 2008, 06:42:22 pm »

Technical details, for the overly curious:

The only reason this hack is needed at all is because DF does a lousy job at rendering. To put it simply, its printing algorithm works as follows:

For each tile, draw its background color. Then draw the actual tile, in the foreground.

Afterwards, flip the buffer so they actually go on-screen. (This is a problem - they should not go on-screen before, and depending on the driver it may be storing an awful lot of details for later use.)

Well, the algorithm's not really a problem in itself. The problem is that it uses immediate-mode opengl rendering to do this, which was deprecated somewhat over a decade ago and is now horribly slow on all but the best drivers. As gamers who don't buy workstation boards, we don't have the best drivers. There are, of course, better ways to do this, but DF doesn't use them.

Solution: Write a library that shimmies between DF and OpenGL, intercepts DF's calls, figures out what they are trying to draw, and draws them using better techniques. That's what I'm doing.

To be more specific, I'm building a tile catalog to upload as a single texture (as opposed to the single-tile-per-texture scheme used by DF - this is why fullscreen toggling doesn't work, by the way), once, and then once per frame I'm gathering all those tile-drawing calls into an array which I'm uploading as a "texture" to the GPU once per frame. I then have a pixel shader read both textures, using the second to decide which tile from the first to draw, as well as in which color.

This reduces the number of opengl calls to something like four per frame, as opposed to the 60,000 I often saw from DF before.

Well, if there are any questions... it's late, I'm going to sleep, but I'll do my best to answer them tomorrow. Have fun.
« Last Edit: November 08, 2008, 06:55:31 pm by Baughn »
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #2 on: November 08, 2008, 07:21:29 pm »

<deleted>
« Last Edit: November 08, 2008, 07:24:49 pm by Baughn »
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Rysith

  • Bay Watcher
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #3 on: November 08, 2008, 10:59:59 pm »

How much of an acceleration should we see using this? I'm just asking since I thought a lot of DF's slowing down issues were with pathing and flows, which it doesn't seem like this would help with. 4 rather than 60,000 definitely seems like a good thing, I'll try it out and report my results.

EDIT: I'm running windowed, no graphical tileset, partial print yes:0, and window settings at
Code: [Select]
[WINDOWEDX:1400]
[WINDOWEDY:840]
[FONT:curses_640x300.bmp]

It shows up as a mess in the upper-left corner of my window, clearly enough that I can navigate to the "quit" menu option but nothing beyond that. I tried turning on graphical tile sets, using
Code: [Select]
[GRID:75:75]

[GRAPHICS:YES]
[GRAPHICS_WINDOWEDX:1200]
[GRAPHICS_WINDOWEDY:1200]
[GRAPHICS_FONT:curses_square_16x16.bmp]

And I was able to view the intro and such, though with some missing letters ("Armok: God o Blood"), then crashed loading the world. Any ideas?
« Last Edit: November 08, 2008, 11:18:26 pm by Rysith »
Logged
Lanternwebs: a community fort
Try my orc mod!
The OP deserves the violent Dwarven equivalent of the Nobel Peace Prize.

William

  • Bay Watcher
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #4 on: November 08, 2008, 11:54:28 pm »

I've tried it, it works, but I'm having problems with random letters missing.
Logged

penguinofhonor

  • Bay Watcher
  • Minister of Love
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #5 on: November 09, 2008, 12:02:19 am »

Mine doesn't work at all. I have an 8x8 tileset, [BLACK_SPACE] is set to YES, and I've followed all the other rules. But I just open DF, and then it sits there with a black screen for a couple seconds, then crashes.
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #6 on: November 09, 2008, 05:19:03 am »

How much of an acceleration should we see using this? I'm just asking since I thought a lot of DF's slowing down issues were with pathing and flows, which it doesn't seem like this would help with. 4 rather than 60,000 definitely seems like a good thing, I'll try it out and report my results.
Depends on how much CPU time is being spent drawing. I personally see pretty much no speedup at all, but others have reported speedups from 20% to 50%.

Try looking at how much CPU time DF spends when idling at the main menu, with partial-print off; that's the most you could possibly save.

Quote
EDIT: I'm running windowed, no graphical tileset, partial print yes:0, and window settings at
Code: [Select]
[WINDOWEDX:1400]
[WINDOWEDY:840]
[FONT:curses_640x300.bmp]
Right. Sorry, but you're supposed to use an 8x8 or 16x16 font; that one isn't.

Quote
It shows up as a mess in the upper-left corner of my window, clearly enough that I can navigate to the "quit" menu option but nothing beyond that. I tried turning on graphical tile sets, using
Code: [Select]
[GRID:75:75]

[GRAPHICS:YES]
[GRAPHICS_WINDOWEDX:1200]
[GRAPHICS_WINDOWEDY:1200]
[GRAPHICS_FONT:curses_square_16x16.bmp]

And I was able to view the intro and such, though with some missing letters ("Armok: God o Blood"), then crashed loading the world. Any ideas?
Graphical tilesets just aren't supported, and would probably confuse the shim rather badly, thus the crash. You should try using curses_square_16x16 as a normal tileset.

For the missing letters, that's a typical consequence of not having the grid size match up with the window size. I could probably fix it pretty easily; I'll look into that later.
« Last Edit: November 09, 2008, 05:25:46 am by Baughn »
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #7 on: November 09, 2008, 05:19:57 am »

Mine doesn't work at all. I have an 8x8 tileset, [BLACK_SPACE] is set to YES, and I've followed all the other rules. But I just open DF, and then it sits there with a black screen for a couple seconds, then crashes.
Can you post your init.txt? Well, all the lines that have to do with graphics in some form?
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #8 on: November 09, 2008, 05:20:53 am »

I've tried it, it works, but I'm having problems with random letters missing.
See my earlier reply to Rysith.

Are they missing based on location, or contents?
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

penguinofhonor

  • Bay Watcher
  • Minister of Love
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #9 on: November 09, 2008, 12:23:58 pm »

Code: [Select]
[WINDOWEDX:840]
[WINDOWEDY:360]
[FONT:customsmall.bmp]

[BLACK_SPACE:YES]

[GRAPHICS:NO]

[GRID:105:45]

[PARTIAL_PRINT:YES:10]

[FPS_CAP:100]

[G_FPS_CAP:12]

That's everything important. The tileset is 8x8, I assure you.
Logged

William

  • Bay Watcher
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #10 on: November 09, 2008, 12:37:55 pm »

They are missing based on contents. I'll take a screen capture for you. I tried using different char sets too with the same result.
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #11 on: November 09, 2008, 12:46:43 pm »

They are missing based on contents. I'll take a screen capture for you. I tried using different char sets too with the same result.

Are you sure? I see some missing es there, with several others in place. Please post the same information the honorable penguin just did.
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

penguinofhonor

  • Bay Watcher
  • Minister of Love
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #12 on: November 09, 2008, 12:55:02 pm »

William, you didn't get a glitch. You've just discovered Engrish Fortress.
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #13 on: November 09, 2008, 12:57:54 pm »

Code: [Select]
[WINDOWEDX:840]
[WINDOWEDY:360]
[FONT:customsmall.bmp]

[BLACK_SPACE:YES]

[GRAPHICS:NO]

[GRID:105:45]

[PARTIAL_PRINT:YES:10]

[FPS_CAP:100]

[G_FPS_CAP:12]

That's everything important. The tileset is 8x8, I assure you.

Your setup is correct; the wrapper is mistaken.
For some reason this didn't happen on OS X.. eh. What's happening is that DF is passing me 16x16 textures, even when the tiles are actually 8x8. I'm going to have to look at the actual texture coordinates to fix this - this is okay, since I was going to use the initial (non-partial) pass as part of the setup routine to support skewed/scaled resolutions too.

Meanwhile, all I can suggest is that you use a 16x16 font. It appears that that's all that will work.

EDIT: Hold that thought.
I made a custom version anyway to verify this, so if you go look in the dfacc_win directory again (link on top), you'll find a penguinofhonor directory. The opengl32.dll in there is hardcoded to work (only) with 8x8 fonts
« Last Edit: November 09, 2008, 01:00:50 pm by Baughn »
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

William

  • Bay Watcher
    • View Profile
Re: DF Accelerator, Windows edition
« Reply #14 on: November 09, 2008, 01:01:55 pm »

[WINDOWEDX:800]
[WINDOWEDY:608]
[FONT:redjack17o.bmp]
[BLACK_SPACE:YES]
[GRAPHICS:NO]
[GRID:50:38]
[PARTIAL_PRINT:YES:0]
[FPS_CAP:100]
[G_FPS_CAP:10]
Logged
Pages: [1] 2 3