* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
-#include "util/u_memory.h"
#include "pipe/p_state.h"
-
#ifdef __cplusplus
extern "C" {
#endif
enum blitter_attrib_type type,
const union pipe_color_union *color);
+ /**
+ * Get the next surface layer for the pipe surface, i.e. make a copy
+ * of the surface and increment the first and last layer by 1.
+ *
+ * This callback is exposed, so that drivers can override it if needed.
+ */
+ struct pipe_surface *(*get_next_surface_layer)(struct pipe_context *pipe,
+ struct pipe_surface *surf);
+
/* Whether the blitter is running. */
boolean running;
void *saved_dsa_state; /**< depth stencil alpha state */
void *saved_velem_state; /**< vertex elements state */
void *saved_rs_state; /**< rasterizer state */
- void *saved_fs, *saved_vs, *saved_gs; /**< shaders */
+ void *saved_fs, *saved_vs, *saved_gs, *saved_tcs, *saved_tes; /**< shaders */
struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
unsigned saved_num_sampler_views;
struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
- unsigned saved_num_vertex_buffers;
- struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS];
+ unsigned cb_slot;
+ struct pipe_constant_buffer saved_fs_constant_buffer;
+
+ unsigned vb_slot;
+ struct pipe_vertex_buffer saved_vertex_buffer;
unsigned saved_num_so_targets;
struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS];
struct pipe_query *saved_render_cond_query;
uint saved_render_cond_mode;
+ boolean saved_render_cond_cond;
};
/**
/**
* Return the pipe context associated with a blitter context.
*/
-static INLINE
+static inline
struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
{
return blitter->pipe;
enum blitter_attrib_type type,
const union pipe_color_union *attrib);
-/**
- * Try to do a blit using resource_copy_region. The function calls
- * resource_copy_region if the blit description is compatible with it.
- *
- * It returns TRUE if the blit was done using resource_copy_region.
- *
- * It returns FALSE otherwise and the caller must fall back to a more generic
- * codepath for the blit operation. (e.g. by using u_blitter)
- */
-boolean util_try_blit_via_copy_region(struct pipe_context *ctx,
- const struct pipe_blit_info *blit);
/*
* These states must be saved before any of the following functions are called:
* - blend state
*/
void util_blitter_clear(struct blitter_context *blitter,
- unsigned width, unsigned height,
- unsigned num_cbufs,
+ unsigned width, unsigned height, unsigned num_layers,
unsigned clear_buffers,
- enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil);
/**
* Check if the blitter (with the help of the driver) can blit between
* the two resources.
- * The mask is a combination of the PIPE_MASK_* flags.
- * Set to PIPE_MASK_RGBAZS if unsure.
*/
boolean util_blitter_is_copy_supported(struct blitter_context *blitter,
const struct pipe_resource *dst,
- const struct pipe_resource *src,
- unsigned mask);
+ const struct pipe_resource *src);
boolean util_blitter_is_blit_supported(struct blitter_context *blitter,
const struct pipe_blit_info *info);
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned src_level,
- const struct pipe_box *srcbox, unsigned mask,
- boolean copy_all_samples);
+ const struct pipe_box *srcbox);
/**
- * Same as util_blitter_copy_texture with the capabilities of util_blitter_blit,
- * but dst and src are pipe_surface and pipe_sampler_view, respectively.
- * The mipmap level and dstz are part of the views.
+ * This is a generic implementation of pipe->blit, which accepts
+ * sampler/surface views instead of resources.
+ *
+ * The layer and mipmap level are specified by the views.
*
* Drivers can use this to change resource properties (like format, width,
* height) by changing how the views interpret them, instead of changing
- * pipe_resource directly. This is usually needed to accelerate copying of
- * compressed formats.
+ * pipe_resource directly. This is used to blit resources of formats which
+ * are not renderable.
*
* src_width0 and src_height0 are sampler_view-private properties that
* override pipe_resource. The blitter uses them for computation of texture
*/
void util_blitter_blit_generic(struct blitter_context *blitter,
struct pipe_surface *dst,
- int dstx, int dsty,
- unsigned dst_width, unsigned dst_height,
+ const struct pipe_box *dstbox,
struct pipe_sampler_view *src,
const struct pipe_box *srcbox,
unsigned src_width0, unsigned src_height0,
unsigned mask, unsigned filter,
const struct pipe_scissor_state *scissor,
- boolean copy_all_samples);
+ boolean alpha_blend);
void util_blitter_blit(struct blitter_context *blitter,
const struct pipe_blit_info *info);
+void util_blitter_generate_mipmap(struct blitter_context *blitter,
+ struct pipe_resource *tex,
+ enum pipe_format format,
+ unsigned base_level, unsigned last_level,
+ unsigned first_layer, unsigned last_layer);
+
/**
* Helper function to initialize a view for copy_texture_view.
* The parameters must match copy_texture_view.
void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
struct pipe_resource *dst,
unsigned dstlevel,
- unsigned dstz,
- const struct pipe_box *srcbox);
+ unsigned dstz);
/**
* Helper function to initialize a view for copy_texture_view.
/**
* Copy data from one buffer to another using the Stream Output functionality.
- * Some alignment is required, otherwise software fallback is used.
+ * 4-byte alignment is required, otherwise software fallback is used.
*/
void util_blitter_copy_buffer(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned srcx,
unsigned size);
+/**
+ * Clear the contents of a buffer using the Stream Output functionality.
+ * 4-byte alignment is required.
+ *
+ * "num_channels" can be 1, 2, 3, or 4, and specifies if the clear value is
+ * R, RG, RGB, or RGBA.
+ *
+ * For each element, only "num_channels" components of "clear_value" are
+ * copied to the buffer, then the offset is incremented by num_channels*4.
+ */
+void util_blitter_clear_buffer(struct blitter_context *blitter,
+ struct pipe_resource *dst,
+ unsigned offset, unsigned size,
+ unsigned num_channels,
+ const union pipe_color_union *clear_value);
+
/**
* Clear a region of a (color) surface to a constant value.
*
*
* States not listed here are not affected by util_blitter. */
-static INLINE
-void util_blitter_save_blend(struct blitter_context *blitter,
- void *state)
+static inline void
+util_blitter_save_blend(struct blitter_context *blitter, void *state)
{
blitter->saved_blend_state = state;
}
-static INLINE
-void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
- void *state)
+static inline void
+util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
+ void *state)
{
blitter->saved_dsa_state = state;
}
-static INLINE
-void util_blitter_save_vertex_elements(struct blitter_context *blitter,
- void *state)
+static inline void
+util_blitter_save_vertex_elements(struct blitter_context *blitter, void *state)
{
blitter->saved_velem_state = state;
}
-static INLINE
-void util_blitter_save_stencil_ref(struct blitter_context *blitter,
- const struct pipe_stencil_ref *state)
+static inline void
+util_blitter_save_stencil_ref(struct blitter_context *blitter,
+ const struct pipe_stencil_ref *state)
{
blitter->saved_stencil_ref = *state;
}
-static INLINE
-void util_blitter_save_rasterizer(struct blitter_context *blitter,
- void *state)
+static inline void
+util_blitter_save_rasterizer(struct blitter_context *blitter, void *state)
{
blitter->saved_rs_state = state;
}
-static INLINE
-void util_blitter_save_fragment_shader(struct blitter_context *blitter,
- void *fs)
+static inline void
+util_blitter_save_fragment_shader(struct blitter_context *blitter, void *fs)
{
blitter->saved_fs = fs;
}
-static INLINE
-void util_blitter_save_vertex_shader(struct blitter_context *blitter,
- void *vs)
+static inline void
+util_blitter_save_vertex_shader(struct blitter_context *blitter, void *vs)
{
blitter->saved_vs = vs;
}
-static INLINE
-void util_blitter_save_geometry_shader(struct blitter_context *blitter,
- void *gs)
+static inline void
+util_blitter_save_geometry_shader(struct blitter_context *blitter, void *gs)
{
blitter->saved_gs = gs;
}
-static INLINE
-void util_blitter_save_framebuffer(struct blitter_context *blitter,
- const struct pipe_framebuffer_state *state)
+static inline void
+util_blitter_save_tessctrl_shader(struct blitter_context *blitter,
+ void *sh)
+{
+ blitter->saved_tcs = sh;
+}
+
+static inline void
+util_blitter_save_tesseval_shader(struct blitter_context *blitter,
+ void *sh)
+{
+ blitter->saved_tes = sh;
+}
+
+static inline void
+util_blitter_save_framebuffer(struct blitter_context *blitter,
+ const struct pipe_framebuffer_state *state)
{
blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */
util_copy_framebuffer_state(&blitter->saved_fb_state, state);
}
-static INLINE
-void util_blitter_save_viewport(struct blitter_context *blitter,
- struct pipe_viewport_state *state)
+static inline void
+util_blitter_save_viewport(struct blitter_context *blitter,
+ struct pipe_viewport_state *state)
{
blitter->saved_viewport = *state;
}
-static INLINE
-void util_blitter_save_scissor(struct blitter_context *blitter,
- struct pipe_scissor_state *state)
+static inline void
+util_blitter_save_scissor(struct blitter_context *blitter,
+ struct pipe_scissor_state *state)
{
blitter->saved_scissor = *state;
}
-static INLINE
-void util_blitter_save_fragment_sampler_states(
+static inline void
+util_blitter_save_fragment_sampler_states(
struct blitter_context *blitter,
unsigned num_sampler_states,
void **sampler_states)
{
- assert(num_sampler_states <= Elements(blitter->saved_sampler_states));
+ assert(num_sampler_states <= ARRAY_SIZE(blitter->saved_sampler_states));
blitter->saved_num_sampler_states = num_sampler_states;
memcpy(blitter->saved_sampler_states, sampler_states,
num_sampler_states * sizeof(void *));
}
-static INLINE void
+static inline void
util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
unsigned num_views,
struct pipe_sampler_view **views)
{
unsigned i;
- assert(num_views <= Elements(blitter->saved_sampler_views));
+ assert(num_views <= ARRAY_SIZE(blitter->saved_sampler_views));
blitter->saved_num_sampler_views = num_views;
for (i = 0; i < num_views; i++)
views[i]);
}
-static INLINE void
-util_blitter_save_vertex_buffers(struct blitter_context *blitter,
- unsigned num_vertex_buffers,
- struct pipe_vertex_buffer *vertex_buffers)
+static inline void
+util_blitter_save_fragment_constant_buffer_slot(
+ struct blitter_context *blitter,
+ struct pipe_constant_buffer *constant_buffers)
{
- assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
+ pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer,
+ constant_buffers[blitter->cb_slot].buffer);
+ memcpy(&blitter->saved_fs_constant_buffer, &constant_buffers[blitter->cb_slot],
+ sizeof(struct pipe_constant_buffer));
+}
- blitter->saved_num_vertex_buffers = 0;
- util_copy_vertex_buffers(blitter->saved_vertex_buffers,
- (unsigned*)&blitter->saved_num_vertex_buffers,
- vertex_buffers,
- num_vertex_buffers);
+static inline void
+util_blitter_save_vertex_buffer_slot(struct blitter_context *blitter,
+ struct pipe_vertex_buffer *vertex_buffers)
+{
+ pipe_vertex_buffer_reference(&blitter->saved_vertex_buffer,
+ &vertex_buffers[blitter->vb_slot]);
}
-static INLINE void
+static inline void
util_blitter_save_so_targets(struct blitter_context *blitter,
unsigned num_targets,
struct pipe_stream_output_target **targets)
{
unsigned i;
- assert(num_targets <= Elements(blitter->saved_so_targets));
+ assert(num_targets <= ARRAY_SIZE(blitter->saved_so_targets));
blitter->saved_num_so_targets = num_targets;
for (i = 0; i < num_targets; i++)
targets[i]);
}
-static INLINE void
+static inline void
util_blitter_save_sample_mask(struct blitter_context *blitter,
unsigned sample_mask)
{
blitter->saved_sample_mask = sample_mask;
}
-static INLINE void
+static inline void
util_blitter_save_render_condition(struct blitter_context *blitter,
struct pipe_query *query,
- uint mode)
+ boolean condition,
+ enum pipe_render_cond_flag mode)
{
blitter->saved_render_cond_query = query;
blitter->saved_render_cond_mode = mode;
+ blitter->saved_render_cond_cond = condition;
}
+void util_blitter_common_clear_setup(struct blitter_context *blitter,
+ unsigned width, unsigned height,
+ unsigned clear_buffers,
+ void *custom_blend, void *custom_dsa);
+
+void util_blitter_set_running_flag(struct blitter_context *blitter);
+void util_blitter_unset_running_flag(struct blitter_context *blitter);
+
+void util_blitter_restore_vertex_states(struct blitter_context *blitter);
+void util_blitter_restore_fragment_states(struct blitter_context *blitter);
+void util_blitter_restore_render_cond(struct blitter_context *blitter);
+void util_blitter_restore_fb_state(struct blitter_context *blitter);
+void util_blitter_restore_textures(struct blitter_context *blitter);
+void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter);
+
#ifdef __cplusplus
}
#endif