mesa/src/gallium/drivers/softpipe/sp_state.h

229 lines
6.5 KiB
C
Raw Normal View History

2008-03-14 21:54:02 +00:00
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
2008-03-14 21:54:02 +00:00
* All Rights Reserved.
*
* 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.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
2008-03-14 21:54:02 +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.
*
**************************************************************************/
/* Authors: Keith Whitwell <keithw@vmware.com>
2008-03-14 21:54:02 +00:00
*/
#ifndef SP_STATE_H
#define SP_STATE_H
#include "pipe/p_state.h"
#include "tgsi/tgsi_scan.h"
2008-03-14 21:54:02 +00:00
#define SP_NEW_VIEWPORT 0x1
#define SP_NEW_RASTERIZER 0x2
#define SP_NEW_FS 0x4
#define SP_NEW_BLEND 0x8
#define SP_NEW_CLIP 0x10
#define SP_NEW_SCISSOR 0x20
2008-03-14 21:54:02 +00:00
#define SP_NEW_FRAMEBUFFER 0x80
#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
#define SP_NEW_CONSTANTS 0x200
#define SP_NEW_SAMPLER 0x400
#define SP_NEW_TEXTURE 0x800
#define SP_NEW_VERTEX 0x1000
#define SP_NEW_VS 0x2000
#define SP_NEW_QUERY 0x4000
#define SP_NEW_GS 0x8000
#define SP_NEW_SO 0x10000
#define SP_NEW_SO_BUFFERS 0x20000
2008-03-14 21:54:02 +00:00
struct tgsi_sampler;
struct tgsi_image;
struct tgsi_buffer;
2008-03-14 21:54:02 +00:00
struct tgsi_exec_machine;
struct vertex_info;
2008-03-14 21:54:02 +00:00
struct sp_fragment_shader_variant_key
{
/* Standard C doesn't allow 0-size structs */
int dummy;
};
2008-03-14 21:54:02 +00:00
struct sp_fragment_shader_variant
{
const struct tgsi_token *tokens;
struct sp_fragment_shader_variant_key key;
2008-03-14 21:54:02 +00:00
struct tgsi_shader_info info;
/* See comments about this elsewhere */
#if 0
struct draw_fragment_shader *draw_shader;
#endif
void (*prepare)(const struct sp_fragment_shader_variant *shader,
struct tgsi_exec_machine *machine,
struct tgsi_sampler *sampler,
struct tgsi_image *image,
struct tgsi_buffer *buffer);
unsigned (*run)(const struct sp_fragment_shader_variant *shader,
struct tgsi_exec_machine *machine,
struct quad_header *quad,
bool early_depth_test);
2008-03-14 21:54:02 +00:00
/* Deletes this instance of the object */
void (*delete)(struct sp_fragment_shader_variant *shader,
struct tgsi_exec_machine *machine);
struct sp_fragment_shader_variant *next;
};
2008-03-14 21:54:02 +00:00
/** Subclass of pipe_shader_state */
struct sp_fragment_shader {
struct pipe_shader_state shader;
struct sp_fragment_shader_variant *variants;
struct draw_fragment_shader *draw_shader;
2008-03-14 21:54:02 +00:00
};
/** Subclass of pipe_shader_state */
struct sp_vertex_shader {
struct pipe_shader_state shader;
2008-03-14 21:54:02 +00:00
struct draw_vertex_shader *draw_data;
int max_sampler; /* -1 if no samplers */
2008-03-14 21:54:02 +00:00
};
/** Subclass of pipe_shader_state */
struct sp_geometry_shader {
struct pipe_shader_state shader;
struct draw_geometry_shader *draw_data;
int max_sampler;
};
2008-03-14 21:54:02 +00:00
struct sp_velems_state {
unsigned count;
struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
};
struct sp_so_state {
gallium: interface changes necessary to implement transform feedback (v5) Namely: - EXT_transform_feedback - ARB_transform_feedback2 - ARB_transform_feedback_instanced The old interface was not useful for OpenGL and had to be reworked. This interface was originally designed for OpenGL, but additional changes have been made in order to make st/d3d1x support easier. The most notable change is the stream-out info must be linked with a vertex or geometry shader and cannot be set independently. This is due to limitations of existing hardware (special shader instructions must be used to write into stream-out buffers), and it's also how OpenGL works (stream outputs must be specified prior to linking shaders). Other than that, each stream output buffer has a "view" into it that internally maintains the number of bytes which have been written into it. (one buffer can be bound in several different transform feedback objects in OpenGL, so we must be able to have several views around) The set_stream_output_targets function contains a parameter saying whether new data should be appended or not. Also, the view can optionally be used to provide the vertex count for draw_vbo. Note that the count is supposed to be stored in device memory and the CPU never gets to know its value. OpenGL way | Gallium way ------------------------------------ BeginTF = set_so_targets(append_bitmask = 0) PauseTF = set_so_targets(num_targets = 0) ResumeTF = set_so_targets(append_bitmask = ~0) EndTF = set_so_targets(num_targets = 0) DrawTF = use pipe_draw_info::count_from_stream_output v2: * removed the reset_stream_output_targets function * added a parameter append_bitmask to set_stream_output_targets, each bit specifies whether new data should be appended to each buffer or not. v3: * added PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME for ARB_tfb2, note that the draw-auto subset is always required (for d3d10), only the pause/resume functionality is limited if the CAP is not advertised v4: * update gallium/docs v5: * compactified struct pipe_stream_output_info, updated dump/trace
2011-12-15 17:42:21 +00:00
struct pipe_stream_output_info base;
};
/** Subclass of pipe_compute_state */
struct sp_compute_shader {
struct pipe_compute_state shader;
struct tgsi_token *tokens;
struct tgsi_shader_info info;
int max_sampler; /* -1 if no samplers */
};
2008-03-14 21:54:02 +00:00
void
softpipe_init_blend_funcs(struct pipe_context *pipe);
2008-03-14 21:54:02 +00:00
void
softpipe_init_clip_funcs(struct pipe_context *pipe);
void
softpipe_init_sampler_funcs(struct pipe_context *pipe);
void
softpipe_init_rasterizer_funcs(struct pipe_context *pipe);
2008-03-14 21:54:02 +00:00
void
2010-09-25 21:19:18 +01:00
softpipe_init_shader_funcs(struct pipe_context *pipe);
2008-03-14 21:54:02 +00:00
void
2010-09-25 21:19:18 +01:00
softpipe_init_streamout_funcs(struct pipe_context *pipe);
2008-03-14 21:54:02 +00:00
void
softpipe_init_vertex_funcs(struct pipe_context *pipe);
void
softpipe_init_image_funcs(struct pipe_context *pipe);
2010-09-25 21:19:18 +01:00
void
softpipe_set_framebuffer_state(struct pipe_context *,
const struct pipe_framebuffer_state *);
2008-03-14 21:54:02 +00:00
2010-09-25 21:19:18 +01:00
void
softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim);
2008-03-14 21:54:02 +00:00
void
softpipe_set_sampler_views(struct pipe_context *pipe,
enum pipe_shader_type shader,
unsigned start,
unsigned num,
unsigned unbind_num_trailing_slots,
bool take_ownership,
struct pipe_sampler_view **views);
void
softpipe_draw_vbo(struct pipe_context *pipe,
const struct pipe_draw_info *info,
unsigned drawid_offset,
const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws);
2008-03-14 21:54:02 +00:00
void
softpipe_map_texture_surfaces(struct softpipe_context *sp);
void
softpipe_unmap_texture_surfaces(struct softpipe_context *sp);
struct vertex_info *
softpipe_get_vbuf_vertex_info(struct softpipe_context *softpipe);
struct sp_fragment_shader_variant *
softpipe_find_fs_variant(struct softpipe_context *softpipe,
struct sp_fragment_shader *fs,
const struct sp_fragment_shader_variant_key *key);
void
softpipe_prepare_vertex_sampling(struct softpipe_context *ctx,
unsigned num,
struct pipe_sampler_view **views);
void
softpipe_cleanup_vertex_sampling(struct softpipe_context *ctx);
void
softpipe_prepare_geometry_sampling(struct softpipe_context *ctx,
unsigned num,
struct pipe_sampler_view **views);
void
softpipe_cleanup_geometry_sampling(struct softpipe_context *ctx);
void
softpipe_launch_grid(struct pipe_context *context,
const struct pipe_grid_info *info);
void
softpipe_update_compute_samplers(struct softpipe_context *softpipe);
2008-03-14 21:54:02 +00:00
#endif