1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2009 Marek Olšák <maraeo@gmail.com>
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef U_BLITTER_H
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define U_BLITTER_H
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_framebuffer.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_inlines.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_memory.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef __cplusplus
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern "C" {
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_context;
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum blitter_attrib_type {
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   UTIL_BLITTER_ATTRIB_NONE,
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   UTIL_BLITTER_ATTRIB_COLOR,
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   UTIL_BLITTER_ATTRIB_TEXCOORD
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct blitter_context
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /**
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * Draw a rectangle.
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param x1      An X coordinate of the top-left corner.
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param y1      A Y coordinate of the top-left corner.
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param x2      An X coordinate of the bottom-right corner.
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param y2      A Y coordinate of the bottom-right corner.
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param depth   A depth which the rectangle is rendered at.
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param type   Semantics of the attributes "attrib".
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               If type is UTIL_BLITTER_ATTRIB_NONE, ignore them.
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               If type is UTIL_BLITTER_ATTRIB_COLOR, the attributes
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               make up a constant RGBA color, and should go
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               to the GENERIC0 varying slot of a fragment shader.
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               If type is UTIL_BLITTER_ATTRIB_TEXCOORD, {a1, a2} and
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               {a3, a4} specify top-left and bottom-right texture
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               coordinates of the rectangle, respectively, and should go
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *               to the GENERIC0 varying slot of a fragment shader.
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \param attrib See type.
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * \note A driver may optionally override this callback to implement
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *       a specialized hardware path for drawing a rectangle, e.g. using
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    *       a rectangular point sprite.
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    */
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void (*draw_rectangle)(struct blitter_context *blitter,
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          unsigned x1, unsigned y1, unsigned x2, unsigned y2,
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          float depth,
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          enum blitter_attrib_type type,
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                          const union pipe_color_union *color);
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* Whether the blitter is running. */
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean running;
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* Private members, really. */
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_context *pipe; /**< pipe context */
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_blend_state;   /**< blend state */
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_dsa_state;     /**< depth stencil alpha state */
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_velem_state;   /**< vertex elements state */
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_rs_state;      /**< rasterizer state */
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_fs, *saved_vs, *saved_gs; /**< shaders */
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_framebuffer_state saved_fb_state;  /**< framebuffer state */
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_stencil_ref saved_stencil_ref;     /**< stencil ref */
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_viewport_state saved_viewport;
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean is_sample_mask_saved;
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned saved_sample_mask;
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int saved_num_sampler_states;
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *saved_sampler_states[PIPE_MAX_SAMPLERS];
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int saved_num_sampler_views;
104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int saved_num_vertex_buffers;
107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS];
108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int saved_num_so_targets;
110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS];
111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Create a blitter context.
115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct blitter_context *util_blitter_create(struct pipe_context *pipe);
117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Destroy a blitter context.
120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_destroy(struct blitter_context *blitter);
122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Return the pipe context associated with a blitter context.
125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return blitter->pipe;
130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* The default function to draw a rectangle. This can only be used
133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * inside of the draw_rectangle callback if the driver overrides it. */
134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_draw_rectangle(struct blitter_context *blitter,
135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 unsigned x1, unsigned y1,
136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 unsigned x2, unsigned y2,
137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 float depth,
138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 enum blitter_attrib_type type,
139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 const union pipe_color_union *attrib);
140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These states must be saved before any of the following functions are called:
143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - vertex buffers
144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - vertex elements
145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - vertex shader
146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - geometry shader (if supported)
147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - stream output targets (if supported)
148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - rasterizer state
149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Clear a specified set of currently bound buffers to specified values.
153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These states must be saved in the blitter in addition to the state objects
155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * already required to be saved:
156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment shader
157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - depth stencil alpha state
158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - blend state
159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_clear(struct blitter_context *blitter,
161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        unsigned width, unsigned height,
162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        unsigned num_cbufs,
163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        unsigned clear_buffers,
164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        enum pipe_format cbuf_format,
165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        const union pipe_color_union *color,
166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        double depth, unsigned stencil);
167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Check if the blitter (with the help of the driver) can blit between
170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the two resources.
171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The mask is a combination of the PIPE_MASK_* flags.
172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Set to PIPE_MASK_RGBAZS if unsure.
173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean util_blitter_is_copy_supported(struct blitter_context *blitter,
175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       const struct pipe_resource *dst,
176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       const struct pipe_resource *src,
177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       unsigned mask);
178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copy a block of pixels from one surface to another.
180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * You can copy from any color format to any other color format provided
182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the former can be sampled from and the latter can be rendered to. Otherwise,
183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a software fallback path is taken and both surfaces must be of the same
184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * format.
185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Only one sample of a multisample texture can be copied and is specified by
187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * src_sample. If the destination is a multisample resource, dst_sample_mask
188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * specifies the sample mask. For single-sample resources, set dst_sample_mask
189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to ~0.
190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These states must be saved in the blitter in addition to the state objects
192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * already required to be saved:
193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment shader
194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - depth stencil alpha state
195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - blend state
196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment sampler states
197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment sampler textures
198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - framebuffer state
199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_copy_texture(struct blitter_context *blitter,
201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               struct pipe_resource *dst,
202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               unsigned dst_level, unsigned dst_sample_mask,
203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               unsigned dstx, unsigned dsty, unsigned dstz,
204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               struct pipe_resource *src,
205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               unsigned src_level, unsigned src_sample,
206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               const struct pipe_box *srcbox);
207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Same as util_blitter_copy_texture, but dst and src are pipe_surface and
210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * pipe_sampler_view, respectively. The mipmap level and dstz are part of
211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the views.
212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Drivers can use this to change resource properties (like format, width,
214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * height) by changing how the views interpret them, instead of changing
215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * pipe_resource directly. This is usually needed to accelerate copying of
216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * compressed formats.
217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * src_width0 and src_height0 are sampler_view-private properties that
219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * override pipe_resource. The blitter uses them for computation of texture
220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * coordinates. The dst dimensions are supplied through pipe_surface::width
221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and height.
222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The mask is a combination of the PIPE_MASK_* flags.
224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Set to PIPE_MASK_RGBAZS if unsure.
225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * NOTE: There are no checks whether the blit is actually supported.
227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_copy_texture_view(struct blitter_context *blitter,
229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    struct pipe_surface *dst,
230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    unsigned dst_sample_mask,
231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    unsigned dstx, unsigned dsty,
232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    struct pipe_sampler_view *src,
233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    unsigned src_sample,
234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    const struct pipe_box *srcbox,
235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    unsigned src_width0, unsigned src_height0,
236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                    unsigned mask);
237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper function to initialize a view for copy_texture_view.
240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The parameters must match copy_texture_view.
241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      struct pipe_resource *dst,
244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned dstlevel,
245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned dstz,
246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      const struct pipe_box *srcbox);
247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper function to initialize a view for copy_texture_view.
250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The parameters must match copy_texture_view.
251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_default_src_texture(struct pipe_sampler_view *src_templ,
253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      struct pipe_resource *src,
254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned srclevel);
255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copy data from one buffer to another using the Stream Output functionality.
258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Some alignment is required, otherwise software fallback is used.
259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_copy_buffer(struct blitter_context *blitter,
261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              struct pipe_resource *dst,
262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              unsigned dstx,
263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              struct pipe_resource *src,
264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              unsigned srcx,
265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              unsigned size);
266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Clear a region of a (color) surface to a constant value.
269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These states must be saved in the blitter in addition to the state objects
271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * already required to be saved:
272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment shader
273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - depth stencil alpha state
274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - blend state
275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - framebuffer state
276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_clear_render_target(struct blitter_context *blitter,
278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      struct pipe_surface *dst,
279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      const union pipe_color_union *color,
280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned dstx, unsigned dsty,
281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned width, unsigned height);
282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Clear a region of a depth-stencil surface, both stencil and depth
285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * or only one of them if this is a combined depth-stencil surface.
286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These states must be saved in the blitter in addition to the state objects
288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * already required to be saved:
289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - fragment shader
290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - depth stencil alpha state
291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - blend state
292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - framebuffer state
293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_clear_depth_stencil(struct blitter_context *blitter,
295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      struct pipe_surface *dst,
296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned clear_flags,
297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      double depth,
298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned stencil,
299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned dstx, unsigned dsty,
300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                      unsigned width, unsigned height);
301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* The following functions are customized variants of the clear functions.
303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Some drivers use them internally to do things like MSAA resolve
304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and resource decompression. It usually consists of rendering a full-screen
305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * quad with a special blend or DSA state.
306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Used by r300g for depth decompression. */
309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_custom_clear_depth(struct blitter_context *blitter,
310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                     unsigned width, unsigned height,
311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                     double depth, void *custom_dsa);
312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Used by r600g for depth decompression. */
314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_custom_depth_stencil(struct blitter_context *blitter,
315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				       struct pipe_surface *zsurf,
316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				       struct pipe_surface *cbsurf,
317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				       unsigned sample_mask,
318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				       void *dsa_stage, float depth);
319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Used by r600g for color decompression. */
321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_custom_color(struct blitter_context *blitter,
322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               struct pipe_surface *dstsurf,
323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               void *custom_blend);
324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Used by r600g for MSAA color resolve. */
326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_custom_resolve_color(struct blitter_context *blitter,
327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       struct pipe_resource *dst,
328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       unsigned dst_level,
329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       unsigned dst_layer,
330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       struct pipe_resource *src,
331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       unsigned src_layer,
332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				       unsigned sampled_mask,
333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       void *custom_blend);
334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* The functions below should be used to save currently bound constant state
336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * objects inside a driver. The objects are automatically restored at the end
337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the util_blitter_{clear, copy_region, fill_region} functions and then
338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * forgotten.
339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * States not listed here are not affected by util_blitter. */
341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_blend(struct blitter_context *blitter,
344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                             void *state)
345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_blend_state = state;
347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                           void *state)
352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_dsa_state = state;
354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_vertex_elements(struct blitter_context *blitter,
358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       void *state)
359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_velem_state = state;
361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_stencil_ref(struct blitter_context *blitter,
365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                   const struct pipe_stencil_ref *state)
366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_stencil_ref = *state;
368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_rasterizer(struct blitter_context *blitter,
372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                  void *state)
373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_rs_state = state;
375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_fragment_shader(struct blitter_context *blitter,
379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       void *fs)
380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_fs = fs;
382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_vertex_shader(struct blitter_context *blitter,
386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                     void *vs)
387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_vs = vs;
389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_geometry_shader(struct blitter_context *blitter,
393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                       void *gs)
394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_gs = gs;
396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_framebuffer(struct blitter_context *blitter,
400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                   const struct pipe_framebuffer_state *state)
401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */
403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_copy_framebuffer_state(&blitter->saved_fb_state, state);
404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_viewport(struct blitter_context *blitter,
408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                struct pipe_viewport_state *state)
409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_viewport = *state;
411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE
414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid util_blitter_save_fragment_sampler_states(
415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                  struct blitter_context *blitter,
416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                  int num_sampler_states,
417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                  void **sampler_states)
418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   assert(num_sampler_states <= Elements(blitter->saved_sampler_states));
420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_num_sampler_states = num_sampler_states;
422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   memcpy(blitter->saved_sampler_states, sampler_states,
423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org          num_sampler_states * sizeof(void *));
424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void
427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgutil_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                         int num_views,
429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                         struct pipe_sampler_view **views)
430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned i;
432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   assert(num_views <= Elements(blitter->saved_sampler_views));
433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_num_sampler_views = num_views;
435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (i = 0; i < num_views; i++)
436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      pipe_sampler_view_reference(&blitter->saved_sampler_views[i],
437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                  views[i]);
438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void
441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgutil_blitter_save_vertex_buffers(struct blitter_context *blitter,
442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 int num_vertex_buffers,
443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                 struct pipe_vertex_buffer *vertex_buffers)
444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_num_vertex_buffers = 0;
448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_copy_vertex_buffers(blitter->saved_vertex_buffers,
449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            (unsigned*)&blitter->saved_num_vertex_buffers,
450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            vertex_buffers,
451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            num_vertex_buffers);
452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void
455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgutil_blitter_save_so_targets(struct blitter_context *blitter,
456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                             int num_targets,
457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                             struct pipe_stream_output_target **targets)
458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned i;
460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   assert(num_targets <= Elements(blitter->saved_so_targets));
461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_num_so_targets = num_targets;
463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (i = 0; i < num_targets; i++)
464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      pipe_so_target_reference(&blitter->saved_so_targets[i],
465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               targets[i]);
466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void
469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgutil_blitter_save_sample_mask(struct blitter_context *blitter,
470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                              unsigned sample_mask)
471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->is_sample_mask_saved = TRUE;
473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   blitter->saved_sample_mask = sample_mask;
474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef __cplusplus
477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
481