summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/D3DBlob.cpp
blob: c0991825b69621bcd1462d8539ef06f63054d821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <d3d11.h>

#include "VideoBackends/D3D/D3DBlob.h"

namespace DX11
{
D3DBlob::D3DBlob(unsigned int blob_size, const u8* init_data)
    : ref(1), size(blob_size), blob(nullptr)
{
  data = new u8[blob_size];
  if (init_data)
    memcpy(data, init_data, size);
}

D3DBlob::D3DBlob(ID3D10Blob* d3dblob) : ref(1)
{
  blob = d3dblob;
  data = (u8*)blob->GetBufferPointer();
  size = (unsigned int)blob->GetBufferSize();
  d3dblob->AddRef();
}

D3DBlob::~D3DBlob()
{
  if (blob)
    blob->Release();
  else
    delete[] data;
}

void D3DBlob::AddRef()
{
  ++ref;
}

unsigned int D3DBlob::Release()
{
  if (--ref == 0)
  {
    delete this;
    return 0;
  }
  return ref;
}

unsigned int D3DBlob::Size() const
{
  return size;
}

u8* D3DBlob::Data()
{
  return data;
}

}  // namespace DX11