st/dri: Use packed RGB formats
[mesa.git] / src / gallium / state_trackers / clover / core / module.hpp
1 //
2 // Copyright 2012 Francisco Jerez
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
21 //
22
23 #ifndef CLOVER_CORE_MODULE_HPP
24 #define CLOVER_CORE_MODULE_HPP
25
26 #include <vector>
27 #include <string>
28
29 namespace clover {
30 struct module {
31 typedef uint32_t resource_id;
32 typedef uint32_t size_t;
33
34 struct section {
35 enum type {
36 text,
37 data_constant,
38 data_global,
39 data_local,
40 data_private
41 };
42
43 section(resource_id id, enum type type, size_t size,
44 const std::vector<char> &data) :
45 id(id), type(type), size(size), data(data) { }
46 section() : id(0), type(text), size(0), data() { }
47
48 resource_id id;
49 type type;
50 size_t size;
51 std::vector<char> data;
52 };
53
54 struct argument {
55 enum type {
56 scalar,
57 constant,
58 global,
59 local,
60 image2d_rd,
61 image2d_wr,
62 image3d_rd,
63 image3d_wr,
64 sampler
65 };
66
67 enum ext_type {
68 zero_ext,
69 sign_ext
70 };
71
72 enum semantic {
73 general,
74 grid_dimension,
75 grid_offset,
76 image_size,
77 image_format
78 };
79
80 argument(enum type type, size_t size,
81 size_t target_size, size_t target_align,
82 enum ext_type ext_type,
83 enum semantic semantic = general) :
84 type(type), size(size),
85 target_size(target_size), target_align(target_align),
86 ext_type(ext_type), semantic(semantic) { }
87
88 argument(enum type type, size_t size) :
89 type(type), size(size),
90 target_size(size), target_align(1),
91 ext_type(zero_ext), semantic(general) { }
92
93 argument() : type(scalar), size(0),
94 target_size(0), target_align(1),
95 ext_type(zero_ext), semantic(general) { }
96
97 type type;
98 size_t size;
99 size_t target_size;
100 size_t target_align;
101 ext_type ext_type;
102 semantic semantic;
103 };
104
105 struct symbol {
106 symbol(const std::string &name, resource_id section,
107 size_t offset, const std::vector<argument> &args) :
108 name(name), section(section), offset(offset), args(args) { }
109 symbol() : name(), section(0), offset(0), args() { }
110
111 std::string name;
112 resource_id section;
113 size_t offset;
114 std::vector<argument> args;
115 };
116
117 void serialize(std::ostream &os) const;
118 static module deserialize(std::istream &is);
119 size_t size() const;
120
121 std::vector<symbol> syms;
122 std::vector<section> secs;
123 };
124 }
125
126 #endif