gpt4 book ai didi

android - 使用不匹配的驱动程序版本启用 glsl 扩展时崩溃

转载 作者:行者123 更新时间:2023-11-29 01:34:42 25 4
gpt4 key购买 nike

我目前在 nexus 6 上遇到一个问题,它会在编译着色器时导致 OpenGL 崩溃。我的着色器通过检查扩展是否为 #defined 然后在 glCompileShader 期间崩溃的过程来启用 GL_OES_standard_derivatives 扩展。该设备确实支持该扩展程序,并且可以在其他 Android/iOS 设备和版本上正常工作。

有没有其他人遇到过这个问题并找到了解决方案/替代解决方案?

堆栈跟踪

03-18 12:41:26.350: I/DEBUG(343): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-18 12:41:26.350: I/DEBUG(343): Build fingerprint: 'google/shamu/shamu:5.0/LRX21O/1570415:user/release-keys'
03-18 12:41:26.350: I/DEBUG(343): Revision: '33696'
03-18 12:41:26.350: I/DEBUG(343): ABI: 'arm'
03-18 12:41:26.350: I/DEBUG(343): pid: 17572, tid: 17613, name: Render Thread >>> com.ninjakiwi.monkeycity <<<
03-18 12:41:26.351: I/DEBUG(343): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x11
03-18 12:41:26.405: I/DEBUG(343): r0 9ec5f900 r1 00000031 r2 9ec8aa00 r3 00000000
03-18 12:41:26.405: I/DEBUG(343): r4 9ecccd80 r5 00000002 r6 00000000 r7 ab474f50
03-18 12:41:26.405: I/DEBUG(343): r8 00000000 r9 00000001 sl 9ee00744 fp 00000001
03-18 12:41:26.405: I/DEBUG(343): ip 9ecf9c04 sp 9ee00728 lr ab3a1c0d pc ab39e0ae cpsr 200f0030
03-18 12:41:26.405: I/DEBUG(343): backtrace:
03-18 12:41:26.406: I/DEBUG(343): #00 pc 005c40ae /system/vendor/lib/libllvm-glnext.so (CPPStruct::UpdateExtBehavior(char const*, char const*)+545)
03-18 12:41:26.406: I/DEBUG(343): #01 pc 005c42a1 /system/vendor/lib/libllvm-glnext.so (CPPStruct::CPPextension(yystypepp*)+232)
03-18 12:41:26.406: I/DEBUG(343): #02 pc 005c60dd /system/vendor/lib/libllvm-glnext.so (CPPStruct::DispatchCPPline(yystypepp*, int)+696)
03-18 12:41:26.406: I/DEBUG(343): #03 pc 005c8a6f /system/vendor/lib/libllvm-glnext.so (YYParser::GetLexToken(char*, unsigned int)+150)
03-18 12:41:26.406: I/DEBUG(343): #04 pc 005c0bd5 /system/vendor/lib/libllvm-glnext.so (yy2_input(char*, int, TParseContext*)+12)
03-18 12:41:26.406: I/DEBUG(343): #05 pc 005c0d27 /system/vendor/lib/libllvm-glnext.so
03-18 12:41:26.406: I/DEBUG(343): #06 pc 005c212d /system/vendor/lib/libllvm-glnext.so (yy2lex(YYSTYPE*, TParseContext&)+3968)
03-18 12:41:26.406: I/DEBUG(343): #07 pc 005bb0a5 /system/vendor/lib/libllvm-glnext.so (yy2parse(TParseContext&)+328)
03-18 12:41:26.406: I/DEBUG(343): #08 pc 005c0e9d /system/vendor/lib/libllvm-glnext.so (yy2PaYYParse(TParseContext&)+16)
03-18 12:41:26.406: I/DEBUG(343): #09 pc 005c8981 /system/vendor/lib/libllvm-glnext.so (YYParser::ParseStrings(char**, long*, int, TParseContext&, int)+276)
03-18 12:41:26.406: I/DEBUG(343): #10 pc 005975b9 /system/vendor/lib/libllvm-glnext.so (ShCompile+1316)
03-18 12:41:26.406: I/DEBUG(343): #11 pc 005405cb /system/vendor/lib/libllvm-glnext.so (LLVMCompiler::parse(QGLC_SRCSHADER*)+1094)
03-18 12:41:26.406: I/DEBUG(343): #12 pc 0054380d /system/vendor/lib/libllvm-glnext.so (CompilerContext::CompileToIRShader(QGLC_SRCSHADER*, QGLC_COMPILETOIR_RESULT*)+168)
03-18 12:41:26.406: I/DEBUG(343): #13 pc 000f7ead /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShaderCompiler::CompileShader(EsxShader const*, EsxInfoLog*)+476)
03-18 12:41:26.406: I/DEBUG(343): #14 pc 000f6a09 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShader::Compile(EsxContext*)+68)
03-18 12:41:26.406: I/DEBUG(343): #15 pc 000a8951 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::GlCompileShader(unsigned int)+60)
03-18 12:41:26.406: I/DEBUG(343): #16 pc 000d9cc1 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlCompileShader(EsxDispatch*, unsigned int)+40)
03-18 12:41:26.406: I/DEBUG(343): #17 pc 0009fc13 /system/vendor/lib/egl/libGLESv2_adreno.so (glCompileShader+26)
03-18 12:41:26.406: I/DEBUG(343): #18 pc 0130c308 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #19 pc 0130bb28 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #20 pc 0130b85c [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #21 pc 011e5614 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #22 pc 0130831c [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #23 pc 01308978 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #24 pc 01308160 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #25 pc 01113a0c [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #26 pc 011137e8 [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #27 pc 0111353c [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #28 pc 0169a8bf [REDACTED]
03-18 12:41:26.406: I/DEBUG(343): #29 pc 000162e3 /system/lib/libc.so (__pthread_start(void*)+30)
03-18 12:41:26.406: I/DEBUG(343): #30 pc 000142d3 /system/lib/libc.so (__start_thread+6)

