Skip to content

Commit 5dc7a42

Browse files
committed
Add links to next chapter and actual projects in GitHub. Fixes #115.
1 parent e12f455 commit 5dc7a42

19 files changed

+125
-22
lines changed

docs/1-introduction/1-1-getting-started/1-1-0-overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A few words about how each project will look like.
2525

2626
Inside the project folder:
2727

28-
```
28+
```bash
2929
Assets/
3030
Assets/Models/
3131
Assets/Shaders/
@@ -45,3 +45,5 @@ x-x-x-project.vcxproj
4545
- `obj/` contains all intermediate junk the compiler produced, to keep the folder structure clean
4646
- `bin/` will contain the compiled program of the chapter along with all necessary `Assets`
4747
- `Assets/` will contain all the used assets, such as models, shaders and textures and other things. It will be empty for the first few chapters, and we will copy it and its contents to the bin/Debug or bin/Release directory, depending on which configuration you chose
48+
49+
[Next chapter](../1-1-1-hello-window/)

docs/1-introduction/1-1-getting-started/1-1-1-hello-window.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,10 @@ and more.
432432

433433
![](../../images/1-1-1-hello-window-1.png)
434434

435+
[Unabstracted Hello Window Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow)
436+
437+
[Raw Winapi Hello Window Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-1-HelloWin32Window)
438+
439+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-1-HelloWindow)
440+
435441
[Next chapter](../1-1-2-hello-d3d11/)

docs/1-introduction/1-1-getting-started/1-1-2-hello-d3d11.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,6 @@ glfwSetFramebufferSizeCallback(_window, HandleResize);
478478
479479
[`glfwSetFramebufferSizeCallback`](https://www.glfw.org/docs/3.3/group__window.html#gab3fb7c3366577daef18c0023e2a8591f) will tell `GLFW` what to do when we resize the window, in this case execute `HandleResize` which will fetch our application instance and all `OnResize` on it, where we can handle resizing in our application code.
480480
481-
## Abstraction into Application & D3D11Context
481+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-2-HelloD3D11)
482+
483+
[Next chapter](../1-1-3-hello-triangle/)

docs/1-introduction/1-1-getting-started/1-1-3-hello-triangle.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ In the last chapter we initialized core components of `D3D11` and DXGI such as t
44
This time we'll be drawing our first triangle with a nice froge-like color.
55

66
## The Pipeline
7-
The fundamental part of all graphic APIs is the "Graphics Pipeline". Everything from a single triangle, textured frog or the whole Elden Ring map goes through this pipeline. It is a series of functions that either exist in hardware, can be configured or are fully programmable. It transforms everything we draw in 3D space to the 2D space that is our monitor.
7+
8+
The fundamental part of all graphic APIs is the "Graphics Pipeline". Everything from a single triangle, textured frog or the whole Elden Ring map goes through this pipeline. It is a series of functions that either exist in hardware, can be configured or are fully programmable. It transforms everything we draw in 3D space to the 2D space that is our monitor.
89

910
All the steps in the graphics pipeline go from top to bottom and are shown below.
1011

@@ -18,6 +19,7 @@ The Vertex and Pixel shaders are fully programmable and we'll write a very basic
1819
The other two stages are not programmable but they are fairly easy to understand and configure, the **Input Assembler** is responsible for processing the vertices in an eventual vertex buffer into the primitive of our choice, which is of course, triangles in our case, and sending this processed output to the Vertex Shader. The **Output Merger** instead is responsible for combining the values written by the pixel shader, may that be depth, color or other things, into the one or more render targets that we provide to the OM, we only have one render target for now.
1920

2021
### Vertex Shader
22+
2123
The **Vertex Shader** is the stage where our vertices are processed however we want, although we don't do much processing here, and in the end they're transformed to [screen-space coordinates](link to the coordinate system chapter?)
2224

