October 18, 2019, 10:59:24 AM

Author Topic: Creating "Graphics" Slow  (Read 490 times)

Offline therevills

  • Hero Member
  • *****
  • Posts: 570
Creating "Graphics" Slow
« on: July 27, 2019, 05:19:08 AM »
I've been noticing that creating graphics on vanilla BlitzMax is pretty slow these days, maybe it's a Windows 10 thing or a driver thing but on my PC it now takes over 3 seconds to create 1920x1080:

Code: [Select]
Building untitled1
Compiling:untitled1.bmx
flat assembler  version 1.69.14  (1048560 kilobytes memory)
3 passes, 3067 bytes.
Linking:untitled1.exe
Executing:untitled1.exe
Creating graphics 1920 x 1080 with depth 32 at 60hz
Time taken = 3095

Process complete

If anyone else could confirm it, the test case is just this little code:

Code: [Select]
SuperStrict

Local startMs:Int = MilliSecs()

Local width:Int = DesktopWidth()
Local height:Int = DesktopHeight()
Local depth:Int = 32
Local hertz:Int = 60

Print "Creating graphics " + width + " x " + height + " with depth " + depth + " at " + hertz + "hz"

Graphics(width, height, depth, hertz)

Local endMs:Int = MilliSecs()

Print "Time taken = " + (endMs - startMs)

End

Any ideas why its so slow these days?  ???

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Creating "Graphics" Slow
« Reply #1 on: July 27, 2019, 06:13:39 AM »
Exclude the desktopwidth() / desktopheight() and first print command from the measurement.

What happens with other graphics renderers (glmax directx9 and directx11)?


Edit: what happens without the fullscreen mode change? (so without the hertz=60). Maybe the delay comes from some stuff getting "made ready for fullscreen" ?

Bye
Ron

Offline GW

  • Full Member
  • ***
  • Posts: 169
Re: Creating "Graphics" Slow
« Reply #2 on: July 27, 2019, 08:33:42 AM »
I've noticed that creating a fullscreen window is slower in proportion to the number of monitors I have connected.  Are you running multiple displays?

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Creating "Graphics" Slow
« Reply #3 on: July 27, 2019, 08:43:08 AM »

Linux Mint 17.04 XFCE:
Code: [Select]
Building untitled1
[ 20%] Processing:untitled1.bmx
[ 83%] Compiling:untitled1.bmx.console.debug.linux.x86.s
flat assembler  version 1.68  (32768 kilobytes memory)
3 passes, 4441 bytes.
[100%] Linking:untitled1.debug
Executing:untitled1.debug
Creating graphics 3200 x 1200 with depth 32 at 60hz
Time taken = 204

Process complete

Manually enforcing 1920*1080 lead to: Time taken = 689
and the screen was black for 2-3 seconds.

As you see I am using a dual screen monitor.


BTW: with SDL.mod (and so NG) trouble with multi-monitor-setups should be less apparent. With vanilla you can experience funny stuff (cloned display, wrong resolutions, centered across all monitors, ...). Might be related to the they vanilla creates windows.


bye
Ron

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 439
Re: Creating "Graphics" Slow
« Reply #4 on: July 27, 2019, 11:13:34 AM »
I have been having the same issue myself.  I think it has something to do with Windows 10, some update started causing a delay when running certain full screen programs.  I would run programs that were compiled years ago with no problems and now have a delay.  After a few seconds, everything will run normally.

BlitzMax is not the only thing I have problems with.  Most anything I run nowadays at fullscreen have a slight delay at the beginning, maybe even a bit of stutter for a few seconds.  I have been mostly blaming my old, near obsolete computer and a slightly incompatible Win10 update for it.

Windows 10 Home 64
AMD A8-6410 2.0 GHz with AMD Radeon R5 graphics
4.0 GB ram
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline therevills

  • Hero Member
  • *****
  • Posts: 570
Re: Creating "Graphics" Slow
« Reply #5 on: July 28, 2019, 01:24:21 AM »
 I'm using an Nvidia GTX 1080...

Full screen:

Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz
Time taken = 3103

Window Mode:

Code: [Select]
Creating graphics 1920 x 1080 with depth 0 at 60hz
Time taken = 62

Jay over on SoCoder is running on an Intel Onboard and his results were:

Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz
Time taken = 115

Offline therevills

  • Hero Member
  • *****
  • Posts: 570
