Skip to content

Commit

Permalink
afedchin's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
thexai committed Jul 14, 2020
1 parent 62bce60 commit 0844dc8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 42 deletions.
12 changes: 6 additions & 6 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ void CVideoBufferCopy::Initialize(CDecoder* decoder)
ComPtr<ID3D11Texture2D> pDecoderTexture;
ComPtr<ID3D11Texture2D> pCopyTexture;
ComPtr<IDXGIResource> pDXGIResource;
ComPtr<ID3D11Query> pQuery;

if (FAILED(pResource.As(&pDecoderTexture)))
{
Expand Down Expand Up @@ -800,23 +801,22 @@ void CVideoBufferCopy::Initialize(CDecoder* decoder)

D3D11_QUERY_DESC queryDesc = {};
queryDesc.Query = D3D11_QUERY_EVENT;
ID3D11Query* pQuery;

if (FAILED(pDevice->CreateQuery(&queryDesc, &pQuery)))
{
CLog::LogF(LOGDEBUG, "unable to create query");
return;
}

m_pQuery = pQuery;
pQuery.As(&m_pQuery);
}

if (m_copyRes)
{
// sends commands to GPU and wait Flush is completed
pDeviceContext->Flush();
pDeviceContext->End(m_pQuery);
while (S_OK != pDeviceContext->GetData(m_pQuery, nullptr, 0, 0))
pDeviceContext->End(m_pQuery.Get());
while (S_OK != pDeviceContext->GetData(m_pQuery.Get(), nullptr, 0, 0))
{
std::this_thread::sleep_for(std::chrono::nanoseconds(500));
}
Expand All @@ -827,8 +827,8 @@ void CVideoBufferCopy::Initialize(CDecoder* decoder)

// sends commands to GPU and wait Flush is completed
pDeviceContext->Flush();
pDeviceContext->End(m_pQuery);
while (S_OK != pDeviceContext->GetData(m_pQuery, nullptr, 0, 0))
pDeviceContext->End(m_pQuery.Get());
while (S_OK != pDeviceContext->GetData(m_pQuery.Get(), nullptr, 0, 0))
{
std::this_thread::sleep_for(std::chrono::nanoseconds(500));
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CVideoBufferCopy : public CVideoBufferShared
: CVideoBufferShared(id) {}

Microsoft::WRL::ComPtr<ID3D11Resource> m_copyRes;
ID3D11Query* m_pQuery;
Microsoft::WRL::ComPtr<ID3D11Query> m_pQuery;
};

class CContext
Expand Down
38 changes: 3 additions & 35 deletions xbmc/rendering/dx/DirectXHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,42 +88,10 @@ namespace DX

inline std::string GetFeatureLevelDescription(D3D_FEATURE_LEVEL featureLevel)
{
std::string fl;
uint32_t fl_major = (featureLevel & 0xF000u) >> 12;
uint32_t fl_minor = (featureLevel & 0x0F00u) >> 8;

switch (featureLevel)
{
case D3D_FEATURE_LEVEL_9_1:
fl = "D3D_FEATURE_LEVEL_9_1";
break;
case D3D_FEATURE_LEVEL_9_2:
fl = "D3D_FEATURE_LEVEL_9_2";
break;
case D3D_FEATURE_LEVEL_9_3:
fl = "D3D_FEATURE_LEVEL_9_3";
break;
case D3D_FEATURE_LEVEL_10_0:
fl = "D3D_FEATURE_LEVEL_10_0";
break;
case D3D_FEATURE_LEVEL_10_1:
fl = "D3D_FEATURE_LEVEL_10_1";
break;
case D3D_FEATURE_LEVEL_11_0:
fl = "D3D_FEATURE_LEVEL_11_0";
break;
case D3D_FEATURE_LEVEL_11_1:
fl = "D3D_FEATURE_LEVEL_11_1";
break;
case D3D_FEATURE_LEVEL_12_0:
fl = "D3D_FEATURE_LEVEL_12_0";
break;
case D3D_FEATURE_LEVEL_12_1:
fl = "D3D_FEATURE_LEVEL_12_1";
break;
default:
fl = StringUtils::Format("D3D_FEATURE_LEVEL_UNKNOWN ({:#04x})", featureLevel);
break;
}
return fl;
return StringUtils::Format("D3D_FEATURE_LEVEL_{}_{}", fl_major, fl_minor);
}

template <typename T> struct SizeGen
Expand Down

0 comments on commit 0844dc8

Please sign in to comment.