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