Rasterizers now use their own interrupt system
This commit is contained in:
parent
915f43503e
commit
0c48fb075f
9 changed files with 22 additions and 17 deletions
|
@ -12,7 +12,7 @@ CanvasPixelShader::CanvasPixelShader(const SoftwareCanvasRenderer &renderer, Can
|
|||
{
|
||||
}
|
||||
|
||||
int CanvasPixelShader::processParallelUnit(int unit)
|
||||
void CanvasPixelShader::processParallelUnit(int unit)
|
||||
{
|
||||
// Locate the chunk we work on
|
||||
int prev_sub_chunk_size = chunk_size * 2;
|
||||
|
@ -33,7 +33,7 @@ int CanvasPixelShader::processParallelUnit(int unit)
|
|||
{
|
||||
if (interrupted)
|
||||
{
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sub_chunk_size == chunk_size or x % prev_sub_chunk_size != 0 or y % prev_sub_chunk_size != 0)
|
||||
|
@ -60,6 +60,4 @@ int CanvasPixelShader::processParallelUnit(int unit)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class CanvasPixelShader: public ParallelWorker
|
|||
public:
|
||||
CanvasPixelShader(const SoftwareCanvasRenderer &renderer, CanvasPortion *portion, int chunk_size, int sub_chunk_size, int chunks_x, int chunks_y);
|
||||
|
||||
virtual int processParallelUnit(int unit) override;
|
||||
virtual void processParallelUnit(int unit) override;
|
||||
|
||||
private:
|
||||
const SoftwareCanvasRenderer &renderer;
|
||||
|
|
|
@ -34,7 +34,7 @@ void SkyRasterizer::rasterizeToCanvas(CanvasPortion* canvas)
|
|||
|
||||
for (j = 0; j < res_j; j++)
|
||||
{
|
||||
if (!renderer->addRenderProgress(0.0))
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,10 @@ void SoftwareCanvasRenderer::interrupt()
|
|||
{
|
||||
current_work->interrupt();
|
||||
}
|
||||
for (auto &rasterizer:getRasterizers())
|
||||
{
|
||||
rasterizer->interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Rasterizer *> &SoftwareCanvasRenderer::getRasterizers() const
|
||||
|
|
|
@ -152,25 +152,29 @@ void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, int displaced
|
|||
for (i = 0; i < chunk_count - 1; i++)
|
||||
{
|
||||
_getChunk(renderer, &chunk, cx - radius_ext + chunk_size * i, cz - radius_ext, chunk_size, displaced);
|
||||
if (!processChunk(canvas, &chunk, progress))
|
||||
processChunk(canvas, &chunk, progress);
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_getChunk(renderer, &chunk, cx + radius_int, cz - radius_ext + chunk_size * i, chunk_size, displaced);
|
||||
if (!processChunk(canvas, &chunk, progress))
|
||||
processChunk(canvas, &chunk, progress);
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_getChunk(renderer, &chunk, cx + radius_int - chunk_size * i, cz + radius_int, chunk_size, displaced);
|
||||
if (!processChunk(canvas, &chunk, progress))
|
||||
processChunk(canvas, &chunk, progress);
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_getChunk(renderer, &chunk, cx - radius_ext, cz + radius_int - chunk_size * i, chunk_size, displaced);
|
||||
if (!processChunk(canvas, &chunk, progress))
|
||||
processChunk(canvas, &chunk, progress);
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -188,12 +192,11 @@ void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, int displaced
|
|||
}
|
||||
}
|
||||
|
||||
int TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress)
|
||||
void TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress)
|
||||
{
|
||||
tessellateChunk(canvas, chunk, chunk->detail_hint);
|
||||
|
||||
renderer->render_progress = 0.05 * progress;
|
||||
return !renderer->render_interrupt;
|
||||
}
|
||||
|
||||
void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas)
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
/**
|
||||
* Method called for each chunk tessellated by getTessellationInfo.
|
||||
*/
|
||||
int processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress);
|
||||
void processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress);
|
||||
|
||||
/**
|
||||
* Tessellate the terrain, calling processChunk for each chunk.
|
||||
|
|
|
@ -55,7 +55,7 @@ void WaterRasterizer::rasterizeToCanvas(CanvasPortion *canvas)
|
|||
|
||||
while (radius_int < 20000.0)
|
||||
{
|
||||
if (!renderer->addRenderProgress(0.0))
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual int processParallelUnit(int unit)
|
||||
virtual void processParallelUnit(int unit)
|
||||
{
|
||||
return func(work, unit, data);
|
||||
func(work, unit, data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
*
|
||||
* This method will be called from any thread in the thread pool used by the ParallelWork.
|
||||
*/
|
||||
virtual int processParallelUnit(int unit) = 0;
|
||||
virtual void processParallelUnit(int unit) = 0;
|
||||
|
||||
/**
|
||||
* Method to reimplement to know when to interrupt the processing of units.
|
||||
|
|
Loading…
Reference in a new issue