From 84f7e586dad055e4310f8d50640d7c6e5e798642 Mon Sep 17 00:00:00 2001 From: Dimitri Sabadie Date: Tue, 7 Jul 2020 10:38:50 +0200 Subject: [PATCH] [luminance-examples] Add a fixture to demonstrate #360. --- integration-tests/desktop/src/main.rs | 19 ++++++------- .../desktop/src/manually_drop_framebuffer.rs | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 integration-tests/desktop/src/manually_drop_framebuffer.rs diff --git a/integration-tests/desktop/src/main.rs b/integration-tests/desktop/src/main.rs index 84cae31e..e0d8cc48 100644 --- a/integration-tests/desktop/src/main.rs +++ b/integration-tests/desktop/src/main.rs @@ -1,16 +1,16 @@ -mod gl33_f64_uniform; -mod scissor; -mod tess_no_data; - use colored::Colorize as _; macro_rules! tests { ($($name:expr, $module:ident),*) => { - const TEST_NAMES: &[&str] = &[$( - $name - ),* - ]; + // declare the modules for all tests + $( + mod $module; + )* + + // list of all available integration tests + const TEST_NAMES: &[&str] = &[$( $name ),*]; + // run a given test fn run_test(name: &str) { $( if name == $name { @@ -33,7 +33,8 @@ macro_rules! tests { tests! { "gl33-f64-uniform", gl33_f64_uniform, "tess-no-data", tess_no_data, - "scissor-test", scissor + "scissor-test", scissor, + "360-manually-drop-framebuffer", manually_drop_framebuffer } fn main() { diff --git a/integration-tests/desktop/src/manually_drop_framebuffer.rs b/integration-tests/desktop/src/manually_drop_framebuffer.rs new file mode 100644 index 00000000..e84b19be --- /dev/null +++ b/integration-tests/desktop/src/manually_drop_framebuffer.rs @@ -0,0 +1,27 @@ +//! +//! +//! When a framebuffer is created, dropped and a new one is created, the new framebuffer doesn’t +//! seem to behave correctly. At the time of #360, it was detected on Windows. +//! +//! Because this example simply creates a framebuffer, drops it and creates another one, nothing is +//! displayed and the window flashes on the screen. Run the application in a tool such as apitrace +//! or renderdoc to analyze it. + +use luminance::context::GraphicsContext as _; +use luminance::pixel::{Depth32F, RGBA32F}; +use luminance::texture::{Dim2, Sampler}; +use luminance_glfw::GlfwSurface; +use luminance_windowing::WindowOpt; + +pub fn fixture() { + let mut surface = + GlfwSurface::new_gl33("fixture-360", WindowOpt::default()).expect("GLFW surface"); + + let framebuffer = + surface.new_framebuffer::([1024, 1024], 0, Sampler::default()); + + std::mem::drop(framebuffer); + + // #360 occurs here after the drop + let _ = surface.new_framebuffer::([1024, 1024], 0, Sampler::default()); +}