Creating "Graphics" Slow

Started by therevills, July 27, 2019, 05:19:08

Previous topic - Next topic

therevills

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:

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:

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?  ???

Derron

#1
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

GW

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?

Derron


Linux Mint 17.04 XFCE:

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

TomToad

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.

therevills

 I'm using an Nvidia GTX 1080...

Full screen:

Creating graphics 1920 x 1080 with depth 32 at 60hz
Time taken = 3103


Window Mode:

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:

Creating graphics 1920 x 1080 with depth 32 at 60hz
Time taken = 115

therevills

Expanded to use different drivers:

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:

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  ???

col

#7
I'm getting this using older GPUs

NVidia GT650. Win7

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

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

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
-------------

https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Derron

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

therevills

Quote from: Derron on July 28, 2019, 18:50:27
Maybe try to disable the "fullscreen optimization" and check if it changes something (Win10 only).

Worth a shot, but it didnt help:

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.

Derron

NG

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) Select

SuperStrict
Framework Brl.StandardIO
Import SDL.SDLTimer
Import SDL.d3d9sdlmax2d
Import SDL.gl2sdlmax2d
Import SDL.glsdlmax2d

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

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

Function CreateGraphics(driver:Int)
Local driverString:String

Select driver
Case 0
SetGraphicsDriver GLMax2DDriver()
driverString = "GLMax2DDriver"
Case 1
SetGraphicsDriver D3D9SDLMax2DDriver()
driverString = "D3D9SDLMax2DDriver"
Case 2
SetGraphicsDriver GL2Max2DDriver()
driverString = "GL2Max2DDriver"
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

col

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


Method MakeCurrent()
gc=Self
_max2dDriver=TMax2DDriver( Driver() )
Assert _max2dDriver
Validate

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


?
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

col

#12
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)

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
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

col

#13
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.
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

therevills

Hmmm, I've noticed that it has improved heaps recently:

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??