BufferQueue: Increase max slots from 32 to 64

Increases NUM_BUFFER_SLOTS from 32 to 64 and changes the mask
returned by IGBC::getReleasedBuffers from 32 to 64 bits.

Bug: 13174352
Change-Id: Ie8ef0853916cfb91f83881c7241886bb1950f01a
This commit is contained in:
Dan Stoza 2014-04-09 16:14:51 -07:00
parent 10f91bbf7d
commit febd4f4f46
10 changed files with 28 additions and 24 deletions

View File

@ -69,7 +69,7 @@ class BufferQueue : public BQProducer,
public:
// BufferQueue will keep track of at most this value of buffers.
// Attempts at runtime to increase the number of buffers past this will fail.
enum { NUM_BUFFER_SLOTS = 32 };
enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };
// Used as a placeholder slot# when the value isn't pointing to an existing buffer.
enum { INVALID_BUFFER_SLOT = IGraphicBufferConsumer::BufferItem::INVALID_BUFFER_SLOT };
// Alias to <IGraphicBufferConsumer.h> -- please scope from there in future code!
@ -325,7 +325,7 @@ public:
// but have not yet been released by the consumer.
//
// This should be called from the onBuffersReleased() callback.
virtual status_t getReleasedBuffers(uint32_t* slotMask);
virtual status_t getReleasedBuffers(uint64_t* slotMask);
// setDefaultBufferSize is used to set the size of buffers returned by
// dequeueBuffer when a width and height of zero is requested. Default

View File

@ -93,7 +93,7 @@ public:
// but have not yet been released by the consumer.
//
// This should be called from the onBuffersReleased() callback.
virtual status_t getReleasedBuffers(uint32_t* outSlotMask);
virtual status_t getReleasedBuffers(uint64_t* outSlotMask);
// setDefaultBufferSize is used to set the size of buffers returned by
// dequeueBuffer when a width and height of zero is requested. Default

View File

@ -26,7 +26,7 @@ namespace android {
// BufferQueue will keep track of at most this value of buffers.
// Attempts at runtime to increase the number of buffers past this
// will fail.
enum { NUM_BUFFER_SLOTS = 32 };
enum { NUM_BUFFER_SLOTS = 64 };
typedef BufferSlot SlotsType[NUM_BUFFER_SLOTS];
} // namespace BufferQueueDefs

View File

@ -230,7 +230,7 @@ public:
//
// Return of a value other than NO_ERROR means an error has occurred:
// * NO_INIT - the buffer queue has been abandoned.
virtual status_t getReleasedBuffers(uint32_t* slotMask) = 0;
virtual status_t getReleasedBuffers(uint64_t* slotMask) = 0;
// setDefaultBufferSize is used to set the size of buffers returned by
// dequeueBuffer when a width and height of zero is requested. Default

View File

