mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[host] d12: add wrappers for backend functions
This commit is contained in:
parent
c07b72883a
commit
be82b7e578
@ -57,9 +57,7 @@ struct D12Backend
|
|||||||
unsigned frameBufferIndex);
|
unsigned frameBufferIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
// helpers for the interface
|
static inline bool d12_backendCreate(
|
||||||
|
|
||||||
static inline bool d12_createBackend(
|
|
||||||
D12Backend * backend, D12Backend ** instance, unsigned frameBuffers)
|
D12Backend * backend, D12Backend ** instance, unsigned frameBuffers)
|
||||||
{
|
{
|
||||||
if (!backend->create(instance, frameBuffers))
|
if (!backend->create(instance, frameBuffers))
|
||||||
@ -68,10 +66,35 @@ static inline bool d12_createBackend(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// apis for the backend
|
static inline bool d12_backendInit(D12Backend * instance, bool debug,
|
||||||
|
ID3D12Device3 * device, IDXGIAdapter1 * adapter, IDXGIOutput * output)
|
||||||
|
{ return instance->init(instance, debug, device, adapter, output); }
|
||||||
|
|
||||||
|
static inline bool d12_backendDeinit(D12Backend * instance)
|
||||||
|
{ return instance->deinit(instance); }
|
||||||
|
|
||||||
|
static inline void d12_backendFree(D12Backend ** instance)
|
||||||
|
{ (*instance)->free(instance); }
|
||||||
|
|
||||||
|
static inline CaptureResult d12_backendCapture(D12Backend * instance,
|
||||||
|
unsigned frameBufferIndex)
|
||||||
|
{ return instance->capture(instance, frameBufferIndex); }
|
||||||
|
|
||||||
|
static inline CaptureResult d12_backendSync(D12Backend * instance,
|
||||||
|
ID3D12CommandQueue * commandQueue)
|
||||||
|
{ return instance->sync(instance, commandQueue); }
|
||||||
|
|
||||||
|
static inline ID3D12Resource * d12_backendFetch(D12Backend * instance,
|
||||||
|
unsigned frameBufferIndex)
|
||||||
|
{ return instance->fetch(instance, frameBufferIndex); }
|
||||||
|
|
||||||
|
// APIs for the backend to call
|
||||||
|
|
||||||
void d12_updatePointer(
|
void d12_updatePointer(
|
||||||
CapturePointer * pointer, void * shape, size_t shapeSize);
|
CapturePointer * pointer, void * shape, size_t shapeSize);
|
||||||
|
|
||||||
|
// Backend defines
|
||||||
|
|
||||||
extern D12Backend D12Backend_DD;
|
extern D12Backend D12Backend_DD;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -166,7 +166,7 @@ static bool d12_create(
|
|||||||
this->getPointerBufferFn = getPointerBufferFn;
|
this->getPointerBufferFn = getPointerBufferFn;
|
||||||
this->postPointerBufferFn = postPointerBufferFn;
|
this->postPointerBufferFn = postPointerBufferFn;
|
||||||
|
|
||||||
if (!d12_createBackend(&D12Backend_DD, &this->backend, frameBuffers))
|
if (!d12_backendCreate(&D12Backend_DD, &this->backend, frameBuffers))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("backend \"%s\" failed to create", this->backend->codeName);
|
DEBUG_ERROR("backend \"%s\" failed to create", this->backend->codeName);
|
||||||
CloseHandle(this->d3d12);
|
CloseHandle(this->d3d12);
|
||||||
@ -278,8 +278,7 @@ retryCreateCommandQueue:
|
|||||||
*alignSize = heapDesc.Alignment;
|
*alignSize = heapDesc.Alignment;
|
||||||
|
|
||||||
// initialize the backend
|
// initialize the backend
|
||||||
if (!this->backend->init(this->backend,
|
if (!d12_backendInit(this->backend, this->debug, *device, *adapter, *output))
|
||||||
this->debug, *device, *adapter, *output))
|
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
comRef_toGlobal(this->factory , factory );
|
comRef_toGlobal(this->factory , factory );
|
||||||
@ -314,7 +313,7 @@ static bool d12_deinit(void)
|
|||||||
|
|
||||||
static void d12_free(void)
|
static void d12_free(void)
|
||||||
{
|
{
|
||||||
this->backend->free(&this->backend);
|
d12_backendFree(&this->backend);
|
||||||
FreeLibrary(this->d3d12);
|
FreeLibrary(this->d3d12);
|
||||||
free(this);
|
free(this);
|
||||||
this = NULL;
|
this = NULL;
|
||||||
@ -323,7 +322,7 @@ static void d12_free(void)
|
|||||||
static CaptureResult d12_capture(
|
static CaptureResult d12_capture(
|
||||||
unsigned frameBufferIndex, FrameBuffer * frameBuffer)
|
unsigned frameBufferIndex, FrameBuffer * frameBuffer)
|
||||||
{
|
{
|
||||||
return this->backend->capture(this->backend, frameBufferIndex);
|
return d12_backendCapture(this->backend, frameBufferIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
||||||
@ -333,7 +332,7 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
|||||||
comRef_scopePush(1);
|
comRef_scopePush(1);
|
||||||
|
|
||||||
comRef_defineLocal(ID3D12Resource, src);
|
comRef_defineLocal(ID3D12Resource, src);
|
||||||
*src = this->backend->fetch(this->backend, frameBufferIndex);
|
*src = d12_backendFetch(this->backend, frameBufferIndex);
|
||||||
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",
|
||||||
@ -383,7 +382,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
|||||||
comRef_scopePush(2);
|
comRef_scopePush(2);
|
||||||
|
|
||||||
comRef_defineLocal(ID3D12Resource, src);
|
comRef_defineLocal(ID3D12Resource, src);
|
||||||
*src = this->backend->fetch(this->backend, frameBufferIndex);
|
*src = d12_backendFetch(this->backend, frameBufferIndex);
|
||||||
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",
|
||||||
@ -427,7 +426,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
|||||||
*this->copyCommand.gfxList, &dstLoc, 0, 0, 0, &srcLoc, NULL);
|
*this->copyCommand.gfxList, &dstLoc, 0, 0, 0, &srcLoc, NULL);
|
||||||
|
|
||||||
// allow the backend to insert a fence into the command queue if it needs it
|
// allow the backend to insert a fence into the command queue if it needs it
|
||||||
result = this->backend->sync(this->backend, *this->commandQueue);
|
result = d12_backendSync(this->backend, *this->commandQueue);
|
||||||
if (result != CAPTURE_RESULT_OK)
|
if (result != CAPTURE_RESULT_OK)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user