mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 16:50:43 +02:00
Fix varaible allocated bindless textures
This commit is contained in:
parent
f9605cffb1
commit
bf1e5f1dbc
3 changed files with 23 additions and 4 deletions
|
@ -74,6 +74,14 @@ public:
|
||||||
uint32_t minMip{ 0 };
|
uint32_t minMip{ 0 };
|
||||||
uint32_t sampler{ 0 };
|
uint32_t sampler{ 0 };
|
||||||
|
|
||||||
|
bool operator==(const Bindless& other) const {
|
||||||
|
return handle == other.handle && minMip == other.minMip && sampler == other.sampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Bindless& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
return handle != 0;
|
return handle != 0;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +185,7 @@ public:
|
||||||
~GL45VariableAllocationTexture();
|
~GL45VariableAllocationTexture();
|
||||||
|
|
||||||
Size size() const override { return _size; }
|
Size size() const override { return _size; }
|
||||||
uint16 getMinMip() const override { return _populatedMip; }
|
uint16 getMinMip() const override { return _populatedMip - _allocatedMip; }
|
||||||
virtual const Bindless& getBindless() const override;
|
virtual const Bindless& getBindless() const override;
|
||||||
|
|
||||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||||
|
|
|
@ -249,7 +249,7 @@ void GL45Texture::releaseBindless() const {
|
||||||
glMakeTextureHandleNonResidentARB(_bindless.handle);
|
glMakeTextureHandleNonResidentARB(_bindless.handle);
|
||||||
_bindless = Bindless();
|
_bindless = Bindless();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45Texture::recreateBindless() const {
|
void GL45Texture::recreateBindless() const {
|
||||||
if (isBindless()) {
|
if (isBindless()) {
|
||||||
releaseBindless();
|
releaseBindless();
|
||||||
|
@ -439,6 +439,7 @@ GL45TextureTable* GL45Backend::syncGPUObject(const TextureTablePointer& textureT
|
||||||
}
|
}
|
||||||
|
|
||||||
object->update(handles);
|
object->update(handles);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,8 @@ void GL45ResourceTexture::promote() {
|
||||||
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
|
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
|
||||||
targetAllocatedMip = std::max<uint16_t>(_minAllocatedMip, targetAllocatedMip);
|
targetAllocatedMip = std::max<uint16_t>(_minAllocatedMip, targetAllocatedMip);
|
||||||
|
|
||||||
if (isBindless()) {
|
bool bindless = isBindless();
|
||||||
|
if (bindless) {
|
||||||
releaseBindless();
|
releaseBindless();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +164,10 @@ void GL45ResourceTexture::promote() {
|
||||||
// copy pre-existing mips
|
// copy pre-existing mips
|
||||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||||
|
|
||||||
|
if (bindless) {
|
||||||
|
getBindless();
|
||||||
|
}
|
||||||
|
|
||||||
// destroy the old texture
|
// destroy the old texture
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
|
|
||||||
|
@ -183,7 +188,8 @@ void GL45ResourceTexture::demote() {
|
||||||
auto oldSize = _size;
|
auto oldSize = _size;
|
||||||
auto oldPopulatedMip = _populatedMip;
|
auto oldPopulatedMip = _populatedMip;
|
||||||
|
|
||||||
if (isBindless()) {
|
bool bindless = isBindless();
|
||||||
|
if (bindless) {
|
||||||
releaseBindless();
|
releaseBindless();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +202,10 @@ void GL45ResourceTexture::demote() {
|
||||||
// copy pre-existing mips
|
// copy pre-existing mips
|
||||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||||
|
|
||||||
|
if (bindless) {
|
||||||
|
getBindless();
|
||||||
|
}
|
||||||
|
|
||||||
// destroy the old texture
|
// destroy the old texture
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue