blob: a22eba2b13a10e641b66de59e3ec931b08b16510 (
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
|
#pragma once
#include "IncludesGLES30.h"
#include "Runtime/GfxDevice/GfxDeviceTypes.h"
#define DEBUG_GLES30_CONSTANT_BUFFER_STATS 0
#if DEBUG_GLES30_CONSTANT_BUFFER_STATS
#include <map>
#endif
class ConstantBuffersGLES30
{
public:
ConstantBuffersGLES30();
~ConstantBuffersGLES30() { Clear(); }
void Clear();
struct ConstBuffer {
int bindIndex;
bool dirty;
UInt8* data;
UInt32 buffer;
#if DEBUG_GLES30_CONSTANT_BUFFER_STATS
int statsDirty;
int stats
int* tryCounts;
int* changeCounts;
#endif
};
void SetCBInfo (int id, int size);
int FindAndBindCB (int id, int bind, int size);
void ResetBinds ();
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;
UInt32 m_ActiveBuffers[16];
};
#if !DEBUG_GLES30_CONSTANT_BUFFER_STATS
inline void ConstantBuffersGLES30::NewFrame() { }
#endif
|