* @param texture defines the BabylonJS internal texture
* @param callback defines the method to call once ready to upload
*/
public loadData(
data: ArrayBufferView,
texture: InternalTexture,
callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void
): void {
const info = DDSTools.GetDDSInfo(data);
const loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && info.width >> (info.mipmapCount - 1) === 1;
callback(info.width, info.height, loadMipmap, info.isFourCC, () => {
DDSTools.UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
});
}
}
// Register the loader.
Engine._TextureLoaders.push(new _DDSTextureLoader());
I don’t know if I have to create additional playground, but comparing 1 with info.width >> (info.mipmapCount - 1)
instead of something like Math.max(info.width, info.height) >> (info.mipmapCount - 1) === 1
disables mipmap loading for the texture with height bigger than width. Additionally, it makes possible reassignment here
currentFace?: number,
destTypeMustBeFilterable = true
) {
let sphericalPolynomialFaces: Nullable<Array<ArrayBufferView>> = null;
if (info.sphericalPolynomial) {
sphericalPolynomialFaces = [] as ArrayBufferView[];
}
const ext = !!engine.getCaps().s3tc;
// TODO WEBGPU Once generateMipMaps is split into generateMipMaps + hasMipMaps in InternalTexture this line can be removed
texture.generateMipMaps = loadMipmaps;
const header = new Int32Array(data.buffer, data.byteOffset, headerLengthInt);
let fourCC: number,
width: number,
height: number,
dataLength: number = 0,
dataOffset: number;
let byteArray: Uint8Array, mipmapCount: number, mip: number;
let internalCompressedFormat = 0;
let blockBytes = 1;
which when value is set to opposite duplicates entry in texture cache (noMipmap
will be the same as generateMipMaps
and thus textures will be compared as different) and will try to reupload it (or create duplicate if buffer is passed):
}
const correctedUseSRGBBuffer = engine._getUseSRGBBuffer(!!useSRGBBuffer, noMipmap);
const texturesCache = engine.getLoadedTexturesCache();
for (let index = 0; index < texturesCache.length; index++) {
const texturesCacheEntry = texturesCache[index];
if (useSRGBBuffer === undefined || correctedUseSRGBBuffer === texturesCacheEntry._useSRGBBuffer) {
if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
if (!sampling || sampling === texturesCacheEntry.samplingMode) {
if (isCube === undefined || isCube === texturesCacheEntry.isCube) {
texturesCacheEntry.incrementReferences();
return texturesCacheEntry;
}
}
}
}
}
}
UPD: For some reason post was flagged as spam by community, I don’t know why
i’ll CC @Deltakosh for his opinion. Gut feeling is that we can remove this check, but I didn’t dive too deep into the code.
Would it be OK for me to initiate PR meanwhile until it is decided should this parameter be present at all?
1 Like
Also I am confused why this (and my another older post where bug was resolved) was hidden by community flag and flagged as spam
The system marks posts as spam sometimes, when they contain links from a new user. I am reviewing those once or twice a day, so it might take a few minutes until it is freed. Sorry about that!
Ah, thanks, makes much more sense
1 Like
Do you mind sending a PR so we can run tests. I’m with you, this should be fine but let’s run tests to be sure
wonderful! I merged it! it is all good
1 Like