-
Notifications
You must be signed in to change notification settings - Fork 1
/
warptrace.glsl
55 lines (49 loc) · 1.59 KB
/
warptrace.glsl
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
/*
Warp trace - Warp-level performance analysis for GPUs
Copyright (C) 2016 Wade Brainerd
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define TRACE_CS 0
#define TRACE_VS 1
#define TRACE_TCS 2
#define TRACE_TES 3
#define TRACE_GS 4
#define TRACE_FS 5
layout( std430, binding = 7 ) buffer TraceData {
int tracePos;
int pad[3];
uvec4 traceData[1];
};
uint warpStartClock;
void BeginTrace(int id, int stage)
{
#if TRACE
warpStartClock = clock2x32ARB().y;
#endif
}
void EndTrace(int id, int stage)
{
#if TRACE
uint activeMask = activeThreadsNV();
if ( (activeMask & gl_ThreadLtMaskNV) == 0 )
{
uint header = (bitCount( activeMask ) - 1)
| (stage << 5)
| (gl_SMIDNV << 8)
| (gl_WarpIDNV << 16);
uint warpEndClock = clock2x32ARB().y;
int warpPos = atomicAdd( tracePos, 1 );
traceData[warpPos] = uvec4( header, id, warpStartClock, warpEndClock );
}
#endif
}