check ReleaseFrame result #10
This commit is contained in:
Binary file not shown.
@@ -5,6 +5,7 @@
|
|||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Unity interface getter
|
// Unity interface getter
|
||||||
struct IUnityInterfaces;
|
struct IUnityInterfaces;
|
||||||
IUnityInterfaces* GetUnity();
|
IUnityInterfaces* GetUnity();
|
||||||
@@ -21,6 +22,21 @@ const std::unique_ptr<MonitorManager>& GetMonitorManager();
|
|||||||
LUID GetUnityAdapterLuid();
|
LUID GetUnityAdapterLuid();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Releaser
|
||||||
|
class ScopedReleaser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ReleaseFuncType = std::function<void()>;
|
||||||
|
ScopedReleaser(ReleaseFuncType&& func) : func_(func) {}
|
||||||
|
~ScopedReleaser() { func_(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ReleaseFuncType func_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Message is pooled and fetch from Unity.
|
// Message is pooled and fetch from Unity.
|
||||||
enum class Message
|
enum class Message
|
||||||
{
|
{
|
||||||
@@ -32,6 +48,7 @@ enum class Message
|
|||||||
void SendMessageToUnity(Message message);
|
void SendMessageToUnity(Message message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Buffer
|
// Buffer
|
||||||
template <class T>
|
template <class T>
|
||||||
class Buffer
|
class Buffer
|
||||||
|
|||||||
@@ -78,25 +78,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// RAII helper
|
|
||||||
class ReleaseGuard
|
|
||||||
{
|
|
||||||
ComPtr<IDXGIOutputDuplication> m_dd;
|
|
||||||
|
|
||||||
ReleaseGuard(const ReleaseGuard &)=delete;
|
|
||||||
ReleaseGuard& operator=(const ReleaseGuard &)=delete;
|
|
||||||
public:
|
|
||||||
ReleaseGuard(const ComPtr<IDXGIOutputDuplication> &dd)
|
|
||||||
: m_dd(dd)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~ReleaseGuard()
|
|
||||||
{
|
|
||||||
m_dd->ReleaseFrame();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct QueueItem
|
struct QueueItem
|
||||||
{
|
{
|
||||||
ComPtr<ID3D11Texture2D> Texture;
|
ComPtr<ID3D11Texture2D> Texture;
|
||||||
@@ -357,7 +338,33 @@ void Monitor::DuplicateAndCopyLoop()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReleaseGuard guard(deskDupl_);
|
ScopedReleaser releaser([this]
|
||||||
|
{
|
||||||
|
const auto hr = deskDupl_->ReleaseFrame();
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
switch (hr)
|
||||||
|
{
|
||||||
|
case DXGI_ERROR_ACCESS_LOST:
|
||||||
|
{
|
||||||
|
Debug::Log("Monitor::Render() => DXGI_ERROR_ACCESS_LOST.");
|
||||||
|
state_ = State::AccessLost;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DXGI_ERROR_INVALID_CALL:
|
||||||
|
{
|
||||||
|
Debug::Error("Monitor::Render() => DXGI_ERROR_INVALID_CALL.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
state_ = State::Unknown;
|
||||||
|
Debug::Error("Monitor::Render() => Unknown Error.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ComPtr<ID3D11Texture2D> texture;
|
ComPtr<ID3D11Texture2D> texture;
|
||||||
if (FAILED(resource.As(&texture))) {
|
if (FAILED(resource.As(&texture))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user