mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:29:03 +02:00
Fixing the bug regarding the numMIps allocated by GLBackend and breaking the HalfRezDepthTexture
This commit is contained in:
parent
73227f6598
commit
618344fe98
7 changed files with 16 additions and 16 deletions
|
@ -72,7 +72,7 @@ GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
|
||||||
incrementTextureGPUCount();
|
incrementTextureGPUCount();
|
||||||
withPreservedTexture([&] {
|
withPreservedTexture([&] {
|
||||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||||
auto numMips = _gpuObject.evalNumMips();
|
auto numMips = _gpuObject.getNumMipLevels();
|
||||||
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
||||||
// Get the mip level dimensions, accounting for the downgrade level
|
// Get the mip level dimensions, accounting for the downgrade level
|
||||||
Vec3u dimensions = _gpuObject.evalMipDimensions(mipLevel);
|
Vec3u dimensions = _gpuObject.evalMipDimensions(mipLevel);
|
||||||
|
|
|
@ -186,8 +186,10 @@ GL45FixedAllocationTexture::~GL45FixedAllocationTexture() {
|
||||||
void GL45FixedAllocationTexture::allocateStorage() const {
|
void GL45FixedAllocationTexture::allocateStorage() const {
|
||||||
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
||||||
const auto dimensions = _gpuObject.getDimensions();
|
const auto dimensions = _gpuObject.getDimensions();
|
||||||
const auto mips = _gpuObject.evalNumMips();
|
const auto mips = _gpuObject.getNumMipLevels();
|
||||||
|
|
||||||
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||||
|
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45FixedAllocationTexture::syncSampler() const {
|
void GL45FixedAllocationTexture::syncSampler() const {
|
||||||
|
@ -214,7 +216,7 @@ GL45AttachmentTexture::~GL45AttachmentTexture() {
|
||||||
using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture;
|
using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture;
|
||||||
|
|
||||||
GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
||||||
auto mipLevels = _gpuObject.evalNumMips();
|
auto mipLevels = _gpuObject.getNumMipLevels();
|
||||||
for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) {
|
for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) {
|
||||||
uint16_t targetMip = sourceMip;
|
uint16_t targetMip = sourceMip;
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
|
|
|
@ -418,8 +418,8 @@ public:
|
||||||
|
|
||||||
uint32 evalTotalSize(uint16 startingMip = 0) const {
|
uint32 evalTotalSize(uint16 startingMip = 0) const {
|
||||||
uint32 size = 0;
|
uint32 size = 0;
|
||||||
uint16 minMipLevel = std::max(minMip(), startingMip);
|
uint16 minMipLevel = std::max(getMinMip(), startingMip);
|
||||||
uint16 maxMipLevel = maxMip();
|
uint16 maxMipLevel = getMaxMip();
|
||||||
for (uint16 l = minMipLevel; l <= maxMipLevel; l++) {
|
for (uint16 l = minMipLevel; l <= maxMipLevel; l++) {
|
||||||
size += evalMipSize(l);
|
size += evalMipSize(l);
|
||||||
}
|
}
|
||||||
|
@ -429,12 +429,9 @@ public:
|
||||||
// max mip is in the range [ 0 if no sub mips, log2(max(width, height, depth))]
|
// max mip is in the range [ 0 if no sub mips, log2(max(width, height, depth))]
|
||||||
// if autoGenerateMip is on => will provide the maxMIp level specified
|
// if autoGenerateMip is on => will provide the maxMIp level specified
|
||||||
// else provide the deepest mip level provided through assignMip
|
// else provide the deepest mip level provided through assignMip
|
||||||
uint16 maxMip() const { return _maxMip; }
|
uint16 getMaxMip() const { return _maxMip; }
|
||||||
|
uint16 getMinMip() const { return _minMip; }
|
||||||
uint16 minMip() const { return _minMip; }
|
uint16 getNumMipLevels() const { return _maxMip + 1; }
|
||||||
|
|
||||||
uint16 mipLevels() const { return _maxMip + 1; }
|
|
||||||
|
|
||||||
uint16 usedMipLevels() const { return (_maxMip - _minMip) + 1; }
|
uint16 usedMipLevels() const { return (_maxMip - _minMip) + 1; }
|
||||||
|
|
||||||
const std::string& source() const { return _source; }
|
const std::string& source() const { return _source; }
|
||||||
|
|
|
@ -121,7 +121,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number level of mips coming
|
// Number level of mips coming
|
||||||
header.numberOfMipmapLevels = texture.maxMip() + 1;
|
header.numberOfMipmapLevels = texture.getNumMipLevels();
|
||||||
|
|
||||||
ktx::Images images;
|
ktx::Images images;
|
||||||
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
||||||
|
|
|
@ -74,11 +74,12 @@ void AmbientOcclusionFramebuffer::allocate() {
|
||||||
auto width = _frameSize.x;
|
auto width = _frameSize.x;
|
||||||
auto height = _frameSize.y;
|
auto height = _frameSize.y;
|
||||||
|
|
||||||
_occlusionTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
// _occlusionTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
|
_occlusionTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));
|
_occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));
|
||||||
_occlusionFramebuffer->setRenderBuffer(0, _occlusionTexture);
|
_occlusionFramebuffer->setRenderBuffer(0, _occlusionTexture);
|
||||||
|
|
||||||
_occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
_occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_occlusionBlurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusionBlurred"));
|
_occlusionBlurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusionBlurred"));
|
||||||
_occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture);
|
_occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ void LinearDepthFramebuffer::allocate() {
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_halfLinearDepthTexture->autoGenerateMips(5);
|
_halfLinearDepthTexture->autoGenerateMips(5);
|
||||||
|
|
||||||
_halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB), _halfFrameSize.x, _halfFrameSize.y,
|
_halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, _halfFrameSize.x, _halfFrameSize.y,
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
|
|
||||||
_downsampleFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("halfLinearDepth"));
|
_downsampleFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("halfLinearDepth"));
|
||||||
|
|
|
@ -456,7 +456,7 @@ protected:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto texture = _textures[_currentTextureIndex];
|
auto texture = _textures[_currentTextureIndex];
|
||||||
texture->setMinMip(texture->minMip() + 1);
|
texture->setMinMip(texture->getMinMip() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadTexture() {
|
void loadTexture() {
|
||||||
|
|
Loading…
Reference in a new issue