[Mesa-dev] [PATCH] radv: fix f16->f32 denorm handling for SI/CIK.

Nicolai Hähnle nhaehnle at gmail.com
Mon Aug 7 07:26:48 UTC 2017


On 04.08.2017 01:18, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This just copies the code from the -pro shaders,
> and fixes the tests on CIK.
> 
> With this CIK passes the same set of conformance
> tests as VI.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>   src/amd/common/ac_nir_to_llvm.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 83e1111..4e6a234 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -1322,7 +1322,6 @@ static LLVMValueRef emit_f2f16(struct nir_to_llvm_context *ctx,
>   	src0 = to_float(&ctx->ac, src0);
>   	result = LLVMBuildFPTrunc(ctx->builder, src0, ctx->f16, "");
>   
> -	/* TODO SI/CIK options here */
>   	if (ctx->options->chip_class >= VI) {
>   		LLVMValueRef args[2];
>   		/* Check if the result is a denormal - and flush to 0 if so. */
> @@ -1336,7 +1335,19 @@ static LLVMValueRef emit_f2f16(struct nir_to_llvm_context *ctx,
>   
>   	if (ctx->options->chip_class >= VI) >   		result = LLVMBuildSelect(ctx->builder, cond, ctx->f32zero, 
result, "");

Could you please merge the two chip_class >= VI blocks, keeping the 
first (truncated) result in a separate variable for the VI path?

Thanks,
Nicolai


> -
> +	else {
> +		/* for SI/CIK */
> +		LLVMValueRef temp, cond2;
> +		temp = emit_intrin_1f_param(&ctx->ac, "llvm.fabs",
> +					    ctx->f32, result);
> +		cond = LLVMBuildFCmp(ctx->builder, LLVMRealUGT,
> +				     LLVMBuildBitCast(ctx->builder, LLVMConstInt(ctx->i32, 0x38000000, false), ctx->f32, ""),
> +				     temp, "");
> +		cond2 = LLVMBuildFCmp(ctx->builder, LLVMRealUNE,
> +				      temp, ctx->f32zero, "");
> +		cond = LLVMBuildAnd(ctx->builder, cond, cond2, "");
> +		result = LLVMBuildSelect(ctx->builder, cond, ctx->f32zero, result, "");
> +	}
>   	return result;
>   }
>   
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list