设备详情

型号:Nexus 6
内部版本号:LRX210
OpenGL版本:OpenGL ES 3.0V@95.0 (GIT@I86da836d38)
OpenGL 渲染器:Adreno (TM) 420
GLSL版本:OpenGL ES GLSL ES 3.10
支持的扩展: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_half_float GL_OES_framebuffer_object GL_OES_rgb8_rgba8 GL_OES_compressed_ETC1_RGB8_texture GL_AMD_compressed_ATC_text ure GL_KHR_texture_compression_astc_ldr GL_OES_texture_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_OES_texture_3D GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_QCOM_alpha_test GL_OES_depth24 GL_ OES_packed_depth_stencil GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_EXT_sRGB GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_EXT_texture_type_2_10_10_10_ REV GL_EXT_texture_sRGB_decode GL_OES_element_index_uint GL_EXT_copy_image GL_EXT_geometry_shader GL_EXT_tessellation_shader GL_OES_texture_stencil8 GL_EXT_shader_io_blocks GL_OES_shader_image_atomic GL_OES_sample_variables GL_EXT_texture_border_clamp GL_ EXT_multisampled_render_to_texture GL_OES_shader_multisample_interpolation GL_EXT_draw_buffers_indexed GL_EXT_gpu_shader5 GL_EXT_robustness GL_EXT_texture_buffer GL_OES_texture_storage_multisample_2d_array GL_OES_sample_shading GL_OES_get_program_binary GL_EXT_debug_标签GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_QCOM_tiled_rendering GL_ANDROID_extension_pack_es31a GL_EXT_primitive_bounding_box GL_OES_standard_derivatives GL_OES_vertex_array_object GL_KHR_debug

重现顶点着色器

attribute highp vec4 Pos;
uniform mat4 ModelViewProj;

void main(void)
{
gl_Position = ModelViewProj * Pos;
}

Repro fragment 着色器

#if GL_OES_standard_derivatives
# extension GL_OES_standard_derivatives : enable
#endif // GL_OES_standard_derivatives

void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}

最佳答案

我对问题的主要观察是,通过查看 gl 详细信息,我的 GL 版本为 3.0,GLSL 为 3.1,这听起来不太可能。我围绕检查 OpenGL 版本并加载没有扩展代码的着色器来尝试补偿它建立了一个工作。然后我只是硬编码一些值来代替扩展代码。它适用于我正在使用的着色器类型,但我可以想象会有其他人没有合适的值可供使用的情况。
然而,在发布游戏后,我目前无法访问的其他设备(Android 5.0 上的三星 Galaxy Note4/S5 和 Android 5.1 上的 Nexus 6)通过 google play 报告了相同的调用堆栈。

编辑:找到问题的实际解决方案。

扩展宏的#if 检查不正确,应使用#ifdef 或#if defined() 检查。
此代码将正确编译并且不会导致崩溃:

#ifdef GL_OES_standard_derivatives
# extension GL_OES_standard_derivatives : enable
#endif // GL_OES_standard_derivatives

void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}

来自GLSL Specification , 第 12 页:

#if, #ifdef, #ifndef, #else, #elif, and #endif are defined to operate as for C++ except for the following:

  • Expressions following #if and #elif are restricted to expressions operating on literal integer constants, plus identifiers consumed by the defined operator.
  • Undefined identifiers not consumed by the defined operator do not default to '0'. Use of such identifiers causes an error.
  • Character constants are not supported.

但是在一些实验中我发现以下代码将无法编译但不会在 glCompileShader 期间崩溃:

#if GL_OES_standard_derivatives
//# extension GL_OES_standard_derivatives : enable
#endif // GL_OES_standard_derivatives

void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}

关于android - 使用不匹配的驱动程序版本启用 glsl 扩展时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29125492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com