Fix varaible allocated bindless textures

This commit is contained in:
Brad Davis 2018-03-07 16:00:14 -08:00
parent f9605cffb1
commit bf1e5f1dbc
3 changed files with 23 additions and 4 deletions

View file

@ -74,6 +74,14 @@ public:
uint32_t minMip{ 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 {
return handle != 0;
}
@ -177,7 +185,7 @@ public:
~GL45VariableAllocationTexture();
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;
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;

View file

@ -249,7 +249,7 @@ void GL45Texture::releaseBindless() const {
glMakeTextureHandleNonResidentARB(_bindless.handle);
_bindless = Bindless();
}
void GL45Texture::recreateBindless() const {
if (isBindless()) {
releaseBindless();
@ -439,6 +439,7 @@ GL45TextureTable* GL45Backend::syncGPUObject(const TextureTablePointer& textureT
}
object->update(handles);
return object;
}

View file

@ -146,7 +146,8 @@ void GL45ResourceTexture::promote() {
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
targetAllocatedMip = std::max<uint16_t>(_minAllocatedMip, targetAllocatedMip);
if (isBindless()) {
bool bindless = isBindless();
if (bindless) {
releaseBindless();
}
@ -163,6 +164,10 @@ void GL45ResourceTexture::promote() {
// copy pre-existing mips
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
if (bindless) {
getBindless();
}
// destroy the old texture
glDeleteTextures(1, &oldId);
@ -183,7 +188,8 @@ void GL45ResourceTexture::demote() {
auto oldSize = _size;
auto oldPopulatedMip = _populatedMip;
if (isBindless()) {
bool bindless = isBindless();
if (bindless) {
releaseBindless();
}
@ -196,6 +202,10 @@ void GL45ResourceTexture::demote() {
// copy pre-existing mips
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
if (bindless) {
getBindless();
}
// destroy the old texture
glDeleteTextures(1, &oldId);