summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/BoundingBox.cpp
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2019-03-29 20:40:06 +1000
committerGitHub <noreply@github.com>2019-03-29 20:40:06 +1000
commitf3fadd730218429a5f6472283d16d30d7e276f8d (patch)
treed1d6577cd52b2d3b3d7872aef4fac80dbd0ce563 /Source/Core/VideoBackends/D3D/BoundingBox.cpp
parentfbe57e8dbef17e583f0ba0208af7bf414a3716bf (diff)
parentd0d010f8549cc902829f567b3b5127d9a0556ca5 (diff)
Merge pull request #7869 from stenzek/d3dcommon
D3D: Move sharable D3D11/D3D12 code to common library
Diffstat (limited to 'Source/Core/VideoBackends/D3D/BoundingBox.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/BoundingBox.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/Source/Core/VideoBackends/D3D/BoundingBox.cpp b/Source/Core/VideoBackends/D3D/BoundingBox.cpp
index abbd7036a1..7cae36e1a1 100644
--- a/Source/Core/VideoBackends/D3D/BoundingBox.cpp
+++ b/Source/Core/VideoBackends/D3D/BoundingBox.cpp
@@ -6,17 +6,18 @@
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "VideoBackends/D3D/D3DState.h"
+#include "VideoBackends/D3DCommon/Common.h"
#include "VideoCommon/VideoConfig.h"
namespace DX11
{
-static ID3D11Buffer* s_bbox_buffer;
-static ID3D11Buffer* s_bbox_staging_buffer;
-static ID3D11UnorderedAccessView* s_bbox_uav;
+static ComPtr<ID3D11Buffer> s_bbox_buffer;
+static ComPtr<ID3D11Buffer> s_bbox_staging_buffer;
+static ComPtr<ID3D11UnorderedAccessView> s_bbox_uav;
-ID3D11UnorderedAccessView*& BBox::GetUAV()
+ID3D11UnorderedAccessView* BBox::GetUAV()
{
- return s_bbox_uav;
+ return s_bbox_uav.Get();
}
void BBox::Init()
@@ -35,7 +36,7 @@ void BBox::Init()
HRESULT hr;
hr = D3D::device->CreateBuffer(&desc, &data, &s_bbox_buffer);
CHECK(SUCCEEDED(hr), "Create BoundingBox Buffer.");
- D3D::SetDebugObjectName(s_bbox_buffer, "BoundingBox Buffer");
+ D3DCommon::SetDebugObjectName(s_bbox_buffer.Get(), "BoundingBox Buffer");
// Second to use as a staging buffer.
desc.Usage = D3D11_USAGE_STAGING;
@@ -43,7 +44,7 @@ void BBox::Init()
desc.BindFlags = 0;
hr = D3D::device->CreateBuffer(&desc, nullptr, &s_bbox_staging_buffer);
CHECK(SUCCEEDED(hr), "Create BoundingBox Staging Buffer.");
- D3D::SetDebugObjectName(s_bbox_staging_buffer, "BoundingBox Staging Buffer");
+ D3DCommon::SetDebugObjectName(s_bbox_staging_buffer.Get(), "BoundingBox Staging Buffer");
// UAV is required to allow concurrent access.
D3D11_UNORDERED_ACCESS_VIEW_DESC UAVdesc = {};
@@ -52,37 +53,37 @@ void BBox::Init()
UAVdesc.Buffer.FirstElement = 0;
UAVdesc.Buffer.Flags = 0;
UAVdesc.Buffer.NumElements = 4;
- hr = D3D::device->CreateUnorderedAccessView(s_bbox_buffer, &UAVdesc, &s_bbox_uav);
+ hr = D3D::device->CreateUnorderedAccessView(s_bbox_buffer.Get(), &UAVdesc, &s_bbox_uav);
CHECK(SUCCEEDED(hr), "Create BoundingBox UAV.");
- D3D::SetDebugObjectName(s_bbox_uav, "BoundingBox UAV");
- D3D::stateman->SetOMUAV(s_bbox_uav);
+ D3DCommon::SetDebugObjectName(s_bbox_uav.Get(), "BoundingBox UAV");
+ D3D::stateman->SetOMUAV(s_bbox_uav.Get());
}
}
void BBox::Shutdown()
{
- SAFE_RELEASE(s_bbox_buffer);
- SAFE_RELEASE(s_bbox_staging_buffer);
- SAFE_RELEASE(s_bbox_uav);
+ s_bbox_uav.Reset();
+ s_bbox_staging_buffer.Reset();
+ s_bbox_buffer.Reset();
}
void BBox::Set(int index, int value)
{
D3D11_BOX box{index * sizeof(s32), 0, 0, (index + 1) * sizeof(s32), 1, 1};
- D3D::context->UpdateSubresource(s_bbox_buffer, 0, &box, &value, 0, 0);
+ D3D::context->UpdateSubresource(s_bbox_buffer.Get(), 0, &box, &value, 0, 0);
}
int BBox::Get(int index)
{
int data = 0;
- D3D::context->CopyResource(s_bbox_staging_buffer, s_bbox_buffer);
+ D3D::context->CopyResource(s_bbox_staging_buffer.Get(), s_bbox_buffer.Get());
D3D11_MAPPED_SUBRESOURCE map;
- HRESULT hr = D3D::context->Map(s_bbox_staging_buffer, 0, D3D11_MAP_READ, 0, &map);
+ HRESULT hr = D3D::context->Map(s_bbox_staging_buffer.Get(), 0, D3D11_MAP_READ, 0, &map);
if (SUCCEEDED(hr))
{
data = ((s32*)map.pData)[index];
}
- D3D::context->Unmap(s_bbox_staging_buffer, 0);
+ D3D::context->Unmap(s_bbox_staging_buffer.Get(), 0);
return data;
}
}; // namespace DX11