Skip to content

Commit

Permalink
Merge branch 'master' into TemporaryHackishBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaMoo committed Dec 25, 2017
2 parents 224c8b3 + 9b909b4 commit cce6a56
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Common/Vulkan/VulkanMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void VulkanPushBuffer::Unmap() {
}

VulkanDeviceAllocator::VulkanDeviceAllocator(VulkanContext *vulkan, size_t minSlabSize, size_t maxSlabSize)
: vulkan_(vulkan), lastSlab_(0), minSlabSize_(minSlabSize), maxSlabSize_(maxSlabSize), memoryTypeIndex_(UNDEFINED_MEMORY_TYPE), destroyed_(false) {
: vulkan_(vulkan), minSlabSize_(minSlabSize), maxSlabSize_(maxSlabSize) {
assert((minSlabSize_ & (SLAB_GRAIN_SIZE - 1)) == 0);
}

Expand Down Expand Up @@ -290,7 +290,7 @@ int VulkanDeviceAllocator::ComputeUsagePercent() const {
blocksUsed += slabs_[i].usage[j] != 0 ? 1 : 0;
}
}
return 100 * blocksUsed / blockSum;
return blockSum == 0 ? 0 : 100 * blocksUsed / blockSum;
}

void VulkanDeviceAllocator::Free(VkDeviceMemory deviceMemory, size_t offset) {
Expand Down
6 changes: 3 additions & 3 deletions Common/Vulkan/VulkanMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ class VulkanDeviceAllocator {

VulkanContext *const vulkan_;
std::vector<Slab> slabs_;
size_t lastSlab_;
size_t lastSlab_ = 0;
size_t minSlabSize_;
const size_t maxSlabSize_;
uint32_t memoryTypeIndex_;
bool destroyed_;
uint32_t memoryTypeIndex_ = UNDEFINED_MEMORY_TYPE;
bool destroyed_ = false;
};
4 changes: 2 additions & 2 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame
vfb->drawnFormat = params.fmt;
vfb->usageFlags = FB_USAGE_RENDERTARGET;
SetColorUpdated(vfb, skipDrawReason);
vfb->depthUpdated = false;

u32 byteSize = FramebufferByteSize(vfb);
u32 fb_address_mem = (params.fb_address & 0x3FFFFFFF) | 0x04000000;
Expand Down Expand Up @@ -591,7 +590,8 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe

// Copy depth pixel value from the read framebuffer to the draw framebuffer
if (prevVfb && !g_Config.bDisableSlowFramebufEffects) {
if (!prevVfb->fbo || !vfb->fbo || !useBufferedRendering_ || !prevVfb->depthUpdated || isClearingDepth) {
bool hasNewerDepth = prevVfb->last_frame_depth_render != 0 && prevVfb->last_frame_depth_render >= vfb->last_frame_depth_updated;
if (!prevVfb->fbo || !vfb->fbo || !useBufferedRendering_ || !hasNewerDepth || isClearingDepth) {
// If depth wasn't updated, then we're at least "two degrees" away from the data.
// This is an optimization: it probably doesn't need to be copied in this case.
} else {
Expand Down
6 changes: 4 additions & 2 deletions GPU/Common/FramebufferCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ struct VirtualFramebuffer {
int last_frame_displayed;
int last_frame_clut;
int last_frame_failed;
int last_frame_depth_updated;
int last_frame_depth_render;
u32 clutUpdatedBytes;
bool memoryUpdated;
bool depthUpdated;
bool firstFrameSaved;

u32 fb_address;
Expand Down Expand Up @@ -283,7 +284,8 @@ class FramebufferManagerCommon {

void SetDepthUpdated() {
if (currentRenderVfb_) {
currentRenderVfb_->depthUpdated = true;
currentRenderVfb_->last_frame_depth_render = gpuStats.numFlips;
currentRenderVfb_->last_frame_depth_updated = gpuStats.numFlips;
}
}
void SetColorUpdated(int skipDrawReason) {
Expand Down
1 change: 1 addition & 0 deletions GPU/D3D11/FramebufferManagerD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ void FramebufferManagerD3D11::BlitFramebufferDepth(VirtualFramebuffer *src, Virt
// TODO: Currently, this copies depth AND stencil, which is a problem. See #9740.
draw_->CopyFramebufferImage(src->fbo, 0, 0, 0, 0, dst->fbo, 0, 0, 0, 0, src->renderWidth, src->renderHeight, 1, Draw::FB_DEPTH_BIT);
RebindFramebuffer();
dst->last_frame_depth_updated = gpuStats.numFlips;
}
}

Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/FramebufferManagerGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void FramebufferManagerGLES::BlitFramebufferDepth(VirtualFramebuffer *src, Virtu
// Let's only do this if not clearing depth.
glstate.scissorTest.force(false);
draw_->BlitFramebuffer(src->fbo, 0, 0, w, h, dst->fbo, 0, 0, w, h, Draw::FB_DEPTH_BIT, Draw::FB_BLIT_NEAREST);
// WARNING: If we set dst->depthUpdated here, our optimization above would be pointless.
dst->last_frame_depth_updated = gpuStats.numFlips;
glstate.scissorTest.restore();
}
}
Expand Down
29 changes: 26 additions & 3 deletions GPU/Software/SoftGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,33 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff) {
break;

case GE_CMD_BOUNDINGBOX:
if (data != 0)
if (data == 0) {
currentList->bboxResult = false;
} else if (((data & 7) == 0) && data <= 64) { // Sanity check
DEBUG_LOG(G3D, "Unsupported bounding box: %06x", data);
// bounding box test. Let's assume the box was within the drawing region.
currentList->bboxResult = true;
void *control_points = Memory::GetPointer(gstate_c.vertexAddr);
if (!control_points) {
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Invalid verts in bounding box check");
currentList->bboxResult = true;
return;
}

if (gstate.vertType & GE_VTYPE_IDX_MASK) {
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Indexed bounding box data not supported.");
// Data seems invalid. Let's assume the box test passed.
currentList->bboxResult = true;
return;
}

// Test if the bounding box is within the drawing region.
int bytesRead;
currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, data, gstate.vertType, &bytesRead);
AdvanceVerts(gstate.vertType, data, bytesRead);
} else {
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Bad bounding box data: %06x", data);
// Data seems invalid. Let's assume the box test passed.
currentList->bboxResult = true;
}
break;

case GE_CMD_VERTEXTYPE:
Expand Down
1 change: 1 addition & 0 deletions GPU/Vulkan/FramebufferVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ void FramebufferManagerVulkan::BlitFramebufferDepth(VirtualFramebuffer *src, Vir
if (matchingDepthBuffer && matchingRenderSize && matchingSize) {
// TODO: Currently, this copies depth AND stencil, which is a problem. See #9740.
draw_->CopyFramebufferImage(src->fbo, 0, 0, 0, 0, dst->fbo, 0, 0, 0, 0, src->renderWidth, src->renderHeight, 1, Draw::FB_DEPTH_BIT);
dst->last_frame_depth_updated = gpuStats.numFlips;
} else if (matchingDepthBuffer && matchingSize) {
/*
int w = std::min(src->renderWidth, dst->renderWidth);
Expand Down
2 changes: 2 additions & 0 deletions ext/native/thin3d/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ void VKContext::BeginFrame() {
// OK, we now know that nothing is reading from this frame's data pushbuffer,
push_->Reset();
push_->Begin(vulkan_);
allocator_->Begin();

frame.descSets_.clear();
VkResult result = vkResetDescriptorPool(device_, frame.descriptorPool, 0);
Expand All @@ -792,6 +793,7 @@ void VKContext::WaitRenderCompletion(Framebuffer *fbo) {
void VKContext::EndFrame() {
// Stop collecting data in the frame's data pushbuffer.
push_->End();
allocator_->End();

renderManager_.Finish();

Expand Down

0 comments on commit cce6a56

Please sign in to comment.