mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Disable support for framebuffer resizing
This commit is contained in:
parent
0953027ef3
commit
82db3d5d55
5 changed files with 38 additions and 38 deletions
|
@ -115,29 +115,31 @@ void Framebuffer::updateSize(const TexturePointer& texture) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void Framebuffer::resize(uint16 width, uint16 height, uint16 numSamples) {
|
||||
if (width && height && numSamples && !isEmpty() && !isSwapchain()) {
|
||||
if ((width != _width) || (height != _height) || (numSamples != _numSamples)) {
|
||||
_numSamples = numSamples;
|
||||
for (uint32 i = 0; i < _renderBuffers.size(); ++i) {
|
||||
if (_renderBuffers[i]) {
|
||||
_renderBuffers[i]._texture->resize2D(width, height, numSamples);
|
||||
_numSamples = _renderBuffers[i]._texture->getNumSamples();
|
||||
_renderBuffers[i]._texture->resize2D(width, height, _numSamples);
|
||||
assert(_renderBuffers[i]._texture->getNumSamples() == _numSamples);
|
||||
++_colorStamps[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (_depthStencilBuffer) {
|
||||
_depthStencilBuffer._texture->resize2D(width, height, numSamples);
|
||||
_numSamples = _depthStencilBuffer._texture->getNumSamples();
|
||||
_depthStencilBuffer._texture->resize2D(width, height, _numSamples);
|
||||
assert(_depthStencilBuffer._texture->getNumSamples() == _numSamples);
|
||||
++_depthStamp;
|
||||
}
|
||||
|
||||
_width = width;
|
||||
_height = height;
|
||||
// _numSamples = numSamples;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16 Framebuffer::getWidth() const {
|
||||
if (isSwapchain()) {
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
float getAspectRatio() const { return getWidth() / (float) getHeight() ; }
|
||||
|
||||
// If not a swapchain canvas, resize can resize all the render buffers and depth stencil attached in one call
|
||||
void resize( uint16 width, uint16 height, uint16 samples = 1 );
|
||||
//void resize( uint16 width, uint16 height, uint16 samples = 1 );
|
||||
|
||||
static const uint32 MAX_NUM_RENDER_BUFFERS = 8;
|
||||
static uint32 getMaxNumRenderBuffers() { return MAX_NUM_RENDER_BUFFERS; }
|
||||
|
|
|
@ -34,7 +34,21 @@ Antialiasing::Antialiasing() {
|
|||
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
||||
int width = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().width();
|
||||
int height = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().height();
|
||||
|
||||
|
||||
if (_antialiasingBuffer && _antialiasingBuffer->getSize() != uvec2(width, height)) {
|
||||
_antialiasingBuffer.reset();
|
||||
}
|
||||
|
||||
if (!_antialiasingBuffer) {
|
||||
// Link the antialiasing FBO to texture
|
||||
_antialiasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat();
|
||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
||||
_antialiasingTexture = gpu::TexturePointer(gpu::Texture::create2D(format, width, height, defaultSampler));
|
||||
_antialiasingTexture->setSource("Antialiasing::_antialiasingTexture");
|
||||
_antialiasingBuffer->setRenderBuffer(0, _antialiasingTexture);
|
||||
}
|
||||
|
||||
if (!_antialiasingPipeline) {
|
||||
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert));
|
||||
auto ps = gpu::Shader::createPixel(std::string(fxaa_frag));
|
||||
|
@ -51,22 +65,10 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
|||
|
||||
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||
|
||||
// Link the antialiasing FBO to texture
|
||||
_antialiasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat();
|
||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
||||
_antialiasingTexture = gpu::TexturePointer(gpu::Texture::create2D(format, width, height, defaultSampler));
|
||||
_antialiasingTexture->setSource("Antialiasing::_antialiasingTexture");
|
||||
_antialiasingBuffer->setRenderBuffer(0, _antialiasingTexture);
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_antialiasingPipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
||||
if (width != _antialiasingBuffer->getWidth() || height != _antialiasingBuffer->getHeight()) {
|
||||
_antialiasingBuffer->resize(width, height);
|
||||
}
|
||||
|
||||
return _antialiasingPipeline;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,13 @@ void PreparePrimaryFramebuffer::run(const SceneContextPointer& sceneContext, con
|
|||
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
auto framebufferSize = framebufferCache->getFrameBufferSize();
|
||||
glm::ivec2 frameSize(framebufferSize.width(), framebufferSize.height());
|
||||
glm::uvec2 frameSize(framebufferSize.width(), framebufferSize.height());
|
||||
|
||||
// Resizing framebuffers instead of re-building them seems to cause issues with threaded
|
||||
// rendering
|
||||
if (_primaryFramebuffer && _primaryFramebuffer->getSize() != frameSize) {
|
||||
_primaryFramebuffer.reset();
|
||||
}
|
||||
|
||||
if (!_primaryFramebuffer) {
|
||||
_primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
|
@ -356,9 +362,7 @@ void PreparePrimaryFramebuffer::run(const SceneContextPointer& sceneContext, con
|
|||
primaryDepthTexture->setSource("PreparePrimaryFramebuffer::primaryDepthTexture");
|
||||
|
||||
_primaryFramebuffer->setDepthStencilBuffer(primaryDepthTexture, depthFormat);
|
||||
|
||||
}
|
||||
_primaryFramebuffer->resize(frameSize.x, frameSize.y);
|
||||
|
||||
primaryFramebuffer = _primaryFramebuffer;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,9 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
|||
if (!sourceFramebuffer) {
|
||||
return false;
|
||||
}
|
||||
if (_blurredFramebuffer && _blurredFramebuffer->getSize() != sourceFramebuffer->getSize()) {
|
||||
_blurredFramebuffer.reset();
|
||||
}
|
||||
|
||||
if (!_blurredFramebuffer) {
|
||||
_blurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
|
@ -107,21 +110,17 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
|||
auto blurringSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT);
|
||||
auto blurringTarget = gpu::TexturePointer(gpu::Texture::create2D(sourceFramebuffer->getRenderBuffer(0)->getTexelFormat(), sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), blurringSampler));
|
||||
_blurredFramebuffer->setRenderBuffer(0, blurringTarget);
|
||||
} else {
|
||||
// it would be easier to just call resize on the bluredFramebuffer and let it work if needed but the source might loose it's depth buffer when doing so
|
||||
if ((_blurredFramebuffer->getWidth() != sourceFramebuffer->getWidth()) || (_blurredFramebuffer->getHeight() != sourceFramebuffer->getHeight())) {
|
||||
_blurredFramebuffer->resize(sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), sourceFramebuffer->getNumSamples());
|
||||
//if (sourceFramebuffer->hasDepthStencil()) {
|
||||
// _blurredFramebuffer->setDepthStencilBuffer(sourceFramebuffer->getDepthStencilBuffer(), sourceFramebuffer->getDepthStencilBufferFormat());
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blurringResources.sourceTexture = sourceFramebuffer->getRenderBuffer(0);
|
||||
blurringResources.blurringFramebuffer = _blurredFramebuffer;
|
||||
blurringResources.blurringTexture = _blurredFramebuffer->getRenderBuffer(0);
|
||||
|
||||
if (_generateOutputFramebuffer) {
|
||||
if (_outputFramebuffer && _outputFramebuffer->getSize() != sourceFramebuffer->getSize()) {
|
||||
_outputFramebuffer.reset();
|
||||
}
|
||||
|
||||
// The job output the blur result in a new Framebuffer spawning here.
|
||||
// Let s make sure it s ready for this
|
||||
if (!_outputFramebuffer) {
|
||||
|
@ -134,13 +133,6 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
|||
auto blurringSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT);
|
||||
auto blurringTarget = gpu::TexturePointer(gpu::Texture::create2D(sourceFramebuffer->getRenderBuffer(0)->getTexelFormat(), sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), blurringSampler));
|
||||
_outputFramebuffer->setRenderBuffer(0, blurringTarget);
|
||||
} else {
|
||||
if ((_outputFramebuffer->getWidth() != sourceFramebuffer->getWidth()) || (_outputFramebuffer->getHeight() != sourceFramebuffer->getHeight())) {
|
||||
_outputFramebuffer->resize(sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), sourceFramebuffer->getNumSamples());
|
||||
/* if (sourceFramebuffer->hasDepthStencil()) {
|
||||
_outputFramebuffer->setDepthStencilBuffer(sourceFramebuffer->getDepthStencilBuffer(), sourceFramebuffer->getDepthStencilBufferFormat());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
// Should be good to use the output Framebuffer as final
|
||||
|
|
Loading…
Reference in a new issue