every Renderer::Command should have valid RenderContext while executing.

This commit is contained in:
rachytski 2012-11-30 11:20:11 +03:00 committed by Alex Zolotarev
parent 81ee600840
commit 4188adad17
8 changed files with 43 additions and 5 deletions

View file

@ -1,4 +1,5 @@
#include "display_list.hpp"
#include "render_context.hpp"
namespace graphics
{
@ -98,7 +99,7 @@ namespace graphics
mv(2, 0) = 0; mv(2, 1) = 0; mv(2, 2) = 1; mv(2, 3) = 0;
mv(3, 0) = m(0, 2); mv(3, 1) = m(1, 2); mv(3, 2) = 0; mv(3, 3) = m(2, 2);
r->loadMatrix(EModelView, mv);
r->renderContext()->setMatrix(EModelView, mv);
/// drawing collected geometry
@ -108,11 +109,15 @@ namespace graphics
for (list<shared_ptr<Command> >::const_iterator it = m_commands.begin();
it != m_commands.end();
++it)
{
(*it)->setRenderContext(r->renderContext());
(*it)->perform();
}
if (m_isDebugging)
LOG(LINFO, ("finished DisplayList::draw"));
r->loadMatrix(EModelView, math::Identity<double, 4>());
r->renderContext()->setMatrix(EModelView, math::Identity<double, 4>());
}
}

View file

@ -325,7 +325,10 @@ namespace graphics
renderQueue()->processPacket(Packet(command, type));
else
if (command)
{
command->setRenderContext(m_renderContext.get());
command->perform();
}
}
PacketsQueue * Renderer::renderQueue()

View file

@ -14,6 +14,7 @@ namespace graphics
{
class ResourceManager;
class RenderTarget;
class RenderContext;
namespace gl
{

View file

@ -13,6 +13,16 @@ namespace graphics
m_isDebugging = flag;
}
void Command::setRenderContext(RenderContext * ctx)
{
m_ctx = ctx;
}
RenderContext * Command::renderContext()
{
return m_ctx;
}
Command::Command()
: m_isDebugging(false)
{}

View file

@ -10,6 +10,8 @@
namespace graphics
{
class RenderContext;
struct Command
{
private:
@ -17,11 +19,16 @@ namespace graphics
bool m_isDebugging;
string m_name;
RenderContext * m_ctx;
public:
bool isDebugging() const;
void setIsDebugging(bool flag);
void setRenderContext(RenderContext * ctx);
RenderContext * renderContext();
Command();
virtual ~Command();

View file

@ -48,7 +48,7 @@ BasicTilingRenderPolicy::BasicTilingRenderPolicy(Params const & p,
LOG(LINFO, ("ScreenSize=", p.m_screenWidth, "x", p.m_screenHeight, ", TileSize=", m_TileSize));
if (doUseQueuedRenderer)
m_QueuedRenderer.reset(new QueuedRenderer(GetPlatform().CpuCores() + 1));
m_QueuedRenderer.reset(new QueuedRenderer(GetPlatform().CpuCores() + 1, p.m_primaryRC));
}
void BasicTilingRenderPolicy::BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)

View file

@ -2,7 +2,8 @@
#include "../graphics/opengl/opengl.hpp"
QueuedRenderer::QueuedRenderer(int pipelinesCount)
QueuedRenderer::QueuedRenderer(int pipelinesCount,
shared_ptr<graphics::RenderContext> const & rc)
{
m_Pipelines = new PacketsPipeline[pipelinesCount];
for (int i = 0; i < pipelinesCount; ++i)
@ -10,6 +11,7 @@ QueuedRenderer::QueuedRenderer(int pipelinesCount)
m_PipelinesCount = pipelinesCount;
m_CurrentPipeline = 0;
m_ProcessSinglePipelineAtFrame = false;
m_RenderContext = rc;
}
QueuedRenderer::~QueuedRenderer()
@ -99,7 +101,10 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum)
{
it = m_Pipelines[pipelineNum].m_FrameCommands.begin();
if (it->m_command)
{
it->m_command->setRenderContext(m_RenderContext.get());
it->m_command->setIsDebugging(m_IsDebugging);
}
if (bucketType == graphics::Packet::ECancelPoint)
{

View file

@ -3,6 +3,11 @@
#include "../base/threaded_list.hpp"
#include "../graphics/opengl/renderer.hpp"
namespace graphics
{
class RenderContext;
}
/// Mixture-class for rendering policies, used on the
/// devices that do not support OpenGL context sharing
class QueuedRenderer
@ -45,9 +50,11 @@ private:
bool m_IsDebugging;
shared_ptr<graphics::RenderContext> m_RenderContext;
public:
QueuedRenderer(int pipelinesCount);
QueuedRenderer(int pipelinesCount, shared_ptr<graphics::RenderContext> const & rc);
~QueuedRenderer();
void CopyQueuedCommands(list<graphics::Packet> & l, list<graphics::Packet> & r);