[Mesa-dev] [PATCH] radeonsi: Prevent geometry shader from emitting too many vertices
Marek Olšák
maraeo at gmail.com
Tue Mar 4 15:25:27 PST 2014
I think this patch breaks geometry shaders with LLVM that doesn't
support the kill instruction in GS. All GS piglit tests fail with:
SILowerControlFlow.cpp:296: void
{anonymous}::SILowerControlFlowPass::Kill(llvm::MachineInstr&):
Assertion `MBB.getParent()->getInfo<SIMachineFunctionInfo>()->ShaderType
== ShaderType::PIXEL' failed.
Marek
On Mon, Feb 24, 2014 at 10:03 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Daenzer <michel.daenzer at amd.com>
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
> src/gallium/drivers/radeonsi/si_shader.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index 54270cd..b22db0b 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -1905,6 +1905,7 @@ static void si_llvm_emit_vertex(
> LLVMValueRef soffset = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn,
> SI_PARAM_GS2VS_OFFSET);
> LLVMValueRef gs_next_vertex;
> + LLVMValueRef can_emit, kill;
> LLVMValueRef t_list_ptr;
> LLVMValueRef t_list;
> LLVMValueRef args[2];
> @@ -1934,6 +1935,21 @@ static void si_llvm_emit_vertex(
>
> /* Write vertex attribute values to GSVS ring */
> gs_next_vertex = LLVMBuildLoad(gallivm->builder, si_shader_ctx->gs_next_vertex, "");
> +
> + /* If this thread has already emitted the declared maximum number of
> + * vertices, kill it: excessive vertex emissions are not supposed to
> + * have any effect, and GS threads have no externally observable
> + * effects other than emitting vertices.
> + */
> + can_emit = LLVMBuildICmp(gallivm->builder, LLVMIntULE, gs_next_vertex,
> + lp_build_const_int32(gallivm,
> + shader->gs_max_out_vertices), "");
> + kill = lp_build_select(&bld_base->base, can_emit,
> + lp_build_const_float(gallivm, 1.0f),
> + lp_build_const_float(gallivm, -1.0f));
> + build_intrinsic(gallivm->builder, "llvm.AMDGPU.kill",
> + LLVMVoidTypeInContext(gallivm->context), &kill, 1, 0);
> +
> for (i = 0; i < shader->noutput; i++) {
> LLVMValueRef *out_ptr =
> si_shader_ctx->radeon_bld.soa.outputs[shader->output[i].index];
> --
> 1.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list