aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-07-31 08:23:29 +1000
committerDave Airlie <[email protected]>2019-10-15 04:43:30 +1000
commitc2efc7c6378ea5cc49c801153129c0f0cc2f3b23 (patch)
tree3d1dd9097636fc5298a4bda1615f038974b8ee4e /src/gallium
parentac7af7c50057f4b72ec058fd08b6f40db595e489 (diff)
gallivm/draw/swr: make the gs_iface not depend on tgsi.
This gs_iface doesn't seem to require a dependence on the tgsi context, except for the swr end prim code. This refactors the API to include all the info that the swr code needs in the interface rather than having to dig it out of the struct inheritance. This is a precursor to adding NIR support to llvmpipe. Reviewed-by: Jan Zielinski <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c35
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h28
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c16
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp84
4 files changed, 83 insertions, 80 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 0416e002cd7..25b0f0f07b5 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -67,14 +67,14 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *var);
struct draw_gs_llvm_iface {
- struct lp_build_tgsi_gs_iface base;
+ struct lp_build_gs_iface base;
struct draw_gs_llvm_variant *variant;
LLVMValueRef input;
};
static inline const struct draw_gs_llvm_iface *
-draw_gs_llvm_iface(const struct lp_build_tgsi_gs_iface *iface)
+draw_gs_llvm_iface(const struct lp_build_gs_iface *iface)
{
return (const struct draw_gs_llvm_iface *)iface;
}
@@ -1462,8 +1462,8 @@ clipmask_booli8(struct gallivm_state *gallivm,
}
static LLVMValueRef
-draw_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+draw_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
boolean is_vindex_indirect,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
@@ -1471,15 +1471,15 @@ draw_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
LLVMValueRef swizzle_index)
{
const struct draw_gs_llvm_iface *gs = draw_gs_llvm_iface(gs_iface);
- struct gallivm_state *gallivm = bld_base->base.gallivm;
+ struct gallivm_state *gallivm = bld->gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef indices[3];
LLVMValueRef res;
- struct lp_type type = bld_base->base.type;
+ struct lp_type type = bld->type;
if (is_vindex_indirect || is_aindex_indirect) {
int i;
- res = bld_base->base.zero;
+ res = bld->zero;
for (i = 0; i < type.length; ++i) {
LLVMValueRef idx = lp_build_const_int32(gallivm, i);
LLVMValueRef vert_chan_index = vertex_index;
@@ -1518,8 +1518,8 @@ draw_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
}
static void
-draw_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+draw_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
LLVMValueRef (*outputs)[4],
LLVMValueRef emitted_vertices_vec)
{
@@ -1527,7 +1527,7 @@ draw_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
struct draw_gs_llvm_variant *variant = gs_iface->variant;
struct gallivm_state *gallivm = variant->gallivm;
LLVMBuilderRef builder = gallivm->builder;
- struct lp_type gs_type = bld_base->base.type;
+ struct lp_type gs_type = bld->type;
LLVMValueRef clipmask = lp_build_const_int_vec(gallivm,
lp_int_type(gs_type), 0);
LLVMValueRef indices[LP_MAX_VECTOR_LENGTH];
@@ -1552,10 +1552,12 @@ draw_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
}
static void
-draw_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+draw_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
+ LLVMValueRef total_emitted_vertices_vec_ptr,
LLVMValueRef verts_per_prim_vec,
- LLVMValueRef emitted_prims_vec)
+ LLVMValueRef emitted_prims_vec,
+ LLVMValueRef mask_vec)
{
const struct draw_gs_llvm_iface *gs_iface = draw_gs_llvm_iface(gs_base);
struct draw_gs_llvm_variant *variant = gs_iface->variant;
@@ -1565,7 +1567,7 @@ draw_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
draw_gs_jit_prim_lengths(variant->gallivm, variant->context_ptr);
unsigned i;
- for (i = 0; i < bld_base->base.type.length; ++i) {
+ for (i = 0; i < bld->type.length; ++i) {
LLVMValueRef ind = lp_build_const_int32(gallivm, i);
LLVMValueRef prims_emitted =
LLVMBuildExtractElement(builder, emitted_prims_vec, ind, "");
@@ -1581,8 +1583,7 @@ draw_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
}
static void
-draw_gs_llvm_epilogue(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+draw_gs_llvm_epilogue(const struct lp_build_gs_iface *gs_base,
LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef emitted_prims_vec)
{
@@ -2508,7 +2509,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
params.context_ptr = context_ptr;
params.sampler = sampler;
params.info = &llvm->draw->gs.geometry_shader->info;
- params.gs_iface = (const struct lp_build_tgsi_gs_iface *)&gs_iface;
+ params.gs_iface = (const struct lp_build_gs_iface *)&gs_iface;
params.ssbo_ptr = ssbos_ptr;
params.ssbo_sizes_ptr = num_ssbos_ptr;
params.image = image;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 9d6dfaa390c..940a4c49a50 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -66,8 +66,7 @@ struct tgsi_shader_info;
struct lp_build_mask_context;
struct gallivm_state;
struct lp_derivatives;
-struct lp_build_tgsi_gs_iface;
-struct lp_build_coro_suspend_info;
+struct lp_build_gs_iface;
enum lp_build_tex_modifier {
LP_BLD_TEX_MODIFIER_NONE = 0,
@@ -247,7 +246,7 @@ struct lp_build_tgsi_params {
LLVMValueRef thread_data_ptr;
const struct lp_build_sampler_soa *sampler;
const struct tgsi_shader_info *info;
- const struct lp_build_tgsi_gs_iface *gs_iface;
+ const struct lp_build_gs_iface *gs_iface;
LLVMValueRef ssbo_ptr;
LLVMValueRef ssbo_sizes_ptr;
const struct lp_build_image_soa *image;
@@ -435,25 +434,26 @@ struct lp_build_tgsi_context
void (*emit_epilogue)(struct lp_build_tgsi_context*);
};
-struct lp_build_tgsi_gs_iface
+struct lp_build_gs_iface
{
- LLVMValueRef (*fetch_input)(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+ LLVMValueRef (*fetch_input)(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
boolean is_vindex_indirect,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
LLVMValueRef swizzle_index);
- void (*emit_vertex)(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+ void (*emit_vertex)(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
LLVMValueRef (*outputs)[4],
LLVMValueRef emitted_vertices_vec);
- void (*end_primitive)(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+ void (*end_primitive)(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
+ LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef verts_per_prim_vec,
- LLVMValueRef emitted_prims_vec);
- void (*gs_epilogue)(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+ LLVMValueRef emitted_prims_vec,
+ LLVMValueRef mask_vec);
+ void (*gs_epilogue)(const struct lp_build_gs_iface *gs_iface,
LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef emitted_prims_vec);
};
@@ -465,7 +465,7 @@ struct lp_build_tgsi_soa_context
/* Builder for scalar elements of shader's data type (float) */
struct lp_build_context elem_bld;
- const struct lp_build_tgsi_gs_iface *gs_iface;
+ const struct lp_build_gs_iface *gs_iface;
LLVMValueRef emitted_prims_vec_ptr;
LLVMValueRef total_emitted_vertices_vec_ptr;
LLVMValueRef emitted_vertices_vec_ptr;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 9bfe41b9062..8066d59ee67 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1581,7 +1581,7 @@ emit_fetch_gs_input(
vertex_index = lp_build_const_int32(gallivm, reg->Dimension.Index);
}
- res = bld->gs_iface->fetch_input(bld->gs_iface, bld_base,
+ res = bld->gs_iface->fetch_input(bld->gs_iface, &bld_base->base,
reg->Dimension.Indirect,
vertex_index,
reg->Register.Indirect,
@@ -1592,7 +1592,7 @@ emit_fetch_gs_input(
if (tgsi_type_is_64bit(stype)) {
LLVMValueRef swizzle_index = lp_build_const_int32(gallivm, swizzle_in >> 16);
LLVMValueRef res2;
- res2 = bld->gs_iface->fetch_input(bld->gs_iface, bld_base,
+ res2 = bld->gs_iface->fetch_input(bld->gs_iface, &bld_base->base,
reg->Dimension.Indirect,
vertex_index,
reg->Register.Indirect,
@@ -3984,7 +3984,7 @@ emit_vertex(
mask = clamp_mask_to_max_output_vertices(bld, mask,
total_emitted_vertices_vec);
gather_outputs(bld);
- bld->gs_iface->emit_vertex(bld->gs_iface, &bld->bld_base,
+ bld->gs_iface->emit_vertex(bld->gs_iface, &bld->bld_base.base,
bld->outputs,
total_emitted_vertices_vec);
increment_vec_ptr_by_mask(bld_base, bld->emitted_vertices_vec_ptr,
@@ -4016,7 +4016,8 @@ end_primitive_masked(struct lp_build_tgsi_context * bld_base,
LLVMBuildLoad(builder, bld->emitted_vertices_vec_ptr, "");
LLVMValueRef emitted_prims_vec =
LLVMBuildLoad(builder, bld->emitted_prims_vec_ptr, "");
-
+ LLVMValueRef total_emitted_vertices_vec =
+ LLVMBuildLoad(builder, bld->total_emitted_vertices_vec_ptr, "");
LLVMValueRef emitted_mask = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL,
emitted_vertices_vec,
uint_bld->zero);
@@ -4026,9 +4027,11 @@ end_primitive_masked(struct lp_build_tgsi_context * bld_base,
executes only on the paths that have unflushed vertices */
mask = LLVMBuildAnd(builder, mask, emitted_mask, "");
- bld->gs_iface->end_primitive(bld->gs_iface, &bld->bld_base,
+ bld->gs_iface->end_primitive(bld->gs_iface, &bld->bld_base.base,
+ total_emitted_vertices_vec,
emitted_vertices_vec,
- emitted_prims_vec);
+ emitted_prims_vec,
+ mask_vec(bld_base));
#if DUMP_GS_EMITS
lp_build_print_value(bld->bld_base.base.gallivm,
@@ -4371,7 +4374,6 @@ static void emit_epilogue(struct lp_build_tgsi_context * bld_base)
LLVMBuildLoad(builder, bld->emitted_prims_vec_ptr, "");
bld->gs_iface->gs_epilogue(bld->gs_iface,
- &bld->bld_base,
total_emitted_vertices_vec,
emitted_prims_vec);
} else {
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index 9b4eb047e21..c8e34b8adb8 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -240,35 +240,36 @@ struct BuilderSWR : public Builder {
PFN_GS_FUNC CompileGS(struct swr_context *ctx, swr_jit_gs_key &key);
LLVMValueRef
- swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+ swr_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
boolean is_vindex_indirect,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
LLVMValueRef swizzle_index);
void
- swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+ swr_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
LLVMValueRef (*outputs)[4],
LLVMValueRef emitted_vertices_vec);
void
- swr_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+ swr_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
+ LLVMValueRef total_emitted_vertices_vec_ptr,
LLVMValueRef verts_per_prim_vec,
- LLVMValueRef emitted_prims_vec);
+ LLVMValueRef emitted_prims_vec,
+ LLVMValueRef mask_vec);
void
- swr_gs_llvm_epilogue(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+ swr_gs_llvm_epilogue(const struct lp_build_gs_iface *gs_base,
LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef emitted_prims_vec);
};
struct swr_gs_llvm_iface {
- struct lp_build_tgsi_gs_iface base;
+ struct lp_build_gs_iface base;
struct tgsi_shader_info *info;
BuilderSWR *pBuilder;
@@ -283,8 +284,8 @@ struct swr_gs_llvm_iface {
// trampoline functions so we can use the builder llvm construction methods
static LLVMValueRef
-swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+swr_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
boolean is_vindex_indirect,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
@@ -293,7 +294,7 @@ swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
{
swr_gs_llvm_iface *iface = (swr_gs_llvm_iface*)gs_iface;
- return iface->pBuilder->swr_gs_llvm_fetch_input(gs_iface, bld_base,
+ return iface->pBuilder->swr_gs_llvm_fetch_input(gs_iface, bld,
is_vindex_indirect,
vertex_index,
is_aindex_indirect,
@@ -302,47 +303,50 @@ swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
}
static void
-swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+swr_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
LLVMValueRef (*outputs)[4],
LLVMValueRef emitted_vertices_vec)
{
swr_gs_llvm_iface *iface = (swr_gs_llvm_iface*)gs_base;
- iface->pBuilder->swr_gs_llvm_emit_vertex(gs_base, bld_base,
+ iface->pBuilder->swr_gs_llvm_emit_vertex(gs_base, bld,
outputs,
emitted_vertices_vec);
}
static void
-swr_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+swr_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
+ LLVMValueRef total_emitted_vertices_vec_ptr,
LLVMValueRef verts_per_prim_vec,
- LLVMValueRef emitted_prims_vec)
+ LLVMValueRef emitted_prims_vec,
+ LLVMValueRef mask_vec)
{
swr_gs_llvm_iface *iface = (swr_gs_llvm_iface*)gs_base;
- iface->pBuilder->swr_gs_llvm_end_primitive(gs_base, bld_base,
+ iface->pBuilder->swr_gs_llvm_end_primitive(gs_base, bld,
+ total_emitted_vertices_vec_ptr,
verts_per_prim_vec,
- emitted_prims_vec);
+ emitted_prims_vec,
+ mask_vec);
}
static void
-swr_gs_llvm_epilogue(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+swr_gs_llvm_epilogue(const struct lp_build_gs_iface *gs_base,
LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef emitted_prims_vec)
{
swr_gs_llvm_iface *iface = (swr_gs_llvm_iface*)gs_base;
- iface->pBuilder->swr_gs_llvm_epilogue(gs_base, bld_base,
+ iface->pBuilder->swr_gs_llvm_epilogue(gs_base,
total_emitted_vertices_vec,
emitted_prims_vec);
}
LLVMValueRef
-BuilderSWR::swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_iface,
- struct lp_build_tgsi_context * bld_base,
+BuilderSWR::swr_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
+ struct lp_build_context * bld,
boolean is_vindex_indirect,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
@@ -357,8 +361,8 @@ BuilderSWR::swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_ifac
if (is_vindex_indirect || is_aindex_indirect) {
int i;
- Value *res = unwrap(bld_base->base.zero);
- struct lp_type type = bld_base->base.type;
+ Value *res = unwrap(bld->zero);
+ struct lp_type type = bld->type;
for (i = 0; i < type.length; i++) {
Value *vert_chan_index = vert_index;
@@ -404,8 +408,8 @@ BuilderSWR::swr_gs_llvm_fetch_input(const struct lp_build_tgsi_gs_iface *gs_ifac
#define CONTROL_HEADER_SIZE (8*32)
void
-BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
LLVMValueRef (*outputs)[4],
LLVMValueRef emitted_vertices_vec)
{
@@ -478,10 +482,12 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base
}
void
-BuilderSWR::swr_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+BuilderSWR::swr_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base,
+ struct lp_build_context * bld,
+ LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef verts_per_prim_vec,
- LLVMValueRef emitted_prims_vec)
+ LLVMValueRef emitted_prims_vec,
+ LLVMValueRef mask_vec)
{
swr_gs_llvm_iface *iface = (swr_gs_llvm_iface*)gs_base;
@@ -496,14 +502,9 @@ BuilderSWR::swr_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_ba
ADD(MUL(unwrap(emitted_prims_vec), VIMMED1(vertsPerPrim)),
unwrap(verts_per_prim_vec));
- struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
- vCount = LOAD(unwrap(bld->total_emitted_vertices_vec_ptr));
-
- struct lp_exec_mask *exec_mask = &bld->exec_mask;
- Value *mask = unwrap(lp_build_mask_value(bld->mask));
- if (exec_mask->has_mask)
- mask = AND(mask, unwrap(exec_mask->exec_mask));
+ vCount = unwrap(total_emitted_vertices_vec);
+ Value *mask = unwrap(mask_vec);
Value *cmpMask = VMASK(ICMP_NE(unwrap(verts_per_prim_vec), VIMMED1(0)));
mask = AND(mask, cmpMask);
vMask1 = TRUNC(mask, VectorType::get(mInt1Ty, 8));
@@ -534,8 +535,7 @@ BuilderSWR::swr_gs_llvm_end_primitive(const struct lp_build_tgsi_gs_iface *gs_ba
}
void
-BuilderSWR::swr_gs_llvm_epilogue(const struct lp_build_tgsi_gs_iface *gs_base,
- struct lp_build_tgsi_context * bld_base,
+BuilderSWR::swr_gs_llvm_epilogue(const struct lp_build_gs_iface *gs_base,
LLVMValueRef total_emitted_vertices_vec,
LLVMValueRef emitted_prims_vec)
{