This repository has been archived by the owner on Apr 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
SUCommon.h
executable file
·189 lines (154 loc) · 5.01 KB
/
SUCommon.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//=====================================================================
// Copyright 2010-2016 (c), Advanced Micro Devices, Inc. All rights reserved.
//
/// \author AMD Developer Tools Team
/// \file SUCommon.h
/// \brief This file defines enums and structs used in ShaderDebugger
/// and APP Profiler.
///
//=====================================================================
//=====================================================================
// $Id: //devtools/main/Common/Src/ShaderUtils/SUCommon.h#9 $
// Last checkin: $DateTime: 2016/04/18 06:01:26 $
// Last edited by: $Author: AMD Developer Tools Team
// Change list: $Change: 569612 $
//=====================================================================
#ifndef _SU_COMMON_H_
#define _SU_COMMON_H_
#include <cassert>
#include <cstdlib>
// TODO: Figure out a way to support the following
#define SU_Assert assert
#define SU_Verify
#define SU_Break assert
#define hidden_quote( s ) #s
#define hidden_numquote( n ) hidden_quote( n )
#if defined (_WIN32)
#define SU_TODO(x) __pragma( message( __FILE__ "(" hidden_numquote( __LINE__ ) "): TODO: " x ) )
#elif defined (__linux__)
#if __GNUC_PREREQ(4,1)
// GCC 4.1.2 expands this incorrectly - nullify it
#define SU_TODO(x)
#else
// Macros do not seem to directly expand on Linux in #pragma statements
#define DO_PRAGMA(x) _Pragma(#x)
#define SU_TODO(x) DO_PRAGMA( message( __FILE__ "(" hidden_numquote( __LINE__ ) "): TODO: " x ) )
#endif
#elif defined (__CYGWIN__)
#define SU_TODO(x)
#endif
namespace ShaderUtils
{
template<typename T>
inline void SU_SAFE_FREE(T& p)
{
free(p);
p = NULL;
}
template<typename T>
inline void SU_SAFE_DELETE(T& p)
{
delete p;
p = NULL;
}
/// The type of shader.
typedef enum
{
ST_Unknown, ///< Unknown shader type.
ST_Pixel, ///< Pixel shader.
ST_Vertex, ///< Vertex shader.
ST_Geometry, ///< Geometry shader.
ST_Geometry_SO, ///< Geometry shader with stream output.
ST_Hull, ///< Hull shader.
ST_Domain, ///< Domain shader.
ST_Compute, ///< Compute shader.
} ShaderType;
/// Type describing RGBA_32F buffer format.
typedef struct RGBA_32F
{
RGBA_32F(float val = 0) { r = g = b = a = val; }
float r, g, b, a;
} RGBA_32F;
/// Equality operator for comparing instances of RGBA_32F.
inline bool operator==(const RGBA_32F& lhs, const RGBA_32F& rhs)
{
return (lhs.r == rhs.r) &&
(lhs.g == rhs.g) &&
(lhs.b == rhs.b) &&
(lhs.a == rhs.a);
}
/// Inequality operator for comparing instances of RGBA_32F.
inline bool operator!=(const RGBA_32F& lhs, const RGBA_32F& rhs)
{
return !(lhs == rhs);
}
/// Type describing RGBA_16 buffer format.
typedef struct
{
unsigned short r, g, b, a;
} RGBA_16;
/// Type describing RGB_32 buffer format.
typedef struct
{
unsigned int r, g, b;
} RGB_32;
/// Type describing RGB_16 buffer format.
typedef struct
{
unsigned short r, g, b;
} RGB_16;
/// Type describing XYZW_32F buffer format.
typedef struct
{
float x, y, z, w;
} XYZW_32F;
/// The data type.
typedef enum
{
DT_Unknown, ///< Unknown data type.
DT_Float32, ///< 32-bit floating point.
DT_Int32, ///< 32-bit integer (signed-ness unknown).
DT_SInt32, ///< 32-bit signed integer.
DT_UInt32, ///< 32-bit unsigned integer.
DT_Boolean, ///< Boolean.
} DataType;
/// The type of thread ID.
typedef enum
{
TID_Unknown, ///< Unknown thread ID type.
TID_1D, ///< 1D thread ID.
TID_2D, ///< 2D thread ID.
TID_3D, ///< 3D thread ID.
} ThreadIDType;
/// The ID of a thread.
typedef struct ThreadID
{
ThreadIDType type; ///< The thread ID type.
int x; ///< The x component of the thread ID.
int y; ///< The y component of the thread ID.
int z; ///< The z component of the thread ID.
int nSubResource; ///< The sub-resource component of the thread ID.
/// Default constructor.
ThreadID() { Clear(); };
/// Constructor.
/// \param[in] _type The thread ID type.
/// \param[in] _x The x component of the thread ID.
/// \param[in] _y The y component of the thread ID.
/// \param[in] _z The z component of the thread ID.
/// \param[in] _nSubResource The sub-resource component of the thread ID.
ThreadID(ThreadIDType _type, int _x, int _y, int _z, int _nSubResource)
{
type = _type; x = _x; y = _y; z = _z; nSubResource = _nSubResource;
};
/// Clear the thread ID to default values.
void Clear() { type = TID_2D; x = y = z = 0; nSubResource = 0; };
} ThreadID;
extern const ThreadID g_tID_Error;
/// A null thread. Used for comparisons.
extern const ThreadID g_tID_Error;
/// Is the thread ID valid?
/// \param[in] threadID The thread ID to check for validity.
/// \return True if threadID is valid, otherwise false.
bool IsValid(const ThreadID& threadID);
}
#endif //_SU_COMMON_H_