Hello Triangle MSAA¶
This example showcases the minimal changes needed to enable multisample anti-aliasing. Read the Hello Triangle example to see the differences.
The first place to look is createRenderTarget
, where the MSAA texture and view are initialized. This function is called on initialization and on window resize.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Filename: hello_triangle_msaa/hello_triangle_msaa.cpp
This creates a texture and a view with the correct multisampling configuration and new dimensions, which we will attach to the render pass option struct (KDGpu::RenderPassCommandRecorderOptions). This texture is able to hold more information (samples) per texel. Additionally, we need to configure the render pass option struct to multisample, passing in the same number of samples we did for the texture above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Filename: hello_triangle_msaa/hello_triangle_msaa.cpp
Notice that the render pass options contains two separate entries: one for view
and one for resolveView
. The view
is set to the multisample texture, which has extra sampling information. During an MSAA pass, though, the multisampled texture needs to have its extra information "resolved" into a final, regular texture: the resolveView
.
Also configure the graphics pipeline (KDGpu::GraphicsPipelineOptions) to multisample:
1 2 3 |
|
Filename: hello_triangle_msaa/hello_triangle_msaa.cpp
Lastly, on each frame, update the resolveView
with the swapchain view that we want to render to.
1 2 |
|
Filename: hello_triangle_msaa/hello_triangle_msaa.cpp
Updated on 2023-12-22 at 00:05:36 +0000