Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0c2b9cf
Prefer use of dynamic state for viewport and scissor
SaschaWillems Apr 1, 2022
84ad844
Slight rewording, working in-page anchor
SaschaWillems Apr 2, 2022
e83821a
Updated command buffers chapter and code to use dynamic viewport and …
SaschaWillems Apr 2, 2022
a54e39e
Updated swap chain recreation chapter
SaschaWillems Apr 2, 2022
51c260e
Updated command buffer chapter code to use dynamic viewport and scissor
SaschaWillems Apr 2, 2022
858d92d
Removed render pass destruction/creation for swap chain recreation
SaschaWillems Apr 2, 2022
0dd95af
Use dynamic state for viewport and scissor for samples after the fixe…
SaschaWillems Apr 2, 2022
806b78d
Use dynamic state for viewport and scissor for samples after the swap…
SaschaWillems Apr 2, 2022
e7e9d8d
Removed duplicate code
SaschaWillems Apr 2, 2022
0c60c92
Wording change
SaschaWillems Apr 2, 2022
35dd1d6
Changed wording on chapter intro, moved dynamic state paragraph to th…
SaschaWillems Apr 2, 2022
7c9d4da
Fixed wording
SaschaWillems Apr 19, 2022
dac0600
Fixed wording
SaschaWillems Apr 19, 2022
8bf72b9
C++ style cast
SaschaWillems Apr 19, 2022
04c6501
Wording
SaschaWillems Apr 19, 2022
7eac464
Wording
SaschaWillems Apr 19, 2022
1fb414b
Wording
SaschaWillems Apr 19, 2022
ea851d5
Added note on renderpass recreation
SaschaWillems May 6, 2022
de18ed9
Merge branch 'master' into dynamic_viewport
SaschaWillems Jun 11, 2022
cdaf5e6
Apply suggestions from code review
SaschaWillems Jun 25, 2022
748086e
Added dynamic state to conclusion chapter
SaschaWillems Jun 26, 2022
1e5de0b
Remove unnecessary link
SaschaWillems Jul 3, 2022
f87bfe7
Remove code referencing command buffers too early
SaschaWillems Jul 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed wording on chapter intro, moved dynamic state paragraph to th…
…e top
  • Loading branch information
SaschaWillems committed Apr 2, 2022
commit 35dd1d6cca92e891ccb36b111bf1be055ee41260
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@

The older graphics APIs provided default state for most of the stages of the
graphics pipeline. In Vulkan you have to be explicit about everything, from
viewport size to color blending function. In this chapter we'll fill in all of
the structures to configure these fixed-function operations.
graphics pipeline. In Vulkan you have to be explicit about most pipeline state as
it'll be baked into an immutable pipeline state object. In this chapter we'll fill
in all of the structures to configure these fixed-function operations.

<a name="dynamic-state"></a>
Comment thread
SaschaWillems marked this conversation as resolved.
Outdated

## Dynamic state

While *most* of the pipeline state needs to be baked into the pipeline state,
a limited amount of the state *can* actually be changed without recreating the
pipeline at draw time instead. Examples are the size of the viewport, line width
and blend constants. If you want to use dynamic state and keep these properties out,
then you'll have to fill in a `VkPipelineDynamicStateCreateInfo` structure like this:

```c++
std::vector<VkDynamicState> dynamicStates = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSROR
};

VkPipelineDynamicStateCreateInfo dynamicState{};
dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicState.dynamicStateCount = static_cast<uint32_t>(dynamicStates.size());
dynamicState.pDynamicStates = dynamicStates.data();
```

This will cause the configuration of these values to be ignored and you will be
able (and required) to specify the data at drawing time. This results in a more flexible
setup and is very common for things like viewport and scissor state, which would
result in a more complex setup when being baked into the pipeline state.

## Vertex input

Expand Down Expand Up @@ -362,31 +389,6 @@ determine which channels in the framebuffer will actually be affected. It is
also possible to disable both modes, as we've done here, in which case the
fragment colors will be written to the framebuffer unmodified.

<a name="dynamic-state"></a>

## Dynamic state

A limited amount of the state that we've specified in the previous structs *can*
actually be changed without recreating the pipeline. Examples are the size of
the viewport, line width and blend constants. If you want to do that, then
you'll have to fill in a `VkPipelineDynamicStateCreateInfo` structure like this:

```c++
std::vector<VkDynamicState> dynamicStates = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_LINE_WIDTH
};

VkPipelineDynamicStateCreateInfo dynamicState{};
dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicState.dynamicStateCount = static_cast<uint32_t>(dynamicStates.size());
dynamicState.pDynamicStates = dynamicStates.data();
```

This will cause the configuration of these values to be ignored and you will be
required to specify the data at drawing time. As noted earlier we'll make use
of dynamic viewport and scissor state.

## Pipeline layout

You can use `uniform` values in shaders, which are globals similar to dynamic
Expand Down