Fixed: BGFX_TEXTURE_MSAA_SAMPLE and msaa sampling bugs with gl (#3351)

* fixed: multiple BGFX_TEXTURE_MSAA_SAMPLE attachments could not be present 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

* fixed: framebuffer with a resolved msaa AND a sample msaa at the same 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

* fixed: depth attachments could not be sample-msaa
this is valid, they don't resolving

* fixed: shader error sampking msaa textures in gl
parameter duplication on texelFetch(sampler2DMS,*) led to failed shaders
This commit is contained in:
ProPuke
2025-10-30 00:29:36 +00:00
committed by GitHub
parent 55f997002f
commit df53a7ca84
3 changed files with 7 additions and 7 deletions

View File

@@ -954,7 +954,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
ir->coordinate->accept(this); ir->coordinate->accept(this);
// lod // lod
if (ir->op == ir_txl || ir->op == ir_txf || ir->op == ir_txf_ms) if (ir->op == ir_txl || ir->op == ir_txf)
{ {
buffer.asprintf_append (", "); buffer.asprintf_append (", ");
ir->lod_info.lod->accept(this); ir->lod_info.lod->accept(this);

View File

@@ -4594,13 +4594,13 @@ namespace bgfx
++depth; ++depth;
BGFX_ERROR_CHECK( BGFX_ERROR_CHECK(
// if BGFX_TEXTURE_RT_MSAA_X2 or greater than BGFX_TEXTURE_RT_WRITE_ONLY is 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 WRITE_ONLY is not required. // if BGFX_TEXTURE_RT with no MSSA then this is not required.
(1 == ((tr.m_flags & BGFX_TEXTURE_RT_MSAA_MASK) >> BGFX_TEXTURE_RT_MSAA_SHIFT)) (1 == ((tr.m_flags & BGFX_TEXTURE_RT_MSAA_MASK) >> BGFX_TEXTURE_RT_MSAA_SHIFT))
|| (0 != (tr.m_flags & BGFX_TEXTURE_RT_WRITE_ONLY)) || (0 != (tr.m_flags & (BGFX_TEXTURE_RT_WRITE_ONLY | BGFX_TEXTURE_MSAA_SAMPLE)))
, _err , _err
, BGFX_ERROR_FRAME_BUFFER_VALIDATION , BGFX_ERROR_FRAME_BUFFER_VALIDATION
, "Frame buffer depth MSAA texture cannot be resolved. It must be created with `BGFX_TEXTURE_RT_WRITE_ONLY` flag." , "Frame buffer depth MSAA texture cannot be resolved. It must be created with either `BGFX_TEXTURE_RT_WRITE_ONLY` or `BGFX_TEXTURE_MSAA_SAMPLE` flag."
, "Attachment %d, texture flags 0x%016" PRIx64 "." , "Attachment %d, texture flags 0x%016" PRIx64 "."
, ii , ii
, tr.m_flags , tr.m_flags

View File

@@ -1479,7 +1479,7 @@ namespace bgfx { namespace gl
, _internalFormat , _internalFormat
, _width , _width
, _height , _height
, false , true
); );
} }
else else
@@ -7106,7 +7106,7 @@ namespace bgfx { namespace gl
{ {
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx]; const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
if (0 != texture.m_id) if (0 != texture.m_rbo && 0 != texture.m_id)
{ {
GLenum attachment = GL_INVALID_ENUM; GLenum attachment = GL_INVALID_ENUM;