Start work on separating frame from backbuffer renderpass

This commit is contained in:
Henrik Rydgård committed 2017-05-30 09:36:17 +02:00
1 parent 4407445d50
commit 3b6fa9be87
5 files changed
+40 -34

No files matched your search

+7 -6
View File
@@ -205,7 +205,7 @@ void FramebufferManagerCommon::SetNumExtraFBOs(int num) {
Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ (int)renderWidth_, (int)renderHeight_, 1, 1, false, Draw::FBO_8888 });
extraFBOs_.push_back(fbo);
// The new FBO is still bound after creation, but let's bind it anyway.
// The new FBO is still bound after creation, but let's bind and clear it anyway.
draw_->BindFramebufferAsRenderTarget(fbo);
ClearBuffer();
}
@@ -828,20 +828,16 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
DownloadFramebufferOnSwitch(currentRenderVfb_);
SetViewport2D(0, 0, pixelWidth_, pixelHeight_);
draw_->BindBackbufferAsRenderTarget();
currentRenderVfb_ = 0;
if (displayFramebufPtr_ == 0) {
DEBUG_LOG(FRAMEBUF, "Display disabled, displaying only black");
// No framebuffer to display! Clear to black.
draw_->BindBackbufferAsRenderTarget();
ClearBuffer();
return;
}
if (useBufferedRendering_) {
draw_->Clear(Draw::FB_COLOR_BIT | Draw::FB_STENCIL_BIT | Draw::FB_DEPTH_BIT, 0, 0, 0);
}
u32 offsetX = 0;
u32 offsetY = 0;
@@ -888,6 +884,11 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
}
}
draw_->BindBackbufferAsRenderTarget();
if (useBufferedRendering_) {
draw_->Clear(Draw::FB_COLOR_BIT | Draw::FB_STENCIL_BIT | Draw::FB_DEPTH_BIT, 0, 0, 0);
}
if (!vfb) {
if (Memory::IsValidAddress(displayFramebufPtr_)) {
// The game is displaying something directly from RAM. In GTA, it's decoded video.
+4 -4
View File
@@ -444,10 +444,10 @@ void FramebufferManagerVulkan::DrawTexture(VulkanTexture *texture, float x, floa
}
Vulkan2D::Vertex vtx[4] = {
{x,y,0,texCoords[0],texCoords[1]},
{x + w,y,0,texCoords[2],texCoords[3]},
{x,y + h,0,texCoords[6],texCoords[7] },
{x + w,y + h,0,texCoords[4],texCoords[5] },
{x,y, 0,texCoords[0],texCoords[1]},
{x + w,y, 0,texCoords[2],texCoords[3]},
{x,y + h, 0,texCoords[6],texCoords[7] },
{x + w,y + h, 0,texCoords[4],texCoords[5] },
};
float invDestW = 1.0f / (destW * 0.5f);
+4 -5
View File
@@ -636,11 +636,10 @@ public:
virtual void DrawIndexed(int vertexCount, int offset) = 0;
virtual void DrawUP(const void *vdata, int vertexCount) = 0;
// Render pass management. Default implementations here.
virtual void Begin(bool clear, uint32_t colorval, float depthVal, int stencilVal) {
Clear(0xF, colorval, depthVal, stencilVal);
}
virtual void End() {}
// Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here.
virtual void BeginFrame() {}
virtual void EndFrame() {}
virtual void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) = 0;
// Necessary to correctly flip scissor rectangles etc for OpenGL.
+22 -17
View File
@@ -387,8 +387,8 @@ public:
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
void Begin(bool clear, uint32_t colorval, float depthVal, int stencilVal) override;
void End() override;
void BeginFrame() override;
void EndFrame() override;
std::string GetInfoString(InfoField info) const override {
// TODO: Make these actually query the right information
@@ -731,21 +731,9 @@ VKContext::~VKContext() {
vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_);
}
void VKContext::Begin(bool clear, uint32_t colorval, float depthVal, int stencilVal) {
void VKContext::BeginFrame() {
cmd_ = vulkan_->BeginFrame();
VkClearValue clearVal[2] = {};
Uint8x4ToFloat4(colorval, clearVal[0].color.float32);
// // Debug flicker - used to see if we swap at all. no longer necessary
// if (frameNum_ & 1)
// clearVal[0].color.float32[2] = 1.0f;
clearVal[1].depthStencil.depth = depthVal;
clearVal[1].depthStencil.stencil = stencilVal;
vulkan_->BeginSurfaceRenderPass(clearVal);
FrameData *frame = &frame_[frameNum_ & 1];
push_ = frame->pushBuffer;
@@ -761,12 +749,29 @@ void VKContext::Begin(bool clear, uint32_t colorval, float depthVal, int stencil
scissor_.extent.height = pixel_yres;
scissorDirty_ = true;
viewportDirty_ = true;
int colorval = 0xFF000000;
float depthVal = 0.0;
int stencilVal = 0;
VkClearValue clearVal[2] = {};
Uint8x4ToFloat4(colorval, clearVal[0].color.float32);
// // Debug flicker - used to see if we swap at all. no longer necessary
// if (frameNum_ & 1)
// clearVal[0].color.float32[2] = 1.0f;
clearVal[1].depthStencil.depth = depthVal;
clearVal[1].depthStencil.stencil = stencilVal;
vulkan_->BeginSurfaceRenderPass(clearVal);
}
void VKContext::End() {
void VKContext::EndFrame() {
vulkan_->EndSurfaceRenderPass();
// Stop collecting data in the frame's data pushbuffer.
push_->End();
vulkan_->EndSurfaceRenderPass();
vulkan_->EndFrame();
frameNum_++;
+3 -2
View File
@@ -65,7 +65,8 @@ void UIScreen::preRender() {
if (!draw) {
return;
}
draw->Begin(true, 0xFF000000, 0.0f, 0);
draw->BeginFrame();
draw->Clear(0xF, 0xFF000000, 0.0f, 0);
Draw::Viewport viewport;
viewport.TopLeftX = 0;
@@ -83,7 +84,7 @@ void UIScreen::postRender() {
if (!draw) {
return;
}
draw->End();
draw->EndFrame();
}
void UIScreen::render() {