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

Side by Side Diff: command_buffer/service/win/d3d9/geometry_d3d9.cc

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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (d3d_vertex_buffer_) { 48 if (d3d_vertex_buffer_) {
49 d3d_vertex_buffer_->Release(); 49 d3d_vertex_buffer_->Release();
50 d3d_vertex_buffer_ = NULL; 50 d3d_vertex_buffer_ = NULL;
51 } 51 }
52 } 52 }
53 53
54 // Creates a D3D9 vertex buffer. 54 // Creates a D3D9 vertex buffer.
55 void VertexBufferD3D9::Create(GAPID3D9 *gapi) { 55 void VertexBufferD3D9::Create(GAPID3D9 *gapi) {
56 DCHECK(d3d_vertex_buffer_ == NULL); 56 DCHECK(d3d_vertex_buffer_ == NULL);
57 57
58 DWORD d3d_usage = (flags() & vertex_buffer::DYNAMIC) ? D3DUSAGE_DYNAMIC : 0; 58 DWORD d3d_usage = (flags() & vertex_buffer::kDynamic) ? D3DUSAGE_DYNAMIC : 0;
59 D3DPOOL d3d_pool = D3DPOOL_MANAGED; 59 D3DPOOL d3d_pool = D3DPOOL_MANAGED;
60 HR(gapi->d3d_device()->CreateVertexBuffer(size(), d3d_usage, 0, d3d_pool, 60 HR(gapi->d3d_device()->CreateVertexBuffer(size(), d3d_usage, 0, d3d_pool,
61 &d3d_vertex_buffer_, NULL)); 61 &d3d_vertex_buffer_, NULL));
62 } 62 }
63 63
64 // Sets the data into the D3D9 vertex buffer, using Lock() and memcpy. 64 // Sets the data into the D3D9 vertex buffer, using Lock() and memcpy.
65 bool VertexBufferD3D9::SetData(unsigned int offset, 65 bool VertexBufferD3D9::SetData(unsigned int offset,
66 unsigned int size, 66 unsigned int size,
67 const void *data) { 67 const void *data) {
68 if (!d3d_vertex_buffer_) { 68 if (!d3d_vertex_buffer_) {
69 LOG(ERROR) << "Calling SetData on a non-initialized VertexBufferD3D9."; 69 LOG(ERROR) << "Calling SetData on a non-initialized VertexBufferD3D9.";
70 return false; 70 return false;
71 } 71 }
72 if ((offset >= this->size()) || (offset + size > this->size())) { 72 if ((offset >= this->size()) || (offset + size > this->size())) {
73 LOG(ERROR) << "Invalid size or offset on VertexBufferD3D9::SetData."; 73 LOG(ERROR) << "Invalid size or offset on VertexBufferD3D9::SetData.";
74 return false; 74 return false;
75 } 75 }
76 void *ptr = NULL; 76 void *ptr = NULL;
77 DWORD lock_flags = 0; 77 DWORD lock_flags = 0;
78 // If we are setting the full buffer, discard the old data. That's only 78 // If we are setting the full buffer, discard the old data. That's only
79 // possible to do for a dynamic d3d vertex buffer. 79 // possible to do for a dynamic d3d vertex buffer.
80 if ((offset == 0) && (size == this->size()) && 80 if ((offset == 0) && (size == this->size()) &&
81 (flags() & vertex_buffer::DYNAMIC)) 81 (flags() & vertex_buffer::kDynamic))
82 lock_flags = D3DLOCK_DISCARD; 82 lock_flags = D3DLOCK_DISCARD;
83 HR(d3d_vertex_buffer_->Lock(offset, size, &ptr, lock_flags)); 83 HR(d3d_vertex_buffer_->Lock(offset, size, &ptr, lock_flags));
84 memcpy(ptr, data, size); 84 memcpy(ptr, data, size);
85 HR(d3d_vertex_buffer_->Unlock()); 85 HR(d3d_vertex_buffer_->Unlock());
86 return true; 86 return true;
87 } 87 }
88 88
89 // Gets the data from the D3D9 vertex buffer, using Lock() and memcpy. 89 // Gets the data from the D3D9 vertex buffer, using Lock() and memcpy.
90 bool VertexBufferD3D9::GetData(unsigned int offset, 90 bool VertexBufferD3D9::GetData(unsigned int offset,
91 unsigned int size, 91 unsigned int size,
(...skipping 20 matching lines...) Expand all
112 if (d3d_index_buffer_) { 112 if (d3d_index_buffer_) {
113 d3d_index_buffer_->Release(); 113 d3d_index_buffer_->Release();
114 d3d_index_buffer_ = NULL; 114 d3d_index_buffer_ = NULL;
115 } 115 }
116 } 116 }
117 117
118 // Creates a D3D9 index buffer. 118 // Creates a D3D9 index buffer.
119 void IndexBufferD3D9::Create(GAPID3D9 *gapi) { 119 void IndexBufferD3D9::Create(GAPID3D9 *gapi) {
120 DCHECK(d3d_index_buffer_ == NULL); 120 DCHECK(d3d_index_buffer_ == NULL);
121 121
122 DWORD d3d_usage = (flags() & index_buffer::DYNAMIC) ? D3DUSAGE_DYNAMIC : 0; 122 DWORD d3d_usage = (flags() & index_buffer::kDynamic) ? D3DUSAGE_DYNAMIC : 0;
123 D3DFORMAT d3d_format = 123 D3DFORMAT d3d_format =
124 (flags() & index_buffer::INDEX_32BIT) ? D3DFMT_INDEX32 : D3DFMT_INDEX16; 124 (flags() & index_buffer::kIndex32Bit) ? D3DFMT_INDEX32 : D3DFMT_INDEX16;
125 D3DPOOL d3d_pool = D3DPOOL_MANAGED; 125 D3DPOOL d3d_pool = D3DPOOL_MANAGED;
126 HR(gapi->d3d_device()->CreateIndexBuffer(size(), d3d_usage, d3d_format, 126 HR(gapi->d3d_device()->CreateIndexBuffer(size(), d3d_usage, d3d_format,
127 d3d_pool, &d3d_index_buffer_, 127 d3d_pool, &d3d_index_buffer_,
128 NULL)); 128 NULL));
129 } 129 }
130 130
131 // Sets the data into the D3D9 index buffer, using Lock() and memcpy. 131 // Sets the data into the D3D9 index buffer, using Lock() and memcpy.
132 bool IndexBufferD3D9::SetData(unsigned int offset, 132 bool IndexBufferD3D9::SetData(unsigned int offset,
133 unsigned int size, 133 unsigned int size,
134 const void *data) { 134 const void *data) {
135 if (!d3d_index_buffer_) { 135 if (!d3d_index_buffer_) {
136 LOG(ERROR) << "Calling SetData on a non-initialized IndexBufferD3D9."; 136 LOG(ERROR) << "Calling SetData on a non-initialized IndexBufferD3D9.";
137 return false; 137 return false;
138 } 138 }
139 if ((offset >= this->size()) || (offset + size > this->size())) { 139 if ((offset >= this->size()) || (offset + size > this->size())) {
140 LOG(ERROR) << "Invalid size or offset on IndexBufferD3D9::SetData."; 140 LOG(ERROR) << "Invalid size or offset on IndexBufferD3D9::SetData.";
141 return false; 141 return false;
142 } 142 }
143 void *ptr = NULL; 143 void *ptr = NULL;
144 DWORD lock_flags = 0; 144 DWORD lock_flags = 0;
145 // If we are setting the full buffer, discard the old data. That's only 145 // If we are setting the full buffer, discard the old data. That's only
146 // possible to do for a dynamic d3d index buffer. 146 // possible to do for a dynamic d3d index buffer.
147 if ((offset == 0) && (size == this->size()) && 147 if ((offset == 0) && (size == this->size()) &&
148 (flags() & index_buffer::DYNAMIC)) 148 (flags() & index_buffer::kDynamic))
149 lock_flags = D3DLOCK_DISCARD; 149 lock_flags = D3DLOCK_DISCARD;
150 HR(d3d_index_buffer_->Lock(offset, size, &ptr, lock_flags)); 150 HR(d3d_index_buffer_->Lock(offset, size, &ptr, lock_flags));
151 memcpy(ptr, data, size); 151 memcpy(ptr, data, size);
152 HR(d3d_index_buffer_->Unlock()); 152 HR(d3d_index_buffer_->Unlock());
153 return true; 153 return true;
154 } 154 }
155 155
156 // Gets the data from the D3D9 index buffer, using Lock() and memcpy. 156 // Gets the data from the D3D9 index buffer, using Lock() and memcpy.
157 bool IndexBufferD3D9::GetData(unsigned int offset, 157 bool IndexBufferD3D9::GetData(unsigned int offset,
158 unsigned int size, 158 unsigned int size,
159 void *data) { 159 void *data) {
160 if (!d3d_index_buffer_) { 160 if (!d3d_index_buffer_) {
161 LOG(ERROR) << "Calling SetData on a non-initialized IndexBufferD3D9."; 161 LOG(ERROR) << "Calling SetData on a non-initialized IndexBufferD3D9.";
162 return false; 162 return false;
163 } 163 }
164 if ((offset >= this->size()) || (offset + size > this->size())) { 164 if ((offset >= this->size()) || (offset + size > this->size())) {
165 LOG(ERROR) << "Invalid size or offset on IndexBufferD3D9::SetData."; 165 LOG(ERROR) << "Invalid size or offset on IndexBufferD3D9::SetData.";
166 return false; 166 return false;
167 } 167 }
168 void *ptr = NULL; 168 void *ptr = NULL;
169 DWORD lock_flags = D3DLOCK_READONLY; 169 DWORD lock_flags = D3DLOCK_READONLY;
170 HR(d3d_index_buffer_->Lock(offset, size, &ptr, lock_flags)); 170 HR(d3d_index_buffer_->Lock(offset, size, &ptr, lock_flags));
171 memcpy(data, ptr, size); 171 memcpy(data, ptr, size);
172 HR(d3d_index_buffer_->Unlock()); 172 HR(d3d_index_buffer_->Unlock());
173 return true; 173 return true;
174 } 174 }
175 175
176 // Sets the input element in the VertexStruct resource. 176 // Sets the input element in the VertexStruct resource.
177 void VertexStructD3D9::SetInput(unsigned int input_index, 177 void VertexStructD3D9::SetInput(unsigned int input_index,
178 ResourceID vertex_buffer_id, 178 ResourceId vertex_buffer_id,
179 unsigned int offset, 179 unsigned int offset,
180 unsigned int stride, 180 unsigned int stride,
181 vertex_struct::Type type, 181 vertex_struct::Type type,
182 vertex_struct::Semantic semantic, 182 vertex_struct::Semantic semantic,
183 unsigned int semantic_index) { 183 unsigned int semantic_index) {
184 Element &element = GetElement(input_index); 184 Element &element = GetElement(input_index);
185 element.vertex_buffer = vertex_buffer_id; 185 element.vertex_buffer = vertex_buffer_id;
186 element.offset = offset; 186 element.offset = offset;
187 element.stride = stride; 187 element.stride = stride;
188 element.type = type; 188 element.type = type;
(...skipping 26 matching lines...) Expand all
215 max_vertices = std::min(max_vertices, 215 max_vertices = std::min(max_vertices,
216 vertex_buffer->size() / pair.second); 216 vertex_buffer->size() / pair.second);
217 } 217 }
218 } 218 }
219 return max_vertices; 219 return max_vertices;
220 } 220 }
221 221
222 // Converts a vertex_struct::Type to a D3DDECLTYPE. 222 // Converts a vertex_struct::Type to a D3DDECLTYPE.
223 static D3DDECLTYPE D3DType(vertex_struct::Type type) { 223 static D3DDECLTYPE D3DType(vertex_struct::Type type) {
224 switch (type) { 224 switch (type) {
225 case vertex_struct::FLOAT1: 225 case vertex_struct::kFloat1:
226 return D3DDECLTYPE_FLOAT1; 226 return D3DDECLTYPE_FLOAT1;
227 case vertex_struct::FLOAT2: 227 case vertex_struct::kFloat2:
228 return D3DDECLTYPE_FLOAT2; 228 return D3DDECLTYPE_FLOAT2;
229 case vertex_struct::FLOAT3: 229 case vertex_struct::kFloat3:
230 return D3DDECLTYPE_FLOAT3; 230 return D3DDECLTYPE_FLOAT3;
231 case vertex_struct::FLOAT4: 231 case vertex_struct::kFloat4:
232 return D3DDECLTYPE_FLOAT4; 232 return D3DDECLTYPE_FLOAT4;
233 case vertex_struct::UCHAR4N: 233 case vertex_struct::kUChar4N:
234 return D3DDECLTYPE_UBYTE4N; 234 return D3DDECLTYPE_UBYTE4N;
235 case vertex_struct::NUM_TYPES: 235 case vertex_struct::kNumTypes:
236 break; 236 break;
237 } 237 }
238 LOG(FATAL) << "Invalid type"; 238 LOG(FATAL) << "Invalid type";
239 return D3DDECLTYPE_FLOAT1; 239 return D3DDECLTYPE_FLOAT1;
240 } 240 }
241 241
242 // Converts a vertex_struct::Semantic to a D3DDECLUSAGE. 242 // Converts a vertex_struct::Semantic to a D3DDECLUSAGE.
243 static D3DDECLUSAGE D3DUsage(vertex_struct::Semantic semantic) { 243 static D3DDECLUSAGE D3DUsage(vertex_struct::Semantic semantic) {
244 switch (semantic) { 244 switch (semantic) {
245 case vertex_struct::POSITION: 245 case vertex_struct::kPosition:
246 return D3DDECLUSAGE_POSITION; 246 return D3DDECLUSAGE_POSITION;
247 case vertex_struct::NORMAL: 247 case vertex_struct::kNormal:
248 return D3DDECLUSAGE_NORMAL; 248 return D3DDECLUSAGE_NORMAL;
249 case vertex_struct::COLOR: 249 case vertex_struct::kColor:
250 return D3DDECLUSAGE_COLOR; 250 return D3DDECLUSAGE_COLOR;
251 case vertex_struct::TEX_COORD: 251 case vertex_struct::kTexCoord:
252 return D3DDECLUSAGE_TEXCOORD; 252 return D3DDECLUSAGE_TEXCOORD;
253 case vertex_struct::NUM_SEMANTICS: 253 case vertex_struct::kNumSemantics:
254 break; 254 break;
255 } 255 }
256 LOG(FATAL) << "Invalid type"; 256 LOG(FATAL) << "Invalid type";
257 return D3DDECLUSAGE_POSITION; 257 return D3DDECLUSAGE_POSITION;
258 } 258 }
259 259
260 // Destroys the d3d vertex declaration. 260 // Destroys the d3d vertex declaration.
261 VertexStructD3D9::~VertexStructD3D9() { 261 VertexStructD3D9::~VertexStructD3D9() {
262 Destroy(); 262 Destroy();
263 } 263 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 D3DVERTEXELEMENT9 &end = d3d_elements[count_]; 303 D3DVERTEXELEMENT9 &end = d3d_elements[count_];
304 end.Stream = 0xFF; 304 end.Stream = 0xFF;
305 end.Type = D3DDECLTYPE_UNUSED; 305 end.Type = D3DDECLTYPE_UNUSED;
306 HR(d3d_device->CreateVertexDeclaration(d3d_elements.get(), 306 HR(d3d_device->CreateVertexDeclaration(d3d_elements.get(),
307 &d3d_vertex_decl_)); 307 &d3d_vertex_decl_));
308 dirty_ = false; 308 dirty_ = false;
309 } 309 }
310 310
311 // Creates and assigns a VertexBufferD3D9 resource. 311 // Creates and assigns a VertexBufferD3D9 resource.
312 BufferSyncInterface::ParseError GAPID3D9::CreateVertexBuffer( 312 BufferSyncInterface::ParseError GAPID3D9::CreateVertexBuffer(
313 ResourceID id, 313 ResourceId id,
314 unsigned int size, 314 unsigned int size,
315 unsigned int flags) { 315 unsigned int flags) {
316 VertexBufferD3D9 *vertex_buffer = new VertexBufferD3D9(size, flags); 316 VertexBufferD3D9 *vertex_buffer = new VertexBufferD3D9(size, flags);
317 vertex_buffer->Create(this); 317 vertex_buffer->Create(this);
318 vertex_buffers_.Assign(id, vertex_buffer); 318 vertex_buffers_.Assign(id, vertex_buffer);
319 return BufferSyncInterface::kParseNoError; 319 return BufferSyncInterface::kParseNoError;
320 } 320 }
321 321
322 // Destroys a VertexBufferD3D9 resource. 322 // Destroys a VertexBufferD3D9 resource.
323 BufferSyncInterface::ParseError GAPID3D9::DestroyVertexBuffer(ResourceID id) { 323 BufferSyncInterface::ParseError GAPID3D9::DestroyVertexBuffer(ResourceId id) {
324 return vertex_buffers_.Destroy(id) ? 324 return vertex_buffers_.Destroy(id) ?
325 BufferSyncInterface::kParseNoError : 325 BufferSyncInterface::kParseNoError :
326 BufferSyncInterface::kParseInvalidArguments; 326 BufferSyncInterface::kParseInvalidArguments;
327 } 327 }
328 328
329 // Copies the data into the VertexBufferD3D9 resource. 329 // Copies the data into the VertexBufferD3D9 resource.
330 BufferSyncInterface::ParseError GAPID3D9::SetVertexBufferData( 330 BufferSyncInterface::ParseError GAPID3D9::SetVertexBufferData(
331 ResourceID id, 331 ResourceId id,
332 unsigned int offset, 332 unsigned int offset,
333 unsigned int size, 333 unsigned int size,
334 const void *data) { 334 const void *data) {
335 VertexBufferD3D9 *vertex_buffer = vertex_buffers_.Get(id); 335 VertexBufferD3D9 *vertex_buffer = vertex_buffers_.Get(id);
336 if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments; 336 if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments;
337 return vertex_buffer->SetData(offset, size, data) ? 337 return vertex_buffer->SetData(offset, size, data) ?
338 BufferSyncInterface::kParseNoError : 338 BufferSyncInterface::kParseNoError :
339 BufferSyncInterface::kParseInvalidArguments; 339 BufferSyncInterface::kParseInvalidArguments;
340 } 340 }
341 341
342 // Copies the data from the VertexBufferD3D9 resource. 342 // Copies the data from the VertexBufferD3D9 resource.
343 BufferSyncInterface::ParseError GAPID3D9::GetVertexBufferData( 343 BufferSyncInterface::ParseError GAPID3D9::GetVertexBufferData(
344 ResourceID id, 344 ResourceId id,
345 unsigned int offset, 345 unsigned int offset,
346 unsigned int size, 346 unsigned int size,
347 void *data) { 347 void *data) {
348 VertexBufferD3D9 *vertex_buffer = vertex_buffers_.Get(id); 348 VertexBufferD3D9 *vertex_buffer = vertex_buffers_.Get(id);
349 if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments; 349 if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments;
350 return vertex_buffer->GetData(offset, size, data) ? 350 return vertex_buffer->GetData(offset, size, data) ?
351 BufferSyncInterface::kParseNoError : 351 BufferSyncInterface::kParseNoError :
352 BufferSyncInterface::kParseInvalidArguments; 352 BufferSyncInterface::kParseInvalidArguments;
353 } 353 }
354 354
355 // Creates and assigns an IndexBufferD3D9 resource. 355 // Creates and assigns an IndexBufferD3D9 resource.
356 BufferSyncInterface::ParseError GAPID3D9::CreateIndexBuffer( 356 BufferSyncInterface::ParseError GAPID3D9::CreateIndexBuffer(
357 ResourceID id, 357 ResourceId id,
358 unsigned int size, 358 unsigned int size,
359 unsigned int flags) { 359 unsigned int flags) {
360 IndexBufferD3D9 *index_buffer = new IndexBufferD3D9(size, flags); 360 IndexBufferD3D9 *index_buffer = new IndexBufferD3D9(size, flags);
361 index_buffer->Create(this); 361 index_buffer->Create(this);
362 index_buffers_.Assign(id, index_buffer); 362 index_buffers_.Assign(id, index_buffer);
363 return BufferSyncInterface::kParseNoError; 363 return BufferSyncInterface::kParseNoError;
364 } 364 }
365 365
366 // Destroys an IndexBufferD3D9 resource. 366 // Destroys an IndexBufferD3D9 resource.
367 BufferSyncInterface::ParseError GAPID3D9::DestroyIndexBuffer(ResourceID id) { 367 BufferSyncInterface::ParseError GAPID3D9::DestroyIndexBuffer(ResourceId id) {
368 return index_buffers_.Destroy(id) ? 368 return index_buffers_.Destroy(id) ?
369 BufferSyncInterface::kParseNoError : 369 BufferSyncInterface::kParseNoError :
370 BufferSyncInterface::kParseInvalidArguments; 370 BufferSyncInterface::kParseInvalidArguments;
371 } 371 }
372 372
373 // Copies the data into the IndexBufferD3D9 resource. 373 // Copies the data into the IndexBufferD3D9 resource.
374 BufferSyncInterface::ParseError GAPID3D9::SetIndexBufferData( 374 BufferSyncInterface::ParseError GAPID3D9::SetIndexBufferData(
375 ResourceID id, 375 ResourceId id,
376 unsigned int offset, 376 unsigned int offset,
377 unsigned int size, 377 unsigned int size,
378 const void *data) { 378 const void *data) {
379 IndexBufferD3D9 *index_buffer = index_buffers_.Get(id); 379 IndexBufferD3D9 *index_buffer = index_buffers_.Get(id);
380 if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments; 380 if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments;
381 return index_buffer->SetData(offset, size, data) ? 381 return index_buffer->SetData(offset, size, data) ?
382 BufferSyncInterface::kParseNoError : 382 BufferSyncInterface::kParseNoError :
383 BufferSyncInterface::kParseInvalidArguments; 383 BufferSyncInterface::kParseInvalidArguments;
384 } 384 }
385 385
386 // Copies the data from the IndexBufferD3D9 resource. 386 // Copies the data from the IndexBufferD3D9 resource.
387 BufferSyncInterface::ParseError GAPID3D9::GetIndexBufferData( 387 BufferSyncInterface::ParseError GAPID3D9::GetIndexBufferData(
388 ResourceID id, 388 ResourceId id,
389 unsigned int offset, 389 unsigned int offset,
390 unsigned int size, 390 unsigned int size,
391 void *data) { 391 void *data) {
392 IndexBufferD3D9 *index_buffer = index_buffers_.Get(id); 392 IndexBufferD3D9 *index_buffer = index_buffers_.Get(id);
393 if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments; 393 if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments;
394 return index_buffer->GetData(offset, size, data) ? 394 return index_buffer->GetData(offset, size, data) ?
395 BufferSyncInterface::kParseNoError : 395 BufferSyncInterface::kParseNoError :
396 BufferSyncInterface::kParseInvalidArguments; 396 BufferSyncInterface::kParseInvalidArguments;
397 } 397 }
398 398
399 // Creates and assigns a VertexStructD3D9 resource. 399 // Creates and assigns a VertexStructD3D9 resource.
400 BufferSyncInterface::ParseError GAPID3D9::CreateVertexStruct( 400 BufferSyncInterface::ParseError GAPID3D9::CreateVertexStruct(
401 ResourceID id, unsigned int input_count) { 401 ResourceId id, unsigned int input_count) {
402 if (id == current_vertex_struct_) validate_streams_ = true; 402 if (id == current_vertex_struct_) validate_streams_ = true;
403 VertexStructD3D9 *vertex_struct = new VertexStructD3D9(input_count); 403 VertexStructD3D9 *vertex_struct = new VertexStructD3D9(input_count);
404 vertex_structs_.Assign(id, vertex_struct); 404 vertex_structs_.Assign(id, vertex_struct);
405 return BufferSyncInterface::kParseNoError; 405 return BufferSyncInterface::kParseNoError;
406 } 406 }
407 407
408 // Destroys a VertexStructD3D9 resource. 408 // Destroys a VertexStructD3D9 resource.
409 BufferSyncInterface::ParseError GAPID3D9::DestroyVertexStruct(ResourceID id) { 409 BufferSyncInterface::ParseError GAPID3D9::DestroyVertexStruct(ResourceId id) {
410 if (id == current_vertex_struct_) validate_streams_ = true; 410 if (id == current_vertex_struct_) validate_streams_ = true;
411 return vertex_structs_.Destroy(id) ? 411 return vertex_structs_.Destroy(id) ?
412 BufferSyncInterface::kParseNoError : 412 BufferSyncInterface::kParseNoError :
413 BufferSyncInterface::kParseInvalidArguments; 413 BufferSyncInterface::kParseInvalidArguments;
414 } 414 }
415 415
416 // Sets an input into a VertexStructD3D9 resource. 416 // Sets an input into a VertexStructD3D9 resource.
417 BufferSyncInterface::ParseError GAPID3D9::SetVertexInput( 417 BufferSyncInterface::ParseError GAPID3D9::SetVertexInput(
418 ResourceID vertex_struct_id, 418 ResourceId vertex_struct_id,
419 unsigned int input_index, 419 unsigned int input_index,
420 ResourceID vertex_buffer_id, 420 ResourceId vertex_buffer_id,
421 unsigned int offset, 421 unsigned int offset,
422 unsigned int stride, 422 unsigned int stride,
423 vertex_struct::Type type, 423 vertex_struct::Type type,
424 vertex_struct::Semantic semantic, 424 vertex_struct::Semantic semantic,
425 unsigned int semantic_index) { 425 unsigned int semantic_index) {
426 if (vertex_buffer_id == current_vertex_struct_) validate_streams_ = true; 426 if (vertex_buffer_id == current_vertex_struct_) validate_streams_ = true;
427 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(vertex_struct_id); 427 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(vertex_struct_id);
428 if (!vertex_struct || input_index >= vertex_struct->count()) 428 if (!vertex_struct || input_index >= vertex_struct->count())
429 return BufferSyncInterface::kParseInvalidArguments; 429 return BufferSyncInterface::kParseInvalidArguments;
430 vertex_struct->SetInput(input_index, vertex_buffer_id, offset, stride, type, 430 vertex_struct->SetInput(input_index, vertex_buffer_id, offset, stride, type,
431 semantic, semantic_index); 431 semantic, semantic_index);
432 return BufferSyncInterface::kParseNoError; 432 return BufferSyncInterface::kParseNoError;
433 } 433 }
434 434
435 } // namespace command_buffer 435 } // namespace command_buffer
436 } // namespace o3d 436 } // namespace o3d
OLDNEW
« no previous file with comments | « command_buffer/service/win/d3d9/geometry_d3d9.h ('k') | command_buffer/service/win/d3d9/render_surface_d3d9.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698