99 lines
2.3 KiB
C++
99 lines
2.3 KiB
C++
#include "app/AppConfig.h"
|
|
#include "app/RenderCadenceApp.h"
|
|
#include "frames/SystemFrameExchange.h"
|
|
#include "render/RenderThread.h"
|
|
#include "VideoIOFormat.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
namespace
|
|
{
|
|
class ComInitGuard
|
|
{
|
|
public:
|
|
~ComInitGuard()
|
|
{
|
|
if (mInitialized)
|
|
CoUninitialize();
|
|
}
|
|
|
|
bool Initialize()
|
|
{
|
|
const HRESULT result = CoInitialize(nullptr);
|
|
mInitialized = SUCCEEDED(result);
|
|
mResult = result;
|
|
return mInitialized;
|
|
}
|
|
|
|
HRESULT Result() const { return mResult; }
|
|
|
|
private:
|
|
bool mInitialized = false;
|
|
HRESULT mResult = S_OK;
|
|
};
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
ComInitGuard com;
|
|
if (!com.Initialize())
|
|
{
|
|
std::cerr << "COM initialization failed: 0x" << std::hex << com.Result() << std::dec << "\n";
|
|
return 1;
|
|
}
|
|
|
|
std::cout << "RenderCadenceCompositor\n"
|
|
<< " Starts render cadence, system-memory exchange, DeckLink scheduled output, and telemetry.\n"
|
|
<< " Press Enter to stop.\n";
|
|
|
|
SystemFrameExchangeConfig frameExchangeConfig;
|
|
frameExchangeConfig.width = 1920;
|
|
frameExchangeConfig.height = 1080;
|
|
frameExchangeConfig.pixelFormat = VideoIOPixelFormat::Bgra8;
|
|
frameExchangeConfig.rowBytes = VideoIORowBytes(frameExchangeConfig.pixelFormat, frameExchangeConfig.width);
|
|
frameExchangeConfig.capacity = 12;
|
|
|
|
SystemFrameExchange frameExchange(frameExchangeConfig);
|
|
|
|
RenderThread::Config renderConfig;
|
|
renderConfig.width = frameExchangeConfig.width;
|
|
renderConfig.height = frameExchangeConfig.height;
|
|
renderConfig.frameDurationMilliseconds = 1000.0 / 59.94;
|
|
renderConfig.pboDepth = 6;
|
|
|
|
RenderThread renderThread(frameExchange, renderConfig);
|
|
|
|
RenderCadenceCompositor::AppConfig appConfig = RenderCadenceCompositor::DefaultAppConfig();
|
|
for (int index = 1; index < argc; ++index)
|
|
{
|
|
const std::string argument = argv[index];
|
|
if (argument == "--shader" && index + 1 < argc)
|
|
{
|
|
appConfig.runtimeShaderId = argv[++index];
|
|
continue;
|
|
}
|
|
if (argument == "--no-shader")
|
|
{
|
|
appConfig.runtimeShaderId.clear();
|
|
continue;
|
|
}
|
|
}
|
|
|
|
RenderCadenceCompositor::RenderCadenceApp<RenderThread, SystemFrameExchange> app(renderThread, frameExchange, appConfig);
|
|
|
|
std::string error;
|
|
if (!app.Start(error))
|
|
{
|
|
std::cerr << "RenderCadenceCompositor start failed: " << error << "\n";
|
|
return 1;
|
|
}
|
|
|
|
std::string line;
|
|
std::getline(std::cin, line);
|
|
app.Stop();
|
|
return 0;
|
|
}
|