mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Assorted FBO fixes
This commit is contained in:
parent
4a49b8ee36
commit
ee32db47b9
2 changed files with 26 additions and 13 deletions
|
@ -61,6 +61,7 @@ static int hCount = 0;
|
|||
static int hCountTotal = 0; //unused
|
||||
static int vCount = 0;
|
||||
static int isVblank = 0;
|
||||
static bool hasSetMode = false;
|
||||
|
||||
// STATE END
|
||||
|
||||
|
@ -86,6 +87,7 @@ void hleLeaveVblank(u64 userdata, int cyclesLate);
|
|||
|
||||
void __DisplayInit()
|
||||
{
|
||||
hasSetMode = false;
|
||||
framebufIsLatched = false;
|
||||
framebuf.topaddr = 0x04000000;
|
||||
framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888;
|
||||
|
@ -140,16 +142,11 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
|||
sprintf(stats, "Draw calls")
|
||||
}*/
|
||||
|
||||
/*
|
||||
PPGeBegin();
|
||||
PPGeDrawImage(I_LOGO, 5, 5, 0, 0xFFFFFFFF);
|
||||
PPGeDrawText("This is PPGeDraw speaking", 10, 100, 0, 0.5f, 0xFFFFFFFF);
|
||||
PPGeEnd();
|
||||
*/
|
||||
// Yeah, this has to be the right moment to end the frame. Give the graphics backend opportunity
|
||||
// to blit the framebuffer, in order to support half-framerate games that otherwise wouldn't have
|
||||
// anything to draw here.
|
||||
gpu->CopyDisplayToOutput();
|
||||
|
||||
{
|
||||
host->EndFrame();
|
||||
host->BeginFrame();
|
||||
|
@ -170,7 +167,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
|||
void hleLeaveVblank(u64 userdata, int cyclesLate)
|
||||
{
|
||||
isVblank = 0;
|
||||
DEBUG_LOG(HLE,"Leave VBlank");
|
||||
DEBUG_LOG(HLE,"Leave VBlank %i", (int)userdata - 1);
|
||||
vCount++;
|
||||
hCount = 0;
|
||||
CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs) - cyclesLate, enterVblankEvent, userdata);
|
||||
|
@ -187,7 +184,11 @@ u32 sceDisplaySetMode(u32 unknown, u32 xres, u32 yres)
|
|||
DEBUG_LOG(HLE,"sceDisplaySetMode(%d,%d,%d)",unknown,xres,yres);
|
||||
host->BeginFrame();
|
||||
|
||||
gpu->InitClear(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
|
||||
if (!hasSetMode)
|
||||
{
|
||||
gpu->InitClear(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
|
||||
hasSetMode = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -231,9 +232,10 @@ void sceDisplaySetFramebuf()
|
|||
|
||||
u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelFormatPtr, int mode)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayGetFramebuf(%08x, %08x, %08x, %i)");
|
||||
|
||||
const FrameBufferState &fbState = mode == 1 ? latchedFramebuf : framebuf;
|
||||
DEBUG_LOG(HLE,"sceDisplayGetFramebuf(*%08x = %08x, *%08x = %08x, *%08x = %08x, %i)",
|
||||
topaddrPtr, fbState.topaddr, linesizePtr, fbState.pspFramebufLinesize, pixelFormatPtr, fbState.pspFramebufFormat, mode);
|
||||
|
||||
if (Memory::IsValidAddress(topaddrPtr))
|
||||
Memory::Write_U32(fbState.topaddr, topaddrPtr);
|
||||
if (Memory::IsValidAddress(linesizePtr))
|
||||
|
|
|
@ -71,9 +71,9 @@ void GLES_GPU::InitClear(int renderWidth, int renderHeight)
|
|||
widthFactor_ = (float)renderWidth / 480.0f;
|
||||
heightFactor_ = (float)renderHeight / 272.0f;
|
||||
|
||||
glClearColor(0,0,0,1);
|
||||
//glClearColor(0,0,0,1);
|
||||
// glClearColor(1,0,1,1);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
//glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, renderWidth_, renderHeight_);
|
||||
}
|
||||
|
||||
|
@ -108,14 +108,18 @@ void GLES_GPU::CopyDisplayToOutput()
|
|||
currentRenderVfb_ = 0;
|
||||
|
||||
if (!vfb) {
|
||||
DEBUG_LOG(HLE, "Found no FBO! displayFBPtr = %08x", displayFramebufPtr_);
|
||||
// No framebuffer to display! Clear to black.
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE, "Displaying FBO %08x", vfb->fb_address);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
fbo_bind_color_as_texture(vfb->fbo, 0);
|
||||
|
||||
|
@ -124,10 +128,12 @@ void GLES_GPU::CopyDisplayToOutput()
|
|||
|
||||
shaderManager.DirtyShader();
|
||||
shaderManager.DirtyUniform(DIRTY_ALL);
|
||||
gstate_c.textureChanged = true;
|
||||
|
||||
// Restore some state
|
||||
ExecuteOp(gstate.cmdmem[GE_CMD_CULLFACEENABLE], 0xFFFFFFFF);
|
||||
ExecuteOp(gstate.cmdmem[GE_CMD_ZTESTENABLE], 0xFFFFFFFF);
|
||||
ExecuteOp(gstate.cmdmem[GE_CMD_ALPHATESTENABLE], 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
GLES_GPU::VirtualFramebuffer *GLES_GPU::GetDisplayFBO()
|
||||
|
@ -140,7 +146,6 @@ GLES_GPU::VirtualFramebuffer *GLES_GPU::GetDisplayFBO()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,24 +187,30 @@ void GLES_GPU::SetRenderFrameBuffer()
|
|||
vfb->z_stride = z_stride;
|
||||
vfb->width = drawing_width;
|
||||
vfb->height = drawing_height;
|
||||
vfb->format = fmt;
|
||||
vfb->fbo = fbo_create(vfb->width * widthFactor_, vfb->height * heightFactor_, 1, true);
|
||||
vfbs_.push_back(vfb);
|
||||
fbo_bind_as_render_target(vfb->fbo);
|
||||
glViewport(0, 0, renderWidth_, renderHeight_);
|
||||
currentRenderVfb_ = vfb;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
DEBUG_LOG(HLE, "Creating FBO for %08x", vfb->fb_address);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vfb != currentRenderVfb_)
|
||||
{
|
||||
// Use it as a render target.
|
||||
DEBUG_LOG(HLE, "Switching to FBO for %08x", vfb->fb_address);
|
||||
fbo_bind_as_render_target(vfb->fbo);
|
||||
glViewport(0, 0, renderWidth_, renderHeight_);
|
||||
currentRenderVfb_ = vfb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Render queue
|
||||
|
||||
bool GLES_GPU::ProcessDLQueue()
|
||||
{
|
||||
std::vector<DisplayList>::iterator iter = dlQueue.begin();
|
||||
|
|
Loading…
Add table
Reference in a new issue