GL Maximum Textures Size Policy

拈花ヽ惹草 提交于 2019-12-06 08:48:54

GL_MAX_TEXTURE_SIZE is the maximum square texture dimensions your hardware supports.

  • Neither the X nor Y dimensions of any texture can exceed this size.

GL_MAX_TEXTURE_IMAGE_UNITS refers to the maximum number of textures (e.g. unique sampler uniform names in a GLSL program) you can bind and use in the programmable pipeline (GL_MAX_TEXTURE_UNITS is the fixed-function analog in GLES 1.0).

  • In GLES 2.0 this has a minimum value of 2.

GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS refers to the number of textures you can use across all shaders in your GLSL program.

  • 4 samplers in a fragment shader + 4 samplers in a vertex shader = 8 Combined Texture Image Units


NOTE: OpenGL ES 2.0 does not require texture lookup support in vertex shaders, and I suspect Samsung Note 8, Sony XPERIA U has an implementation that does not support this, judging by the parity between COMBINED and general TMU counts.

  • Querying the value of GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS would put an end to any speculation though.


To answer your actual question, though... the only one of these values you can use to determine which texture pack to use is GL_MAX_TEXTURE_SIZE. There is no OpenGL parameter you can query to determine the underlying hardware's memory capacity / texture fillrate, which is what you really want to know when selecting texture packs. You will need to gather this information through other means, perhaps a mini-benchmark or a database of known hardware, or if you are lucky the platform has a separate API that lets you query this.

I came across another test case that may come in handy, checking for available memory:

        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
        ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
        activityManager.getMemoryInfo(mi);
        long availableMegs = mi.availMem / 1048576L;

So far my test cases are:

if (IS_TABLET7 || IS_TABLET10) {
    useHIGH &= smallestWidthSize >= TABLET_MAX_SMALLEST_WIDTH;
} else {
    useHIGH &= smallestWidthSize >= SMARTPHONE_MAX_SMALLEST_WIDTH;
}

Log.i(C.TAG, "=========SCREEN DIMENSIONS=========");
Log.i(C.TAG, "Screen Size Info: smallestWidthSize = " + smallestWidthSize);
Log.i(C.TAG, "Screen Size Info: smallestWidthSize >= MAX_SMALLEST_WIDTH (" + (IS_TABLET ? TABLET_MAX_SMALLEST_WIDTH : SMARTPHONE_MAX_SMALLEST_WIDTH) + ")? " + useHIGH);
Log.i(C.TAG, "Screen Size Info: should use Texture Type > " + (useHIGH ? "HIGH" : "LOW"));


useHIGH &= availableMegs > MIN_RAM_LIMIT;
Log.i(C.TAG, "=========AVAILABLE RAM=========");
Log.i(C.TAG, "Memory Info: available RAM = " + availableMegs + "Mb");
Log.i(C.TAG, "Memory Info: available RAM > MIN_RAM_LIMIT(" + MIN_RAM_LIMIT + "Mb)? " + useHIGH);
Log.i(C.TAG, "Memory Info: should use Texture Type > " + (useHIGH ? "HIGH" : "LOW"));

As stated above I'll always keep this post updated until a good solid solution is reached.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!