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

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

Issue 329046: Splits the command buffers into common commands... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 1 month 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 namespace o3d { 67 namespace o3d {
68 68
69 // This macro is used to safely and convienently expand the list of commnad 69 // This macro is used to safely and convienently expand the list of commnad
70 // buffer commands in to various lists and never have them get out of sync. To 70 // buffer commands in to various lists and never have them get out of sync. To
71 // add a new command, add it this list, create the corresponding structure below 71 // add a new command, add it this list, create the corresponding structure below
72 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where 72 // and then add a function in gapi_decoder.cc called Handle_COMMAND_NAME where
73 // COMMAND_NAME is the name of your command structure. 73 // COMMAND_NAME is the name of your command structure.
74 // 74 //
75 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order) 75 // NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order)
76 #define O3D_COMMAND_BUFFER_CMDS(OP) \ 76 #define O3D_COMMAND_BUFFER_CMDS(OP) \
77 OP(Noop) /* 1024 */ \ 77 OP(BeginFrame) /* 1024 */ \
78 OP(SetToken) /* 1025 */ \ 78 OP(EndFrame) /* 1025 */ \
79 OP(BeginFrame) /* 1026 */ \ 79 OP(Clear) /* 1026 */ \
80 OP(EndFrame) /* 1027 */ \ 80 OP(CreateVertexBuffer) /* 1027 */ \
81 OP(Clear) /* 1028 */ \ 81 OP(DestroyVertexBuffer) /* 1028 */ \
82 OP(CreateVertexBuffer) /* 1029 */ \ 82 OP(SetVertexBufferData) /* 1029 */ \
83 OP(DestroyVertexBuffer) /* 1030 */ \ 83 OP(SetVertexBufferDataImmediate) /* 1030 */ \
84 OP(SetVertexBufferData) /* 1031 */ \ 84 OP(GetVertexBufferData) /* 1031 */ \
85 OP(SetVertexBufferDataImmediate) /* 1032 */ \ 85 OP(CreateIndexBuffer) /* 1032 */ \
86 OP(GetVertexBufferData) /* 1033 */ \ 86 OP(DestroyIndexBuffer) /* 1033 */ \
87 OP(CreateIndexBuffer) /* 1034 */ \ 87 OP(SetIndexBufferData) /* 1034 */ \
88 OP(DestroyIndexBuffer) /* 1035 */ \ 88 OP(SetIndexBufferDataImmediate) /* 1035 */ \
89 OP(SetIndexBufferData) /* 1036 */ \ 89 OP(GetIndexBufferData) /* 1036 */ \
90 OP(SetIndexBufferDataImmediate) /* 1037 */ \ 90 OP(CreateVertexStruct) /* 1037 */ \
91 OP(GetIndexBufferData) /* 1038 */ \ 91 OP(DestroyVertexStruct) /* 1038 */ \
92 OP(CreateVertexStruct) /* 1039 */ \ 92 OP(SetVertexInput) /* 1039 */ \
93 OP(DestroyVertexStruct) /* 1040 */ \ 93 OP(SetVertexStruct) /* 1040 */ \
94 OP(SetVertexInput) /* 1041 */ \ 94 OP(Draw) /* 1041 */ \
95 OP(SetVertexStruct) /* 1042 */ \ 95 OP(DrawIndexed) /* 1042 */ \
96 OP(Draw) /* 1043 */ \ 96 OP(CreateEffect) /* 1043 */ \
97 OP(DrawIndexed) /* 1044 */ \ 97 OP(CreateEffectImmediate) /* 1044 */ \
98 OP(CreateEffect) /* 1045 */ \ 98 OP(DestroyEffect) /* 1045 */ \
99 OP(CreateEffectImmediate) /* 1046 */ \ 99 OP(SetEffect) /* 1046 */ \
100 OP(DestroyEffect) /* 1047 */ \ 100 OP(GetParamCount) /* 1047 */ \
101 OP(SetEffect) /* 1048 */ \ 101 OP(CreateParam) /* 1048 */ \
102 OP(GetParamCount) /* 1049 */ \ 102 OP(CreateParamByName) /* 1049 */ \
103 OP(CreateParam) /* 1050 */ \ 103 OP(CreateParamByNameImmediate) /* 1050 */ \
104 OP(CreateParamByName) /* 1051 */ \ 104 OP(DestroyParam) /* 1051 */ \
105 OP(CreateParamByNameImmediate) /* 1052 */ \ 105 OP(SetParamData) /* 1052 */ \
106 OP(DestroyParam) /* 1053 */ \ 106 OP(SetParamDataImmediate) /* 1053 */ \
107 OP(SetParamData) /* 1054 */ \ 107 OP(GetParamDesc) /* 1054 */ \
108 OP(SetParamDataImmediate) /* 1055 */ \ 108 OP(GetStreamCount) /* 1055 */ \
109 OP(GetParamDesc) /* 1056 */ \ 109 OP(GetStreamDesc) /* 1056 */ \
110 OP(GetStreamCount) /* 1057 */ \ 110 OP(DestroyTexture) /* 1057 */ \
111 OP(GetStreamDesc) /* 1058 */ \ 111 OP(CreateTexture2d) /* 1058 */ \
112 OP(DestroyTexture) /* 1059 */ \ 112 OP(CreateTexture3d) /* 1059 */ \
113 OP(CreateTexture2d) /* 1060 */ \ 113 OP(CreateTextureCube) /* 1060 */ \
114 OP(CreateTexture3d) /* 1061 */ \ 114 OP(SetTextureData) /* 1061 */ \
115 OP(CreateTextureCube) /* 1062 */ \ 115 OP(SetTextureDataImmediate) /* 1062 */ \
116 OP(SetTextureData) /* 1063 */ \ 116 OP(GetTextureData) /* 1063 */ \
117 OP(SetTextureDataImmediate) /* 1064 */ \ 117 OP(CreateSampler) /* 1064 */ \
118 OP(GetTextureData) /* 1065 */ \ 118 OP(DestroySampler) /* 1065 */ \
119 OP(CreateSampler) /* 1066 */ \ 119 OP(SetSamplerStates) /* 1066 */ \
120 OP(DestroySampler) /* 1067 */ \ 120 OP(SetSamplerBorderColor) /* 1067 */ \
121 OP(SetSamplerStates) /* 1068 */ \ 121 OP(SetSamplerTexture) /* 1068 */ \
122 OP(SetSamplerBorderColor) /* 1069 */ \ 122 OP(SetViewport) /* 1069 */ \
123 OP(SetSamplerTexture) /* 1070 */ \ 123 OP(SetScissor) /* 1070 */ \
124 OP(SetViewport) /* 1071 */ \ 124 OP(SetPointLineRaster) /* 1071 */ \
125 OP(SetScissor) /* 1072 */ \ 125 OP(SetPolygonRaster) /* 1072 */ \
126 OP(SetPointLineRaster) /* 1073 */ \ 126 OP(SetPolygonOffset) /* 1073 */ \
127 OP(SetPolygonRaster) /* 1074 */ \ 127 OP(SetAlphaTest) /* 1074 */ \
128 OP(SetPolygonOffset) /* 1075 */ \ 128 OP(SetDepthTest) /* 1075 */ \
129 OP(SetAlphaTest) /* 1076 */ \ 129 OP(SetStencilTest) /* 1076 */ \
130 OP(SetDepthTest) /* 1077 */ \ 130 OP(SetBlending) /* 1077 */ \
131 OP(SetStencilTest) /* 1078 */ \ 131 OP(SetBlendingColor) /* 1078 */ \
132 OP(SetBlending) /* 1079 */ \ 132 OP(SetColorWrite) /* 1079 */ \
133 OP(SetBlendingColor) /* 1080 */ \ 133 OP(CreateRenderSurface) /* 1080 */ \
134 OP(SetColorWrite) /* 1081 */ \ 134 OP(DestroyRenderSurface) /* 1081 */ \
135 OP(CreateRenderSurface) /* 1082 */ \ 135 OP(CreateDepthSurface) /* 1082 */ \
136 OP(DestroyRenderSurface) /* 1083 */ \ 136 OP(DestroyDepthSurface) /* 1083 */ \
137 OP(CreateDepthSurface) /* 1084 */ \ 137 OP(SetRenderSurface) /* 1084 */ \
138 OP(DestroyDepthSurface) /* 1085 */ \ 138 OP(SetBackSurfaces) /* 1085 */ \
139 OP(SetRenderSurface) /* 1086 */ \
140 OP(SetBackSurfaces) /* 1087 */ \
141 139
142 140
143 // GAPI commands. 141 // GAPI commands.
144 enum CommandId { 142 enum CommandId {
145 // kStartPoint = cmd::kLastCommonId, // All O3D commands start after this. 143 kStartPoint = cmd::kLastCommonId, // All O3D commands start after this.
146 #define O3D_COMMAND_BUFFER_CMD_OP(name) k ## name, 144 #define O3D_COMMAND_BUFFER_CMD_OP(name) k ## name,
147 145
148 O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP) 146 O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
149 147
150 #undef O3D_COMMAND_BUFFER_CMD_OP 148 #undef O3D_COMMAND_BUFFER_CMD_OP
151 149
152 kNumCommands, 150 kNumCommands,
153 }; 151 };
154 152
155 // Bit definitions for buffers to clear. 153 // Bit definitions for buffers to clear.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 kBlendFuncInvBlendColor, 238 kBlendFuncInvBlendColor,
241 kNumBlendFunc 239 kNumBlendFunc
242 }; 240 };
243 241
244 const char* GetCommandName(CommandId id); 242 const char* GetCommandName(CommandId id);
245 243
246 // Make sure the compiler does not add extra padding to any of the command 244 // Make sure the compiler does not add extra padding to any of the command
247 // structures. 245 // structures.
248 O3D_PUSH_STRUCTURE_PACKING_1; 246 O3D_PUSH_STRUCTURE_PACKING_1;
249 247
250 struct Noop {
251 typedef Noop ValueType;
252 static const CommandId kCmdId = kNoop;
253 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
254
255 void SetHeader(uint32 skip_count) {
256 header.Init(kCmdId, skip_count + 1);
257 }
258
259 void Init(uint32 skip_count) {
260 SetHeader(skip_count);
261 }
262
263 static void* Set(void* cmd, uint32 skip_count) {
264 static_cast<ValueType*>(cmd)->Init(skip_count);
265 return NextImmediateCmdAddress<ValueType>(
266 cmd, skip_count * sizeof(CommandBufferEntry)); // NOLINT
267 }
268
269 CommandHeader header;
270 };
271
272 COMPILE_ASSERT(sizeof(Noop) == 4, Sizeof_Noop_is_not_4);
273 COMPILE_ASSERT(offsetof(Noop, header) == 0, Offsetof_Noop_header_not_0);
274
275 struct SetToken {
276 typedef SetToken ValueType;
277 static const CommandId kCmdId = kSetToken;
278 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
279
280 void SetHeader() {
281 header.SetCmd<ValueType>();
282 }
283
284 void Init(uint32 _token) {
285 SetHeader();
286 token = _token;
287 }
288 static void* Set(void* cmd, uint32 token) {
289 static_cast<ValueType*>(cmd)->Init(token);
290 return NextCmdAddress<ValueType>(cmd);
291 }
292
293 CommandHeader header;
294 uint32 token;
295 };
296
297 COMPILE_ASSERT(sizeof(SetToken) == 8, Sizeof_SetToken_is_not_8);
298 COMPILE_ASSERT(offsetof(SetToken, header) == 0,
299 Offsetof_SetToken_header_not_0);
300 COMPILE_ASSERT(offsetof(SetToken, token) == 4,
301 Offsetof_SetToken_token_not_4);
302
303 struct BeginFrame { 248 struct BeginFrame {
304 typedef BeginFrame ValueType; 249 typedef BeginFrame ValueType;
305 static const CommandId kCmdId = kBeginFrame; 250 static const CommandId kCmdId = kBeginFrame;
306 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 251 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
307 252
308 void SetHeader() { 253 void SetHeader() {
309 header.SetCmd<ValueType>(); 254 header.SetCmd<ValueType>();
310 } 255 }
311 256
312 void Init() { 257 void Init() {
(...skipping 2890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3203 COMPILE_ASSERT(offsetof(SetBackSurfaces, header) == 0, 3148 COMPILE_ASSERT(offsetof(SetBackSurfaces, header) == 0,
3204 OffsetOf_SetBackSurfaces_header_not_0); 3149 OffsetOf_SetBackSurfaces_header_not_0);
3205 3150
3206 O3D_POP_STRUCTURE_PACKING; 3151 O3D_POP_STRUCTURE_PACKING;
3207 3152
3208 } // namespace o3d 3153 } // namespace o3d
3209 } // namespace command_buffer 3154 } // namespace command_buffer
3210 } // namespace o3d 3155 } // namespace o3d
3211 3156
3212 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_ 3157 #endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_FORMAT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698