2325
The vertices are usually read from a **Vertex Buffer** which are laid out in a particular way. The vertex shader will be run however many times we tell it to run, which is specified in the first parameter of `ID3D11DeviceContext::Draw()` (more on this later), for instance if we call `Draw(3, 0)`, the vertex shader will run 3 times.
@@ -27,7 +29,9 @@ Since we only want to draw a triangle, we don't need to do much processing, we c
2729
The vertex buffer can be omitted, for example if we want to draw a full screen triangle, instead of creating a vertex buffer, for simplicity we can just hardcode the vertices in the vertex shader without having to bind a vertex buffer.
2830

2931
Let's look at our basic vertex shader for this section:
32+
3033
#### Main.vs.hlsl
34+
3135
```hlsl
3236
struct VSInput
3337
{
@@ -49,29 +53,33 @@ VSOutput Main(VSInput input)
4953
return output;
5054
}
5155
```
56+
5257
First off, we define 2 types, `VSInput` and `VSOutput` which represent the vertex shader's input and output.
5358

5459
The input is 2, `float3` (vector of 3 float components), the first is the "position" field, which are coordinates ranging from [-1.0, 1.0], if the values are outside this range they are clipped, and we won't see them on screen.
5560

5661
The second is the "color" field, which we also pass as the output of this stage onto the pixel shader.
5762

58-
Notice how all our fields have a colon and some identifier attached to them, these are "semantics".
59-
Semantics that are preceded by `SV` are called "system-value semantics" and their meaning and usage is defined by D3D11. `SV_Position` for example means that the field `position` will be used by D3D11 as the actual output of the vertex shader.
63+
Notice how all our fields have a colon and some identifier attached to them, these are "semantics".
64+
Semantics that are preceded by `SV` are called "system-value semantics" and their meaning and usage is defined by D3D11. `SV_Position` for example means that the field `position` will be used by D3D11 as the actual output of the vertex shader.
6065
Everything else are "user defined semantics" and their naming is up to us. These are used to pass data between shader stages.
6166

6267
Then we have our `VSOutput`, which has our vertices in the first field `position` and our color in the second field `color`.
6368

6469
Finally we have our main function, which takes in a single parameter which is our input in the form of `VSInput`, and returns our output in the form of a `VSOutput`. Since we don't do any processing, we simply make a new instance of `VSOutput`, initialize it all to 0 and forward our input position and color to the output.
6570

6671
### Pixel Shader
72+
6773
The **Pixel Shader** is the stage where we give the pixels on our render target color, it is invoked for each pixel that is covered by a triangle.
6874

6975
We use this stage to apply most of our shading techniques, from basic lighting, to textures and shadows, all the way to physically based rendering.
7076

7177
Since we did not specify any shader between the VS and the PS, our input here is the output of the VS, and the output is one or more render targets.
7278

7379
Let's look at our Pixel Shader now:
80+
7481
#### Main.ps.hlsl
82+
7583
```hlsl
7684
struct PSInput
7785
{
@@ -91,6 +99,7 @@ PSOutput Main(PSInput input)
9199
return output;
92100
}
93101
```
102+
94103
Here as well we have an input `PSInput`, and an output `PSOutput`.
95104

96105
Since there aren't any other shaders in between the VS and the PS, the VS's output is the PS's input, the naming might be a bit confusing but that's the gist of it, PSInput should match the VSOutput in vertex shader, this isn't entirely required but not doing so is only advisable if you really know what you are doing.
@@ -99,16 +108,18 @@ Next we have our output, `D3D11` gives us the possibility to write to multiple r
99108

100109
Notice how we have another semantic string attached to the `color` field, this semantic string specifies which render target we want to be writing to, the `0` after `SV_Target` is the index of our render target, in our case, we have only one so we write `SV_Target0` or `SV_Target`.
101110

102-
`D3D11` lets us write up to 8 render targets simultaneously from the same pixel shader, those come in handy when implementing more advanced shading techniques, for example a popular technique that uses 4 or more
111+
`D3D11` lets us write up to 8 render targets simultaneously from the same pixel shader, those come in handy when implementing more advanced shading techniques, for example a popular technique that uses 4 or more
103112

