GMS 2 Surface questions

Discussion in 'Programming' started by Doulos, Jul 13, 2019 at 9:14 PM.

Tags:
  1. Doulos

    Doulos Member

    Joined:
    Jun 8, 2019
    Posts:
    15
    I read here http://gmc.yoyogames.com/index.php?showtopic=631986 that surfaces should be kept small, but are great for optimization.
    This was a few years ago, thus I am asking.

    What is the rule of thumb here?
    "The English phrase rule of thumb refers to a principle with broad application that is not intended to be strictly accurate or reliable for every situation."
    Generally speaking When should we use a surface vs when we should not?

    I have a massive room that the player would may see all at once if they zoom out. 7680x3840.
    I have 5 layers of tiles of various sizes to create a map look. ~ 200,000 tiles
    I make this map dynamically, but exactly once at creation.

    Should I put that all on 1 surface instead of a few hundred thousands of tiles?
     
  2. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    When striving for importance, it is important to strive to make as few drawing calls as possible. Drawing a big textured rectangle (which is what a surface is in the end) is much simpler than drawing thousands of elements. This is the same concept as complex graphical formats in image editing software, where the resulting image is lighter and easier to draw than the source file and its multiple layers.
    Be mindful however that a 7680x3840 surface would be "rounded" to a 8192x8192 surface (8192x8192 also happens to be the maximum texture size in GM, if that hasn't changed). So the first simplification you could make in this sense is using two 4096x4096 surfaces, which would halve the graphical memory expended. A desktop should be able to handle this ok, phones probably not (you would not put 200.000 tiles in a mobile game anyway).

    Still, this is actually a pretty tricky topic and I would suggest doing what one does when there is a mystery regarding performance... TEST IT OUT!
     
  3. mikix

    mikix Member

    Joined:
    May 2, 2017
    Posts:
    306
    So does this mean background image of a level > tile mapped level in terms of performance?

    Edit: In that case, I think GM should give us an option to save our tile mapped room into a png background image.
     
  4. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    It depends on how much optimization GM does when it comes to tiles. The manual states they're efficient because they don't have the overhead of instances, but doesn't mention anything else. While it is totally possible there is more going on under the hood, given that GM has a generally pretty hands-off approach to handling complex stuff (you need to handle your structures manually, you need to handle the activation\deactivation of your instances manually, you need to handle the creation/freeing of surfaces manually) I wouldn't bet on it. But that's why I said one should really test it out when it comes to such large optimization choices.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice