Description
The WithStaticUsage
method of the TextureBuilder
class provides a hint to the GPU that the texture being built will not be modified after its creation. This can optimize the performance by allowing the GPU to handle the texture more efficiently, as it can assume the texture data will remain constant.
Usage
Use the WithStaticUsage
method when you are certain that the texture data will not change after it is initially set. This is particularly useful for textures that are loaded once and used repeatedly without modification, such as static background images or UI elements.
Example
// Example of using WithStaticUsage in a TextureBuilder
TextureBuilder builder = new TextureBuilder();
builder.WithSize(256, 256)
.WithFormat(ImageFormat.RGBA8)
.WithStaticUsage();
Texture texture = builder.Create("MyStaticTexture", false, data, data.Length);