Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 898f655

Browse files
authored
Use VK_LOD_CLAMP_NONE constant to set mipmap max LOD level in sampler (#354)
This allows for using different texture sizes without having to know the mipmap count in advance. All conformant Vulkan implementations should be able to handle this constant, which is equal to `1000.0f`.
1 parent 1dbd594 commit 898f655

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

code/29_mipmapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ class HelloTriangleApplication {
952952
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
953953
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
954954
samplerInfo.minLod = 0.0f;
955-
samplerInfo.maxLod = static_cast<float>(mipLevels);
955+
samplerInfo.maxLod = VK_LOD_CLAMP_NONE;
956956
samplerInfo.mipLodBias = 0.0f;
957957

958958
if (vkCreateSampler(device, &samplerInfo, nullptr, &textureSampler) != VK_SUCCESS) {

code/30_multisampling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ class HelloTriangleApplication {
10021002
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
10031003
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
10041004
samplerInfo.minLod = 0.0f;
1005-
samplerInfo.maxLod = static_cast<float>(mipLevels);
1005+
samplerInfo.maxLod = VK_LOD_CLAMP_NONE;
10061006
samplerInfo.mipLodBias = 0.0f;
10071007

10081008
if (vkCreateSampler(device, &samplerInfo, nullptr, &textureSampler) != VK_SUCCESS) {

en/09_Generating_Mipmaps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,13 @@ void createTextureSampler() {
317317
...
318318
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
319319
samplerInfo.minLod = 0.0f; // Optional
320-
samplerInfo.maxLod = static_cast<float>(mipLevels);
320+
samplerInfo.maxLod = VK_LOD_CLAMP_NONE;
321321
samplerInfo.mipLodBias = 0.0f; // Optional
322322
...
323323
}
324324
```
325325

326-
To allow the full range of mip levels to be used, we set `minLod` to 0.0f, and `maxLod` to the number of mip levels. We have no reason to change the `lod` value , so we set `mipLodBias` to 0.0f.
326+
To allow the full range of mip levels to be used, we set `minLod` to 0.0f, and `maxLod` to `VK_LOD_CLAMP_NONE`. This constant is equal to `1000.0f`, which means that all available mipmap levels in the texture will be sampled. We have no reason to change the `lod` value, so we set `mipLodBias` to 0.0f.
327327

328328
Now run your program and you should see the following:
329329

fr/09_Générer_des_mipmaps.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,13 @@ void createTextureSampler() {
375375
...
376376
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
377377
samplerInfo.minLod = 0.0f;
378-
samplerInfo.maxLod = static_cast<float>(mipLevels);
378+
samplerInfo.maxLod = VK_LOD_CLAMP_NONE;
379379
samplerInfo.mipLodBias = 0.0f; // Optionnel
380380
...
381381
}
382382
```
383383

384-
Pour utiliser la totalité des niveaux de mipmaps, nous mettons `minLod` à `0.0f` et `maxLod` au nombre de niveaux de
385-
mipmaps. Nous n'avons aucune raison d'altérer `lod` avec `mipLodBias`, alors nous pouvons le mettre à `0.0f`.
384+
Pour utiliser la totalité des niveaux de mipmaps, nous mettons `minLod` à `0.0f` et `maxLod` à `VK_LOD_CLAMP_NONE`. Cette constante est égale à `1000.0f`, ce qui veut dire que la totalité des niveaux de mipmaps disponible dans la texture sera échantillonée. Nous n'avons aucune raison d'altérer `lod` avec `mipLodBias`, alors nous pouvons le mettre à `0.0f`.
386385

387386
Lancez votre programme et vous devriez voir ceci :
388387

0 commit comments

Comments
 (0)