2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:29:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2011-06-11 19:37:21 +00:00
|
|
|
|
|
|
|
#include <d3d11.h>
|
2014-02-17 10:18:15 +00:00
|
|
|
|
|
|
|
#include "VideoBackends/D3D/D3DBlob.h"
|
2011-06-11 19:37:21 +00:00
|
|
|
|
|
|
|
namespace DX11
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
D3DBlob::D3DBlob(unsigned int blob_size, const u8* init_data)
|
|
|
|
: ref(1), size(blob_size), blob(nullptr)
|
2011-06-11 19:37:21 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
data = new u8[blob_size];
|
|
|
|
if (init_data)
|
|
|
|
memcpy(data, init_data, size);
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D3DBlob::D3DBlob(ID3D10Blob* d3dblob) : ref(1)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
blob = d3dblob;
|
|
|
|
data = (u8*)blob->GetBufferPointer();
|
|
|
|
size = (unsigned int)blob->GetBufferSize();
|
|
|
|
d3dblob->AddRef();
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D3DBlob::~D3DBlob()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (blob)
|
|
|
|
blob->Release();
|
|
|
|
else
|
|
|
|
delete[] data;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void D3DBlob::AddRef()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
++ref;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int D3DBlob::Release()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (--ref == 0)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ref;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
2015-04-15 04:38:21 +00:00
|
|
|
unsigned int D3DBlob::Size() const
|
2011-06-11 19:37:21 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return size;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u8* D3DBlob::Data()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return data;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
2015-03-01 16:17:09 +00:00
|
|
|
} // namespace DX11
|