mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #10091 from hrydgard/vulkan-remove-refcounts
Vulkan: Remove refcounts on VKRFramebuffer.
This commit is contained in:
commit
9f77d48719
5 changed files with 8 additions and 65 deletions
|
@ -545,7 +545,9 @@ void Jit::BranchVFPUFlag(MIPSOpcode op, Gen::CCFlags cc, bool likely)
|
||||||
{
|
{
|
||||||
CONDITIONAL_LOG;
|
CONDITIONAL_LOG;
|
||||||
if (js.inDelaySlot) {
|
if (js.inDelaySlot) {
|
||||||
ERROR_LOG_REPORT(JIT, "Branch in VFPU delay slot at %08x in block starting at %08x", GetCompilerPC(), js.blockStart);
|
// I think we can safely just warn-log this without reporting, it's pretty clear that this type
|
||||||
|
// of branch is ignored.
|
||||||
|
WARN_LOG(JIT, "Branch in VFPU delay slot at %08x in block starting at %08x", GetCompilerPC(), js.blockStart);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int offset = _IMM16 << 2;
|
int offset = _IMM16 << 2;
|
||||||
|
|
|
@ -348,7 +348,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
|
||||||
vkCmdPipelineBarrier(cmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
vkCmdPipelineBarrier(cmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
iter.fb->color.layout = barrier.newLayout;
|
iter.fb->color.layout = barrier.newLayout;
|
||||||
}
|
}
|
||||||
iter.fb->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't execute empty renderpasses.
|
// Don't execute empty renderpasses.
|
||||||
|
@ -601,10 +600,6 @@ void VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKRStep &step
|
||||||
rp_begin.clearValueCount = numClearVals;
|
rp_begin.clearValueCount = numClearVals;
|
||||||
rp_begin.pClearValues = numClearVals ? clearVal : nullptr;
|
rp_begin.pClearValues = numClearVals ? clearVal : nullptr;
|
||||||
vkCmdBeginRenderPass(cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
if (step.render.framebuffer) {
|
|
||||||
step.render.framebuffer->Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) {
|
void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) {
|
||||||
|
@ -678,9 +673,6 @@ void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) {
|
||||||
}
|
}
|
||||||
vkCmdCopyImage(cmd, src->depth.image, src->depth.layout, dst->depth.image, dst->depth.layout, 1, ©);
|
vkCmdCopyImage(cmd, src->depth.image, src->depth.layout, dst->depth.image, dst->depth.layout, 1, ©);
|
||||||
}
|
}
|
||||||
|
|
||||||
src->Release();
|
|
||||||
dst->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) {
|
void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) {
|
||||||
|
@ -764,9 +756,6 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) {
|
||||||
}
|
}
|
||||||
vkCmdBlitImage(cmd, src->depth.image, src->depth.layout, dst->depth.image, dst->depth.layout, 1, &blit, step.blit.filter);
|
vkCmdBlitImage(cmd, src->depth.image, src->depth.layout, dst->depth.image, dst->depth.layout, 1, &blit, step.blit.filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
src->Release();
|
|
||||||
dst->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanQueueRunner::SetupTransitionToTransferSrc(VKRImage &img, VkImageMemoryBarrier &barrier, VkPipelineStageFlags &stage, VkImageAspectFlags aspect) {
|
void VulkanQueueRunner::SetupTransitionToTransferSrc(VKRImage &img, VkImageMemoryBarrier &barrier, VkPipelineStageFlags &stage, VkImageAspectFlags aspect) {
|
||||||
|
@ -867,8 +856,6 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd
|
||||||
vkCmdCopyImageToBuffer(cmd, srcImage->image, srcImage->layout, readbackBuffer_, 1, ®ion);
|
vkCmdCopyImageToBuffer(cmd, srcImage->image, srcImage->layout, readbackBuffer_, 1, ®ion);
|
||||||
|
|
||||||
// NOTE: Can't read the buffer using the CPU here - need to sync first.
|
// NOTE: Can't read the buffer using the CPU here - need to sync first.
|
||||||
|
|
||||||
step.readback.src->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanQueueRunner::PerformReadbackImage(const VKRStep &step, VkCommandBuffer cmd) {
|
void VulkanQueueRunner::PerformReadbackImage(const VKRStep &step, VkCommandBuffer cmd) {
|
||||||
|
|
|
@ -96,16 +96,6 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int
|
||||||
img.format = format;
|
img.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VKRFramebuffer::Release() {
|
|
||||||
if (--refcount_ == 0) {
|
|
||||||
delete this;
|
|
||||||
return true;
|
|
||||||
} else if (refcount_ >= 10000 || refcount_ < 0) {
|
|
||||||
ELOG("Refcount (%d) invalid for object %p - corrupt?", refcount_.load(), this);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan), queueRunner_(vulkan) {
|
VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan), queueRunner_(vulkan) {
|
||||||
VkSemaphoreCreateInfo semaphoreCreateInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
|
VkSemaphoreCreateInfo semaphoreCreateInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
|
||||||
semaphoreCreateInfo.flags = 0;
|
semaphoreCreateInfo.flags = 0;
|
||||||
|
@ -406,9 +396,6 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR
|
||||||
step->render.numDraws = 0;
|
step->render.numDraws = 0;
|
||||||
step->render.finalColorLayout = !fb ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
step->render.finalColorLayout = !fb ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
steps_.push_back(step);
|
steps_.push_back(step);
|
||||||
if (fb) {
|
|
||||||
fb->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
curRenderStep_ = step;
|
curRenderStep_ = step;
|
||||||
curWidth_ = fb ? fb->width : vulkan_->GetBackbufferWidth();
|
curWidth_ = fb ? fb->width : vulkan_->GetBackbufferWidth();
|
||||||
|
@ -422,7 +409,6 @@ void VulkanRenderManager::CopyFramebufferToMemorySync(VKRFramebuffer *src, int a
|
||||||
step->readback.srcRect.offset = { x, y };
|
step->readback.srcRect.offset = { x, y };
|
||||||
step->readback.srcRect.extent = { (uint32_t)w, (uint32_t)h };
|
step->readback.srcRect.extent = { (uint32_t)w, (uint32_t)h };
|
||||||
steps_.push_back(step);
|
steps_.push_back(step);
|
||||||
src->AddRef();
|
|
||||||
|
|
||||||
curRenderStep_ = nullptr;
|
curRenderStep_ = nullptr;
|
||||||
|
|
||||||
|
@ -599,8 +585,6 @@ void VulkanRenderManager::CopyFramebuffer(VKRFramebuffer *src, VkRect2D srcRect,
|
||||||
step->copy.srcRect = srcRect;
|
step->copy.srcRect = srcRect;
|
||||||
step->copy.dst = dst;
|
step->copy.dst = dst;
|
||||||
step->copy.dstPos = dstPos;
|
step->copy.dstPos = dstPos;
|
||||||
src->AddRef();
|
|
||||||
dst->AddRef();
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
steps_.push_back(step);
|
steps_.push_back(step);
|
||||||
|
@ -632,8 +616,6 @@ void VulkanRenderManager::BlitFramebuffer(VKRFramebuffer *src, VkRect2D srcRect,
|
||||||
step->blit.dst = dst;
|
step->blit.dst = dst;
|
||||||
step->blit.dstRect = dstRect;
|
step->blit.dstRect = dstRect;
|
||||||
step->blit.filter = filter;
|
step->blit.filter = filter;
|
||||||
src->AddRef();
|
|
||||||
dst->AddRef();
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
steps_.push_back(step);
|
steps_.push_back(step);
|
||||||
|
@ -657,7 +639,6 @@ VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, in
|
||||||
}
|
}
|
||||||
|
|
||||||
curRenderStep_->preTransitions.push_back({ fb, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL });
|
curRenderStep_->preTransitions.push_back({ fb, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL });
|
||||||
fb->AddRef();
|
|
||||||
return fb->color.imageView;
|
return fb->color.imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,29 +665,6 @@ void VulkanRenderManager::Finish() {
|
||||||
|
|
||||||
void VulkanRenderManager::Wipe() {
|
void VulkanRenderManager::Wipe() {
|
||||||
for (auto step : steps_) {
|
for (auto step : steps_) {
|
||||||
// Need to release held framebuffers.
|
|
||||||
switch (step->stepType) {
|
|
||||||
case VKRStepType::RENDER:
|
|
||||||
for (const auto &iter : step->preTransitions) {
|
|
||||||
iter.fb->Release();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case VKRStepType::COPY:
|
|
||||||
step->copy.src->Release();
|
|
||||||
step->copy.dst->Release();
|
|
||||||
break;
|
|
||||||
case VKRStepType::BLIT:
|
|
||||||
step->blit.src->Release();
|
|
||||||
step->blit.dst->Release();
|
|
||||||
break;
|
|
||||||
case VKRStepType::READBACK:
|
|
||||||
step->readback.src->Release();
|
|
||||||
break;
|
|
||||||
case VKRStepType::READBACK_IMAGE:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
delete step;
|
delete step;
|
||||||
}
|
}
|
||||||
steps_.clear();
|
steps_.clear();
|
||||||
|
|
|
@ -29,7 +29,6 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int
|
||||||
class VKRFramebuffer {
|
class VKRFramebuffer {
|
||||||
public:
|
public:
|
||||||
VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VkRenderPass renderPass, int _width, int _height) : vulkan_(vk) {
|
VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VkRenderPass renderPass, int _width, int _height) : vulkan_(vk) {
|
||||||
refcount_ = 1;
|
|
||||||
width = _width;
|
width = _width;
|
||||||
height = _height;
|
height = _height;
|
||||||
|
|
||||||
|
@ -50,6 +49,7 @@ public:
|
||||||
|
|
||||||
vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf);
|
vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
~VKRFramebuffer() {
|
~VKRFramebuffer() {
|
||||||
vulkan_->Delete().QueueDeleteImage(color.image);
|
vulkan_->Delete().QueueDeleteImage(color.image);
|
||||||
vulkan_->Delete().QueueDeleteImage(depth.image);
|
vulkan_->Delete().QueueDeleteImage(depth.image);
|
||||||
|
@ -60,11 +60,6 @@ public:
|
||||||
vulkan_->Delete().QueueDeleteFramebuffer(framebuf);
|
vulkan_->Delete().QueueDeleteFramebuffer(framebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRef() {
|
|
||||||
refcount_++;
|
|
||||||
}
|
|
||||||
bool Release();
|
|
||||||
|
|
||||||
int numShadows = 1; // TODO: Support this.
|
int numShadows = 1; // TODO: Support this.
|
||||||
|
|
||||||
VkFramebuffer framebuf = VK_NULL_HANDLE;
|
VkFramebuffer framebuf = VK_NULL_HANDLE;
|
||||||
|
@ -73,9 +68,7 @@ public:
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
|
||||||
private:
|
|
||||||
VulkanContext *vulkan_;
|
VulkanContext *vulkan_;
|
||||||
std::atomic<int> refcount_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class VKRRunType {
|
enum class VKRRunType {
|
||||||
|
|
|
@ -1251,7 +1251,10 @@ public:
|
||||||
// Inherits ownership so no AddRef.
|
// Inherits ownership so no AddRef.
|
||||||
VKFramebuffer(VKRFramebuffer *fb) : buf_(fb) {}
|
VKFramebuffer(VKRFramebuffer *fb) : buf_(fb) {}
|
||||||
~VKFramebuffer() {
|
~VKFramebuffer() {
|
||||||
buf_->Release();
|
buf_->vulkan_->Delete().QueueCallback([](void *fb) {
|
||||||
|
VKRFramebuffer *vfb = static_cast<VKRFramebuffer *>(fb);
|
||||||
|
delete vfb;
|
||||||
|
}, buf_);
|
||||||
}
|
}
|
||||||
VKRFramebuffer *GetFB() const { return buf_; }
|
VKRFramebuffer *GetFB() const { return buf_; }
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue