Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: BGFX_TEXTURE_MSAA_SAMPLE and msaa sampling bugs with gl #3351

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ProPuke
Copy link

@ProPuke ProPuke commented Sep 9, 2024

BGFX_TEXTURE_MSAA_SAMPLE wasn't usable with multiple attachments.
Depth attachments couldn't be used with BGFX_TEXTURE_MSAA_SAMPLE.
Using texelFetch with Sampler2DMS would result in shader errors.

…sent in a framebuffer at once (sample locations were not fixed)

I've just set the sample location as always fixed for now, although technically this can be false if only 1 msaa texture attachment is present
… time would result in an invalid framebuffer

it would try to also resolve the sample-msaa texture at the same, leading to an invalid target type
this is valid, they don't resolving
parameter duplication on texelFetch(sampler2DMS,*) led to failed shaders
@@ -954,7 +954,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
ir->coordinate->accept(this);

// lod
if (ir->op == ir_txl || ir->op == ir_txf || ir->op == ir_txf_ms)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We handle the ir_txf_ms case a few lines below, so this lead to a duplicate last parameter with texelFetch(Sampler2DMS, ...)

// if BGFX_TEXTURE_RT_MSAA_X2 or greater than BGFX_TEXTURE_RT_WRITE_ONLY is required
// if BGFX_TEXTURE_RT with no MSSA then WRITE_ONLY is not required.
// if BGFX_TEXTURE_RT_MSAA_X2 or greater than either BGFX_TEXTURE_RT_WRITE_ONLY or BGFX_TEXTURE_MSAA_SAMPLE is required
// if BGFX_TEXTURE_RT with no MSSA then this is not required.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BGFX_TEXTURE_MSAA_SAMPLER doesn't resolve either, so it's valid to use with depth attachments

@@ -1479,7 +1479,7 @@ namespace bgfx { namespace gl
, _internalFormat
, _width
, _height
, false
, true
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have multiple GL_TEXTURE_2D_MULTISAMPLE attachments this is required to be true, so that all sample locations match.
Realistically I don't know how common it is for sample locations to not match anyway, and I don't believe there is any penalty to doing so, so might as well have it on all the time for now.

@@ -7101,7 +7101,7 @@ namespace bgfx { namespace gl
{
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];

if (0 != texture.m_id)
if (0 != texture.m_rbo && 0 != texture.m_id)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't try to resolve multisample textures too, ensure it also has an rbo!
(If one attachment required resolve, this would accidentally try and resolve the multisample texture too, causing an unhappy framebuffer)

@ProPuke ProPuke marked this pull request as ready for review September 9, 2024 17:19
@ProPuke ProPuke changed the title Fixed: BGFX_TEXTURE_MSAA_SAMPLE and msaa sampling bugs Fixed: BGFX_TEXTURE_MSAA_SAMPLE and msaa sampling bugs with gl Sep 9, 2024
@bkaradzic
Copy link
Owner

Did you test this with other backends? So that behavior is consistent?

@ProPuke
Copy link
Author

ProPuke commented Sep 9, 2024

Did you test this with other backends? So that behavior is consistent?

I haven't, no.
I can do Vulkan, but I don't have access to windows or mac at the moment to check other targets.

@bkaradzic
Copy link
Owner

Yeah, you should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants