diff options
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/draw/draw_private.h')
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/draw/draw_private.h | 230 |
1 files changed, 91 insertions, 139 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_private.h b/lib/mesa/src/gallium/auxiliary/draw/draw_private.h index 1780070fa..9d3a465c5 100644 --- a/lib/mesa/src/gallium/auxiliary/draw/draw_private.h +++ b/lib/mesa/src/gallium/auxiliary/draw/draw_private.h @@ -43,16 +43,19 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" +#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_scan.h" +#include "draw_vertex_header.h" #ifdef DRAW_LLVM_AVAILABLE struct gallivm_state; #endif - -/** Sum of frustum planes and user-defined planes */ -#define DRAW_TOTAL_CLIP_PLANES (6 + PIPE_MAX_CLIP_PLANES) +/** + * The max stage the draw stores resources for. + * i.e. vs, tcs, tes, gs. no fs/cs/ms/ts. + */ +#define DRAW_MAX_SHADER_STAGE (PIPE_SHADER_GEOMETRY + 1) /** * The largest possible index of a vertex that can be fetched. @@ -102,6 +105,8 @@ struct tgsi_sampler; struct tgsi_image; struct tgsi_buffer; struct lp_cached_code; +struct draw_vertex_info; +struct draw_prim_info; /** * Represents the mapped vertex buffer. @@ -111,20 +116,6 @@ struct draw_vertex_buffer { uint32_t size; }; -/** - * Basic vertex info. Used to represent vertices after VS (through GS, TESS, - * etc.) to vbuf output. - */ -struct vertex_header { - unsigned clipmask:DRAW_TOTAL_CLIP_PLANES; - unsigned edgeflag:1; - unsigned pad:1; - unsigned vertex_id:16; - - float clip_pos[4]; - float data[][4]; // the vertex attributes -}; - /* NOTE: It should match vertex_id size above */ #define UNDEFINED_VERTEX_ID 0xffff @@ -132,6 +123,11 @@ struct vertex_header { /* maximum number of shader variants we can cache */ #define DRAW_MAX_SHADER_VARIANTS 512 +struct draw_buffer_info { + const void *ptr; + unsigned size; +}; + /** * Private context for the drawing module. */ @@ -163,9 +159,9 @@ struct draw_context float wide_point_threshold; /**< convert pnts to tris if larger than this */ float wide_line_threshold; /**< convert lines to tris if wider than this */ - boolean wide_point_sprites; /**< convert points to tris for sprite mode */ - boolean line_stipple; /**< do line stipple? */ - boolean point_sprite; /**< convert points to quads for sprites? */ + bool wide_point_sprites; /**< convert points to tris for sprite mode */ + bool line_stipple; /**< do line stipple? */ + bool point_sprite; /**< convert points to quads for sprites? */ /* Temporary storage while the pipeline is being run: */ @@ -181,17 +177,19 @@ struct draw_context struct { /* Current active frontend */ struct draw_pt_front_end *frontend; - enum pipe_prim_type prim; + enum mesa_prim prim; + uint8_t vertices_per_patch; + bool rebind_parameters; + unsigned opt; /**< bitmask of PT_x flags */ unsigned eltSize; /* saved eltSize for flushing */ unsigned viewid; /* saved viewid for flushing */ - ubyte vertices_per_patch; - boolean rebind_parameters; struct { struct draw_pt_middle_end *fetch_shade_emit; struct draw_pt_middle_end *general; struct draw_pt_middle_end *llvm; + struct draw_pt_middle_end *mesh; } middle; struct { @@ -209,9 +207,13 @@ struct draw_context */ unsigned max_index; + unsigned vertex_strides[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned nr_vertex_elements; + bool test_fse; /* enable FSE even though its not correct (eg for softpipe) */ + bool no_fse; /* disable FSE even when it is correct */ + /* user-space vertex data, buffers */ struct { /** vertex element/index buffer (ex: glDrawElements) */ @@ -231,58 +233,41 @@ struct draw_context struct draw_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS]; /** constant buffers for each shader stage */ - const void *vs_constants[PIPE_MAX_CONSTANT_BUFFERS]; - unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; - const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS]; - unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; - const void *tcs_constants[PIPE_MAX_CONSTANT_BUFFERS]; - unsigned tcs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; - const void *tes_constants[PIPE_MAX_CONSTANT_BUFFERS]; - unsigned tes_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; - - /** shader buffers for each shader stage */ - const void *vs_ssbos[PIPE_MAX_SHADER_BUFFERS]; - unsigned vs_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; - const void *gs_ssbos[PIPE_MAX_SHADER_BUFFERS]; - unsigned gs_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; - const void *tcs_ssbos[PIPE_MAX_SHADER_BUFFERS]; - unsigned tcs_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; - const void *tes_ssbos[PIPE_MAX_SHADER_BUFFERS]; - unsigned tes_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; + struct draw_buffer_info constants[DRAW_MAX_SHADER_STAGE][PIPE_MAX_CONSTANT_BUFFERS]; + struct draw_buffer_info ssbos[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_BUFFERS]; /* pointer to planes */ float (*planes)[DRAW_TOTAL_CLIP_PLANES][4]; } user; - - boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */ - boolean no_fse; /* disable FSE even when it is correct */ } pt; struct { - boolean bypass_clip_xy; - boolean bypass_clip_z; - boolean guard_band_xy; - boolean bypass_clip_points; + bool bypass_clip_xy; + bool bypass_clip_z; + bool guard_band_xy; + bool bypass_clip_points_lines; } driver; - boolean quads_always_flatshade_last; + bool quads_always_flatshade_last; - boolean flushing; /**< debugging/sanity */ - boolean suspend_flushing; /**< internally set */ + bool flushing; /**< debugging/sanity */ + bool suspend_flushing; /**< internally set */ /* Flags set if API requires clipping in these planes and the * driver doesn't indicate that it can do it for us. */ - boolean clip_xy; - boolean clip_z; - boolean clip_user; - boolean guard_band_xy; - boolean guard_band_points_xy; + bool clip_xy; + bool clip_z; + bool clip_user; + bool guard_band_xy; + bool guard_band_points_lines_xy; - boolean dump_vs; + bool dump_vs; + bool identity_viewport; + bool bypass_viewport; /** Depth format and bias related settings. */ - boolean floating_point_depth; + bool floating_point_depth; double mrd; /**< minimum resolvable depth value, for polygon offset */ /** Current rasterizer state given to us by the driver */ @@ -294,17 +279,15 @@ struct draw_context void *rasterizer_no_cull[2][2][2]; struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS]; - boolean identity_viewport; - boolean bypass_viewport; /** Vertex shader state */ struct { struct draw_vertex_shader *vertex_shader; - uint num_vs_outputs; /**< convenience, from vertex_shader */ - uint position_output; - uint edgeflag_output; - uint clipvertex_output; - uint ccdistance_output[2]; + unsigned num_vs_outputs; /**< convenience, from vertex_shader */ + unsigned position_output; + unsigned edgeflag_output; + unsigned clipvertex_output; + unsigned ccdistance_output[2]; /** Fields for TGSI interpreter / execution */ struct { @@ -324,9 +307,9 @@ struct draw_context /** Geometry shader state */ struct { struct draw_geometry_shader *geometry_shader; - uint num_gs_outputs; /**< convenience, from geometry_shader */ - uint position_output; - uint clipvertex_output; + unsigned num_gs_outputs; /**< convenience, from geometry_shader */ + unsigned position_output; + unsigned clipvertex_output; /** Fields for TGSI interpreter / execution */ struct { @@ -341,31 +324,13 @@ struct draw_context /* Tessellation state */ struct { struct draw_tess_ctrl_shader *tess_ctrl_shader; - - /** Fields for TGSI interpreter / execution */ - struct { - struct tgsi_exec_machine *machine; - - struct tgsi_sampler *sampler; - struct tgsi_image *image; - struct tgsi_buffer *buffer; - } tgsi; } tcs; struct { struct draw_tess_eval_shader *tess_eval_shader; - uint num_tes_outputs; /**< convenience, from tess_eval_shader */ - uint position_output; - uint clipvertex_output; - - /** Fields for TGSI interpreter / execution */ - struct { - struct tgsi_exec_machine *machine; - - struct tgsi_sampler *sampler; - struct tgsi_image *image; - struct tgsi_buffer *buffer; - } tgsi; + unsigned num_tes_outputs; /**< convenience, from tess_eval_shader */ + unsigned position_output; + unsigned clipvertex_output; } tes; /** Fragment shader state */ @@ -373,10 +338,17 @@ struct draw_context struct draw_fragment_shader *fragment_shader; } fs; + struct { + struct draw_mesh_shader *mesh_shader; + unsigned num_ms_outputs; /**< convenience, from geometry_shader */ + unsigned position_output; + unsigned clipvertex_output; + } ms; + /** Stream output (vertex feedback) state */ struct { struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]; - uint num_targets; + unsigned num_targets; } so; /* Clip derived state: @@ -386,10 +358,10 @@ struct draw_context /* If a prim stage introduces new vertex attributes, they'll be stored here */ struct { - uint num; - uint semantic_name[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; - uint semantic_index[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; - uint slot[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; + unsigned num; + enum tgsi_semantic semantic_name[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; + unsigned semantic_index[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; + unsigned slot[DRAW_MAX_EXTRA_SHADER_OUTPUTS]; } extra_shader_outputs; unsigned instance_id; @@ -403,20 +375,20 @@ struct draw_context * we only handle vertex and geometry shaders in the draw module, but * there may be more in the future (ex: hull and tessellation). */ - struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; - unsigned num_sampler_views[PIPE_SHADER_TYPES]; - const struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - unsigned num_samplers[PIPE_SHADER_TYPES]; + struct pipe_sampler_view *sampler_views[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_SAMPLER_VIEWS]; + unsigned num_sampler_views[DRAW_MAX_SHADER_STAGE]; + const struct pipe_sampler_state *samplers[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SAMPLERS]; + unsigned num_samplers[DRAW_MAX_SHADER_STAGE]; - struct pipe_image_view *images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES]; - unsigned num_images[PIPE_SHADER_TYPES]; + struct pipe_image_view *images[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_IMAGES]; + unsigned num_images[DRAW_MAX_SHADER_STAGE]; struct pipe_query_data_pipeline_statistics statistics; - boolean collect_statistics; + bool collect_statistics; + bool collect_primgen; float default_outer_tess_level[4]; float default_inner_tess_level[2]; - bool collect_primgen; struct draw_assembler *ia; @@ -433,55 +405,34 @@ struct draw_context struct draw_fetch_info { - boolean linear; + bool linear; unsigned start; const unsigned *elts; unsigned count; }; -struct draw_vertex_info { - struct vertex_header *verts; - unsigned vertex_size; - unsigned stride; - unsigned count; -}; - /* these flags are set if the primitive is a segment of a larger one */ #define DRAW_SPLIT_BEFORE 0x1 #define DRAW_SPLIT_AFTER 0x2 #define DRAW_LINE_LOOP_AS_STRIP 0x4 -struct draw_prim_info { - boolean linear; - unsigned start; - - const ushort *elts; - unsigned count; - - enum pipe_prim_type prim; - unsigned flags; - unsigned *primitive_lengths; - unsigned primitive_count; -}; - - /******************************************************************************* * Draw common initialization code */ -boolean draw_init(struct draw_context *draw); +bool draw_init(struct draw_context *draw); void draw_new_instance(struct draw_context *draw); /******************************************************************************* * Vertex shader code: */ -boolean draw_vs_init(struct draw_context *draw); +bool draw_vs_init(struct draw_context *draw); void draw_vs_destroy(struct draw_context *draw); /******************************************************************************* * Geometry shading code: */ -boolean draw_gs_init(struct draw_context *draw); +bool draw_gs_init(struct draw_context *draw); void draw_gs_destroy(struct draw_context *draw); @@ -489,24 +440,25 @@ void draw_gs_destroy(struct draw_context *draw); /******************************************************************************* * Common shading code: */ -uint draw_current_shader_outputs(const struct draw_context *draw); -uint draw_current_shader_position_output(const struct draw_context *draw); -uint draw_current_shader_viewport_index_output(const struct draw_context *draw); -uint draw_current_shader_clipvertex_output(const struct draw_context *draw); -uint draw_current_shader_ccdistance_output(const struct draw_context *draw, int index); -uint draw_current_shader_num_written_clipdistances(const struct draw_context *draw); -uint draw_current_shader_num_written_culldistances(const struct draw_context *draw); +unsigned draw_current_shader_outputs(const struct draw_context *draw); +unsigned draw_current_shader_position_output(const struct draw_context *draw); +unsigned draw_current_shader_viewport_index_output(const struct draw_context *draw); +unsigned draw_current_shader_clipvertex_output(const struct draw_context *draw); +unsigned draw_current_shader_ccdistance_output(const struct draw_context *draw, int index); +unsigned draw_current_shader_num_written_clipdistances(const struct draw_context *draw); +unsigned draw_current_shader_num_written_culldistances(const struct draw_context *draw); int draw_alloc_extra_vertex_attrib(struct draw_context *draw, - uint semantic_name, uint semantic_index); + enum tgsi_semantic semantic_name, + unsigned semantic_index); void draw_remove_extra_vertex_attribs(struct draw_context *draw); -boolean draw_current_shader_uses_viewport_index( +bool draw_current_shader_uses_viewport_index( const struct draw_context *draw); /******************************************************************************* * Vertex processing (was passthrough) code: */ -boolean draw_pt_init(struct draw_context *draw); +bool draw_pt_init(struct draw_context *draw); void draw_pt_destroy(struct draw_context *draw); void draw_pt_reset_vertex_ids(struct draw_context *draw); void draw_pt_flush(struct draw_context *draw, unsigned flags); @@ -516,7 +468,7 @@ void draw_pt_flush(struct draw_context *draw, unsigned flags); * Primitive processing (pipeline) code: */ -boolean draw_pipeline_init(struct draw_context *draw); +bool draw_pipeline_init(struct draw_context *draw); void draw_pipeline_destroy(struct draw_context *draw); /* |