mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
texture memory
This commit is contained in:
parent
c90c0b53c3
commit
e9add29af1
3 changed files with 24 additions and 4 deletions
|
@ -271,7 +271,12 @@ void GLBackend::syncGPUObject(const Texture& texture) {
|
|||
|
||||
if (texture.isAutogenerateMips()) {
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
// At this point the mip piels have been loaded, we can notify
|
||||
texture.notifyGPULoaded(0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, boundTex);
|
||||
object->_contentStamp = texture.getDataStamp();
|
||||
}
|
||||
|
@ -302,6 +307,9 @@ void GLBackend::syncGPUObject(const Texture& texture) {
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
// At this point the mip piels have been loaded, we can notify
|
||||
texture.notifyGPULoaded(0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, boundTex);
|
||||
object->_storageStamp = texture.getStamp();
|
||||
object->_size = texture.getSize();
|
||||
|
|
|
@ -17,7 +17,8 @@ using namespace gpu;
|
|||
|
||||
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
||||
_sysmem(size, bytes),
|
||||
_format(format) {
|
||||
_format(format),
|
||||
_isGPULoaded(false) {
|
||||
}
|
||||
|
||||
Texture::Pixels::~Pixels() {
|
||||
|
@ -53,6 +54,14 @@ const Texture::PixelsPointer Texture::Storage::getMip(uint16 level) const {
|
|||
return PixelsPointer();
|
||||
}
|
||||
|
||||
void Texture::Storage::notifyGPULoaded(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
if (mip) {
|
||||
mip->_isGPULoaded = true;
|
||||
mip->_sysmem.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::Storage::isMipAvailable(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
return (mip && mip->_sysmem.getSize());
|
||||
|
|
|
@ -26,8 +26,9 @@ public:
|
|||
Pixels(const Element& format, Size size, const Byte* bytes);
|
||||
~Pixels();
|
||||
|
||||
Sysmem _sysmem;
|
||||
mutable Sysmem _sysmem;
|
||||
Element _format;
|
||||
mutable bool _isGPULoaded;
|
||||
};
|
||||
typedef QSharedPointer< Pixels > PixelsPointer;
|
||||
|
||||
|
@ -42,7 +43,8 @@ public:
|
|||
virtual bool allocateMip(uint16 level);
|
||||
virtual bool assignMipData(uint16 level, const Element& format, Size size, const Byte* bytes);
|
||||
virtual bool isMipAvailable(uint16 level) const;
|
||||
|
||||
virtual void notifyGPULoaded(uint16 level) const;
|
||||
|
||||
protected:
|
||||
Texture* _texture;
|
||||
std::vector<PixelsPointer> _mips;
|
||||
|
@ -168,7 +170,8 @@ public:
|
|||
// Access the the sub mips
|
||||
bool isStoredMipAvailable(uint16 level) const { return _storage->isMipAvailable(level); }
|
||||
const PixelsPointer accessStoredMip(uint16 level) const { return _storage->getMip(level); }
|
||||
|
||||
void notifyGPULoaded(uint16 level) const { return _storage->notifyGPULoaded(level); }
|
||||
|
||||
// access sizes for the stored mips
|
||||
uint16 getStoredMipWidth(uint16 level) const;
|
||||
uint16 getStoredMipHeight(uint16 level) const;
|
||||
|
|
Loading…
Reference in a new issue