mirror of
https://github.com/overte-org/overte.git
synced 2025-06-15 20:59:17 +02:00
Enabling msaa framebuffer and testing for forward
This commit is contained in:
parent
6cb8cf0202
commit
f9891775fc
7 changed files with 54 additions and 12 deletions
|
@ -60,9 +60,17 @@ GLenum GLTexture::getGLTextureType(const Texture& texture) {
|
||||||
switch (texture.getType()) {
|
switch (texture.getType()) {
|
||||||
case Texture::TEX_2D:
|
case Texture::TEX_2D:
|
||||||
if (!texture.isArray()) {
|
if (!texture.isArray()) {
|
||||||
return GL_TEXTURE_2D;
|
if (!texture.isMultisample()) {
|
||||||
|
return GL_TEXTURE_2D;
|
||||||
|
} else {
|
||||||
|
return GL_TEXTURE_2D_MULTISAMPLE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return GL_TEXTURE_2D_ARRAY;
|
if (!texture.isMultisample()) {
|
||||||
|
return GL_TEXTURE_2D_ARRAY;
|
||||||
|
} else {
|
||||||
|
return GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -81,7 +89,9 @@ GLenum GLTexture::getGLTextureType(const Texture& texture) {
|
||||||
uint8_t GLTexture::getFaceCount(GLenum target) {
|
uint8_t GLTexture::getFaceCount(GLenum target) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
|
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
|
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||||
return TEXTURE_2D_NUM_FACES;
|
return TEXTURE_2D_NUM_FACES;
|
||||||
case GL_TEXTURE_CUBE_MAP:
|
case GL_TEXTURE_CUBE_MAP:
|
||||||
return TEXTURE_CUBE_NUM_FACES;
|
return TEXTURE_CUBE_NUM_FACES;
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
if (gltexture) {
|
if (gltexture) {
|
||||||
if (gltexture->_target == GL_TEXTURE_2D) {
|
if (gltexture->_target == GL_TEXTURE_2D) {
|
||||||
glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0);
|
glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0);
|
||||||
|
} else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
|
||||||
|
glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0);
|
||||||
} else {
|
} else {
|
||||||
glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource);
|
glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +95,9 @@ public:
|
||||||
if (gltexture) {
|
if (gltexture) {
|
||||||
if (gltexture->_target == GL_TEXTURE_2D) {
|
if (gltexture->_target == GL_TEXTURE_2D) {
|
||||||
glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0);
|
glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0);
|
||||||
|
}
|
||||||
|
else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
|
||||||
|
glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0);
|
||||||
} else {
|
} else {
|
||||||
glNamedFramebufferTextureLayer(_id, attachement, gltexture->_texture, 0,
|
glNamedFramebufferTextureLayer(_id, attachement, gltexture->_texture, 0,
|
||||||
_gpuObject.getDepthStencilBufferSubresource());
|
_gpuObject.getDepthStencilBufferSubresource());
|
||||||
|
|
|
@ -375,11 +375,22 @@ void GL45FixedAllocationTexture::allocateStorage() const {
|
||||||
const auto dimensions = _gpuObject.getDimensions();
|
const auto dimensions = _gpuObject.getDimensions();
|
||||||
const auto mips = _gpuObject.getNumMips();
|
const auto mips = _gpuObject.getNumMips();
|
||||||
const auto numSlices = _gpuObject.getNumSlices();
|
const auto numSlices = _gpuObject.getNumSlices();
|
||||||
|
const auto numSamples = _gpuObject.getNumSamples();
|
||||||
|
|
||||||
if (!_gpuObject.isArray()) {
|
|
||||||
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
if (!_gpuObject.isMultisample()) {
|
||||||
|
if (!_gpuObject.isArray()) {
|
||||||
|
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||||
|
} else {
|
||||||
|
glTextureStorage3D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
glTextureStorage3D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices);
|
if (!_gpuObject.isArray()) {
|
||||||
|
glTextureStorage2DMultisample(_id, numSamples, texelFormat.internalFormat, dimensions.x, dimensions.y, GL_FALSE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glTextureStorage3DMultisample(_id, numSamples, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, GL_FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
|
|
|
@ -263,7 +263,7 @@ public:
|
||||||
frontFaceClockwise(false),
|
frontFaceClockwise(false),
|
||||||
depthClampEnable(false),
|
depthClampEnable(false),
|
||||||
scissorEnable(false),
|
scissorEnable(false),
|
||||||
multisampleEnable(false),
|
multisampleEnable(true),
|
||||||
antialisedLineEnable(true),
|
antialisedLineEnable(true),
|
||||||
alphaToCoverageEnable(false)
|
alphaToCoverageEnable(false)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -176,10 +176,18 @@ TexturePointer Texture::createRenderBuffer(const Element& texelFormat, uint16 wi
|
||||||
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler);
|
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TexturePointer Texture::createRenderBufferMultisample(const Element& texelFormat, uint16 width, uint16 height, uint16 numSamples, const Sampler& sampler) {
|
||||||
|
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, numSamples, 0, gpu::Texture::SINGLE_MIP, sampler);
|
||||||
|
}
|
||||||
|
|
||||||
TexturePointer Texture::createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) {
|
TexturePointer Texture::createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) {
|
||||||
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler);
|
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TexturePointer Texture::createRenderBufferMultisampleArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numSamples, const Sampler& sampler) {
|
||||||
|
return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, numSamples, numSlices, gpu::Texture::SINGLE_MIP, sampler);
|
||||||
|
}
|
||||||
|
|
||||||
TexturePointer Texture::create1D(const Element& texelFormat, uint16 width, uint16 numMips, const Sampler& sampler) {
|
TexturePointer Texture::create1D(const Element& texelFormat, uint16 width, uint16 numMips, const Sampler& sampler) {
|
||||||
return create(TextureUsageType::RESOURCE, TEX_1D, texelFormat, width, 1, 1, 1, 0, numMips, sampler);
|
return create(TextureUsageType::RESOURCE, TEX_1D, texelFormat, width, 1, 1, 1, 0, numMips, sampler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,9 @@ public:
|
||||||
static TexturePointer create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
static TexturePointer create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
||||||
static TexturePointer createCube(const Element& texelFormat, uint16 width, uint16 numMips = 1, const Sampler& sampler = Sampler());
|
static TexturePointer createCube(const Element& texelFormat, uint16 width, uint16 numMips = 1, const Sampler& sampler = Sampler());
|
||||||
static TexturePointer createRenderBuffer(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
static TexturePointer createRenderBuffer(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
||||||
|
static TexturePointer createRenderBufferMultisample(const Element& texelFormat, uint16 width, uint16 height, uint16 numSamples, const Sampler& sampler = Sampler());
|
||||||
static TexturePointer createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
static TexturePointer createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
||||||
|
static TexturePointer createRenderBufferMultisampleArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numSamples, const Sampler& sampler = Sampler());
|
||||||
static TexturePointer createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
static TexturePointer createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler());
|
||||||
static TexturePointer createExternal(const ExternalRecycler& recycler, const Sampler& sampler = Sampler());
|
static TexturePointer createExternal(const ExternalRecycler& recycler, const Sampler& sampler = Sampler());
|
||||||
|
|
||||||
|
@ -431,6 +433,7 @@ public:
|
||||||
uint16 getNumSamples() const { return _numSamples; }
|
uint16 getNumSamples() const { return _numSamples; }
|
||||||
// NumSamples can only have certain values based on the hw
|
// NumSamples can only have certain values based on the hw
|
||||||
static uint16 evalNumSamplesUsed(uint16 numSamplesTried);
|
static uint16 evalNumSamplesUsed(uint16 numSamplesTried);
|
||||||
|
bool isMultisample() const { return _numSamples > 1; }
|
||||||
|
|
||||||
// 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))]
|
||||||
// It is defined at creation time (immutable)
|
// It is defined at creation time (immutable)
|
||||||
|
|
|
@ -118,7 +118,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel).asVarying();
|
const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel).asVarying();
|
||||||
task.addJob<DrawForward>("DrawTransparents", transparentInputs, shapePlumber);
|
task.addJob<DrawForward>("DrawTransparents", transparentInputs, shapePlumber);
|
||||||
|
|
||||||
{ // Debug the bounds of the rendered items, still look at the zbuffer
|
/* { // Debug the bounds of the rendered items, still look at the zbuffer
|
||||||
|
|
||||||
task.addJob<DrawBounds>("DrawMetaBounds", metas);
|
task.addJob<DrawBounds>("DrawMetaBounds", metas);
|
||||||
task.addJob<DrawBounds>("DrawBounds", opaques);
|
task.addJob<DrawBounds>("DrawBounds", opaques);
|
||||||
|
@ -127,7 +127,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
task.addJob<DrawBounds>("DrawZones", zones);
|
task.addJob<DrawBounds>("DrawZones", zones);
|
||||||
const auto debugZoneInputs = DebugZoneLighting::Inputs(deferredFrameTransform, lightFrame, backgroundFrame).asVarying();
|
const auto debugZoneInputs = DebugZoneLighting::Inputs(deferredFrameTransform, lightFrame, backgroundFrame).asVarying();
|
||||||
task.addJob<DebugZoneLighting>("DrawZoneStack", debugZoneInputs);
|
task.addJob<DebugZoneLighting>("DrawZoneStack", debugZoneInputs);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Lighting Buffer ready for tone mapping
|
// Lighting Buffer ready for tone mapping
|
||||||
// Forward rendering on GLES doesn't support tonemapping to and from the same FBO, so we specify
|
// Forward rendering on GLES doesn't support tonemapping to and from the same FBO, so we specify
|
||||||
|
@ -141,7 +141,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
|
|
||||||
// Disable blit because we do tonemapping and compositing directly to the blit FBO
|
// Disable blit because we do tonemapping and compositing directly to the blit FBO
|
||||||
// Blit!
|
// Blit!
|
||||||
// task.addJob<Blit>("Blit", framebuffer);
|
task.addJob<Blit>("Blit", framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
||||||
|
@ -157,13 +157,18 @@ void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::Fra
|
||||||
|
|
||||||
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
|
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
|
||||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
||||||
auto colorTexture =
|
/* auto colorTexture =
|
||||||
gpu::Texture::createRenderBuffer(colorFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler);
|
gpu::Texture::createRenderBuffer(colorFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler);
|
||||||
|
_framebuffer->setRenderBuffer(0, colorTexture);*/
|
||||||
|
auto colorTexture =
|
||||||
|
gpu::Texture::createRenderBufferMultisample(colorFormat, frameSize.x, frameSize.y, 16, defaultSampler);
|
||||||
_framebuffer->setRenderBuffer(0, colorTexture);
|
_framebuffer->setRenderBuffer(0, colorTexture);
|
||||||
|
|
||||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
||||||
auto depthTexture =
|
/* auto depthTexture =
|
||||||
gpu::Texture::createRenderBuffer(depthFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler);
|
gpu::Texture::createRenderBuffer(depthFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler);
|
||||||
|
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);*/
|
||||||
|
auto depthTexture =
|
||||||
|
gpu::Texture::createRenderBufferMultisample(depthFormat, frameSize.x, frameSize.y, 16, defaultSampler);
|
||||||
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue