Lines Matching +full:offset +full:- +full:y

1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
4 * Copyright (c) 2021-2024 Broadcom. All Rights Reserved. The term
43 return (tmp > (uint64_t) ((u32) -1)) ? (u32) -1 : tmp; in clamped_umul32()
47 * vmw_surface_get_desc - Look up the appropriate SVGA3dSurfaceDesc for the
60 * vmw_surface_get_mip_size - Given a base level size and the mip level,
80 block_size->width = __KERNEL_DIV_ROUND_UP(pixel_size->width, in vmw_surface_get_size_in_blocks()
81 desc->blockSize.width); in vmw_surface_get_size_in_blocks()
82 block_size->height = __KERNEL_DIV_ROUND_UP(pixel_size->height, in vmw_surface_get_size_in_blocks()
83 desc->blockSize.height); in vmw_surface_get_size_in_blocks()
84 block_size->depth = __KERNEL_DIV_ROUND_UP(pixel_size->depth, in vmw_surface_get_size_in_blocks()
85 desc->blockSize.depth); in vmw_surface_get_size_in_blocks()
91 return (desc->blockDesc & SVGA3DBLOCKDESC_PLANAR_YUV) != 0; in vmw_surface_is_planar_surface()
103 pitch = blocks.width * desc->pitchBytesPerBlock; in vmw_surface_calculate_pitch()
109 * vmw_surface_get_image_buffer_size - Calculates image buffer size.
116 * This function is overflow-safe. If the result would have overflowed, instead
133 total_size = clamped_umul32(total_size, desc->bytesPerBlock); in vmw_surface_get_image_buffer_size()
147 * vmw_surface_get_serialized_size - Get the serialized size for the image.
170 * vmw_surface_get_serialized_size_extended - Returns the number of bytes
191 * vmw_surface_get_pixel_offset - Compute the offset (in bytes) to a pixel
200 u32 x, u32 y, u32 z) in vmw_surface_get_pixel_offset() argument
203 const u32 bw = desc->blockSize.width, bh = desc->blockSize.height; in vmw_surface_get_pixel_offset()
204 const u32 bd = desc->blockSize.depth; in vmw_surface_get_pixel_offset()
206 desc->bytesPerBlock; in vmw_surface_get_pixel_offset()
208 const u32 offset = (z / bd * imgstride + in vmw_surface_get_pixel_offset() local
209 y / bh * rowstride + in vmw_surface_get_pixel_offset()
210 x / bw * desc->bytesPerBlock); in vmw_surface_get_pixel_offset()
211 return offset; in vmw_surface_get_pixel_offset()
222 u32 offset; in vmw_surface_get_image_offset() local
242 offset = mipChainBytes * face + mipChainBytesToLevel; in vmw_surface_get_image_offset()
244 return offset; in vmw_surface_get_image_offset()
249 * vmw_surface_is_gb_screen_target_format - Is the specified format usable as
251 * (with just the GBObjects cap-bit
271 * vmw_surface_is_dx_screen_target_format - Is the specified format usable as
290 * vmw_surface_is_screen_target_format - Is the specified format usable as a
309 * struct vmw_surface_mip - Mimpmap level information
324 * struct vmw_surface_cache - Cached surface information
346 * struct vmw_surface_loc - Surface location
351 * @y: Y coordinate.
357 u32 x, y, z; member
361 * vmw_surface_subres - Compute the subresource from layer and mipmap.
371 return cache->num_mip_levels * layer + mip_level; in vmw_surface_subres()
375 * vmw_surface_setup_cache - Build a surface cache entry
382 * Return: Zero on success, -EINVAL on invalid surface layout.
395 cache->desc = desc = vmw_surface_get_desc(format); in vmw_surface_setup_cache()
396 cache->num_mip_levels = num_mip_levels; in vmw_surface_setup_cache()
397 cache->num_layers = num_layers; in vmw_surface_setup_cache()
398 for (i = 0; i < cache->num_mip_levels; i++) { in vmw_surface_setup_cache()
399 struct vmw_surface_mip *mip = &cache->mip[i]; in vmw_surface_setup_cache()
401 mip->size = vmw_surface_get_mip_size(*size, i); in vmw_surface_setup_cache()
402 mip->bytes = vmw_surface_get_image_buffer_size in vmw_surface_setup_cache()
403 (desc, &mip->size, 0); in vmw_surface_setup_cache()
404 mip->row_stride = in vmw_surface_setup_cache()
405 __KERNEL_DIV_ROUND_UP(mip->size.width, in vmw_surface_setup_cache()
406 desc->blockSize.width) * in vmw_surface_setup_cache()
407 desc->bytesPerBlock * num_samples; in vmw_surface_setup_cache()
408 if (!mip->row_stride) in vmw_surface_setup_cache()
411 mip->img_stride = in vmw_surface_setup_cache()
412 __KERNEL_DIV_ROUND_UP(mip->size.height, in vmw_surface_setup_cache()
413 desc->blockSize.height) * in vmw_surface_setup_cache()
414 mip->row_stride; in vmw_surface_setup_cache()
415 if (!mip->img_stride) in vmw_surface_setup_cache()
418 cache->mip_chain_bytes += mip->bytes; in vmw_surface_setup_cache()
420 cache->sheet_bytes = cache->mip_chain_bytes * num_layers; in vmw_surface_setup_cache()
421 if (!cache->sheet_bytes) in vmw_surface_setup_cache()
428 return -EINVAL; in vmw_surface_setup_cache()
432 * vmw_surface_get_loc - Get a surface location from an offset into the
436 * @offset: Offset into the surface backing store.
441 size_t offset) in vmw_surface_get_loc() argument
443 const struct vmw_surface_mip *mip = &cache->mip[0]; in vmw_surface_get_loc()
444 const SVGA3dSurfaceDesc *desc = cache->desc; in vmw_surface_get_loc()
448 loc->sheet = offset / cache->sheet_bytes; in vmw_surface_get_loc()
449 offset -= loc->sheet * cache->sheet_bytes; in vmw_surface_get_loc()
451 layer = offset / cache->mip_chain_bytes; in vmw_surface_get_loc()
452 offset -= layer * cache->mip_chain_bytes; in vmw_surface_get_loc()
453 for (i = 0; i < cache->num_mip_levels; ++i, ++mip) { in vmw_surface_get_loc()
454 if (mip->bytes > offset) in vmw_surface_get_loc()
456 offset -= mip->bytes; in vmw_surface_get_loc()
459 loc->sub_resource = vmw_surface_subres(cache, i, layer); in vmw_surface_get_loc()
460 loc->z = offset / mip->img_stride; in vmw_surface_get_loc()
461 offset -= loc->z * mip->img_stride; in vmw_surface_get_loc()
462 loc->z *= desc->blockSize.depth; in vmw_surface_get_loc()
463 loc->y = offset / mip->row_stride; in vmw_surface_get_loc()
464 offset -= loc->y * mip->row_stride; in vmw_surface_get_loc()
465 loc->y *= desc->blockSize.height; in vmw_surface_get_loc()
466 loc->x = offset / desc->bytesPerBlock; in vmw_surface_get_loc()
467 loc->x *= desc->blockSize.width; in vmw_surface_get_loc()
471 * vmw_surface_inc_loc - Clamp increment a surface location with one block
476 * When computing the size of a range as size = end - start, the range does not
486 const SVGA3dSurfaceDesc *desc = cache->desc; in vmw_surface_inc_loc()
487 u32 mip = loc->sub_resource % cache->num_mip_levels; in vmw_surface_inc_loc()
488 const struct drm_vmw_size *size = &cache->mip[mip].size; in vmw_surface_inc_loc()
490 loc->sub_resource++; in vmw_surface_inc_loc()
491 loc->x += desc->blockSize.width; in vmw_surface_inc_loc()
492 if (loc->x > size->width) in vmw_surface_inc_loc()
493 loc->x = size->width; in vmw_surface_inc_loc()
494 loc->y += desc->blockSize.height; in vmw_surface_inc_loc()
495 if (loc->y > size->height) in vmw_surface_inc_loc()
496 loc->y = size->height; in vmw_surface_inc_loc()
497 loc->z += desc->blockSize.depth; in vmw_surface_inc_loc()
498 if (loc->z > size->depth) in vmw_surface_inc_loc()
499 loc->z = size->depth; in vmw_surface_inc_loc()
503 * vmw_surface_min_loc - The start location in a subresource
513 loc->sheet = 0; in vmw_surface_min_loc()
514 loc->sub_resource = sub_resource; in vmw_surface_min_loc()
515 loc->x = loc->y = loc->z = 0; in vmw_surface_min_loc()
519 * vmw_surface_min_loc - The end location in a subresource
535 loc->sheet = 0; in vmw_surface_max_loc()
536 loc->sub_resource = sub_resource + 1; in vmw_surface_max_loc()
537 mip = sub_resource % cache->num_mip_levels; in vmw_surface_max_loc()
538 size = &cache->mip[mip].size; in vmw_surface_max_loc()
539 loc->x = size->width; in vmw_surface_max_loc()
540 loc->y = size->height; in vmw_surface_max_loc()
541 loc->z = size->depth; in vmw_surface_max_loc()