# Meshes, textures, and uniforms

Keep geometry that rarely changes separate from values that change every frame. This makes resource ownership visible and avoids rebuilding a mesh just to move the camera.

The [triangle](../triangle/index.md) uses three unmanaged vertices. Each contains a `Float3` position followed by a `Color4`; that matches the basic pipeline's default vertex layout. `SetVertexBuffer<T>` borrows the span only during the call. Keep the array for future updates, but do not assume the backend keeps a pointer into it.

## Upload frame data as one value

The example uploads a `Float4x4` transform with `SetConstantBuffer(in transform)`. Its memory layout matches the shader's bindings: one matrix. If you add fields to the shader bindings, update the CPU buffer layout at the same time. A mismatched layout can compile successfully while producing incorrect pixels.

For a moving object, retain the vertices and update the transform. Reuse the command list. Mark the scene dirty and invalidate rendering only when its visible state changes.

## Add textures deliberately

Sampled textures and immutable vertex buffers are optional. Resolve `IGpuResourceDevice` before calling `CreateSampledTexture` or `CreateVertexBuffer`, and use an `IGpuResourceCommandList` to bind them. The texture contract accepts premultiplied RGBA8 mip levels, largest first, with tightly packed rows. Supplying straight-alpha data to that contract produces dark or bright fringes around transparent edges.

A texture shader also needs texture/sampler bindings and UV varyings. Adding a texture to a device does not change the triangle's color-only shader. Start with one known image and one sampler, verify its orientation and alpha, then add mip levels.

## Know the current boundary

The floorplan GPU example demonstrates immutable geometry and an atlas in DemoApp. Android's current Vulkan path does not implement this general resource contract; its initial path is position/color geometry with a uniform buffer and one draw per pass. The browser does not support border-color sampling, and its composition targets are not exposed as sampled textures.

Dispose owned textures and buffers when their owning page stops using them. Avoid recreating them in `RenderCore`. Do not dispose the window's shared device. If a capability is missing, choose a [documented fallback](../canvas-or-gpu/index.md) before allocating the rest of the scene.
