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