Minor image loading optimization and fix

This commit is contained in:
Sascha Willems 2020-05-15 07:11:47 +02:00
parent 78a9b5bde1
commit 940aef5b86

View file

@ -164,9 +164,7 @@ public:
unsigned char* rgba = buffer; unsigned char* rgba = buffer;
unsigned char* rgb = &glTFImage.image[0]; unsigned char* rgb = &glTFImage.image[0];
for (size_t i = 0; i < glTFImage.width * glTFImage.height; ++i) { for (size_t i = 0; i < glTFImage.width * glTFImage.height; ++i) {
for (int32_t j = 0; j < 3; ++j) { memcpy(rgba, rgb, sizeof(unsigned char) * 3);
rgba[j] = rgb[j];
}
rgba += 4; rgba += 4;
rgb += 3; rgb += 3;
} }
@ -178,6 +176,9 @@ public:
} }
// Load texture from image buffer // Load texture from image buffer
images[i].texture.fromBuffer(buffer, bufferSize, VK_FORMAT_R8G8B8A8_UNORM, glTFImage.width, glTFImage.height, vulkanDevice, copyQueue); images[i].texture.fromBuffer(buffer, bufferSize, VK_FORMAT_R8G8B8A8_UNORM, glTFImage.width, glTFImage.height, vulkanDevice, copyQueue);
if (deleteBuffer) {
delete buffer;
}
} }
} }