* @memberof ktxTexture2 @private * @~English * @brief Construct a ktxTexture from a ktxStream reading from a KTX source. * * The KTX header, which must have been read prior to calling this, is passed * to the function. * * The stream object is copied into the constructed ktxTexture2. * * The create flag KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT should not be set, * if the ktxTexture is ulti
| 672 | * supported by OpenGL or Vulkan, e.g, a 3D array. |
| 673 | */ |
| 674 | KTX_error_code |
| 675 | ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, |
| 676 | KTX_header2* pHeader, |
| 677 | ktxTextureCreateFlags createFlags) |
| 678 | { |
| 679 | ktxTexture2_private* private; |
| 680 | KTX_error_code result; |
| 681 | KTX_supplemental_info suppInfo; |
| 682 | ktxStream* stream; |
| 683 | struct BDFD* pBDFD; |
| 684 | ktx_size_t levelIndexSize; |
| 685 | |
| 686 | assert(pHeader != NULL && pStream != NULL); |
| 687 | |
| 688 | memset(This, 0, sizeof(*This)); |
| 689 | result = ktxTexture_constructFromStream(ktxTexture(This), pStream, |
| 690 | createFlags); |
| 691 | if (result != KTX_SUCCESS) |
| 692 | return result; |
| 693 | |
| 694 | result = ktxCheckHeader2_(pHeader, &suppInfo); |
| 695 | if (result != KTX_SUCCESS) |
| 696 | goto cleanup; |
| 697 | // ktxCheckHeader2_ has done the max(1, levelCount) on pHeader->levelCount. |
| 698 | result = ktxTexture2_constructCommon(This, pHeader->levelCount); |
| 699 | if (result != KTX_SUCCESS) |
| 700 | goto cleanup; |
| 701 | private = This->_private; |
| 702 | |
| 703 | stream = ktxTexture2_getStream(This); |
| 704 | |
| 705 | /* |
| 706 | * Initialize from pHeader->info. |
| 707 | */ |
| 708 | This->vkFormat = pHeader->vkFormat; |
| 709 | This->supercompressionScheme = pHeader->supercompressionScheme; |
| 710 | |
| 711 | This->_protected->_typeSize = pHeader->typeSize; |
| 712 | // Can these be done by a ktxTexture_constructFromStream? |
| 713 | This->numDimensions = suppInfo.textureDimension; |
| 714 | This->baseWidth = pHeader->pixelWidth; |
| 715 | assert(suppInfo.textureDimension > 0 && suppInfo.textureDimension < 4); |
| 716 | switch (suppInfo.textureDimension) { |
| 717 | case 1: |
| 718 | This->baseHeight = This->baseDepth = 1; |
| 719 | break; |
| 720 | case 2: |
| 721 | This->baseHeight = pHeader->pixelHeight; |
| 722 | This->baseDepth = 1; |
| 723 | break; |
| 724 | case 3: |
| 725 | This->baseHeight = pHeader->pixelHeight; |
| 726 | This->baseDepth = pHeader->pixelDepth; |
| 727 | break; |
| 728 | } |
| 729 | if (pHeader->layerCount > 0) { |
| 730 | This->numLayers = pHeader->layerCount; |
| 731 | This->isArray = KTX_TRUE; |
no test coverage detected