mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-21 21:17:19 +00:00
[host] d12: pass frame information in a description structure
This commit is contained in:
parent
c7f1aadb9e
commit
5c4540ed8b
@ -29,6 +29,8 @@
|
||||
|
||||
typedef struct D12Backend D12Backend;
|
||||
|
||||
typedef struct D12FetchDesc D12FetchDesc;
|
||||
|
||||
struct D12Backend
|
||||
{
|
||||
// friendly name
|
||||
@ -58,12 +60,15 @@ struct D12Backend
|
||||
CaptureResult (*sync)(D12Backend * instance,
|
||||
ID3D12CommandQueue * commandQueue);
|
||||
|
||||
ID3D12Resource * (*fetch)(
|
||||
D12Backend * instance,
|
||||
unsigned frameBufferIndex,
|
||||
RECT ** dirtyRects,
|
||||
unsigned * nbDirtyRects,
|
||||
CaptureRotation * rotation);
|
||||
ID3D12Resource * (*fetch)(D12Backend * instance, unsigned frameBufferIndex,
|
||||
D12FetchDesc * meta);
|
||||
};
|
||||
|
||||
struct D12FetchDesc
|
||||
{
|
||||
CaptureRotation rotation;
|
||||
RECT * dirtyRects;
|
||||
unsigned nbDirtyRects;
|
||||
};
|
||||
|
||||
static inline bool d12_backendCreate(const D12Backend * backend,
|
||||
@ -98,10 +103,8 @@ static inline CaptureResult d12_backendSync(D12Backend * instance,
|
||||
{ return instance->sync(instance, commandQueue); }
|
||||
|
||||
static inline ID3D12Resource * d12_backendFetch(D12Backend * instance,
|
||||
unsigned frameBufferIndex, RECT ** dirtyRects, unsigned * nbDirtyRects,
|
||||
CaptureRotation * rotation)
|
||||
{ return instance->fetch(instance, frameBufferIndex, dirtyRects,
|
||||
nbDirtyRects, rotation); }
|
||||
unsigned frameBufferIndex, D12FetchDesc * desc)
|
||||
{ return instance->fetch(instance, frameBufferIndex, desc); }
|
||||
|
||||
// Backend defines
|
||||
|
||||
|
@ -441,17 +441,16 @@ static CaptureResult d12_dd_sync(D12Backend * instance,
|
||||
}
|
||||
|
||||
static ID3D12Resource * d12_dd_fetch(D12Backend * instance,
|
||||
unsigned frameBufferIndex, RECT * dirtyRects[static D12_MAX_DIRTY_RECTS],
|
||||
unsigned * nbDirtyRects, CaptureRotation * rotation)
|
||||
unsigned frameBufferIndex, D12FetchDesc * desc)
|
||||
{
|
||||
DDInstance * this = UPCAST(DDInstance, instance);
|
||||
|
||||
if (!this->current)
|
||||
return NULL;
|
||||
|
||||
*dirtyRects = this->current->dirtyRects;
|
||||
*nbDirtyRects = this->current->nbDirtyRects;
|
||||
*rotation = this->rotation;
|
||||
desc->dirtyRects = this->current->dirtyRects;
|
||||
desc->nbDirtyRects = this->current->nbDirtyRects;
|
||||
desc->rotation = this->rotation;
|
||||
|
||||
ID3D12Resource_AddRef(*this->current->d12Res);
|
||||
return *this->current->d12Res;
|
||||
|
@ -428,13 +428,10 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
||||
CaptureResult result = CAPTURE_RESULT_ERROR;
|
||||
comRef_scopePush(1);
|
||||
|
||||
RECT * dirtyRects;
|
||||
unsigned nbDirtyRects;
|
||||
CaptureRotation rotation;
|
||||
D12FetchDesc desc;
|
||||
|
||||
comRef_defineLocal(ID3D12Resource, src);
|
||||
*src = d12_backendFetch(this->backend, frameBufferIndex,
|
||||
&dirtyRects, &nbDirtyRects, &rotation);
|
||||
*src = d12_backendFetch(this->backend, frameBufferIndex, &desc);
|
||||
if (!*src)
|
||||
{
|
||||
DEBUG_ERROR("D12 backend failed to produce an expected frame: %u",
|
||||
@ -504,13 +501,14 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
||||
CAPTURE_FMT_BGR_32 : CAPTURE_FMT_BGRA;
|
||||
frame->hdr = false;
|
||||
frame->hdrPQ = false;
|
||||
frame->rotation = rotation;
|
||||
frame->rotation = desc.rotation;
|
||||
|
||||
{
|
||||
// create a clean list of rects
|
||||
FrameDamageRect allRects[nbDirtyRects];
|
||||
FrameDamageRect allRects[desc.nbDirtyRects];
|
||||
unsigned count = 0;
|
||||
for(const RECT * rect = dirtyRects; rect < dirtyRects + nbDirtyRects; ++rect)
|
||||
for(const RECT * rect = desc.dirtyRects;
|
||||
rect < desc.dirtyRects + desc.nbDirtyRects; ++rect)
|
||||
allRects[count++] = (FrameDamageRect){
|
||||
.x = rect->left,
|
||||
.y = rect->top,
|
||||
@ -544,13 +542,10 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
CaptureResult result = CAPTURE_RESULT_ERROR;
|
||||
comRef_scopePush(3);
|
||||
|
||||
RECT * dirtyRects;
|
||||
unsigned nbDirtyRects;
|
||||
CaptureRotation rotation;
|
||||
D12FetchDesc desc;
|
||||
|
||||
comRef_defineLocal(ID3D12Resource, src);
|
||||
*src = d12_backendFetch(this->backend, frameBufferIndex,
|
||||
&dirtyRects, &nbDirtyRects, &rotation);
|
||||
*src = d12_backendFetch(this->backend, frameBufferIndex, &desc);
|
||||
if (!*src)
|
||||
{
|
||||
DEBUG_ERROR("D12 backend failed to produce an expected frame: %u",
|
||||
@ -575,7 +570,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
{
|
||||
next = d12_effectRun(
|
||||
this->effectRGB24, *this->device, *this->computeCommand.gfxList, next,
|
||||
dirtyRects, &nbDirtyRects);
|
||||
desc.dirtyRects, &desc.nbDirtyRects);
|
||||
}
|
||||
|
||||
// copy into the framebuffer resource
|
||||
@ -605,7 +600,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
};
|
||||
|
||||
// if full frame damage
|
||||
if (nbDirtyRects == 0)
|
||||
if (desc.nbDirtyRects == 0)
|
||||
{
|
||||
this->nbDirtyRects = 0;
|
||||
ID3D12GraphicsCommandList_CopyTextureRegion(
|
||||
@ -622,7 +617,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
}
|
||||
else
|
||||
{
|
||||
FrameDamageRect allRects[this->nbDirtyRects + nbDirtyRects];
|
||||
FrameDamageRect allRects[this->nbDirtyRects + desc.nbDirtyRects];
|
||||
unsigned count = 0;
|
||||
|
||||
/* we must update the rects that were dirty in the prior frame also,
|
||||
@ -638,8 +633,8 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
};
|
||||
|
||||
/* add the new dirtyRects to the array */
|
||||
for(const RECT * rect = dirtyRects;
|
||||
rect < dirtyRects + nbDirtyRects; ++rect)
|
||||
for(const RECT * rect = desc.dirtyRects;
|
||||
rect < desc.dirtyRects + desc.nbDirtyRects; ++rect)
|
||||
allRects[count++] = (FrameDamageRect){
|
||||
.x = rect->left,
|
||||
.y = rect->top,
|
||||
@ -670,9 +665,9 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
||||
}
|
||||
|
||||
/* store the dirty rects for the next frame */
|
||||
memcpy(this->dirtyRects, dirtyRects,
|
||||
nbDirtyRects * sizeof(*this->dirtyRects));
|
||||
this->nbDirtyRects = nbDirtyRects;
|
||||
memcpy(this->dirtyRects, desc.dirtyRects,
|
||||
desc.nbDirtyRects * sizeof(*this->dirtyRects));
|
||||
this->nbDirtyRects = desc.nbDirtyRects;
|
||||
}
|
||||
|
||||
// execute the compute commands
|
||||
|
Loading…
Reference in New Issue
Block a user