forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpuCommand.h
More file actions
89 lines (74 loc) · 2.88 KB
/
gpuCommand.h
File metadata and controls
89 lines (74 loc) · 2.88 KB
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
/**
*
* RenderPipeline
*
* Copyright (c) 2014-2016 tobspr <tobias.springer1@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef GPUCOMMAND_H
#define GPUCOMMAND_H
#include "pandabase.h"
#include "luse.h"
NotifyCategoryDecl(gpucommand, EXPORT_CLASS, EXPORT_TEMPL);
#define GPU_COMMAND_ENTRIES 32
// Packs integers by storing their binary representation in floats
// This only works if the command and light buffer is 32bit floating point.
#define PACK_INT_AS_FLOAT 0
/**
* @brief Class for storing data to be transferred to the GPU.
* @details This class can be seen like a packet, to be transferred to the GPU.
* It has a command type, which tells the GPU what to do once it recieved this
* "packet". It stores a limited amount of floating point components.
*/
class GPUCommand {
PUBLISHED:
/**
* The different types of GPUCommands. Each type has a special case in
* the command queue processor. When adding new types, those need to
* be handled in the command target, too.
*/
enum CommandType {
CMD_invalid = 0,
CMD_store_light = 1,
CMD_remove_light = 2,
CMD_store_source = 3,
CMD_remove_sources = 4,
};
GPUCommand(CommandType command_type);
inline void push_int(int v);
inline void push_float(float v);
inline void push_vec3(const LVecBase3 &v);
inline void push_vec3(const LVecBase3i &v);
inline void push_vec4(const LVecBase4 &v);
inline void push_vec4(const LVecBase4i &v);
inline void push_mat3(const LMatrix3 &v);
inline void push_mat4(const LMatrix4 &v);
inline static bool get_uses_integer_packing();
void write_to(const PTA_uchar &dest, size_t command_index);
void write(std::ostream &out) const;
private:
inline float convert_int_to_float(int v) const;
CommandType _command_type;
size_t _current_index;
float _data[GPU_COMMAND_ENTRIES];
};
#include "gpuCommand.I"
#endif // GPUCOMMAND_H