Re: Creating "Graphics" Slow
« Reply #6 on: July 28, 2019, 01:35:55 AM »
Expanded to use different drivers:

Code: [Select]
SuperStrict

Import srs.D3D11Max2D

Global width:Int = DesktopWidth()
Global height:Int = DesktopHeight()
Global depth:Int = 32
Global hertz:Int = 60

CreateGraphics(0)
CreateGraphics(1)
CreateGraphics(2)
CreateGraphics(3)

Function CreateGraphics(driver:Int)
Local driverString:String

Select driver
Case 0
SetGraphicsDriver GLMax2DDriver()
driverString = "GLMax2DDriver"
Case 1
SetGraphicsDriver D3D7Max2DDriver()
driverString = "D3D7Max2DDriver"
Case 2
SetGraphicsDriver D3D9Max2DDriver()
driverString = "D3D9Max2DDriver"
Case 3
SetGraphicsDriver D3D11Max2DDriver()
driverString = "D3D11Max2DDriver"
End Select

Print "Creating graphics " + width + " x " + height + " with depth " + depth + " at " + hertz + "hz with " + driverString

Local startMs:Int = MilliSecs()

Graphics(width, height, depth, hertz)

Local endMs:Int = MilliSecs()

Print "Time taken = " + (endMs - startMs)

Print "-------------"

EndGraphics()

End Function

End

And my results:

Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 410
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 3085
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 3105
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 398
-------------

So OpenGL and DX11 are fine, but I really need DX9 back to normal  ???

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Creating "Graphics" Slow
« Reply #7 on: July 28, 2019, 04:17:58 PM »
I'm getting this using older GPUs

NVidia GT650. Win7
Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 526
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 661
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 555
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 607
-------------

using a GTX750Ti on Win7
Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 542
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 714
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 334
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 713
-------------

Using the same GTX750Ti on Win10
Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 607
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 3174
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 3169
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 1175
-------------
To be is to be perceived.

https://github.com/davecamp

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Creating "Graphics" Slow
« Reply #8 on: July 28, 2019, 06:50:27 PM »
https://www.reddit.com/r/pcgaming/comments/bq7kro/windows_10_forces_games_into_a_faux_fullscreen/

Maybe try to disable the "fullscreen optimization" and check if it changes something (Win10 only).


bye
Ron

Offline therevills

  • Hero Member
  • *****
  • Posts: 570
Re: Creating "Graphics" Slow
« Reply #9 on: July 29, 2019, 11:20:08 AM »
Maybe try to disable the "fullscreen optimization" and check if it changes something (Win10 only).

Worth a shot, but it didnt help:

Code: [Select]
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 380
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 3068
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 3160
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 400
-------------


@col - definitely looks like a Windows 10 issue.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Creating "Graphics" Slow
« Reply #10 on: July 29, 2019, 02:26:16 PM »
NG
Code: [Select]
x86 brl:

Creating graphics 1280 x 800 with depth 32 at 60hz with GLMax2DDriver
Time taken = 1498
-------------
Creating graphics 1280 x 800 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 1695
-------------


x64 brl:
Creating graphics 1280 x 800 with depth 32 at 60hz with GLMax2DDriver
Time taken = 1249
-------------
Creating graphics 1280 x 800 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 1570
-------------


and now - with SDL on NG:
Creating graphics 1280 x 800 with depth 32 at 60hz with GLMax2DDriver
Time taken = 343
-------------
Creating graphics 1280 x 800 with depth 32 at 60hz with D3D9SDLMax2DDriver
Time taken = 1577
-------------
GL2 (with shaders) Active
Creating graphics 1280 x 800 with depth 32 at 60hz with GL2Max2DDriver
Time taken = 536
-------------

See how the d3d9 thing takes a big bunch longer?


