mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 08:23: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()) {
|
||||
case Texture::TEX_2D:
|
||||
if (!texture.isArray()) {
|
||||
return GL_TEXTURE_2D;
|
||||
if (!texture.isMultisample()) {
|
||||
return GL_TEXTURE_2D;
|
||||
} else {
|
||||
return GL_TEXTURE_2D_MULTISAMPLE;
|
||||
}
|
||||
} else {
|
||||
return GL_TEXTURE_2D_ARRAY;
|
||||
if (!texture.isMultisample()) {
|
||||
return GL_TEXTURE_2D_ARRAY;
|
||||
} else {
|
||||
return GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -81,7 +89,9 @@ GLenum GLTexture::getGLTextureType(const Texture& texture) {
|
|||
uint8_t GLTexture::getFaceCount(GLenum target) {
|
||||
switch (target) {
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||
return TEXTURE_2D_NUM_FACES;
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
return TEXTURE_CUBE_NUM_FACES;
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
if (gltexture) {
|
||||
if (gltexture->_target == GL_TEXTURE_2D) {
|
||||
glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0);
|
||||
} else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
|
||||
glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0);
|
||||
} else {
|
||||
glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource);
|
||||
}
|
||||
|
@ -93,6 +95,9 @@ public:
|
|||
if (gltexture) {
|
||||
if (gltexture->_target == GL_TEXTURE_2D) {
|
||||
glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0);
|
||||
}
|
||||
else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
|
||||
glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0);
|
||||
} else {
|
||||
glNamedFramebufferTextureLayer(_id, attachement, gltexture->_texture, 0,
|
||||
_gpuObject.getDepthStencilBufferSubresource());
|
||||
|
|
|
@ -375,11 +375,22 @@ void GL45FixedAllocationTexture::allocateStorage() const {
|
|||
const auto dimensions = _gpuObject.getDimensions();
|
||||
const auto mips = _gpuObject.getNumMips();
|
||||
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 {
|
||||
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);
|
||||
|
|
|
@ -263,7 +263,7 @@ public:
|
|||
frontFaceClockwise(false),
|
||||
depthClampEnable(false),
|
||||
scissorEnable(false),
|
||||
multisampleEnable(false),
|
||||
multisampleEnable(true),
|
||||
antialisedLineEnable(true),
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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 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 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 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 createExternal(const ExternalRecycler& recycler, const Sampler& sampler = Sampler());
|
||||
|
||||
|
@ -431,6 +433,7 @@ public:
|
|||
uint16 getNumSamples() const { return _numSamples; }
|
||||
// NumSamples can only have certain values based on the hw
|
||||
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))]
|
||||
// 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();
|
||||
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>("DrawBounds", opaques);
|
||||
|
@ -127,7 +127,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
|||
task.addJob<DrawBounds>("DrawZones", zones);
|
||||
const auto debugZoneInputs = DebugZoneLighting::Inputs(deferredFrameTransform, lightFrame, backgroundFrame).asVarying();
|
||||
task.addJob<DebugZoneLighting>("DrawZoneStack", debugZoneInputs);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Lighting Buffer ready for tone mapping
|
||||
// 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
|
||||
// Blit!
|
||||
// task.addJob<Blit>("Blit", framebuffer);
|
||||
task.addJob<Blit>("Blit", 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 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);
|
||||
_framebuffer->setRenderBuffer(0, colorTexture);*/
|
||||
auto colorTexture =
|
||||
gpu::Texture::createRenderBufferMultisample(colorFormat, frameSize.x, frameSize.y, 16, defaultSampler);
|
||||
_framebuffer->setRenderBuffer(0, colorTexture);
|
||||
|
||||
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);
|
||||
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);*/
|
||||
auto depthTexture =
|
||||
gpu::Texture::createRenderBufferMultisample(depthFormat, frameSize.x, frameSize.y, 16, defaultSampler);
|
||||
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue