1a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard/*
2a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * Copyright 2010 Marek Olšák <maraeo@gmail.com
3a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard *
4a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * Permission is hereby granted, free of charge, to any person obtaining a
5a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * copy of this software and associated documentation files (the "Software"),
6a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * to deal in the Software without restriction, including without limitation
7a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * on the rights to use, copy, modify, merge, publish, distribute, sub
8a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * license, and/or sell copies of the Software, and to permit persons to whom
9a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * the Software is furnished to do so, subject to the following conditions:
10a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard *
11a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * The above copyright notice and this permission notice (including the next
12a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * paragraph) shall be included in all copies or substantial portions of the
13a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * Software.
14a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard *
15a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard * USE OR OTHER DEALINGS IN THE SOFTWARE.
22a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard */
23a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard#ifndef R600_RESOURCE_H
24a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard#define R600_RESOURCE_H
25a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
26a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard#include "util/u_transfer.h"
27a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
28a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard/* flag to indicate a resource is to be used as a transfer so should not be tiled */
29a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard#define R600_RESOURCE_FLAG_TRANSFER     PIPE_RESOURCE_FLAG_DRV_PRIV
30a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
31a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard/* Texture transfer. */
32a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardstruct r600_transfer {
33a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	/* Base class. */
34a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	struct pipe_transfer		transfer;
35a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	/* Buffer transfer. */
36a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	struct pipe_transfer		*buffer_transfer;
37a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	unsigned			offset;
38a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	struct pipe_resource		*staging_texture;
39a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard};
40a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
41a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardstruct r600_resource_texture {
42fe41287ffa8cb35421cadfb16d4cc27c5fcb8b76Christian König	struct si_resource		resource;
43a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
44a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	/* If this resource is a depth-stencil buffer on evergreen, this contains
45a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	 * the depth part of the format. There is a separate stencil resource
46a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	 * for the stencil buffer below. */
47a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	enum pipe_format		real_format;
48a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
49a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	unsigned			pitch_override;
50a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	unsigned			depth;
51a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	unsigned			dirty_db;
52a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	struct r600_resource_texture	*flushed_depth_texture;
53a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	boolean				is_flushing_texture;
5488a2e2388bfeee66cb6d873558431b0e0af7e316Michel Dänzer	struct radeon_surface		surface;
55a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard};
56a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
57a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardstruct r600_surface {
58a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard	struct pipe_surface		base;
59a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard};
60a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
61a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardvoid r600_init_screen_resource_functions(struct pipe_screen *screen);
62a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
63a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard/* r600_texture */
641b11395a36a44a902cfb3e1783758544662df73fMichel Dänzerstruct pipe_resource *si_texture_create(struct pipe_screen *screen,
65a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard					const struct pipe_resource *templ);
661b11395a36a44a902cfb3e1783758544662df73fMichel Dänzerstruct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
671b11395a36a44a902cfb3e1783758544662df73fMichel Dänzer					     const struct pipe_resource *base,
681b11395a36a44a902cfb3e1783758544662df73fMichel Dänzer					     struct winsys_handle *whandle);
69a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
70a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardint r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture, boolean just_create);
71a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
72a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
73a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellardstruct r600_context;
74a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
75fe41287ffa8cb35421cadfb16d4cc27c5fcb8b76Christian Königvoid r600_upload_const_buffer(struct r600_context *rctx, struct si_resource **rbuffer,
7665d451d9fa1192c386301ca0b84b6c5cd369f92dMarek Olšák			      const uint8_t *ptr, unsigned size,
7765d451d9fa1192c386301ca0b84b6c5cd369f92dMarek Olšák			      uint32_t *const_offset);
78a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard
79a75c6163e605f35b14f26930dd9227e4f337ec9eTom Stellard#endif
80