| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #include "command_buffer/service/win/d3d9/gapi_d3d9.h" | 36 #include "command_buffer/service/win/d3d9/gapi_d3d9.h" |
| 37 #include "command_buffer/service/win/d3d9/texture_d3d9.h" | 37 #include "command_buffer/service/win/d3d9/texture_d3d9.h" |
| 38 | 38 |
| 39 namespace o3d { | 39 namespace o3d { |
| 40 namespace command_buffer { | 40 namespace command_buffer { |
| 41 | 41 |
| 42 // Converts a texture format to a D3D texture format. | 42 // Converts a texture format to a D3D texture format. |
| 43 D3DFORMAT TextureD3D9::D3DFormat(texture::Format format) { | 43 D3DFORMAT TextureD3D9::D3DFormat(texture::Format format) { |
| 44 switch (format) { | 44 switch (format) { |
| 45 case texture::XRGB8: return D3DFMT_X8R8G8B8; | 45 case texture::kXRGB8: return D3DFMT_X8R8G8B8; |
| 46 case texture::ARGB8: return D3DFMT_A8R8G8B8; | 46 case texture::kARGB8: return D3DFMT_A8R8G8B8; |
| 47 case texture::ABGR16F: return D3DFMT_A16B16G16R16F; | 47 case texture::kABGR16F: return D3DFMT_A16B16G16R16F; |
| 48 case texture::DXT1: return D3DFMT_DXT1; | 48 case texture::kDXT1: return D3DFMT_DXT1; |
| 49 default: return D3DFMT_UNKNOWN; | 49 default: return D3DFMT_UNKNOWN; |
| 50 }; | 50 }; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Converts a cube map face to a D3D face. | 53 // Converts a cube map face to a D3D face. |
| 54 D3DCUBEMAP_FACES TextureD3D9::D3DFace(texture::Face face) { | 54 D3DCUBEMAP_FACES TextureD3D9::D3DFace(texture::Face face) { |
| 55 switch (face) { | 55 switch (face) { |
| 56 case texture::FACE_POSITIVE_X: | 56 case texture::kFacePositiveX: |
| 57 return D3DCUBEMAP_FACE_POSITIVE_X; | 57 return D3DCUBEMAP_FACE_POSITIVE_X; |
| 58 case texture::FACE_NEGATIVE_X: | 58 case texture::kFaceNegativeX: |
| 59 return D3DCUBEMAP_FACE_NEGATIVE_X; | 59 return D3DCUBEMAP_FACE_NEGATIVE_X; |
| 60 case texture::FACE_POSITIVE_Y: | 60 case texture::kFacePositiveY: |
| 61 return D3DCUBEMAP_FACE_POSITIVE_Y; | 61 return D3DCUBEMAP_FACE_POSITIVE_Y; |
| 62 case texture::FACE_NEGATIVE_Y: | 62 case texture::kFaceNegativeY: |
| 63 return D3DCUBEMAP_FACE_NEGATIVE_Y; | 63 return D3DCUBEMAP_FACE_NEGATIVE_Y; |
| 64 case texture::FACE_POSITIVE_Z: | 64 case texture::kFacePositiveZ: |
| 65 return D3DCUBEMAP_FACE_POSITIVE_Z; | 65 return D3DCUBEMAP_FACE_POSITIVE_Z; |
| 66 case texture::FACE_NEGATIVE_Z: | 66 case texture::kFaceNegativeZ: |
| 67 return D3DCUBEMAP_FACE_NEGATIVE_Z; | 67 return D3DCUBEMAP_FACE_NEGATIVE_Z; |
| 68 } | 68 } |
| 69 LOG(FATAL) << "Not reached."; | 69 LOG(FATAL) << "Not reached."; |
| 70 return D3DCUBEMAP_FACE_POSITIVE_X; | 70 return D3DCUBEMAP_FACE_POSITIVE_X; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Texture 2D functions | 73 // Texture 2D functions |
| 74 | 74 |
| 75 // Destroys the 2D texture, releasing the D3D texture, and its shadow if any. | 75 // Destroys the 2D texture, releasing the D3D texture, and its shadow if any. |
| 76 Texture2DD3D9::~Texture2DD3D9() { | 76 Texture2DD3D9::~Texture2DD3D9() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 D3DUSAGE_RENDERTARGET, d3d_format, | 103 D3DUSAGE_RENDERTARGET, d3d_format, |
| 104 D3DPOOL_DEFAULT, &d3d_texture, | 104 D3DPOOL_DEFAULT, &d3d_texture, |
| 105 NULL); | 105 NULL); |
| 106 if (result != D3D_OK) { | 106 if (result != D3D_OK) { |
| 107 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 107 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 108 << DXGetErrorStringA(result); | 108 << DXGetErrorStringA(result); |
| 109 return NULL; | 109 return NULL; |
| 110 } | 110 } |
| 111 return new Texture2DD3D9(levels, format, flags, width, height, d3d_texture, | 111 return new Texture2DD3D9(levels, format, flags, width, height, d3d_texture, |
| 112 NULL, enable_render_surfaces); | 112 NULL, enable_render_surfaces); |
| 113 } else if (flags & texture::DYNAMIC) { | 113 } else if (flags & texture::kDynamic) { |
| 114 CComPtr<IDirect3DTexture9> d3d_texture = NULL; | 114 CComPtr<IDirect3DTexture9> d3d_texture = NULL; |
| 115 HRESULT result = device->CreateTexture(width, height, levels, | 115 HRESULT result = device->CreateTexture(width, height, levels, |
| 116 D3DUSAGE_DYNAMIC, d3d_format, | 116 D3DUSAGE_DYNAMIC, d3d_format, |
| 117 D3DPOOL_DEFAULT, &d3d_texture, | 117 D3DPOOL_DEFAULT, &d3d_texture, |
| 118 NULL); | 118 NULL); |
| 119 if (result != D3D_OK) { | 119 if (result != D3D_OK) { |
| 120 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 120 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 121 << DXGetErrorStringA(result); | 121 << DXGetErrorStringA(result); |
| 122 return NULL; | 122 return NULL; |
| 123 } | 123 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 slice_pitch); | 167 slice_pitch); |
| 168 if (!CheckVolume(mip_info, volume) || level >= levels() || | 168 if (!CheckVolume(mip_info, volume) || level >= levels() || |
| 169 size < src_transfer_info.total_size) | 169 size < src_transfer_info.total_size) |
| 170 return false; | 170 return false; |
| 171 | 171 |
| 172 bool full_rect = IsFullVolume(mip_info, volume); | 172 bool full_rect = IsFullVolume(mip_info, volume); |
| 173 D3DLOCKED_RECT locked_rect; | 173 D3DLOCKED_RECT locked_rect; |
| 174 RECT rect = {volume.x, volume.y, volume.x+volume.width, | 174 RECT rect = {volume.x, volume.y, volume.x+volume.width, |
| 175 volume.y+volume.height}; | 175 volume.y+volume.height}; |
| 176 DWORD lock_flags = | 176 DWORD lock_flags = |
| 177 full_rect && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; | 177 full_rect && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; |
| 178 HR(lock_texture->LockRect(level, &locked_rect, full_rect ? NULL : &rect, | 178 HR(lock_texture->LockRect(level, &locked_rect, full_rect ? NULL : &rect, |
| 179 lock_flags)); | 179 lock_flags)); |
| 180 | 180 |
| 181 TransferInfo dst_transfer_info; | 181 TransferInfo dst_transfer_info; |
| 182 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_rect.Pitch, | 182 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_rect.Pitch, |
| 183 slice_pitch); | 183 slice_pitch); |
| 184 TransferVolume(volume, mip_info, dst_transfer_info, locked_rect.pBits, | 184 TransferVolume(volume, mip_info, dst_transfer_info, locked_rect.pBits, |
| 185 src_transfer_info, data); | 185 src_transfer_info, data); |
| 186 | 186 |
| 187 HR(lock_texture->UnlockRect(level)); | 187 HR(lock_texture->UnlockRect(level)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 D3DUSAGE_RENDERTARGET, | 281 D3DUSAGE_RENDERTARGET, |
| 282 d3d_format, D3DPOOL_DEFAULT, | 282 d3d_format, D3DPOOL_DEFAULT, |
| 283 &d3d_texture, NULL); | 283 &d3d_texture, NULL); |
| 284 if (result != D3D_OK) { | 284 if (result != D3D_OK) { |
| 285 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 285 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 286 << DXGetErrorStringA(result); | 286 << DXGetErrorStringA(result); |
| 287 return NULL; | 287 return NULL; |
| 288 } | 288 } |
| 289 return new Texture3DD3D9(levels, format, flags, width, height, depth, | 289 return new Texture3DD3D9(levels, format, flags, width, height, depth, |
| 290 d3d_texture, NULL, enable_render_surfaces); | 290 d3d_texture, NULL, enable_render_surfaces); |
| 291 } else if (flags & texture::DYNAMIC) { | 291 } else if (flags & texture::kDynamic) { |
| 292 CComPtr<IDirect3DVolumeTexture9> d3d_texture = NULL; | 292 CComPtr<IDirect3DVolumeTexture9> d3d_texture = NULL; |
| 293 HRESULT result = device->CreateVolumeTexture(width, height, depth, levels, | 293 HRESULT result = device->CreateVolumeTexture(width, height, depth, levels, |
| 294 D3DUSAGE_DYNAMIC, d3d_format, | 294 D3DUSAGE_DYNAMIC, d3d_format, |
| 295 D3DPOOL_DEFAULT, &d3d_texture, | 295 D3DPOOL_DEFAULT, &d3d_texture, |
| 296 NULL); | 296 NULL); |
| 297 if (result != D3D_OK) { | 297 if (result != D3D_OK) { |
| 298 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 298 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 299 << DXGetErrorStringA(result); | 299 << DXGetErrorStringA(result); |
| 300 return NULL; | 300 return NULL; |
| 301 } | 301 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 slice_pitch); | 348 slice_pitch); |
| 349 if (!CheckVolume(mip_info, volume) || level >= levels() || | 349 if (!CheckVolume(mip_info, volume) || level >= levels() || |
| 350 size < src_transfer_info.total_size) | 350 size < src_transfer_info.total_size) |
| 351 return false; | 351 return false; |
| 352 | 352 |
| 353 bool full_box = IsFullVolume(mip_info, volume); | 353 bool full_box = IsFullVolume(mip_info, volume); |
| 354 D3DLOCKED_BOX locked_box; | 354 D3DLOCKED_BOX locked_box; |
| 355 D3DBOX box = {volume.x, volume.y, volume.z, volume.x+volume.width, | 355 D3DBOX box = {volume.x, volume.y, volume.z, volume.x+volume.width, |
| 356 volume.y+volume.height, volume.z+volume.depth}; | 356 volume.y+volume.height, volume.z+volume.depth}; |
| 357 DWORD lock_flags = | 357 DWORD lock_flags = |
| 358 full_box && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; | 358 full_box && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; |
| 359 HR(lock_texture->LockBox(level, &locked_box, full_box ? NULL : &box, | 359 HR(lock_texture->LockBox(level, &locked_box, full_box ? NULL : &box, |
| 360 lock_flags)); | 360 lock_flags)); |
| 361 | 361 |
| 362 TransferInfo dst_transfer_info; | 362 TransferInfo dst_transfer_info; |
| 363 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_box.RowPitch, | 363 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_box.RowPitch, |
| 364 locked_box.SlicePitch); | 364 locked_box.SlicePitch); |
| 365 TransferVolume(volume, mip_info, dst_transfer_info, locked_box.pBits, | 365 TransferVolume(volume, mip_info, dst_transfer_info, locked_box.pBits, |
| 366 src_transfer_info, data); | 366 src_transfer_info, data); |
| 367 | 367 |
| 368 HR(lock_texture->UnlockBox(level)); | 368 HR(lock_texture->UnlockBox(level)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 D3DUSAGE_RENDERTARGET, | 454 D3DUSAGE_RENDERTARGET, |
| 455 d3d_format, D3DPOOL_DEFAULT, | 455 d3d_format, D3DPOOL_DEFAULT, |
| 456 &d3d_texture, NULL); | 456 &d3d_texture, NULL); |
| 457 if (result != D3D_OK) { | 457 if (result != D3D_OK) { |
| 458 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 458 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 459 << DXGetErrorStringA(result); | 459 << DXGetErrorStringA(result); |
| 460 return NULL; | 460 return NULL; |
| 461 } | 461 } |
| 462 return new TextureCubeD3D9(levels, format, flags, side, d3d_texture, NULL, | 462 return new TextureCubeD3D9(levels, format, flags, side, d3d_texture, NULL, |
| 463 enable_render_surfaces); | 463 enable_render_surfaces); |
| 464 } else if (flags & texture::DYNAMIC) { | 464 } else if (flags & texture::kDynamic) { |
| 465 CComPtr<IDirect3DCubeTexture9> d3d_texture = NULL; | 465 CComPtr<IDirect3DCubeTexture9> d3d_texture = NULL; |
| 466 HRESULT result = device->CreateCubeTexture(side, levels, D3DUSAGE_DYNAMIC, | 466 HRESULT result = device->CreateCubeTexture(side, levels, D3DUSAGE_DYNAMIC, |
| 467 d3d_format, D3DPOOL_DEFAULT, | 467 d3d_format, D3DPOOL_DEFAULT, |
| 468 &d3d_texture, NULL); | 468 &d3d_texture, NULL); |
| 469 if (result != D3D_OK) { | 469 if (result != D3D_OK) { |
| 470 LOG(ERROR) << "DirectX error when calling CreateTexture: " | 470 LOG(ERROR) << "DirectX error when calling CreateTexture: " |
| 471 << DXGetErrorStringA(result); | 471 << DXGetErrorStringA(result); |
| 472 return NULL; | 472 return NULL; |
| 473 } | 473 } |
| 474 CComPtr<IDirect3DCubeTexture9> d3d_shadow = NULL; | 474 CComPtr<IDirect3DCubeTexture9> d3d_shadow = NULL; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 if (!CheckVolume(mip_info, volume) || level >= levels() || | 519 if (!CheckVolume(mip_info, volume) || level >= levels() || |
| 520 size < src_transfer_info.total_size) | 520 size < src_transfer_info.total_size) |
| 521 return false; | 521 return false; |
| 522 | 522 |
| 523 D3DCUBEMAP_FACES d3d_face = D3DFace(face); | 523 D3DCUBEMAP_FACES d3d_face = D3DFace(face); |
| 524 bool full_rect = IsFullVolume(mip_info, volume); | 524 bool full_rect = IsFullVolume(mip_info, volume); |
| 525 D3DLOCKED_RECT locked_rect; | 525 D3DLOCKED_RECT locked_rect; |
| 526 RECT rect = {volume.x, volume.y, volume.x+volume.width, | 526 RECT rect = {volume.x, volume.y, volume.x+volume.width, |
| 527 volume.y+volume.height}; | 527 volume.y+volume.height}; |
| 528 DWORD lock_flags = | 528 DWORD lock_flags = |
| 529 full_rect && (flags() & texture::DYNAMIC) ? D3DLOCK_DISCARD : 0; | 529 full_rect && (flags() & texture::kDynamic) ? D3DLOCK_DISCARD : 0; |
| 530 HR(lock_texture->LockRect(d3d_face, level, &locked_rect, | 530 HR(lock_texture->LockRect(d3d_face, level, &locked_rect, |
| 531 full_rect ? NULL : &rect, lock_flags)); | 531 full_rect ? NULL : &rect, lock_flags)); |
| 532 | 532 |
| 533 TransferInfo dst_transfer_info; | 533 TransferInfo dst_transfer_info; |
| 534 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_rect.Pitch, | 534 MakeTransferInfo(&dst_transfer_info, mip_info, volume, locked_rect.Pitch, |
| 535 slice_pitch); | 535 slice_pitch); |
| 536 TransferVolume(volume, mip_info, dst_transfer_info, locked_rect.pBits, | 536 TransferVolume(volume, mip_info, dst_transfer_info, locked_rect.pBits, |
| 537 src_transfer_info, data); | 537 src_transfer_info, data); |
| 538 | 538 |
| 539 HR(lock_texture->UnlockRect(d3d_face, level)); | 539 HR(lock_texture->UnlockRect(d3d_face, level)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 HR(d3d_cube_texture->GetCubeMapSurface( | 601 HR(d3d_cube_texture->GetCubeMapSurface( |
| 602 D3DFace(static_cast<texture::Face>(side)), | 602 D3DFace(static_cast<texture::Face>(side)), |
| 603 mip_level, | 603 mip_level, |
| 604 direct3d_surface)); | 604 direct3d_surface)); |
| 605 return true; | 605 return true; |
| 606 } | 606 } |
| 607 | 607 |
| 608 // GAPID3D9 functions. | 608 // GAPID3D9 functions. |
| 609 | 609 |
| 610 // Destroys a texture resource. | 610 // Destroys a texture resource. |
| 611 BufferSyncInterface::ParseError GAPID3D9::DestroyTexture(ResourceID id) { | 611 BufferSyncInterface::ParseError GAPID3D9::DestroyTexture(ResourceId id) { |
| 612 // Dirty effect, because this texture id may be used | 612 // Dirty effect, because this texture id may be used |
| 613 DirtyEffect(); | 613 DirtyEffect(); |
| 614 return textures_.Destroy(id) ? | 614 return textures_.Destroy(id) ? |
| 615 BufferSyncInterface::kParseNoError : | 615 BufferSyncInterface::kParseNoError : |
| 616 BufferSyncInterface::kParseInvalidArguments; | 616 BufferSyncInterface::kParseInvalidArguments; |
| 617 } | 617 } |
| 618 | 618 |
| 619 // Creates a 2D texture resource. | 619 // Creates a 2D texture resource. |
| 620 BufferSyncInterface::ParseError GAPID3D9::CreateTexture2D( | 620 BufferSyncInterface::ParseError GAPID3D9::CreateTexture2D( |
| 621 ResourceID id, | 621 ResourceId id, |
| 622 unsigned int width, | 622 unsigned int width, |
| 623 unsigned int height, | 623 unsigned int height, |
| 624 unsigned int levels, | 624 unsigned int levels, |
| 625 texture::Format format, | 625 texture::Format format, |
| 626 unsigned int flags, | 626 unsigned int flags, |
| 627 bool enable_render_surfaces) { | 627 bool enable_render_surfaces) { |
| 628 Texture2DD3D9 *texture = Texture2DD3D9::Create(this, width, height, levels, | 628 Texture2DD3D9 *texture = Texture2DD3D9::Create(this, width, height, levels, |
| 629 format, flags, | 629 format, flags, |
| 630 enable_render_surfaces); | 630 enable_render_surfaces); |
| 631 if (!texture) return BufferSyncInterface::kParseInvalidArguments; | 631 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
| 632 // Dirty effect, because this texture id may be used | 632 // Dirty effect, because this texture id may be used |
| 633 DirtyEffect(); | 633 DirtyEffect(); |
| 634 textures_.Assign(id, texture); | 634 textures_.Assign(id, texture); |
| 635 return BufferSyncInterface::kParseNoError; | 635 return BufferSyncInterface::kParseNoError; |
| 636 } | 636 } |
| 637 | 637 |
| 638 // Creates a 3D texture resource. | 638 // Creates a 3D texture resource. |
| 639 BufferSyncInterface::ParseError GAPID3D9::CreateTexture3D( | 639 BufferSyncInterface::ParseError GAPID3D9::CreateTexture3D( |
| 640 ResourceID id, | 640 ResourceId id, |
| 641 unsigned int width, | 641 unsigned int width, |
| 642 unsigned int height, | 642 unsigned int height, |
| 643 unsigned int depth, | 643 unsigned int depth, |
| 644 unsigned int levels, | 644 unsigned int levels, |
| 645 texture::Format format, | 645 texture::Format format, |
| 646 unsigned int flags, | 646 unsigned int flags, |
| 647 bool enable_render_surfaces) { | 647 bool enable_render_surfaces) { |
| 648 Texture3DD3D9 *texture = Texture3DD3D9::Create(this, width, height, depth, | 648 Texture3DD3D9 *texture = Texture3DD3D9::Create(this, width, height, depth, |
| 649 levels, format, flags, | 649 levels, format, flags, |
| 650 enable_render_surfaces); | 650 enable_render_surfaces); |
| 651 if (!texture) return BufferSyncInterface::kParseInvalidArguments; | 651 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
| 652 // Dirty effect, because this texture id may be used | 652 // Dirty effect, because this texture id may be used |
| 653 DirtyEffect(); | 653 DirtyEffect(); |
| 654 textures_.Assign(id, texture); | 654 textures_.Assign(id, texture); |
| 655 return BufferSyncInterface::kParseNoError; | 655 return BufferSyncInterface::kParseNoError; |
| 656 } | 656 } |
| 657 | 657 |
| 658 // Creates a cube map texture resource. | 658 // Creates a cube map texture resource. |
| 659 BufferSyncInterface::ParseError GAPID3D9::CreateTextureCube( | 659 BufferSyncInterface::ParseError GAPID3D9::CreateTextureCube( |
| 660 ResourceID id, | 660 ResourceId id, |
| 661 unsigned int side, | 661 unsigned int side, |
| 662 unsigned int levels, | 662 unsigned int levels, |
| 663 texture::Format format, | 663 texture::Format format, |
| 664 unsigned int flags, | 664 unsigned int flags, |
| 665 bool enable_render_surfaces) { | 665 bool enable_render_surfaces) { |
| 666 TextureCubeD3D9 *texture = TextureCubeD3D9::Create(this, side, levels, | 666 TextureCubeD3D9 *texture = TextureCubeD3D9::Create(this, side, levels, |
| 667 format, flags, | 667 format, flags, |
| 668 enable_render_surfaces); | 668 enable_render_surfaces); |
| 669 if (!texture) return BufferSyncInterface::kParseInvalidArguments; | 669 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
| 670 // Dirty effect, because this texture id may be used | 670 // Dirty effect, because this texture id may be used |
| 671 DirtyEffect(); | 671 DirtyEffect(); |
| 672 textures_.Assign(id, texture); | 672 textures_.Assign(id, texture); |
| 673 return BufferSyncInterface::kParseNoError; | 673 return BufferSyncInterface::kParseNoError; |
| 674 } | 674 } |
| 675 | 675 |
| 676 // Copies the data into a texture resource. | 676 // Copies the data into a texture resource. |
| 677 BufferSyncInterface::ParseError GAPID3D9::SetTextureData( | 677 BufferSyncInterface::ParseError GAPID3D9::SetTextureData( |
| 678 ResourceID id, | 678 ResourceId id, |
| 679 unsigned int x, | 679 unsigned int x, |
| 680 unsigned int y, | 680 unsigned int y, |
| 681 unsigned int z, | 681 unsigned int z, |
| 682 unsigned int width, | 682 unsigned int width, |
| 683 unsigned int height, | 683 unsigned int height, |
| 684 unsigned int depth, | 684 unsigned int depth, |
| 685 unsigned int level, | 685 unsigned int level, |
| 686 texture::Face face, | 686 texture::Face face, |
| 687 unsigned int row_pitch, | 687 unsigned int row_pitch, |
| 688 unsigned int slice_pitch, | 688 unsigned int slice_pitch, |
| 689 unsigned int size, | 689 unsigned int size, |
| 690 const void *data) { | 690 const void *data) { |
| 691 TextureD3D9 *texture = textures_.Get(id); | 691 TextureD3D9 *texture = textures_.Get(id); |
| 692 if (!texture) | 692 if (!texture) |
| 693 return BufferSyncInterface::kParseInvalidArguments; | 693 return BufferSyncInterface::kParseInvalidArguments; |
| 694 Volume volume = {x, y, z, width, height, depth}; | 694 Volume volume = {x, y, z, width, height, depth}; |
| 695 return texture->SetData(this, volume, level, face, row_pitch, slice_pitch, | 695 return texture->SetData(this, volume, level, face, row_pitch, slice_pitch, |
| 696 size, data) ? | 696 size, data) ? |
| 697 BufferSyncInterface::kParseNoError : | 697 BufferSyncInterface::kParseNoError : |
| 698 BufferSyncInterface::kParseInvalidArguments; | 698 BufferSyncInterface::kParseInvalidArguments; |
| 699 } | 699 } |
| 700 | 700 |
| 701 // Copies the data from a texture resource. | 701 // Copies the data from a texture resource. |
| 702 BufferSyncInterface::ParseError GAPID3D9::GetTextureData( | 702 BufferSyncInterface::ParseError GAPID3D9::GetTextureData( |
| 703 ResourceID id, | 703 ResourceId id, |
| 704 unsigned int x, | 704 unsigned int x, |
| 705 unsigned int y, | 705 unsigned int y, |
| 706 unsigned int z, | 706 unsigned int z, |
| 707 unsigned int width, | 707 unsigned int width, |
| 708 unsigned int height, | 708 unsigned int height, |
| 709 unsigned int depth, | 709 unsigned int depth, |
| 710 unsigned int level, | 710 unsigned int level, |
| 711 texture::Face face, | 711 texture::Face face, |
| 712 unsigned int row_pitch, | 712 unsigned int row_pitch, |
| 713 unsigned int slice_pitch, | 713 unsigned int slice_pitch, |
| 714 unsigned int size, | 714 unsigned int size, |
| 715 void *data) { | 715 void *data) { |
| 716 TextureD3D9 *texture = textures_.Get(id); | 716 TextureD3D9 *texture = textures_.Get(id); |
| 717 if (!texture) | 717 if (!texture) |
| 718 return BufferSyncInterface::kParseInvalidArguments; | 718 return BufferSyncInterface::kParseInvalidArguments; |
| 719 Volume volume = {x, y, z, width, height, depth}; | 719 Volume volume = {x, y, z, width, height, depth}; |
| 720 return texture->GetData(this, volume, level, face, row_pitch, slice_pitch, | 720 return texture->GetData(this, volume, level, face, row_pitch, slice_pitch, |
| 721 size, data) ? | 721 size, data) ? |
| 722 BufferSyncInterface::kParseNoError : | 722 BufferSyncInterface::kParseNoError : |
| 723 BufferSyncInterface::kParseInvalidArguments; | 723 BufferSyncInterface::kParseInvalidArguments; |
| 724 } | 724 } |
| 725 | 725 |
| 726 } // namespace command_buffer | 726 } // namespace command_buffer |
| 727 } // namespace o3d | 727 } // namespace o3d |
| OLD | NEW |