我試圖在運行時使用shaderc編譯glsl着色器來spir-v。該庫在桌面win32應用程序上運行良好,但是當我嘗試在使用Visual Studio 2017的android上移動它時,如果着色器沒有編譯錯誤,它會崩潰。我正在測試NVIDIA屏蔽平板電腦。Shaderc在調用glsl時崩潰android上的spv程序集
這是代碼的版本的崩潰之一:
void android_main(struct android_app* state)
{
shaderc::Compiler compiler;
shaderc::CompileOptions options;
char test_program[] = "#version 450 \n void main() { gl_Position = vec4(0.0f, 0.0f, 0.0f, 0.0f);}";
shaderc::AssemblyCompilationResult assembly =
compiler.CompileGlslToSpvAssembly(test_program, strlen(test_program),
shaderc_glsl_vertex_shader, "shader", "main", options);
if(assembly.GetCompilationStatus() != shaderc_compilation_status_success)
LOGI(assembly.GetErrorMessage().c_str());
std::string resultAssembly(assembly.cbegin(), assembly.cend());
for(int i = 0; i < resultAssembly.length(); i++)
{
int newline = resultAssembly.find_first_of('\n', i);
newline = newline != -1 ? newline : resultAssembly.length();
LOGI("%s", resultAssembly.substr(i, newline - i).c_str());
i = newline;
}
compiler.CompileGlslToSpv(test_program, strlen(test_program),
shaderc_glsl_vertex_shader, "shader");
}
有了這個logcat的:
08-28 22:36:38.431 5450 5484 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x48 in tid 5484 (m.AndroidEngine)
08-28 22:36:38.432 5450 5458 I art : Starting a blocking GC Instrumentation
08-28 22:36:38.434 183 183 W : debuggerd: handling request: pid=5450 uid=10154 gid=10154 tid=5484
08-28 22:36:38.548 5487 5487 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-28 22:36:38.550 5487 5487 F DEBUG : Build fingerprint: 'nvidia/wx_un_do/shieldtablet:7.0/NRD90M/1928188_904.2811:user/release-keys'
08-28 22:36:38.550 5487 5487 F DEBUG : Revision: '0'
08-28 22:36:38.551 5487 5487 F DEBUG : ABI: 'arm'
08-28 22:36:38.552 5487 5487 F DEBUG : pid: 5450, tid: 5484, name: m.AndroidEngine >>> com.AndroidEngine <<<
08-28 22:36:38.553 5487 5487 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x48
08-28 22:36:38.553 5487 5487 F DEBUG : r0 95642fe0 r1 00000002 r2 95ae6428 r3 9564201c
08-28 22:36:38.554 5487 5487 F DEBUG : r4 95641f60 r5 95642fe0 r6 00000048 r7 956416e0
08-28 22:36:38.555 5487 5487 F DEBUG : r8 00000002 r9 00000000 sl 00000005 fp fffffcb8
08-28 22:36:38.556 5487 5487 F DEBUG : ip 0000002e sp 956416c0 lr 95ae63bb pc 00000048 cpsr 200f0010
08-28 22:36:38.578 5487 5487 F DEBUG :
08-28 22:36:38.578 5487 5487 F DEBUG : backtrace:
08-28 22:36:38.579 5487 5487 F DEBUG : #00 pc 00000048 <unknown>
08-28 22:36:38.579 5487 5487 F DEBUG : #01 pc 0017b3b9 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZN8libspirv16DiagnosticStreamD2Ev+84)
08-28 22:36:38.579 5487 5487 F DEBUG : #02 pc 00159a2d /data/app/com.AndroidEngine-1/lib/arm/libVkLayer_core_validation.so (spvBinaryParse+5248)
08-28 22:36:38.580 5487 5487 F DEBUG : #03 pc 00194065 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZN8libspirv18FriendlyNameMapperC1EPK13spv_context_tPKjj+124)
08-28 22:36:38.580 5487 5487 F DEBUG : #04 pc 0017a697 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (spvBinaryToText+174)
08-28 22:36:38.580 5487 5487 F DEBUG : #05 pc 0017a463 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZNK8spvtools10SpirvTools11DisassembleEPKjjPSsj+38)
08-28 22:36:38.581 5487 5487 F DEBUG : #06 pc 0017a435 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZNK8spvtools10SpirvTools11DisassembleERKSt6vectorIjSaIjEEPSsj+24)
08-28 22:36:38.581 5487 5487 F DEBUG : #07 pc 0014d1e9 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZN12shaderc_util21SpirvToolsDisassembleENS_8Compiler9TargetEnvERKSt6vectorIjSaIjEEPSs+96)
08-28 22:36:38.581 5487 5487 F DEBUG : #08 pc 0014e013 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZNK12shaderc_util8Compiler7CompileERKNS_12string_pieceE11EShLanguageRKSsPKcRKSt8functionIFS4_PSoS3_EERNS_16CountingIncluderENS0_10OutputTypeESA_PjSI_PNS_18GlslangInitializerE+1246)
08-28 22:36:38.581 5487 5487 F DEBUG : #09 pc 000d34bf /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so
08-28 22:36:38.582 5487 5487 F DEBUG : #10 pc 000d3793 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (shaderc_compile_into_spv_assembly+22)
08-28 22:36:38.582 5487 5487 F DEBUG : #11 pc 000c4167 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (_ZNK7shaderc8Compiler24CompileGlslToSpvAssemblyEPKcj19shaderc_shader_kindS2_S2_RKNS_14CompileOptionsE+42)
08-28 22:36:38.582 5487 5487 F DEBUG : #12 pc 000c3ce1 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so (android_main+120)
08-28 22:36:38.582 5487 5487 F DEBUG : #13 pc 000d1219 /data/app/com.AndroidEngine-1/lib/arm/libAndroidEngine.so
08-28 22:36:38.583 5487 5487 F DEBUG : #14 pc 000475c3 /system/lib/libc.so (_ZL15__pthread_startPv+22)
08-28 22:36:38.583 5487 5487 F DEBUG : #15 pc 0001a115 /system/lib/libc.so (__start_thread+6)
08-28 22:36:39.012 5487 5487 E : debuggerd: failed to kill process 5450: No such process
08-28 22:36:39.014 183 183 W : debuggerd: resuming target 5450
目前沒有任何崩潰,如果着色器編譯錯誤:程序只是打印編譯錯誤信息。 Visual Studio顯示分段錯誤錯誤。 如果我編寫時沒有CompileGlslToSpvAssembly,並嘗試使用CompileGlslToSpv,那麼在創建vulkan着色器模塊時沒有logcat中的任何內容會出現分段錯誤錯誤。
我試着使用:
從GitHub庫中的最新shaderc代碼NDK R13B,R14B,r15b命令行通過NDK,球泡建造(也帶有鏈接在Visual Studio中的參數NDK目錄)
shaderc在ndk r13b和r14b的第三方子目錄中提供。如在NDK FAQ所示BULDING:
Ndk_path/NDK-build.cmd」。-B NDK_PROJECT_PATH = APP_BULD_SCRIPT = Android.mk APP_STL = gnustl_static APP_ABI = armeabi-V7A APP_PLATFORM =機器人-24 ANDROID_CPP_FEATURES = 「例外」 libshaderc_combined
非常感謝!它現在運作良好。這是否意味着無法使用運行時着色器編譯使用驗證圖層?至少現在呢? –
已更新的答案指向固定的驗證圖層源。 – awoloszyn