Permalink
Browse files

Keep the draw context up to date in a bunch of places. More logging.

  • Loading branch information...
hrydgard committed Nov 9, 2017
1 parent ec50475 commit 6eb58b12524ecc7aa19533f11939fe8e8542ceb9
@@ -70,6 +70,11 @@ DepalShaderCacheVulkan::~DepalShaderCacheVulkan() {
vulkan_->Delete().QueueDeleteShaderModule(vshader_);
}
void DepalShaderCacheVulkan::DeviceRestore(Draw::DrawContext *draw, VulkanContext *vulkan) {
draw_ = draw;
vulkan_ = vulkan;
}
DepalShaderVulkan *DepalShaderCacheVulkan::GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat) {
u32 id = GenerateShaderID(clutMode, pixelFormat);
@@ -52,6 +52,7 @@ class DepalShaderCacheVulkan : public DepalShaderCacheCommon {
public:
DepalShaderCacheVulkan(Draw::DrawContext *draw, VulkanContext *vulkan);
~DepalShaderCacheVulkan();
void DeviceRestore(Draw::DrawContext *draw, VulkanContext *vulkan);
// This also uploads the palette and binds the correct texture.
DepalShaderVulkan *GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat);
@@ -269,8 +269,9 @@ void DrawEngineVulkan::DeviceLost() {
DirtyAllUBOs();
}
void DrawEngineVulkan::DeviceRestore(VulkanContext *vulkan) {
void DrawEngineVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw) {
vulkan_ = vulkan;
draw_ = draw;
InitDeviceObjects();
}
@@ -137,7 +137,7 @@ class DrawEngineVulkan : public DrawEngineCommon {
}
void DeviceLost();
void DeviceRestore(VulkanContext *vulkan);
void DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw);
void SetupVertexDecoder(u32 vertType);
void SetupVertexDecoderInternal(u32 vertType);
@@ -593,8 +593,9 @@ void FramebufferManagerVulkan::DeviceLost() {
DestroyDeviceObjects();
}
void FramebufferManagerVulkan::DeviceRestore(VulkanContext *vulkan) {
void FramebufferManagerVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw) {
vulkan_ = vulkan;
draw_ = draw;
vulkan2D_->DeviceRestore(vulkan_);
InitDeviceObjects();
@@ -70,7 +70,7 @@ class FramebufferManagerVulkan : public FramebufferManagerCommon {
void Resized() override;
void DeviceLost();
void DeviceRestore(VulkanContext *vulkan);
void DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw);
int GetLineWidth();
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
@@ -813,17 +813,19 @@ void GPU_Vulkan::DeviceLost() {
void GPU_Vulkan::DeviceRestore() {
vulkan_ = (VulkanContext *)PSP_CoreParameter().graphicsContext->GetAPIContext();
draw_ = (Draw::DrawContext *)PSP_CoreParameter().graphicsContext->GetDrawContext();
InitDeviceObjects();
CheckGPUFeatures();
BuildReportingInfo();
UpdateCmdInfo();
framebufferManagerVulkan_->DeviceRestore(vulkan_);
drawEngine_.DeviceRestore(vulkan_);
framebufferManagerVulkan_->DeviceRestore(vulkan_, draw_);
drawEngine_.DeviceRestore(vulkan_, draw_);
pipelineManager_->DeviceRestore(vulkan_);
textureCacheVulkan_->DeviceRestore(vulkan_);
textureCacheVulkan_->DeviceRestore(vulkan_, draw_);
shaderManagerVulkan_->DeviceRestore(vulkan_);
depalShaderCache_.DeviceRestore(draw_, vulkan_);
}
void GPU_Vulkan::GetStats(char *buffer, size_t bufsize) {
@@ -187,8 +187,9 @@ void TextureCacheVulkan::DeviceLost() {
nextTexture_ = nullptr;
}
void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan) {
void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw) {
vulkan_ = vulkan;
draw_ = draw;
assert(!allocator_);
@@ -72,7 +72,7 @@ class TextureCacheVulkan : public TextureCacheCommon {
void EndFrame();
void DeviceLost();
void DeviceRestore(VulkanContext *vulkan);
void DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw);
void SetFramebufferManager(FramebufferManagerVulkan *fbManager);
void SetDepalShaderCache(DepalShaderCacheVulkan *dpCache) {
@@ -340,6 +340,7 @@ void AndroidVulkanContext::Shutdown() {
draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
delete draw_;
draw_ = nullptr;
ILOG("Calling NativeShutdownGraphics");
NativeShutdownGraphics();
g_Vulkan->WaitUntilQueueIdle();
g_Vulkan->DestroyObjects();
@@ -9,6 +9,7 @@
const uint32_t readbackBufferSize = 2048 * 2048 * 4;
void VulkanQueueRunner::CreateDeviceObjects() {
ILOG("VulkanQueueRuner::CreateDeviceObjects");
InitBackbufferRenderPass();
InitRenderpasses();
@@ -36,16 +37,21 @@ void VulkanQueueRunner::CreateDeviceObjects() {
}
void VulkanQueueRunner::DestroyDeviceObjects() {
ILOG("VulkanQueueRuner::DestroyDeviceObjects");
VkDevice device = vulkan_->GetDevice();
vkFreeMemory(device, readbackMemory_, nullptr);
readbackMemory_ = VK_NULL_HANDLE;
vulkan_->Delete().QueueDeleteBuffer(readbackBuffer_);
readbackBuffer_ = VK_NULL_HANDLE;
for (int i = 0; i < ARRAY_SIZE(renderPasses_); i++) {
assert(renderPasses_[i] != VK_NULL_HANDLE);
vkDestroyRenderPass(device, renderPasses_[i], nullptr);
renderPasses_[i] = VK_NULL_HANDLE;
}
assert(backbufferRenderPass_ != VK_NULL_HANDLE);
vkDestroyRenderPass(device, backbufferRenderPass_, nullptr);
backbufferRenderPass_ = VK_NULL_HANDLE;
}
void VulkanQueueRunner::InitBackbufferRenderPass() {
@@ -199,7 +199,7 @@ void VulkanRenderManager::CreateBackbuffers() {
}
}
void VulkanRenderManager::StopThread(bool shutdown) {
void VulkanRenderManager::StopThread() {
if (useThread && run_) {
run_ = false;
// Stop the thread.
@@ -232,7 +232,7 @@ void VulkanRenderManager::StopThread(bool shutdown) {
}
void VulkanRenderManager::DestroyBackbuffers() {
StopThread(false);
StopThread();
vulkan_->WaitUntilQueueIdle();
VkDevice device = vulkan_->GetDevice();
@@ -253,7 +253,8 @@ void VulkanRenderManager::DestroyBackbuffers() {
}
VulkanRenderManager::~VulkanRenderManager() {
StopThread(true);
ILOG("VulkanRenderManager destructor");
StopThread();
vulkan_->WaitUntilQueueIdle();
VkDevice device = vulkan_->GetDevice();
@@ -222,7 +222,7 @@ class VulkanRenderManager {
void FlushSync();
void EndSyncFrame(int frame);
void StopThread(bool shutdown);
void StopThread();
// Permanent objects
VkSemaphore acquireSemaphore_;

0 comments on commit 6eb58b1

Please sign in to comment.