1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5namespace bs
6{
7 // Undefine defines from other libs, that conflict with enums below
8#undef None
9#undef Convex
10
11 /** @addtogroup Utility-Core
12 * @{
13 */
14
15 /** Factors used when blending new pixels with existing pixels. */
16 enum BlendFactor
17 {
18 BF_ONE, /**< Use a value of one for all pixel components. */
19 BF_ZERO, /**< Use a value of zero for all pixel components. */
20 BF_DEST_COLOR, /**< Use the existing pixel value. */
21 BF_SOURCE_COLOR, /**< Use the newly generated pixel value. */
22 BF_INV_DEST_COLOR, /**< Use the inverse of the existing value. */
23 BF_INV_SOURCE_COLOR, /**< Use the inverse of the newly generated pixel value. */
24 BF_DEST_ALPHA, /**< Use the existing alpha value. */
25 BF_SOURCE_ALPHA, /**< Use the newly generated alpha value. */
26 BF_INV_DEST_ALPHA, /**< Use the inverse of the existing alpha value. */
27 BF_INV_SOURCE_ALPHA /**< Use the inverse of the newly generated alpha value. */
28 };
29
30 /** Operations that determines how are blending factors combined. */
31 enum BlendOperation
32 {
33 BO_ADD, /**< Blend factors are added together. */
34 BO_SUBTRACT, /**< Blend factors are subtracted in "srcFactor - dstFactor" order. */
35 BO_REVERSE_SUBTRACT, /**< Blend factors are subtracted in "dstFactor - srcFactor" order. */
36 BO_MIN, /**< Minimum of the two factors is chosen. */
37 BO_MAX /**< Maximum of the two factors is chosen. */
38 };
39
40 /** Comparison functions used for the depth/stencil buffer. */
41 enum CompareFunction
42 {
43 CMPF_ALWAYS_FAIL, /**< Operation will always fail. */
44 CMPF_ALWAYS_PASS, /**< Operation will always pass. */
45 CMPF_LESS, /**< Operation will pass if the new value is less than existing value. */
46 CMPF_LESS_EQUAL, /**< Operation will pass if the new value is less or equal than existing value. */
47 CMPF_EQUAL, /**< Operation will pass if the new value is equal to the existing value. */
48 CMPF_NOT_EQUAL, /**< Operation will pass if the new value is not equal to the existing value. */
49 CMPF_GREATER_EQUAL, /**< Operation will pass if the new value greater or equal than the existing value. */
50 CMPF_GREATER /**< Operation will pass if the new value greater than the existing value. */
51 };
52
53 /**
54 * Types of texture addressing modes that determine what happens when texture coordinates are outside of the valid range.
55 */
56 enum TextureAddressingMode
57 {
58 TAM_WRAP, /**< Coordinates wrap back to the valid range. */
59 TAM_MIRROR, /**< Coordinates flip every time the size of the valid range is passed. */
60 TAM_CLAMP, /**< Coordinates are clamped within the valid range. */
61 TAM_BORDER /**< Coordinates outside of the valid range will return a separately set border color. */
62 };
63
64 /** Types of available filtering situations. */
65 enum FilterType
66 {
67 FT_MIN, /**< The filter used when shrinking a texture. */
68 FT_MAG, /**< The filter used when magnifying a texture. */
69 FT_MIP /**< The filter used when filtering between mipmaps. */
70 };
71
72 /** Filtering options for textures. */
73 enum FilterOptions
74 {
75 FO_NONE = 0, /**< Use no filtering. Only relevant for mipmap filtering. */
76 FO_POINT = 1, /**< Filter using the nearest found pixel. Most basic filtering. */
77 FO_LINEAR = 2, /**< Average a 2x2 pixel area, signifies bilinear filtering for texture, trilinear for mipmaps. */
78 FO_ANISOTROPIC = 3, /**< More advanced filtering that improves quality when viewing textures at a steep angle */
79 };
80
81 /** Types of frame buffers. */
82 enum FrameBufferType
83 {
84 FBT_COLOR = 0x1, /**< Color surface. */
85 FBT_DEPTH = 0x2, /**< Depth surface. */
86 FBT_STENCIL = 0x4 /**< Stencil surface. */
87 };
88
89 /**
90 * Types of culling that determine how (and if) hardware discards faces with certain winding order. Winding order can
91 * be used for determining front or back facing polygons by checking the order of its vertices from the render
92 * perspective.
93 */
94 enum CullingMode
95 {
96 CULL_NONE = 0, /**< Hardware performs no culling and renders both sides. */
97 CULL_CLOCKWISE = 1, /**< Hardware culls faces that have a clockwise vertex ordering. */
98 CULL_COUNTERCLOCKWISE = 2 /**< Hardware culls faces that have a counter-clockwise vertex ordering. */
99 };
100
101 /** Polygon mode to use when rasterizing. */
102 enum PolygonMode
103 {
104 PM_WIREFRAME = 1, /**< Render as wireframe showing only polygon outlines. */
105 PM_SOLID = 2 /**< Render as solid showing whole polygons. */
106 };
107
108 /** Types of action that can happen on the stencil buffer. */
109 enum StencilOperation
110 {
111 SOP_KEEP, /**< Leave the stencil buffer unchanged. */
112 SOP_ZERO, /**< Set the stencil value to zero. */
113 SOP_REPLACE, /**< Replace the stencil value with the reference value. */
114 SOP_INCREMENT, /**< Increase the stencil value by 1, clamping at the maximum value. */
115 SOP_DECREMENT, /**< Decrease the stencil value by 1, clamping at 0. */
116 SOP_INCREMENT_WRAP, /**< Increase the stencil value by 1, wrapping back to 0 when incrementing past the maximum value. */
117 SOP_DECREMENT_WRAP, /**< Decrease the stencil value by 1, wrapping when decrementing 0. */
118 SOP_INVERT /**< Invert the bits of the stencil buffer. */
119 };
120
121 /** Describes operation that will be used for rendering a certain set of vertices. */
122 enum BS_SCRIPT_EXPORT(n:MeshTopology,m:Rendering) DrawOperationType
123 {
124 /** Each vertex represents a point. */
125 DOT_POINT_LIST BS_SCRIPT_EXPORT(n:PointList) = 1,
126 /** Each sequential pair of vertices represent a line. */
127 DOT_LINE_LIST BS_SCRIPT_EXPORT(n:LineList) = 2,
128 /** Each vertex (except the first) forms a line with the previous vertex. */
129 DOT_LINE_STRIP BS_SCRIPT_EXPORT(n:LineStrip) = 3,
130 /** Each sequential 3-tuple of vertices represent a triangle. */
131 DOT_TRIANGLE_LIST BS_SCRIPT_EXPORT(n:TriangleList) = 4,
132 /** Each vertex (except the first two) form a triangle with the previous two vertices. */
133 DOT_TRIANGLE_STRIP BS_SCRIPT_EXPORT(n:TriangleStrip) = 5,
134 /** Each vertex (except the first two) form a triangle with the first vertex and previous vertex. */
135 DOT_TRIANGLE_FAN BS_SCRIPT_EXPORT(n:TriangleFan) = 6
136 };
137
138 /** Type of mesh indices used, used for determining maximum number of vertices in a mesh. */
139 enum BS_SCRIPT_EXPORT(m:Rendering) IndexType
140 {
141 IT_16BIT BS_SCRIPT_EXPORT(n:Index16), /**< 16-bit indices. */
142 IT_32BIT BS_SCRIPT_EXPORT(n:Index32) /**< 32-bit indices. */
143 };
144
145 /** These values represent a hint to the driver when locking a hardware buffer. */
146 enum GpuLockOptions
147 {
148 /**
149 * Allows you to write to the buffer. Can cause a CPU-GPU sync point so avoid using it often (every frame) as
150 * that might limit your performance significantly.
151 */
152 GBL_READ_WRITE,
153 /**
154 * Allows you to write to the buffer. Tells the driver to completely discard the contents of the buffer you are
155 * writing to. The driver will (most likely) internally allocate another buffer with same specifications (which is
156 * fairly fast) and you will avoid CPU-GPU stalls.
157 */
158 GBL_WRITE_ONLY_DISCARD,
159 /**
160 * Allows you to write to the buffer. Tells the driver to discard the contents of the mapped buffer range (but
161 * not the entire buffer like with GBL_WRITE_ONLY_DISCARD). Use this if you plan on overwriting all of the
162 * range. This can help avoid CPU-GPU stalls.
163 */
164 GBL_WRITE_ONLY_DISCARD_RANGE,
165 /** Allows you to read from a buffer. Be aware that reading is usually a very slow operation. */
166 GBL_READ_ONLY,
167 /**
168 * Allows you to write to the buffer. Guarantees the driver that you will not be updating any part of the buffer
169 * that is currently used. This will also avoid CPU-GPU stalls, without requiring you to discard the entire buffer.
170 * However it is hard to guarantee when GPU has finished using a buffer.
171 */
172 GBL_WRITE_ONLY_NO_OVERWRITE,
173 /** Allows you to write to a buffer. */
174 GBL_WRITE_ONLY
175 };
176
177 /** Types of programs that may run on GPU. */
178 enum GpuProgramType
179 {
180 GPT_VERTEX_PROGRAM, /**< Vertex program. */
181 GPT_FRAGMENT_PROGRAM, /**< Fragment(pixel) program. */
182 GPT_GEOMETRY_PROGRAM, /**< Geometry program. */
183 GPT_DOMAIN_PROGRAM, /**< Domain (tesselation evaluation) program. */
184 GPT_HULL_PROGRAM, /**< Hull (tesselation control) program. */
185 GPT_COMPUTE_PROGRAM, /**< Compute program. */
186 GPT_COUNT // Keep at end
187 };
188
189 /**
190 * Values that represent hardware buffer usage. These usually determine in what type of memory is buffer placed in,
191 * however that depends on rendering API.
192 */
193 enum GpuBufferUsage
194 {
195 /**
196 * Signifies that you don't plan on modifying the buffer often (or at all) after creation. Modifying such buffer
197 * will involve a larger performance hit. Mutually exclusive with GBU_DYNAMIC.
198 */
199 GBU_STATIC = 1 << 0,
200 /**
201 * Signifies that you will modify this buffer fairly often (e.g. every frame). Mutually exclusive with GBU_STATIC.
202 */
203 GBU_DYNAMIC = 1 << 1,
204 /** Siginifies that the buffer can be used for arbitrary load/store operations on the GPU. Implies GBU_STATIC. */
205 GBU_LOADSTORE = GBU_STATIC | 1 << 2
206 };
207
208 /** Types of generic GPU buffers that may be attached to GPU programs. */
209 enum GpuBufferType
210 {
211 /** Buffer containing an array of primitives (e.g. float4's). */
212 GBT_STANDARD,
213 /**
214 * Buffer containing an array of structures. Structure parameters can usually be easily accessed from within the
215 * GPU program.
216 */
217 GBT_STRUCTURED,
218 /**
219 * Special type of buffer allowing you to specify arguments for draw operations inside the buffer instead of
220 * providing them directly. Useful when you want to control drawing directly from GPU.
221 */
222 GBT_INDIRECTARGUMENT,
223 };
224
225 /** Types of valid formats used for standard GPU buffers. */
226 enum GpuBufferFormat
227 {
228 BF_16X1F, /**< 1D 16-bit floating-point format. */
229 BF_16X2F, /**< 2D 16-bit floating-point format. */
230 BF_16X4F, /**< 4D 16-bit floating-point format. */
231 BF_32X1F, /**< 1D 32-bit floating-point format. */
232 BF_32X2F, /**< 2D 32-bit floating-point format. */
233 BF_32X3F, /**< 3D 32-bit floating-point format. */
234 BF_32X4F, /**< 4D 32-bit floating-point format. */
235 BF_8X1, /**< 1D 8-bit normalized format. */
236 BF_8X2, /**< 2D 8-bit normalized format. */
237 BF_8X4, /**< 4D 8-bit normalized format. */
238 BF_16X1, /**< 1D 16-bit normalized format. */
239 BF_16X2, /**< 2D 16-bit normalized format. */
240 BF_16X4, /**< 4D 16-bit normalized format. */
241 BF_8X1S, /**< 1D 8-bit signed integer format. */
242 BF_8X2S, /**< 2D 8-bit signed integer format. */
243 BF_8X4S, /**< 4D 8-bit signed integer format. */
244 BF_16X1S, /**< 1D 16-bit signed integer format. */
245 BF_16X2S, /**< 2D 16-bit signed integer format. */
246 BF_16X4S, /**< 4D 16-bit signed integer format. */
247 BF_32X1S, /**< 1D 32-bit signed integer format. */
248 BF_32X2S, /**< 2D 32-bit signed integer format. */
249 BF_32X3S, /**< 3D 32-bit signed integer format. */
250 BF_32X4S, /**< 4D 32-bit signed integer format. */
251 BF_8X1U, /**< 1D 8-bit unsigned integer format. */
252 BF_8X2U, /**< 2D 8-bit unsigned integer format. */
253 BF_8X4U, /**< 4D 8-bit unsigned integer format. */
254 BF_16X1U, /**< 1D 16-bit unsigned integer format. */
255 BF_16X2U, /**< 2D 16-bit unsigned integer format. */
256 BF_16X4U, /**< 4D 16-bit unsigned integer format. */
257 BF_32X1U, /**< 1D 32-bit unsigned integer format. */
258 BF_32X2U, /**< 2D 32-bit unsigned integer format. */
259 BF_32X3U, /**< 3D 32-bit unsigned integer format. */
260 BF_32X4U, /**< 4D 32-bit unsigned integer format. */
261 BF_COUNT, /**< Not a valid format. Keep just before BS_UNKNOWN. */
262 BF_UNKNOWN = 0xffff /**< Unknown format (used for non-standard buffers, like structured or raw. */
263 };
264
265 /** Different types of GPU views that control how GPU sees a hardware buffer. */
266 enum GpuViewUsage
267 {
268 /** Buffer is seen as a default shader resource, used primarily for reading. (for example a texture for sampling) */
269 GVU_DEFAULT = 0x01,
270 /** Buffer is seen as a render target that color pixels will be written to after pixel shader stage. */
271 GVU_RENDERTARGET = 0x02,
272 /** Buffer is seen as a depth stencil target that depth and stencil information is written to. */
273 GVU_DEPTHSTENCIL = 0x04,
274 /** Buffer that allows you to write to any part of it from within a GPU program. */
275 GVU_RANDOMWRITE = 0x08
276 };
277
278 /** Combineable set of bits that describe a set of physical GPU's. */
279 enum GpuDeviceFlags
280 {
281 /**
282 * Use the default set of devices. This may be the primary device or multiple devices. Cannot be used together with
283 * other device flags.
284 */
285 GDF_DEFAULT = 0,
286 /** Use only the primary GPU. */
287 GDF_PRIMARY = 0x01,
288 /** Use the second GPU. */
289 GDF_GPU2 = 0x02,
290 /** Use the third GPU. */
291 GDF_GPU3 = 0x04,
292 /** Use the fourth GPU. */
293 GDF_GPU4 = 0x08,
294 /** Use the fifth GPU. */
295 GDF_GPU5 = 0x10
296 };
297
298 /** Type of a parameter in a GPU program. */
299 enum GpuParamType
300 {
301 GPT_DATA, /**< Raw data type like float, Vector3, Color, etc. */
302 GPT_TEXTURE, /**< Texture type (2D, 3D, cube, etc.) */
303 GPT_BUFFER, /**< Data buffer (raw, structured, etc.) */
304 GPT_SAMPLER /**< Sampler type (2D, 3D, cube, etc.) */
305 };
306
307 /** Type of GPU data parameters that can be used as inputs to a GPU program. */
308 enum GpuParamDataType
309 {
310 GPDT_FLOAT1 = 1, /**< 1D floating point value. */
311 GPDT_FLOAT2 = 2, /**< 2D floating point value. */
312 GPDT_FLOAT3 = 3, /**< 3D floating point value. */
313 GPDT_FLOAT4 = 4, /**< 4D floating point value. */
314 GPDT_MATRIX_2X2 = 11, /**< 2x2 matrix. */
315 GPDT_MATRIX_2X3 = 12, /**< 2x3 matrix. */
316 GPDT_MATRIX_2X4 = 13, /**< 2x4 matrix. */
317 GPDT_MATRIX_3X2 = 14, /**< 3x2 matrix. */
318 GPDT_MATRIX_3X3 = 15, /**< 3x3 matrix. */
319 GPDT_MATRIX_3X4 = 16, /**< 3x4 matrix. */
320 GPDT_MATRIX_4X2 = 17, /**< 4x2 matrix. */
321 GPDT_MATRIX_4X3 = 18, /**< 4x3 matrix. */
322 GPDT_MATRIX_4X4 = 19, /**< 4x4 matrix. */
323 GPDT_INT1 = 20, /**< 1D signed integer value. */
324 GPDT_INT2 = 21, /**< 2D signed integer value. */
325 GPDT_INT3 = 22, /**< 3D signed integer value. */
326 GPDT_INT4 = 23, /**< 4D signed integer value. */
327 GPDT_BOOL = 24, /**< Boolean value. */
328 GPDT_STRUCT = 25, /**< Variable size structure. */
329 GPDT_COLOR = 26, /**< Same as GPDT_FLOAT4, but can be used to better deduce usage. */
330 GPDT_COUNT = 27, // Keep at end before GPDT_UNKNOWN
331 GPDT_UNKNOWN = 0xffff
332 };
333
334 /** Available texture types. */
335 enum BS_SCRIPT_EXPORT(m:Rendering) TextureType
336 {
337 /** One dimensional texture. Just a row of pixels. */
338 TEX_TYPE_1D BS_SCRIPT_EXPORT(n:Texture1D) = 1,
339 /** Two dimensional texture. */
340 TEX_TYPE_2D BS_SCRIPT_EXPORT(n:Texture2D) = 2,
341 /** Three dimensional texture. */
342 TEX_TYPE_3D BS_SCRIPT_EXPORT(n:Texture3D) = 3,
343 /** Texture consisting out of six 2D textures describing an inside of a cube. Allows special sampling. */
344 TEX_TYPE_CUBE_MAP BS_SCRIPT_EXPORT(n:TextureCube) = 4
345 };
346
347 /** Projection type to use by the camera. */
348 enum BS_SCRIPT_EXPORT() ProjectionType
349 {
350 /** Projection type where object size remains constant and parallel lines remain parallel. */
351 PT_ORTHOGRAPHIC BS_SCRIPT_EXPORT(n:Orthographic),
352 /** Projection type that emulates human vision. Objects farther away appear smaller. */
353 PT_PERSPECTIVE BS_SCRIPT_EXPORT(n:Perspective)
354 };
355
356 /** Contains data about a type used for GPU data parameters. */
357 struct GpuParamDataTypeInfo
358 {
359 UINT32 baseTypeSize;
360 UINT32 size;
361 UINT32 alignment;
362 UINT32 numRows;
363 UINT32 numColumns;
364 };
365
366 /** Contains a lookup table for various information of all types used for data GPU parameters. Sizes are in bytes. */
367 struct GpuDataParamInfos
368 {
369 GpuDataParamInfos()
370 {
371 memset(lookup, 0, sizeof(lookup));
372
373 lookup[(UINT32)GPDT_FLOAT1] = { 4, 4, 4, 1, 1 };
374 lookup[(UINT32)GPDT_FLOAT2] = { 4, 8, 8, 1, 2 };
375 lookup[(UINT32)GPDT_FLOAT3] = { 4, 16, 16, 1, 3 };
376 lookup[(UINT32)GPDT_FLOAT4] = { 4, 16, 16, 1, 4 };
377 lookup[(UINT32)GPDT_COLOR] = { 4, 16, 16, 1, 4 };
378 lookup[(UINT32)GPDT_MATRIX_2X2] = { 4, 16, 8, 2, 2 };
379 lookup[(UINT32)GPDT_MATRIX_2X3] = { 4, 32, 16, 2, 3 };
380 lookup[(UINT32)GPDT_MATRIX_2X4] = { 4, 32, 16, 2, 4 };
381 lookup[(UINT32)GPDT_MATRIX_3X2] = { 4, 24, 8, 3, 2 };
382 lookup[(UINT32)GPDT_MATRIX_3X3] = { 4, 48, 16, 3, 3 };
383 lookup[(UINT32)GPDT_MATRIX_3X4] = { 4, 48, 16, 3, 4 };
384 lookup[(UINT32)GPDT_MATRIX_4X2] = { 4, 32, 8, 4, 2 };
385 lookup[(UINT32)GPDT_MATRIX_4X3] = { 4, 64, 16, 4, 3 };
386 lookup[(UINT32)GPDT_MATRIX_4X4] = { 4, 64, 16, 4, 4 };
387 lookup[(UINT32)GPDT_INT1] = { 4, 4, 4, 1, 1 };
388 lookup[(UINT32)GPDT_INT2] = { 4, 8, 8, 1, 2 };
389 lookup[(UINT32)GPDT_INT3] = { 4, 12, 16, 1, 3 };
390 lookup[(UINT32)GPDT_INT4] = { 4, 16, 16, 1, 4 };
391 lookup[(UINT32)GPDT_BOOL] = { 4, 4, 4, 1, 1 };
392 lookup[(UINT32)GPDT_STRUCT] = { 4, 0, 16, 1, 1 };
393 }
394
395 GpuParamDataTypeInfo lookup[GPDT_COUNT];
396 };
397
398 /** Type of GPU object parameters that can be used as inputs to a GPU program. */
399 enum GpuParamObjectType
400 {
401 GPOT_SAMPLER1D = 1, /**< Sampler state for a 1D texture. */
402 GPOT_SAMPLER2D = 2, /**< Sampler state for a 2D texture. */
403 GPOT_SAMPLER3D = 3, /**< Sampler state for a 3D texture. */
404 GPOT_SAMPLERCUBE = 4, /**< Sampler state for a cube texture. */
405 GPOT_SAMPLER2DMS = 5, /**< Sampler state for a 2D texture with multiple samples. */
406 GPOT_TEXTURE1D = 11, /**< 1D texture. */
407 GPOT_TEXTURE2D = 12, /**< 2D texture. */
408 GPOT_TEXTURE3D = 13, /**< 3D texture. */
409 GPOT_TEXTURECUBE = 14, /**< Cube texture. */
410 GPOT_TEXTURE2DMS = 15, /**< 2D texture with multiple samples. */
411 GPOT_BYTE_BUFFER = 32, /**< Buffer containing raw bytes (no interpretation). */
412 GPOT_STRUCTURED_BUFFER = 33, /**< Buffer containing a set of structures. */
413 GPOT_RWTYPED_BUFFER = 41, /**< Read-write buffer containing a set of primitives. */
414 GPOT_RWBYTE_BUFFER = 42, /**< Read-write buffer containing raw bytes (no interpretation). */
415 GPOT_RWSTRUCTURED_BUFFER = 43, /**< Read-write buffer containing a set of structures. */
416 GPOT_RWSTRUCTURED_BUFFER_WITH_COUNTER = 44, /**< Read-write buffer containing a set of structures, with a counter. */
417 GPOT_RWAPPEND_BUFFER = 45, /**< Buffer that can be used for appending data in a stack-like fashion. */
418 GPOT_RWCONSUME_BUFFER = 46, /**< Buffer that can be used for consuming data in a stack-like fashion. */
419 GPOT_RWTEXTURE1D = 50, /**< 1D texture with unordered read/writes. */
420 GPOT_RWTEXTURE2D = 51, /**< 2D texture with unordered read/writes. */
421 GPOT_RWTEXTURE3D = 52, /**< 3D texture with unordered read/writes. */
422 GPOT_RWTEXTURE2DMS = 53, /**< 2D texture with multiple samples and unordered read/writes. */
423 GPOT_TEXTURE1DARRAY = 54, /**< 1D texture with multiple array entries. */
424 GPOT_TEXTURE2DARRAY = 55, /**< 2D texture with multiple array entries. */
425 GPOT_TEXTURECUBEARRAY = 56, /**< Cubemap texture with multiple array entries. */
426 GPOT_TEXTURE2DMSARRAY = 57, /**< 2D texture with multiple samples and array entries. */
427 GPOT_RWTEXTURE1DARRAY = 58, /**< 1D texture with multiple array entries and unordered read/writes. */
428 GPOT_RWTEXTURE2DARRAY = 59, /**< 2D texture with multiple array entries and unordered read/writes. */
429 GPOT_RWTEXTURE2DMSARRAY = 60, /**< 2D texture with multiple array entries, samples and unordered read/writes. */
430 GPOT_UNKNOWN = 0xffff
431 };
432
433 /** Types of GPU queues. */
434 enum GpuQueueType
435 {
436 /**
437 * Queue used for rendering. Allows the use of draw commands, but also all commands supported by compute
438 * or upload buffers.
439 */
440 GQT_GRAPHICS,
441 /** Discrete queue used for compute operations. Allows the use of dispatch and upload commands. */
442 GQT_COMPUTE,
443 /** Queue used for memory transfer operations only. No rendering or compute dispatch allowed. */
444 GQT_UPLOAD,
445 GQT_COUNT // Keep at end
446 };
447
448 /** These values represent a hint to the driver when writing to a GPU buffer. */
449 enum BufferWriteType
450 {
451 /**
452 * Default flag with least restrictions. Can cause a CPU-GPU sync point so avoid using it often (every frame)
453 * as that might limit your performance significantly.
454 */
455 BWT_NORMAL,
456 /**
457 * Tells the driver to completely discard the contents of the buffer you are writing to. The driver will (most
458 * likely) internally allocate another buffer with same specifications (which is fairly fast) and you will avoid
459 * CPU-GPU stalls.
460 */
461 BWT_DISCARD,
462 /**
463 * Guarantees the driver that you will not be updating any part of the buffer that is currently used. This will
464 * also avoid CPU-GPU stalls, without requiring you to discard the entire buffer. However it is hard to guarantee
465 * when GPU has finished using a buffer.
466 */
467 BTW_NO_OVERWRITE
468 };
469
470 /**
471 * Suggested queue priority numbers used for sorting objects in the render queue. Objects with higher priority will
472 * be renderer sooner.
473 */
474 enum class QueuePriority
475 {
476 Opaque = 100000,
477 Transparent = 90000,
478 Skybox = 80000,
479 Overlay = 70000
480 };
481
482 /** Type of sorting to perform on an object when added to a render queue. */
483 enum class QueueSortType
484 {
485 FrontToBack, /**< All objects with the same priority will be rendered front to back based on their center. */
486 BackToFront, /**< All objects with the same priority will be rendered back to front based on their center. */
487 None /**< Objects will not be sorted and will be processed in the order they were added to the queue. */
488 };
489
490 /** Flags that may be assigned to a shader that let the renderer know how to interpret the shader. */
491 enum class ShaderFlag
492 {
493 Transparent = 0x1, /**< Signifies that the shader is rendering a transparent object. */
494 Forward = 0x2 /**< Signifies the shader should use the forward rendering pipeline, if relevant. */
495 };
496
497 typedef Flags<ShaderFlag> ShaderFlags;
498 BS_FLAGS_OPERATORS(ShaderFlag)
499
500 /** Valid types of a mesh used for physics. */
501 enum class BS_SCRIPT_EXPORT() PhysicsMeshType
502 {
503 /**
504 * A regular triangle mesh. Mesh can be of arbitrary size but cannot be used for triggers and non-kinematic
505 * objects. Incurrs a significantly larger performance impact than convex meshes.
506 */
507 Triangle,
508 /**
509 * Mesh representing a convex shape. Mesh will not have more than 256 vertices. Incurrs a significantly lower
510 * performance impact than triangle meshes.
511 */
512 Convex
513 };
514
515 /** Determines the type of the source image for generating cubemaps. */
516 enum class BS_SCRIPT_EXPORT(m:Utility,api:bsf,api:bed) CubemapSourceType
517 {
518 /** Source is a single image that will be replicated on all cubemap faces. */
519 Single,
520
521 /**
522 * Source is a list of 6 images, either sequentially next to each other or in a cross format. The system will
523 * automatically guess the layout and orientation based on the aspect ratio.
524 */
525 Faces,
526
527 /** Source is a single spherical panoramic image. */
528 Spherical,
529
530 /** Source is a single cylindrical panoramic image. */
531 Cylindrical
532 };
533
534 /** Names of individual components of a vector. */
535 enum class BS_SCRIPT_EXPORT(m:Utility) VectorComponent
536 {
537 X, Y, Z, W
538 };
539
540 /** Names of individual components of a color. */
541 enum class BS_SCRIPT_EXPORT(m:Utility) ColorComponent
542 {
543 R, G, B, A
544 };
545
546 /** Identifiers representing a range of values. */
547 enum class BS_SCRIPT_EXPORT(m:Utility) RangeComponent
548 {
549 Min, Max
550 };
551
552 /**
553 * Bits that map to a specific surface of a render target. Combine the bits to generate a mask that references
554 * only specific render target surfaces.
555 */
556 enum RenderSurfaceMaskBits
557 {
558 RT_NONE = 0,
559 RT_COLOR0 = 1 << 0,
560 RT_COLOR1 = 1 << 1,
561 RT_COLOR2 = 1 << 2,
562 RT_COLOR3 = 1 << 3,
563 RT_COLOR4 = 1 << 4,
564 RT_COLOR5 = 1 << 5,
565 RT_COLOR6 = 1 << 6,
566 RT_COLOR7 = 1 << 7,
567 RT_DEPTH = 1 << 30,
568 RT_STENCIL = 1 << 31,
569 RT_DEPTH_STENCIL = (1 << 30) | (1 << 31),
570 RT_ALL = 0xFFFFFFFF
571 };
572
573 typedef Flags<RenderSurfaceMaskBits> RenderSurfaceMask;
574 BS_FLAGS_OPERATORS(RenderSurfaceMaskBits);
575
576 /**
577 * Controls what kind of mobility restrictions a scene object has. This is used primarily as a performance hint to
578 * other systems. Generally the more restricted the mobility the higher performance can be achieved.
579 */
580 enum class BS_SCRIPT_EXPORT() ObjectMobility
581 {
582 /** Scene object can be moved and has no mobility restrictions. */
583 Movable,
584 /**
585 * Scene object isn't allowed to be moved but is allowed to be visually changed in other ways (e.g. changing the
586 * displayed mesh or light intensity (depends on attached components).
587 */
588 Immovable,
589 /** Scene object isn't allowed to be moved nor is it allowed to be visually changed. Object must be fully static. */
590 Static
591 };
592
593 /** Texture addressing mode, per component. */
594 struct UVWAddressingMode
595 {
596 UVWAddressingMode()
597 :u(TAM_WRAP), v(TAM_WRAP), w(TAM_WRAP)
598 { }
599
600 bool operator==(const UVWAddressingMode& rhs) const
601 {
602 return u == rhs.u && v == rhs.v && w == rhs.w;
603 }
604
605 TextureAddressingMode u, v, w;
606 };
607
608 /** References a subset of surfaces within a texture. */
609 struct BS_SCRIPT_EXPORT(m:Rendering,pl:true) TextureSurface
610 {
611 TextureSurface(UINT32 mipLevel = 0, UINT32 numMipLevels = 1, UINT32 face = 0, UINT32 numFaces = 1)
612 :mipLevel(mipLevel), numMipLevels(numMipLevels), face(face), numFaces(numFaces)
613 { }
614
615 /** First mip level to reference. */
616 UINT32 mipLevel;
617
618 /** Number of mip levels to reference. Must be greater than zero. */
619 UINT32 numMipLevels;
620
621 /**
622 * First face to reference. Face can represent a single cubemap face, or a single array entry in a
623 * texture array. If cubemaps are laid out in a texture array then every six sequential faces represent a single
624 * array entry.
625 */
626 UINT32 face;
627
628 /** Number of faces to reference, if the texture has more than one. */
629 UINT32 numFaces;
630
631 /** Surface that covers all texture sub-resources. */
632 static BS_CORE_EXPORT const TextureSurface COMPLETE;
633 };
634
635 /** Meta-data describing a chunk of audio. */
636 struct AudioDataInfo
637 {
638 UINT32 numSamples; /**< Total number of audio samples in the audio data (includes all channels). */
639 UINT32 sampleRate; /**< Number of audio samples per second, per channel. */
640 UINT32 numChannels; /**< Number of channels. Each channel has its own set of samples. */
641 UINT32 bitDepth; /**< Number of bits per sample. */
642 };
643
644 /** Helper class for syncing dirty data from sim CoreObject to core CoreObject and other way around. */
645 class CoreSyncData
646 {
647 public:
648 CoreSyncData()
649 :data(nullptr), size(0)
650 { }
651
652 CoreSyncData(UINT8* data, UINT32 size)
653 :data(data), size(size)
654 { }
655
656 /** Gets the internal data and checks the data is of valid size. */
657 template<class T>
658 const T& getData() const
659 {
660 assert(sizeof(T) == size);
661
662 return *(T*)data;
663 }
664
665 /** Returns a pointer to internal data buffer. */
666 UINT8* getBuffer() const { return data; }
667
668 /** Returns the size of the internal data buffer. */
669 UINT32 getBufferSize() const { return size; }
670
671 private:
672 UINT8* data;
673 UINT32 size;
674 };
675
676 /** @cond SPECIALIZATIONS */
677 BS_ALLOW_MEMCPY_SERIALIZATION(TextureSurface);
678 /** @endcond */
679
680 /** @} */
681}