| 48 | } |
| 49 | |
| 50 | bool GFXTextureArray::fromTextureArray(const Vector<GFXTexHandle>& textureArray, U32 capacity) |
| 51 | { |
| 52 | PROFILE_SCOPE(GFXTextureArray_fromTextureArray) |
| 53 | bool success = true; |
| 54 | |
| 55 | // Not initialized, infer it from the given array of textures |
| 56 | if (mArraySize == 0) |
| 57 | { |
| 58 | bool found = false; |
| 59 | for (const GFXTexHandle& texObj : textureArray) |
| 60 | { |
| 61 | if (texObj.isValid()) |
| 62 | { |
| 63 | if (!found) |
| 64 | { |
| 65 | found = true; |
| 66 | mFormat = texObj.getFormat(); |
| 67 | mWidth = texObj.getWidth(); |
| 68 | mHeight = texObj.getHeight(); |
| 69 | mMipLevels = texObj->getMipLevels(); |
| 70 | } |
| 71 | |
| 72 | if (mFormat != texObj.getFormat() || mWidth != texObj.getWidth() || mHeight != texObj.getHeight()) |
| 73 | { |
| 74 | AssertWarn(true, "GFXTextureArray::fromTextureArray there was a mismatch in texture formats, defaulting to uncompressed format"); |
| 75 | Con::warnf("GFXTextureArray::fromTextureArray there was a mismatch in texture formats, defaulting to uncompressed format"); |
| 76 | success = false; |
| 77 | mFormat = GFXFormatR8G8B8A8; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // One might think this should return false in this case, but the return value is mostly to highlight internal errors not input errors. |
| 83 | if (!found) return true; |
| 84 | |
| 85 | |
| 86 | //--------------------------------------------------------------------------------------- |
| 87 | // Create the texture array. Each element in the texture |
| 88 | // array has the same format/dimensions. |
| 89 | //--------------------------------------------------------------------------------------- |
| 90 | U32 size = capacity; |
| 91 | if (size == 0) |
| 92 | { |
| 93 | size = textureArray.size(); |
| 94 | } |
| 95 | set(mWidth, mHeight, size, mFormat, mMipLevels); |
| 96 | } |
| 97 | //--------------------------------------------------------------------------------------- |
| 98 | |
| 99 | |
| 100 | //--------------------------------------------------------------------------------------- |
| 101 | // Copy individual texture elements into texture array. |
| 102 | //--------------------------------------------------------------------------------------- |
| 103 | // for each texture element... |
| 104 | for (U32 i = 0; i < textureArray.size(); ++i) |
| 105 | { |
| 106 | if (textureArray[i].isValid()) |
| 107 | { |
no test coverage detected