1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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 * Authors:
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *      Jerome Glisse
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef R600_PIPE_H
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_PIPE_H
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_blitter.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_slab.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "r600.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "r600_llvm.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "r600_public.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "r600_shader.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "r600_resource.h"
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "evergreen_compute.h"
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_MAX_CONST_BUFFERS 2
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_MAX_CONST_BUFFER_SIZE 4096
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef PIPE_ARCH_BIG_ENDIAN
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_BIG_ENDIAN 1
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#else
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_BIG_ENDIAN 0
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum r600_atom_flags {
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* When set, atoms are added at the beginning of the dirty list
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * instead of the end. */
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	EMIT_EARLY = (1 << 0)
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* This encapsulates a state or an operation which can emitted into the GPU
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * command stream. It's not limited to states only, it can be used for anything
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * that wants to write commands into the CS (e.g. cache flushes). */
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_atom {
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void (*emit)(struct r600_context *ctx, struct r600_atom *state);
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		num_dw;
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	enum r600_atom_flags	flags;
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool			dirty;
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head	head;
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* This is an atom containing GPU commands that never change.
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is supposed to be copied directly into the CS. */
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_command_buffer {
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t *buf;
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned max_num_dw;
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned pkt_flags;
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_surface_sync_cmd {
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned flush_flags; /* CP_COHER_CNTL */
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_db_misc_state {
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool occlusion_query_enabled;
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool flush_depthstencil_through_cb;
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool copy_depth, copy_stencil;
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned copy_sample;
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned log_samples;
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_cb_misc_state {
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned cb_color_control; /* this comes from blend state */
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned blend_colormask; /* 8*4 bits for 8 RGBA colorbuffers */
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned nr_cbufs;
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned nr_ps_color_outputs;
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool multiwrite;
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool dual_src_blend;
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_alphatest_state {
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned sx_alpha_test_control; /* this comes from dsa state */
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned sx_alpha_ref; /* this comes from dsa state */
103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool bypass;
104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool cb0_export_16bpc; /* from set_framebuffer_state */
105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_cs_shader_state {
108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_compute *shader;
110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_sample_mask {
113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom atom;
114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint16_t sample_mask; /* there are only 8 bits on EG, 16 bits on Cayman */
115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum r600_pipe_state_id {
118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_BLEND = 0,
119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_BLEND_COLOR,
120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_CONFIG,
121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_SEAMLESS_CUBEMAP,
122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_CLIP,
123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_SCISSOR,
124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_VIEWPORT,
125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_RASTERIZER,
126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_VGT,
127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_FRAMEBUFFER,
128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_DSA,
129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_STENCIL_REF,
130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_PS_SHADER,
131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_VS_SHADER,
132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_CONSTANT,
133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_SAMPLER,
134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_RESOURCE,
135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_POLYGON_OFFSET,
136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_FETCH_SHADER,
137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_STATE_SPI,
138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	R600_PIPE_NSTATES
139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct compute_memory_pool;
142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid compute_memory_pool_delete(struct compute_memory_pool* pool);
143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct compute_memory_pool* compute_memory_pool_new(
144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_screen *rscreen);
145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_fences {
147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*bo;
148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			*data;
149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			next_index;
150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* linked list of preallocated blocks */
151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head		blocks;
152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* linked list of freed fences */
153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head		pool;
154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	pipe_mutex			mutex;
155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_screen {
158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_screen		screen;
159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct radeon_winsys		*ws;
160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			family;
161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	enum chip_class			chip_class;
162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct radeon_info		info;
163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				has_streamout;
164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_tiling_info		tiling_info;
165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_fences		fences;
166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/*for compute global memory binding, we allocate stuff here, instead of
168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * buffers.
169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * XXX: Not sure if this is the best place for global_pool.  Also,
170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * it's not thread safe, so it won't work with multiple contexts. */
171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct compute_memory_pool *global_pool;
172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_sampler_view {
175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_sampler_view	base;
176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*tex_resource;
177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			tex_resource_words[8];
178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_rasterizer {
181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		rstate;
182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				flatshade;
183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				two_side;
184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			sprite_coord_enable;
185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned                        clip_plane_enable;
186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			pa_sc_line_stipple;
187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			pa_cl_clip_cntl;
188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	float				offset_units;
189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	float				offset_scale;
190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				scissor_enable;
191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				multisample_enable;
192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_blend {
195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		rstate;
196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			cb_target_mask;
197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			cb_color_control;
198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				dual_src_blend;
199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				alpha_to_one;
200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_dsa {
203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		rstate;
204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			alpha_ref;
205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ubyte				valuemask[2];
206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ubyte				writemask[2];
207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned                        sx_alpha_test_control;
208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_vertex_element
211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			count;
213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_vertex_element	elements[PIPE_MAX_ATTRIBS];
214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*fetch_shader;
215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			fs_size;
216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		rstate;
217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_shader;
220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_shader_selector {
222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_shader *current;
223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct tgsi_token       *tokens;
225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_stream_output_info  so;
226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	num_shaders;
228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* PIPE_SHADER_[VERTEX|FRAGMENT|...] */
230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	type;
231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	nr_ps_max_color_exports;
233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_shader {
236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_shader_selector *selector;
237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_shader	*next_variant;
238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_shader		shader;
239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		rstate;
240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*bo;
241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*bo_fetch;
242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_vertex_element	vertex_elements;
243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	sprite_coord_enable;
244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	flatshade;
245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	pa_cl_vs_out_cntl;
246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	nr_ps_color_outputs;
247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	key;
248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		db_shader_control;
249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		ps_depth_export;
250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_pipe_sampler_state {
253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			tex_sampler_words[3];
254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			border_color[4];
255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				border_color_use;
256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				seamless_cube_map;
257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* needed for blitter save */
260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define NUM_TEX_UNITS 16
261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_seamless_cube_map {
263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		atom;
264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				enabled;
265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_samplerview_state {
268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		atom;
269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_sampler_view	*views[NUM_TEX_UNITS];
270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			enabled_mask;
271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			dirty_mask;
272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			compressed_depthtex_mask; /* which textures are depth */
273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			compressed_colortex_mask;
274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_textures_info {
277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_samplerview_state	views;
278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		atom_sampler;
279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_sampler_state	*samplers[NUM_TEX_UNITS];
280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			n_samplers;
281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				is_array_sampler[NUM_TEX_UNITS];
282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_fence {
285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_reference		reference;
286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			index; /* in the shared bo */
287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource		*sleep_bo;
288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head		head;
289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define FENCE_BLOCK_SIZE 16
292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_fence_block {
294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_fence		fences[FENCE_BLOCK_SIZE];
295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head		head;
296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_CONSTANT_ARRAY_SIZE 256
299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_RESOURCE_ARRAY_SIZE 160
300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_stencil_ref
302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ubyte ref_value[2];
304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ubyte valuemask[2];
305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ubyte writemask[2];
306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_constbuf_state
309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		atom;
311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_constant_buffer	cb[PIPE_MAX_CONSTANT_BUFFERS];
312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			enabled_mask;
313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			dirty_mask;
314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_vertexbuf_state
317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		atom;
319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_vertex_buffer	vb[PIPE_MAX_ATTRIBS];
320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			enabled_mask; /* non-NULL buffers */
321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint32_t			dirty_mask;
322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct r600_context {
325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_context		context;
326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct blitter_context		*blitter;
327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	enum radeon_family		family;
328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	enum chip_class			chip_class;
329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				has_vertex_cache;
330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			r6xx_num_clause_temp_gprs;
331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void				*custom_dsa_flush;
332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void				*custom_blend_resolve;
333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void				*custom_blend_decompress;
334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_screen		*screen;
336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct radeon_winsys		*ws;
337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state		*states[R600_PIPE_NSTATES];
338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_vertex_element	*vertex_elements;
339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_framebuffer_state	framebuffer;
340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			compressed_cb_mask;
341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			compute_cb_target_mask;
342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			db_shader_control;
343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			pa_sc_line_stipple;
344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			pa_cl_clip_cntl;
345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* for saving when using blitter */
346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_stencil_ref		stencil_ref;
347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_viewport_state	viewport;
348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_clip_state		clip;
349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_shader_selector 	*ps_shader;
350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_shader_selector 	*vs_shader;
351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_rasterizer	*rasterizer;
352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state          vgt;
353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_state          spi;
354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_query		*current_render_cond;
355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			current_render_cond_mode;
356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_query		*saved_render_cond;
357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			saved_render_cond_mode;
358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* shader information */
359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				two_side;
360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				spi_dirty;
361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			sprite_coord_enable;
362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				flatshade;
363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean				export_16bpc;
364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned			nr_cbufs;
365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				alpha_to_one;
366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				multisample_enable;
367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool				cb0_is_integer;
368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct u_upload_mgr	        *uploader;
370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct util_slab_mempool	pool_transfers;
371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned default_ps_gprs, default_vs_gprs;
373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* current unaccounted memory usage */
375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint64_t			vram;
376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	uint64_t			gtt;
377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* States based on r600_atom. */
379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head		dirty_states;
380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_command_buffer	start_cs_cmd; /* invariant state mostly */
381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/** Compute specific registers initializations.  The start_cs_cmd atom
382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 *  must be emitted before start_compute_cs_cmd. */
383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org        struct r600_command_buffer      start_compute_cs_cmd;
384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_surface_sync_cmd	surface_sync_cmd;
385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_atom		r6xx_flush_and_inv_cmd;
386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_alphatest_state	alphatest_state;
387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_cb_misc_state	cb_misc_state;
388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_db_misc_state	db_misc_state;
389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/** Vertex buffers for fetch shaders */
390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_vertexbuf_state	vertex_buffer_state;
391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/** Vertex buffers for compute shaders */
392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_vertexbuf_state	cs_vertex_buffer_state;
393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_constbuf_state	vs_constbuf_state;
394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_constbuf_state	ps_constbuf_state;
395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_textures_info	vs_samplers;
396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_textures_info	ps_samplers;
397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_seamless_cube_map	seamless_cube_map;
398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_cs_shader_state	cs_shader_state;
399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_sample_mask		sample_mask;
400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* current external blend state (from state tracker) */
402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_blend		*blend;
403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* state with disabled blending - used internally with blend_override */
404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_pipe_blend		*no_blend;
405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* 1 - override current blend state with no_blend, 0 - use external state */
407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned	blend_override;
408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct radeon_winsys_cs	*cs;
410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_range	*range;
412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		nblocks;
413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_block	**blocks;
414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head	dirty;
415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head	enable_list;
416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		pm4_dirty_cdwords;
417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		ctx_pm4_ndwords;
418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* The list of active queries. Only one query of each type can be active. */
420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int			num_occlusion_queries;
421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* Manage queries in two separate groups:
423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * The timer ones and the others (streamout, occlusion).
424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 *
425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * We do this because we should only suspend non-timer queries for u_blitter,
426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * and later if the non-timer queries are suspended, the context flush should
427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * only suspend and resume the timer queries. */
428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head	active_timer_queries;
429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		num_cs_dw_timer_queries_suspend;
430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct list_head	active_nontimer_queries;
431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		num_cs_dw_nontimer_queries_suspend;
432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		num_cs_dw_streamout_end;
434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		backend_mask;
436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned                max_db; /* for OQ */
437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		flags;
438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean                 predicate_drawing;
439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		num_so_targets;
441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_so_target	*so_targets[PIPE_MAX_SO_BUFFERS];
442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean			streamout_start;
443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	unsigned		streamout_append_bitmask;
444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* There is no scissor enable bit on r6xx, so we must use a workaround.
446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * These track the current scissor state. */
447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	bool			scissor_enable;
448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_scissor_state scissor_state;
449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* With rasterizer discard, there doesn't have to be a pixel shader.
451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * In that case, we bind this one: */
452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void			*dummy_pixel_shader;
453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	boolean			dual_src_blend;
455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* Index buffer. */
457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct pipe_index_buffer index_buffer;
458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* Dummy CMASK and FMASK buffers used to get around the R6xx hardware
460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * bug where valid CMASK and FMASK are required to be present to avoid
461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * a hardlock in certain operations but aren't actually used
462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * for anything useful. */
463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource *dummy_fmask;
464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource *dummy_cmask;
465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom *atom)
468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	atom->emit(rctx, atom);
470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	atom->dirty = false;
471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (atom->head.next && atom->head.prev)
472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		LIST_DELINIT(&atom->head);
473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_atom_dirty(struct r600_context *rctx, struct r600_atom *state)
476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (!state->dirty) {
478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		if (state->flags & EMIT_EARLY) {
479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			LIST_ADD(&state->head, &rctx->dirty_states);
480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		} else {
481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			LIST_ADDTAIL(&state->head, &rctx->dirty_states);
482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		}
483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		state->dirty = true;
484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* evergreen_state.c */
488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_init_common_regs(struct r600_command_buffer *cb,
489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				enum chip_class ctx_chip_class,
490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				enum radeon_family ctx_family,
491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				int ctx_drm_minor);
492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_init_state_functions(struct r600_context *rctx);
494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_init_atom_start_cs(struct r600_context *rctx);
495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader);
496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_fetch_shader(struct pipe_context *ctx, struct r600_vertex_element *ve);
498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *evergreen_create_db_flush_dsa(struct r600_context *rctx);
499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *evergreen_create_resolve_blend(struct r600_context *rctx);
500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *evergreen_create_decompress_blend(struct r600_context *rctx);
501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_polygon_offset_update(struct r600_context *rctx);
502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean evergreen_is_format_supported(struct pipe_screen *screen,
503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				      enum pipe_format format,
504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				      enum pipe_texture_target target,
505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				      unsigned sample_count,
506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				      unsigned usage);
507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_init_color_surface(struct r600_context *rctx,
508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				  struct r600_surface *surf);
509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid evergreen_update_dual_export_state(struct r600_context * rctx);
510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_blit.c */
512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_copy_buffer(struct pipe_context *ctx, struct
513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      pipe_resource *dst, unsigned dstx,
514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      struct pipe_resource *src, const struct pipe_box *src_box);
515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_blit_functions(struct r600_context *rctx);
516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_blit_decompress_depth(struct pipe_context *ctx,
517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		struct r600_texture *texture,
518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		struct r600_texture *staging,
519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		unsigned first_level, unsigned last_level,
520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		unsigned first_layer, unsigned last_layer,
521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		unsigned first_sample, unsigned last_sample);
522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_decompress_depth_textures(struct r600_context *rctx,
523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				    struct r600_samplerview_state *textures);
524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_decompress_color_textures(struct r600_context *rctx,
525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				    struct r600_samplerview_state *textures);
526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_buffer.c */
528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgbool r600_init_resource(struct r600_screen *rscreen,
529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			struct r600_resource *res,
530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			unsigned size, unsigned alignment,
531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			unsigned bind, unsigned usage);
532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org					 const struct pipe_resource *templ,
534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org					 unsigned alignment);
535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_pipe.c */
537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		unsigned flags);
539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_query.c */
541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_query_functions(struct r600_context *rctx);
542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_suspend_nontimer_queries(struct r600_context *ctx);
543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_resume_nontimer_queries(struct r600_context *ctx);
544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_suspend_timer_queries(struct r600_context *ctx);
545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_resume_timer_queries(struct r600_context *ctx);
546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_resource.c */
548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_context_resource_functions(struct r600_context *r600);
549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_shader.c */
551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *shader);
552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef HAVE_OPENCL
553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint r600_compute_shader_create(struct pipe_context * ctx,
554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	LLVMModuleRef mod,  struct r600_bytecode * bytecode);
555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader);
557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_state.c */
559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_scissor_state(struct r600_context *rctx,
560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    const struct pipe_scissor_state *state);
561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_state_functions(struct r600_context *rctx);
562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_atom_start_cs(struct r600_context *rctx);
563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader);
564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_fetch_shader(struct pipe_context *ctx, struct r600_vertex_element *ve);
566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_db_flush_dsa(struct r600_context *rctx);
567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_resolve_blend(struct r600_context *rctx);
568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r700_create_resolve_blend(struct r600_context *rctx);
569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_decompress_blend(struct r600_context *rctx);
570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_polygon_offset_update(struct r600_context *rctx);
571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_adjust_gprs(struct r600_context *rctx);
572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean r600_is_format_supported(struct pipe_screen *screen,
573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 enum pipe_format format,
574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 enum pipe_texture_target target,
575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 unsigned sample_count,
576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 unsigned usage);
577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_update_dual_export_state(struct r600_context * rctx);
578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_texture.c */
580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_screen_texture_functions(struct pipe_screen *screen);
581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_surface_functions(struct r600_context *r600);
582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orguint32_t r600_translate_texformat(struct pipe_screen *screen, enum pipe_format format,
583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				  const unsigned char *swizzle_view,
584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				  uint32_t *word4_p, uint32_t *yuv_format_p);
585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_texture_get_offset(struct r600_texture *rtex,
586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org					unsigned level, unsigned layer);
587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_translate.c */
589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_translate_index_buffer(struct r600_context *r600,
590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 struct pipe_index_buffer *ib,
591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				 unsigned count);
592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* r600_state_common.c */
594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_atom(struct r600_atom *atom,
595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		    void (*emit)(struct r600_context *ctx, struct r600_atom *state),
596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		    unsigned num_dw, enum r600_atom_flags flags);
597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_common_atoms(struct r600_context *rctx);
598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_get_cb_flush_flags(struct r600_context *rctx);
599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_texture_barrier(struct pipe_context *ctx);
600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_index_buffer(struct pipe_context *ctx,
601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			   const struct pipe_index_buffer *ib);
602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_vertex_buffers_dirty(struct r600_context *rctx);
603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     const struct pipe_vertex_buffer *input);
605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_sampler_views_dirty(struct r600_context *rctx,
606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			      struct r600_samplerview_state *state);
607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_sampler_views(struct pipe_context *pipe,
608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            unsigned shader,
609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            unsigned start,
610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    unsigned count,
611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    struct pipe_sampler_view **views);
612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_vs_samplers(struct pipe_context *ctx, unsigned count, void **states);
613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_ps_samplers(struct pipe_context *ctx, unsigned count, void **states);
614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_vertex_elements(struct pipe_context *ctx,
615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				  unsigned count,
616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				  const struct pipe_vertex_element *elements);
617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_vertex_element(struct pipe_context *ctx, void *state);
618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_blend_state(struct pipe_context *ctx, void *state);
619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_blend_color(struct pipe_context *ctx,
620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			  const struct pipe_blend_color *state);
621f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_dsa_state(struct pipe_context *ctx, void *state);
622f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_max_scissor(struct r600_context *rctx);
623f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_rs_state(struct pipe_context *ctx, void *state);
624f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_rs_state(struct pipe_context *ctx, void *state);
625f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_sampler_view_destroy(struct pipe_context *ctx,
626f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			       struct pipe_sampler_view *state);
627f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_sampler(struct pipe_context *ctx, void *state);
628f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_state(struct pipe_context *ctx, void *state);
629f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_vertex_elements(struct pipe_context *ctx, void *state);
630f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_shader_state_ps(struct pipe_context *ctx,
631f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                   const struct pipe_shader_state *state);
632f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid *r600_create_shader_state_vs(struct pipe_context *ctx,
633f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                   const struct pipe_shader_state *state);
634f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_ps_shader(struct pipe_context *ctx, void *state);
635f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_bind_vs_shader(struct pipe_context *ctx, void *state);
636f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_ps_shader(struct pipe_context *ctx, void *state);
637f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_delete_vs_shader(struct pipe_context *ctx, void *state);
638f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf_state *state);
639f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
640f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			      struct pipe_constant_buffer *cb);
641f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_stream_output_target *
642f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgr600_create_so_target(struct pipe_context *ctx,
643f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      struct pipe_resource *buffer,
644f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      unsigned buffer_offset,
645f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      unsigned buffer_size);
646f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_so_target_destroy(struct pipe_context *ctx,
647f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    struct pipe_stream_output_target *target);
648f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_so_targets(struct pipe_context *ctx,
649f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			 unsigned num_targets,
650f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			 struct pipe_stream_output_target **targets,
651f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			 unsigned append_bitmask);
652f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask);
653f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_set_pipe_stencil_ref(struct pipe_context *ctx,
654f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			       const struct pipe_stencil_ref *state);
655f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info);
656f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_draw_rectangle(struct blitter_context *blitter,
657f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			 unsigned x1, unsigned y1, unsigned x2, unsigned y2, float depth,
658f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			 enum blitter_attrib_type type, const union pipe_color_union *attrib);
659f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orguint32_t r600_translate_stencil_op(int s_op);
660f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orguint32_t r600_translate_fill(uint32_t func);
661f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_tex_wrap(unsigned wrap);
662f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_tex_filter(unsigned filter);
663f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_tex_mipfilter(unsigned filter);
664f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned r600_tex_compare(unsigned compare);
665f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
666f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
667f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helpers for building command buffers
668f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
669f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
670f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_SET_CONFIG_REG	0x68
671f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_SET_CONTEXT_REG	0x69
672f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_SET_CTL_CONST      0x6F
673f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_SET_LOOP_CONST                    0x6C
674f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
675f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_CONFIG_REG_OFFSET	0x08000
676f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_CONTEXT_REG_OFFSET 0x28000
677f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_CTL_CONST_OFFSET   0x3CFF0
678f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define R600_LOOP_CONST_OFFSET                 0X0003E200
679f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EG_LOOP_CONST_OFFSET               0x0003A200
680f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
681f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT_TYPE_S(x)                   (((x) & 0x3) << 30)
682f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT_COUNT_S(x)                  (((x) & 0x3FFF) << 16)
683f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_IT_OPCODE_S(x)             (((x) & 0xFF) << 8)
684f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3_PREDICATE(x)               (((x) >> 0) & 0x1)
685f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3(op, count, predicate) (PKT_TYPE_S(3) | PKT_COUNT_S(count) | PKT3_IT_OPCODE_S(op) | PKT3_PREDICATE(predicate))
686f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
687f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define RADEON_CP_PACKET3_COMPUTE_MODE 0x00000002
688f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
689f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*Evergreen Compute packet3*/
690f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PKT3C(op, count, predicate) (PKT_TYPE_S(3) | PKT3_IT_OPCODE_S(op) | PKT_COUNT_S(count) | PKT3_PREDICATE(predicate) | RADEON_CP_PACKET3_COMPUTE_MODE)
691f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
692f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_value(struct r600_command_buffer *cb, unsigned value)
693f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
694f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = value;
695f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
696f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
697f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_config_reg_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
698f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
699f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg < R600_CONTEXT_REG_OFFSET);
700f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cb->atom.num_dw+2+num <= cb->max_num_dw);
701f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = PKT3(PKT3_SET_CONFIG_REG, num, 0);
702f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = (reg - R600_CONFIG_REG_OFFSET) >> 2;
703f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
704f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
705f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
706f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
707f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * shaders.
708f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
709f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_context_reg_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
710f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
711f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= R600_CONTEXT_REG_OFFSET && reg < R600_CTL_CONST_OFFSET);
712f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cb->atom.num_dw+2+num <= cb->max_num_dw);
713f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = PKT3(PKT3_SET_CONTEXT_REG, num, 0) | cb->pkt_flags;
714f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = (reg - R600_CONTEXT_REG_OFFSET) >> 2;
715f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
716f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
717f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
718f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
719f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * shaders.
720f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
721f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_ctl_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
722f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
723f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= R600_CTL_CONST_OFFSET);
724f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cb->atom.num_dw+2+num <= cb->max_num_dw);
725f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = PKT3(PKT3_SET_CTL_CONST, num, 0) | cb->pkt_flags;
726f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = (reg - R600_CTL_CONST_OFFSET) >> 2;
727f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
728f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
729f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_loop_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
730f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
731f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= R600_LOOP_CONST_OFFSET);
732f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cb->atom.num_dw+2+num <= cb->max_num_dw);
733f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = PKT3(PKT3_SET_LOOP_CONST, num, 0);
734f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = (reg - R600_LOOP_CONST_OFFSET) >> 2;
735f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
736f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
737f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
738f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
739f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * shaders.
740f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
741f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void eg_store_loop_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
742f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
743f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= EG_LOOP_CONST_OFFSET);
744f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cb->atom.num_dw+2+num <= cb->max_num_dw);
745f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = PKT3(PKT3_SET_LOOP_CONST, num, 0) | cb->pkt_flags;
746f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cb->buf[cb->atom.num_dw++] = (reg - EG_LOOP_CONST_OFFSET) >> 2;
747f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
748f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
749f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_config_reg(struct r600_command_buffer *cb, unsigned reg, unsigned value)
750f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
751f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_config_reg_seq(cb, reg, 1);
752f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_value(cb, value);
753f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
754f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
755f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_context_reg(struct r600_command_buffer *cb, unsigned reg, unsigned value)
756f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
757f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_context_reg_seq(cb, reg, 1);
758f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_value(cb, value);
759f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
760f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
761f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_ctl_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
762f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
763f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_ctl_const_seq(cb, reg, 1);
764f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_value(cb, value);
765f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
766f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
767f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_store_loop_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
768f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
769f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_loop_const_seq(cb, reg, 1);
770f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_value(cb, value);
771f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
772f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
773f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void eg_store_loop_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
774f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
775f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	eg_store_loop_const_seq(cb, reg, 1);
776f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_store_value(cb, value);
777f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
778f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
779f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_init_command_buffer(struct r600_command_buffer *cb, unsigned num_dw, enum r600_atom_flags flags);
780f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_release_command_buffer(struct r600_command_buffer *cb);
781f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
782f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
783f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helpers for emitting state into a command stream directly.
784f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
785f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
786f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r600_resource *rbo,
787f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org					     enum radeon_bo_usage usage)
788f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
789f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(usage);
790f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	return ctx->ws->cs_add_reloc(ctx->cs, rbo->cs_buf, usage, rbo->domains) * 4;
791f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
792f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
793f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_value(struct radeon_winsys_cs *cs, unsigned value)
794f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
795f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = value;
796f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
797f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
798f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_array(struct radeon_winsys_cs *cs, unsigned num, unsigned *ptr)
799f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
800f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cs->cdw+num <= RADEON_MAX_CMDBUF_DWORDS);
801f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	memcpy(&cs->buf[cs->cdw], ptr, num * sizeof(ptr[0]));
802f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->cdw += num;
803f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
804f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
805f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_config_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num)
806f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
807f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg < R600_CONTEXT_REG_OFFSET);
808f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cs->cdw+2+num <= RADEON_MAX_CMDBUF_DWORDS);
809f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = PKT3(PKT3_SET_CONFIG_REG, num, 0);
810f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = (reg - R600_CONFIG_REG_OFFSET) >> 2;
811f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
812f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
813f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_context_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num)
814f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
815f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= R600_CONTEXT_REG_OFFSET && reg < R600_CTL_CONST_OFFSET);
816f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cs->cdw+2+num <= RADEON_MAX_CMDBUF_DWORDS);
817f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = PKT3(PKT3_SET_CONTEXT_REG, num, 0);
818f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = (reg - R600_CONTEXT_REG_OFFSET) >> 2;
819f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
820f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
821f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_compute_context_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num)
822f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
823f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_context_reg_seq(cs, reg, num);
824f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/* Set the compute bit on the packet header */
825f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw - 2] |= RADEON_CP_PACKET3_COMPUTE_MODE;
826f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
827f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
828f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_ctl_const_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num)
829f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
830f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(reg >= R600_CTL_CONST_OFFSET);
831f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	assert(cs->cdw+2+num <= RADEON_MAX_CMDBUF_DWORDS);
832f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = PKT3(PKT3_SET_CTL_CONST, num, 0);
833f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	cs->buf[cs->cdw++] = (reg - R600_CTL_CONST_OFFSET) >> 2;
834f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
835f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
836f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_config_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value)
837f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
838f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_config_reg_seq(cs, reg, 1);
839f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_value(cs, value);
840f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
841f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
842f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_context_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value)
843f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
844f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_context_reg_seq(cs, reg, 1);
845f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_value(cs, value);
846f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
847f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
848f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_compute_context_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value)
849f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
850f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_compute_context_reg_seq(cs, reg, 1);
851f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_value(cs, value);
852f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
853f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
854f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_write_ctl_const(struct radeon_winsys_cs *cs, unsigned reg, unsigned value)
855f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
856f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_ctl_const_seq(cs, reg, 1);
857f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	r600_write_value(cs, value);
858f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
859f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
860f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
861f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * common helpers
862f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
863f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE uint32_t S_FIXED(float value, uint32_t frac_bits)
864f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
865f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	return value * (1 << frac_bits);
866f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
867f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y))
868f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
869f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline unsigned r600_tex_aniso_filter(unsigned filter)
870f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
871f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (filter <= 1)   return 0;
872f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (filter <= 2)   return 1;
873f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (filter <= 4)   return 2;
874f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (filter <= 8)   return 3;
875f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 /* else */        return 4;
876f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
877f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
878f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 12.4 fixed-point */
879f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE unsigned r600_pack_float_12p4(float x)
880f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
881f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	return x <= 0    ? 0 :
882f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	       x >= 4096 ? 0xffff : x * 16;
883f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
884f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
885f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE uint64_t r600_resource_va(struct pipe_screen *screen, struct pipe_resource *resource)
886f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
887f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_screen *rscreen = (struct r600_screen*)screen;
888f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource *rresource = (struct r600_resource*)resource;
889f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
890f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	return rscreen->ws->buffer_get_virtual_address(rresource->cs_buf);
891f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
892f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
893f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r)
894f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
895f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_context *rctx = (struct r600_context *)ctx;
896f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct r600_resource *rr = (struct r600_resource *)r;
897f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
898f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (r == NULL) {
899f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		return;
900f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
901f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
902f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	/*
903f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * The idea is to compute a gross estimate of memory requirement of
904f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * each draw call. After each draw call, memory will be precisely
905f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * accounted. So the uncertainty is only on the current draw call.
906f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * In practice this gave very good estimate (+/- 10% of the target
907f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 * memory limit).
908f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	 */
909f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (rr->domains & RADEON_DOMAIN_GTT) {
910f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		rctx->gtt += rr->buf->size;
911f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
912f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (rr->domains & RADEON_DOMAIN_VRAM) {
913f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		rctx->vram += rr->buf->size;
914f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
915f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
916f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
917f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
918