jPCT-AE - a 3d engine for Android > Support

itexture apply effect causing GC compaction on overlay

(1/2) > >>

davec64:
I am using overlays to place some text on the 3d view .if I do not apply the effect GC is firing about 1 time in 25 seconds. I normally call apply 1 time per second. And GC is firing almost every second causing a pause of 100 ms which even pauses my async tasks as well.
I am running at 25 fps with plenty of spare CPU. It frees around 8000k in 100ms.
Any ideas how to stop the memory being allocated and deallocated.
Dave

EgonOlsen:
Applying an ITextureEffect is costly, because it requires a new texture upload which needs some memory. If it's used as an overlay, chances are that you don't need mipmaps. You can disable them by setting this to false: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Texture.html#setMipmap(boolean)

Another thing worth trying is to use the latest beta jar: http://jpct.de/download/beta/jpct_ae.jar. It includes some changes to reuse buffers if possible when uploading textures.

davec64:
Hi Egon 
The logcat is being spammed with creating 32768 texture buffer in this version.

I am not seeing any benefits in the GC department I Have turned off mipmap as well.


--- Code: --- if (overlayBitmap == null) {
      // get a canvas to paint over the overlayBitmap
      overlayBitmap = Bitmap.createBitmap(nextPow2(280), nextPow2(64), Bitmap.Config.ARGB_8888);
      overlayBitmap.eraseColor(0);
      overlayCanvas = new Canvas(overlayBitmap);
      overlay = new Texture(Bitmap.createBitmap(overlayBitmap));
      overlay.setMipmap(false);
      overlay.setEffect(new ITextureEffect() {

        @Override
        public void init(Texture arg0) {
        }

        @Override
        public boolean containsAlpha() {
          return true;
        }

        @Override
        public void apply(int[] dest, int[] src) {
          overlayBitmap.getPixels(dest, 0, overlay.getWidth(), 0, 0, overlay.getWidth(),
              overlay.getHeight());
        }
      });
    }
--- End code ---

davec64:
Is there any other way to create a lets call it a text character layer over the 3d view. When I designed an Arcade Board in an Asic I created an 8*8 character map that was the first layer ( hi score points player level info etc) then 2 * 16*16 background layers. I just pointed the index (texture pointer) in the map to the correct character to display.
So if you like a plane with a custom character texture of say 64 characters . The same as I have done for my depth plane. but with alphanumeric's rather than textures. It would have to support transparency.
Before the days of 3D rendering chips. :-)

This would resolve all the memory re use issues in my case and it would be incredibly quick and would not require any bitmap and canvas draw rubbish.

Dave

 

EgonOlsen:

--- Quote from: davec64 on December 16, 2013, 11:02:49 pm ---The logcat is being spammed with creating 32768 texture buffer in this version.

--- End quote ---
Thanks for pointing that out. I forgot to limit this particular message to debug mode. Too bad that it didn't help though.

Edit: i just remembered that you have enable that feature by setting Config.reuseTextureBuffers=true;...

Navigation

[0] Message Index

[#] Next page

Go to full version