freedreno_resource.h revision 848b8605
1/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ 2 3/* 4 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 * 25 * Authors: 26 * Rob Clark <robclark@freedesktop.org> 27 */ 28 29#ifndef FREEDRENO_RESOURCE_H_ 30#define FREEDRENO_RESOURCE_H_ 31 32#include "util/u_transfer.h" 33 34#include "freedreno_util.h" 35 36/* for mipmap, cubemap, etc, each level is represented by a slice. 37 * Currently all slices are part of same bo (just different offsets), 38 * this is at least how it needs to be for cubemaps, although mipmap 39 * can be different bo's (although, not sure if there is a strong 40 * advantage to doing that) 41 */ 42struct fd_resource_slice { 43 uint32_t offset; /* offset of first layer in slice */ 44 uint32_t pitch; 45 uint32_t size0; /* size of first layer in slice */ 46}; 47 48struct fd_resource { 49 struct u_resource base; 50 struct fd_bo *bo; 51 uint32_t cpp; 52 struct fd_resource_slice slices[MAX_MIP_LEVELS]; 53 uint32_t timestamp; 54 bool dirty; 55}; 56 57static INLINE struct fd_resource * 58fd_resource(struct pipe_resource *ptex) 59{ 60 return (struct fd_resource *)ptex; 61} 62 63static INLINE struct fd_resource_slice * 64fd_resource_slice(struct fd_resource *rsc, unsigned level) 65{ 66 assert(level <= rsc->base.b.last_level); 67 return &rsc->slices[level]; 68} 69 70void fd_resource_screen_init(struct pipe_screen *pscreen); 71void fd_resource_context_init(struct pipe_context *pctx); 72 73#endif /* FREEDRENO_RESOURCE_H_ */ 74