[idd] implemented frame feed from the guest (very hacky)

This is NOT READY for general consumption, if you decide to make
use of this driver, DO NOT ASK FOR SUPPORT.
This commit is contained in:
Geoffrey McRae
2023-04-11 16:55:58 +10:00
parent 3c85957b99
commit 0c3dce3ca6
8 changed files with 315 additions and 33 deletions

View File

@@ -1,30 +1,55 @@
#pragma once
#include "Direct3DDevice.h"
#include "CIndirectDeviceContext.h"
#include <Windows.h>
#include <wrl.h>
#include <IddCx.h>
#include <memory>
using namespace Microsoft::WRL;
#define STAGING_TEXTURES 3
class CSwapChainProcessor
{
private:
CIndirectDeviceContext * m_devContext;
IDDCX_SWAPCHAIN m_hSwapChain;
std::shared_ptr<Direct3DDevice> m_device;
HANDLE m_newFrameEvent;
Microsoft::WRL::Wrappers::HandleT<
Microsoft::WRL::Wrappers::HandleTraits::HANDLENullTraits> m_thread;
Microsoft::WRL::Wrappers::Event m_terminateEvent;
Wrappers::HandleT<Wrappers::HandleTraits::HANDLENullTraits> m_thread[2];
Wrappers::Event m_terminateEvent;
static DWORD CALLBACK RunThread(LPVOID argument);
static DWORD CALLBACK _SwapChainThread(LPVOID arg);
static DWORD CALLBACK _FrameThread(LPVOID arg);
void Run();
void RunCore();
void SwapChainThread();
void SwapChainThreadCore();
void SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer);
void FrameThread();
struct StagingTexture
{
int width;
int height;
DXGI_FORMAT format;
Microsoft::WRL::ComPtr<ID3D11Texture2D> tex;
};
StagingTexture m_cpuTex[STAGING_TEXTURES] = {};
volatile LONG m_copyCount = 0;
volatile LONG m_contextLock = 0;
int m_texRIndex = 0;
int m_texWIndex = 0;
bool SetupStagingTexture(StagingTexture & t, int width, int height, DXGI_FORMAT format);
public:
CSwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain,
CSwapChainProcessor(CIndirectDeviceContext * devContext, IDDCX_SWAPCHAIN hSwapChain,
std::shared_ptr<Direct3DDevice> device, HANDLE newFrameEvent);
~CSwapChainProcessor();
};