Skip to content

Commit

Permalink
[host] d12: fix damage tracking with RGB24 enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Feb 23, 2024
1 parent 2f3ca44 commit 4408359
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
12 changes: 6 additions & 6 deletions host/platform/Windows/capture/D12/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ struct D12Backend
CaptureResult (*sync)(D12Backend * instance,
ID3D12CommandQueue * commandQueue);

ID3D12Resource * (*fetch)(D12Backend * instance,
unsigned frameBufferIndex,
const RECT ** dirtyRects,
unsigned * nbDirtyRects);
ID3D12Resource * (*fetch)(
D12Backend * instance,
unsigned frameBufferIndex,
RECT ** dirtyRects,
unsigned * nbDirtyRects);
};

static inline bool d12_backendCreate(const D12Backend * backend,
Expand Down Expand Up @@ -96,8 +97,7 @@ static inline CaptureResult d12_backendSync(D12Backend * instance,
{ return instance->sync(instance, commandQueue); }

static inline ID3D12Resource * d12_backendFetch(D12Backend * instance,
unsigned frameBufferIndex, const RECT ** dirtyRects,
unsigned * nbDirtyRects)
unsigned frameBufferIndex, RECT ** dirtyRects, unsigned * nbDirtyRects)
{ return instance->fetch(instance, frameBufferIndex, dirtyRects,
nbDirtyRects); }

Expand Down
2 changes: 1 addition & 1 deletion host/platform/Windows/capture/D12/backend/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static CaptureResult d12_dd_sync(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)
{
DDInstance * this = UPCAST(DDInstance, instance);
Expand Down
7 changes: 4 additions & 3 deletions host/platform/Windows/capture/D12/d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
CaptureResult result = CAPTURE_RESULT_ERROR;
comRef_scopePush(1);

const RECT * dirtyRects;
RECT * dirtyRects;
unsigned nbDirtyRects;

comRef_defineLocal(ID3D12Resource, src);
Expand Down Expand Up @@ -543,7 +543,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
CaptureResult result = CAPTURE_RESULT_ERROR;
comRef_scopePush(3);

const RECT * dirtyRects;
RECT * dirtyRects;
unsigned nbDirtyRects;

comRef_defineLocal(ID3D12Resource, src);
Expand Down Expand Up @@ -572,7 +572,8 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
if (this->allowRGB24)
{
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
Expand Down
17 changes: 12 additions & 5 deletions host/platform/Windows/capture/D12/effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ struct D12Effect
D3D12_RESOURCE_DESC * dst);

ID3D12Resource * (*run)(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src);
ID3D12Device3 * device,
ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects);
};

static inline bool d12_effectCreate(const D12Effect * effect,
Expand All @@ -68,9 +71,13 @@ static inline bool d12_effectSetFormat(D12Effect * effect,
{ return effect->setFormat(effect, device, src, dst); }

static inline ID3D12Resource * d12_effectRun(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src)
{ return effect->run(effect, device, commandList, src); }
ID3D12Device3 * device,
ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects)
{ return effect->run(effect, device, commandList, src,
dirtyRects, nbDirtyRects); }

// effect defines

Expand Down
10 changes: 9 additions & 1 deletion host/platform/Windows/capture/D12/effect/rgb24.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static bool d12_effect_rgb24SetFormat(D12Effect * effect,

static ID3D12Resource * d12_effect_rgb24Run(D12Effect * effect,
ID3D12Device3 * device, ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src)
ID3D12Resource * src, RECT dirtyRects[], unsigned * nbDirtyRects)
{
TestInstance * this = UPCAST(TestInstance, effect);

Expand Down Expand Up @@ -365,6 +365,14 @@ static ID3D12Resource * d12_effect_rgb24Run(D12Effect * effect,
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 *this->dst;
}
Expand Down

0 comments on commit 4408359

Please sign in to comment.