2024-02-01 15:37:17 +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_EFFECT_
|
|
|
|
#define _H_D12_EFFECT_
|
|
|
|
|
2024-02-27 22:40:35 +00:00
|
|
|
#include "d12.h"
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <d3d12.h>
|
|
|
|
|
|
|
|
typedef struct D12Effect D12Effect;
|
|
|
|
|
2024-02-27 22:40:35 +00:00
|
|
|
typedef enum D12EffectStatus
|
|
|
|
{
|
|
|
|
D12_EFFECT_STATUS_OK,
|
|
|
|
D12_EFFECT_STATUS_ERROR,
|
|
|
|
D12_EFFECT_STATUS_BYPASS
|
|
|
|
}
|
|
|
|
D12EffectStatus;
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
struct D12Effect
|
|
|
|
{
|
|
|
|
const char * name;
|
|
|
|
|
2024-02-27 22:40:35 +00:00
|
|
|
bool enabled;
|
|
|
|
|
2024-02-28 05:05:56 +00:00
|
|
|
void (*initOptions)(void);
|
|
|
|
|
|
|
|
D12EffectStatus (*create)(D12Effect ** instance, ID3D12Device3 * device,
|
2024-02-28 00:59:58 +00:00
|
|
|
const DISPLAYCONFIG_PATH_INFO * displayPathInfo);
|
2024-02-01 15:37:17 +00:00
|
|
|
|
|
|
|
void (*free)(D12Effect ** instance);
|
|
|
|
|
|
|
|
// set the input format, and get the output format of the effect
|
2024-02-27 22:40:35 +00:00
|
|
|
D12EffectStatus (*setFormat)(D12Effect * effect,
|
2024-02-01 15:37:17 +00:00
|
|
|
ID3D12Device3 * device,
|
2024-02-27 22:40:35 +00:00
|
|
|
const D12FrameFormat * src,
|
|
|
|
D12FrameFormat * dst);
|
2024-02-01 15:37:17 +00:00
|
|
|
|
2024-02-28 09:21:47 +00:00
|
|
|
void (*adjustDamage)(D12Effect * effect,
|
|
|
|
RECT dirtyRects[],
|
|
|
|
unsigned * nbDirtyRects);
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
ID3D12Resource * (*run)(D12Effect * effect,
|
2024-02-23 22:04:59 +00:00
|
|
|
ID3D12Device3 * device,
|
|
|
|
ID3D12GraphicsCommandList * commandList,
|
|
|
|
ID3D12Resource * src,
|
|
|
|
RECT dirtyRects[],
|
|
|
|
unsigned * nbDirtyRects);
|
2024-02-01 15:37:17 +00:00
|
|
|
};
|
|
|
|
|
2024-02-28 05:05:56 +00:00
|
|
|
static inline void d12_effectInitOptions(const D12Effect * effect)
|
|
|
|
{ if (effect->initOptions) effect->initOptions(); }
|
|
|
|
|
|
|
|
static inline D12EffectStatus d12_effectCreate(const D12Effect * effect,
|
2024-02-28 00:59:58 +00:00
|
|
|
D12Effect ** instance, ID3D12Device3 * device,
|
|
|
|
const DISPLAYCONFIG_PATH_INFO * displayPathInfo)
|
2024-02-01 15:37:17 +00:00
|
|
|
{
|
2024-02-28 05:05:56 +00:00
|
|
|
*instance = NULL;
|
|
|
|
D12EffectStatus status = effect->create(instance, device, displayPathInfo);
|
|
|
|
if (status == D12_EFFECT_STATUS_OK)
|
|
|
|
memcpy(*instance, effect, sizeof(*effect));
|
|
|
|
return status;
|
2024-02-01 15:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void d12_effectFree(D12Effect ** instance)
|
2024-02-04 18:17:55 +00:00
|
|
|
{
|
|
|
|
if (*instance)
|
|
|
|
(*instance)->free(instance);
|
|
|
|
*instance = NULL;
|
|
|
|
}
|
2024-02-01 15:37:17 +00:00
|
|
|
|
2024-02-27 22:40:35 +00:00
|
|
|
static inline D12EffectStatus d12_effectSetFormat(D12Effect * effect,
|
|
|
|
ID3D12Device3 * device,
|
|
|
|
const D12FrameFormat * src,
|
|
|
|
D12FrameFormat * dst)
|
2024-02-01 15:37:17 +00:00
|
|
|
{ return effect->setFormat(effect, device, src, dst); }
|
|
|
|
|
2024-02-28 09:21:47 +00:00
|
|
|
static inline void d12_effectAdjustDamage(D12Effect * effect,
|
|
|
|
RECT dirtyRects[],
|
|
|
|
unsigned * nbDirtyRects)
|
|
|
|
{ if (effect->adjustDamage)
|
|
|
|
effect->adjustDamage(effect, dirtyRects, nbDirtyRects); }
|
|
|
|
|
2024-02-01 15:37:17 +00:00
|
|
|
static inline ID3D12Resource * d12_effectRun(D12Effect * effect,
|
2024-02-23 22:04:59 +00:00
|
|
|
ID3D12Device3 * device,
|
|
|
|
ID3D12GraphicsCommandList * commandList,
|
|
|
|
ID3D12Resource * src,
|
|
|
|
RECT dirtyRects[],
|
|
|
|
unsigned * nbDirtyRects)
|
|
|
|
{ return effect->run(effect, device, commandList, src,
|
|
|
|
dirtyRects, nbDirtyRects); }
|
2024-02-01 15:37:17 +00:00
|
|
|
|
|
|
|
#endif
|