Skip to content

Commit 7508961

Browse files
committed
Fixup docs
1 parent 66f604d commit 7508961

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

guide/src/shader_objects/drawing_triangle.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
Add a `ShaderProgram` to `App` and its create function:
44

55
```cpp
6+
[[nodiscard]] auto asset_path(std::string_view uri) const -> fs::path;
7+
8+
// ...
69
void create_shader();
710

811
// ...
912
std::optional<ShaderProgram> m_shader{};
1013
```
1114
12-
Implement and call `create_shader()`:
15+
Implement and call `create_shader()` (and `asset_path()`):
1316
1417
```cpp
1518
void App::create_shader() {
@@ -22,6 +25,10 @@ void App::create_shader() {
2225
};
2326
m_shader.emplace(shader_ci);
2427
}
28+
29+
auto App::asset_path(std::string_view const uri) const -> fs::path {
30+
return m_assets_dir / uri;
31+
}
2532
```
2633

2734
Before `render()` grows to an unwieldy size, extract the higher level logic into two member functions:

guide/src/shader_objects/shader_program.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Shader Program
22

3-
SPIR-V modules are binary files with a stride/alignment of 4 bytes. The Vulkan API accepts a span of `std::uint32_t`s, so we need to load it into such a buffer (and _not_ `std::vector<std::byte>` or other 1-byte equivalents). We will encapsulate both vertex and fragment shaders into a single `ShaderProgram`, which will also bind the shaders before a draw, and expose/set various dynamic states.
3+
We will encapsulate both vertex and fragment shaders into a single `ShaderProgram`, which will also bind the shaders before a draw, and expose/set various dynamic states.
44

55
In `shader_program.hpp`, first add a `ShaderProgramCreateInfo` struct:
66

@@ -233,35 +233,3 @@ void ShaderProgram::bind_shaders(vk::CommandBuffer const command_buffer) const {
233233
command_buffer.bindShadersEXT(stages_v, shaders);
234234
}
235235
```
236-
237-
## TODO: MOVE
238-
239-
Add new members to `App`:
240-
241-
```cpp
242-
void create_pipelines();
243-
244-
[[nodiscard]] auto asset_path(std::string_view uri) const -> fs::path;
245-
```
246-
247-
Add code to load shaders in `create_pipelines()` and call it before starting the main loop:
248-
249-
```cpp
250-
void App::create_pipelines() {
251-
auto shader_loader = ShaderLoader{*m_device};
252-
// we only need shader modules to create the pipelines, thus no need to
253-
// store them as members.
254-
auto const vertex = shader_loader.load(asset_path("shader.vert"));
255-
auto const fragment = shader_loader.load(asset_path("shader.frag"));
256-
if (!vertex || !fragment) {
257-
throw std::runtime_error{"Failed to load Shaders"};
258-
}
259-
std::println("[lvk] Shaders loaded");
260-
261-
// TODO
262-
}
263-
264-
auto App::asset_path(std::string_view const uri) const -> fs::path {
265-
return m_assets_dir / uri;
266-
}
267-
```

0 commit comments

Comments
 (0)