2024-01-29 10:47:02 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
|
|
|
* Copyright © 2017-2024 The Looking Glass Authors
|
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _H_D12_BACKEND_
|
|
|
|
#define _H_D12_BACKEND_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <d3d12.h>
|
|
|
|
#include "interface/capture.h"
|
|
|
|
|
2024-01-30 22:43:01 +00:00
|
|
|
typedef struct D12Backend D12Backend;
|
|
|
|
|
|
|
|
struct D12Backend
|
2024-01-29 10:47:02 +00:00
|
|
|
{
|
|
|
|
// friendly name
|
|
|
|
const char * name;
|
|
|
|
|
|
|
|
// internal name
|
|
|
|
const char * codeName;
|
|
|
|
|
|
|
|
// creation/init/free
|
2024-01-30 22:43:01 +00:00
|
|
|
bool (*create)(D12Backend ** instance, unsigned frameBuffers);
|
2024-01-29 10:47:02 +00:00
|
|
|
bool (*init)(
|
2024-01-30 22:43:01 +00:00
|
|
|
D12Backend * instance,
|
2024-01-29 10:47:02 +00:00
|
|
|
bool debug,
|
|
|
|
ID3D12Device3 * device,
|
|
|
|
IDXGIAdapter1 * adapter,
|
|
|
|
IDXGIOutput * output);
|
2024-01-30 22:43:01 +00:00
|
|
|
bool (*deinit)(D12Backend * instance);
|
|
|
|
void (*free)(D12Backend ** instance);
|
2024-01-29 10:47:02 +00:00
|
|
|
|
|
|
|
// capture callbacks
|
2024-01-30 22:43:01 +00:00
|
|
|
CaptureResult (*capture)(D12Backend * instance,
|
|
|
|
unsigned frameBufferIndex);
|
|
|
|
|
|
|
|
CaptureResult (*sync)(D12Backend * instance,
|
|
|
|
ID3D12CommandQueue * commandQueue);
|
|
|
|
|
|
|
|
ID3D12Resource * (*fetch)(D12Backend * instance,
|
|
|
|
unsigned frameBufferIndex);
|
|
|
|
};
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
static inline bool d12_backendCreate(const D12Backend * backend,
|
|
|
|
D12Backend ** instance, unsigned frameBuffers)
|
2024-01-30 22:43:01 +00:00
|
|
|
{
|
|
|
|
if (!backend->create(instance, frameBuffers))
|
|
|
|
return false;
|
|
|
|
memcpy(*instance, backend, sizeof(*backend));
|
|
|
|
return true;
|
2024-01-29 10:47:02 +00:00
|
|
|
}
|
|
|
|
|
2024-01-30 23:18:56 +00:00
|
|
|
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); }
|
|
|
|
|
|
|
|
// Backend defines
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
extern const D12Backend D12Backend_DD;
|
2024-01-29 10:47:02 +00:00
|
|
|
|
|
|
|
#endif
|