| 200 | } |
| 201 | |
| 202 | bool Material::loadTexture(TextureSlot slot, const std::filesystem::path& path, bool useSrgb) |
| 203 | { |
| 204 | if (!hasTextureSlot(slot)) |
| 205 | { |
| 206 | logWarning("Material '{}' does not have texture slot '{}'. Ignoring call to loadTexture().", getName(), to_string(slot)); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | auto texture = Texture::createFromFile(mpDevice, path, true, useSrgb && getTextureSlotInfo(slot).srgb); |
| 211 | if (texture) |
| 212 | { |
| 213 | setTexture(slot, texture); |
| 214 | // Wait for GPU to finish to prevent the upload heap from growing too large. Doing so after |
| 215 | // every texture creation is overly conservative, and will likely lead to performance issues |
| 216 | // due to the forced CPU/GPU sync. |
| 217 | mpDevice->wait(); |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | uint2 Material::getMaxTextureDimensions() const |
| 225 | { |