- fix sky drawer issues when not using max screenblocks

This commit is contained in:
Magnus Norddahl 2018-12-19 04:27:41 +01:00
parent e296d2819b
commit db295fae3a
4 changed files with 61 additions and 58 deletions

View file

@ -151,8 +151,8 @@ void PolyTriangleThreadData::SetViewport(int x, int y, int width, int height, ui
dest_height = new_dest_height;
dest_pitch = new_dest_pitch;
dest_bgra = new_dest_bgra;
numa_start_y = numa_node * dest_height / num_numa_nodes;
numa_end_y = (numa_node + 1) * dest_height / num_numa_nodes;
numa_start_y = numa_node * screen->GetHeight() / num_numa_nodes;
numa_end_y = (numa_node + 1) * screen->GetHeight() / num_numa_nodes;
ccw = true;
weaponScene = false;
}

View file

@ -558,21 +558,6 @@ namespace swrenderer
int32_t frac = args.TextureVPos();
int32_t fracstep = args.TextureVStep();
if (!args.FadeSky())
{
int count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
@ -594,6 +579,21 @@ namespace swrenderer
fracstep *= num_cores;
pitch *= num_cores;
if (!args.FadeSky())
{
count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
uint32_t solid_top = args.SolidTopColor();
uint32_t solid_bottom = args.SolidBottomColor();
@ -686,7 +686,6 @@ namespace swrenderer
void DrawDoubleSky1PalCommand::Execute(DrawerThread *thread)
{
uint8_t *dest = args.Dest();
int count = args.Count();
int pitch = args.Viewport()->RenderTarget->GetPitch();
const uint8_t *source0 = args.FrontTexturePixels();
const uint8_t *source1 = args.BackTexturePixels();
@ -696,6 +695,10 @@ namespace swrenderer
int32_t frac = args.TextureVPos();
int32_t fracstep = args.TextureVStep();
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
// Find bands for top solid color, top fade, center textured, bottom fade, bottom solid color:
int start_fade = 2; // How fast it should fade out
int fade_length = (1 << (24 - start_fade));
@ -708,8 +711,6 @@ namespace swrenderer
start_fadebottom_y = clamp(start_fadebottom_y, 0, count);
end_fadebottom_y = clamp(end_fadebottom_y, 0, count);
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
dest = thread->dest_for_thread(args.DestY(), pitch, dest);
frac += fracstep * skipped;
fracstep *= num_cores;

View file

@ -50,21 +50,6 @@ namespace swrenderer
uint32_t solid_bottom = args.SolidBottomColor();
bool fadeSky = args.FadeSky();
if (!fadeSky)
{
int count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
@ -86,6 +71,21 @@ namespace swrenderer
fracstep *= num_cores;
pitch *= num_cores;
if (!fadeSky)
{
int count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
BgraColor solid_top_fill = solid_top;
BgraColor solid_bottom_fill = solid_bottom;
@ -172,7 +172,6 @@ namespace swrenderer
void Execute(DrawerThread *thread) override
{
uint32_t *dest = (uint32_t *)args.Dest();
int count = args.Count();
int pitch = args.Viewport()->RenderTarget->GetPitch();
const uint32_t *source0 = (const uint32_t *)args.FrontTexturePixels();
const uint32_t *source1 = (const uint32_t *)args.BackTexturePixels();
@ -181,7 +180,11 @@ namespace swrenderer
int32_t frac = args.TextureVPos();
int32_t fracstep = args.TextureVStep();
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
uint32_t solid_top = args.SolidTopColor();
uint32_t solid_bottom = args.SolidBottomColor();
bool fadeSky = args.FadeSky();
@ -198,8 +201,6 @@ namespace swrenderer
start_fadebottom_y = clamp(start_fadebottom_y, 0, count);
end_fadebottom_y = clamp(end_fadebottom_y, 0, count);
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
dest = thread->dest_for_thread(args.DestY(), pitch, dest);
frac += fracstep * skipped;
fracstep *= num_cores;

View file

@ -49,21 +49,6 @@ namespace swrenderer
uint32_t solid_bottom = args.SolidBottomColor();
bool fadeSky = args.FadeSky();
if (!fadeSky)
{
int count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
@ -85,6 +70,21 @@ namespace swrenderer
fracstep *= num_cores;
pitch *= num_cores;
if (!fadeSky)
{
int count = thread->count_for_thread(args.DestY(), args.Count());
for (int index = 0; index < count; index++)
{
uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS;
*dest = source0[sample_index];
dest += pitch;
frac += fracstep;
}
return;
}
__m128i solid_top_fill = _mm_unpacklo_epi8(_mm_cvtsi32_si128(solid_top), _mm_setzero_si128());
__m128i solid_bottom_fill = _mm_unpacklo_epi8(_mm_cvtsi32_si128(solid_bottom), _mm_setzero_si128());
@ -167,7 +167,6 @@ namespace swrenderer
void Execute(DrawerThread *thread) override
{
uint32_t *dest = (uint32_t *)args.Dest();
int count = args.Count();
int pitch = args.Viewport()->RenderTarget->GetPitch();
const uint32_t *source0 = (const uint32_t *)args.FrontTexturePixels();
const uint32_t *source1 = (const uint32_t *)args.BackTexturePixels();
@ -176,7 +175,11 @@ namespace swrenderer
int32_t frac = args.TextureVPos();
int32_t fracstep = args.TextureVStep();
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
int count = skipped + thread->count_for_thread(args.DestY(), args.Count()) * num_cores;
uint32_t solid_top = args.SolidTopColor();
uint32_t solid_bottom = args.SolidBottomColor();
bool fadeSky = args.FadeSky();
@ -193,8 +196,6 @@ namespace swrenderer
start_fadebottom_y = clamp(start_fadebottom_y, 0, count);
end_fadebottom_y = clamp(end_fadebottom_y, 0, count);
int num_cores = thread->num_cores;
int skipped = thread->skipped_by_thread(args.DestY());
dest = thread->dest_for_thread(args.DestY(), pitch, dest);
frac += fracstep * skipped;
fracstep *= num_cores;