From 3701e2eca3a0698de01201b5a166ca1232976cfa Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 5 Jan 2016 22:55:47 +0100 Subject: [PATCH] Reaches the first clear --- GPU/GPU.cpp | 2 -- GPU/Vulkan/DrawEngineVulkan.cpp | 14 ------------- GPU/Vulkan/DrawEngineVulkan.h | 1 - GPU/Vulkan/FramebufferVulkan.cpp | 24 ++++++++++++++++++++++ GPU/Vulkan/FramebufferVulkan.h | 34 +++++++++++--------------------- GPU/Vulkan/GPU_Vulkan.cpp | 3 ++- 6 files changed, 38 insertions(+), 40 deletions(-) diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index dc1b9b9e3c..0c509df0c7 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -60,9 +60,7 @@ bool GPU_Init(GraphicsContext *ctx) { #endif break; case GPU_VULKAN: - { SetGPU(new GPU_Vulkan(ctx)); - } break; } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index f090bd602c..72e2aba8a7 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -73,7 +73,6 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan) numDrawCalls(0), vertexCountInDrawCalls(0), decodeCounter_(0), - dcid_(0), fboTexNeedBind_(false), fboTexBound_(false), curFrame_(0) { @@ -231,18 +230,6 @@ void DrawEngineVulkan::SubmitPrim(void *verts, void *inds, GEPrimitiveType prim, dc.prim = prim; dc.vertexCount = vertexCount; - u32 dhash = dcid_; - dhash ^= (u32)(uintptr_t)verts; - dhash = __rotl(dhash, 13); - dhash ^= (u32)(uintptr_t)inds; - dhash = __rotl(dhash, 13); - dhash ^= (u32)vertType; - dhash = __rotl(dhash, 13); - dhash ^= (u32)vertexCount; - dhash = __rotl(dhash, 13); - dhash ^= (u32)prim; - dcid_ = dhash; - if (inds) { GetIndexBounds(inds, vertexCount, vertType, &dc.indexLowerBound, &dc.indexUpperBound); } else { @@ -553,7 +540,6 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) { numDrawCalls = 0; vertexCountInDrawCalls = 0; decodeCounter_ = 0; - dcid_ = 0; prevPrim_ = GE_PRIM_INVALID; gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index ebb81dadc9..05f3911cb8 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -207,7 +207,6 @@ private: int vertexCountInDrawCalls; int decodeCounter_; - u32 dcid_; bool fboTexNeedBind_; bool fboTexBound_; diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 24f4c8cbd7..b26ab43b12 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -18,7 +18,10 @@ #pragma once #include "GPU/GPUInterface.h" +#include "GPU/GPUState.h" #include "GPU/Vulkan/FramebufferVulkan.h" +#include "GPU/Vulkan/DrawEngineVulkan.h" + VulkanFramebuffer *FramebufferManagerVulkan::GetTempFBO(int width, int height, VulkanFBOColorDepth colorDepth) { @@ -41,10 +44,31 @@ void FramebufferManagerVulkan::CopyDisplayToOutput() { } +void FramebufferManagerVulkan::DecimateFBOs() { + +} + void FramebufferManagerVulkan::EndFrame() { } +void FramebufferManagerVulkan::DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) { + // So: Allocate a temporary texture from a (very small) pool, upload content directly into it, schedule a transition + // into the init command buffer, alloc and create an appropriate descriptor set, then bind and draw. no need for uniforms. +} + + +void FramebufferManagerVulkan::FlushBeforeCopy() { + // Flush anything not yet drawn before blitting, downloading, or uploading. + // This might be a stalled list, or unflushed before a block transfer, etc. + + // TODO: It's really bad that we are calling SetRenderFramebuffer here with + // all the irrelevant state checking it'll use to decide what to do. Should + // do something more focused here. + SetRenderFrameBuffer(gstate_c.framebufChanged, gstate_c.skipDrawReason); + drawEngine_->Flush(nullptr); +} + std::vector FramebufferManagerVulkan::GetFramebufferList() { return std::vector(); } diff --git a/GPU/Vulkan/FramebufferVulkan.h b/GPU/Vulkan/FramebufferVulkan.h index f8a8b6f521..a30a097e70 100644 --- a/GPU/Vulkan/FramebufferVulkan.h +++ b/GPU/Vulkan/FramebufferVulkan.h @@ -30,25 +30,26 @@ enum VulkanFBOColorDepth { }; class TextureCacheVulkan; +class DrawEngineVulkan; +class VulkanContext; class FramebufferManagerVulkan : public FramebufferManagerCommon { public: + FramebufferManagerVulkan(VulkanContext *vulkan) : vulkan_(vulkan) {} // Subsequent commands will be enqueued on this buffer. - void SetInstance(VkInstance inst) { inst_ = inst; } void SetCmdBuffer(VkCommandBuffer cmd) { cmd_ = cmd; } virtual void ClearBuffer(bool keepState = false) override { throw std::logic_error("The method or operation is not implemented."); } void SetTextureCache(TextureCacheVulkan *texCache) { texCache_ = texCache; } + void SetDrawEngine(DrawEngineVulkan *drawEngine) { drawEngine_ = drawEngine; } VulkanFramebuffer *GetTempFBO(int width, int height, VulkanFBOColorDepth colorDepth); - virtual void RebindFramebuffer() override { - throw std::logic_error("The method or operation is not implemented."); - } + void RebindFramebuffer() override { } // This makes little sense with Vulkan's model. - virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override { - throw std::logic_error("The method or operation is not implemented."); + bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override { + return false; } virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) override { @@ -56,28 +57,20 @@ public: } virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override { - throw std::logic_error("The method or operation is not implemented."); } - virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override { - throw std::logic_error("The method or operation is not implemented."); - } + void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override; virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override { throw std::logic_error("The method or operation is not implemented."); } virtual void DisableState() override { - throw std::logic_error("The method or operation is not implemented."); } - virtual void FlushBeforeCopy() override { - throw std::logic_error("The method or operation is not implemented."); - } + virtual void FlushBeforeCopy() override; - virtual void DecimateFBOs() override { - throw std::logic_error("The method or operation is not implemented."); - } + void DecimateFBOs() override; virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override { throw std::logic_error("The method or operation is not implemented."); @@ -88,19 +81,15 @@ public: } virtual void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false) override { - throw std::logic_error("The method or operation is not implemented."); } virtual void NotifyRenderFramebufferCreated(VirtualFramebuffer *vfb) override { - throw std::logic_error("The method or operation is not implemented."); } virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) override { - throw std::logic_error("The method or operation is not implemented."); } virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) override { - throw std::logic_error("The method or operation is not implemented."); } void DownloadFramebufferForClut(u32 fb_address, u32 loadBytes) override { @@ -123,8 +112,9 @@ public: std::vector GetFramebufferList(); private: - VkInstance inst_; + VulkanContext *vulkan_; VkCommandBuffer cmd_; TextureCacheVulkan *texCache_; + DrawEngineVulkan *drawEngine_; }; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 5980c49220..77ce919ac5 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -394,6 +394,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *ctx) : vulkan_((VulkanContext *)ctx->GetAPIContext()), drawEngine_(vulkan_), textureCache_(vulkan_), + framebufferManager_(vulkan_), resized_(false), gfxCtx_(ctx) { UpdateVsyncInterval(true); @@ -405,6 +406,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *ctx) drawEngine_.SetFramebufferManager(&framebufferManager_); framebufferManager_.Init(); framebufferManager_.SetTextureCache(&textureCache_); + framebufferManager_.SetDrawEngine(&drawEngine_); textureCache_.SetFramebufferManager(&framebufferManager_); textureCache_.SetDepalShaderCache(&depalShaderCache_); textureCache_.SetShaderManager(shaderManager_); @@ -619,7 +621,6 @@ void GPU_Vulkan::CopyDisplayToOutput() { void GPU_Vulkan::CopyDisplayToOutputInternal() { // Flush anything left over. - framebufferManager_.RebindFramebuffer(); drawEngine_.Flush(curCmd_); shaderManager_->DirtyLastShader();