Removed old render_progress in SoftwareRenderer

This commit is contained in:
Michaël Lemaire 2014-08-19 14:20:37 +02:00
parent 1bf6d9382b
commit 2b135eedac
7 changed files with 28 additions and 30 deletions

View file

@ -37,6 +37,8 @@ Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id, const Color &c
this->color = new Color(color); this->color = new Color(color);
interrupted = false; interrupted = false;
predicted_poly_count = 0;
done_poly_count = 0;
} }
Rasterizer::~Rasterizer() Rasterizer::~Rasterizer()
@ -49,6 +51,16 @@ void Rasterizer::interrupt()
interrupted = true; interrupted = true;
} }
void Rasterizer::addPredictedPolys(int count)
{
predicted_poly_count += count;
}
void Rasterizer::addDonePolys(int count)
{
done_poly_count += count;
}
void Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3) void Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3)
{ {
ScanPoint point1, point2, point3; ScanPoint point1, point2, point3;

View file

@ -25,6 +25,9 @@ public:
virtual void interrupt(); virtual void interrupt();
protected: protected:
void addPredictedPolys(int count=1);
void addDonePolys(int count=1);
void pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3); void pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3);
void pushTriangle(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3); void pushTriangle(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
@ -43,6 +46,9 @@ private:
void pushScanPoint(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point); void pushScanPoint(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point);
void pushScanLineEdge(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point1, ScanPoint *point2); void pushScanLineEdge(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point1, ScanPoint *point2);
void renderScanLines(CanvasPortion *canvas, RenderScanlines *scanlines); void renderScanLines(CanvasPortion *canvas, RenderScanlines *scanlines);
int predicted_poly_count;
int done_poly_count;
}; };
} }

View file

@ -14,6 +14,7 @@
SoftwareCanvasRenderer::SoftwareCanvasRenderer() SoftwareCanvasRenderer::SoftwareCanvasRenderer()
{ {
started = false; started = false;
interrupted = false;
canvas = new Canvas(); canvas = new Canvas();
rasterizers.push_back(new SkyRasterizer(this, 0)); rasterizers.push_back(new SkyRasterizer(this, 0));
@ -60,13 +61,13 @@ void SoftwareCanvasRenderer::render()
{ {
CanvasPortion *portion = canvas->at(x, y); CanvasPortion *portion = canvas->at(x, y);
if (not render_interrupt) if (not interrupted)
{ {
portion->preparePixels(); portion->preparePixels();
rasterize(portion, true); rasterize(portion, true);
} }
if (not render_interrupt) if (not interrupted)
{ {
applyPixelShader(portion, true); applyPixelShader(portion, true);
} }
@ -78,7 +79,7 @@ void SoftwareCanvasRenderer::render()
void SoftwareCanvasRenderer::interrupt() void SoftwareCanvasRenderer::interrupt()
{ {
SoftwareRenderer::interrupt(); interrupted = true;
if (current_work) if (current_work)
{ {
@ -119,7 +120,7 @@ void SoftwareCanvasRenderer::applyPixelShader(CanvasPortion *portion, bool threa
// Render chunks in parallel // Render chunks in parallel
for (int sub_chunk_size = chunk_size; sub_chunk_size >= 1; sub_chunk_size /= 2) for (int sub_chunk_size = chunk_size; sub_chunk_size >= 1; sub_chunk_size /= 2)
{ {
if (render_interrupt) if (interrupted)
{ {
break; break;
} }

View file

@ -36,7 +36,10 @@ public:
*/ */
void render(); void render();
virtual void interrupt() override; /**
* @brief Interrupt the render process.
*/
void interrupt();
/** /**
* @brief Get the list of objects that can be rasterized to polygons on a canvas. * @brief Get the list of objects that can be rasterized to polygons on a canvas.
@ -67,6 +70,7 @@ private:
Canvas *canvas; Canvas *canvas;
std::vector<Rasterizer*> rasterizers; std::vector<Rasterizer*> rasterizers;
bool started; bool started;
bool interrupted;
ParallelWork *current_work; ParallelWork *current_work;
}; };

View file

@ -23,9 +23,6 @@
SoftwareRenderer::SoftwareRenderer(Scenery* scenery) SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
{ {
render_quality = 5; render_quality = 5;
render_interrupt = 0;
render_progress = 0.0;
is_rendering = 0;
render_camera = new CameraDefinition; render_camera = new CameraDefinition;
atmosphere_renderer = new BaseAtmosphereRenderer(this); atmosphere_renderer = new BaseAtmosphereRenderer(this);
@ -145,11 +142,6 @@ void SoftwareRenderer::disableAtmosphere(const std::vector<LightComponent> &ligh
atmosphere_renderer->setStaticLights(lights); atmosphere_renderer->setStaticLights(lights);
} }
void SoftwareRenderer::interrupt()
{
render_interrupt = 1;
}
Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material) Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material)
{ {
LightStatus status(lighting, location, getCameraLocation(location)); LightStatus status(lighting, location, getCameraLocation(location));
@ -185,11 +177,6 @@ RayCastingResult SoftwareRenderer::rayWalking(const Vector3 &location, const Vec
return result; return result;
} }
int SoftwareRenderer::addRenderProgress(double)
{
return not render_interrupt;
}
Vector3 SoftwareRenderer::getCameraLocation(const Vector3 &) Vector3 SoftwareRenderer::getCameraLocation(const Vector3 &)
{ {
return render_camera->getLocation(); return render_camera->getLocation();

View file

@ -22,11 +22,6 @@ public:
int render_quality; int render_quality;
CameraDefinition* render_camera; CameraDefinition* render_camera;
/* Render related */
double render_progress;
int render_interrupt;
int is_rendering;
void* customData[10]; void* customData[10];
virtual Vector3 getCameraLocation(const Vector3 &target); virtual Vector3 getCameraLocation(const Vector3 &target);
@ -34,7 +29,6 @@ public:
virtual double getPrecision(const Vector3 &location); virtual double getPrecision(const Vector3 &location);
virtual Vector3 projectPoint(const Vector3 &point); virtual Vector3 projectPoint(const Vector3 &point);
virtual Vector3 unprojectPoint(const Vector3 &point); virtual Vector3 unprojectPoint(const Vector3 &point);
virtual int addRenderProgress(double progress);
/*! /*!
* \brief Set the scenery to render. * \brief Set the scenery to render.
@ -65,8 +59,6 @@ public:
void disableAtmosphere(); void disableAtmosphere();
void disableAtmosphere(const std::vector<LightComponent> &lights); void disableAtmosphere(const std::vector<LightComponent> &lights);
virtual void interrupt();
inline Scenery* getScenery() const {return scenery;} inline Scenery* getScenery() const {return scenery;}
inline BaseAtmosphereRenderer* getAtmosphereRenderer() const {return atmosphere_renderer;} inline BaseAtmosphereRenderer* getAtmosphereRenderer() const {return atmosphere_renderer;}

View file

@ -195,15 +195,11 @@ void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, int displaced
void TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress) void TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress)
{ {
tessellateChunk(canvas, chunk, chunk->detail_hint); tessellateChunk(canvas, chunk, chunk->detail_hint);
renderer->render_progress = 0.05 * progress;
} }
void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas) void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas)
{ {
renderer->render_progress = 0.0;
getTessellationInfo(canvas, 0); getTessellationInfo(canvas, 0);
renderer->render_progress = 0.05;
} }
Color TerrainRasterizer::shadeFragment(const CanvasFragment &fragment) const Color TerrainRasterizer::shadeFragment(const CanvasFragment &fragment) const