static int vc4_rcl_msaa_surface_setup(struct vc4_exec_info *exec, struct drm_gem_cma_object **obj, struct drm_vc4_submit_rcl_surface *surf) { if (surf->flags != 0 || surf->bits != 0) { DRM_ERROR("MSAA surface had nonzero flags/bits\n"); return -EINVAL; } if (surf->hindex == ~0) return 0; *obj = vc4_use_bo(exec, surf->hindex); if (!*obj) return -EINVAL; exec->rcl_write_bo[exec->rcl_write_bo_count++] = *obj; if (surf->offset & 0xf) { DRM_ERROR("MSAA write must be 16b aligned.\n"); return -EINVAL; } return vc4_full_res_bounds_check(exec, *obj, surf); }
static int vc4_rcl_surface_setup(struct vc4_exec_info *exec, struct drm_gem_cma_object **obj, struct drm_vc4_submit_rcl_surface *surf) { uint8_t tiling = VC4_GET_FIELD(surf->bits, VC4_LOADSTORE_TILE_BUFFER_TILING); uint8_t buffer = VC4_GET_FIELD(surf->bits, VC4_LOADSTORE_TILE_BUFFER_BUFFER); uint8_t format = VC4_GET_FIELD(surf->bits, VC4_LOADSTORE_TILE_BUFFER_FORMAT); int cpp; int ret; if (surf->flags & ~VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES) { DRM_ERROR("Extra flags set\n"); return -EINVAL; } if (surf->hindex == ~0) return 0; *obj = vc4_use_bo(exec, surf->hindex); if (!*obj) return -EINVAL; if (surf->flags & VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES) { if (surf == &exec->args->zs_write) { DRM_ERROR("general zs write may not be a full-res.\n"); return -EINVAL; } if (surf->bits != 0) { DRM_ERROR("load/store general bits set with " "full res load/store.\n"); return -EINVAL; } ret = vc4_full_res_bounds_check(exec, *obj, surf); if (!ret) return ret; return 0; } if (surf->bits & ~(VC4_LOADSTORE_TILE_BUFFER_TILING_MASK | VC4_LOADSTORE_TILE_BUFFER_BUFFER_MASK | VC4_LOADSTORE_TILE_BUFFER_FORMAT_MASK)) { DRM_ERROR("Unknown bits in load/store: 0x%04x\n", surf->bits); return -EINVAL; } if (tiling > VC4_TILING_FORMAT_LT) { DRM_ERROR("Bad tiling format\n"); return -EINVAL; } if (buffer == VC4_LOADSTORE_TILE_BUFFER_ZS) { if (format != 0) { DRM_ERROR("No color format should be set for ZS\n"); return -EINVAL; } cpp = 4; } else if (buffer == VC4_LOADSTORE_TILE_BUFFER_COLOR) { switch (format) { case VC4_LOADSTORE_TILE_BUFFER_BGR565: case VC4_LOADSTORE_TILE_BUFFER_BGR565_DITHER: cpp = 2; break; case VC4_LOADSTORE_TILE_BUFFER_RGBA8888: cpp = 4; break; default: DRM_ERROR("Bad tile buffer format\n"); return -EINVAL; } } else { DRM_ERROR("Bad load/store buffer %d.\n", buffer); return -EINVAL; } if (surf->offset & 0xf) { DRM_ERROR("load/store buffer must be 16b aligned.\n"); return -EINVAL; } if (!vc4_check_tex_size(exec, *obj, surf->offset, tiling, exec->args->width, exec->args->height, cpp)) { return -EINVAL; } return 0; }