From 6f86e00cf6ed9d2bc10f8627b8fce5cd844d6b85 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Mon, 22 Oct 2018 19:59:43 +0100 Subject: [PATCH] Annotate hero/code480 --- cmuratori/hero/code/code480.hmml | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 cmuratori/hero/code/code480.hmml diff --git a/cmuratori/hero/code/code480.hmml b/cmuratori/hero/code/code480.hmml new file mode 100644 index 0000000..b298cfe --- /dev/null +++ b/cmuratori/hero/code/code480.hmml @@ -0,0 +1,67 @@ +[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Debugging Large Texture Support" vod_platform=youtube id=FvNWEIaz9tM annotator=Miblo] +[0:00][Recap and set the stage for the day debugging our large texture implementation][:"asset system" :speech] +[1:27][Refresh our memories on the additional multiple-dispatch slow path for arbitrary sized textures][:"asset system" :speech] +[3:17][Continue to investigate the incorrectness in the multiple-dispatch path][:"asset system"] +[6:40][Try making OpenGLInit() and OpenGLAllocateTexture() use GL_TEXTURE_2D_ARRAY for special textures][:"asset system" :hardware :memory] +[8:49][:Run the game and crash in OpenGLAllocateTexture()][:"asset system" :hardware :memory] +[9:08][Fix OpenGLAllocateTexture() to allocate one slice][:"asset system" :hardware :memory] +[9:27][:Run the game and crash in OpenGLEndFrame()][:"asset system" :hardware :memory] +[9:54][Make OpenGLEndFrame() use a GL_TEXTURE_2D_ARRAY for special textures][:"asset system" :hardware :memory] +[10:19][:Run the game without crashing, but also without seeing any cutscene textures][:"asset system"] +[11:48][Change GameUpdateAndRender() to boot directly into the cutscene] +[13:40][Capture a frame with Nsight and inspect the events][:"asset system" :hardware :rendering :run] +[18:57][Praise NVIDIA for Nsight's event filter][:speech] +[19:35][Continue to check out our glBindTexture events][:"asset system" :hardware :rendering :run] +[21:04][Break in the special texture path in OpenGLEndFrame() successfully][:"asset system" :hardware :rendering :run] +[21:50][Correctly set the working directory][:admin] +[22:40][Check out the glBindTexture event for our GL_TEXTURE_2D_ARRAY][:hardware :rendering :run] +[25:58][Consult the documentation on glTexImage3D[ref + site=docs.GL + page=glTexImage3D + url=http://docs.gl/gl3/glTexImage3D]][:hardware :rendering :research] +[26:14][Make OpenGLAllocateTexture() pass 0 as the level to glTexImage3D()][:hardware :rendering] +[27:29][:Run the game and see imagery][:rendering] +[28:26][Make PushQuad() correctly compute the UV coordinates for special textures][:rendering] +[29:52][:Run the game and see our cutscene texture more correctly, but without :animation or alpha blending][:rendering] +[31:48][Begin to investigate the bug in the alpha blending of large textures][:rendering] +[35:33][Step into PushQuad() and inspect the vertices][:rendering :run] +[39:10][Try making PushQuad() set the TextureIndex of special textures to 0][:rendering] +[40:02][:Run the game to see that that doesn't solve the transparency problem][:rendering] +[41:14][Make OpenGLEndFrame() unbind the GL_TEXTURE_2D_ARRAY][:rendering] +[44:38][:Run the game, see no difference and consider capturing a frame][:rendering] +[45:12][Try skipping the depth peeling altogether when :rendering the cutscene] +[47:15][:Run the game to see that the cutscene layers do get composited, but still without alpha blending][:rendering] +[48:48][Try making RenderLayeredScene() draw the cutscene layers in the opposite order][:rendering] +[50:00][:Run the game to see that this changed the zoom speed, but had no effect on the transparency][:animation :rendering] +[50:53][Revert RenderLayeredScene() to draw the cutscene in the original order][:rendering] +[51:39][Capture a frame of the cutscene, scrub through the events and inspect the shaders][:rendering :run] +[59:14][Toggle on ALLOW_GPU_SRGB][:rendering] +[1:01:30][:Run the game to see that that still works okay, but the cutscene also remains unaffected][:rendering] +[1:04:23][Capture a frame and scrutinise the fragment and vertex shaders][:rendering :run] +[1:10:48][Try making CompileZBiasProgram() hard set the FogAmount and AlphaAmount to known values][:rendering] +[1:11:14][:Run it to see no effect][:rendering] +[1:11:25][Try making CompileZBiasProgram() hard set the SurfaceReflect.a to 0.5][:rendering] +[1:11:42][:Run it to see no alpha blending][:rendering] +[1:14:12][Capture a frame and inspect the draw buffer settings][:rendering :run] +[1:22:40][Remove CompileDepthPeelToLighting() and other cruft from the OpenGL code][:hardware :rendering] +[1:28:01][:Run the game and Renderer Test to see that we didn't bust anything][:hardware :rendering] +[1:29:50][Refrain from binding the OpenGLColor_Emit and OpenGLColor_NPL handle types][:hardware :rendering] +[1:31:50][:Run the game to see that the background colour is now incorrect][:hardware :rendering] +[1:32:57][Remove the NPL samplers from CompilePeelComposite()][:hardware :rendering] +[1:34:50][:Run the game to see that the background colour is correct again, and capture a frame to see our intended single colour target][:rendering] +[1:36:22][Determine to investigate the positional corruption as exhibited by the draw order of the cutscene layers][:rendering :run] +[1:39:45][Make OpenGLEndFrame() call glDrawElementsBaseVertex() directly in the special texture path][:rendering :run] +[1:42:25][:Run it to see that it's looking a little better][:rendering] +[1:42:41][Make RenderLayeredScene() draw the layers in the original order][:rendering] +[1:42:52][:Run it to see that the cutscene plates are now correct, but the alpha blending is still not happening][:rendering] +[1:44:09][Capture a frame and take a closer look at the pixel operations to see that alpha blending was turned off the whole time][:rendering :run] +[1:47:37][Make OpenGLEndFrame() call glEnable() at the end of a depth peel][:rendering] +[1:48:27][:Run the game to see that the cutscene alpha blending works beautifully][:rendering] +[1:52:41][@cemuzunlar][Greatest [~hero Handmade Hero] Episode! A real hands on example of an ordinary day of a graphics programmer] +[1:53:32][Q&A][:speech] +[1:54:18][@frostyninja][Q: Missed what was preventing the parallax movement; could you point that out again real quick? Also is it just me or is the gamma off a little on the cutscenes? It looks a bit washed out to me][:rendering] +[1:55:14][Toggle off ALLOW_GPU_SRGB][:rendering] +[1:56:03][@vateferfout][Q: In the OpenGLAllocateTexture(), in the non-special texture case, you're calling the GetTextureIndexFrom() to mask off the special texture bit, but at this point you know that this bit isn't set, or am I reading this incorrectly?][:memory :rendering] +[1:56:26][@charliekelly_aka_dayman][Q: Do you have the :story for the game all written / thought out or are you still working on it?] +[1:57:03][Wrap it up][:speech] +[/video]