blob: 7c2a3eb17421d104b10a8b38715e52f71ead0b3f (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#pragma once
#include "D3D11Includes.h"
#include "Runtime/GfxDevice/GfxDeviceTypes.h"
#define DEBUG_D3D11_CONSTANT_BUFFER_STATS 0
#if DEBUG_D3D11_CONSTANT_BUFFER_STATS
#include <map>
#endif
class ConstantBuffersD3D11
{
public:
ConstantBuffersD3D11();
~ConstantBuffersD3D11() { Clear(); }
void Clear();
void InvalidateState();
struct ConstBuffer {
int bindIndex[kShaderTypeCount];
unsigned bindStages;
bool dirty;
UInt8* data;
ID3D11Buffer* buffer;
#if DEBUG_D3D11_CONSTANT_BUFFER_STATS
int statsDirty;
int stats[kShaderTypeCount]
int* tryCounts;
int* changeCounts;
#endif
};
void SetCBInfo (int id, int size);
int FindAndBindCB (int id, ShaderType shaderType, int bind, int size);
void ResetBinds (ShaderType shaderType);
void SetBuiltinCBConstant (int id, int offset, const void* data, int size);
void SetCBConstant (int index, int offset, const void* data, int size);
void UpdateBuffers();
void NewFrame();
private:
inline int GetCBIndexByID (int id) const
{
UInt32 key = id;
int n = m_BufferKeys.size();
for (int i = 0; i < n; ++i)
{
if ((m_BufferKeys[i]&0xFFFF) == key)
return i;
}
Assert (false);
return -1;
}
private:
typedef std::vector<UInt32> ConstBufferKeys;
typedef std::vector<ConstBuffer> ConstBuffers;
ConstBufferKeys m_BufferKeys;
ConstBuffers m_Buffers;
ID3D11Buffer* m_ActiveBuffers[kShaderTypeCount][16];
};
#if !DEBUG_D3D11_CONSTANT_BUFFER_STATS
inline void ConstantBuffersD3D11::NewFrame() { }
#endif
|