[host] d12: fix damage tracking with RGB24 enabled

This commit is contained in:
Geoffrey McRae 2024-02-24 09:04:59 +11:00
parent 2f3ca443cf
commit 4408359597
5 changed files with 32 additions and 16 deletions

View File

@ -58,9 +58,10 @@ struct D12Backend
CaptureResult (*sync)(D12Backend * instance, CaptureResult (*sync)(D12Backend * instance,
ID3D12CommandQueue * commandQueue); ID3D12CommandQueue * commandQueue);
ID3D12Resource * (*fetch)(D12Backend * instance, ID3D12Resource * (*fetch)(
D12Backend * instance,
unsigned frameBufferIndex, unsigned frameBufferIndex,
const RECT ** dirtyRects, RECT ** dirtyRects,
unsigned * nbDirtyRects); unsigned * nbDirtyRects);
}; };
@ -96,8 +97,7 @@ 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, const RECT ** dirtyRects, unsigned frameBufferIndex, RECT ** dirtyRects, unsigned * nbDirtyRects)
unsigned * nbDirtyRects)
{ return instance->fetch(instance, frameBufferIndex, dirtyRects, { return instance->fetch(instance, frameBufferIndex, dirtyRects,
nbDirtyRects); } nbDirtyRects); }

View File

@ -419,7 +419,7 @@ static CaptureResult d12_dd_sync(D12Backend * instance,
} }
static ID3D12Resource * d12_dd_fetch(D12Backend * instance, static ID3D12Resource * d12_dd_fetch(D12Backend * instance,
unsigned frameBufferIndex, const RECT * dirtyRects[static D12_MAX_DIRTY_RECTS], unsigned frameBufferIndex, RECT * dirtyRects[static D12_MAX_DIRTY_RECTS],
unsigned * nbDirtyRects) unsigned * nbDirtyRects)
{ {
DDInstance * this = UPCAST(DDInstance, instance); DDInstance * this = UPCAST(DDInstance, instance);

View File

@ -428,7 +428,7 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
CaptureResult result = CAPTURE_RESULT_ERROR; CaptureResult result = CAPTURE_RESULT_ERROR;
comRef_scopePush(1); comRef_scopePush(1);
const RECT * dirtyRects; RECT * dirtyRects;
unsigned nbDirtyRects; unsigned nbDirtyRects;
comRef_defineLocal(ID3D12Resource, src); comRef_defineLocal(ID3D12Resource, src);
@ -543,7 +543,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
CaptureResult result = CAPTURE_RESULT_ERROR; CaptureResult result = CAPTURE_RESULT_ERROR;
comRef_scopePush(3); comRef_scopePush(3);
const RECT * dirtyRects; RECT * dirtyRects;
unsigned nbDirtyRects; unsigned nbDirtyRects;
comRef_defineLocal(ID3D12Resource, src); comRef_defineLocal(ID3D12Resource, src);
@ -572,7 +572,8 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
if (this->allowRGB24) if (this->allowRGB24)
{ {
next = d12_effectRun( next = d12_effectRun(
this->effectRGB24, *this->device, *this->computeCommand.gfxList, next); this->effectRGB24, *this->device, *this->computeCommand.gfxList, next,
dirtyRects, &nbDirtyRects);
} }
// copy into the framebuffer resource // copy into the framebuffer resource

View File

@ -41,8 +41,11 @@ struct D12Effect
D3D12_RESOURCE_DESC * dst); D3D12_RESOURCE_DESC * dst);
ID3D12Resource * (*run)(D12Effect * effect, ID3D12Resource * (*run)(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList, ID3D12Device3 * device,
ID3D12Resource * src); ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects);
}; };
static inline bool d12_effectCreate(const D12Effect * effect, static inline bool d12_effectCreate(const D12Effect * effect,
@ -68,9 +71,13 @@ static inline bool d12_effectSetFormat(D12Effect * effect,
{ return effect->setFormat(effect, device, src, dst); } { return effect->setFormat(effect, device, src, dst); }
static inline ID3D12Resource * d12_effectRun(D12Effect * effect, static inline ID3D12Resource * d12_effectRun(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList, ID3D12Device3 * device,
ID3D12Resource * src) ID3D12GraphicsCommandList * commandList,
{ return effect->run(effect, device, commandList, src); } ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects)
{ return effect->run(effect, device, commandList, src,
dirtyRects, nbDirtyRects); }
// effect defines // effect defines

View File

@ -278,7 +278,7 @@ exit:
static ID3D12Resource * d12_effect_rgb24Run(D12Effect * effect, static ID3D12Resource * d12_effect_rgb24Run(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList, ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src) ID3D12Resource * src, RECT dirtyRects[], unsigned * nbDirtyRects)
{ {
TestInstance * this = UPCAST(TestInstance, effect); TestInstance * this = UPCAST(TestInstance, effect);
@ -365,6 +365,14 @@ static ID3D12Resource * d12_effect_rgb24Run(D12Effect * effect,
ID3D12GraphicsCommandList_ResourceBarrier(commandList, 1, &barrier); ID3D12GraphicsCommandList_ResourceBarrier(commandList, 1, &barrier);
} }
// adjust the dirty rects
for(RECT * rect = dirtyRects; rect < dirtyRects + *nbDirtyRects; ++rect)
{
unsigned width = rect->right - rect->left;
rect->left = (rect->left * 3) / 4;
rect->right = rect->left + (width * 3 + 3) / 4;
}
// return the output buffer // return the output buffer
return *this->dst; return *this->dst;
} }