mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[idd] capture: build frame processing graph
This commit is contained in:
@@ -91,6 +91,7 @@ void CPostProcessor::Reset()
|
||||
m_device.Reset();
|
||||
m_srcFormat = {};
|
||||
m_dstFormat = {};
|
||||
m_texFormat = {};
|
||||
m_copyLayout = {};
|
||||
m_copyEffect = nullptr;
|
||||
m_frameSize = 0;
|
||||
@@ -173,6 +174,7 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
|
||||
// Propagate it without recreating resources or post-processing state.
|
||||
D12::CopyHdr(m_srcFormat, srcFormat);
|
||||
D12::CopyHdr(m_dstFormat, srcFormat);
|
||||
D12::CopyHdr(m_texFormat, srcFormat);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -181,6 +183,7 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
|
||||
|
||||
D12FrameFormat oldDst = m_dstFormat;
|
||||
D12FrameFormat cur = srcFormat;
|
||||
D12FrameFormat tex = srcFormat;
|
||||
CPostProcessEffect * outputEffect = nullptr;
|
||||
bool effectsActive = false;
|
||||
|
||||
@@ -193,6 +196,8 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
|
||||
effect->Enabled = true;
|
||||
effectsActive = true;
|
||||
cur = dst;
|
||||
if (dst.desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D)
|
||||
tex = dst;
|
||||
outputEffect = effect.get();
|
||||
break;
|
||||
|
||||
@@ -249,6 +254,7 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
|
||||
|
||||
m_srcFormat = srcFormat;
|
||||
m_dstFormat = cur;
|
||||
m_texFormat = tex;
|
||||
m_copyLayout = copyLayout;
|
||||
m_copyEffect = copyEffect;
|
||||
m_frameSize = frameSize;
|
||||
|
||||
@@ -107,6 +107,7 @@ private:
|
||||
std::vector<std::unique_ptr<CPostProcessEffect>> m_effects;
|
||||
D12FrameFormat m_srcFormat = {};
|
||||
D12FrameFormat m_dstFormat = {};
|
||||
D12FrameFormat m_texFormat = {};
|
||||
D3D12_PLACED_SUBRESOURCE_FOOTPRINT m_copyLayout = {};
|
||||
CPostProcessEffect * m_copyEffect = nullptr;
|
||||
size_t m_frameSize = 0;
|
||||
@@ -135,6 +136,7 @@ public:
|
||||
unsigned * nbDirtyRects);
|
||||
|
||||
const D12FrameFormat& GetOutputFormat() const { return m_dstFormat; }
|
||||
const D12FrameFormat& GetTextureFormat() const { return m_texFormat; }
|
||||
bool HasActiveEffects() const { return m_effectsActive; }
|
||||
void GetTimingToken(unsigned * effectIndex, uint64_t * token) const;
|
||||
void RecordTiming(unsigned effectIndex, uint64_t token,
|
||||
|
||||
@@ -71,6 +71,27 @@ std::shared_ptr<const D12ColorTransform> D12::Transform(
|
||||
return transform;
|
||||
}
|
||||
|
||||
DXGI_FORMAT D12::Dxgi(FramePixel pixel)
|
||||
{
|
||||
switch (pixel)
|
||||
{
|
||||
case FramePixel::BGRA8:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
case FramePixel::RGBA8:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
case FramePixel::RGB10A2:
|
||||
return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
case FramePixel::RGBA16F:
|
||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
}
|
||||
return DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
FrameType D12::Type(FramePixel pixel)
|
||||
{
|
||||
return Type(Dxgi(pixel));
|
||||
}
|
||||
|
||||
FrameType D12::Type(DXGI_FORMAT format)
|
||||
{
|
||||
switch (format)
|
||||
@@ -88,6 +109,75 @@ FrameType D12::Type(DXGI_FORMAT format)
|
||||
}
|
||||
}
|
||||
|
||||
bool D12::Profile(const D12FrameFormat& format, FrameStorage storage,
|
||||
FrameProfile& profile)
|
||||
{
|
||||
if ((format.hdrPQ && !format.hdr) || !Frame::Valid(storage))
|
||||
return false;
|
||||
|
||||
FrameProfile result;
|
||||
result.storage = storage;
|
||||
if (!format.hdr)
|
||||
{
|
||||
result.signal = FrameSignal::SRGB;
|
||||
if (format.format == FRAME_TYPE_BGRA)
|
||||
result.pixel = FramePixel::BGRA8;
|
||||
else if (format.format == FRAME_TYPE_RGBA)
|
||||
result.pixel = FramePixel::RGBA8;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (format.hdrPQ)
|
||||
{
|
||||
if (format.format != FRAME_TYPE_RGBA10)
|
||||
return false;
|
||||
result.pixel = FramePixel::RGB10A2;
|
||||
result.signal = FrameSignal::PQ_BT2020;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (format.format != FRAME_TYPE_RGBA16F)
|
||||
return false;
|
||||
result.pixel = FramePixel::RGBA16F;
|
||||
result.signal = FrameSignal::SCRGB_LINEAR;
|
||||
}
|
||||
|
||||
if (format.desc.Format != Dxgi(result.pixel))
|
||||
return false;
|
||||
|
||||
profile = result;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D12::Set(D12FrameFormat& format, const FrameProfile& profile,
|
||||
unsigned width, unsigned height, D3D12_RESOURCE_FLAGS flags)
|
||||
{
|
||||
if (!width || !height || profile.storage != FrameStorage::D3D12_TEXTURE ||
|
||||
!Frame::Valid(profile))
|
||||
return false;
|
||||
|
||||
format.desc = {};
|
||||
format.desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
format.desc.Width = width;
|
||||
format.desc.Height = height;
|
||||
format.desc.DepthOrArraySize = 1;
|
||||
format.desc.MipLevels = 1;
|
||||
format.desc.Format = Dxgi(profile.pixel);
|
||||
format.desc.SampleDesc.Count = 1;
|
||||
format.desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||
format.desc.Flags = flags;
|
||||
format.dataWidth = width;
|
||||
format.dataHeight = height;
|
||||
format.pitch = 0;
|
||||
format.width = width;
|
||||
format.height = height;
|
||||
format.format = Type(profile.pixel);
|
||||
format.hdr = profile.signal != FrameSignal::SRGB;
|
||||
format.hdrPQ = profile.signal == FrameSignal::PQ_BT2020;
|
||||
return format.desc.Format != DXGI_FORMAT_UNKNOWN &&
|
||||
format.format != FRAME_TYPE_INVALID;
|
||||
}
|
||||
|
||||
void D12::CopyHdr(D12FrameFormat& dst, const D12FrameFormat& src)
|
||||
{
|
||||
dst.hdrMetadata = src.hdrMetadata;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "transport/FrameProfile.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <d3d12.h>
|
||||
#include <memory>
|
||||
@@ -85,7 +87,15 @@ namespace D12
|
||||
NO_FLAGS,
|
||||
};
|
||||
|
||||
DXGI_FORMAT Dxgi(FramePixel pixel);
|
||||
FrameType Type(DXGI_FORMAT format);
|
||||
FrameType Type(FramePixel pixel);
|
||||
|
||||
bool Profile(const D12FrameFormat& format, FrameStorage storage,
|
||||
FrameProfile& profile);
|
||||
bool Set(D12FrameFormat& format, const FrameProfile& profile,
|
||||
unsigned width, unsigned height,
|
||||
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE);
|
||||
void CopyHdr(D12FrameFormat& dst, const D12FrameFormat& src);
|
||||
std::shared_ptr<const D12ColorTransform> Transform(
|
||||
const std::shared_ptr<const D12ColorTransform>& transform);
|
||||
|
||||
Reference in New Issue
Block a user