Page MenuHome

Enable OpenGL rendering for RenderEngine.render
ClosedPublic

Authored by Miguel Pozo (pragma37) on Jul 15 2020, 7:07 PM.

Details

Summary

I've made this pach trying to follow the instructions given by @Brecht Van Lommel (brecht) on T78921

This should be an option, with a flag on the render engine to indicate if an OpenGL context is needed by the renderer. We don't want to create an OpenGL context for renderers that don't need it.

DRW_render_to_image has the code for Eevee, initializing/deinitializing the OpenGL context at the start/end of the function. This code could be moved from the draw module to the render module, and Eevee and Workbench would then set the flag to request an OpenGL context.

Diff Detail

Repository
rB Blender

Event Timeline

Miguel Pozo (pragma37) requested review of this revision.Jul 15 2020, 7:07 PM
Miguel Pozo (pragma37) created this revision.
Brecht Van Lommel (brecht) requested changes to this revision.Jul 15 2020, 7:22 PM

@Clément Foucault (fclem), any objections to this?

source/blender/draw/intern/draw_manager.c
1656

This function call should be removed, it should already be happening because RE_USE_GPU_CONTEXT is set for Eevee and Workbench.

1708

Same here.

source/blender/makesrna/intern/rna_render.c
872

Description could be made more detailed here, like:

Enable OpenGL context for the render method, for engines that render using OpenGL
source/blender/render/intern/source/external_engine.c
780

Code style is is to put { on this line. Easiest way to conform code is to run make format.
https://wiki.blender.org/wiki/Tools/ClangFormat

This revision now requires changes to proceed.Jul 15 2020, 7:22 PM

Formatting and docs.

Looks acceptable. I have nothing against this!

Miguel Pozo (pragma37) marked an inline comment as done.Jul 15 2020, 8:09 PM
source/blender/draw/intern/draw_manager.c
1708

Are you sure about this ?
This is the DRW_render_gpencil function.
The code was duplicated here and in DRW_render_to_image.

If I remove it I get an exception thrown when it tries to do the grease pencil rendering.

If I understand the code right, to avoid calling enable and disable twice we could move the DRW_render_gpencil call in RE_engine_render before the disable call, but then there's no point in checking for RE_USE_GPU_CONTEXT because an OpenGL context is always needed.

Miguel Pozo (pragma37) marked an inline comment as not done.Jul 15 2020, 8:12 PM

You're right, it looks correct as is.

This revision is now accepted and ready to land.Jul 15 2020, 8:13 PM