mirror of
https://github.com/alacritty/alacritty
synced 2024-09-06 00:04:40 +00:00
Add 'debug.renderer' config option
This should help trouble shooting the renderer being created and different renderer options to determine when something like dual-source rendering isn't working.
This commit is contained in:
parent
19120f40be
commit
2d619850ae
|
@ -888,6 +888,12 @@
|
|||
# - Trace
|
||||
#log_level: Warn
|
||||
|
||||
# Renderer override.
|
||||
# - glsl3
|
||||
# - gles2
|
||||
# - gles2_pure
|
||||
#renderer: None
|
||||
|
||||
# Print all received window events.
|
||||
#print_events: false
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use log::LevelFilter;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use alacritty_config_derive::ConfigDeserialize;
|
||||
|
||||
/// Debugging options.
|
||||
|
@ -18,6 +20,9 @@ pub struct Debug {
|
|||
/// Highlight damage information produced by alacritty.
|
||||
pub highlight_damage: bool,
|
||||
|
||||
/// The renderer alacritty should be using.
|
||||
pub renderer: Option<RendererPreference>,
|
||||
|
||||
/// Record ref test.
|
||||
#[config(skip)]
|
||||
pub ref_test: bool,
|
||||
|
@ -32,6 +37,23 @@ impl Default for Debug {
|
|||
render_timer: Default::default(),
|
||||
highlight_damage: Default::default(),
|
||||
ref_test: Default::default(),
|
||||
renderer: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The renderer configuration options.
|
||||
#[derive(Deserialize, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum RendererPreference {
|
||||
/// OpenGL 3.3 renderer.
|
||||
#[serde(rename = "glsl3")]
|
||||
Glsl3,
|
||||
|
||||
/// GLES 2 renderer, with optional extensions like dual source blending.
|
||||
#[serde(rename = "gles2")]
|
||||
Gles2,
|
||||
|
||||
/// Pure GLES 2 renderer.
|
||||
#[serde(rename = "gles2_pure")]
|
||||
Gles2Pure,
|
||||
}
|
||||
|
|
|
@ -420,7 +420,7 @@ impl Display {
|
|||
let context = gl_context.make_current(&surface)?;
|
||||
|
||||
// Create renderer.
|
||||
let mut renderer = Renderer::new(&context)?;
|
||||
let mut renderer = Renderer::new(&context, config.debug.renderer)?;
|
||||
|
||||
// Load font common glyphs to accelerate rendering.
|
||||
debug!("Filling glyph cache with common glyphs");
|
||||
|
|
|
@ -13,6 +13,7 @@ use alacritty_terminal::index::Point;
|
|||
use alacritty_terminal::term::cell::Flags;
|
||||
use alacritty_terminal::term::color::Rgb;
|
||||
|
||||
use crate::config::debug::RendererPreference;
|
||||
use crate::display::content::RenderableCell;
|
||||
use crate::display::SizeInfo;
|
||||
use crate::gl;
|
||||
|
@ -87,7 +88,10 @@ impl Renderer {
|
|||
///
|
||||
/// This will automatically pick between the GLES2 and GLSL3 renderer based on the GPU's
|
||||
/// supported OpenGL version.
|
||||
pub fn new(context: &PossiblyCurrentContext) -> Result<Self, Error> {
|
||||
pub fn new(
|
||||
context: &PossiblyCurrentContext,
|
||||
renderer_prefernce: Option<RendererPreference>,
|
||||
) -> Result<Self, Error> {
|
||||
// We need to load OpenGL functions once per instance, but only after we make our context
|
||||
// current due to WGL limitations.
|
||||
if !GL_FUNS_LOADED.swap(true, Ordering::Relaxed) {
|
||||
|
@ -106,12 +110,20 @@ impl Renderer {
|
|||
|
||||
info!("Running on {}", renderer);
|
||||
|
||||
let (text_renderer, rect_renderer) = if version.as_ref() >= "3.3" {
|
||||
// Use the config option to enforce a particular renderer configuration.
|
||||
let (use_glsl3, allow_dsb) = match renderer_prefernce {
|
||||
Some(RendererPreference::Glsl3) => (true, true),
|
||||
Some(RendererPreference::Gles2) => (false, true),
|
||||
Some(RendererPreference::Gles2Pure) => (false, false),
|
||||
None => (version.as_ref() >= "3.3", true),
|
||||
};
|
||||
|
||||
let (text_renderer, rect_renderer) = if use_glsl3 {
|
||||
let text_renderer = TextRendererProvider::Glsl3(Glsl3Renderer::new()?);
|
||||
let rect_renderer = RectRenderer::new(ShaderVersion::Glsl3)?;
|
||||
(text_renderer, rect_renderer)
|
||||
} else {
|
||||
let text_renderer = TextRendererProvider::Gles2(Gles2Renderer::new()?);
|
||||
let text_renderer = TextRendererProvider::Gles2(Gles2Renderer::new(allow_dsb)?);
|
||||
let rect_renderer = RectRenderer::new(ShaderVersion::Gles2)?;
|
||||
(text_renderer, rect_renderer)
|
||||
};
|
||||
|
|
|
@ -37,11 +37,12 @@ pub struct Gles2Renderer {
|
|||
}
|
||||
|
||||
impl Gles2Renderer {
|
||||
pub fn new() -> Result<Self, Error> {
|
||||
pub fn new(allow_dsb: bool) -> Result<Self, Error> {
|
||||
info!("Using OpenGL ES 2.0 renderer");
|
||||
|
||||
let dual_source_blending = GlExtensions::contains("GL_EXT_blend_func_extended")
|
||||
|| GlExtensions::contains("GL_ARB_blend_func_extended");
|
||||
let dual_source_blending = allow_dsb
|
||||
&& (GlExtensions::contains("GL_EXT_blend_func_extended")
|
||||
|| GlExtensions::contains("GL_ARB_blend_func_extended"));
|
||||
|
||||
if dual_source_blending {
|
||||
info!("Using dual source blending");
|
||||
|
|
Loading…
Reference in a new issue