-
Notifications
You must be signed in to change notification settings - Fork 25
Update 1-1-3-hello-triangle.md for #95 #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update 1-1-3-hello-triangle.md for #95 #124
Conversation
|
github actions is still broken due to perms |
|
yes I already fixed it with b7ad37b, but on PRs it seems to use the old workflows, even when I click 'Re-run jobs' and doesn't update them directly. Perhaps push a empty commit and see if it re-runs properly? |
|
Consider testing those workflow things using your fork before committing nonsense to the repo, thanks :) |
deccer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things...
| - `SemanticName`: lets us refer to a particular field given the string after the colon in HLSL (remember `float3 position: POSITION`) | ||
| D3D11_INPUT_ELEMENT_DESC vertexInputLayoutInfo[] is an array since when we pass data to a GPU to read in the **vertex shader** we need to specify to the GPU how 1 vertex of data will be formatted for when we later load many vertices onto the GPU to render a triangle. | ||
|
|
||
| **now lets explain what makes up a Input Layout Description** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capital N please
| this allows us to do things such as have 4 elements named `POSITION`, with a semantic index of 0, 1, 2, 3 — being convenient for the programmer to not have to type `POSITION0` `POSITION1` `POSITION2` `POSITION3` | ||
| - `Format`: the format of this field, basically how many components there are and what type they are, a `float3` in HLSL is a vector of 3 floats, each float is 4 bytes wide (or 32 bits), so the format here is `DXGI_FORMAT_R32G32B32_FLOAT`. We made a `float3` to map to `VSInput` and the types inside the HLSL struct | ||
| - `InputSlot`: we'll see about this later since right now it has no use, but for now all you need to know is that a GPU cannot store an infinite amount of Input Layouts, instead you specify here what 'slot' this input layout occupy's in memory that stores input layouts. | ||
| - `AlignedByteOffset`: the offset of where this field starts in the memory of 1 vertex in bytes. For example with `vertexInputLayoutInfo`, since we want `COLOR` after `POSITION` which is a `float3` (12 bytes) — we tell D3D11 that we want a 12 byte offset to put `COLOR` immediately after `POSITION` in memory. `POSITION` on the other hand needs no offset and is the first element (offset is 0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be remassaged into explaining offsetof here instead of adding those comments up in the code (which i dont like that much)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine to make this change - I think it may have a small negative to reader since more obfuscated data, but probably not important in the grand scheme of things
it needed a rewording anyways
| - `InputSlot`: we'll see about this later since right now it has no use, but for now all you need to know is that a GPU cannot store an infinite amount of Input Layouts, instead you specify here what 'slot' this input layout occupy's in memory that stores input layouts. | ||
| - `AlignedByteOffset`: the offset of where this field starts in the memory of 1 vertex in bytes. For example with `vertexInputLayoutInfo`, since we want `COLOR` after `POSITION` which is a `float3` (12 bytes) — we tell D3D11 that we want a 12 byte offset to put `COLOR` immediately after `POSITION` in memory. `POSITION` on the other hand needs no offset and is the first element (offset is 0). | ||
| offsetof(VertexPositionColor, color) is a preprocessor that calcualtes the offset for us using a struct and its element name as input | ||
| - `InputSlotClass`: The rate of input is either per-vertex or per-instance, we don't care about instances right now, so we'll set this to PER_VERTEX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe instead of "we dont care about x" we should write "you can ignore x for now, we will pick it up later when we use it"??? not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| UINT InstanceDataStepRate | ||
| } | ||
| ``` | ||
| - `SemanticName`: Tells the GPU to expect in the **vertex shader** that a variable in a vertex shader input struct (`VSInput` in this case) with the same `SemanticName` (string after a colon in the vertex shader's declaration — recall `float3 position: STUFF_AFTER_COLON`) will be where the GPU puts the received data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is quite long and too many stuff is wrapped in braces somehow :) can this maybe broken into 2 or more sentences and dont be afraid to write more text if you have to.
the last (string after a colon ... feels kinda strange the way its written, but it could also just be me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I adjusted it and will make a more natural language setup to explain the process.
I start with what it is, how it links - and then simply a part of where it actually is shown in the gpu code, but revised the English to be better
| DXGI_FORMAT::DXGI_FORMAT_R32G32B32_FLOAT, | ||
| 0, | ||
| offsetof(VertexPositionColor, position), | ||
| offsetof(VertexPositionColor, position) /*resolves to 0*/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the comments from offsetof as mentioned below
No description provided.