Code I used for NG (sdl):
Code: BlitzMax
  1. SuperStrict
  2. Framework Brl.StandardIO
  3. Import SDL.SDLTimer
  4. Import SDL.d3d9sdlmax2d
  5. Import SDL.gl2sdlmax2d
  6. Import SDL.glsdlmax2d
  7.  
  8. Global width:Int = DesktopWidth()
  9. Global height:Int = DesktopHeight()
  10. Global depth:Int = 32
  11. Global hertz:Int = 60
  12.  
  13. CreateGraphics(0)
  14. CreateGraphics(1)
  15. CreateGraphics(2)
  16.  
  17. Function CreateGraphics(driver:Int)
  18.         Local driverString:String
  19.        
  20.         Select driver
  21.                 Case 0
  22.                         SetGraphicsDriver GLMax2DDriver()
  23.                         driverString = "GLMax2DDriver"
  24.                 Case 1
  25.                         SetGraphicsDriver D3D9SDLMax2DDriver()
  26.                         driverString = "D3D9SDLMax2DDriver"
  27.                 Case 2
  28.                         SetGraphicsDriver GL2Max2DDriver()
  29.                         driverString = "GL2Max2DDriver"
  30.         End Select
  31.  
  32.         Print "Creating graphics " + width + " x " + height + " with depth " + depth + " at " + hertz + "hz with " + driverString
  33.        
  34.         Local startMs:Int = MilliSecs()
  35.        
  36.         Graphics(width, height, depth, hertz)
  37.        
  38.         Local endMs:Int = MilliSecs()
  39.        
  40.         Print "Time taken = " + (endMs - startMs)
  41.  
  42.         Print "-------------"
  43.  
  44.         EndGraphics()
  45.  
  46. End Function
  47.  
  48. End
  49.  

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Creating "Graphics" Slow
« Reply #11 on: July 29, 2019, 03:07:03 PM »
What do you guys get if you amend :

brl.mod -> max2d.mod -> max2d.bmx -> TMax2DGraphics -> MakeCurrent

Comment out the couple of Flip and a Cls to make the method look as

Code: [Select]
Method MakeCurrent()
gc=Self
_max2dDriver=TMax2DDriver( Driver() )
Assert _max2dDriver
Validate

If _setup Return
Cls
'Flip 0
'Cls
'Flip 0
_setup=True
End Method

?
To be is to be perceived.

https://github.com/davecamp

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Creating "Graphics" Slow
« Reply #12 on: July 29, 2019, 03:47:59 PM »
Hmm I've noticed this so far...

The d3d9 device reset command is taking the most time for me at ~2600ms. In the d3d9 driver the 'reset' is called for a number of reasons, including changing the Flip interval parameter for full screen modes.

I'll see if there's a way to improve what is happening there... don't hold your breath though  ;D

And some for you play with (in the meantime)
Code: [Select]
SuperStrict

Global width:Int = DesktopWidth()
Global height:Int = DesktopHeight()
Global depth:Int = 32
Global hertz:Int = 60

SetGraphicsDriver D3D9Max2DDriver()

Local startMs:Int = MilliSecs()
Graphics(width, height, depth, hertz)
Print "Time taken = " + (MilliSecs() - startMs)

Global useflip1% = False
Global firstflip%
While Not KeyDown(key_escape)
Cls

DrawText "time to do first flip : " + firstflip, 0, 0
DrawText "using flip1 " + useflip1, 0, 20

If KeyHit(key_space)
useflip1 = 1 - useflip1
firstflip = 0
startms = MilliSecs()
EndIf

Global ang# = 0
DrawText "Test", 400 + 200 * Sin(ang), 400 + 200 * Cos(ang)
ang :+ 1
Flip useflip1

If firstflip = 0 firstflip = MilliSecs() - startms
Wend
To be is to be perceived.

https://github.com/davecamp

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Creating "Graphics" Slow
« Reply #13 on: July 29, 2019, 03:57:42 PM »
Brainstorming...
You could fix the problem if you pass in the flip interval that you intend to use as a parameter in the CreateGraphics set of commands... this would let you set up the flip interval when it is created. This would work if you always have the same flip interval through out all of your code. As soon as you change the interval (when full screen) then you run the risk of the delay during the presentation mode change.
To be is to be perceived.

https://github.com/davecamp

Offline therevills

  • Hero Member
  • *****
  • Posts: 570
Re: Creating "Graphics" Slow
« Reply #14 on: August 18, 2019, 07:15:24 AM »
Hmmm, I've noticed that it has improved heaps recently:

Code: [Select]
Executing:fullscreen_slow.exe
Creating graphics 1920 x 1080 with depth 32 at 60hz with GLMax2DDriver
Time taken = 486
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D7Max2DDriver
Time taken = 93
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D9Max2DDriver
Time taken = 129
-------------
Creating graphics 1920 x 1080 with depth 32 at 60hz with D3D11Max2DDriver
Time taken = 104
-------------

Process complete

I didnt do anything!?!? Maybe all those Windows 10 updates??