mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
first few elements
This commit is contained in:
parent
34633c2f19
commit
24b26e3097
2 changed files with 53 additions and 3 deletions
|
@ -17,6 +17,30 @@
|
|||
|
||||
using namespace gpu;
|
||||
|
||||
std::atomic<uint32_t> Texture::_textureSystemMemoryUsage;
|
||||
std::atomic<uint32_t> Texture::_textureVideoMemoryUsage;
|
||||
|
||||
uint32_t Texture::getCurrentSystemMemoryUsage() {
|
||||
return _textureSystemMemoryUsage.load();
|
||||
}
|
||||
uint32_t Texture::getCurrentVideoMemoryUsage() {
|
||||
return _textureVideoMemoryUsage.load();
|
||||
}
|
||||
|
||||
void Texture::addSystemMemoryUsage(uint32_t memorySize) {
|
||||
_textureSystemMemoryUsage.fetch_add(memorySize);
|
||||
}
|
||||
void Texture::subSystemMemoryUsage(uint32_t memorySize) {
|
||||
_textureSystemMemoryUsage.fetch_sub(memorySize);
|
||||
}
|
||||
|
||||
void Texture::addVideoMemoryUsage(uint32_t memorySize) {
|
||||
_textureVideoMemoryUsage.fetch_add(memorySize);
|
||||
}
|
||||
void Texture::subVideoMemoryUsage(uint32_t memorySize) {
|
||||
_textureVideoMemoryUsage.fetch_sub(memorySize);
|
||||
}
|
||||
|
||||
uint8 Texture::NUM_FACES_PER_TYPE[NUM_TYPES] = {1, 1, 1, 6};
|
||||
|
||||
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
||||
|
@ -28,6 +52,15 @@ Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
|||
Texture::Pixels::~Pixels() {
|
||||
}
|
||||
|
||||
Texture::Size Texture::Pixels::resize(Size pSize) {
|
||||
return _sysmem.resize(pSize);
|
||||
}
|
||||
|
||||
void Texture::Pixels::notifyGPULoaded() {
|
||||
_isGPULoaded = true;
|
||||
_sysmem.resize(0);
|
||||
}
|
||||
|
||||
void Texture::Storage::assignTexture(Texture* texture) {
|
||||
_texture = texture;
|
||||
if (_texture) {
|
||||
|
@ -60,8 +93,7 @@ const Texture::PixelsPointer Texture::Storage::getMipFace(uint16 level, uint8 fa
|
|||
void Texture::Storage::notifyMipFaceGPULoaded(uint16 level, uint8 face) const {
|
||||
PixelsPointer mipFace = getMipFace(level, face);
|
||||
if (mipFace && (_type != TEX_CUBE)) {
|
||||
mipFace->_isGPULoaded = true;
|
||||
mipFace->_sysmem.resize(0);
|
||||
mipFace->notifyGPULoaded();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <algorithm> //min max and more
|
||||
#include <bitset>
|
||||
#include <atomic>
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
|
@ -138,8 +139,20 @@ protected:
|
|||
};
|
||||
|
||||
class Texture : public Resource {
|
||||
static std::atomic<uint32_t> _textureSystemMemoryUsage;
|
||||
static std::atomic<uint32_t> _textureVideoMemoryUsage;
|
||||
|
||||
void addSystemMemoryUsage(uint32_t memorySize);
|
||||
void subSystemMemoryUsage(uint32_t memorySize);
|
||||
|
||||
void addVideoMemoryUsage(uint32_t memorySize);
|
||||
void subVideoMemoryUsage(uint32_t memorySize);
|
||||
|
||||
public:
|
||||
|
||||
uint32_t getCurrentSystemMemoryUsage();
|
||||
uint32_t getCurrentVideoMemoryUsage();
|
||||
|
||||
class Usage {
|
||||
public:
|
||||
enum FlagBit {
|
||||
|
@ -194,8 +207,13 @@ public:
|
|||
Pixels(const Element& format, Size size, const Byte* bytes);
|
||||
~Pixels();
|
||||
|
||||
Sysmem _sysmem;
|
||||
Size getSize() const { return _sysmem.getSize(); }
|
||||
Size resize(Size pSize);
|
||||
void notifyGPULoaded();
|
||||
|
||||
protected:
|
||||
Element _format;
|
||||
Sysmem _sysmem;
|
||||
bool _isGPULoaded;
|
||||
};
|
||||
typedef std::shared_ptr< Pixels > PixelsPointer;
|
||||
|
|
Loading…
Reference in a new issue