I'm using nvidia nsight graphics to check out what happens when clearing a framebuffer using a cubemap.
I cannot figure out if the clearing affect all the six faces, or if I have to specify which face I'm rendering into before clear it.
I need to know how to clear correctly a cubemap in fact. Per face or by the framebuffer.
EDIT:
Here is the calling log :
Issues (324) Event Description CPU ms GPU ms
563 "void glBindFramebuffer(GLenum target = GL_FRAMEBUFFER, GLuint framebuffer = '4')" 0.02 -
Issues (324) Event Description CPU ms GPU ms
565 "void glViewport(GLint x = 0, GLint y = 0, GLsizei width = 256, GLsizei height = 256)" <0.01 -
Issues (324) Event Description CPU ms GPU ms
566 "void glClearNamedFramebufferfv(GLuint framebuffer = '4', GLenum buffer = GL_DEPTH, GLint drawbuffer = 0, GLfloat* value = {1})" 0.03 <0.01
Issues (324) Event Description CPU ms GPU ms
567 "void glNamedFramebufferTextureLayer(GLuint framebuffer = '4', GLenum attachment = GL_DEPTH_ATTACHMENT, GLuint texture = '59', GLint level = 0, GLint layer = 0)" 0.01 -
Issues (324) Event Description CPU ms GPU ms
570 void glUseProgram(GLuint program = '616') <0.01 -
Some drawings (I havn't reported the program and drawing log), I saw primitives hitting the framebuffer in the nvidia software with no warning about nothing written, so I assume the framebuffer is valid.
Next face :
Issues (324) Event Description CPU ms GPU ms
914 "void glNamedFramebufferTextureLayer(GLuint framebuffer = '4', GLenum attachment = GL_DEPTH_ATTACHMENT, GLuint texture = '59', GLint level = 0, GLint layer = 1)" 0.02 -
... I don't clear anything and I start again to draw with a new matrix orientation until the 6 faces are rendered.
EDIT2, here is how I create the shadow cubemap:
glCreateTextures(
GL_TEXTURE_CUBE_MAP,
1,
&m_identifier
);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glTextureStorage2D(
m_identifier,
1,
GL_DEPTH_COMPONENT32F,
256,
256
);
Framebuffers have images attached to them. Framebuffer operations affect the images that are currently attached to them.
Note that I said "images" and not textures". Textures contain images, but as far as a framebuffer is concerned, distinct images in the same texture have no relationship to one another. Framebuffer operations only affects the images that are attached to it at the time time.
If you attach a specific cubemap face to a framebuffer, then that face is the image attached to that attachment location in the FBO. Operations on the framebuffer will affect that image, but the framebuffer neither knows about nor cares about any other cubemap faces that may be in the texture. Framebuffers only deal with the currently attached images.
Furthermore, if you want to clear the framebuffer attached image you're about to use to render with, the image you want to clear must be attached to the FBO when you issue the clear call. Clearing, then attaching, makes no sense if you intend to clear the image that you're attaching.
If you want to clear an entire texture to a specific value (such as with all faces of a cubemap), you can do that with glClearTexImage
.