| 575 | } |
| 576 | |
| 577 | bool GPUTexture::Resize(int32 width, int32 height, int32 depth, PixelFormat format) |
| 578 | { |
| 579 | PROFILE_CPU(); |
| 580 | if (!IsAllocated()) |
| 581 | { |
| 582 | LOG(Warning, "Cannot resize not created textures."); |
| 583 | return true; |
| 584 | } |
| 585 | |
| 586 | auto desc = GetDescription(); |
| 587 | if (format == PixelFormat::Unknown) |
| 588 | format = desc.Format; |
| 589 | |
| 590 | // Skip if size won't change |
| 591 | if (desc.Width == width && desc.Height == height && desc.Depth == depth && desc.Format == format) |
| 592 | return false; |
| 593 | |
| 594 | desc.Format = format; |
| 595 | desc.Width = width; |
| 596 | desc.Height = height; |
| 597 | desc.Depth = depth; |
| 598 | if (desc.MipLevels > 1) |
| 599 | desc.MipLevels = CalculateMipMapCount(0, Math::Max(width, height)); |
| 600 | |
| 601 | // Recreate |
| 602 | return Init(desc); |
| 603 | } |
| 604 | |
| 605 | uint64 GPUTexture::calculateMemoryUsage() const |
| 606 | { |
no test coverage detected