Skip to content

Commit

Permalink
igl | opengl | Properly support IMG_multisampled_render_to_texture wh…
Browse files Browse the repository at this point in the history
…en EXT_multisampled_render_to_texture is not supported.

Summary:
https://registry.khronos.org/OpenGL/extensions/IMG/IMG_multisampled_render_to_texture.txt

unlike newer version

https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture.txt

supports only GL_FRAMEBUFFER and not GL_READ/DRAW_FRAMEBUFFER.
Fix the usage within our stack, as it will just result in GL_INVALID_ENUM

Reviewed By: dmannemela

Differential Revision: D49675129

fbshipit-source-id: 13d73503567fc4bf5e4df076b68184a8c0855619
  • Loading branch information
nlutsenko authored and facebook-github-bot committed Sep 27, 2023
1 parent 4d0250f commit 71f5789
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/igl/opengl/TextureBufferBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ void TextureBufferBase::attachAsColor(uint32_t index, const AttachmentParams& pa
void TextureBufferBase::attach(GLenum attachment,
const AttachmentParams& params,
GLuint textureID) {
GLenum target = target_ == GL_TEXTURE_CUBE_MAP ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.face
: target_;
const GLenum target =
target_ == GL_TEXTURE_CUBE_MAP ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.face : target_;
GLenum framebufferTarget = GL_FRAMEBUFFER;
if (getContext().deviceFeatures().hasFeature(DeviceFeatures::ReadWriteFramebuffer)) {
const auto& deviceFeatures = getContext().deviceFeatures();
if (deviceFeatures.hasFeature(DeviceFeatures::ReadWriteFramebuffer)) {
framebufferTarget = params.read ? GL_READ_FRAMEBUFFER : GL_DRAW_FRAMEBUFFER;
}
const auto numSamples = getSamples();
Expand All @@ -89,6 +90,13 @@ void TextureBufferBase::attach(GLenum attachment,
0,
2);
} else {
// `IMG_multisampled_render_to_texture` unlike `EXT_multisampled_render_to_texture`,
// only supports GL_FRAMEBUFFER, not GL_DRAW/READ_FRAMEBUFFER
if ((framebufferTarget == GL_DRAW_FRAMEBUFFER || framebufferTarget == GL_READ_FRAMEBUFFER) &&
!deviceFeatures.hasExtension(Extensions::MultiSampleExt) &&
deviceFeatures.hasExtension(Extensions::MultiSampleImg)) {
framebufferTarget = GL_FRAMEBUFFER;
}
getContext().framebufferTexture2DMultisample(
framebufferTarget, attachment, target, textureID, params.mipLevel, getSamples());
}
Expand Down

0 comments on commit 71f5789

Please sign in to comment.