mirror of
https://github.com/overte-org/overte.git
synced 2025-06-21 14:21:18 +02:00
Prevent sparse texture on AMD gpus for now
This commit is contained in:
parent
b1582b474b
commit
6a39ad3b5a
6 changed files with 37 additions and 4 deletions
|
@ -56,6 +56,7 @@ BackendPointer GLBackend::createBackend() {
|
||||||
}
|
}
|
||||||
result->initInput();
|
result->initInput();
|
||||||
result->initTransform();
|
result->initTransform();
|
||||||
|
result->initTextureManagementStage();
|
||||||
|
|
||||||
INSTANCE = result.get();
|
INSTANCE = result.get();
|
||||||
void* voidInstance = &(*result);
|
void* voidInstance = &(*result);
|
||||||
|
|
|
@ -176,6 +176,9 @@ public:
|
||||||
virtual void releaseQuery(GLuint id) const;
|
virtual void releaseQuery(GLuint id) const;
|
||||||
virtual void queueLambda(const std::function<void()> lambda) const;
|
virtual void queueLambda(const std::function<void()> lambda) const;
|
||||||
|
|
||||||
|
bool isTextureManagementSparseEnabled() const { return (_textureManagement._sparseCapable && Texture::getEnableSparseTextures()); }
|
||||||
|
bool isTextureManagementIncrementalTransferEnabled() const { return (_textureManagement._incrementalTransferCapable && Texture::getEnableIncrementalTextureTransfers()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void recycle() const override;
|
void recycle() const override;
|
||||||
|
@ -364,6 +367,12 @@ protected:
|
||||||
|
|
||||||
void resetStages();
|
void resetStages();
|
||||||
|
|
||||||
|
struct TextureManagementStageState {
|
||||||
|
bool _sparseCapable { false };
|
||||||
|
bool _incrementalTransferCapable { false };
|
||||||
|
} _textureManagement;
|
||||||
|
virtual void initTextureManagementStage() {}
|
||||||
|
|
||||||
typedef void (GLBackend::*CommandCall)(const Batch&, size_t);
|
typedef void (GLBackend::*CommandCall)(const Batch&, size_t);
|
||||||
static CommandCall _commandCalls[Batch::NUM_COMMANDS];
|
static CommandCall _commandCalls[Batch::NUM_COMMANDS];
|
||||||
friend class GLState;
|
friend class GLState;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
static GLuint allocate(const Texture& texture);
|
static GLuint allocate(const Texture& texture);
|
||||||
static const uint32_t DEFAULT_PAGE_DIMENSION = 128;
|
static const uint32_t DEFAULT_PAGE_DIMENSION = 128;
|
||||||
static const uint32_t DEFAULT_MAX_SPARSE_LEVEL = 0xFFFF;
|
static const uint32_t DEFAULT_MAX_SPARSE_LEVEL = 0xFFFF;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint externalId);
|
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint externalId);
|
||||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable);
|
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable);
|
||||||
|
@ -132,6 +133,9 @@ protected:
|
||||||
|
|
||||||
// Output stage
|
// Output stage
|
||||||
void do_blit(const Batch& batch, size_t paramOffset) override;
|
void do_blit(const Batch& batch, size_t paramOffset) override;
|
||||||
|
|
||||||
|
// Texture Management Stage
|
||||||
|
void initTextureManagementStage() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -148,6 +148,22 @@ uint32_t SparseInfo::getPageCount(const uvec3& dimensions) const {
|
||||||
return pageCounts.x * pageCounts.y * pageCounts.z;
|
return pageCounts.x * pageCounts.y * pageCounts.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GL45Backend::initTextureManagementStage() {
|
||||||
|
|
||||||
|
// enable the Sparse Texture on gl45
|
||||||
|
_textureManagement._sparseCapable = true;
|
||||||
|
_textureManagement._incrementalTransferCapable = true;
|
||||||
|
|
||||||
|
// But now let s refine the behavior based on vendor
|
||||||
|
std::string vendor { (const char*)glGetString(GL_VENDOR) };
|
||||||
|
if ((vendor.compare("AMD") <= 0) || (vendor.compare("INTEL") <= 0)) {
|
||||||
|
qCDebug(gpugllogging, "GPU is sparse capable but force it off %s\n", vendor);
|
||||||
|
_textureManagement._sparseCapable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using TransferState = GL45Backend::GL45Texture::TransferState;
|
using TransferState = GL45Backend::GL45Texture::TransferState;
|
||||||
|
|
||||||
TransferState::TransferState(GL45Texture& texture) : texture(texture) {
|
TransferState::TransferState(GL45Texture& texture) : texture(texture) {
|
||||||
|
@ -250,7 +266,8 @@ GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
|
||||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
|
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
|
||||||
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this), _transferState(*this) {
|
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this), _transferState(*this) {
|
||||||
|
|
||||||
if (_transferrable && Texture::getEnableSparseTextures()) {
|
auto theBackend = _backend.lock();
|
||||||
|
if (_transferrable && theBackend && theBackend->isTextureManagementSparseEnabled()) {
|
||||||
_sparseInfo.maybeMakeSparse();
|
_sparseInfo.maybeMakeSparse();
|
||||||
if (_sparseInfo.sparse) {
|
if (_sparseInfo.sparse) {
|
||||||
Backend::incrementTextureGPUSparseCount();
|
Backend::incrementTextureGPUSparseCount();
|
||||||
|
@ -362,7 +379,8 @@ void GL45Texture::startTransfer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GL45Texture::continueTransfer() {
|
bool GL45Texture::continueTransfer() {
|
||||||
if (!Texture::getEnableIncrementalTextureTransfers()) {
|
auto backend = _backend.lock();
|
||||||
|
if (!backend || !backend->isTextureManagementIncrementalTransferEnabled()) {
|
||||||
size_t maxFace = GL_TEXTURE_CUBE_MAP == _target ? CUBE_NUM_FACES : 1;
|
size_t maxFace = GL_TEXTURE_CUBE_MAP == _target ? CUBE_NUM_FACES : 1;
|
||||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||||
for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) {
|
for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) {
|
||||||
|
|
|
@ -125,6 +125,7 @@ protected:
|
||||||
friend class Context;
|
friend class Context;
|
||||||
ContextStats _stats;
|
ContextStats _stats;
|
||||||
StereoState _stereo;
|
StereoState _stereo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Context {
|
class Context {
|
||||||
|
@ -270,7 +271,6 @@ protected:
|
||||||
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
|
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
|
||||||
static std::atomic<uint32_t> _textureGPUTransferCount;
|
static std::atomic<uint32_t> _textureGPUTransferCount;
|
||||||
|
|
||||||
|
|
||||||
friend class Backend;
|
friend class Backend;
|
||||||
};
|
};
|
||||||
typedef std::shared_ptr<Context> ContextPointer;
|
typedef std::shared_ptr<Context> ContextPointer;
|
||||||
|
|
|
@ -147,6 +147,7 @@ class Texture : public Resource {
|
||||||
|
|
||||||
static std::atomic<bool> _enableSparseTextures;
|
static std::atomic<bool> _enableSparseTextures;
|
||||||
static std::atomic<bool> _enableIncrementalTextureTransfers;
|
static std::atomic<bool> _enableIncrementalTextureTransfers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static uint32_t getTextureCPUCount();
|
static uint32_t getTextureCPUCount();
|
||||||
static Size getTextureCPUMemoryUsage();
|
static Size getTextureCPUMemoryUsage();
|
||||||
|
|
Loading…
Reference in a new issue