framebufferfetch in mali multiple render targets mrt


gl_LastFragColorARM

https://www.khronos.org/registry/OpenGL/extensions/ARM/ARM_shader_framebuffer_fetch.txt

https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_shader_framebuffer_fetch.txt

上擴展鎮樓

mali真是奇 似乎不支持通用擴展

query試試

程序員職業素養。。。內事不決問unreal。。。ue已經做了singlepass deferred了 。。。但沒做metal2的!

mali G76 extension query不支持 EXT_shader_framebuffer_fetch只有ARM_shader_framebuffer_fetch

我看ue寫了arm這個擴展

unity根本沒做 

GL_ARM_shader_framebuffer_fetch 這個貌似不支持 mrt

可以query

 FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM           0x8F66

 GetBooleanv

即便query出來 我就沒看到使用的語法。。

這個single query unity根本就沒包。。。 只包了GetIntegerv

人家ue都有GetBooleanv。。。

 integerv  query不到 0x8F66 glGetIntegerv: GL_INVALID_ENUM: enum argument out of range(因為是adreno。。。。)

booleanv 加不進去。。

 integerv  query 支持mrt。。ogles3.2支持0x8F66query 支持framebufferfetch mrt 下面問題就是語法是什么呢。。。

gl_FragColor = gl_LastFragColorARM + vec4(0.0, 1.0, 1.0, 1.0);

gl_LastFragColorARM[0]只能拿到float 拿不到vector4.。。

那語法能是啥

 請教了一下 原來 這個query通過意思是 對於mrt

用 gl_LastFragColorARM那rt0 是可以拿到的 不是未定義的行為

而rt1.2 是沒有提供拿到的語法的 

arm fbf擴展這里就是比ext fbf擴展少這個功能的

 

還得給mali專門再寫套管線。。。

G76 的extension

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
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_
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_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

 

這里肯定有工作量了 

1.GL_EXT_shader_pixel_local_storage

這是一個方法 它有這個通用擴展

2.vulkan subpass

3.zprepass   mask +depth+ 引擎加 GL_ARM_shader_framebuffer_fetch

 

有關擴展 遇到個很坑的問題

https://www.khronos.org/registry/OpenGL/api/GLES2/gl2ext.h

比如 GL_EXT_shader_pixel_local_storage這個 宏在哪開的 找遍unity沒找到

原來是 opengl里定義的 並且和#extension GL_EXT_shader_pixel_local_storage: enable

無關

它就是

#ifndef GL_EXT_shader_pixel_local_storage
#define GL_EXT_shader_pixel_local_storage 1
#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
#endif /* GL_EXT_shader_pixel_local_storage */

另外一些擴展的宏就是沒定義 就是沒定義。。。

https://www.khronos.org/registry/OpenGL/index_es.php

https://www.khronos.org/registry/OpenGL/api/GLES2/gl2ext.h

https://www.khronos.org/registry/OpenGL/api/GLES3/gl32.h

比如 GL_EXT_tessellation_shader GL_EXT_sRGB GL_EXT_robustness GL_KHR_robustness 他們都是G76支持的ext 

可能是我寫的fragment shader 里沒有觸發 上面的這幾個宏的define? 

 

    Including the following line in a shader can be used to control the
    language features described in this extension:

      #extension GL_EXT_tessellation_shader : <behavior>
      #extension GL_EXT_tessellation_point_size : <behavior>

    where <behavior> is as specified in section 3.4.

    A new preprocessor #define is added to the OpenGL ES Shading Language:

      #define GL_EXT_tessellation_shader 1
      #define GL_EXT_tessellation_point_size 1

好像我猜的對。。。

但是和 gl2ext.h里這個說不通

#ifndef GL_EXT_tessellation_shader
#define GL_EXT_tessellation_shader 1
#define GL_PATCHES_EXT                    0x000E
#define GL_PATCH_VERTICES_EXT             0x8E72
#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
#define GL_TESS_GEN_MODE_EXT              0x8E76
。。。。。。。。。。。。。

 不過GL_ARM_shader_framebuffer_fetch

GL_ARM_shader_framebuffer_fetch_depth_stencil

在G76的fragmentshader里是 define的 

#version 320 es
#ifdef GL_ARM_shader_framebuffer_fetch
#extension GL_ARM_shader_framebuffer_fetch : enable
#endif
precision mediump float;

void main()
{
#ifdef GL_ARM_shader_framebuffer_fetch
gl_FragColor = gl_LastFragColorARM + vec4(0.0, 0.0, 1.0, 1.0);
#else
gl_FragColor = gl_LastFragColorARM+ vec4(1.0, 0.0, 0.0, 1.0);
#endif
}

 

unity這代碼看的我昏天暗地的

它有個宏

FRAMEBUFFERFETCH

跟這個flag kShaderRequireFramebufferFetch

https://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/

 

unity 解決方案

pc用一個pass

ios和android adreno用 cgprogram inout

android mali用glsl 

perfect

 //////////////////////////////

// ::printf_console("mg============testoutput01");
// GLboolean armMrtBool = false;
//FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66
// GLES_CALL(api, glGetBooleanv, 0x8F66, &armMrtBool);
/// api->glGetBooleanv(0x8F66, &armMrtBool);
//GLint armMrtBool = 0;
////FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66
//GLES_CALL(api, glGetIntegerv, 0x8F66, &armMrtBool);
//api->glGetBooleanv(0x8F66, &armMrtBool);
// ::printf_console("mg====================armMRT supported:%d", armMrtBool);
// ::printf_console("mg====================armMRT supported:%s", armMrtBool ? "true": "false");
// ::printf_console("mg============testoutput02");
if (extensionString.size())

GraphicsCapsGLES.cpp

//--version--

arm mrt 考慮depthstencil fbf

或者pixel_local_storage

考慮到后者 unity和ue都沒包 前者是比較推薦的方案了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM