Skip to content

Commit

Permalink
[Tests/Render/RenderProcess] Removed window run on frame rendering
Browse files Browse the repository at this point in the history
- This isn't required as we render to a texture instead of the default framebuffer, and sometimes gives an empty image on the second frame rendered under Linux (notably WSL), making some tests fail

- Added parenting to the tested processes
  - This is not required as there's only one pass in every test, but as tests also serve as documentation it would be a good practice
  • Loading branch information
Razakhel committed Feb 24, 2024
1 parent 930e481 commit eee8868
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions tests/src/RaZ/Render/RenderProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
namespace {

Raz::Image renderFrame(Raz::World& world, const Raz::Texture2DPtr& output, const Raz::FilePath& renderedImgPath = {}) {
Raz::Window& window = TestUtils::getWindow();

// Rendering a frame of the scene by updating the World's RenderSystem & running the Window
// Rendering a frame of the scene by updating the World's RenderSystem
// Running the window shouldn't be useful as we render to a texture, and more importantly can make this file's tests
// fail under Linux (as the second rendered frame of each test might be empty)
world.update({});
window.run(0.f);

#if !defined(USE_OPENGL_ES)
Raz::Image renderedImg = output->recoverImage();
Expand All @@ -39,8 +38,8 @@ Raz::Image renderFrame(Raz::World& world, const Raz::Texture2DPtr& output, const
Raz::TextureType::TEXTURE_2D,
Raz::FramebufferType::READ_FRAMEBUFFER);

Raz::Image renderedImg(window.getWidth(), window.getHeight(), Raz::ImageColorspace::RGB, Raz::ImageDataType::BYTE);
Raz::Renderer::recoverFrame(window.getWidth(), window.getHeight(), Raz::TextureFormat::RGB, Raz::PixelDataType::UBYTE, renderedImg.getDataPtr());
Raz::Image renderedImg(output->getWidth(), output->getHeight(), Raz::ImageColorspace::RGB, Raz::ImageDataType::BYTE);
Raz::Renderer::recoverFrame(output->getWidth(), output->getHeight(), Raz::TextureFormat::RGB, Raz::PixelDataType::UBYTE, renderedImg.getDataPtr());

Raz::Renderer::unbindFramebuffer(Raz::FramebufferType::READ_FRAMEBUFFER);
#endif
Expand Down Expand Up @@ -71,6 +70,7 @@ TEST_CASE("ChromaticAberrationRenderProcess execution", "[render]") {
const Raz::Texture2DPtr output = Raz::Texture2D::create(window.getWidth(), window.getHeight(), Raz::TextureColorspace::RGB, Raz::TextureDataType::BYTE);

auto& chromaticAberration = render.getRenderGraph().addRenderProcess<Raz::ChromaticAberrationRenderProcess>();
chromaticAberration.addParent(render.getGeometryPass());
chromaticAberration.setInputBuffer(std::move(input));
chromaticAberration.setOutputBuffer(output);

Expand Down Expand Up @@ -116,6 +116,7 @@ TEST_CASE("ConvolutionRenderProcess execution", "[render]") {
auto& convolution = render.getRenderGraph().addRenderProcess<Raz::ConvolutionRenderProcess>(Raz::Mat3f(0.f, 0.f, 0.f,
0.f, 1.f, 0.f,
0.f, 0.f, 0.f));
convolution.addParent(render.getGeometryPass());
convolution.setInputBuffer(std::move(input));
convolution.setOutputBuffer(output);

Expand All @@ -141,6 +142,7 @@ TEST_CASE("FilmGrainRenderProcess execution", "[render][!mayfail]") { // May fai
const Raz::Texture2DPtr output = Raz::Texture2D::create(window.getWidth(), window.getHeight(), Raz::TextureColorspace::RGB, Raz::TextureDataType::BYTE);

auto& filmGrain = render.getRenderGraph().addRenderProcess<Raz::FilmGrainRenderProcess>();
filmGrain.addParent(render.getGeometryPass());
filmGrain.setInputBuffer(std::move(input));
filmGrain.setOutputBuffer(output);

Expand Down Expand Up @@ -168,6 +170,7 @@ TEST_CASE("PixelizationRenderProcess execution", "[render][!mayfail]") { // May
const Raz::Texture2DPtr output = Raz::Texture2D::create(window.getWidth(), window.getHeight(), Raz::TextureColorspace::RGB, Raz::TextureDataType::BYTE);

auto& pixelization = render.getRenderGraph().addRenderProcess<Raz::PixelizationRenderProcess>();
pixelization.addParent(render.getGeometryPass());
pixelization.setInputBuffer(std::move(input));
pixelization.setOutputBuffer(output);

Expand All @@ -191,6 +194,7 @@ TEST_CASE("VignetteRenderProcess execution", "[render]") {
const Raz::Texture2DPtr output = Raz::Texture2D::create(window.getWidth(), window.getHeight(), Raz::TextureColorspace::RGB, Raz::TextureDataType::BYTE);

auto& vignette = render.getRenderGraph().addRenderProcess<Raz::VignetteRenderProcess>();
vignette.addParent(render.getGeometryPass());
vignette.setInputBuffer(std::move(input));
vignette.setOutputBuffer(output);

Expand Down
2 changes: 1 addition & 1 deletion tests/src/RaZ/Render/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace {
Raz::Image renderFrame(Raz::World& world, const Raz::FilePath& renderedImgPath = {}) {
Raz::Window& window = TestUtils::getWindow();

// Rendering a frame of the scene by updating the World's RenderSystem & running the Window
// Rendering a frame of the scene by updating the World's RenderSystem, and running the Window to render its overlay
world.update({});
window.run(0.f);

Expand Down

0 comments on commit eee8868

Please sign in to comment.