Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: command_buffer/common/cross/resource.h

Issue 234002: More work in Command Buffers... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « command_buffer/common/cross/gapi_interface.h ('k') | command_buffer/common/cross/resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 28 matching lines...) Expand all
39 #include <algorithm> 39 #include <algorithm>
40 #include "base/basictypes.h" 40 #include "base/basictypes.h"
41 #include "base/scoped_ptr.h" 41 #include "base/scoped_ptr.h"
42 #include "command_buffer/common/cross/types.h" 42 #include "command_buffer/common/cross/types.h"
43 #include "command_buffer/common/cross/logging.h" 43 #include "command_buffer/common/cross/logging.h"
44 44
45 namespace o3d { 45 namespace o3d {
46 namespace command_buffer { 46 namespace command_buffer {
47 47
48 // A resource ID, key to the resource maps. 48 // A resource ID, key to the resource maps.
49 // TODO(gman): Shouldn't this be a uint32? 49 typedef uint32 ResourceId;
50 typedef unsigned int ResourceID;
51 // Invalid resource ID. 50 // Invalid resource ID.
52 static const ResourceID kInvalidResource = 0xffffffffU; 51 static const ResourceId kInvalidResource = 0xffffffffU;
53 52
54 namespace vertex_buffer { 53 namespace vertex_buffer {
55 // Vertex buffer flags. 54 // Vertex buffer flags.
56 enum Flags { 55 enum Flags {
57 DYNAMIC = 0x01, // This vertex buffer is dynamic and is expected to have 56 kNone = 0x00,
58 // its data updated often. 57 kDynamic = 0x01, // This vertex buffer is dynamic and is expected to have
58 // its data updated often.
59 }; 59 };
60 } // namespace vertex_buffer 60 } // namespace vertex_buffer
61 61
62 namespace index_buffer { 62 namespace index_buffer {
63 // Index buffer flags. 63 // Index buffer flags.
64 enum Flags { 64 enum Flags {
65 DYNAMIC = 0x01, // This index buffer is dynamic and is expected to have 65 kNone = 0x00,
66 // its data updated often. 66 kDynamic = 0x01, // This index buffer is dynamic and is expected to have
67 INDEX_32BIT = 0x02, // Indices contained in this index buffer are 32 bits 67 // its data updated often.
68 kIndex32Bit = 0x02, // Indices contained in this index buffer are 32 bits
68 // (unsigned int) instead of 16 bit (unsigned short). 69 // (unsigned int) instead of 16 bit (unsigned short).
69 }; 70 };
70 } // namespace index_buffer 71 } // namespace index_buffer
71 72
72 namespace vertex_struct { 73 namespace vertex_struct {
73 // Semantics for input data. 74 // Semantics for input data.
74 enum Semantic { 75 enum Semantic {
75 UNKNOWN_SEMANTIC = -1, 76 kUnknownSemantic = -1,
76 POSITION = 0, 77 kPosition = 0,
77 NORMAL, 78 kNormal,
78 COLOR, 79 kColor,
79 TEX_COORD, 80 kTexCoord,
80 NUM_SEMANTICS 81 kNumSemantics
81 }; 82 };
82 83
83 // Input data types. 84 // Input data types.
84 enum Type { 85 enum Type {
85 FLOAT1, 86 kFloat1,
86 FLOAT2, 87 kFloat2,
87 FLOAT3, 88 kFloat3,
88 FLOAT4, 89 kFloat4,
89 UCHAR4N, 90 kUChar4N,
90 NUM_TYPES 91 kNumTypes
91 }; 92 };
92 } // namespace vertex_struct 93 } // namespace vertex_struct
93 94
94 namespace effect_param { 95 namespace effect_param {
95 enum DataType { 96 enum DataType {
96 UNKNOWN, // A parameter exists in the effect, but the type is not 97 kUnknown, // A parameter exists in the effect, but the type is not
97 // representable (e.g. MATRIX3x4). 98 // representable (e.g. MATRIX3x4).
98 FLOAT1, 99 kFloat1,
99 FLOAT2, 100 kFloat2,
100 FLOAT3, 101 kFloat3,
101 FLOAT4, 102 kFloat4,
102 MATRIX4, 103 kMatrix4,
103 INT, 104 kInt,
104 BOOL, 105 kBool,
105 SAMPLER, 106 kSampler,
106 TEXTURE, 107 kTexture,
107 NUM_TYPES, 108 kNumTypes,
108 MAKE_32_BIT = 0x7fffffff, 109 kMake32Bit = 0x7fffffff,
109 }; 110 };
110 COMPILE_ASSERT(sizeof(DataType) == 4, DataType_should_be_32_bits); 111 COMPILE_ASSERT(sizeof(DataType) == 4, DataType_should_be_32_bits);
111 112
112 // Gets the size of the data of a particular type. 113 // Gets the size of the data of a particular type.
113 unsigned int GetDataSize(DataType type); 114 unsigned int GetDataSize(DataType type);
114 115
115 // Structure describing a parameter, filled in by the 116 // Structure describing a parameter, filled in by the
116 // GAPIInterface::GetParamDesc call. 117 // GAPIInterface::GetParamDesc call.
117 struct Desc { 118 struct Desc {
118 Uint32 size; // the total memory size needed for the complete 119 Uint32 size; // the total memory size needed for the complete
(...skipping 15 matching lines...) Expand all
134 Uint32 num_elements; // the number of entries if the parameter is an array 135 Uint32 num_elements; // the number of entries if the parameter is an array
135 // 0 otherwise. 136 // 0 otherwise.
136 DataType data_type; // the data type of the parameter. 137 DataType data_type; // the data type of the parameter.
137 Uint32 data_size; // the size of the parameter data, in bytes. 138 Uint32 data_size; // the size of the parameter data, in bytes.
138 }; 139 };
139 } // namespace effect_param 140 } // namespace effect_param
140 141
141 namespace effect_stream { 142 namespace effect_stream {
142 struct Desc { 143 struct Desc {
143 Desc() 144 Desc()
144 : semantic(vertex_struct::UNKNOWN_SEMANTIC), 145 : semantic(vertex_struct::kUnknownSemantic),
145 semantic_index(0) {} 146 semantic_index(0) {}
146 Desc(Uint32 semantic, Uint32 semantic_index) 147 Desc(Uint32 semantic, Uint32 semantic_index)
147 : semantic(semantic), 148 : semantic(semantic),
148 semantic_index(semantic_index) {} 149 semantic_index(semantic_index) {}
149 Uint32 semantic; // the semantic type 150 Uint32 semantic; // the semantic type
150 Uint32 semantic_index; 151 Uint32 semantic_index;
151 }; 152 };
152 } // namespace effect_stream 153 } // namespace effect_stream
153 154
154 namespace texture { 155 namespace texture {
155 // Texture flags. 156 // Texture flags.
156 enum Flags { 157 enum Flags {
157 DYNAMIC = 0x01, // This texture is dynamic and is expected to have 158 kNone = 0x00,
158 // its data updated often. 159 kDynamic = 0x01, // This texture is dynamic and is expected to have
160 // its data updated often.
159 }; 161 };
160 162
161 // Texel formats. 163 // Texel formats.
162 enum Format { 164 enum Format {
163 XRGB8, 165 kXRGB8,
164 ARGB8, 166 kARGB8,
165 ABGR16F, 167 kABGR16F,
166 DXT1, 168 kDXT1,
167 NUM_FORMATS 169 kNumFormats
168 }; 170 };
169 171
170 // Texture type. 172 // Texture type.
171 enum Type { 173 enum Type {
172 TEXTURE_2D, 174 kTexture2d,
173 TEXTURE_3D, 175 kTexture3d,
174 TEXTURE_CUBE, 176 kTextureCube,
175 }; 177 };
176 178
177 // Cube map face. 179 // Cube map face.
178 enum Face { 180 enum Face {
179 FACE_POSITIVE_X, 181 kFacePositiveX,
180 FACE_NEGATIVE_X, 182 kFaceNegativeX,
181 FACE_POSITIVE_Y, 183 kFacePositiveY,
182 FACE_NEGATIVE_Y, 184 kFaceNegativeY,
183 FACE_POSITIVE_Z, 185 kFacePositiveZ,
184 FACE_NEGATIVE_Z, 186 kFaceNegativeZ,
187 kFaceNone = kFacePositiveX, // For non-cube maps.
185 }; 188 };
186 189
187 // Gets the number of bytes per block for a given texture format. For most 190 // Gets the number of bytes per block for a given texture format. For most
188 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks. 191 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks.
189 unsigned int GetBytesPerBlock(Format format); 192 unsigned int GetBytesPerBlock(Format format);
190 // Gets the x dimension of a texel block for a given texture format. For most 193 // Gets the x dimension of a texel block for a given texture format. For most
191 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks. 194 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks.
192 unsigned int GetBlockSizeX(Format format); 195 unsigned int GetBlockSizeX(Format format);
193 // Gets the y dimension of a texel block for a given texture format. For most 196 // Gets the y dimension of a texel block for a given texture format. For most
194 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks. 197 // texture formats, a block is 1x1 texels, but DXT* formats have 4x4 blocks.
195 unsigned int GetBlockSizeY(Format format); 198 unsigned int GetBlockSizeY(Format format);
196 // Gets the dimension of a mipmap level given the dimension of the base 199 // Gets the dimension of a mipmap level given the dimension of the base
197 // level. Every mipmap level is half the size of the previous level, rounding 200 // level. Every mipmap level is half the size of the previous level, rounding
198 // down. 201 // down.
199 static unsigned int GetMipMapDimension(unsigned int base, 202 static unsigned int GetMipMapDimension(unsigned int base,
200 unsigned int level) { 203 unsigned int level) {
201 DCHECK_GT(base, 0U); 204 DCHECK_GT(base, 0U);
202 return std::max(1U, base >> level); 205 return std::max(1U, base >> level);
203 } 206 }
204 } // namespace texture 207 } // namespace texture
205 208
206 namespace sampler { 209 namespace sampler {
207 enum AddressingMode { 210 enum AddressingMode {
208 WRAP, 211 kWrap,
209 MIRROR_REPEAT, 212 kMirrorRepeat,
210 CLAMP_TO_EDGE, 213 kClampToEdge,
211 CLAMP_TO_BORDER, 214 kClampToBorder,
212 NUM_ADDRESSING_MODE 215 kNumAddressingMode
213 }; 216 };
214 217
215 enum FilteringMode { 218 enum FilteringMode {
216 NONE, 219 kNone,
217 POINT, 220 kPoint,
218 LINEAR, 221 kLinear,
219 NUM_FILTERING_MODE 222 kNumFilteringMode
220 }; 223 };
221 } // namespace sampler 224 } // namespace sampler
222 225
223 } // namespace command_buffer 226 } // namespace command_buffer
224 } // namespace o3d 227 } // namespace o3d
225 228
226 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_RESOURCE_H_ 229 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_RESOURCE_H_
OLDNEW
« no previous file with comments | « command_buffer/common/cross/gapi_interface.h ('k') | command_buffer/common/cross/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698