Skip to content

Commit dea2c31

Browse files
committed
- Update multiple Vulkan tutorial sections and examples with improvements and fixes
- Add frame time-based rotation to `36_multiple_objects.cpp` for consistent object rotation speed. - Enhance Vulkan Configurator documentation for clarity and consistency. - Convert `README.md` to AsciiDoc (`README.adoc`) with improved structure and detailed instructions. - Include reference links for Khronos formats (glTF, KTX2) and improve descriptions. - Refine shared and per-object resource explanations in the multiple objects guide.
1 parent d7730ba commit dea2c31

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

attachments/36_multiple_objects.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,16 +1404,20 @@ class VulkanApplication {
14041404

14051405
void updateUniformBuffers() {
14061406
static auto startTime = std::chrono::high_resolution_clock::now();
1407+
static auto lastFrameTime = startTime;
14071408
auto currentTime = std::chrono::high_resolution_clock::now();
14081409
float time = std::chrono::duration<float>(currentTime - startTime).count();
1410+
float deltaTime = std::chrono::duration<float>(currentTime - lastFrameTime).count();
1411+
lastFrameTime = currentTime;
14091412

14101413
// Camera and projection matrices (shared by all objects)
14111414
glm::mat4 view = glm::lookAt(glm::vec3(2.0f, 2.0f, 6.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
14121415
glm::mat4 proj = glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 20.0f);
14131416
// Update uniform buffers for each object
14141417
for (auto& gameObject : gameObjects) {
1415-
// Apply continuous rotation to the object
1416-
gameObject.rotation.y += 0.001f; // Slow rotation around Y axis
1418+
// Apply continuous rotation to the object based on frame time
1419+
const float rotationSpeed = 0.5f; // Rotation speed in radians per second
1420+
gameObject.rotation.y += rotationSpeed * deltaTime; // Slow rotation around Y axis scaled by frame time
14171421

14181422
// Get the model matrix for this object
14191423
glm::mat4 model = gameObject.getModelMatrix();
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
# Android Project for Vulkan Tutorial
1+
= Android Project for Vulkan Tutorial
22

33
This Android project allows you to run different chapters of the Vulkan Tutorial on Android devices.
44

5-
## Selecting a Chapter
5+
== Selecting a Chapter
66

77
By default, the project builds and runs the `34_android` chapter. You can select a different chapter by setting the `chapter` property in your Gradle build.
88

9-
### Available Chapters
9+
=== Available Chapters
1010

11-
- `34_android`: The Android chapter that uses tinyobjloader to load OBJ models
12-
- `35_gltf_ktx`: The glTF and KTX chapter that uses tinygltf to load glTF models and KTX to load KTX2 textures
11+
* `34_android`: The Android chapter that uses tinyobjloader to load OBJ models
12+
* `35_gltf_ktx`: The glTF and KTX chapter that uses tinygltf to load glTF models and KTX to load KTX2 textures
1313

14-
### How to Select a Chapter
14+
=== How to Select a Chapter
1515

16-
#### From the Command Line
16+
==== From the Command Line
1717

18-
```bash
18+
[source,bash]
19+
----
1920
./gradlew assembleDebug -Pchapter=35_gltf_ktx
20-
```
21+
----
2122

22-
#### From Android Studio
23+
==== From Android Studio
2324

2425
1. Edit the `gradle.properties` file in the project root directory
2526
2. Add the following line:
26-
```
27-
chapter=35_gltf_ktx
28-
```
27+
+
28+
[source]
29+
----
30+
chapter=35_gltf_ktx
31+
----
2932
3. Sync the project and build
3033

31-
## Adding New Chapters
34+
== Adding New Chapters
3235

3336
To add support for a new chapter:
3437

@@ -38,7 +41,8 @@ To add support for a new chapter:
3841

3942
For example, to add support for a hypothetical `36_new_feature` chapter:
4043

41-
```cmake
44+
[source,cmake]
45+
----
4246
# Define the list of supported chapters
4347
set(SUPPORTED_CHAPTERS
4448
"34_android"
@@ -55,9 +59,9 @@ elseif(CHAPTER STREQUAL "36_new_feature")
5559
target_link_libraries(vulkan_tutorial_android
5660
# Add any required libraries here
5761
)
58-
62+
5963
target_compile_definitions(vulkan_tutorial_android PRIVATE
6064
# Add any required compile definitions here
6165
)
6266
endif()
63-
```
67+
----

en/12_Ecosystem_Utilities_and_Compatibility.adoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ If you're considering using a specific extension:
6363

6464
This helps you decide whether to require the extension or provide a fallback path.
6565

66-
==== Example: Using the vulkanconfig Tool
66+
==== Example: Using the Vulkan Configurator Tool
6767

68-
The `vulkanconfig` tool is included in the Vulkan SDK and provides a convenient way to configure Vulkan settings on your system. Here's how to use it:
68+
The Vulkan Configurator tool (executable name `vkconfig` on all platforms) is included in the Vulkan SDK and provides a convenient way to configure Vulkan settings on your system. Here's how to use it:
6969

70-
1. *Launch vulkanconfig*: Open a terminal or command prompt and run `vulkanconfig`
70+
1. *Launch the Vulkan Configurator*:
71+
- On Windows: It's recommended to start "Vulkan Configurator" from the Start menu, as running `vkconfig.exe` from the command line only shows limited options
72+
- On other platforms: Open a terminal and run `vkconfig`
73+
74+
Note that the executable is called `vkconfig` on all platforms.
7175

7276
2. *Configure Validation Layers*:
7377
- Navigate to the "Layers" tab
@@ -87,12 +91,12 @@ The `vulkanconfig` tool is included in the Vulkan SDK and provides a convenient
8791
- Save your configuration for later use or to share with team members
8892
- This ensures consistent Vulkan environments across development machines
8993

90-
Using `vulkanconfig` is particularly helpful when:
94+
Using the Vulkan Configurator is particularly helpful when:
9195
- Debugging Vulkan applications with different validation layer configurations
9296
- Testing your application with different Vulkan settings without modifying code
9397
- Setting up a development environment with specific Vulkan requirements
9498

95-
==== Using vulkanconfig for Validation Layers Instead of Code
99+
==== Using Vulkan Configurator for Validation Layers Instead of Code
96100

97101
In many Vulkan applications, validation layers are enabled programmatically during instance creation, typically only in debug builds. Here's how this is commonly done:
98102

@@ -142,7 +146,7 @@ While this approach works, it has several drawbacks:
142146
2. It's harder to experiment with different validation layer configurations
143147
3. It adds complexity to your codebase
144148

145-
A better approach is to use `vulkanconfig` to manage validation layers externally. Here's how to modify your code to take advantage of this:
149+
A better approach is to use the Vulkan Configurator to manage validation layers externally. Here's how to modify your code to take advantage of this:
146150

147151
[,c++]
148152
----
@@ -162,12 +166,12 @@ void createInstance() {
162166
With this approach:
163167

164168
1. You remove all validation layer-specific code from your application
165-
2. You use `vulkanconfig` to enable validation layers when needed
169+
2. You use the Vulkan Configurator to enable validation layers when needed
166170
3. You can switch validation configurations without recompiling
167171

168-
To enable validation layers with `vulkanconfig`:
172+
To enable validation layers with the Vulkan Configurator:
169173

170-
1. Launch `vulkanconfig`
174+
1. Launch the Vulkan Configurator (from the Start menu on Windows, or run `vkconfig` from the terminal - the executable is called `vkconfig` on all platforms)
171175
2. Go to the "Layers" tab
172176
3. Enable the `VK_LAYER_KHRONOS_validation` layer
173177
4. Apply the settings
@@ -187,7 +191,7 @@ Besides GPUInfo.org, several other tools can help you develop and debug Vulkan a
187191

188192
* *Vulkan SDK Tools*:
189193
** `vulkaninfo`: Displays Vulkan capabilities of your local system
190-
** `vulkanconfig`: A configuration tool for managing Vulkan settings (see <<Example: Using the vulkanconfig Tool>> for details)
194+
** `vkconfig` (Vulkan Configurator): A configuration tool for managing Vulkan settings (see <<Example: Using the Vulkan Configurator Tool>> for details)
191195
** Validation layers: Help identify API usage errors
192196
** RenderDoc: Graphics debugging tool
193197

en/13_Vulkan_Profiles.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ First, you need to include the Vulkan profiles header:
8585

8686
This header provides the necessary functions and structures to work with Vulkan profiles.
8787

88+
The Vulkan Profiles header is NOT part of the standard Vulkan headers.
89+
It is only available if you use the Vulkan SDK. Make sure you have the Vulkan SDK installed and properly configured in your development environment.
90+
8891
=== Defining the Profile Requirements
8992

9093
Instead of manually checking for features and extensions, you can define your profile requirements:

en/14_Android.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Now that we understand the key differences, let's set up our Android project. Ou
3030

3131
Before we begin, make sure you have the following tools installed:
3232

33-
* *Android Studio*: The official IDE for Android development
33+
* *link:++https://developer.android.com/studio[Android Studio]++[Android Studio]*: The official IDE for Android development
3434
* *Android NDK (Native Development Kit)*: Enables native C++ development on Android
3535
* *Android SDK*: With a recent API level (24+, which corresponds to Android 7.0 or higher) for Vulkan support
3636
* *CMake and Ninja build tools*: For building native code (these can be installed through Android Studio)

en/15_GLTF_KTX2_Migration.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Let's dive into the migration process and see how to adapt our Vulkan applicatio
2323

2424
=== What is glTF?
2525

26-
glTF (GL Transmission Format) is a royalty-free specification for the efficient transmission and loading of 3D scenes and models. Developed by the Khronos Group, glTF is designed to be a "JPEG for 3D" - a common publishing format for 3D content.
26+
https://www.khronos.org/gltf/[glTF] (GL Transmission Format) is a royalty-free specification for the efficient transmission and loading of 3D scenes and models. Developed by the Khronos Group, glTF is designed to be a "JPEG for 3D" - a common publishing format for 3D content.
2727

2828
Key features of glTF include:
2929

@@ -70,7 +70,7 @@ Let's compare the OBJ format with glTF:
7070

7171
=== What is KTX2?
7272

73-
KTX2 (Khronos Texture 2.0) is a container file format for storing texture data optimized for GPU usage. It's designed to work efficiently with modern graphics APIs like Vulkan, OpenGL, and DirectX.
73+
https://www.khronos.org/ktx/[KTX2] (Khronos Texture 2.0) is a container file format for storing texture data optimized for GPU usage. It's designed to work efficiently with modern graphics APIs like Vulkan, OpenGL, and DirectX.
7474

7575
Key features of KTX2 include:
7676

en/16_Multiple_Objects.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ When rendering multiple objects, we need to consider which resources should be:
1515
Here's a quick reference for what typically falls into each category:
1616

1717
*Shared resources:*
18+
1819
* Vertex and index buffers (when objects use the same mesh)
1920
* Textures and samplers (when objects use the same textures)
2021
* Pipeline objects and pipeline layouts
2122
* Render passes
2223
* Command pools
2324

2425
*Per-object resources:*
26+
2527
* Transformation matrices (position, rotation, scale)
2628
* Uniform buffers containing those matrices
2729
* Descriptor sets that reference those uniform buffers
@@ -306,14 +308,16 @@ When rendering multiple objects, keep these performance considerations in mind:
306308
== Conclusion
307309

308310
You've now learned how to render multiple objects in Vulkan by:
311+
309312
1. Creating a structure to hold per-object data
310-
2. Duplicating the necessary resources (uniform buffers, descriptor sets) for each object
313+
2. Duplicating the necessary resources with (uniform buffers, descriptor sets) for each object
311314
3. Sharing resources that can be reused (vertex/index buffers, pipeline, textures)
312315
4. Updating the rendering loop to draw each object with its own transformation
313316

314317
This approach gives you the flexibility to position, rotate, and scale objects independently while maintaining good performance by sharing resources where appropriate.
315318

316319
In a real-world application, you might extend this system with:
320+
317321
* Object hierarchies (parent-child relationships)
318322
* Different meshes and materials for different objects
319323
* Frustum culling to avoid rendering objects outside the camera view

0 commit comments

Comments
 (0)