Fix buffer alloc alignment and framebuffer comparison.

This commit is contained in:
Ben Vanik
2016-02-21 14:43:59 -08:00
parent 06ba273492
commit d57f974e2e
3 changed files with 17 additions and 11 deletions

View File

@@ -344,11 +344,12 @@ VkDeviceSize BufferCache::TryAllocateTransientData(VkDeviceSize alignment,
if (transient_tail_offset_ >= transient_head_offset_) {
// Tail follows head, so things are easy:
// | H----T |
if (transient_tail_offset_ + length <= transient_capacity_) {
if (xe::round_up(transient_tail_offset_, alignment) + length <=
transient_capacity_) {
// Allocation fits from tail to end of buffer, so grow.
// | H----**T |
VkDeviceSize offset = transient_tail_offset_;
transient_tail_offset_ += length;
VkDeviceSize offset = xe::round_up(transient_tail_offset_, alignment);
transient_tail_offset_ = offset + length;
return offset;
} else if (length + kDeadZone <= transient_head_offset_) {
// Can't fit at the end, but can fit if we wrap around.
@@ -360,11 +361,12 @@ VkDeviceSize BufferCache::TryAllocateTransientData(VkDeviceSize alignment,
} else {
// Head follows tail, so we're reversed:
// |----T H---|
if (transient_tail_offset_ + length + kDeadZone <= transient_head_offset_) {
if (xe::round_up(transient_tail_offset_, alignment) + length + kDeadZone <=
transient_head_offset_) {
// Fits from tail to head.
// |----***T H---|
VkDeviceSize offset = transient_tail_offset_;
transient_tail_offset_ += length;
VkDeviceSize offset = xe::round_up(transient_tail_offset_, alignment);
transient_tail_offset_ = offset + length;
return offset;
}
}