Hello,
I ran into an issue with glDrawBuffers and MRT when disabling certain buffers.
Consider this (simplified) fragment shader
#version 150 core
out vec4 Color0;
out vec4 Color1;
out vec4 Color2;
void main(void)
{
Color0 = vec4(0.0, 0.0, 0.0, 0.3);
Color1 = vec4(0.0, 0.0, 0.0, 0.5);
Color2 = vec4(0.0, 0.0, 0.0, 0.8);
}
During shader linking the color outputs are mapped to draw buffer indices like this:
glBindFragDataLocation(Handle, 0, "Color0");
glBindFragDataLocation(Handle, 1, "Color1");
glBindFragDataLocation(Handle, 2, "Color2");
The FBO has 3 color attachments:
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 and GL_COLOR_ATTACHMENT2.
Before rendering with the fragment shader above, glDrawBuffers is called like this:
GLenum buffers[3] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(3, buffers);
=> The output is as expected, each of the 3 buffers receives the proper alpha value (also the RGB terms would be the proper ones as I tested, so it is not about only the alpha part here).
Now the problem:
When I call glDrawBuffers like this (because I don't want to render to 2nd color buffer):
GLenum buffers[3] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(3, buffers)
=> Then nothing is rendered to the 3rd color buffer (i.e. GL_COLOR_ATTACHMENT2)! It seems everything after GL_NONE is skipped/discarded as well.
How is that possible? Where is my mistake? Or could it be a driver bug?
Help is really appreciated!
I have Windows 10 64bit and a Radeon HD 5850 with latest driver (at least no update was found). Here are the details:
Treiber-Paketversion 15.201.1151.1008-151104a-296217E
Anbieter Advanced Micro Devices, Inc.
2D-Treiberversion 8.01.01.1500
2D-Treiberpfad /REGISTRY/MACHINE/SYSTEM/ControlSet001/Control/Class/{4d36e968-e325-11ce-bfc1-08002be10318}/0000
Direct3D-Version 9.14.10.01128
OpenGL-Version 6.14.10.13399
Mantle-Treiberversion 9.1.10.0083
Mantle-API-Version Nicht verfügbar
AMD Catalyst Control Center-Version 2015.1104.1643.30033
Grafikkarten-Hersteller Powered by AMD
Grafik-Chipsatz AMD Radeon HD 5800 Series
Geräte-ID 6899
Anbieter-ID 1002
Subsystem-ID E140
Subsystem-Anbieter-ID 174B
Revisions-ID 00
Grafikbus-Unterstützung PCI Express 2.0
Maximale Buseinstellungen PCI Express 2.0x16
BIOS-Version 012.019.000.002
BIOS-Teilenummer 113-C00140-00X
BIOS-Datum 2010/03/09
Speichergröße 1024 MB
Speichertyp GDDR5
Kern-Taktfrequenz in MHz 725 MHz
Speichertaktfrequenz in MHz 1000 MHz
Gesamtspeicherbandbreite in GB/s 128,0 GB/s
Are AMD developers reading here? Can somebody confirm it as a driver bug?
Help is really appreciated!
Also happens with latest Crimson driver:
Version der Radeon Einstellungen - 2016.0226.1531.27895
Treiber-Paketversion - 15.301.1901-160226a-299900E
Anbieter - Advanced Micro Devices, Inc.
2D-Treiberversion - 8.1.1.1533
Direct3D® Version - 9.14.10.1171
OpenGL® Version - 6.14.10.13417
OpenCL™ Version - 2.0.4.0
AMD Mantle-Version - 9.1.10.99
AMD Mantle API-Version - Not Available
AMD Audio-Treiberversion - 10.0.0.2
AMD, please. This seems to be really a driver bug as it is not reproducible with an NVidia card (GTX 1080).
Any comment? Any driver developer reading this? =/
Are you using an OpenGL ES or an OpenGL context? If it's the latter, is it Compatibility or Core Profile? What's the context version your'e requesting?
Are you seeing any feed-back generated by the driver through the "debug output" functionality? (https://www.opengl.org/registry/specs/ARB/debug_output.txt )
I was using a normal (not ES) OpenGL 3.2 core profile context (with forward-compatible bit set).
int glAttributes[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0 };
Currently there is no ARB debug_output facility in my code but I always check for glGetError and there was no error reported.
With the NVidia card installed there are no problems when disabling 2nd color buffer, it renders as expected to the 1st and 3rd buffer.
I think there is a bug in the ATI/AMD driver which, for some reason, disables buffer write to any buffer slot that comes after the first GL_NONE rather than only the buffer slot that was set to GL_NONE.
I would appreciate if you could verify ARB_debug_output does not report any error via the debug call-back function. I'm not saying there is no driver bug here but I'd like to make sure we've covered everything before I try to reproduce this issue locally.
Ok I will try to work on this on this weekend and post here when I have something.
I have implemented a nice facility for ARB_debug_output.
But since the NVidia card is currently installed I cannot provide the output for the relevant hardware yet.
Probably next weekend I have time again to replace the NVidia with the AMD card and then post the output here.
Sorry for the delay, please be patient :-)
That's OK, please take your time.