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

Skip to content

Commit c05bff3

Browse files
committed
Fix wrong VkSamplerCreateInfo type assignments.
The four members of VkSamplerCreateInfo maxAnisotropy, mipLodBias, minLod and maxLod are floats, but actually assigned integer values.
1 parent af18336 commit c05bff3

10 files changed

Lines changed: 21 additions & 21 deletions

code/24_sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ class HelloTriangleApplication {
763763
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
764764
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
765765
samplerInfo.anisotropyEnable = VK_TRUE;
766-
samplerInfo.maxAnisotropy = 16;
766+
samplerInfo.maxAnisotropy = 16.0f;
767767
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
768768
samplerInfo.unnormalizedCoordinates = VK_FALSE;
769769
samplerInfo.compareEnable = VK_FALSE;

code/25_texture_mapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class HelloTriangleApplication {
777777
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
778778
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
779779
samplerInfo.anisotropyEnable = VK_TRUE;
780-
samplerInfo.maxAnisotropy = 16;
780+
samplerInfo.maxAnisotropy = 16.0f;
781781
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
782782
samplerInfo.unnormalizedCoordinates = VK_FALSE;
783783
samplerInfo.compareEnable = VK_FALSE;

code/26_depth_buffering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ class HelloTriangleApplication {
854854
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
855855
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
856856
samplerInfo.anisotropyEnable = VK_TRUE;
857-
samplerInfo.maxAnisotropy = 16;
857+
samplerInfo.maxAnisotropy = 16.0f;
858858
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
859859
samplerInfo.unnormalizedCoordinates = VK_FALSE;
860860
samplerInfo.compareEnable = VK_FALSE;

code/27_model_loading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ class HelloTriangleApplication {
861861
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
862862
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
863863
samplerInfo.anisotropyEnable = VK_TRUE;
864-
samplerInfo.maxAnisotropy = 16;
864+
samplerInfo.maxAnisotropy = 16.0f;
865865
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
866866
samplerInfo.unnormalizedCoordinates = VK_FALSE;
867867
samplerInfo.compareEnable = VK_FALSE;

code/28_mipmapping.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,15 +952,15 @@ class HelloTriangleApplication {
952952
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
953953
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
954954
samplerInfo.anisotropyEnable = VK_TRUE;
955-
samplerInfo.maxAnisotropy = 16;
955+
samplerInfo.maxAnisotropy = 16.0f;
956956
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
957957
samplerInfo.unnormalizedCoordinates = VK_FALSE;
958958
samplerInfo.compareEnable = VK_FALSE;
959959
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
960960
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
961-
samplerInfo.minLod = 0;
961+
samplerInfo.minLod = 0.0f;
962962
samplerInfo.maxLod = static_cast<float>(mipLevels);
963-
samplerInfo.mipLodBias = 0;
963+
samplerInfo.mipLodBias = 0.0f;
964964

965965
if (vkCreateSampler(device, &samplerInfo, nullptr, &textureSampler) != VK_SUCCESS) {
966966
throw std::runtime_error("failed to create texture sampler!");

code/29_multisampling.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,15 +1002,15 @@ VkSampleCountFlagBits getMaxUsableSampleCount() {
10021002
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
10031003
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
10041004
samplerInfo.anisotropyEnable = VK_TRUE;
1005-
samplerInfo.maxAnisotropy = 16;
1005+
samplerInfo.maxAnisotropy = 16.0f;
10061006
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
10071007
samplerInfo.unnormalizedCoordinates = VK_FALSE;
10081008
samplerInfo.compareEnable = VK_FALSE;
10091009
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
10101010
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
1011-
samplerInfo.minLod = 0;
1011+
samplerInfo.minLod = 0.0f;
10121012
samplerInfo.maxLod = static_cast<float>(mipLevels);
1013-
samplerInfo.mipLodBias = 0;
1013+
samplerInfo.mipLodBias = 0.0f;
10141014

10151015
if (vkCreateSampler(device, &samplerInfo, nullptr, &textureSampler) != VK_SUCCESS) {
10161016
throw std::runtime_error("failed to create texture sampler!");

en/06_Texture_mapping/01_Image_view_and_sampler.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ floors and walls.
218218

219219
```c++
220220
samplerInfo.anisotropyEnable = VK_TRUE;
221-
samplerInfo.maxAnisotropy = 16;
221+
samplerInfo.maxAnisotropy = 16.0f;
222222
```
223223

224224
These two fields specify if anisotropic filtering should be used. There is no
@@ -346,7 +346,7 @@ possible to simply not use it by conditionally setting:
346346
347347
```c++
348348
samplerInfo.anisotropyEnable = VK_FALSE;
349-
samplerInfo.maxAnisotropy = 1;
349+
samplerInfo.maxAnisotropy = 1.0f;
350350
```
351351

352352
In the next chapter we will expose the image and sampler objects to the shaders

en/09_Generating_Mipmaps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,14 @@ To see the results of this chapter, we need to choose values for our `textureSam
314314
void createTextureSampler() {
315315
...
316316
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
317-
samplerInfo.minLod = 0; // Optional
317+
samplerInfo.minLod = 0.0f; // Optional
318318
samplerInfo.maxLod = static_cast<float>(mipLevels);
319-
samplerInfo.mipLodBias = 0; // Optional
319+
samplerInfo.mipLodBias = 0.0f; // Optional
320320
...
321321
}
322322
```
323323

324-
To allow the full range of mip levels to be used, we set `minLod` to 0, and `maxLod` to the number of mip levels. We have no reason to change the `lod` value , so we set `mipLodBias` to 0.
324+
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.
325325

326326
Now run your program and you should see the following:
327327

fr/06_Texture_mapping/01_Vue_sur_image_et_sampler.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ même carré à la pipeline, pour dessiner un pavage au sol par exemple.
200200

201201
```c++
202202
samplerInfo.anisotropyEnable = VK_TRUE;
203-
samplerInfo.maxAnisotropy = 16;
203+
samplerInfo.maxAnisotropy = 16.0f;
204204
```
205205

206206
Ces deux membres paramètrent l'utilisation de l'anistropic filtering. Il n'y a pas vraiment de raison de ne pas
@@ -317,7 +317,7 @@ conditionnellement activer ou pas l'anistropic filtering :
317317
318318
```c++
319319
samplerInfo.anisotropyEnable = VK_FALSE;
320-
samplerInfo.maxAnisotropy = 1;
320+
samplerInfo.maxAnisotropy = 1.0f;
321321
```
322322

323323
Dans le prochain chapitre nous exposerons l'image et le sampler au fragment shader pour qu'il puisse utiliser la

fr/09_Générer_des_mipmaps.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,15 @@ Pour voir les résultats de ce chapitre, nous devons choisir les valeurs pour `t
372372
void createTextureSampler() {
373373
...
374374
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
375-
samplerInfo.minLod = 0;
375+
samplerInfo.minLod = 0.0f;
376376
samplerInfo.maxLod = static_cast<float>(mipLevels);
377-
samplerInfo.mipLodBias = 0; // Optionel
377+
samplerInfo.mipLodBias = 0.0f; // Optionel
378378
...
379379
}
380380
```
381381

382-
Pour utiliser la totalité des niveaux de mipmaps, nous mettons `minLod` à `0` et `maxLod` au nombre de niveaux de
383-
mipmaps. Nous n'avons aucune raison d'altérer `lod` avec `mipLodBias`, alors nous pouvons le mettre à `0`.
382+
Pour utiliser la totalité des niveaux de mipmaps, nous mettons `minLod` à `0.0f` et `maxLod` au nombre de niveaux de
383+
mipmaps. Nous n'avons aucune raison d'altérer `lod` avec `mipLodBias`, alors nous pouvons le mettre à `0.0f`.
384384

385385
Lancez votre programme et vous devriez voir ceci :
386386

0 commit comments

Comments
 (0)