104113
And lastly, our `Main` function, following the same pattern as in the VS, we have one parameter, the input, and one return value, the output, again we create an instance of `PSOutput`, initialize everything to 0, and write the color we got from the input, to our output.
114+
105115
## Compiling shaders
106116

107117
Now that we wrote our shader code and saved it somewhere, we have to feed this to the GPU, to do that we'll have our D3DCompiler get to work.
108118

109119
First, we will declare some functions that will help us compile our shaders more quickly.
110120

111121
### HelloTriangle.hpp
122+
112123
```cpp
113124
bool CompileShader(
114125
const std::wstring_view fileName,
@@ -122,6 +133,7 @@ bool CompileShader(
122133

123134
[[nodiscard]] ComPtr<ID3D11PixelShader> CreatePixelShader(std::wstring_view fileName) const;
124135
```
136+
125137
In order we have:
126138
127139
`CompileShader`: This function is the core for compiling shaders, it requires 3 input parameters:
@@ -140,9 +152,13 @@ Then:
140152
`CreatePixelShader`: It does the same thing that `CreateVertexShader` does, except we don't need to pass a `ID3DBlob` here.
141153
142154
Now that we know how our new members look, we will see how we implemented them.
155+
143156
### HelloTriangle.cpp
157+
144158
First things first, let's see `CompileShader`:
159+
145160
#### CompileShader
161+
146162
```cpp
147163
bool HelloTriangleApplication::CompileShader(
148164
const std::wstring_view fileName,
@@ -188,7 +204,7 @@ Then we call for [`D3DCompileFromFile`](https://docs.microsoft.com/en-us/windows
188204
- `pInclude`: optional, a pointer to a `ID3DInclude` object, it is useful to specify how to handle `#include` directives in shaders. It is common to just use `D3D_COMPILE_STANDARD_FILE_INCLUDE`, which is the default handler.
189205
- `pEntrypoint`: a string containing the name of the main function in the shader.
190206
- `pTarget`: a string containing the Shader Model version to use for this shader.
191-
- `Flags1`: the flags that changes how to compile our shaders, for example we pass `D3DCOMPILE_ENABLE_STRICTNESS` which makes the compiler stricter in judging our code and disables legacy syntax support.
207+
- `Flags1`: the flags that changes how to compile our shaders, for example we pass `D3DCOMPILE_ENABLE_STRICTNESS` which makes the compiler stricter in judging our code and disables legacy syntax support.
192208
- `Flags2`: ignored, set to 0.
193209
- `ppCode`: output, a pointer to a `ID3DBlob*`, this is where our compiled code will be stored.
194210
- `ppErrorMsgs`: optional, output, a pointer to a `ID3DBlob*`, this is where the D3D compiler will store our errors, `nullptr` if everything went fine.
@@ -198,6 +214,7 @@ Then we do our usual checking, if there were errors, leave the output blob as is
198214
Now let's see `CreateVertexShader` and `CreatePixelShader`:
199215

