Author Topic: Bottleneck of my current project  (Read 10630 times)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Bottleneck of my current project
« Reply #15 on: 2014-Sep-07 »
Have to say sorry, my understanding for mathematics is quite limited so programming can easily become a running the gauntlet for me. Finally I found the right formula and my checkerboard background can be drawn correctly:

Code: (glbasic) [Select]
FOR i = 0 TO 16 STEP 16
    FOR j = 0 TO 16 STEP 16
        FOR k = 0 TO 7
            FOR l = 0 TO 7
                Ima[(i * 32) + j + (k * 32) + l] = 0xFF444444
                Ima[(i * 32) + 8 + j + (k * 32) + l] = 0xFF323232
                Ima[256 + (i * 32) + j + (k * 32) + l] = 0xFF323232
                Ima[256 + (i * 32) + 8 + j + (k * 32) + l] = 0xFF444444
            NEXT
        NEXT
    NEXT
NEXT

But one thing I noticed though. Normally the color value 0x222222 that I used is clearly visible. In this case, if I set it as 0xFF222222 for MEM2SPRITE I got black pixels. Why?

[EDIT]

Fortunately this method works on Android nice and smooth, so it's an acceptable solution for me, even if a bit unlikely. Please pardon the inconvenience!
« Last Edit: 2014-Sep-07 by S.O.P.M. »
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1622
  • Particle Hawk
    • View Profile
Re: Bottleneck of my current project
« Reply #16 on: 2014-Sep-08 »
0xFF222222

try 0xFF2222 instead

Hex is basically 6 characters long not 8 (not including the 0x part of course)

R G B red green blue  each is 2 chars long

This color should look pink.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Bottleneck of my current project
« Reply #17 on: 2014-Sep-08 »
0xFF222222

try 0xFF2222 instead

Hex is basically 6 characters long not 8 (not including the 0x part of course)

R G B red green blue  each is 2 chars long

This color should look pink.
MEM2SPRITE colours in array are 8 chars(32bit), 2x each of Alpha, Blue, Green, Red. 0xAABBGGRR.

I should be home soon so will have a look at your code more closely S.O.P.M when there. Also 0xFF222222 is a very very dark gray. Does it look black on windows or android as don't forget nearly all android devices are 16bit colour & not 24bit like pc's etc.

Lee
« Last Edit: 2014-Sep-08 by fuzzy70 »
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1622
  • Particle Hawk
    • View Profile
Re: Bottleneck of my current project
« Reply #18 on: 2014-Sep-08 »
hmm
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Bottleneck of my current project
« Reply #19 on: 2014-Sep-08 »
Quote from: fuzzy70
Also 0xFF222222 is a very very dark gray. Does it look black on windows or android as don't forget nearly all android devices are 16bit colour & not 24bit like pc's etc.
Yes, it's a quite dark gray but it was cleary visible on a black ground under Win and also on my Android phone. I still believe 0xFF222222 should be exactly the same color value than without the transparency declaration 0x222222. So I don't understand why DRAWRECT x, y, w, h, 0x222222 is visible and 0xFF222222 if saved for MEM2SPRITE absolutely not.

However, this is not a problem because I was able to get a similar grey with other values. And that's all I need. Would still nice to understand the mathematical or other background, though.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Bottleneck of my current project
« Reply #20 on: 2014-Sep-08 »
Interesting, I just done a test with the following code
Code: (glbasic) [Select]
LOCAL spritemem%[]
LOCAL loop%

DIM spritemem[76800]

FOR loop = 0 TO 76799
spritemem[loop]=0xFF222222
NEXT

MEM2SPRITE(spritemem[],1,320,240)
DRAWSPRITE 1,321,0

DRAWRECT 0,0,320,240,0x222222

SHOWSCREEN

MOUSEWAIT
which basically draws 2 rects the same colour, 1 using DRAWRECT & other with a sprite made from MEM2SPRITE & the result was as expected, 2 rects the same colour.

Tested on both Windows & Android.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Bottleneck of my current project
« Reply #21 on: 2014-Sep-08 »
Impossible... your code is working. Now I've changed my code again and it works also. Don't ask me what was wrong the last time.

Another thing puzzles me now. The CPU load is very different in same situations. One time I start the program it goes not above 10%, another time it's at 20-25% permanently. Sometimes the load reduces by itself while the app is running and nothing else changes. I can minimize the window and if I bring it back the load can be very low while I can use the app on any screen. How can that be? My graphics driver is up to date.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Bottleneck of my current project
« Reply #22 on: 2014-Sep-08 »
Welcome to windows lol. No seriously though I have that problem with non glb apps as well & never really got to the bottom of it.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Bottleneck of my current project
« Reply #23 on: 2014-Sep-08 »
I don't think it's windows. Not that I observed the overall load, no, the load of exactly my app. I'm sure it's an issue with OpenGL.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1810
    • View Profile
Re: Bottleneck of my current project
« Reply #24 on: 2014-Oct-15 »
You can significantly reduce all draw calls by drawing 1 large rect of black then draw white tiles using a step in you loop calculations

You dont need to draw all 64 squares - Just 17
 :P
« Last Edit: 2014-Oct-16 by MrPlow »
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1810
    • View Profile
Re: Bottleneck of my current project
« Reply #25 on: 2014-Oct-15 »
duplicate...
« Last Edit: 2014-Oct-16 by MrPlow »
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Bottleneck of my current project
« Reply #26 on: 2014-Oct-19 »
Luckily, all problems are gone. The app currently runs perfectly fine, even if there's a lot to do before it's finished. Programming is always a great learning experience for me.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium