Search Unity

Bug URP Shader FrameBuffer Fetch Mali Crash

Discussion in 'Universal Render Pipeline' started by fly-codes, Apr 20, 2023.

  1. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6
    Code (CSharp):
    1. Shader "unlit/test"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Main Color", Color) = (1,1,1,1)
    6.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    7.     }
    8.     SubShader
    9.     {
    10.         Tags
    11.         {
    12.             "Queue"="Transparent"
    13.             "IgnoreProjector"="True"
    14.             "RenderType"="Transparent"
    15.             "PreviewType"="Plane"
    16.             "CanUseSpriteAtlas"="True"
    17.         }
    18.  
    19.         Pass
    20.         {
    21.             Name "ForwardLit"
    22.             Tags {"LightMode" = "UniversalForward"}
    23.  
    24.             HLSLPROGRAM
    25.  
    26.             #define ENABLE_FRAMEBUFFER_FETCH 1
    27.  
    28.             #pragma vertex Vertex
    29.             #pragma fragment Fragment
    30.  
    31.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    32.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
    33.  
    34.             struct Attributes
    35.             {
    36.                 float4 positionOS   : POSITION;
    37.                 float4 color        : COLOR;
    38.                 float2 texcoord     : TEXCOORD0;
    39.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    40.             };
    41.    
    42.             struct Varyings
    43.             {
    44.                 float4 positionCS    : SV_POSITION;
    45.                 float4 texcoord      : TEXCOORD0;
    46.                 half4 color            : TEXCOORD2;
    47.                 UNITY_VERTEX_OUTPUT_STEREO
    48.             };
    49.  
    50.             TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
    51.  
    52.             CBUFFER_START(UnityPerMaterial)
    53.             half4 _Color;
    54.             CBUFFER_END      
    55.    
    56.             Varyings Vertex(Attributes input)
    57.             {
    58.                 Varyings output;
    59.                 UNITY_SETUP_INSTANCE_ID(input);
    60.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
    61.  
    62.                 output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
    63.                 output.texcoord = input.texcoord.xyxy;
    64.                 output.color = input.color;
    65.                 return output;
    66.             }
    67.  
    68.             half4 FragmentInner(Varyings input)
    69.             {
    70.                 half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_LinearClamp, input.texcoord.xy).rgba;
    71.                 return color * input.color * _Color;
    72.             }
    73.  
    74.             void Fragment(Varyings input, inout half4 output : CoLoR0)
    75.             {
    76.                 half4 col = FragmentInner(input);
    77.                 output.rgb = lerp(output.rgb, col.rgb, col.a); output.a = col.a;
    78.             }
    79.  
    80.             ENDHLSL
    81.         }
    82.     }
    83. }
    84.  
    Unity 2021.3.23
    Custom SRP
    Device : HUAWEI P40 --- Mali-G76

    Shader Above crash at shader compiling.....
    if i remove SAMPLE_TEXTURE2D code like this
    Code (CSharp):
    1. half4 FragmentInner(Varyings input)
    2. {
    3.     return input.color * _Color;
    4. }
    then it complie sucssed and work well
     

    Attached Files:

    dan_ginovker likes this.
  2. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6
    2023/04/20 19:54:30.381 13797 13919 Error CRASH *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    2023/04/20 19:54:30.381 13797 13919 Error CRASH Version '2021.3.23f1 (213b516bf396)', Build type 'Development', Scripting Backend 'mono', CPU 'armeabi-v7a'
    2023/04/20 19:54:30.381 13797 13919 Error CRASH Build fingerprint: 'HUAWEI/ANA-AN00/HWANA:12/HUAWEIANA-AN00/103.0.0.208C00:user/release-keys'
    2023/04/20 19:54:30.381 13797 13919 Error CRASH Revision: '0'
    2023/04/20 19:54:30.381 13797 13919 Error CRASH ABI: 'arm'
    2023/04/20 19:54:30.381 13797 13919 Error CRASH Timestamp: 2023-04-20 19:54:30+0800
    2023/04/20 19:54:30.381 13797 13919 Error CRASH pid: 13797, tid: 13919, name: UnityGfxDeviceW >>> com.wygame.crisisx <<<
    2023/04/20 19:54:30.381 13797 13919 Error CRASH uid: 10190
    2023/04/20 19:54:30.381 13797 13919 Error CRASH signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x34
    2023/04/20 19:54:30.381 13797 13919 Error CRASH Cause: null pointer dereference
    2023/04/20 19:54:30.381 13797 13919 Error CRASH r0 a0ed35c0 r1 e27ed6cc r2 a4d9ac28 r3 00000000
    2023/04/20 19:54:30.381 13797 13919 Error CRASH r4 e27ed6cc r5 a0ad2300 r6 00000001 r7 00000001
    2023/04/20 19:54:30.381 13797 13919 Error CRASH r8 00000001 r9 e4d58240 r10 00000000 r11 00000002
    2023/04/20 19:54:30.381 13797 13919 Error CRASH ip 00000001 sp a4d9abc4 lr c32addd1 pc c33ad5be
    2023/04/20 19:54:30.381 13797 13919 Error CRASH backtrace:
    2023/04/20 19:54:30.381 13797 13919 Error CRASH #00 pc 0181b5be /vendor/lib/egl/libGLES_mali.so (BuildId: 723c25d85ed1c737)
    2023/04/20 19:54:30.451 13797 13919 Error CRASH Forwarding signal 11
     
  3. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6
    2023/04/20 19:54:29.555 13797 13846 Debug Unity GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_EXT_texture_compression_astc_decode_mode GL_EXT_texture_compression_astc_decode_mode_rgb9e5 GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer
    2023/04/20 19:54:29.555 13797 13846 Debug Unity GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_EXT_multisampled_render_to_texture2 GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic GL_EXT_robustness GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed GL_EXT_texture_border_clamp GL_OES_texture_border_clamp GL_EXT_texture_cube_map_array GL_OES_texture_cube_map_array GL_OES_sample_variables GL_OES_sample_shading GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks GL_OES_shader_io_blocks GL_EXT_tessellation_shader GL_OES_tessellation_shader GL_EXT_primitive_bounding_box GL_OES_primitive_bounding_
    2023/04/20 19:54:29.555 13797 13846 Debug Unity box GL_EXT_geometry_shader GL_OES_geometry_shader GL_ANDROID_extension_pack_es31a GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture_buffer GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image GL_EXT_shader_non_constant_global_initializers GL_EXT_color_buffer_half_float GL_EXT_unpack_subimage GL_EXT_color_buffer_float GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2 GL_OVR_multiview_multisampled_render_to_texture GL_KHR_robustness GL_KHR_robust_buffer_access_behavior GL_EXT_draw_elements_base_vertex GL_OES_draw_elements_base_vertex GL_EXT_protected_textures GL_EXT_buffer_storage GL_EXT_external_buffer GL_EXT_EGL_image_array GL_EXT_texture_filter_anisotropic GL_ARM_texture_unnormalized_coordinates GL_HUAWEI_smart_cache GL_EXT_shader_framebuffer_fetch GL_HUAWEI_framebuffer_partial_update
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    Hi!
    Please report a bug - it shouldn't crash.
    Note that it won't fix your issue fully, for the extension that we use for framebuffer fetch is not supported on Mali.
     
  5. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6
    GLES 3.0 Only
    My HUAWEI P40, P40Pro, Meta 40 all Crash, it seems HUAWEI Mali all crash......
    Script :
    GraphicsSettings.HasShaderDefine(BuiltinShaderDefine.UNITY_FRAMEBUFFER_FETCH_AVAILABLE) return true

    Shader :
    UNITY_FRAMEBUFFER_FETCH_AVAILABLE is Enable

    Logcat print that my decives extention GL_EXT_shader_framebuffer_fetch is supported...

    I have send a bug report : CASE IN-39026
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    Oh, interesting, did they add it after all?
     
  7. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6
    upload_2023-4-21_17-12-38.png
    May that _MainTexture UNITY_LOCATION(1) need be After SV_Target0 ?
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    Relevant people will take a look at what's happening when they get to the bug you reported :)
     
  9. fly-codes

    fly-codes

    Joined:
    Dec 10, 2019
    Posts:
    6