200216
#### CreateVertexShader
217+
201218
```cpp
202219
HelloTriangleApplication::ComPtr<ID3D11VertexShader> HelloTriangleApplication::CreateVertexShader(
203220
const std::wstring_view fileName,
@@ -228,6 +245,7 @@ As you can see here we are using our helper function `CompileShader` to avoid re
228245
After we get our blob successfully, we can create a vertex shader out of it with `ID3D11Device::CreateVertexShader`, it takes a pointer to a buffer with the compiled code and its size as the input. The resulting vertex shader is the last parameter which is our output.
229246
230247
And finally
248+
231249
#### CreatePixelShader
232250
233251
```cpp
@@ -253,10 +271,13 @@ HelloTriangleApplication::ComPtr<ID3D11PixelShader> HelloTriangleApplication::Cr
253271
return pixelShader;
254272
}
255273
```
274+
256275
Pretty much the same thing as `CreateVertexShader`, the only thing that changes is the `profile` parameter, from `"vs_5_0"` to `"ps_5_0"`, since we're not compiling a vertex shader now, we have to change this to the "Pixel Shader Model 5.0".
257276

258277
After all of this, we can now call these functions, in `HelloTriangleApplication::Initialize()` you should now add:
278+
259279
#### Initialize
280+
260281
```cpp
261282
ComPtr<ID3DBlob> vertexShaderBlob = nullptr;
262283
_vertexShader = CreateVertexShader(L"Assets/Shaders/Main.vs.hlsl", vertexShaderBlob);
@@ -275,6 +296,7 @@ if (_pixelShader == nullptr)
275296
We still have a `vertexShaderBlob` now, it will be useful to us later, in creating an input layout.
276297

277298
### Input Layouts
299+
278300
We have successfully compiled our shaders now, we need one last thing, an **Input Layout**.
279301
An input layout, is basically the format we want to lay our vertices in our buffers.
280302

@@ -487,3 +509,11 @@ _deviceContext->OMSetRenderTargets(
487509
As you can see, we go through the pipeline in an orderly fashion, and although we don't use all the stages, we can see the top-to-bottom execution of the stages, IA (Input Assembler) -> VS (Vertex Shader) -> RS (Rasterizer Stage) -> PS (Pixel Shader) -> OM (Output Merger).
488510
489511
You should now be able to run this and see your first triangle!
512+
513+
!!! error
514+
515+
Provide picture of window with triangle
516+
517+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-3-HelloTriangle)
518+
519+
[Next chapter](../1-1-4-abstractions/)

docs/1-introduction/1-1-getting-started/1-1-4-abstractions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,7 @@ struct VertexPositionColor
106106
!!! error "Explain DeviceContext"
107107

108108
!!! error "Migrate from current hello-triangle to hello-triangle-refactored"
109+
110+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-1-3-HelloTriangle-Refactored)
111+
112+
[Next chapter](../1-2-debug/1-2-0-overview.md)

docs/1-introduction/1-2-debug/1-2-0-overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ There are various tools and techniques which can help us getting the triangle on
1515
[RenderDoc](1-2-4-renderdoc.md)
1616

1717
[Laptop GPUs](1-2-5-laptop-gpus.md)
18+
19+
[Next chapter](./1-2-1-clear-state.md)

docs/1-introduction/1-2-debug/1-2-1-clear-state.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ Setting their states/buffers/resources/targets to NULL where possible by hand.
1919
Or call a more "reset it all" function that exists on the ID3D11DeviceContext aptly called __ClearState()__.
2020
!!! info
2121
https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-clearstate
22-
22+
2323
Though keep in mind that using the latter function also resets stuff like the inputlayout, primitive topology and literally everything. This might require a bit more work in making sure all rendering state is setup correctly again afterwards
2424

25-
In pure performance terms it can be quite wasteful to reset a whole bunch of state (or re-set it) every draw/pass/frame which is why this is viewed as a debugging option.
25+
In pure performance terms it can be quite wasteful to reset a whole bunch of state (or re-set it) every draw/pass/frame which is why this is viewed as a debugging option.
26+
27+
In the end, one generally should make sure their draws always set (or have set) their required state so they do not need to use a clear-state.
2628

27-
In the end, one generally should make sure their draws always set (or have set) their required state so they do not need to use a clear-state.
29+
[Next chapter](./1-2-2-debug-layer.md)

docs/1-introduction/1-2-debug/1-2-2-debug-layer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,7 @@ However the developer probably did not intend to make use of this behavior. [ E
110110
How to do that via the control panel
111111
112112
One thing which should go without saying, the debug layer will slow down your application a bit.
113+
114+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-2-2-DebugLayer)
115+
116+
[Next chapter](./1-2-3-naming-things.md)

