Skip to content

Commit 2313b8c

Browse files
committed
Update wording
1 parent 257dbc0 commit 2313b8c

File tree

1 file changed

+59
-33
lines changed
  • blog/2024/2024-11-01-my-screen-is-black

1 file changed

+59
-33
lines changed

Diff for: blog/2024/2024-11-01-my-screen-is-black/index.md

+59-33
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ Setup `glDebugMessageCallback` see [here](https://deccer.github.io/OpenGL-Gettin
2323

2424
If you use `glGetError` with or without macros like `GLCALL` or `GLCHECK` or rolled your own, get rid of it. `glDebugMessageCallback` will replace those. There is a high chance that you used it incorrectly anyway because you copy pasted it from some questionable source.
2525

26-
Make sure you check that shader compilation _and_ linking was successful. See `glGetShaderiv` & `glGetProgramiv` on compile and link status.
26+
Make sure you check that shader compilation *and* linking was successful. See `glGetShaderiv` & `glGetProgramiv` on compile and link status.
2727

2828
### You are on a Mac
2929

30-
Seriously port your engine to `metal`, or `webgpu` at least. There is no support for `KHR_debug` and you cannot use anything > gl 4.1 is enough reason
30+
Please port your engine to `metal` or `webgpu` at least, seriously. There is no support for `KHR_debug` and you cannot use anything > gl 4.1. That is enough reason
3131

3232
You are getting `UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable`. You need to call glGenerateMipmap(GL_TEXTURE_2D) after glTexImage2D() or set max level to 0 if you dont need/want mips.
3333

34+
If you insist on using Mac, stay with OpenGL 3.3.
35+
3436
### RenderDoc is crashing when trying to run your application
3537

3638
This is most likely **not** RenderDoc's fault, but yours. Something in your code is fishy and RenderDoc doesnt like it. Use a debugger/code-sanitizer to figure out
@@ -72,44 +74,55 @@ You most likely have no indexbuffer is bound. Or it is not associated to/with th
7274
You probably want to draw more primitives than you have in your vertexbuffer, check arguments of your `glDrawArrays` call.
7375
Potentially you might not have set the vertex count variable and that contains an ununitialized value because you used c/c++ and are a doofus.
7476

75-
### Textures are black
77+
### Textures/Triangles are black
78+
79+
Did you forget to bind the texture in question?
80+
81+
When you are not using `glXXXTextureStorage` but not good and old `glTexImageXX` make sure the texture is complete.
82+
**Check** with **OpenGL Specification** what completeness entails.
83+
84+
If it was not complete it should have told you about it in the debug callback. **Shame on you** if you still have not set it up.
7685

77-
- no textures bound
78-
- are your textures complete? if not should produce an output in debug callback, so, go check that (hmm this might not be the case for glXXXTextureStorage i might take this one off the list)
79-
- no samplers bound (check your sampler objects if you use them as separate objects)
80-
- fucked uvs
81-
- you might be sampling from a corner of your texture where its actually black, check uvs
86+
You might be using sampler objects. Make sure you bind one.
8287

83-
### Your Triangle is black
88+
You might be sampling from a corner of your texture where its actually black, Check your UVs.
8489

85-
- smells like your vao is fucked. make sure you setup the attributes (and stride when binding le vbo using DSA)
86-
- fucked uvs?
87-
- forgot to bind a texture?
90+
Another very likely reason is you didn't understand VAOs and copy pastaed it from learnopengl and added your own twist to it.
91+
Check that your VAO setup is correct. Make sure stride, offset is set correctly. And if you are using multiple vertexbuffers for all your attributes, make sure
92+
they are bound properly.
93+
94+
You tried to use vertex colors, but you didn't setup the VAO properly.
95+
Vertex colors might just be black. If it wasn't intentional, check the contents of your VBO.
8896

8997
### Screen is Black
9098

91-
- check if your screen is on/connected properly
92-
- camera (projection/view matrices are fucked) is not looking at the scene in question
93-
- no texture is sampled due to missing or wrong uvs => default value is 0 aka black (depends on the driver)
94-
- no shader bound (especially fragment shader)
95-
- fragment shader doesnt write anything to its output
96-
- no viewport is set/is too small
97-
- you might be rendering to a framebuffer, but not blitting that framebuffer to the default one
98-
- let clearcolor be something else than pure black
99-
- are you doing MRT?
100-
- if yes, check that you called the right `gl(Named)DrawBuffers` and not n times `gl(Named)DrawBuffer` one per render target
101-
- are you playing with depth pre pass-isms?
102-
- make sure the gl state between passes is the same, face winding, cullmode, etc, see Appending A.3 in the gl spec for more clues
99+
- Check if your screen is on/connected properly
100+
- Camera (projection/view matrices are fucked) is not looking at the scene in question
101+
- No texture is sampled due to missing or wrong uvs => default value is 0 aka black (depends on the driver)
102+
- No shader bound (especially fragment shader)
103+
- Fragment shader doesnt write anything to its output
104+
- No viewport is set/is too small
105+
- you might be rendering to a framebuffer, but not blitting that framebuffer to the default one or using it in a way to see its contents.
106+
- Let clearcolor be something else than pure black
107+
- are you rendering to multiple render targets?
108+
- if yes, check that you called the right `gl(Named)DrawBuffers`. Check that you didnt call `gl(Named)DrawBuffer` once per render target.
109+
- are you playing with depth-pre-pass-isms?
110+
- make sure the gl state between passes is the same, face winding, cullmode, etc. See Appending A.3 in the gl spec for more clues about invariance.
103111
- check winding order and cullmode, you might be looking at the wrong side of your faces
104-
- you check renderdoc and wonder why the vertex list contains the same (perhaps even first element) only, for all vertices => make sure your `glDrawElements(..., ..., GL_UNSIGNED_INT, ...)` or whatever datatype your indexbuffer consists of matches that parameter
112+
- you check renderdoc and wonder why the vertex list contains the same (perhaps even first element) only, for all vertices. Make sure your `glDrawElements(..., ..., GL_UNSIGNED_INT, ...)` or whatever datatype your indexbuffer consists of matches that parameter
113+
114+
All these things can be checked with a graphics debugger of your choice.
105115

106116
### Textures look funny, like a garbled version of the actual image
107117

108-
- make sure your internalformat and actual pixel format match. You probably used stb_image to load, but used 0 as the last parameter,
109-
and pixel data has 3 components, instead of the 4 (GL_RGBA) you told OpenGL about -> request 4 channels from stb_image
118+
Make sure your internalformat and actual pixel format match.
119+
You probably used stb_image to load, but used 0 as the last parameter, and pixel data has 3 components, instead of the 4 (GL_RGBA) you told OpenGL about.
120+
Request 4 channels from stb_image. There is almost never a reason to request 3 or less channels for color bearing pixelmaps.
110121

111122
### Textures look like one color component is more prominent than others
112123

124+
Happens when you are used to DirectXisms.
125+
113126
- Colors are more shifted towards blue
114127

115128
- You probably messed up the format and asked for GL_BRG.. of sorts => make sure they match
@@ -118,23 +131,36 @@ Potentially you might not have set the vertex count variable and that contains a
118131

119132
- Original pixeldata was probably in BGR... but you asked for GL_RGB... of sorts => make sure they match
120133

121-
### Textures seem to work, but mesh also appear to be shaded weirdly as if black Fog is on
134+
### Textures seem to work, but the mesh also appears to be shaded weirdly as if its in some black fog
122135

123136
Did you generate mipmaps?
124137

125138
### Render artifacts like small missing tiles on a floor
126139

127-
- synchronization issues - perhaps a missing glMemoryBarrier at the right spot
128-
- ubo/ssbo alignment issue - check std140/430 rule in the glsl spec
129-
- binding multiple textures to the same slot - check your glBindTextureUnit calls
130-
- you might be using a float to index into a buffer to grab material/texture info, use a flat int
140+
VERY likely an alignment issue. **Check** the alignment rules in the **GLSL Specification**.
141+
142+
Other reasons could be that you are binding multiple textures to the same slot/unit. Check your `glBindTextureUnit` calls and if you are stuck in non DSA land,
143+
check your `glBindTexture/glActiveTexture/glUniform1f` combinations.
144+
145+
Another classic is not using a flat index when indexing into material buffers or texture arrays.
146+
147+
```glsl
148+
layout(location = n) flat int in v_material_index;
149+
```
150+
151+
Synchronization issues could be yet another reason. Perhaps a missing `glMemoryBarrier` at the right spot.
131152

132153
### Depth buffer not cleared
133154

134155
- Despite calling `glClear(GL_DEPTH_BUFFER_BIT)` => check if `glDepthMask` was set to `GL_FALSE`. When you use FBOs migrate to glClearNamedFramebuffer() if you havent already (still requires glDepthMask set properly)
135156

136-
### Weird "Z-fighting"
157+
### Weird "Z-Fighting"
137158

138159
- check your depth buffer, near and far planes... try near 0.1f and 512/1024 as farplane
139160
- your depth buffer might be too small and is set to D16 only, set it to something D24 or D32
140161
- you use SDL2 and on your platform the default might be set to D16, find the SDL2_GL_Set_Attribute which sets the depth bits for the default fbo
162+
163+
### PS
164+
165+
`RenderDoc` is not a profiler, the frametimes you see reported there are not really usable. Use an actual gpu profiler like `NSight Graphics`. I hear you complain already
166+
that Version YYYY.XX doesnt support your potato GPU. NVidia provides downloads for older versions as well, you just dont get the latest bling features with it.

0 commit comments

Comments
 (0)