mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:24: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) {
|
void Framebuffer::resize(uint16 width, uint16 height, uint16 numSamples) {
|
||||||
if (width && height && numSamples && !isEmpty() && !isSwapchain()) {
|
if (width && height && numSamples && !isEmpty() && !isSwapchain()) {
|
||||||
if ((width != _width) || (height != _height) || (numSamples != _numSamples)) {
|
if ((width != _width) || (height != _height) || (numSamples != _numSamples)) {
|
||||||
|
_numSamples = numSamples;
|
||||||
for (uint32 i = 0; i < _renderBuffers.size(); ++i) {
|
for (uint32 i = 0; i < _renderBuffers.size(); ++i) {
|
||||||
if (_renderBuffers[i]) {
|
if (_renderBuffers[i]) {
|
||||||
_renderBuffers[i]._texture->resize2D(width, height, numSamples);
|
_renderBuffers[i]._texture->resize2D(width, height, _numSamples);
|
||||||
_numSamples = _renderBuffers[i]._texture->getNumSamples();
|
assert(_renderBuffers[i]._texture->getNumSamples() == _numSamples);
|
||||||
++_colorStamps[i];
|
++_colorStamps[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_depthStencilBuffer) {
|
if (_depthStencilBuffer) {
|
||||||
_depthStencilBuffer._texture->resize2D(width, height, numSamples);
|
_depthStencilBuffer._texture->resize2D(width, height, _numSamples);
|
||||||
_numSamples = _depthStencilBuffer._texture->getNumSamples();
|
assert(_depthStencilBuffer._texture->getNumSamples() == _numSamples);
|
||||||
++_depthStamp;
|
++_depthStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
_width = width;
|
_width = width;
|
||||||
_height = height;
|
_height = height;
|
||||||
// _numSamples = numSamples;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint16 Framebuffer::getWidth() const {
|
uint16 Framebuffer::getWidth() const {
|
||||||
if (isSwapchain()) {
|
if (isSwapchain()) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
float getAspectRatio() const { return getWidth() / (float) getHeight() ; }
|
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
|
// 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 const uint32 MAX_NUM_RENDER_BUFFERS = 8;
|
||||||
static uint32 getMaxNumRenderBuffers() { return MAX_NUM_RENDER_BUFFERS; }
|
static uint32 getMaxNumRenderBuffers() { return MAX_NUM_RENDER_BUFFERS; }
|
||||||
|
|
|
@ -35,6 +35,20 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
||||||
int width = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().width();
|
int width = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().width();
|
||||||
int height = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().height();
|
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) {
|
if (!_antialiasingPipeline) {
|
||||||
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert));
|
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert));
|
||||||
auto ps = gpu::Shader::createPixel(std::string(fxaa_frag));
|
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);
|
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
|
// Good to go add the brand new pipeline
|
||||||
_antialiasingPipeline = gpu::Pipeline::create(program, state);
|
_antialiasingPipeline = gpu::Pipeline::create(program, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width != _antialiasingBuffer->getWidth() || height != _antialiasingBuffer->getHeight()) {
|
|
||||||
_antialiasingBuffer->resize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _antialiasingPipeline;
|
return _antialiasingPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,13 @@ void PreparePrimaryFramebuffer::run(const SceneContextPointer& sceneContext, con
|
||||||
|
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
auto framebufferSize = framebufferCache->getFrameBufferSize();
|
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) {
|
if (!_primaryFramebuffer) {
|
||||||
_primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
_primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||||
|
@ -356,9 +362,7 @@ void PreparePrimaryFramebuffer::run(const SceneContextPointer& sceneContext, con
|
||||||
primaryDepthTexture->setSource("PreparePrimaryFramebuffer::primaryDepthTexture");
|
primaryDepthTexture->setSource("PreparePrimaryFramebuffer::primaryDepthTexture");
|
||||||
|
|
||||||
_primaryFramebuffer->setDepthStencilBuffer(primaryDepthTexture, depthFormat);
|
_primaryFramebuffer->setDepthStencilBuffer(primaryDepthTexture, depthFormat);
|
||||||
|
|
||||||
}
|
}
|
||||||
_primaryFramebuffer->resize(frameSize.x, frameSize.y);
|
|
||||||
|
|
||||||
primaryFramebuffer = _primaryFramebuffer;
|
primaryFramebuffer = _primaryFramebuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,9 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
||||||
if (!sourceFramebuffer) {
|
if (!sourceFramebuffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (_blurredFramebuffer && _blurredFramebuffer->getSize() != sourceFramebuffer->getSize()) {
|
||||||
|
_blurredFramebuffer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
if (!_blurredFramebuffer) {
|
if (!_blurredFramebuffer) {
|
||||||
_blurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
_blurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||||
|
@ -107,14 +110,6 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
||||||
auto blurringSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT);
|
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));
|
auto blurringTarget = gpu::TexturePointer(gpu::Texture::create2D(sourceFramebuffer->getRenderBuffer(0)->getTexelFormat(), sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), blurringSampler));
|
||||||
_blurredFramebuffer->setRenderBuffer(0, blurringTarget);
|
_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.sourceTexture = sourceFramebuffer->getRenderBuffer(0);
|
||||||
|
@ -122,6 +117,10 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra
|
||||||
blurringResources.blurringTexture = _blurredFramebuffer->getRenderBuffer(0);
|
blurringResources.blurringTexture = _blurredFramebuffer->getRenderBuffer(0);
|
||||||
|
|
||||||
if (_generateOutputFramebuffer) {
|
if (_generateOutputFramebuffer) {
|
||||||
|
if (_outputFramebuffer && _outputFramebuffer->getSize() != sourceFramebuffer->getSize()) {
|
||||||
|
_outputFramebuffer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
// The job output the blur result in a new Framebuffer spawning here.
|
// The job output the blur result in a new Framebuffer spawning here.
|
||||||
// Let s make sure it s ready for this
|
// Let s make sure it s ready for this
|
||||||
if (!_outputFramebuffer) {
|
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 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));
|
auto blurringTarget = gpu::TexturePointer(gpu::Texture::create2D(sourceFramebuffer->getRenderBuffer(0)->getTexelFormat(), sourceFramebuffer->getWidth(), sourceFramebuffer->getHeight(), blurringSampler));
|
||||||
_outputFramebuffer->setRenderBuffer(0, blurringTarget);
|
_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
|
// Should be good to use the output Framebuffer as final
|
||||||
|
|
Loading…
Reference in a new issue