mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	render/gles2: add a few 10-bit and FP16 formats
The half-float formats depend on GL_OES_texture_half_float_linear, not just the GL_OES_texture_half_float extension, because the latter does not include support for linear magni/minification filters. The new 2101010 and 16161616F formats are only available on little- endian builds, since their gl_types are larger than a byte and thus endianness dependent.
This commit is contained in:
		
							parent
							
								
									44e8451cd9
								
							
						
					
					
						commit
						f5df956c18
					
				
					 3 changed files with 40 additions and 1 deletions
				
			
		| 
						 | 
					@ -43,6 +43,8 @@ struct wlr_gles2_renderer {
 | 
				
			||||||
		bool KHR_debug;
 | 
							bool KHR_debug;
 | 
				
			||||||
		bool OES_egl_image_external;
 | 
							bool OES_egl_image_external;
 | 
				
			||||||
		bool OES_egl_image;
 | 
							bool OES_egl_image;
 | 
				
			||||||
 | 
							bool EXT_texture_type_2_10_10_10_REV;
 | 
				
			||||||
 | 
							bool OES_texture_half_float_linear;
 | 
				
			||||||
	} exts;
 | 
						} exts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,7 +69,30 @@ static const struct wlr_gles2_pixel_format formats[] = {
 | 
				
			||||||
		.gl_type = GL_UNSIGNED_SHORT_5_6_5,
 | 
							.gl_type = GL_UNSIGNED_SHORT_5_6_5,
 | 
				
			||||||
		.has_alpha = false,
 | 
							.has_alpha = false,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	// TODO: EXT_texture_type_2_10_10_10_REV support
 | 
						{
 | 
				
			||||||
 | 
							.drm_format = DRM_FORMAT_XBGR2101010,
 | 
				
			||||||
 | 
							.gl_format = GL_RGBA,
 | 
				
			||||||
 | 
							.gl_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT,
 | 
				
			||||||
 | 
							.has_alpha = false,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							.drm_format = DRM_FORMAT_ABGR2101010,
 | 
				
			||||||
 | 
							.gl_format = GL_RGBA,
 | 
				
			||||||
 | 
							.gl_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT,
 | 
				
			||||||
 | 
							.has_alpha = true,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							.drm_format = DRM_FORMAT_XBGR16161616F,
 | 
				
			||||||
 | 
							.gl_format = GL_RGBA,
 | 
				
			||||||
 | 
							.gl_type = GL_HALF_FLOAT_OES,
 | 
				
			||||||
 | 
							.has_alpha = false,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							.drm_format = DRM_FORMAT_ABGR16161616F,
 | 
				
			||||||
 | 
							.gl_format = GL_RGBA,
 | 
				
			||||||
 | 
							.gl_type = GL_HALF_FLOAT_OES,
 | 
				
			||||||
 | 
							.has_alpha = true,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +100,14 @@ static const struct wlr_gles2_pixel_format formats[] = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool is_gles2_pixel_format_supported(const struct wlr_gles2_renderer *renderer,
 | 
					bool is_gles2_pixel_format_supported(const struct wlr_gles2_renderer *renderer,
 | 
				
			||||||
		const struct wlr_gles2_pixel_format *format) {
 | 
							const struct wlr_gles2_pixel_format *format) {
 | 
				
			||||||
 | 
						if (format->gl_type == GL_UNSIGNED_INT_2_10_10_10_REV_EXT
 | 
				
			||||||
 | 
								&& !renderer->exts.EXT_texture_type_2_10_10_10_REV) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (format->gl_type == GL_HALF_FLOAT_OES
 | 
				
			||||||
 | 
								&& !renderer->exts.OES_texture_half_float_linear) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (format->gl_format == GL_BGRA_EXT
 | 
						if (format->gl_format == GL_BGRA_EXT
 | 
				
			||||||
			&& !renderer->exts.EXT_read_format_bgra) {
 | 
								&& !renderer->exts.EXT_read_format_bgra) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -749,6 +749,12 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
 | 
				
			||||||
	renderer->exts.EXT_read_format_bgra =
 | 
						renderer->exts.EXT_read_format_bgra =
 | 
				
			||||||
		check_gl_ext(exts_str, "GL_EXT_read_format_bgra");
 | 
							check_gl_ext(exts_str, "GL_EXT_read_format_bgra");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						renderer->exts.EXT_texture_type_2_10_10_10_REV =
 | 
				
			||||||
 | 
							check_gl_ext(exts_str, "GL_EXT_texture_type_2_10_10_10_REV");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						renderer->exts.OES_texture_half_float_linear =
 | 
				
			||||||
 | 
							check_gl_ext(exts_str, "GL_OES_texture_half_float_linear");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (check_gl_ext(exts_str, "GL_KHR_debug")) {
 | 
						if (check_gl_ext(exts_str, "GL_KHR_debug")) {
 | 
				
			||||||
		renderer->exts.KHR_debug = true;
 | 
							renderer->exts.KHR_debug = true;
 | 
				
			||||||
		load_gl_proc(&renderer->procs.glDebugMessageCallbackKHR,
 | 
							load_gl_proc(&renderer->procs.glDebugMessageCallbackKHR,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue