diff options
author | Dave Airlie <airlied@redhat.com> | 2020-02-17 17:09:10 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2020-02-28 18:33:34 +1000 |
commit | 0d02a7b8ca794a594c2e9cc5e6d63dc591593105 (patch) | |
tree | 4b77dbbf1131ac8b22ef1db6be0f42a91b7a8f3e /src/gallium/auxiliary/draw/draw_llvm.h | |
parent | 76daf893ea0fdbbb53017d0395be7c23b80c256c (diff) |
draw: add main tessellation code
This is the bulk of the llvm shader builders and tessellation
execution code.
TCS uses a coroutine launcher like compute shaders to handle
barriers. It executes 4-wide with one input vertex per lane.
Tessellation happens before the TES is run.
TES is just a 4-wide launcher, one per primitive is executed,
with one lane per tessellation coordinate input.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3841>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_llvm.h')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.h | 187 |
1 files changed, 185 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 4e7859d5dac..d376a84c073 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -44,6 +44,8 @@ struct draw_llvm; struct llvm_vertex_shader; struct llvm_geometry_shader; +struct llvm_tess_ctrl_shader; +struct llvm_tess_eval_shader; struct draw_jit_texture { @@ -467,7 +469,7 @@ struct draw_llvm_variant_key unsigned clip_halfz:1; unsigned bypass_viewport:1; unsigned need_edgeflags:1; - unsigned has_gs:1; + unsigned has_gs_or_tes:1; unsigned num_outputs:8; unsigned ucp_enable:PIPE_MAX_CLIP_PLANES; /* note padding here - must use memset */ @@ -495,6 +497,24 @@ struct draw_gs_llvm_variant_key /* Followed by variable number of images.*/ }; +struct draw_tcs_llvm_variant_key +{ + unsigned nr_samplers:8; + unsigned nr_sampler_views:8; + unsigned nr_images:8; + struct draw_sampler_static_state samplers[1]; + /* Followed by variable number of images.*/ +}; + +struct draw_tes_llvm_variant_key +{ + unsigned nr_samplers:8; + unsigned nr_sampler_views:8; + unsigned nr_images:8; + struct draw_sampler_static_state samplers[1]; + /* Followed by variable number of images.*/ +}; + #define DRAW_LLVM_MAX_VARIANT_KEY_SIZE \ (sizeof(struct draw_llvm_variant_key) + \ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state) + \ @@ -506,6 +526,16 @@ struct draw_gs_llvm_variant_key PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state)) +#define DRAW_TCS_LLVM_MAX_VARIANT_KEY_SIZE \ + (sizeof(struct draw_tcs_llvm_variant_key) + \ + PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \ + PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state)) + +#define DRAW_TES_LLVM_MAX_VARIANT_KEY_SIZE \ + (sizeof(struct draw_tes_llvm_variant_key) + \ + PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \ + PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state)) + static inline size_t draw_llvm_variant_key_size(unsigned nr_vertex_elements, @@ -526,6 +556,21 @@ draw_gs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images) (nr_samplers - 1) * sizeof(struct draw_sampler_static_state)); } +static inline size_t +draw_tcs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images) +{ + return (sizeof(struct draw_tcs_llvm_variant_key) + + (nr_images) * sizeof(struct draw_sampler_static_state) + + (nr_samplers - 1) * sizeof(struct draw_sampler_static_state)); +} + +static inline size_t +draw_tes_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images) +{ + return (sizeof(struct draw_tes_llvm_variant_key) + + (nr_images) * sizeof(struct draw_sampler_static_state) + + (nr_samplers - 1) * sizeof(struct draw_sampler_static_state)); +} static inline struct draw_sampler_static_state * draw_llvm_variant_key_samplers(struct draw_llvm_variant_key *key) @@ -550,6 +595,20 @@ draw_gs_llvm_variant_key_images(struct draw_gs_llvm_variant_key *key) &key->samplers[key->nr_samplers]; } +static inline struct draw_image_static_state * +draw_tcs_llvm_variant_key_images(struct draw_tcs_llvm_variant_key *key) +{ + return (struct draw_image_static_state *) + &key->samplers[key->nr_samplers]; +} + +static inline struct draw_image_static_state * +draw_tes_llvm_variant_key_images(struct draw_tes_llvm_variant_key *key) +{ + return (struct draw_image_static_state *) + &key->samplers[key->nr_samplers]; +} + struct draw_llvm_variant_list_item { struct draw_llvm_variant *base; @@ -562,6 +621,17 @@ struct draw_gs_llvm_variant_list_item struct draw_gs_llvm_variant_list_item *next, *prev; }; +struct draw_tcs_llvm_variant_list_item +{ + struct draw_tcs_llvm_variant *base; + struct draw_tcs_llvm_variant_list_item *next, *prev; +}; + +struct draw_tes_llvm_variant_list_item +{ + struct draw_tes_llvm_variant *base; + struct draw_tes_llvm_variant_list_item *next, *prev; +}; struct draw_llvm_variant { @@ -612,6 +682,57 @@ struct draw_gs_llvm_variant struct draw_gs_llvm_variant_key key; }; +struct draw_tcs_llvm_variant +{ + struct gallivm_state *gallivm; + + /* LLVM JIT builder types */ + LLVMTypeRef context_ptr_type; + LLVMTypeRef input_array_type; + LLVMTypeRef output_array_type; + + LLVMValueRef context_ptr; + LLVMValueRef io_ptr; + LLVMValueRef num_prims; + LLVMValueRef function; + draw_tcs_jit_func jit_func; + + struct llvm_tess_ctrl_shader *shader; + + struct draw_llvm *llvm; + struct draw_tcs_llvm_variant_list_item list_item_global; + struct draw_tcs_llvm_variant_list_item list_item_local; + + /* key is variable-sized, must be last */ + struct draw_tcs_llvm_variant_key key; +}; + +struct draw_tes_llvm_variant +{ + struct gallivm_state *gallivm; + + /* LLVM JIT builder types */ + LLVMTypeRef context_ptr_type; + LLVMTypeRef vertex_header_ptr_type; + LLVMTypeRef input_array_type; + LLVMTypeRef patch_input_array_type; + + LLVMValueRef context_ptr; + LLVMValueRef io_ptr; + LLVMValueRef num_prims; + LLVMValueRef function; + draw_tes_jit_func jit_func; + + struct llvm_tess_eval_shader *shader; + + struct draw_llvm *llvm; + struct draw_tes_llvm_variant_list_item list_item_global; + struct draw_tes_llvm_variant_list_item list_item_local; + + /* key is variable-sized, must be last */ + struct draw_tes_llvm_variant_key key; +}; + struct llvm_vertex_shader { struct draw_vertex_shader base; @@ -630,6 +751,23 @@ struct llvm_geometry_shader { unsigned variants_cached; }; +struct llvm_tess_ctrl_shader { + struct draw_tess_ctrl_shader base; + + unsigned variant_key_size; + struct draw_tcs_llvm_variant_list_item variants; + unsigned variants_created; + unsigned variants_cached; +}; + +struct llvm_tess_eval_shader { + struct draw_tess_eval_shader base; + + unsigned variant_key_size; + struct draw_tes_llvm_variant_list_item variants; + unsigned variants_created; + unsigned variants_cached; +}; struct draw_llvm { struct draw_context *draw; @@ -639,12 +777,20 @@ struct draw_llvm { struct draw_jit_context jit_context; struct draw_gs_jit_context gs_jit_context; + struct draw_tcs_jit_context tcs_jit_context; + struct draw_tes_jit_context tes_jit_context; struct draw_llvm_variant_list_item vs_variants_list; int nr_variants; struct draw_gs_llvm_variant_list_item gs_variants_list; int nr_gs_variants; + + struct draw_tcs_llvm_variant_list_item tcs_variants_list; + int nr_tcs_variants; + + struct draw_tes_llvm_variant_list_item tes_variants_list; + int nr_tes_variants; }; @@ -660,8 +806,17 @@ llvm_geometry_shader(struct draw_geometry_shader *gs) return (struct llvm_geometry_shader *)gs; } +static inline struct llvm_tess_ctrl_shader * +llvm_tess_ctrl_shader(struct draw_tess_ctrl_shader *tcs) +{ + return (struct llvm_tess_ctrl_shader *)tcs; +} - +static inline struct llvm_tess_eval_shader * +llvm_tess_eval_shader(struct draw_tess_eval_shader *tes) +{ + return (struct llvm_tess_eval_shader *)tes; +} struct draw_llvm * draw_llvm_create(struct draw_context *draw, LLVMContextRef llvm_context); @@ -698,6 +853,34 @@ draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store); void draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key); +struct draw_tcs_llvm_variant * +draw_tcs_llvm_create_variant(struct draw_llvm *llvm, + unsigned num_vertex_header_attribs, + const struct draw_tcs_llvm_variant_key *key); + +void +draw_tcs_llvm_destroy_variant(struct draw_tcs_llvm_variant *variant); + +struct draw_tcs_llvm_variant_key * +draw_tcs_llvm_make_variant_key(struct draw_llvm *llvm, char *store); + +void +draw_tcs_llvm_dump_variant_key(struct draw_tcs_llvm_variant_key *key); + +struct draw_tes_llvm_variant * +draw_tes_llvm_create_variant(struct draw_llvm *llvm, + unsigned num_vertex_header_attribs, + const struct draw_tes_llvm_variant_key *key); + +void +draw_tes_llvm_destroy_variant(struct draw_tes_llvm_variant *variant); + +struct draw_tes_llvm_variant_key * +draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store); + +void +draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key); + struct lp_build_sampler_soa * draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state); |