2009-12-10 09:25:33 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright 2009 Marek Olšák <maraeo@gmail.com>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* 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.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
2009-12-10 09:25:33 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef U_BLITTER_H
|
|
|
|
#define U_BLITTER_H
|
|
|
|
|
2010-08-29 05:08:24 +01:00
|
|
|
#include "util/u_framebuffer.h"
|
2010-06-09 01:13:10 +01:00
|
|
|
#include "util/u_inlines.h"
|
2009-12-10 09:25:33 +00:00
|
|
|
|
|
|
|
#include "pipe/p_state.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct pipe_context;
|
|
|
|
|
2010-07-12 05:32:50 +01:00
|
|
|
enum blitter_attrib_type {
|
|
|
|
UTIL_BLITTER_ATTRIB_NONE,
|
|
|
|
UTIL_BLITTER_ATTRIB_COLOR,
|
2017-08-17 02:32:23 +01:00
|
|
|
UTIL_BLITTER_ATTRIB_TEXCOORD_XY,
|
|
|
|
UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW,
|
2010-07-12 05:32:50 +01:00
|
|
|
};
|
|
|
|
|
2017-08-17 01:09:54 +01:00
|
|
|
union blitter_attrib {
|
|
|
|
float color[4];
|
|
|
|
|
|
|
|
struct {
|
2017-08-17 02:32:23 +01:00
|
|
|
float x1, y1, x2, y2, z, w;
|
2017-08-17 01:09:54 +01:00
|
|
|
} texcoord;
|
|
|
|
};
|
|
|
|
|
2017-10-05 03:02:05 +01:00
|
|
|
struct blitter_context;
|
|
|
|
|
|
|
|
typedef void *(*blitter_get_vs_func)(struct blitter_context *blitter);
|
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
struct blitter_context
|
|
|
|
{
|
2010-07-12 05:32:50 +01:00
|
|
|
/**
|
|
|
|
* Draw a rectangle.
|
|
|
|
*
|
2017-10-05 03:02:05 +01:00
|
|
|
* \param get_vs Callback for obtaining the vertex shader for the draw call.
|
|
|
|
* It might invoke the shader compiler. The driver is
|
|
|
|
* responsible for setting the vertex shader, and the callback
|
|
|
|
* allows the driver to query the vertex shader CSO if it
|
|
|
|
* wants to use the default one.
|
2010-07-12 05:32:50 +01:00
|
|
|
* \param x1 An X coordinate of the top-left corner.
|
|
|
|
* \param y1 A Y coordinate of the top-left corner.
|
|
|
|
* \param x2 An X coordinate of the bottom-right corner.
|
|
|
|
* \param y2 A Y coordinate of the bottom-right corner.
|
2011-01-25 04:37:52 +00:00
|
|
|
* \param depth A depth which the rectangle is rendered at.
|
2010-07-12 05:32:50 +01:00
|
|
|
*
|
|
|
|
* \param type Semantics of the attributes "attrib".
|
|
|
|
* If type is UTIL_BLITTER_ATTRIB_NONE, ignore them.
|
|
|
|
* If type is UTIL_BLITTER_ATTRIB_COLOR, the attributes
|
2011-01-25 04:37:52 +00:00
|
|
|
* make up a constant RGBA color, and should go
|
|
|
|
* to the GENERIC0 varying slot of a fragment shader.
|
2010-07-12 05:32:50 +01:00
|
|
|
* If type is UTIL_BLITTER_ATTRIB_TEXCOORD, {a1, a2} and
|
|
|
|
* {a3, a4} specify top-left and bottom-right texture
|
|
|
|
* coordinates of the rectangle, respectively, and should go
|
|
|
|
* to the GENERIC0 varying slot of a fragment shader.
|
|
|
|
*
|
|
|
|
* \param attrib See type.
|
|
|
|
*
|
|
|
|
* \note A driver may optionally override this callback to implement
|
|
|
|
* a specialized hardware path for drawing a rectangle, e.g. using
|
|
|
|
* a rectangular point sprite.
|
|
|
|
*/
|
|
|
|
void (*draw_rectangle)(struct blitter_context *blitter,
|
2017-10-05 01:38:35 +01:00
|
|
|
void *vertex_elements_cso,
|
2017-10-05 03:02:05 +01:00
|
|
|
blitter_get_vs_func get_vs,
|
2012-09-12 22:37:17 +01:00
|
|
|
int x1, int y1, int x2, int y2,
|
2017-08-17 01:38:23 +01:00
|
|
|
float depth, unsigned num_instances,
|
2010-07-12 05:32:50 +01:00
|
|
|
enum blitter_attrib_type type,
|
2017-08-17 01:09:54 +01:00
|
|
|
const union blitter_attrib *attrib);
|
2010-07-12 05:32:50 +01:00
|
|
|
|
2011-02-10 10:21:27 +00:00
|
|
|
/* Whether the blitter is running. */
|
2017-08-17 14:36:20 +01:00
|
|
|
bool running;
|
2011-02-10 10:21:27 +00:00
|
|
|
|
2018-07-11 22:53:57 +01:00
|
|
|
bool use_index_buffer;
|
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
/* Private members, really. */
|
2010-07-12 01:06:19 +01:00
|
|
|
struct pipe_context *pipe; /**< pipe context */
|
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
void *saved_blend_state; /**< blend state */
|
|
|
|
void *saved_dsa_state; /**< depth stencil alpha state */
|
2010-03-01 17:40:22 +00:00
|
|
|
void *saved_velem_state; /**< vertex elements state */
|
2009-12-10 09:25:33 +00:00
|
|
|
void *saved_rs_state; /**< rasterizer state */
|
2014-09-23 17:40:27 +01:00
|
|
|
void *saved_fs, *saved_vs, *saved_gs, *saved_tcs, *saved_tes; /**< shaders */
|
2009-12-10 09:25:33 +00:00
|
|
|
|
|
|
|
struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
|
2010-02-11 18:01:10 +00:00
|
|
|
struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
|
2010-03-01 16:06:20 +00:00
|
|
|
struct pipe_viewport_state saved_viewport;
|
2012-09-12 22:37:17 +01:00
|
|
|
struct pipe_scissor_state saved_scissor;
|
2017-10-05 20:29:35 +01:00
|
|
|
bool skip_viewport_restore;
|
2017-08-17 14:36:20 +01:00
|
|
|
bool is_sample_mask_saved;
|
2012-07-22 19:27:04 +01:00
|
|
|
unsigned saved_sample_mask;
|
2021-10-29 15:59:51 +01:00
|
|
|
unsigned saved_min_samples;
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned saved_num_sampler_states;
|
2010-02-19 18:00:26 +00:00
|
|
|
void *saved_sampler_states[PIPE_MAX_SAMPLERS];
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned saved_num_sampler_views;
|
2010-02-19 18:00:26 +00:00
|
|
|
struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
|
2010-04-18 13:50:14 +01:00
|
|
|
|
2016-08-13 15:36:00 +01:00
|
|
|
unsigned cb_slot;
|
|
|
|
struct pipe_constant_buffer saved_fs_constant_buffer;
|
|
|
|
|
2012-03-29 16:51:50 +01:00
|
|
|
unsigned vb_slot;
|
|
|
|
struct pipe_vertex_buffer saved_vertex_buffer;
|
2011-11-19 20:44:28 +00:00
|
|
|
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned saved_num_so_targets;
|
2011-11-19 20:44:28 +00:00
|
|
|
struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS];
|
2012-09-12 22:33:50 +01:00
|
|
|
|
|
|
|
struct pipe_query *saved_render_cond_query;
|
|
|
|
uint saved_render_cond_mode;
|
2017-08-17 14:36:20 +01:00
|
|
|
bool saved_render_cond_cond;
|
2018-08-06 09:16:47 +01:00
|
|
|
|
|
|
|
boolean saved_window_rectangles_include;
|
|
|
|
unsigned saved_num_window_rectangles;
|
|
|
|
struct pipe_scissor_state saved_window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];
|
2009-12-10 09:25:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a blitter context.
|
|
|
|
*/
|
|
|
|
struct blitter_context *util_blitter_create(struct pipe_context *pipe);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a blitter context.
|
|
|
|
*/
|
|
|
|
void util_blitter_destroy(struct blitter_context *blitter);
|
|
|
|
|
2012-09-12 22:14:57 +01:00
|
|
|
void util_blitter_cache_all_shaders(struct blitter_context *blitter);
|
2019-07-30 22:43:41 +01:00
|
|
|
void *util_blitter_get_noop_blend_state(struct blitter_context *blitter);
|
2019-07-30 22:43:41 +01:00
|
|
|
void *util_blitter_get_noop_dsa_state(struct blitter_context *blitter);
|
2019-07-30 22:43:41 +01:00
|
|
|
void *util_blitter_get_discard_rasterizer_state(struct blitter_context *blitter);
|
2019-07-30 22:43:41 +01:00
|
|
|
|
2012-09-12 22:14:57 +01:00
|
|
|
|
2010-07-12 01:06:19 +01:00
|
|
|
/**
|
|
|
|
* Return the pipe context associated with a blitter context.
|
|
|
|
*/
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline
|
2010-07-12 01:06:19 +01:00
|
|
|
struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
|
|
|
|
{
|
|
|
|
return blitter->pipe;
|
|
|
|
}
|
|
|
|
|
2012-10-12 17:46:32 +01:00
|
|
|
/**
|
|
|
|
* Override PIPE_CAP_TEXTURE_MULTISAMPLE as reported by the driver.
|
|
|
|
*/
|
|
|
|
void util_blitter_set_texture_multisample(struct blitter_context *blitter,
|
2017-08-17 14:36:20 +01:00
|
|
|
bool supported);
|
2012-10-12 17:46:32 +01:00
|
|
|
|
2012-08-24 04:57:22 +01:00
|
|
|
/* The default function to draw a rectangle. This can only be used
|
|
|
|
* inside of the draw_rectangle callback if the driver overrides it. */
|
|
|
|
void util_blitter_draw_rectangle(struct blitter_context *blitter,
|
2017-10-05 01:38:35 +01:00
|
|
|
void *vertex_elements_cso,
|
2017-10-05 03:02:05 +01:00
|
|
|
blitter_get_vs_func get_vs,
|
2017-08-17 01:38:23 +01:00
|
|
|
int x1, int y1, int x2, int y2,
|
|
|
|
float depth, unsigned num_instances,
|
2012-08-24 04:57:22 +01:00
|
|
|
enum blitter_attrib_type type,
|
2017-08-17 01:09:54 +01:00
|
|
|
const union blitter_attrib *attrib);
|
2012-08-24 04:57:22 +01:00
|
|
|
|
2012-09-12 22:45:49 +01:00
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
/*
|
2011-10-07 18:10:41 +01:00
|
|
|
* These states must be saved before any of the following functions are called:
|
2011-08-10 01:58:40 +01:00
|
|
|
* - vertex buffers
|
|
|
|
* - vertex elements
|
2011-10-07 18:10:41 +01:00
|
|
|
* - vertex shader
|
2011-10-07 18:28:19 +01:00
|
|
|
* - geometry shader (if supported)
|
2011-11-19 20:44:28 +00:00
|
|
|
* - stream output targets (if supported)
|
2011-10-07 18:10:41 +01:00
|
|
|
* - rasterizer state
|
2009-12-10 09:25:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear a specified set of currently bound buffers to specified values.
|
2011-10-07 18:10:41 +01:00
|
|
|
*
|
|
|
|
* These states must be saved in the blitter in addition to the state objects
|
|
|
|
* already required to be saved:
|
|
|
|
* - fragment shader
|
|
|
|
* - depth stencil alpha state
|
|
|
|
* - blend state
|
2009-12-10 09:25:33 +00:00
|
|
|
*/
|
|
|
|
void util_blitter_clear(struct blitter_context *blitter,
|
2013-11-21 14:41:36 +00:00
|
|
|
unsigned width, unsigned height, unsigned num_layers,
|
2009-12-10 09:25:33 +00:00
|
|
|
unsigned clear_buffers,
|
2011-09-16 09:39:34 +01:00
|
|
|
const union pipe_color_union *color,
|
2019-07-22 15:14:20 +01:00
|
|
|
double depth, unsigned stencil,
|
|
|
|
bool msaa);
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2012-07-28 00:19:18 +01:00
|
|
|
/**
|
|
|
|
* Check if the blitter (with the help of the driver) can blit between
|
|
|
|
* the two resources.
|
|
|
|
*/
|
2017-08-17 14:36:20 +01:00
|
|
|
bool util_blitter_is_copy_supported(struct blitter_context *blitter,
|
|
|
|
const struct pipe_resource *dst,
|
|
|
|
const struct pipe_resource *src);
|
2012-09-12 22:37:17 +01:00
|
|
|
|
2017-08-17 14:36:20 +01:00
|
|
|
bool util_blitter_is_blit_supported(struct blitter_context *blitter,
|
|
|
|
const struct pipe_blit_info *info);
|
2012-09-12 22:37:17 +01:00
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
/**
|
|
|
|
* Copy a block of pixels from one surface to another.
|
|
|
|
*
|
|
|
|
* These states must be saved in the blitter in addition to the state objects
|
|
|
|
* already required to be saved:
|
2011-10-07 18:10:41 +01:00
|
|
|
* - fragment shader
|
|
|
|
* - depth stencil alpha state
|
|
|
|
* - blend state
|
2009-12-10 09:25:33 +00:00
|
|
|
* - fragment sampler states
|
|
|
|
* - fragment sampler textures
|
2011-10-07 18:10:41 +01:00
|
|
|
* - framebuffer state
|
2012-09-12 22:37:17 +01:00
|
|
|
* - sample mask
|
2009-12-10 09:25:33 +00:00
|
|
|
*/
|
2011-08-10 01:58:40 +01:00
|
|
|
void util_blitter_copy_texture(struct blitter_context *blitter,
|
|
|
|
struct pipe_resource *dst,
|
2012-09-12 22:37:17 +01:00
|
|
|
unsigned dst_level,
|
2011-08-10 01:58:40 +01:00
|
|
|
unsigned dstx, unsigned dsty, unsigned dstz,
|
|
|
|
struct pipe_resource *src,
|
2012-09-12 22:37:17 +01:00
|
|
|
unsigned src_level,
|
2013-12-06 21:39:48 +00:00
|
|
|
const struct pipe_box *srcbox);
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2011-10-21 01:09:40 +01:00
|
|
|
/**
|
2012-12-19 22:06:51 +00:00
|
|
|
* 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.
|
2011-10-21 01:09:40 +01:00
|
|
|
*
|
|
|
|
* Drivers can use this to change resource properties (like format, width,
|
2011-10-21 02:32:29 +01:00
|
|
|
* height) by changing how the views interpret them, instead of changing
|
2012-12-19 22:06:51 +00:00
|
|
|
* pipe_resource directly. This is used to blit resources of formats which
|
|
|
|
* are not renderable.
|
2011-10-21 01:09:40 +01:00
|
|
|
*
|
2011-10-21 02:32:29 +01:00
|
|
|
* src_width0 and src_height0 are sampler_view-private properties that
|
|
|
|
* override pipe_resource. The blitter uses them for computation of texture
|
|
|
|
* coordinates. The dst dimensions are supplied through pipe_surface::width
|
|
|
|
* and height.
|
|
|
|
*
|
2012-07-28 00:19:18 +01:00
|
|
|
* The mask is a combination of the PIPE_MASK_* flags.
|
|
|
|
* Set to PIPE_MASK_RGBAZS if unsure.
|
2011-10-21 01:09:40 +01:00
|
|
|
*/
|
2012-09-12 22:37:17 +01:00
|
|
|
void util_blitter_blit_generic(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *dst,
|
2012-12-19 22:06:51 +00:00
|
|
|
const struct pipe_box *dstbox,
|
2012-09-12 22:37:17 +01:00
|
|
|
struct pipe_sampler_view *src,
|
|
|
|
const struct pipe_box *srcbox,
|
|
|
|
unsigned src_width0, unsigned src_height0,
|
|
|
|
unsigned mask, unsigned filter,
|
2014-11-08 12:02:47 +00:00
|
|
|
const struct pipe_scissor_state *scissor,
|
2022-07-19 05:19:34 +01:00
|
|
|
bool alpha_blend, bool sample0_only,
|
|
|
|
unsigned dst_sample);
|
2012-09-12 22:37:17 +01:00
|
|
|
|
|
|
|
void util_blitter_blit(struct blitter_context *blitter,
|
|
|
|
const struct pipe_blit_info *info);
|
2011-10-21 01:09:40 +01:00
|
|
|
|
2016-06-10 02:02:24 +01:00
|
|
|
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);
|
|
|
|
|
2011-12-29 17:07:22 +00:00
|
|
|
/**
|
|
|
|
* 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,
|
2012-12-19 21:25:22 +00:00
|
|
|
unsigned dstz);
|
2011-12-29 17:07:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to initialize a view for copy_texture_view.
|
|
|
|
* The parameters must match copy_texture_view.
|
|
|
|
*/
|
2017-05-30 22:52:07 +01:00
|
|
|
void util_blitter_default_src_texture(struct blitter_context *blitter,
|
|
|
|
struct pipe_sampler_view *src_templ,
|
2011-12-29 17:07:22 +00:00
|
|
|
struct pipe_resource *src,
|
|
|
|
unsigned srclevel);
|
|
|
|
|
2013-04-21 18:39:03 +01:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
/**
|
2010-05-28 23:02:05 +01:00
|
|
|
* Clear a region of a (color) surface to a constant value.
|
2009-12-10 09:25:33 +00:00
|
|
|
*
|
|
|
|
* These states must be saved in the blitter in addition to the state objects
|
|
|
|
* already required to be saved:
|
2011-10-07 18:10:41 +01:00
|
|
|
* - fragment shader
|
|
|
|
* - depth stencil alpha state
|
|
|
|
* - blend state
|
2009-12-10 09:25:33 +00:00
|
|
|
* - framebuffer state
|
|
|
|
*/
|
2010-06-03 15:33:25 +01:00
|
|
|
void util_blitter_clear_render_target(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *dst,
|
2011-09-16 09:39:34 +01:00
|
|
|
const union pipe_color_union *color,
|
2010-06-03 15:33:25 +01:00
|
|
|
unsigned dstx, unsigned dsty,
|
|
|
|
unsigned width, unsigned height);
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2010-05-28 23:02:05 +01:00
|
|
|
/**
|
|
|
|
* Clear a region of a depth-stencil surface, both stencil and depth
|
|
|
|
* or only one of them if this is a combined depth-stencil surface.
|
|
|
|
*
|
|
|
|
* These states must be saved in the blitter in addition to the state objects
|
|
|
|
* already required to be saved:
|
2011-10-07 18:10:41 +01:00
|
|
|
* - fragment shader
|
|
|
|
* - depth stencil alpha state
|
|
|
|
* - blend state
|
2010-05-28 23:02:05 +01:00
|
|
|
* - framebuffer state
|
|
|
|
*/
|
2010-06-03 15:33:25 +01:00
|
|
|
void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *dst,
|
|
|
|
unsigned clear_flags,
|
|
|
|
double depth,
|
|
|
|
unsigned stencil,
|
|
|
|
unsigned dstx, unsigned dsty,
|
|
|
|
unsigned width, unsigned height);
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2012-08-13 22:37:30 +01:00
|
|
|
/* The following functions are customized variants of the clear functions.
|
|
|
|
* Some drivers use them internally to do things like MSAA resolve
|
|
|
|
* and resource decompression. It usually consists of rendering a full-screen
|
|
|
|
* quad with a special blend or DSA state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Used by r300g for depth decompression. */
|
|
|
|
void util_blitter_custom_clear_depth(struct blitter_context *blitter,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
double depth, void *custom_dsa);
|
|
|
|
|
|
|
|
/* Used by r600g for depth decompression. */
|
2010-09-23 05:18:22 +01:00
|
|
|
void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *zsurf,
|
|
|
|
struct pipe_surface *cbsurf,
|
2012-08-09 16:17:18 +01:00
|
|
|
unsigned sample_mask,
|
2010-09-23 05:18:22 +01:00
|
|
|
void *dsa_stage, float depth);
|
|
|
|
|
2012-08-12 19:06:33 +01:00
|
|
|
/* Used by r600g for color decompression. */
|
|
|
|
void util_blitter_custom_color(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *dstsurf,
|
|
|
|
void *custom_blend);
|
|
|
|
|
2012-08-13 22:37:30 +01:00
|
|
|
/* Used by r600g for MSAA color resolve. */
|
|
|
|
void util_blitter_custom_resolve_color(struct blitter_context *blitter,
|
2012-08-09 16:21:10 +01:00
|
|
|
struct pipe_resource *dst,
|
|
|
|
unsigned dst_level,
|
|
|
|
unsigned dst_layer,
|
|
|
|
struct pipe_resource *src,
|
|
|
|
unsigned src_layer,
|
2012-08-30 04:38:02 +01:00
|
|
|
unsigned sampled_mask,
|
2012-10-12 05:04:01 +01:00
|
|
|
void *custom_blend,
|
|
|
|
enum pipe_format format);
|
2012-08-09 16:21:10 +01:00
|
|
|
|
2018-02-07 14:40:08 +00:00
|
|
|
/* Used by vc4 for 8/16-bit linear-to-tiled blits */
|
|
|
|
void util_blitter_custom_shader(struct blitter_context *blitter,
|
|
|
|
struct pipe_surface *dstsurf,
|
|
|
|
void *custom_vs, void *custom_fs);
|
|
|
|
|
2020-09-09 14:07:54 +01:00
|
|
|
/* Used by D3D12 for non-MSAA -> MSAA stencil blits */
|
|
|
|
void util_blitter_stencil_fallback(struct blitter_context *blitter,
|
|
|
|
struct pipe_resource *dst,
|
|
|
|
unsigned dst_level,
|
2020-09-28 20:38:38 +01:00
|
|
|
const struct pipe_box *dstbox,
|
2020-09-09 14:07:54 +01:00
|
|
|
struct pipe_resource *src,
|
|
|
|
unsigned src_level,
|
2020-10-01 12:02:34 +01:00
|
|
|
const struct pipe_box *srcbox,
|
|
|
|
const struct pipe_scissor_state *scissor);
|
2020-09-09 14:07:54 +01:00
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
/* The functions below should be used to save currently bound constant state
|
|
|
|
* objects inside a driver. The objects are automatically restored at the end
|
2010-05-25 22:10:49 +01:00
|
|
|
* of the util_blitter_{clear, copy_region, fill_region} functions and then
|
2009-12-10 09:25:33 +00:00
|
|
|
* forgotten.
|
|
|
|
*
|
2011-10-07 18:10:41 +01:00
|
|
|
* States not listed here are not affected by util_blitter. */
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_blend(struct blitter_context *blitter, void *state)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
|
|
|
blitter->saved_blend_state = state;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
|
|
|
|
void *state)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
|
|
|
blitter->saved_dsa_state = state;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_vertex_elements(struct blitter_context *blitter, void *state)
|
2010-03-01 17:40:22 +00:00
|
|
|
{
|
|
|
|
blitter->saved_velem_state = state;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_stencil_ref(struct blitter_context *blitter,
|
|
|
|
const struct pipe_stencil_ref *state)
|
2010-02-11 18:01:10 +00:00
|
|
|
{
|
|
|
|
blitter->saved_stencil_ref = *state;
|
|
|
|
}
|
|
|
|
|
2015-12-10 19:25:04 +00:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_rasterizer(struct blitter_context *blitter, void *state)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
|
|
|
blitter->saved_rs_state = state;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_fragment_shader(struct blitter_context *blitter, void *fs)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
|
|
|
blitter->saved_fs = fs;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_vertex_shader(struct blitter_context *blitter, void *vs)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
|
|
|
blitter->saved_vs = vs;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_geometry_shader(struct blitter_context *blitter, void *gs)
|
2011-10-07 18:28:19 +01:00
|
|
|
{
|
|
|
|
blitter->saved_gs = gs;
|
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2014-09-23 17:40:27 +01:00
|
|
|
util_blitter_save_tessctrl_shader(struct blitter_context *blitter,
|
|
|
|
void *sh)
|
|
|
|
{
|
|
|
|
blitter->saved_tcs = sh;
|
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2014-09-23 17:40:27 +01:00
|
|
|
util_blitter_save_tesseval_shader(struct blitter_context *blitter,
|
|
|
|
void *sh)
|
|
|
|
{
|
|
|
|
blitter->saved_tes = sh;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_framebuffer(struct blitter_context *blitter,
|
|
|
|
const struct pipe_framebuffer_state *state)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
2010-06-29 00:52:09 +01:00
|
|
|
blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */
|
2010-08-29 05:08:24 +01:00
|
|
|
util_copy_framebuffer_state(&blitter->saved_fb_state, state);
|
2009-12-10 09:25:33 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_viewport(struct blitter_context *blitter,
|
|
|
|
struct pipe_viewport_state *state)
|
2010-03-01 16:06:20 +00:00
|
|
|
{
|
|
|
|
blitter->saved_viewport = *state;
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:25:31 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_scissor(struct blitter_context *blitter,
|
|
|
|
struct pipe_scissor_state *state)
|
2012-09-12 22:37:17 +01:00
|
|
|
{
|
|
|
|
blitter->saved_scissor = *state;
|
|
|
|
}
|
|
|
|
|
2015-12-10 19:25:04 +00:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_fragment_sampler_states(
|
2009-12-10 09:25:33 +00:00
|
|
|
struct blitter_context *blitter,
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned num_sampler_states,
|
2009-12-10 09:25:33 +00:00
|
|
|
void **sampler_states)
|
|
|
|
{
|
2016-04-25 16:38:05 +01:00
|
|
|
assert(num_sampler_states <= ARRAY_SIZE(blitter->saved_sampler_states));
|
2009-12-10 09:25:33 +00:00
|
|
|
|
|
|
|
blitter->saved_num_sampler_states = num_sampler_states;
|
|
|
|
memcpy(blitter->saved_sampler_states, sampler_states,
|
|
|
|
num_sampler_states * sizeof(void *));
|
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2010-02-19 18:00:26 +00:00
|
|
|
util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned num_views,
|
2010-02-19 18:00:26 +00:00
|
|
|
struct pipe_sampler_view **views)
|
2009-12-10 09:25:33 +00:00
|
|
|
{
|
2010-06-29 00:52:09 +01:00
|
|
|
unsigned i;
|
2016-04-25 16:38:05 +01:00
|
|
|
assert(num_views <= ARRAY_SIZE(blitter->saved_sampler_views));
|
2009-12-10 09:25:33 +00:00
|
|
|
|
2010-02-19 18:00:26 +00:00
|
|
|
blitter->saved_num_sampler_views = num_views;
|
2010-06-29 00:52:09 +01:00
|
|
|
for (i = 0; i < num_views; i++)
|
|
|
|
pipe_sampler_view_reference(&blitter->saved_sampler_views[i],
|
|
|
|
views[i]);
|
2009-12-10 09:25:33 +00:00
|
|
|
}
|
|
|
|
|
2016-08-13 15:36:00 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_fragment_constant_buffer_slot(
|
|
|
|
struct blitter_context *blitter,
|
|
|
|
struct pipe_constant_buffer *constant_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));
|
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2012-03-29 16:51:50 +01:00
|
|
|
util_blitter_save_vertex_buffer_slot(struct blitter_context *blitter,
|
|
|
|
struct pipe_vertex_buffer *vertex_buffers)
|
2010-04-18 13:50:14 +01:00
|
|
|
{
|
2017-04-02 13:30:16 +01:00
|
|
|
pipe_vertex_buffer_reference(&blitter->saved_vertex_buffer,
|
|
|
|
&vertex_buffers[blitter->vb_slot]);
|
2010-04-18 13:50:14 +01:00
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2011-11-19 20:44:28 +00:00
|
|
|
util_blitter_save_so_targets(struct blitter_context *blitter,
|
2012-10-17 01:32:57 +01:00
|
|
|
unsigned num_targets,
|
2011-11-19 20:44:28 +00:00
|
|
|
struct pipe_stream_output_target **targets)
|
|
|
|
{
|
|
|
|
unsigned i;
|
2016-04-25 16:38:05 +01:00
|
|
|
assert(num_targets <= ARRAY_SIZE(blitter->saved_so_targets));
|
2011-11-19 20:44:28 +00:00
|
|
|
|
|
|
|
blitter->saved_num_so_targets = num_targets;
|
|
|
|
for (i = 0; i < num_targets; i++)
|
|
|
|
pipe_so_target_reference(&blitter->saved_so_targets[i],
|
|
|
|
targets[i]);
|
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2012-07-22 19:27:04 +01:00
|
|
|
util_blitter_save_sample_mask(struct blitter_context *blitter,
|
2021-10-29 15:59:51 +01:00
|
|
|
unsigned sample_mask, unsigned min_samples)
|
2012-07-22 19:27:04 +01:00
|
|
|
{
|
2017-08-17 14:36:20 +01:00
|
|
|
blitter->is_sample_mask_saved = true;
|
2012-07-22 19:27:04 +01:00
|
|
|
blitter->saved_sample_mask = sample_mask;
|
2021-10-29 15:59:51 +01:00
|
|
|
blitter->saved_min_samples = min_samples;
|
2012-07-22 19:27:04 +01:00
|
|
|
}
|
|
|
|
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2012-09-12 22:33:50 +01:00
|
|
|
util_blitter_save_render_condition(struct blitter_context *blitter,
|
|
|
|
struct pipe_query *query,
|
2017-08-17 14:36:20 +01:00
|
|
|
bool condition,
|
2017-03-05 20:07:28 +00:00
|
|
|
enum pipe_render_cond_flag mode)
|
2012-09-12 22:33:50 +01:00
|
|
|
{
|
|
|
|
blitter->saved_render_cond_query = query;
|
|
|
|
blitter->saved_render_cond_mode = mode;
|
2013-06-14 18:48:57 +01:00
|
|
|
blitter->saved_render_cond_cond = condition;
|
2012-09-12 22:33:50 +01:00
|
|
|
}
|
|
|
|
|
2018-08-06 09:16:47 +01:00
|
|
|
static inline void
|
|
|
|
util_blitter_save_window_rectangles(struct blitter_context *blitter,
|
|
|
|
boolean include,
|
|
|
|
unsigned num_rectangles,
|
|
|
|
const struct pipe_scissor_state *rects)
|
|
|
|
{
|
|
|
|
blitter->saved_window_rectangles_include = include;
|
|
|
|
blitter->saved_num_window_rectangles = num_rectangles;
|
|
|
|
if (num_rectangles > 0) {
|
|
|
|
assert(num_rectangles < ARRAY_SIZE(blitter->saved_window_rectangles));
|
|
|
|
memcpy(blitter->saved_window_rectangles, rects,
|
|
|
|
sizeof(*rects) * num_rectangles);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-13 15:51:51 +01:00
|
|
|
void util_blitter_common_clear_setup(struct blitter_context *blitter,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
unsigned clear_buffers,
|
|
|
|
void *custom_blend, void *custom_dsa);
|
|
|
|
|
2016-08-13 15:35:23 +01:00
|
|
|
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);
|
2016-08-13 15:36:00 +01:00
|
|
|
void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter);
|
2016-08-13 15:35:23 +01:00
|
|
|
|
2019-06-20 23:24:19 +01:00
|
|
|
/* These are supported combinations of blits from ZS to color and vice versa.
|
|
|
|
* The blitter will do the packing/unpacking of depth and stencil
|
|
|
|
* in the fragment shader.
|
|
|
|
*/
|
|
|
|
static inline enum pipe_format
|
|
|
|
util_blitter_get_color_format_for_zs(enum pipe_format format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case PIPE_FORMAT_Z16_UNORM:
|
|
|
|
return PIPE_FORMAT_R16_UNORM;
|
|
|
|
|
|
|
|
case PIPE_FORMAT_Z32_FLOAT:
|
|
|
|
return PIPE_FORMAT_R32_FLOAT;
|
|
|
|
|
|
|
|
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
|
|
|
|
case PIPE_FORMAT_Z24X8_UNORM:
|
|
|
|
case PIPE_FORMAT_S8_UINT_Z24_UNORM:
|
|
|
|
case PIPE_FORMAT_X8Z24_UNORM:
|
|
|
|
return PIPE_FORMAT_R32_UINT;
|
|
|
|
|
|
|
|
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
|
|
|
|
return PIPE_FORMAT_R32G32_UINT;
|
|
|
|
|
|
|
|
case PIPE_FORMAT_Z32_UNORM:
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2019-06-27 18:20:31 +01:00
|
|
|
return PIPE_FORMAT_NONE;
|
2019-06-20 23:24:19 +01:00
|
|
|
}
|
|
|
|
|
2009-12-10 09:25:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|