mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-24 05:42:40 +02:00
Add bqCancelBuffer and use it in gfx.c
This commit is contained in:
parent
c8ebe8a3b5
commit
651dd72ac1
@ -79,6 +79,7 @@ Result bqRequestBuffer(Binder *b, s32 bufferIdx, BqGraphicBuffer *buf);
|
|||||||
Result bqDequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, NvMultiFence *fence);
|
Result bqDequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, NvMultiFence *fence);
|
||||||
Result bqDetachBuffer(Binder *b, s32 slot);
|
Result bqDetachBuffer(Binder *b, s32 slot);
|
||||||
Result bqQueueBuffer(Binder *b, s32 buf, BqQueueBufferInput *input, BqQueueBufferOutput *output);
|
Result bqQueueBuffer(Binder *b, s32 buf, BqQueueBufferInput *input, BqQueueBufferOutput *output);
|
||||||
|
Result bqCancelBuffer(Binder *b, s32 buf, NvMultiFence *fence);
|
||||||
Result bqQuery(Binder *b, s32 what, s32* value);
|
Result bqQuery(Binder *b, s32 what, s32* value);
|
||||||
Result bqConnect(Binder *b, s32 api, bool producerControlledByApp, BqQueueBufferOutput *output);
|
Result bqConnect(Binder *b, s32 api, bool producerControlledByApp, BqQueueBufferOutput *output);
|
||||||
Result bqDisconnect(Binder *b, s32 api);
|
Result bqDisconnect(Binder *b, s32 api);
|
||||||
|
@ -147,6 +147,24 @@ Result bqQueueBuffer(Binder *b, s32 buf, BqQueueBufferInput *input, BqQueueBuffe
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result bqCancelBuffer(Binder *b, s32 buf, NvMultiFence *fence)
|
||||||
|
{
|
||||||
|
Result rc;
|
||||||
|
Parcel parcel, parcel_reply;
|
||||||
|
|
||||||
|
parcelCreate(&parcel);
|
||||||
|
parcelCreate(&parcel_reply);
|
||||||
|
|
||||||
|
parcelWriteInterfaceToken(&parcel, g_bq_InterfaceDescriptor);
|
||||||
|
parcelWriteInt32(&parcel, buf);
|
||||||
|
parcelWriteFlattenedObject(&parcel, fence, sizeof(*fence));
|
||||||
|
|
||||||
|
rc = parcelTransact(b, CANCEL_BUFFER, &parcel, &parcel_reply);
|
||||||
|
// Reply parcel has no content
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result bqQuery(Binder *b, s32 what, s32* value)
|
Result bqQuery(Binder *b, s32 what, s32* value)
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
|
@ -119,8 +119,10 @@ static Result _gfxDequeueBuffer(void) {
|
|||||||
|
|
||||||
if (!(g_gfx_ProducerSlotsRequested & BIT(slot))) {
|
if (!(g_gfx_ProducerSlotsRequested & BIT(slot))) {
|
||||||
rc = bqRequestBuffer(&g_gfxBinderSession, slot, NULL);
|
rc = bqRequestBuffer(&g_gfxBinderSession, slot, NULL);
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc)) {
|
||||||
return rc; // todo: cancelbuffer or something
|
bqCancelBuffer(&g_gfxBinderSession, slot, &fence);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
g_gfx_ProducerSlotsRequested |= BIT(slot);
|
g_gfx_ProducerSlotsRequested |= BIT(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +149,17 @@ static Result _gfxQueueBuffer(void) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _gfxCancelBuffer(void) {
|
||||||
|
Result rc=0;
|
||||||
|
|
||||||
|
if (g_gfxCurrentProducerBuffer >= 0) {
|
||||||
|
rc = bqCancelBuffer(&g_gfxBinderSession, g_gfxCurrentProducerBuffer, &g_gfxQueueBufferData.fence);
|
||||||
|
g_gfxCurrentProducerBuffer = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result gfxInitDefault(void) {
|
Result gfxInitDefault(void) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
@ -237,7 +250,7 @@ Result gfxInitDefault(void) {
|
|||||||
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
if (g_gfx_ProducerConnected) {
|
if (g_gfx_ProducerConnected) {
|
||||||
_gfxQueueBuffer();
|
_gfxCancelBuffer();
|
||||||
for(u32 i=0; i<32; i++) {
|
for(u32 i=0; i<32; i++) {
|
||||||
if (g_gfx_ProducerSlotsRequested & BIT(i)) bqDetachBuffer(&g_gfxBinderSession, i);
|
if (g_gfx_ProducerSlotsRequested & BIT(i)) bqDetachBuffer(&g_gfxBinderSession, i);
|
||||||
}
|
}
|
||||||
@ -281,7 +294,7 @@ void gfxExit(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_gfx_ProducerConnected) {
|
if (g_gfx_ProducerConnected) {
|
||||||
_gfxQueueBuffer();
|
_gfxCancelBuffer();
|
||||||
for(u32 i=0; i<32; i++) {
|
for(u32 i=0; i<32; i++) {
|
||||||
if (g_gfx_ProducerSlotsRequested & BIT(i)) bqDetachBuffer(&g_gfxBinderSession, i);
|
if (g_gfx_ProducerSlotsRequested & BIT(i)) bqDetachBuffer(&g_gfxBinderSession, i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user