-->

Android GLSL fragment shader on NVIDIA tegra2

2019-09-12 14:08发布

问题:

I'm developing an app for the android galaxy tab 10.1 which has the Tegra 250 T20. I am writing a shader in GLSL that has a for() loop. I want the for() loop to terminate early under some conditions.

What I'm seeing is that the shader compiler has unwound the loop and the entire unwound code is being executed, which kills the performance.

Here's the question: Does the Tegra 250 T20 support the execution flow instructions at all? And if so, how can I tell the compiler to actually make use of them.

Thanks very much for any and all replies.

ETA: glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION) returns "OpenGL ES GLSL 1.00".

Also if the GLSL can't handle it, how can I write in the ARB assembly language to do it myself?

ETA2: GL_EXTENSIONS has this: GL_NV_platform_binary GL_OES_rgb8_rgba8 GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_NV_depth_nonlinear GL_NV_draw_path GL_NV_texture_npot_2D_mipmap GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_vertex_half_float GL_NV_framebuffer_vertex_attrib_array GL_NV_coverage_sample GL_OES_mapbuffer GL_ARB_draw_buffers GL_EXT_Cg_shader GL_EXT_packed_float GL_OES_texture_half_float GL_OES_texture_float GL_EXT_texture_array GL_OES_compressed_ETC1_RGB8_texture GL_EXT_texture_compression_latc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_NV_get_tex_image GL_NV_read_buffer GL_NV_shader_framebuffer_fetch GL_NV_fbo_color_attachments GL_EXT_bgra GL_EXT_texture_format_BGRA8888 GL_EXT_unpack_subimage GL_NV_texture_compression_s3tc_update

回答1:

On most embedded Platforms - I believe all plattforms that only support version 120 - GLSL does not support any kind of dynamic looping. For example: You can't declare a variable to determine how often the loop should loop.

The only possibility is to split it up in several conditional blocks, if applicable.



回答2:

Neigher the Tegra vertex nor fragment shader units supports dynamic control-flow; you need loops to be possible to unroll at compile time. Most other OpenGL ES 2.0 implementations supports dynamic control-flow, but the standard does not require it.



标签: android tegra