Skip to content

Commit

Permalink
#5933: Brushes didn't get a chance to upload their data to the geomet…
Browse files Browse the repository at this point in the history
…ry store when LightingModeRenderer was active.

This step has now been moved to the OpenGLRenderSystem before invoking the renderer.
The downside here is that all possible shaders applicable to Camera or Ortho are asked to update, even though they might not be contributing to the scene.
  • Loading branch information
codereader committed Apr 8, 2022
1 parent 51c4286 commit 3ac2c4e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
11 changes: 11 additions & 0 deletions radiantcore/rendersystem/OpenGLRenderSystem.cpp
Expand Up @@ -170,6 +170,17 @@ IRenderResult::Ptr OpenGLRenderSystem::renderLitScene(RenderStateFlags globalFla

IRenderResult::Ptr OpenGLRenderSystem::render(SceneRenderer& renderer, RenderStateFlags globalFlagsMask, const IRenderView& view)
{
const auto viewType = renderer.getViewType();

// Make sure all shaders are ready for rendering, submitting their data to the store
for (const auto& [_, shader] : _shaders)
{
if (shader->isApplicableTo(viewType))
{
shader->prepareForRendering();
}
}

auto result = renderer.render(globalFlagsMask, view, _time);

renderText();
Expand Down
9 changes: 0 additions & 9 deletions radiantcore/rendersystem/backend/FullBrightRenderer.cpp
Expand Up @@ -30,15 +30,6 @@ class FullBrightRenderResult :

IRenderResult::Ptr FullBrightRenderer::render(RenderStateFlags globalstate, const IRenderView& view, std::size_t time)
{
// Make sure all the geometry is ready for rendering
for (const auto& [_, pass] : _sortedStates)
{
if (pass->isApplicableTo(_renderViewType))
{
pass->getShader().prepareForRendering();
}
}

// Make sure all the data is uploaded
_geometryStore.syncToBufferObjects();

Expand Down
3 changes: 1 addition & 2 deletions radiantcore/rendersystem/backend/FullBrightRenderer.h
Expand Up @@ -10,13 +10,12 @@ class FullBrightRenderer final :
public SceneRenderer
{
private:
RenderViewType _renderViewType;
const OpenGLStates& _sortedStates;
IGeometryStore& _geometryStore;

public:
FullBrightRenderer(RenderViewType renderViewType, const OpenGLStates& sortedStates, IGeometryStore& geometryStore) :
_renderViewType(renderViewType),
SceneRenderer(renderViewType),
_sortedStates(sortedStates),
_geometryStore(geometryStore)
{}
Expand Down
1 change: 1 addition & 0 deletions radiantcore/rendersystem/backend/LightingModeRenderer.cpp
Expand Up @@ -17,6 +17,7 @@ namespace render
LightingModeRenderer::LightingModeRenderer(GLProgramFactory& programFactory,
IGeometryStore& store, const std::set<RendererLightPtr>& lights,
const std::set<IRenderEntityPtr>& entities) :
SceneRenderer(RenderViewType::Camera),
_programFactory(programFactory),
_geometryStore(store),
_lights(lights),
Expand Down
12 changes: 11 additions & 1 deletion radiantcore/rendersystem/backend/SceneRenderer.h
Expand Up @@ -15,7 +15,12 @@ class IRenderView;
class SceneRenderer
{
protected:
SceneRenderer()
// The view type this renderer is designed for
RenderViewType _renderViewType;

protected:
SceneRenderer(RenderViewType viewType) :
_renderViewType(viewType)
{}

SceneRenderer(const SceneRenderer& other) = delete;
Expand All @@ -27,6 +32,11 @@ class SceneRenderer

virtual IRenderResult::Ptr render(RenderStateFlags globalstate, const IRenderView& view, std::size_t time) = 0;

RenderViewType getViewType() const
{
return _renderViewType;
}

protected:
// Set the projection and modelview matrices
void setupViewMatrices(const IRenderView& view);
Expand Down

0 comments on commit 3ac2c4e

Please sign in to comment.