LookingGlass/host/platform/Windows/capture/D12/effect.h

102 lines
2.9 KiB
C
Raw Normal View History

/**
* 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_EFFECT_
#define _H_D12_EFFECT_
#include "d12.h"
#include <stdbool.h>
#include <d3d12.h>
typedef struct D12Effect D12Effect;
typedef enum D12EffectStatus
{
D12_EFFECT_STATUS_OK,
D12_EFFECT_STATUS_ERROR,
D12_EFFECT_STATUS_BYPASS
}
D12EffectStatus;
struct D12Effect
{
const char * name;
bool enabled;
bool (*create)(D12Effect ** instance, ID3D12Device3 * device,
const DISPLAYCONFIG_PATH_INFO * displayPathInfo);
void (*free)(D12Effect ** instance);
// set the input format, and get the output format of the effect
D12EffectStatus (*setFormat)(D12Effect * effect,
ID3D12Device3 * device,
const D12FrameFormat * src,
D12FrameFormat * dst);
ID3D12Resource * (*run)(D12Effect * effect,
ID3D12Device3 * device,
ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects);
};
static inline bool d12_effectCreate(const D12Effect * effect,
D12Effect ** instance, ID3D12Device3 * device,
const DISPLAYCONFIG_PATH_INFO * displayPathInfo)
{
if (!effect->create(instance, device, displayPathInfo))
return false;
memcpy(*instance, effect, sizeof(*effect));
return true;
}
static inline void d12_effectFree(D12Effect ** instance)
{
if (*instance)
(*instance)->free(instance);
*instance = NULL;
}
static inline D12EffectStatus d12_effectSetFormat(D12Effect * effect,
ID3D12Device3 * device,
const D12FrameFormat * src,
D12FrameFormat * dst)
{ return effect->setFormat(effect, device, src, dst); }
static inline ID3D12Resource * d12_effectRun(D12Effect * effect,
ID3D12Device3 * device,
ID3D12GraphicsCommandList * commandList,
ID3D12Resource * src,
RECT dirtyRects[],
unsigned * nbDirtyRects)
{ return effect->run(effect, device, commandList, src,
dirtyRects, nbDirtyRects); }
// effect defines
extern const D12Effect D12Effect_RGB24;
extern const D12Effect D12Effect_HDR16to10;
#endif