Handle RTT texture stride (VT)
This commit is contained in:
parent
136c3d6825
commit
b77843b927
|
@ -1625,7 +1625,7 @@ bool RenderFrame()
|
|||
|
||||
//-1 -> too much to left
|
||||
ShaderUniforms.scale_coefs[0]=2.0f/(screen_width/dc2s_scale_h*scale_x);
|
||||
ShaderUniforms.scale_coefs[1]=(is_rtt ? 2 : -2) / min(480.0, dc_height); // FIXME Is that min() right? due to global clipping (TA_GLOB_TILE_CLIP)?
|
||||
ShaderUniforms.scale_coefs[1]=(is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512
|
||||
ShaderUniforms.scale_coefs[2]=1-2*ds2s_offs_x/(screen_width);
|
||||
ShaderUniforms.scale_coefs[3]=(is_rtt?1:-1);
|
||||
|
||||
|
@ -1732,7 +1732,7 @@ bool RenderFrame()
|
|||
die("7 is not valid");
|
||||
break;
|
||||
}
|
||||
//printf("RTT packmode=%d stride=%d - %d,%d -> %d,%d\n", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 4,
|
||||
//printf("RTT packmode=%d stride=%d - %d,%d -> %d,%d\n", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 8,
|
||||
// FB_X_CLIP.min, FB_Y_CLIP.min, FB_X_CLIP.max, FB_Y_CLIP.max);
|
||||
BindRTT(FB_W_SOF1 & VRAM_MASK, dc_width, dc_height, channels, format);
|
||||
}
|
||||
|
|
|
@ -453,7 +453,13 @@ void ReadRTTBuffer() {
|
|||
u32 w = pvrrc.fb_X_CLIP.max - pvrrc.fb_X_CLIP.min + 1;
|
||||
u32 h = pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1;
|
||||
|
||||
// FIXME stride
|
||||
u32 stride = FB_W_LINESTRIDE.stride * 8;
|
||||
if (stride == 0)
|
||||
stride = w * 2;
|
||||
else if (w * 2 > stride) {
|
||||
// Happens for Virtua Tennis
|
||||
w = stride / 2;
|
||||
}
|
||||
|
||||
u32 size = w * h * 2;
|
||||
u32 tex_addr = fb_rtt.TexAddr << 3;
|
||||
|
@ -481,7 +487,7 @@ void ReadRTTBuffer() {
|
|||
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &color_fmt);
|
||||
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &color_type);
|
||||
|
||||
if (FB_W_CTRL.fb_packmode == 1 && color_fmt == GL_RGB && color_type == GL_UNSIGNED_SHORT_5_6_5) {
|
||||
if (FB_W_CTRL.fb_packmode == 1 && stride == w * 2 && color_fmt == GL_RGB && color_type == GL_UNSIGNED_SHORT_5_6_5) {
|
||||
// Can be read directly into vram
|
||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, dst);
|
||||
}
|
||||
|
@ -493,23 +499,26 @@ void ReadRTTBuffer() {
|
|||
u32 chunk_lines = min((u32)sizeof(temp_tex_buffer), w * lines * 4) / w / 4;
|
||||
glReadPixels(0, h - lines, w, chunk_lines, GL_RGBA, GL_UNSIGNED_BYTE, p);
|
||||
|
||||
for (u32 i = 0; i < w * chunk_lines; i++) {
|
||||
switch(FB_W_CTRL.fb_packmode)
|
||||
{
|
||||
case 0: //0x0 0555 KRGB 16 bit (default) Bit 15 is the value of fb_kval[7].
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 10) | (((p[1] >> 3) & 0x1F) << 5) | ((p[2] >> 3) & 0x1F) | ((FB_W_CTRL.fb_kval & 0x80) << 8);
|
||||
break;
|
||||
case 1: //0x1 565 RGB 16 bit
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 11) | (((p[1] >> 2) & 0x3F) << 5) | ((p[2] >> 3) & 0x1F);
|
||||
break;
|
||||
case 2: //0x2 4444 ARGB 16 bit
|
||||
*dst++ = (((p[0] >> 4) & 0xF) << 8) | (((p[1] >> 4) & 0xF) << 4) | ((p[2] >> 4) & 0xF) | (((p[3] >> 4) & 0xF) << 12);
|
||||
break;
|
||||
case 3://0x3 1555 ARGB 16 bit The alpha value is determined by comparison with the value of fb_alpha_threshold.
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 10) | (((p[1] >> 3) & 0x1F) << 5) | ((p[2] >> 3) & 0x1F) | (p[3] >= FB_W_CTRL.fb_alpha_threshold ? 0x8000 : 0);
|
||||
break;
|
||||
for (u32 l = 0; l < chunk_lines; l++) {
|
||||
for (u32 c = 0; c < w; c++) {
|
||||
switch(FB_W_CTRL.fb_packmode)
|
||||
{
|
||||
case 0: //0x0 0555 KRGB 16 bit (default) Bit 15 is the value of fb_kval[7].
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 10) | (((p[1] >> 3) & 0x1F) << 5) | ((p[2] >> 3) & 0x1F) | ((FB_W_CTRL.fb_kval & 0x80) << 8);
|
||||
break;
|
||||
case 1: //0x1 565 RGB 16 bit
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 11) | (((p[1] >> 2) & 0x3F) << 5) | ((p[2] >> 3) & 0x1F);
|
||||
break;
|
||||
case 2: //0x2 4444 ARGB 16 bit
|
||||
*dst++ = (((p[0] >> 4) & 0xF) << 8) | (((p[1] >> 4) & 0xF) << 4) | ((p[2] >> 4) & 0xF) | (((p[3] >> 4) & 0xF) << 12);
|
||||
break;
|
||||
case 3://0x3 1555 ARGB 16 bit The alpha value is determined by comparison with the value of fb_alpha_threshold.
|
||||
*dst++ = (((p[0] >> 3) & 0x1F) << 10) | (((p[1] >> 3) & 0x1F) << 5) | ((p[2] >> 3) & 0x1F) | (p[3] >= FB_W_CTRL.fb_alpha_threshold ? 0x8000 : 0);
|
||||
break;
|
||||
}
|
||||
p += 4;
|
||||
}
|
||||
p += 4;
|
||||
dst += (stride - w * 2) / 2;
|
||||
}
|
||||
lines -= chunk_lines;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue