mirror of
https://github.com/lubosz/overte.git
synced 2025-04-18 13:57:42 +02:00
force data in MemoryStorage to be word aligned to avoid crash in glTextureSubImage2D
This commit is contained in:
parent
3c652a52d8
commit
c9868640c1
4 changed files with 13 additions and 9 deletions
|
@ -14,7 +14,7 @@
|
|||
class OtherAvatar : public Avatar {
|
||||
public:
|
||||
explicit OtherAvatar(QThread* thread, RigPointer rig = nullptr);
|
||||
void instantiableAvatar() {};
|
||||
virtual void instantiableAvatar() override {};
|
||||
};
|
||||
|
||||
#endif // hifi_OtherAvatar_h
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
void addSample(T sample) {
|
||||
if (numSamples > 0) {
|
||||
average = (sample * WEIGHTING) + (average * ONE_MINUS_WEIGHTING);
|
||||
average = (sample * (T)WEIGHTING) + (average * (T)ONE_MINUS_WEIGHTING);
|
||||
} else {
|
||||
average = sample;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ StoragePointer Storage::toFileStorage(const QString& filename) const {
|
|||
return FileStorage::create(filename, size(), data());
|
||||
}
|
||||
|
||||
MemoryStorage::MemoryStorage(size_t size, const uint8_t* data) {
|
||||
_data.resize(size);
|
||||
MemoryStorage::MemoryStorage(size_t size, const uint8_t* data) : _size(size) {
|
||||
_data.resize((size + 3) / 4); // alloc smallest number of 4-byte chunks that will cover size bytes
|
||||
|
||||
if (data) {
|
||||
memcpy(_data.data(), data, size);
|
||||
}
|
||||
|
|
|
@ -41,13 +41,16 @@ namespace storage {
|
|||
class MemoryStorage : public Storage {
|
||||
public:
|
||||
MemoryStorage(size_t size, const uint8_t* data = nullptr);
|
||||
const uint8_t* data() const override { return _data.data(); }
|
||||
uint8_t* data() { return _data.data(); }
|
||||
uint8_t* mutableData() override { return _data.data(); }
|
||||
size_t size() const override { return _data.size(); }
|
||||
const uint8_t* data() const override { return reinterpret_cast<const uint8_t*>(_data.data()); }
|
||||
uint8_t* data() { return reinterpret_cast<uint8_t*>(_data.data()); }
|
||||
uint8_t* mutableData() override { return reinterpret_cast<uint8_t*>(_data.data()); }
|
||||
|
||||
size_t _size { 0 };
|
||||
size_t size() const override { return _size; }
|
||||
operator bool() const override { return true; }
|
||||
private:
|
||||
std::vector<uint8_t> _data;
|
||||
// the vector is of uint32_t rather than uint8_t to force alignment
|
||||
std::vector<uint32_t> _data;
|
||||
};
|
||||
|
||||
class FileStorage : public Storage {
|
||||
|
|
Loading…
Reference in a new issue