docs/1-introduction/1-2-debug/1-2-3-naming-things.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ D3D11 WARNING: Live ID3D11Context at 0x000002214E8A5B50, Name: CTX_Main, Refcou
4747
Notice anything?
4848

4949
Exactly, they show names.
50+
51+
[Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-2-3-NamingThings)
52+
53+
[Next chapter](./1-2-4-renderdoc.md)

docs/1-introduction/1-2-debug/1-2-4-renderdoc.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# RenderDoc
22

3-
Typically while developing an application there will be complications that cannot be easily deduced by watching the program execute or by reading the code; in a situation like this one will use a debugger to monitor the state of the program to locate the bug, and this is no different for graphics programming.
3+
Typically while developing an application there will be complications that cannot be easily deduced by watching the program execute or by reading the code; in a situation like this one will use a debugger to monitor the state of the program to locate the bug, and this is no different for graphics programming.
44

5-
Graphics programmers will use what is called a "graphics debugger" when working with a graphics API to monitor API calls, pipeline state, data within the pipeline, etc.
5+
Graphics programmers will use what is called a "graphics debugger" when working with a graphics API to monitor API calls, pipeline state, data within the pipeline, etc.
66

77
While there are multiple graphics debuggers provided by multiple vendors such as Nvidia's Nsight, AMD's Radeon Graphics Profiler (Does not directly support DX11), Intel's Graphics Performance Analyzers, and Microsoft's PIX, we will instead be using a cross-platform open-source option, RenderDoc.
88

99
To download RenderDoc, [click here](https://renderdoc.org/) and follow the instructions on the webpage.
1010

1111
![Screenshot](media/1-2-3-naming-things/render-doc-default.png)
1212

13-
Before getting into the details of Renderdoc, an executable is needed to display what the application is capable of.
13+
Before getting into the details of Renderdoc, an executable is needed to display what the application is capable of.
1414

1515
![Screenshot](media/1-2-3-naming-things/application-dirs.png)
1616

@@ -28,7 +28,7 @@ The RenderDoc window is now fully populated, however for the sake of brevity onl
2828

2929
![Screenshot](media/1-2-3-naming-things/event-browser.png)
3030

31-
The event browser displays a generalization of the API calls called in the form of events, an event is one or more API calls that have been grouped together by relation.
31+
The event browser displays a generalization of the API calls called in the form of events, an event is one or more API calls that have been grouped together by relation.
3232

3333
There is not much going on in this example, but it can be helpful when debugging scenes making hundreds or even thousands of draws and dispatches a frame.
3434

@@ -38,14 +38,16 @@ The API Inspector displays the contents of an event by listing out the API calls
3838

3939
![Screenshot](media/1-2-3-naming-things/pipeline-state.gif)
4040

41-
The Pipeline State tab displays the state of each active pipeline stage in addition to bound resources for the currently selected event.
41+
The Pipeline State tab displays the state of each active pipeline stage in addition to bound resources for the currently selected event.
4242

43-
In this instance, the hull, domain, and geometry shader stages are grayed out because they were not used for that draw.
43+
In this instance, the hull, domain, and geometry shader stages are grayed out because they were not used for that draw.
4444

4545
The compute shader stage is called with its own dispatch commands and therefore is never active with the other stages; it is not a part of the rasterization pipeline.
4646

4747
![Screenshot](media/1-2-3-naming-things/resource-inspector.png)
4848

49-
The Resource Inspector presents a list of all the resources used to render the frame on the right side of the window with information pertaining to its usage within the frame, related resources, and the functions used to initialize the resource.
49+
The Resource Inspector presents a list of all the resources used to render the frame on the right side of the window with information pertaining to its usage within the frame, related resources, and the functions used to initialize the resource.
5050

5151
To learn more about RenderDoc, [click here](https://renderdoc.org/docs/index.html) for its documentation.
52+
53+
[Next chapter](./1-2-5-laptop-gpus.md)

0 commit comments

Comments
 (0)