-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathgpu-printing-ops.h
55 lines (48 loc) · 1.56 KB
/
gpu-printing-ops.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
// gpu-printing-op.h
// This file defines the various opcodes that
// will be used for GPU printing commands.
//
// Because the CPU will be doing printing on
// behalf of the GPU, the two processors need
// to agree on the values of these opcodes.
// Therefore we have set up this file to be
// included into both the C++ `gpu-printing.cpp`
// implementation and the Slang `printing.slang`
// file.
//
// Client code should defiine the `GPU_PRINTING_OP`
// macro appropriately, before including this file.
//
#ifndef GPU_PRINTING_OP
#error "Must define 'GPU_PRINTING_OP(NAME)' before including"
#endif
// The `Nop` opcode is used to represent a vacuous
// printing command that does nothing.
//
// It's main purpose is to allow GPU code to zero
// out parts of the printing buffer to disable
// or shorten a printing command that was started.
//
GPU_PRINTING_OP(Nop)
// The `NewLine` command is a compact way to
// print a newline character (`\n`)
GPU_PRINTING_OP(NewLine)
// Simple value types like `int`, `uint`, and `float`
// can have their own printing commands for when
// they will be printed directly.
//
GPU_PRINTING_OP(Int32)
GPU_PRINTING_OP(UInt32)
GPU_PRINTING_OP(Float32)
// String values are encoded in the print buffer as
// a 32-bit hash code, and are thus similar to
// the simple value cases in practice.
//
GPU_PRINTING_OP(String)
// The final opcode we define is a complex `printf()`
// style operation that combines a format string with
// a variable amount of argument data to be referenced
// by that format string.
//
GPU_PRINTING_OP(PrintF)
#undef GPU_PRINTING_OP