Can We Determine Where The Bottleneck Is?

Monkey Forums/Monkey Programming/Can We Determine Where The Bottleneck Is?

GarBenjamin(Posted 2015) [#1]
THIS HAS BEEN RESOLVED!


This issue is present in all 3D rendered games on both my new and old laptop regardless of whether it is a 2D game in Unity, Monkey X or GLBasic. Apparently, it is just a symptom of modern 3D rendering.

One thing I did resolve was the anti-aliasing that was present on moving objects.
@therevills reminded me of the floating point issue (again tied to 3D rendering) so I simply used the same kind of code I had in my Unity projects to set the rendered position to even pixels. In fact, I went one better and did what I should have done originally... multiplied the movement to 2 pixel increments to match the low res display.

I do wish we could still do true 2D blitting instead of having to do 3D for everything but it is what it is.

Now I am thinking what would happen if all rendering is done to a target image first then only that single image is rendered to the display?

This may be a way to achieve a non-blurred display of moving objects. Assuming everything really is rendered in 1 frame (60 FPS or so).

-----------------------------------------------
ORIGINAL POST

Hey all.

I am wondering if anyone has any idea why the Monkey X programs are not running at 60 FPS or more.

I keep thinking we were getting 60 FPS over a decade ago in Blitz on much weaker hardware.

Does anyone know where the bottleneck is? is it in the graphics rendering or something in the update phase? Normally I'd first suspect the rendering but cannot imagine how that could be possible on these modern machines. Even if the graphics were being entirely software rendered they should be running fast as hell these days.

I have seen the audio cause delays in some frameworks in the past so perhaps that is something to consider as well.

So... the question is why are we not getting at least 60 FPS in our 2D Monkey X games (particularly on desktop)?


Neuro(Posted 2015) [#2]
Just wondering, what kind of fps you getting? Do you have an nVidia graphics card?


GarBenjamin(Posted 2015) [#3]
Just from eyeballing it about 30 fps. Almost seems like it is locked to 30 fps. I will check again after work but I believe every example banana is the same regardless of complexity. Everything has that slight blur when in motion where 60 FPS or more always looks very crisp and clean.

Yes. My laptop (MSI GT70 Dominator-2295 2.5 GHz, 16 GB RAM, GeForce GTX 970M) is a gaming powerhouse... for a laptop. Obviously not as powerful as a desktop gaming computer but it is quite good.


GarBenjamin(Posted 2015) [#4]
UPDATE:

I had an idea wondering if perhaps it is not actually running slow (all of the FPS counters in examples and other MX stuff I have tried shows 60 to 61 FPS) and perhaps there is some kind of anti-aliasing going on.

What I discovered is very interesting! I took a screenshot of my game with the player standing still. Then I took a screenshot with the player moving. In the still shot everything is sharp with 24 total colors as expected. In the shot taken while moving some of the graphics are blurred. Examining it I see the images that are in motion are anti-aliased and the screenshot has 98 colors as a result.

The really interesting thing is it is only the graphics that are actually moving. The player, spiders and so forth are anti-aliased only when they move.

Normally I'd expect a screenshot to always be sharp and non anti-aliased regardless of if it is taken from a 30 fps rendering or a 60 fps rendering. So basically something is making these games / examples anti-alias only moving graphics.



It may possibly be some "feature" of my monitor or perhaps the rendering system in Monkey X. Whatever it is this is what makes the stuff appear like it is running at 30 fps. It creates a slight blur effect to the moving objects.

I will continue to investigate. Also, if someone doesn't mind testing it take a screenshot of one of your Monkey X games with the player standing still and then take one while the player is moving and see if you get the same effect.


therevills(Posted 2015) [#5]
If you are moving via floats you will get that effect.

Try adding this preprocessor at the top of your main file:
#MOJO_IMAGE_FILTERING_ENABLED="false"



GarBenjamin(Posted 2015) [#6]
@therevills

Ah thank you! I actually already had that but that explains it perfectly. I ran into the same thing in Unity. I guess even Monkey X (and probably everything else these days) is ultimately rendering everything in 3D.

I should have realized that but I kept thinking it was actually doing true 2D blitting for some reason. lol

I can fix this issue no problem now that I know what it is. Thanks again!


GarBenjamin(Posted 2015) [#7]
Alright that issue is fixed! And indeed now even in motion nothing is anti-aliased.

Unfortunately, objects still have the blur effect while moving. The faster they are moving the more of a blur they have. Taking a screenshot however revealed there is no anti-aliasing going on to cause it now.

So now it does seem to indeed be the frame rate. It reminds me so much of seeing games back in the Amiga days running at 30 fps compared to games running at 60 fps.

I will keep digging into it. I'd like to sort it out before I start on my Christmas game next week.


Nobuyuki(Posted 2015) [#8]
Try the latest experimental version of Monkey. There was an issue with polling joysticks which caused the framerates to drop dramatically on some people's machines.

I saw in the other thread that you tried this already. Maybe try an Angle build with a Mojo2 project and see if you have the same issue. Some graphics card drivers aren''t friends with OpenGL...


GarBenjamin(Posted 2015) [#9]
@Nobuyuki I can give that a try. I don't know anything about Mojo 2 (or even mojo for that matter other than I import it and the methods are all very familiar because they are the same I was using in Blitz years ago). I'm guessing that will mean just rewriting the rendering piece of my game. There are only two methods in the entire game that actually draw anything so it shouldn't be too much work to convert. I will do that tomorrow. Thanks for the tip! :)


therevills(Posted 2015) [#10]
Have you outputted the FPS?


GarBenjamin(Posted 2015) [#11]
@therevills No, I have not. Because the FPS counters in the examples always show 60 to 61 FPS and yet the display does not support that number. When everything is updating in 1 frame the graphics look sharp, there is no blur to moving objects. No stutter, etc.

@Nobuyuki I had a little time to look into Mojo2 but seems like it is a bit different from Mojo using canvas and no image frame rendering and so forth. Probably not too big of a deal at all but more than I can get into now because I am going to sleep in about 5 minutes.

However, instead of spending time converting to Mojo2 without knowing if there is any benefit in doing so I decided to simply test the Mojo2 bouncy aliens example.
I removed the scaling, rotation and animation so it would be very easy to see.

I also set the number of aliens to only 25. And they all move with the blur and also have a sort of stutter / jerkiness to them. It seems that on my laptop Mojo 1 actually performs better than Mojo 2.

That is great to know though so I don't waste time converting over to Mojo 2! I'd have been an unhappy campy if I converted it all over only to find it was worse than Mojo 1! LOL! ;)

Anyway, thanks guys for throwing out ideas. I appreciate it. I don't know what the issue is. Do you all see crystal clear displays on your computer?

Like with the Mojo2 Bouncy Aliens if you just use the basic canvas.DrawImage with only the alienframe(0), Int(x), Int(y) and 25 aliens... is it a crisp display with no blur or jerkiness?

I am just trying to figure out it if it is something with my laptop and Monkey X graphics or if it is something with Monkey X graphics period.


therevills(Posted 2015) [#12]
Hmmm... could it be the display on the laptop itself? Do you get it with any "proper" games?


bitJericho(Posted 2015) [#13]
Unfortunately, objects still have the blur effect while moving. The faster they are moving the more of a blur they have.


This is probably your monitor. This is known as "ghosting." This effect is non-existent on CRTs and Plasma displays. If you were to have such a thing lying around you could test it


GarBenjamin(Posted 2015) [#14]
@bitJericho I wondered about that too. It may well be my new laptop monitor.
I am much more likely to notice it in my own stuff. I don't recall seeing the effect in other games though. It's possible it was there and I just paid no mind to it. Probably because I expect better results from myself than things I get. lol

My next step is to play all of the 2D games I normally do and pay close attention to see if they have the same ghosting while in motion. I noticed it in the GLBasic and Monkey X version of my Mars Explorer test game. However, I started on all of this exploring of other dev kits right at the time I got my new laptop. So there is a definite possibility because I have been so busy developing trying out different languages that it is not these other languages actually causing the blur but my new laptop monitor itself. Which would be idiotic for them to have a monitor do that in my opinion but since everything is geared toward 3D these days and that is not noticeable, at least not nearly to the degree due to the view, in 3D games it is possiible it is a "feature" of the monitor. lol


GarBenjamin(Posted 2015) [#15]
I tested thoroughly and this issue is present in all 3D rendered games on both my new and old laptop regardless of whether it is a 2D game in Unity, Monkey X or GLBasic. Apparently, it is just a symptom of modern 3D rendering.

I can live with that as long as it is just the way it is. I thought maybe I was doing something wrong in my code to cause Mojo to do it. One thing was entirely on me the lack of locking the movement to integer pixel boundaries. Updated the original post here.


SLotman(Posted 2015) [#16]
Have you tried to draw your images with a .5 offset? Something like Drawimage image, Int(x+0.5), Int(y+0.5)

It could be a subpixel rendering problem...


GarBenjamin(Posted 2015) [#17]
@SLotman I will give that a try but I don't think it will make any difference because it is not just my games but other people's MX games, Unity 2D games and so forth . I am now using Integer values for all positions and that removed the anti-aliasing. I think it is just the way it is with 3D rendered stuff these days. I've tested on 3 machines now different things in Unity, Monkey X and so forth and they all have the blur. It is probably something most people don't even notice.

This is a perfect example of how people can get hyper critical of their own stuff then start looking into it and "go down a rabbit hole". I never even noticed that all of the other 2D games whether in GameMaker Studio, Unity or whatever all have that blurred look. I noticed it only in my game and then started paying attention and noticed it in other MX games and demos then in Unity games and basically everything. It is probably directly related to me having used laptops for may years now. Yet in my mind I always remember things being crisp and clean. I would have drove myself insane trying to achieve something that is probably technically impossible in this case. Ha ha ha! ;)

Anyway glad that's sorted out. I got to start thinking about my Chrstmas game. Want to start on it next week for sure so I have time to do it justice. Thank you all for listening to my crazy rambling and trying to help out.