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