Skip to content

Conversation

@16-Bit-Dog
Copy link
Contributor

No description provided.

@16-Bit-Dog
Copy link
Contributor Author

github actions is still broken due to perms

@spnda
Copy link
Member

spnda commented May 22, 2022

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?

@deccer
Copy link
Contributor

deccer commented May 22, 2022

Consider testing those workflow things using your fork before committing nonsense to the repo, thanks :)

@16-Bit-Dog 16-Bit-Dog changed the title Update 1-1-3-hello-triangle.md Update 1-1-3-hello-triangle.md for #95 May 22, 2022
Copy link
Contributor

@deccer deccer left a 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**
Copy link
Contributor

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).
Copy link
Contributor

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)

Copy link
Contributor Author

@16-Bit-Dog 16-Bit-Dog May 22, 2022

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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*/,
Copy link
Contributor

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

@spnda spnda merged commit 636903e into GraphicsProgramming:main Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants