mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:21:32 +02:00
commit
b586425ec2
1 changed files with 11 additions and 9 deletions
|
@ -40,7 +40,7 @@ struct GPUKTXPayload {
|
||||||
Sampler::Desc _samplerDesc;
|
Sampler::Desc _samplerDesc;
|
||||||
Texture::Usage _usage;
|
Texture::Usage _usage;
|
||||||
TextureUsageType _usageType;
|
TextureUsageType _usageType;
|
||||||
glm::ivec2 _originalSize;
|
glm::ivec2 _originalSize { 0, 0 };
|
||||||
|
|
||||||
Byte* serialize(Byte* data) const {
|
Byte* serialize(Byte* data) const {
|
||||||
*(Version*)data = CURRENT_VERSION;
|
*(Version*)data = CURRENT_VERSION;
|
||||||
|
@ -65,15 +65,14 @@ struct GPUKTXPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unserialize(const Byte* data, size_t size) {
|
bool unserialize(const Byte* data, size_t size) {
|
||||||
if (size != SIZE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Version version = *(const Version*)data;
|
Version version = *(const Version*)data;
|
||||||
if (version != CURRENT_VERSION) {
|
data += sizeof(Version);
|
||||||
|
|
||||||
|
if (version > CURRENT_VERSION) {
|
||||||
|
// If we try to load a version that we don't know how to parse,
|
||||||
|
// it will render incorrectly
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
data += sizeof(Version);
|
|
||||||
|
|
||||||
memcpy(&_samplerDesc, data, sizeof(Sampler::Desc));
|
memcpy(&_samplerDesc, data, sizeof(Sampler::Desc));
|
||||||
data += sizeof(Sampler::Desc);
|
data += sizeof(Sampler::Desc);
|
||||||
|
@ -88,8 +87,11 @@ struct GPUKTXPayload {
|
||||||
memcpy(&_usageType, data, sizeof(TextureUsageType));
|
memcpy(&_usageType, data, sizeof(TextureUsageType));
|
||||||
data += sizeof(TextureUsageType);
|
data += sizeof(TextureUsageType);
|
||||||
|
|
||||||
memcpy(&_originalSize, data, sizeof(glm::ivec2));
|
if (version >= 2) {
|
||||||
data += sizeof(glm::ivec2);
|
memcpy(&_originalSize, data, sizeof(glm::ivec2));
|
||||||
|
data += sizeof(glm::ivec2);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue