drivers/gpu/drm/vmwgfx/vmw_surface_cache.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmw_surface_cache.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmw_surface_cache.h- Extension
.h- Size
- 15916 bytes
- Lines
- 546
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
device_include/svga3d_surfacedefs.hdrm/vmwgfx_drm.h
Detected Declarations
struct vmw_surface_mipstruct vmw_surface_cachestruct vmw_surface_locfunction Copyrightfunction vmw_surface_get_descfunction vmw_surface_get_mip_sizefunction vmw_surface_get_size_in_blocksfunction vmw_surface_is_planar_surfacefunction vmw_surface_calculate_pitchfunction vmw_surface_get_image_buffer_sizefunction vmw_surface_get_serialized_sizefunction vmw_surface_get_serialized_size_extendedfunction imagefunction vmw_surface_get_image_offsetfunction vmw_surface_is_gb_screen_target_formatfunction vmw_surface_is_dx_screen_target_formatfunction vmw_surface_is_screen_target_formatfunction vmw_surface_subresfunction vmw_surface_setup_cachefunction vmw_surface_get_locfunction vmw_surface_inc_locfunction vmw_surface_min_locfunction vmw_surface_inc_loc
Annotated Snippet
struct vmw_surface_mip {
size_t bytes;
size_t img_stride;
size_t row_stride;
struct drm_vmw_size size;
};
/**
* struct vmw_surface_cache - Cached surface information
* @desc: Pointer to the surface descriptor
* @mip: Array of mipmap level information. Valid size is @num_mip_levels.
* @mip_chain_bytes: Bytes required in the backing store for the whole chain
* of mip levels.
* @sheet_bytes: Bytes required in the backing store for a sheet
* representing a single sample.
* @num_mip_levels: Valid size of the @mip array. Number of mipmap levels in
* a chain.
* @num_layers: Number of slices in an array texture or number of faces in
* a cubemap texture.
*/
struct vmw_surface_cache {
const SVGA3dSurfaceDesc *desc;
struct vmw_surface_mip mip[DRM_VMW_MAX_MIP_LEVELS];
size_t mip_chain_bytes;
size_t sheet_bytes;
u32 num_mip_levels;
u32 num_layers;
};
/**
* struct vmw_surface_loc - Surface location
* @sheet: The multisample sheet.
* @sub_resource: Surface subresource. Defined as layer * num_mip_levels +
* mip_level.
* @x: X coordinate.
* @y: Y coordinate.
* @z: Z coordinate.
*/
struct vmw_surface_loc {
u32 sheet;
u32 sub_resource;
u32 x, y, z;
};
/**
* vmw_surface_subres - Compute the subresource from layer and mipmap.
* @cache: Surface layout data.
* @mip_level: The mipmap level.
* @layer: The surface layer (face or array slice).
*
* Return: The subresource.
*/
static inline u32 vmw_surface_subres(const struct vmw_surface_cache *cache,
u32 mip_level, u32 layer)
{
return cache->num_mip_levels * layer + mip_level;
}
/**
* vmw_surface_setup_cache - Build a surface cache entry
* @size: The surface base level dimensions.
* @format: The surface format.
* @num_mip_levels: Number of mipmap levels.
* @num_layers: Number of layers.
* @cache: Pointer to a struct vmw_surface_cach object to be filled in.
*
* Return: Zero on success, -EINVAL on invalid surface layout.
*/
static inline int vmw_surface_setup_cache(const struct drm_vmw_size *size,
SVGA3dSurfaceFormat format,
u32 num_mip_levels,
u32 num_layers,
u32 num_samples,
struct vmw_surface_cache *cache)
{
const SVGA3dSurfaceDesc *desc;
u32 i;
memset(cache, 0, sizeof(*cache));
cache->desc = desc = vmw_surface_get_desc(format);
cache->num_mip_levels = num_mip_levels;
cache->num_layers = num_layers;
for (i = 0; i < cache->num_mip_levels; i++) {
struct vmw_surface_mip *mip = &cache->mip[i];
mip->size = vmw_surface_get_mip_size(*size, i);
mip->bytes = vmw_surface_get_image_buffer_size
(desc, &mip->size, 0);
mip->row_stride =
Annotation
- Immediate include surface: `device_include/svga3d_surfacedefs.h`, `drm/vmwgfx_drm.h`.
- Detected declarations: `struct vmw_surface_mip`, `struct vmw_surface_cache`, `struct vmw_surface_loc`, `function Copyright`, `function vmw_surface_get_desc`, `function vmw_surface_get_mip_size`, `function vmw_surface_get_size_in_blocks`, `function vmw_surface_is_planar_surface`, `function vmw_surface_calculate_pitch`, `function vmw_surface_get_image_buffer_size`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.