From eb2796d40b4ff720e9d9a1ba62643c5d2f57357b Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 7 Nov 2023 18:33:31 +1100 Subject: [PATCH] [host] dxgi: move the backend interface into a separate header --- .../Windows/capture/DXGI/src/backend.h | 60 +++++++++++++++++++ .../platform/Windows/capture/DXGI/src/d3d11.c | 2 +- .../platform/Windows/capture/DXGI/src/d3d12.c | 2 +- .../Windows/capture/DXGI/src/dxgi_capture.h | 21 ++----- host/platform/Windows/capture/DXGI/src/pp.h | 5 ++ 5 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 host/platform/Windows/capture/DXGI/src/backend.h diff --git a/host/platform/Windows/capture/DXGI/src/backend.h b/host/platform/Windows/capture/DXGI/src/backend.h new file mode 100644 index 00000000..999ffefe --- /dev/null +++ b/host/platform/Windows/capture/DXGI/src/backend.h @@ -0,0 +1,60 @@ +/** + * Looking Glass + * Copyright © 2017-2023 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_DXGI_BACKEND_ +#define _H_DXGI_BACKEND_ + +#include "dxgi_capture.h" + +struct DXGIInterface; +struct Texture; + +struct DXGICopyBackend +{ + // friendly name + const char * name; + + // internal code name + const char * code; + + // create the copy backend + bool (*create)(struct DXGIInterface * intf); + + // configure the copy backend with the specified format + bool (*configure)(unsigned width, unsigned height, + DXGI_FORMAT format, unsigned * pitch); + + // free the copy backend + void (*free)(void); + + // called each captured frame after post processing to copy the frame + bool (*copyFrame)(struct Texture * tex, ID3D11Texture2D * src); + + // maps the copied frame into memory + CaptureResult (*mapTexture)(struct Texture * tex); + + // unmaps the copied frame from memory + void (*unmapTexture)(struct Texture * tex); + + // called just before the frame is released by the frontend + void (*preRelease)(void); +}; + +#endif diff --git a/host/platform/Windows/capture/DXGI/src/d3d11.c b/host/platform/Windows/capture/DXGI/src/d3d11.c index a343606b..45200e71 100644 --- a/host/platform/Windows/capture/DXGI/src/d3d11.c +++ b/host/platform/Windows/capture/DXGI/src/d3d11.c @@ -18,7 +18,7 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "dxgi_capture.h" +#include "backend.h" #include "com_ref.h" #include diff --git a/host/platform/Windows/capture/DXGI/src/d3d12.c b/host/platform/Windows/capture/DXGI/src/d3d12.c index 02ebad93..d485f712 100644 --- a/host/platform/Windows/capture/DXGI/src/d3d12.c +++ b/host/platform/Windows/capture/DXGI/src/d3d12.c @@ -18,7 +18,7 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "dxgi_capture.h" +#include "backend.h" #include "com_ref.h" #include diff --git a/host/platform/Windows/capture/DXGI/src/dxgi_capture.h b/host/platform/Windows/capture/DXGI/src/dxgi_capture.h index 35ece498..6811cdf3 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi_capture.h +++ b/host/platform/Windows/capture/DXGI/src/dxgi_capture.h @@ -18,6 +18,9 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _H_DXGI_CAPTURE_ +#define _H_DXGI_CAPTURE_ + #include "pp.h" #include @@ -33,6 +36,8 @@ #include "common/vector.h" #include "interface/capture.h" +#include "backend.h" + enum TextureState { TEXTURE_STATE_UNUSED, @@ -64,8 +69,6 @@ struct FrameDamage FrameDamageRect rects[KVMFR_MAX_DAMAGE_RECTS]; }; -struct DXGICopyBackend; - struct DXGIInterface { bool initialized; @@ -119,16 +122,4 @@ struct DXGIInterface struct FrameDamage frameDamage[LGMP_Q_FRAME_LEN]; }; -struct DXGICopyBackend -{ - const char * name; - const char * code; - bool (*create)(struct DXGIInterface * intf); - bool (*configure)(unsigned width, unsigned height, - DXGI_FORMAT format, unsigned * pitch); - void (*free)(void); - bool (*copyFrame)(Texture * tex, ID3D11Texture2D * src); - CaptureResult (*mapTexture)(Texture * tex); - void (*unmapTexture)(Texture * tex); - void (*preRelease)(void); -}; +#endif diff --git a/host/platform/Windows/capture/DXGI/src/pp.h b/host/platform/Windows/capture/DXGI/src/pp.h index 71ac36b4..788210eb 100644 --- a/host/platform/Windows/capture/DXGI/src/pp.h +++ b/host/platform/Windows/capture/DXGI/src/pp.h @@ -18,6 +18,9 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _H_DXGI_PP_ +#define _H_DXGI_PP_ + #include #include @@ -58,3 +61,5 @@ typedef struct void (*finish)(void); } DXGIPostProcess; + +#endif