[Source] Need help restoring low detail modes (r_detail)
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
-
- Vintage GZDoom Developer
- Posts: 3146
- Joined: Fri Apr 23, 2004 3:51 am
- Location: Spain
Re: [Source] Need help restoring low detail modes (r_detail)
Now that i think of it the algorithm doesn't take into accont that now lineto is four times the size of linefrom (was two times before), may be the problem is there but i don't know how to deal with it. By the way i wonder where the memory for lineto is reserved.
-
- Vintage GZDoom Developer
- Posts: 3146
- Joined: Fri Apr 23, 2004 3:51 am
- Location: Spain
Re: [Source] Need help restoring low detail modes (r_detail)
Well, believe or not it's fixed now with a different approach. Seems like i'm not as bad as i thought, i plan to do a release soon.
-
- Vintage GZDoom Developer
- Posts: 3146
- Joined: Fri Apr 23, 2004 3:51 am
- Location: Spain
Re: [Source] Need help restoring low detail modes (r_detail)
I've added a 3x3 low detail mode (4x2 was easy), it works but crashes on exit and i don't know why. I've traced the algorithm and it's right. The only way to prevent the crash is to stop the inner loop with x < rowsize-6 but then the rightmost part of the screen wouldn't be filled and would display junk. I've kept detailxshift and detailyshift at 1 since otherwise would be a mess but i think it doesn't matter. The problem is in ~DSimpleCanvas but the debug info is not useful. If someone wants to help i would appreciate it, i know Randi is the only one who knows well that part of the code.
Edit: rowsize is for instance 160 and screen width is 320. I've added the missing part but it crashes the same.
Edit2: it's fixed.
Code: Select all
void R_DetailDouble ()
{
...
case 5: // x- and y-triple
{
int rowsize = viewwidth;
int realpitch = RenderTarget->GetPitch();
int pitch = realpitch << 1;
int y,x;
BYTE *linefrom, *lineto;
BYTE c;
int offset = viewwidth > 320 ? CPU.DataL1LineSize : 0;
linefrom = dc_destorg;
for (y = 0; y < viewheight; ++y, linefrom += pitch)
{
if (y > 0)
{
lineto = linefrom - viewwidth*3 - offset;
}
else
{
lineto = linefrom - viewwidth;
}
for (x = 0; x < rowsize-3; x=x+3)
{
c = linefrom[x];
lineto[x*2] = c;
lineto[x*2+1] = c;
lineto[x*2+2] = c;
c = linefrom[x+1];
lineto[x*2+3] = c;
lineto[x*2+4] = c;
lineto[x*2+5] = c;
}
x = rowsize-1;
if (viewwidth >= 200)
{
c = linefrom[x-2];
lineto[x*2-2] = c;
lineto[x*2-1] = c;
}
c = linefrom[x-1];
lineto[x*2] = c;
lineto[x*2+1] = c;
if (y > 0)
{
memcpy (lineto+realpitch, lineto, rowsize*2);
memcpy (lineto+realpitch*2, lineto, rowsize*2);
}
else
{
memcpy (lineto+realpitch, lineto, rowsize*2);
}
}
}
break;
}
Edit2: it's fixed.
Last edited by drfrag on Sun Oct 01, 2017 1:50 am, edited 1 time in total.
-
- Vintage GZDoom Developer
- Posts: 3146
- Joined: Fri Apr 23, 2004 3:51 am
- Location: Spain
Re: [Source] Need help restoring low detail modes (r_detail)
It's fixed now. I wanted to do this mainly to prove myself that i was capable of doing it. I guess the compiler will optimize this and the y > 0 condition will not be checked on every iteration of the outer loop but i'm not sure.
There's a remaining problem, the image at high resolutions is displaced to the right and i think that's due to the CPU.DataL1LineSize cache optimization in DSimpleCanvas::DSimpleCanvas. I guess the pitch must be different but i don't know how to fix it, i've tried without luck.
Edit: fixed as well. Uploaded to gzdoomle.
Edit2: actually it's a 3x2 mode. I think 3x3 is impossible, i'd need to use linefrom += realpitch*3 but i get junk.
Same for 3x1, setting detailyshift to 0 makes the engine crash somewhere else.
There's a remaining problem, the image at high resolutions is displaced to the right and i think that's due to the CPU.DataL1LineSize cache optimization in DSimpleCanvas::DSimpleCanvas. I guess the pitch must be different but i don't know how to fix it, i've tried without luck.
Edit: fixed as well. Uploaded to gzdoomle.
Edit2: actually it's a 3x2 mode. I think 3x3 is impossible, i'd need to use linefrom += realpitch*3 but i get junk.
Same for 3x1, setting detailyshift to 0 makes the engine crash somewhere else.