mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
Move bindless compile time flag to GL45 backend, fix warnings and compile errors
This commit is contained in:
parent
9056ee0f14
commit
c793a8d2c0
6 changed files with 27 additions and 21 deletions
|
@ -55,8 +55,6 @@
|
|||
#define GPU_STEREO_CAMERA_BUFFER
|
||||
#endif
|
||||
|
||||
#define GPU_BINDLESS_TEXTURES 0
|
||||
|
||||
namespace gpu { namespace gl {
|
||||
|
||||
class GLBackend : public Backend, public std::enable_shared_from_this<GLBackend> {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#define INCREMENTAL_TRANSFER 0
|
||||
#define GPU_SSBO_TRANSFORM_OBJECT 1
|
||||
#define GPU_BINDLESS_TEXTURES 0
|
||||
|
||||
namespace gpu { namespace gl45 {
|
||||
|
||||
|
@ -92,20 +93,11 @@ public:
|
|||
private:
|
||||
mutable Bindless _bindless;
|
||||
#endif
|
||||
class InvalidSampler : public Sampler {
|
||||
public:
|
||||
InvalidSampler() {
|
||||
_desc._borderColor = vec4(-1.0f);
|
||||
}
|
||||
|
||||
operator const Sampler&() const {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
static Sampler getInvalidSampler();
|
||||
|
||||
static const Sampler INVALID_SAMPLER;
|
||||
// This stores the texture handle (64 bits) in xy, the min mip available in z, and the sampler ID in w
|
||||
mutable Sampler _cachedSampler{ INVALID_SAMPLER };
|
||||
mutable Sampler _cachedSampler{ getInvalidSampler() };
|
||||
};
|
||||
|
||||
#if GPU_BINDLESS_TEXTURES
|
||||
|
|
|
@ -163,7 +163,18 @@ private:
|
|||
};
|
||||
|
||||
static GLSamplerCache SAMPLER_CACHE;
|
||||
const Sampler GL45Texture::INVALID_SAMPLER = GL45Texture::InvalidSampler();
|
||||
|
||||
|
||||
Sampler GL45Texture::getInvalidSampler() {
|
||||
static Sampler INVALID_SAMPLER;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
Sampler::Desc invalidDesc;
|
||||
invalidDesc._borderColor = vec4(-1.0f);
|
||||
INVALID_SAMPLER = Sampler(invalidDesc);
|
||||
});
|
||||
return INVALID_SAMPLER;
|
||||
}
|
||||
|
||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture)
|
||||
: GLTexture(backend, texture, allocate(texture)) {
|
||||
|
|
|
@ -185,7 +185,7 @@ void GL45ResourceTexture::promote() {
|
|||
glDeleteTextures(1, &oldId);
|
||||
|
||||
// Update sampler
|
||||
_cachedSampler = InvalidSampler();
|
||||
_cachedSampler = getInvalidSampler();
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
|
@ -228,7 +228,7 @@ void GL45ResourceTexture::demote() {
|
|||
glDeleteTextures(1, &oldId);
|
||||
|
||||
// Update sampler
|
||||
_cachedSampler = InvalidSampler();
|
||||
_cachedSampler = getInvalidSampler();
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <shared/GlobalAppProperties.h>
|
||||
using namespace gpu;
|
||||
|
||||
|
||||
const size_t TextureTable::COUNT{ TEXTURE_TABLE_COUNT };
|
||||
|
||||
TextureTable::TextureTable() { }
|
||||
|
||||
TextureTable::TextureTable(const std::initializer_list<TexturePointer>& textures) {
|
||||
|
@ -23,7 +26,7 @@ TextureTable::TextureTable(const std::initializer_list<TexturePointer>& textures
|
|||
}
|
||||
}
|
||||
|
||||
TextureTable::TextureTable(const std::array<TexturePointer, COUNT>& textures) : _stamp(1), _textures(textures) {
|
||||
TextureTable::TextureTable(const Array& textures) : _textures(textures) {
|
||||
}
|
||||
|
||||
void TextureTable::setTexture(size_t index, const TexturePointer& texturePointer) {
|
||||
|
|
|
@ -12,15 +12,17 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#define TEXTURE_TABLE_COUNT 8
|
||||
|
||||
namespace gpu {
|
||||
|
||||
class TextureTable {
|
||||
public:
|
||||
static const size_t COUNT = 8;
|
||||
using Array = std::array<TexturePointer, COUNT>;
|
||||
static const size_t COUNT;
|
||||
using Array = std::array<TexturePointer, TEXTURE_TABLE_COUNT>;
|
||||
TextureTable();
|
||||
TextureTable(const std::initializer_list<TexturePointer>& textures);
|
||||
TextureTable(const std::array<TexturePointer, COUNT>& textures);
|
||||
TextureTable(const Array& textures);
|
||||
|
||||
// Only for gpu::Context
|
||||
const GPUObjectPointer gpuObject{};
|
||||
|
@ -34,7 +36,7 @@ public:
|
|||
private:
|
||||
mutable Mutex _mutex;
|
||||
Array _textures;
|
||||
Stamp _stamp{ 0 };
|
||||
Stamp _stamp{ 1 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue