forked from doitsujin/dxvk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdxso_util.cpp
34 lines (25 loc) · 843 Bytes
/
dxso_util.cpp
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
#include "dxso_util.h"
#include "dxso_include.h"
namespace dxvk {
dxvk::mutex g_linkerSlotMutex;
uint32_t g_linkerSlotCount = 0;
std::array<DxsoSemantic, 32> g_linkerSlots;
uint32_t RegisterLinkerSlot(DxsoSemantic semantic) {
// Lock, because games could be trying
// to make multiple shaders at a time.
std::lock_guard<dxvk::mutex> lock(g_linkerSlotMutex);
// Need to chose a slot that maps nicely and similarly
// between vertex and pixel shaders
// Find or map a slot.
uint32_t slot = g_linkerSlotCount;
for (uint32_t j = 0; j < g_linkerSlotCount; j++) {
if (g_linkerSlots[j] == semantic) {
slot = j;
break;
}
}
if (slot == g_linkerSlotCount)
g_linkerSlots[g_linkerSlotCount++] = semantic;
return slot;
}
}