- Use the proper address when reading custom VRAM during a BG layer affine extended direct render. Fixes the pencil drawing background in the title screen of Super Mario 64 DS when rendering at a custom resolution.
This commit is contained in:
rogerman 2016-02-23 07:26:44 +00:00
parent c98e669d74
commit dc53f97d17
2 changed files with 21 additions and 4 deletions

View File

@ -2273,7 +2273,7 @@ void GPUEngineBase::_RenderPixelsCustom(u16 *__restrict dstColorLine, u8 *__rest
const size_t lineCount = _gpuDstLineCount[lineIndex];
const size_t dstPixCount = this->renderedWidth * lineCount;
const size_t ssePixCount = (dstPixCount - (dstPixCount % 8));
const u16 *__restrict srcLine = GPU->GetCustomVRAMBuffer() + (this->vramBlockBGIndex * _gpuVRAMBlockOffset) + (_gpuDstLineIndex[lineIndex] * this->renderedWidth);
const u16 *__restrict srcLine = GPU->GetCustomVRAMAddressUsingMappedAddress(this->_BGLayer[LAYERID].BMPAddress) + (_gpuDstLineIndex[lineIndex] * this->renderedWidth);
size_t i = 0;
#ifdef ENABLE_SSE2
@ -4062,6 +4062,11 @@ void GPUEngineA::UpdateSelectedVRAMBlock()
this->_VRAMaddrCustom = this->_VRAMCustomBlockPtr[DISPCNT.VRAM_Block];
}
u16* GPUEngineA::GetCustomVRAMBlockPtr(const size_t blockID)
{
return this->_VRAMCustomBlockPtr[blockID];
}
void GPUEngineA::SetCustomFramebufferSize(size_t w, size_t h)
{
this->GPUEngineBase::SetCustomFramebufferSize(w, h);
@ -4086,7 +4091,6 @@ void GPUEngineA::SetCustomFramebufferSize(size_t w, size_t h)
free_aligned(oldColorRGBA5551Buffer);
}
bool GPUEngineA::WillRender3DLayer()
{
return ( this->_enableLayer[GPULayerID_BG0] && (this->_IORegisterMap->DISPCNT.BG0_Enable != 0) && (this->_IORegisterMap->DISPCNT.BG0_3D != 0) );
@ -4310,7 +4314,7 @@ void GPUEngineA::_RenderLine_Layer(const u16 l, u16 *dstColorLine, const size_t
if (ISCUSTOMRENDERINGNEEDED)
{
const bool useCustomVRAM = (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE);
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetCustomVRAMBuffer() + (this->vramBlockOBJIndex * _gpuVRAMBlockOffset) + (dstLineIndex * dstLineWidth) : NULL;
const u16 *__restrict srcLine = (useCustomVRAM) ? this->_VRAMCustomBlockPtr[this->vramBlockOBJIndex] + (dstLineIndex * dstLineWidth) : NULL;
for (size_t line = 0; line < dstLineCount; line++)
{
@ -5143,7 +5147,7 @@ void GPUEngineB::_RenderLine_Layer(const u16 l, u16 *dstColorLine, const size_t
if (ISCUSTOMRENDERINGNEEDED)
{
const bool useCustomVRAM = (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE);
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetCustomVRAMBuffer() + (this->vramBlockOBJIndex * _gpuVRAMBlockOffset) + (dstLineIndex * dstLineWidth) : NULL;
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetEngineMain()->GetCustomVRAMBlockPtr(this->vramBlockOBJIndex) + (dstLineIndex * dstLineWidth) : NULL;
for (size_t line = 0; line < dstLineCount; line++)
{
@ -5695,6 +5699,17 @@ u16* GPUSubsystem::GetCustomVRAMBlankBuffer()
return this->_customVRAMBlank;
}
u16* GPUSubsystem::GetCustomVRAMAddressUsingMappedAddress(const u32 mappedAddr)
{
const size_t vramPixel = (size_t)((u8 *)MMU_gpu_map(mappedAddr) - MMU.ARM9_LCD) / sizeof(u16);
const size_t blockID = vramPixel / (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_VRAM_BLOCK_LINES);
const size_t blockPixel = vramPixel % (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_VRAM_BLOCK_LINES);
const size_t blockLine = blockPixel / GPU_FRAMEBUFFER_NATIVE_WIDTH;
const size_t linePixel = blockPixel % GPU_FRAMEBUFFER_NATIVE_WIDTH;
return (this->GetEngineMain()->GetCustomVRAMBlockPtr(blockID) + (_gpuCaptureLineIndex[blockLine] * this->_displayInfo.customWidth) + _gpuDstPitchIndex[linePixel]);
}
VRAM3DUsageProperties& GPUSubsystem::GetRenderProperties()
{
return this->_VRAM3DUsage;

View File

@ -1401,6 +1401,7 @@ public:
virtual void Reset();
void ParseReg_DISPCAPCNT();
void UpdateSelectedVRAMBlock();
u16* GetCustomVRAMBlockPtr(const size_t blockID);
FragmentColor* Get3DFramebufferRGBA6665() const;
u16* Get3DFramebufferRGBA5551() const;
virtual void SetCustomFramebufferSize(size_t w, size_t h);
@ -1511,6 +1512,7 @@ public:
u16* GetCustomVRAMBuffer();
u16* GetCustomVRAMBlankBuffer();
u16* GetCustomVRAMAddressUsingMappedAddress(const u32 addr);
size_t GetCustomFramebufferWidth() const;
size_t GetCustomFramebufferHeight() const;