How to use 2048 * 1024 texture on a sphere?

Started by hisong, September 21, 2011, 08:50:28 AM

Previous topic - Next topic

K24A3

I was thinking it may be a 3DS issue, perhaps try texturing a bare sphere using primitives.getSphere.

EgonOlsen

To upload a texture, a copy into the VM's memory has to exists. Or otherwise, there's nothing to upload. By default, jPCT-AE keeps this copy for handling context changes. You can disable this behaviour, but you still need the memory before it will be uploaded. 2048*2048*4=16mb => crash. I don't really get how one can think that this should actually work on a VM with 16-24mb. And i don't the reason why it should. No game on the desktop is using this crazy resolution maybe except for shadow maps. So why on earth does anybody even think about using it on a mobile device...  ???

K24A3

Is there a way to stream the texture into the GPU or perhaps use Texture compression?

K24A3

#18
I found a way to load huge textures, but only honeycomb (Android 3.x) is supported.

Honeycomb increases the memory size per application to 48MB using the standard heap (as opposed to 24MB and 32MB in previous Androids). But loading a 2048x2048 texture still crashed my app.

Here is the memory allocation (crashes when loading the large texture):
09-22 18:21:08.190: VERBOSE/Tosh(25398): debug.heap native: allocated 3.02MB of 3.04MB (0.01MB free)
09-22 18:21:08.190: VERBOSE/Tosh(25398): debug.memory: allocated: 22.00MB of 48.00MB (6.00MB free)

Then I made the following changes to increase the heap to Large:
In default.properties file, I changed the target to 'target=android-11'
In AndroidManifest.xml file, I added 'android:largeHeap="true"' to the Application tag.

Now that large 2048 texture loads with no problem.
09-22 18:23:14.980: VERBOSE/Tosh(25572): debug.heap native: allocated 3.02MB of 3.02MB (0.00MB free)
09-22 18:23:14.980: VERBOSE/Tosh(25572): debug.memory: allocated: 55.00MB of 256.00MB (22.00MB free)

256MB to play with! But your app won't be able to run on any phone, or at least until Icecream Sandwich phones come out (2012).

Here's the code to log the memory stats

public static void logHeap() {
        Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/new Double((1048576));
        Double available = new Double(Debug.getNativeHeapSize())/1048576.0;
        Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0;
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(2);
        df.setMinimumFractionDigits(2);

        Log.d("Log", "debug. =================================");
        Log.d("Log", "debug.heap native: allocated " + df.format(allocated) + "MB of " + df.format(available) + "MB (" + df.format(free) + "MB free)");
        Log.d("Log", "debug.memory: allocated: " + df.format(new Double(Runtime.getRuntime().totalMemory()/1048576)) + "MB of " + df.format(new Double(Runtime.getRuntime().maxMemory()/1048576))+ "MB (" + df.format(new Double(Runtime.getRuntime().freeMemory()/1048576)) +"MB free)");
    }




EgonOlsen

...So they finally realized that people might need some more memory...good to know.

K24A3

hehe yeah I think we will see a big jump in memory capacity and performance soon.

The Tegra Wiki suggests that performance will be 10x faster with the Tegra 4 chip next year (compared to Tegra2), then 50x faster the following year, including support for OpenGL 4.0
http://en.wikipedia.org/wiki/Nvidia_Tegra#Tegra_3_.28Kal-El.29_series