Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Poor performance (single figure FPS) when using two dimensional array of structure

    Help
    3
    10
    223
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Psyclist
      Psyclist F last edited by Psyclist

      Hi there

      I have been looking a creating a text mode console using a two dimensional array eg:

      struct txtCell
      int ascii // ASCII code of character 0 - 255
      int flag // If true draw cell otherwise skip (not using this ATM - I draw all cells)
      vector fcol // Foreground colour
      vector bcol // Background colour
      int x // Pre-calculated  Screen pixel X position
      int y // Pre-calculated  Screen pixel Y position
      endStruct
      
      txtCell txtScreen[80][30]
      

      The array is scanned and each cell is drawn to the screen using an image, it all works fine but the performance (FPS) plummets to 25 (ish) instantly just gets lower and lower until it hits around 1 FPS.

      If I was to use the same loops to pass over the array but instead use say random() for ascii and colours etc and calculate the pixel coordinates manually within the loop I get 60 FPS.

      How can lookup table be slower than using random / inline calculations ?!?

      Thanks in advance for any feedback :)

      1 Reply Last reply Reply Quote 0
      • M
        MikeDX last edited by

        Can you share the program so I can take a look please

        When using 2d arrays I find it quicker to take a copy of the 2nd array i want to work with within the loop

        for a = 0 to len (2darray) loop
            c = 2darray[a]
            for b = 0 to len (c) loop
             /// STUFF
           repeat
        repeat
        
        
        Psyclist 1 Reply Last reply Reply Quote 0
        • Psyclist
          Psyclist F @MikeDX last edited by

          @MikeDX said in Poor performance (single figure FPS) when using two dimensional array of structure:

          Can you share the program so I can take a look please

          When using 2d arrays I find it quicker to take a copy of the 2nd array i want to work with within the loop

          for a = 0 to len (2darray) loop
              c = 2darray[a]
              for b = 0 to len (c) loop
               /// STUFF
             repeat
          repeat
          
          

          Thanks for the suggestion Mike.

          Just tried that method with pretty much the exact same results.

          1 Reply Last reply Reply Quote 0
          • M
            MikeDX last edited by

            Actually that's compacted by it being a 2D array of structs

            I'll raise an issue, we can take a look and hopefully performance will improve in a future patch.

            1 Reply Last reply Reply Quote 0
            • Psyclist
              Psyclist F last edited by

              @MikeDX Would you still like me share program ?

              1 Reply Last reply Reply Quote 0
              • Dave
                Dave Fuze Team last edited by

                I'm sure @Luke would like to take a look at that program too so yes please mate!

                1 Reply Last reply Reply Quote 0
                • M
                  MikeDX last edited by

                  I think I got the idea of what you were doing now, thank you. It's always useful to share code that breaks / does stuff as we can test against it

                  1 Reply Last reply Reply Quote 0
                  • Psyclist
                    Psyclist F last edited by

                    My Nintendo Switch Friend Code: SW-2370-8420-6054

                    Program Name: Text Console

                    I cannot share ATM keeping getting a "Error: No Connection" when I try (I will post here once i have succeeded)

                    1 Reply Last reply Reply Quote 0
                    • M
                      MikeDX last edited by

                      There are issues with the share server at the minute but we are working on a fix. You should be able to share at the moment

                      1 Reply Last reply Reply Quote 0
                      • Psyclist
                        Psyclist F last edited by

                        @MikeDX @Dave I have now successfully shared my code :-)

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post