@ -158,7 +158,7 @@ status_t BufferQueue::consumerDisconnect() {
return mConsumer->disconnect();
}
status_t BufferQueue::getReleasedBuffers(uint32_t* slotMask) {
status_t BufferQueue::getReleasedBuffers(uint64_t* slotMask) {
return mConsumer->getReleasedBuffers(slotMask);
}

View File

@ -346,7 +346,7 @@ status_t BufferQueueConsumer::disconnect() {
return NO_ERROR;
}
status_t BufferQueueConsumer::getReleasedBuffers(uint32_t *outSlotMask) {
status_t BufferQueueConsumer::getReleasedBuffers(uint64_t *outSlotMask) {
ATRACE_CALL();
if (outSlotMask == NULL) {
@ -361,10 +361,10 @@ status_t BufferQueueConsumer::getReleasedBuffers(uint32_t *outSlotMask) {
return NO_INIT;
}
uint32_t mask = 0;
uint64_t mask = 0;
for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
if (!mSlots[s].mAcquireCalled) {
mask |= (1u << s);
mask |= (1ULL << s);
}
}
@ -374,12 +374,12 @@ status_t BufferQueueConsumer::getReleasedBuffers(uint32_t *outSlotMask) {
BufferQueueCore::Fifo::iterator current(mCore->mQueue.begin());
while (current != mCore->mQueue.end()) {
if (current->mAcquireCalled) {
mask &= ~(1u << current->mSlot);
mask &= ~(1ULL << current->mSlot);
}
++current;
}
BQ_LOGV("getReleasedBuffers: returning mask %#x", mask);
BQ_LOGV("getReleasedBuffers: returning mask %#" PRIx64, mask);
*outSlotMask = mask;
return NO_ERROR;
}

View File

@ -121,10 +121,10 @@ void ConsumerBase::onBuffersReleased() {
return;
}
uint32_t mask = 0;
uint64_t mask = 0;
mConsumer->getReleasedBuffers(&mask);
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
if (mask & (1 << i)) {
if (mask & (1ULL << i)) {
freeBufferLocked(i);
}
}

View File

@ -298,14 +298,18 @@ public:
return reply.readInt32();
}
virtual status_t getReleasedBuffers(uint32_t* slotMask) {
virtual status_t getReleasedBuffers(uint64_t* slotMask) {
Parcel data, reply;
if (slotMask == NULL) {
ALOGE("getReleasedBuffers: slotMask must not be NULL");
return BAD_VALUE;
}
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
status_t result = remote()->transact(GET_RELEASED_BUFFERS, data, &reply);
if (result != NO_ERROR) {
return result;
}
*slotMask = reply.readInt32();
*slotMask = reply.readInt64();
return reply.readInt32();
}
@ -480,9 +484,9 @@ status_t BnGraphicBufferConsumer::onTransact(
} break;
case GET_RELEASED_BUFFERS: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t slotMask;
uint64_t slotMask;
status_t result = getReleasedBuffers(&slotMask);
reply->writeInt32(slotMask);
reply->writeInt64(slotMask);
reply->writeInt32(result);
return NO_ERROR;
} break;

View File

@ -256,7 +256,7 @@ void VirtualDisplaySurface::onFrameCommitted() {
resetPerFrameState();
}
void VirtualDisplaySurface::dump(String8& result) const {
void VirtualDisplaySurface::dump(String8& /* result */) const {
}
status_t VirtualDisplaySurface::requestBuffer(int pslot,
@ -285,19 +285,19 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source,
int pslot = mapSource2ProducerSlot(source, *sslot);
VDS_LOGV("dequeueBuffer(%s): sslot=%d pslot=%d result=%d",
dbgSourceStr(source), *sslot, pslot, result);
uint32_t sourceBit = static_cast<uint32_t>(source) << pslot;
uint64_t sourceBit = static_cast<uint64_t>(source) << pslot;
if ((mProducerSlotSource & (1u << pslot)) != sourceBit) {
if ((mProducerSlotSource & (1ULL << pslot)) != sourceBit) {
// This slot was previously dequeued from the other source; must
// re-request the buffer.
result |= BUFFER_NEEDS_REALLOCATION;
mProducerSlotSource &= ~(1u << pslot);
mProducerSlotSource &= ~(1ULL << pslot);
mProducerSlotSource |= sourceBit;
}
if (result & RELEASE_ALL_BUFFERS) {
for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
if ((mProducerSlotSource & (1u << i)) == sourceBit)
if ((mProducerSlotSource & (1ULL << i)) == sourceBit)
mProducerBuffers[i].clear();
}
}

View File

@ -152,10 +152,10 @@ private:
// Since we present a single producer interface to the GLES driver, but
// are internally muxing between the sink and scratch producers, we have
// to keep track of which source last returned each producer slot from
// dequeueBuffer. Each bit in mLastSlotSource corresponds to a producer
// dequeueBuffer. Each bit in mProducerSlotSource corresponds to a producer
// slot. Both mProducerSlotSource and mProducerBuffers are indexed by a
// "producer slot"; see the mapSlot*() functions.
uint32_t mProducerSlotSource;
uint64_t mProducerSlotSource;
sp<GraphicBuffer> mProducerBuffers[BufferQueue::NUM_BUFFER_SLOTS];
// The QueueBufferOutput with the latest info from the sink, and with the