Skip to content

Commit

Permalink
WIP renderdoc support
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Dec 22, 2021
1 parent 587e604 commit 02e582b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ slog-async = "2.2"
slog-stdlog = "4.1.0"
slog-scope = "4.4.0"
xkbcommon = "0.4.0"
renderdoc = "0.10.1"

[dependencies.smithay]
path = ".."
Expand Down
2 changes: 2 additions & 0 deletions anvil/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub struct AnvilState<BackendData> {
// things we must keep alive
#[cfg(feature = "xwayland")]
pub xwayland: XWayland<AnvilState<BackendData>>,
pub renderdoc: Option<renderdoc::RenderDoc<renderdoc::V141>>,
}

impl<BackendData: Backend + 'static> AnvilState<BackendData> {
Expand Down Expand Up @@ -240,6 +241,7 @@ impl<BackendData: Backend + 'static> AnvilState<BackendData> {
start_time: std::time::Instant::now(),
#[cfg(feature = "xwayland")]
xwayland,
renderdoc: renderdoc::RenderDoc::new().ok(),
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions anvil/src/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ pub fn run_x11(log: Logger) {
state.start_xwayland();

info!(log, "Initialization completed, starting the main loop.");


while state.running.load(Ordering::SeqCst) {
let mut space = state.space.borrow_mut();
Expand All @@ -226,6 +227,9 @@ pub fn run_x11(log: Logger) {
continue;
}

if let Some(mut renderdoc) = state.renderdoc.as_mut() {
renderdoc.start_frame_capture(renderer.egl.context, std::ptr::null());
}
// TODO fullscreen surface

let mut elements = Vec::new();
Expand Down Expand Up @@ -283,6 +287,10 @@ pub fn run_x11(log: Logger) {
}
_ => {}
}

if let Some(mut renderdoc) = state.renderdoc.as_mut() {
renderdoc.end_frame_capture(renderer.egl.context, std::ptr::null());
}

#[cfg(feature = "debug")]
state.backend_data.fps.tick();
Expand Down
2 changes: 1 addition & 1 deletion src/backend/egl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use slog::{info, o, trace};
/// EGL context for rendering
#[derive(Debug)]
pub struct EGLContext {
context: ffi::egl::types::EGLContext,
pub context: ffi::egl::types::EGLContext,
pub(crate) display: EGLDisplay,
config_id: ffi::egl::types::EGLConfig,
pixel_format: Option<PixelFormat>,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/renderer/gles2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub struct Gles2Renderer {
solid_program: Gles2SolidProgram,
#[cfg(feature = "wayland_frontend")]
dmabuf_cache: std::collections::HashMap<WeakDmabuf, Gles2Texture>,
egl: EGLContext,
pub egl: EGLContext,
#[cfg(all(feature = "wayland_frontend", feature = "use_system_lib"))]
egl_reader: Option<EGLBufferReader>,
vbos: [ffi::types::GLuint; 2],
Expand Down

0 comments on commit 02e582b

Please sign in to comment.