首页 > 解决方案 > OpenGL ES / Vulkan:每个片段模板写入/测试(在 Qualcomm Snapdragon XR2 上)

问题描述

我想渲染两个网格,第一个写入模板缓冲区,第二个对其进行测试。我想在每个片段级别上执行此操作(第一个对象的片段着色器应该定义将哪个值写入模板缓冲区,第二个对象的片段着色器应该定义第二个对象的片段是否以及针对哪个模板值对象应该被剪裁)。

我的目标平台是具有 Qualcomm Snapdragon XR 的 Oculus Quest 2。

如果平台支持 GL_ARM_shader_framebuffer_fetch_depth_stencil,我可以使用它,但仅在某些 Mali GPU 上支持。

我想使用模板的原因是,出于性能原因,我想在单个前向渲染过程中渲染所有内容,并且由于我已经被迫在我的着色器中使用片段丢弃,所以早期的 z 拒绝无论如何都不在桌面上,所以这不是关注。

如何在 OpenGL ES 3.0 或 Vulkan 中在 Qualcomm Snapdragon XR2 上实现每个片段模板编写/测试?

任何指针表示赞赏。

标签: opengl-esrenderingvulkanfragment-shaderstencil-buffer

解决方案


我最近必须为一个项目打印 Quest 2 上所有可用的扩展,并且可以确认它GL_ARM_shader_framebuffer_fetch_depth_stencil 受支持的。

需要明确的是,这个扩展只允许读取模板值,而不是写入它。

如果有帮助,这些是受支持的扩展:

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_texture
GL_KHR_texture_compression_astc_ldr
GL_KHR_texture_compression_astc_hdr
GL_OES_texture_compression_astc
GL_OES_texture_npot
GL_EXT_texture_filter_anisotropic
GL_EXT_texture_format_BGRA8888
GL_EXT_read_format_bgra
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_EXT_texture_format_sRGB_override
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_EGL_image_external_wrap_modes
GL_EXT_multisampled_render_to_texture
GL_EXT_multisampled_render_to_texture2
GL_OES_shader_multisample_interpolation
GL_EXT_texture_cube_map_array
GL_EXT_draw_buffers_indexed
GL_EXT_gpu_shader5
GL_EXT_robustness
GL_EXT_texture_buffer
GL_EXT_shader_framebuffer_fetch
GL_ARM_shader_framebuffer_fetch_depth_stencil
GL_OES_texture_storage_multisample_2d_array
GL_OES_sample_shading
GL_OES_get_program_binary
GL_EXT_debug_label
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_EXT_disjoint_timer_query
GL_KHR_debug
GL_EXT_YUV_target
GL_EXT_sRGB_write_control
GL_EXT_texture_norm16
GL_EXT_discard_framebuffer
GL_OES_surfaceless_context
GL_OVR_multiview
GL_OVR_multiview2
GL_EXT_texture_sRGB_R8
GL_KHR_no_error
GL_EXT_debug_marker
GL_OES_EGL_image_external_essl3
GL_OVR_multiview_multisampled_render_to_texture
GL_EXT_buffer_storage
GL_EXT_external_buffer
GL_EXT_blit_framebuffer_params
GL_EXT_clip_cull_distance
GL_EXT_protected_textures
GL_EXT_shader_non_constant_global_initializers
GL_QCOM_texture_foveated
GL_QCOM_texture_foveated2
GL_QCOM_texture_foveated_subsampled_layout
GL_QCOM_shader_framebuffer_fetch_noncoherent
GL_QCOM_shader_framebuffer_fetch_rate
GL_EXT_memory_object
GL_EXT_memory_object_fd
GL_EXT_EGL_image_array
GL_NV_shader_noperspective_interpolation
GL_KHR_robust_buffer_access_behavior
GL_EXT_EGL_image_storage
GL_EXT_blend_func_extended
GL_EXT_clip_control
GL_OES_texture_view
GL_EXT_fragment_invocation_density
GL_QCOM_motion_estimation
GL_QCOM_validate_shader_binary
GL_QCOM_YUV_texture_gather
GL_IMG_texture_filter_cubic```

推荐阅读