|
|
@ -100,24 +100,19 @@ static u32 GetDepth(int x, int y) {
|
|
|
|
y = (registers.framebuffer.height - y);
|
|
|
|
y = (registers.framebuffer.height - y);
|
|
|
|
|
|
|
|
|
|
|
|
const u32 coarse_y = y & ~7;
|
|
|
|
const u32 coarse_y = y & ~7;
|
|
|
|
|
|
|
|
u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(registers.framebuffer.depth_format);
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * bytes_per_pixel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride;
|
|
|
|
|
|
|
|
u8* src_pixel = depth_buffer + src_offset;
|
|
|
|
|
|
|
|
|
|
|
|
switch (registers.framebuffer.depth_format) {
|
|
|
|
switch (registers.framebuffer.depth_format) {
|
|
|
|
case registers.framebuffer.D16:
|
|
|
|
case Pica::Regs::DepthFormat::D16:
|
|
|
|
{
|
|
|
|
return Color::DecodeD16(src_pixel);
|
|
|
|
u32 stride = registers.framebuffer.width * 2;
|
|
|
|
case Pica::Regs::DepthFormat::D24:
|
|
|
|
return Color::DecodeD16(depth_buffer + VideoCore::GetMortonOffset(x, y, 2) + coarse_y * stride);
|
|
|
|
return Color::DecodeD24(src_pixel);
|
|
|
|
}
|
|
|
|
case Pica::Regs::DepthFormat::D24S8:
|
|
|
|
case registers.framebuffer.D24:
|
|
|
|
return Color::DecodeD24S8(src_pixel).x;
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * 3;
|
|
|
|
|
|
|
|
u8* address = depth_buffer + VideoCore::GetMortonOffset(x, y, 3) + coarse_y * stride;
|
|
|
|
|
|
|
|
return Color::DecodeD24(address);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case registers.framebuffer.D24S8:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * 4;
|
|
|
|
|
|
|
|
return Color::DecodeD24S8(depth_buffer + VideoCore::GetMortonOffset(x, y, 4) + coarse_y * stride).x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format);
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format);
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
UNIMPLEMENTED();
|
|
|
@ -132,28 +127,23 @@ static void SetDepth(int x, int y, u32 value) {
|
|
|
|
y = (registers.framebuffer.height - y);
|
|
|
|
y = (registers.framebuffer.height - y);
|
|
|
|
|
|
|
|
|
|
|
|
const u32 coarse_y = y & ~7;
|
|
|
|
const u32 coarse_y = y & ~7;
|
|
|
|
|
|
|
|
u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(registers.framebuffer.depth_format);
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * bytes_per_pixel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride;
|
|
|
|
|
|
|
|
u8* dst_pixel = depth_buffer + dst_offset;
|
|
|
|
|
|
|
|
|
|
|
|
switch (registers.framebuffer.depth_format) {
|
|
|
|
switch (registers.framebuffer.depth_format) {
|
|
|
|
case registers.framebuffer.D16:
|
|
|
|
case Pica::Regs::DepthFormat::D16:
|
|
|
|
{
|
|
|
|
Color::EncodeD16(value, dst_pixel);
|
|
|
|
u32 stride = registers.framebuffer.width * 2;
|
|
|
|
|
|
|
|
Color::EncodeD16(value, depth_buffer + VideoCore::GetMortonOffset(x, y, 2) + coarse_y * stride);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Pica::Regs::DepthFormat::D24:
|
|
|
|
case registers.framebuffer.D24:
|
|
|
|
Color::EncodeD24(value, dst_pixel);
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * 3;
|
|
|
|
|
|
|
|
u8* address = depth_buffer + VideoCore::GetMortonOffset(x, y, 3) + coarse_y * stride;
|
|
|
|
|
|
|
|
Color::EncodeD24(value, address);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Pica::Regs::DepthFormat::D24S8:
|
|
|
|
case registers.framebuffer.D24S8:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 stride = registers.framebuffer.width * 4;
|
|
|
|
|
|
|
|
// TODO(Subv): Implement the stencil buffer
|
|
|
|
// TODO(Subv): Implement the stencil buffer
|
|
|
|
Color::EncodeD24S8(value, 0, depth_buffer + VideoCore::GetMortonOffset(x, y, 4) + coarse_y * stride);
|
|
|
|
Color::EncodeD24S8(value, 0, dst_pixel);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format);
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format);
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
UNIMPLEMENTED();
|
|
|
|