| OLD | NEW |
| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::PARSE_NO_ERROR; | 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::PARSE_NO_ERROR : | 325 BufferSyncInterface::kParseNoError : |
| 326 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR : | 338 BufferSyncInterface::kParseNoError : |
| 339 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR : | 351 BufferSyncInterface::kParseNoError : |
| 352 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR; | 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::PARSE_NO_ERROR : | 369 BufferSyncInterface::kParseNoError : |
| 370 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR : | 382 BufferSyncInterface::kParseNoError : |
| 383 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR : | 395 BufferSyncInterface::kParseNoError : |
| 396 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR; | 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::PARSE_NO_ERROR : | 412 BufferSyncInterface::kParseNoError : |
| 413 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 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::PARSE_INVALID_ARGUMENTS; | 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::PARSE_NO_ERROR; | 432 return BufferSyncInterface::kParseNoError; |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace command_buffer | 435 } // namespace command_buffer |
| 436 } // namespace o3d | 436 } // namespace o3d |
| OLD | NEW |