Add missing check for sample usage in material textures;

This commit is contained in:
bjorn 2022-11-14 20:10:23 -08:00
parent b61dbab21b
commit 58dc7ee9dd
1 changed files with 1 additions and 0 deletions

View File

@ -2066,6 +2066,7 @@ Material* lovrMaterialCreate(const MaterialInfo* info) {
lovrRetain(textures[i]);
Texture* texture = textures[i] ? textures[i] : state.defaultTexture;
lovrCheck(i == 0 || texture->info.type == TEXTURE_2D, "Material textures must be 2D");
lovrCheck(texture->info.usage & TEXTURE_SAMPLE, "Textures must be created with the 'sample' usage to use them in Materials");
bindings[i + 1] = (gpu_binding) { i + 1, GPU_SLOT_SAMPLED_TEXTURE, .texture = texture->gpu };
material->hasWritableTexture |= texture->info.usage != TEXTURE_SAMPLE;
}