Merge pull request #8993 from samcake/blue

Prevent sparse texture on AMD gpus for now
This commit is contained in:
Brad Hefta-Gaub 2016-11-03 16:48:52 -07:00 committed by GitHub
commit 7cca8f0a66
7 changed files with 41 additions and 5 deletions

View file

@ -302,7 +302,7 @@ void Stats::updateStats(bool force) {
STAT_UPDATE(gpuTextureVirtualMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUVirtualMemoryUsage()));
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUFramebufferMemoryUsage()));
STAT_UPDATE(gpuTextureSparseMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUSparseMemoryUsage()));
STAT_UPDATE(gpuSparseTextureEnabled, gpu::Texture::getEnableSparseTextures() ? 1 : 0);
STAT_UPDATE(gpuSparseTextureEnabled, qApp->getGPUContext()->getBackend()->isTextureManagementSparseEnabled() ? 1 : 0);
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()));
STAT_UPDATE(rectifiedTextureCount, (int)RECTIFIED_TEXTURE_COUNT.load());
STAT_UPDATE(decimatedTextureCount, (int)DECIMATED_TEXTURE_COUNT.load());

View file

@ -56,6 +56,7 @@ BackendPointer GLBackend::createBackend() {
}
result->initInput();
result->initTransform();
result->initTextureManagementStage();
INSTANCE = result.get();
void* voidInstance = &(*result);

View file

@ -176,6 +176,9 @@ public:
virtual void releaseQuery(GLuint id) const;
virtual void queueLambda(const std::function<void()> lambda) const;
bool isTextureManagementSparseEnabled() const override { return (_textureManagement._sparseCapable && Texture::getEnableSparseTextures()); }
bool isTextureManagementIncrementalTransferEnabled() const override { return (_textureManagement._incrementalTransferCapable && Texture::getEnableIncrementalTextureTransfers()); }
protected:
void recycle() const override;
@ -364,6 +367,12 @@ protected:
void resetStages();
struct TextureManagementStageState {
bool _sparseCapable { false };
bool _incrementalTransferCapable { false };
} _textureManagement;
virtual void initTextureManagementStage() {}
typedef void (GLBackend::*CommandCall)(const Batch&, size_t);
static CommandCall _commandCalls[Batch::NUM_COMMANDS];
friend class GLState;

View file

@ -32,6 +32,7 @@ public:
static GLuint allocate(const Texture& texture);
static const uint32_t DEFAULT_PAGE_DIMENSION = 128;
static const uint32_t DEFAULT_MAX_SPARSE_LEVEL = 0xFFFF;
public:
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint externalId);
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable);
@ -132,6 +133,9 @@ protected:
// Output stage
void do_blit(const Batch& batch, size_t paramOffset) override;
// Texture Management Stage
void initTextureManagementStage() override;
};
} }

View file

@ -148,6 +148,24 @@ uint32_t SparseInfo::getPageCount(const uvec3& dimensions) const {
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.find("AMD") != std::string::npos) || (vendor.find("ATI") != std::string::npos) || (vendor.find("INTEL") != std::string::npos)) {
qCDebug(gpugllogging) << "GPU is sparse capable but force it off, vendor = " << vendor.c_str();
_textureManagement._sparseCapable = false;
} else {
qCDebug(gpugllogging) << "GPU is sparse capable, vendor = " << vendor.c_str();
}
}
using TransferState = GL45Backend::GL45Texture::TransferState;
TransferState::TransferState(GL45Texture& texture) : texture(texture) {
@ -250,7 +268,8 @@ GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
: 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();
if (_sparseInfo.sparse) {
Backend::incrementTextureGPUSparseCount();
@ -362,7 +381,8 @@ void GL45Texture::startTransfer() {
}
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;
for (uint8_t face = 0; face < maxFace; ++face) {
for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) {

View file

@ -85,7 +85,8 @@ public:
void getStats(ContextStats& stats) const { stats = _stats; }
virtual bool isTextureManagementSparseEnabled() const = 0;
virtual bool isTextureManagementIncrementalTransferEnabled() const = 0;
// These should only be accessed by Backend implementation to repport the buffer and texture allocations,
// they are NOT public calls
@ -125,6 +126,7 @@ protected:
friend class Context;
ContextStats _stats;
StereoState _stereo;
};
class Context {
@ -270,7 +272,6 @@ protected:
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
static std::atomic<uint32_t> _textureGPUTransferCount;
friend class Backend;
};
typedef std::shared_ptr<Context> ContextPointer;

View file

@ -147,6 +147,7 @@ class Texture : public Resource {
static std::atomic<bool> _enableSparseTextures;
static std::atomic<bool> _enableIncrementalTextureTransfers;
public:
static uint32_t getTextureCPUCount();
static Size getTextureCPUMemoryUsage();