Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
I see. Rb for the whole patch then. Marek On Fri, May 31, 2019, 2:24 PM Rhys Perry wrote: > The first and last hunks are needed to pass on the shader_info to the > middle hunk, which needs it so that it can test if the compute shader > has a derivative group. > > On Fri, 31 May 2019 at 18:38, Marek Olšák wrote: > > > > The first and last hunks look like they shouldn't be there. Other than > that: > > > > Reviewed-by: Marek Olšák > > > > Marek > > > > On Fri, May 31, 2019 at 11:53 AM Rhys Perry > wrote: > >> > >> Otherwise LLVM can sink them and their texture coordinate calculations > >> into divergent branches. > >> > >> v2: simplify the conditions on which the intrinsic is marked as > convergent > >> v3: only mark as convergent in FS and CS with derivative groups > >> > >> Cc: > >> Signed-off-by: Rhys Perry > >> --- > >> src/amd/common/ac_nir_to_llvm.c | 18 ++ > >> 1 file changed, 18 insertions(+) > >> > >> diff --git a/src/amd/common/ac_nir_to_llvm.c > b/src/amd/common/ac_nir_to_llvm.c > >> index 265e3b636c4..9e9fade7227 100644 > >> --- a/src/amd/common/ac_nir_to_llvm.c > >> +++ b/src/amd/common/ac_nir_to_llvm.c > >> @@ -38,6 +38,7 @@ struct ac_nir_context { > >> struct ac_shader_abi *abi; > >> > >> gl_shader_stage stage; > >> + shader_info *info; > >> > >> LLVMValueRef *ssa_defs; > >> > >> @@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct > ac_nir_context *ctx, > >> } > >> > >> args->attributes = AC_FUNC_ATTR_READNONE; > >> + bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE && > >> +ctx->info->cs.derivative_group != > DERIVATIVE_GROUP_NONE; > >> + if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) { > >> + /* Prevent texture instructions with implicit > derivatives from being > >> +* sinked into branches. */ > >> + switch (instr->op) { > >> + case nir_texop_tex: > >> + case nir_texop_txb: > >> + case nir_texop_lod: > >> + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > >> + break; > >> + default: > >> + break; > >> + } > >> + } > >> + > >> return ac_build_image_opcode(&ctx->ac, args); > >> } > >> > >> @@ -4350,6 +4367,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, > struct ac_shader_abi *abi, > >> ctx.abi = abi; > >> > >> ctx.stage = nir->info.stage; > >> + ctx.info = &nir->info; > >> > >> ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock( > ctx.ac.builder)); > >> > >> -- > >> 2.21.0 > >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
The first and last hunks are needed to pass on the shader_info to the middle hunk, which needs it so that it can test if the compute shader has a derivative group. On Fri, 31 May 2019 at 18:38, Marek Olšák wrote: > > The first and last hunks look like they shouldn't be there. Other than that: > > Reviewed-by: Marek Olšák > > Marek > > On Fri, May 31, 2019 at 11:53 AM Rhys Perry wrote: >> >> Otherwise LLVM can sink them and their texture coordinate calculations >> into divergent branches. >> >> v2: simplify the conditions on which the intrinsic is marked as convergent >> v3: only mark as convergent in FS and CS with derivative groups >> >> Cc: >> Signed-off-by: Rhys Perry >> --- >> src/amd/common/ac_nir_to_llvm.c | 18 ++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/src/amd/common/ac_nir_to_llvm.c >> b/src/amd/common/ac_nir_to_llvm.c >> index 265e3b636c4..9e9fade7227 100644 >> --- a/src/amd/common/ac_nir_to_llvm.c >> +++ b/src/amd/common/ac_nir_to_llvm.c >> @@ -38,6 +38,7 @@ struct ac_nir_context { >> struct ac_shader_abi *abi; >> >> gl_shader_stage stage; >> + shader_info *info; >> >> LLVMValueRef *ssa_defs; >> >> @@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct >> ac_nir_context *ctx, >> } >> >> args->attributes = AC_FUNC_ATTR_READNONE; >> + bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE && >> +ctx->info->cs.derivative_group != >> DERIVATIVE_GROUP_NONE; >> + if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) { >> + /* Prevent texture instructions with implicit derivatives >> from being >> +* sinked into branches. */ >> + switch (instr->op) { >> + case nir_texop_tex: >> + case nir_texop_txb: >> + case nir_texop_lod: >> + args->attributes |= AC_FUNC_ATTR_CONVERGENT; >> + break; >> + default: >> + break; >> + } >> + } >> + >> return ac_build_image_opcode(&ctx->ac, args); >> } >> >> @@ -4350,6 +4367,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, >> struct ac_shader_abi *abi, >> ctx.abi = abi; >> >> ctx.stage = nir->info.stage; >> + ctx.info = &nir->info; >> >> ctx.main_function = >> LLVMGetBasicBlockParent(LLVMGetInsertBlock(ctx.ac.builder)); >> >> -- >> 2.21.0 >> ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
The first and last hunks look like they shouldn't be there. Other than that: Reviewed-by: Marek Olšák Marek On Fri, May 31, 2019 at 11:53 AM Rhys Perry wrote: > Otherwise LLVM can sink them and their texture coordinate calculations > into divergent branches. > > v2: simplify the conditions on which the intrinsic is marked as convergent > v3: only mark as convergent in FS and CS with derivative groups > > Cc: > Signed-off-by: Rhys Perry > --- > src/amd/common/ac_nir_to_llvm.c | 18 ++ > 1 file changed, 18 insertions(+) > > diff --git a/src/amd/common/ac_nir_to_llvm.c > b/src/amd/common/ac_nir_to_llvm.c > index 265e3b636c4..9e9fade7227 100644 > --- a/src/amd/common/ac_nir_to_llvm.c > +++ b/src/amd/common/ac_nir_to_llvm.c > @@ -38,6 +38,7 @@ struct ac_nir_context { > struct ac_shader_abi *abi; > > gl_shader_stage stage; > + shader_info *info; > > LLVMValueRef *ssa_defs; > > @@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct > ac_nir_context *ctx, > } > > args->attributes = AC_FUNC_ATTR_READNONE; > + bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE && > +ctx->info->cs.derivative_group != > DERIVATIVE_GROUP_NONE; > + if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) { > + /* Prevent texture instructions with implicit derivatives > from being > +* sinked into branches. */ > + switch (instr->op) { > + case nir_texop_tex: > + case nir_texop_txb: > + case nir_texop_lod: > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > + break; > + default: > + break; > + } > + } > + > return ac_build_image_opcode(&ctx->ac, args); > } > > @@ -4350,6 +4367,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, > struct ac_shader_abi *abi, > ctx.abi = abi; > > ctx.stage = nir->info.stage; > + ctx.info = &nir->info; > > ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock( > ctx.ac.builder)); > > -- > 2.21.0 > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
Otherwise LLVM can sink them and their texture coordinate calculations into divergent branches. v2: simplify the conditions on which the intrinsic is marked as convergent v3: only mark as convergent in FS and CS with derivative groups Cc: Signed-off-by: Rhys Perry --- src/amd/common/ac_nir_to_llvm.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 265e3b636c4..9e9fade7227 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -38,6 +38,7 @@ struct ac_nir_context { struct ac_shader_abi *abi; gl_shader_stage stage; + shader_info *info; LLVMValueRef *ssa_defs; @@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, } args->attributes = AC_FUNC_ATTR_READNONE; + bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE && +ctx->info->cs.derivative_group != DERIVATIVE_GROUP_NONE; + if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) { + /* Prevent texture instructions with implicit derivatives from being +* sinked into branches. */ + switch (instr->op) { + case nir_texop_tex: + case nir_texop_txb: + case nir_texop_lod: + args->attributes |= AC_FUNC_ATTR_CONVERGENT; + break; + default: + break; + } + } + return ac_build_image_opcode(&ctx->ac, args); } @@ -4350,6 +4367,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi, ctx.abi = abi; ctx.stage = nir->info.stage; + ctx.info = &nir->info; ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock(ctx.ac.builder)); -- 2.21.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Thu, May 30, 2019, 7:08 PM Bas Nieuwenhuizen wrote: > > > On Fri, May 31, 2019, 12:49 AM Marek Olšák wrote: > >> >> >> On Thu, May 30, 2019, 6:44 PM Bas Nieuwenhuizen >> wrote: >> >>> >>> >>> On Thu, May 30, 2019, 11:45 PM Marek Olšák wrote: >>> On Thu, May 30, 2019, 3:54 PM Rhys Perry wrote: > Otherwise LLVM can sink them and their texture coordinate calculations > into divergent branches. > > v2: simplify the conditions on which the intrinsic is marked as > convergent > > Cc: > Signed-off-by: Rhys Perry > Reviewed-By: Bas Nieuwenhuizen > --- > src/amd/common/ac_nir_to_llvm.c | 12 > 1 file changed, 12 insertions(+) > > diff --git a/src/amd/common/ac_nir_to_llvm.c > b/src/amd/common/ac_nir_to_llvm.c > index 265e3b636c4..b1a191ac24c 100644 > --- a/src/amd/common/ac_nir_to_llvm.c > +++ b/src/amd/common/ac_nir_to_llvm.c > @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct > ac_nir_context *ctx, > } > > args->attributes = AC_FUNC_ATTR_READNONE; > + /* Prevent texture instructions with implicit derivatives from > being > +* sinked into branches. */ > + switch (instr->op) { > + case nir_texop_tex: > + case nir_texop_txb: > + case nir_texop_lod: > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > + break; > + default: > + break; > + } > I think this should only apply to the fragment shader. >>> >>> Well these opcodes will only be used in fragment shaders anyway, right? >>> >> >> I think the normal tex opcode can be used in vertex shaders as well, >> probably only in OpenGL. >> > > What is the behavior there? Implicit lod of 0? > Yes. Marek >> Marek >> >> Marek + > return ac_build_image_opcode(&ctx->ac, args); > } > > -- > 2.21.0 > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Fri, May 31, 2019, 12:49 AM Marek Olšák wrote: > > > On Thu, May 30, 2019, 6:44 PM Bas Nieuwenhuizen > wrote: > >> >> >> On Thu, May 30, 2019, 11:45 PM Marek Olšák wrote: >> >>> >>> >>> On Thu, May 30, 2019, 3:54 PM Rhys Perry >>> wrote: >>> Otherwise LLVM can sink them and their texture coordinate calculations into divergent branches. v2: simplify the conditions on which the intrinsic is marked as convergent Cc: Signed-off-by: Rhys Perry Reviewed-By: Bas Nieuwenhuizen --- src/amd/common/ac_nir_to_llvm.c | 12 1 file changed, 12 insertions(+) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 265e3b636c4..b1a191ac24c 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, } args->attributes = AC_FUNC_ATTR_READNONE; + /* Prevent texture instructions with implicit derivatives from being +* sinked into branches. */ + switch (instr->op) { + case nir_texop_tex: + case nir_texop_txb: + case nir_texop_lod: + args->attributes |= AC_FUNC_ATTR_CONVERGENT; + break; + default: + break; + } >>> >>> I think this should only apply to the fragment shader. >>> >> >> Well these opcodes will only be used in fragment shaders anyway, right? >> > > I think the normal tex opcode can be used in vertex shaders as well, > probably only in OpenGL. > What is the behavior there? Implicit lod of 0? > > Marek > > >>> Marek >>> >>> + return ac_build_image_opcode(&ctx->ac, args); } -- 2.21.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Thu, May 30, 2019, 6:44 PM Bas Nieuwenhuizen wrote: > > > On Thu, May 30, 2019, 11:45 PM Marek Olšák wrote: > >> >> >> On Thu, May 30, 2019, 3:54 PM Rhys Perry >> wrote: >> >>> Otherwise LLVM can sink them and their texture coordinate calculations >>> into divergent branches. >>> >>> v2: simplify the conditions on which the intrinsic is marked as >>> convergent >>> >>> Cc: >>> Signed-off-by: Rhys Perry >>> Reviewed-By: Bas Nieuwenhuizen >>> --- >>> src/amd/common/ac_nir_to_llvm.c | 12 >>> 1 file changed, 12 insertions(+) >>> >>> diff --git a/src/amd/common/ac_nir_to_llvm.c >>> b/src/amd/common/ac_nir_to_llvm.c >>> index 265e3b636c4..b1a191ac24c 100644 >>> --- a/src/amd/common/ac_nir_to_llvm.c >>> +++ b/src/amd/common/ac_nir_to_llvm.c >>> @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct >>> ac_nir_context *ctx, >>> } >>> >>> args->attributes = AC_FUNC_ATTR_READNONE; >>> + /* Prevent texture instructions with implicit derivatives from >>> being >>> +* sinked into branches. */ >>> + switch (instr->op) { >>> + case nir_texop_tex: >>> + case nir_texop_txb: >>> + case nir_texop_lod: >>> + args->attributes |= AC_FUNC_ATTR_CONVERGENT; >>> + break; >>> + default: >>> + break; >>> + } >>> >> >> I think this should only apply to the fragment shader. >> > > Well these opcodes will only be used in fragment shaders anyway, right? > I think the normal tex opcode can be used in vertex shaders as well, probably only in OpenGL. Marek >> Marek >> >> + >>> return ac_build_image_opcode(&ctx->ac, args); >>> } >>> >>> -- >>> 2.21.0 >>> >>> ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Thu, May 30, 2019, 11:45 PM Marek Olšák wrote: > > > On Thu, May 30, 2019, 3:54 PM Rhys Perry wrote: > >> Otherwise LLVM can sink them and their texture coordinate calculations >> into divergent branches. >> >> v2: simplify the conditions on which the intrinsic is marked as convergent >> >> Cc: >> Signed-off-by: Rhys Perry >> Reviewed-By: Bas Nieuwenhuizen >> --- >> src/amd/common/ac_nir_to_llvm.c | 12 >> 1 file changed, 12 insertions(+) >> >> diff --git a/src/amd/common/ac_nir_to_llvm.c >> b/src/amd/common/ac_nir_to_llvm.c >> index 265e3b636c4..b1a191ac24c 100644 >> --- a/src/amd/common/ac_nir_to_llvm.c >> +++ b/src/amd/common/ac_nir_to_llvm.c >> @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct >> ac_nir_context *ctx, >> } >> >> args->attributes = AC_FUNC_ATTR_READNONE; >> + /* Prevent texture instructions with implicit derivatives from >> being >> +* sinked into branches. */ >> + switch (instr->op) { >> + case nir_texop_tex: >> + case nir_texop_txb: >> + case nir_texop_lod: >> + args->attributes |= AC_FUNC_ATTR_CONVERGENT; >> + break; >> + default: >> + break; >> + } >> > > I think this should only apply to the fragment shader. > Well these opcodes will only be used in fragment shaders anyway, right? > > Marek > > + >> return ac_build_image_opcode(&ctx->ac, args); >> } >> >> -- >> 2.21.0 >> >> ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Thu, May 30, 2019, 3:54 PM Rhys Perry wrote: > Otherwise LLVM can sink them and their texture coordinate calculations > into divergent branches. > > v2: simplify the conditions on which the intrinsic is marked as convergent > > Cc: > Signed-off-by: Rhys Perry > Reviewed-By: Bas Nieuwenhuizen > --- > src/amd/common/ac_nir_to_llvm.c | 12 > 1 file changed, 12 insertions(+) > > diff --git a/src/amd/common/ac_nir_to_llvm.c > b/src/amd/common/ac_nir_to_llvm.c > index 265e3b636c4..b1a191ac24c 100644 > --- a/src/amd/common/ac_nir_to_llvm.c > +++ b/src/amd/common/ac_nir_to_llvm.c > @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct > ac_nir_context *ctx, > } > > args->attributes = AC_FUNC_ATTR_READNONE; > + /* Prevent texture instructions with implicit derivatives from > being > +* sinked into branches. */ > + switch (instr->op) { > + case nir_texop_tex: > + case nir_texop_txb: > + case nir_texop_lod: > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > + break; > + default: > + break; > + } > I think this should only apply to the fragment shader. Marek + > return ac_build_image_opcode(&ctx->ac, args); > } > > -- > 2.21.0 > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
Otherwise LLVM can sink them and their texture coordinate calculations into divergent branches. v2: simplify the conditions on which the intrinsic is marked as convergent Cc: Signed-off-by: Rhys Perry Reviewed-By: Bas Nieuwenhuizen --- src/amd/common/ac_nir_to_llvm.c | 12 1 file changed, 12 insertions(+) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 265e3b636c4..b1a191ac24c 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, } args->attributes = AC_FUNC_ATTR_READNONE; + /* Prevent texture instructions with implicit derivatives from being +* sinked into branches. */ + switch (instr->op) { + case nir_texop_tex: + case nir_texop_txb: + case nir_texop_lod: + args->attributes |= AC_FUNC_ATTR_CONVERGENT; + break; + default: + break; + } + return ac_build_image_opcode(&ctx->ac, args); } -- 2.21.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
It doesn't matter if the opcode supplies a lod. The only thing that matters is if the opcode computes derivatives. It seems that the only opcodes computing derivatives are tex, tex_bias, and query_lod. This only applies to fragment shaders. Other stages never compute derivatives. There is an NV extension that enables derivatives in compute shaders. Marek On Thu, May 30, 2019, 2:47 PM Rhys Perry wrote: > Seems txf can(should?) have a lod supplied. txf_ms and tg4 always use > the 0th level. > > I'll add txf, txf_ms and tg4 to the list of nir_texop which don't ever > have implicit derivatives. > > On Thu, 30 May 2019 at 19:43, Ilia Mirkin wrote: > > > > txf supplies an lod, but tg4's is implicitly always 0. > > > > On Thu, May 30, 2019 at 2:26 PM Bas Nieuwenhuizen > > wrote: > > > > > > On Thu, May 30, 2019 at 6:50 PM Rhys Perry > wrote: > > > > > > > > Otherwise LLVM can sink them and their texture coordinate > calculations > > > > into divergent branches. > > > > > > > > Cc: > > > > Signed-off-by: Rhys Perry > > > > --- > > > > src/amd/common/ac_nir_to_llvm.c | 29 + > > > > 1 file changed, 29 insertions(+) > > > > > > > > diff --git a/src/amd/common/ac_nir_to_llvm.c > b/src/amd/common/ac_nir_to_llvm.c > > > > index 265e3b636c4..d2dc617de36 100644 > > > > --- a/src/amd/common/ac_nir_to_llvm.c > > > > +++ b/src/amd/common/ac_nir_to_llvm.c > > > > @@ -1316,6 +1316,30 @@ static nir_deref_instr > *get_tex_texture_deref(const nir_tex_instr *instr) > > > > return texture_deref_instr; > > > > } > > > > > > > > +static bool has_implicit_derivatives(const nir_tex_instr *instr) > > > > +{ > > > > + switch (instr->op) { > > > > + case nir_texop_txs: > > > > + case nir_texop_query_levels: > > > > + case nir_texop_texture_samples: > > > > + case nir_texop_samples_identical: > > > > + return false; > > > > + default: > > > > + break; > > > > + } > > > > + for (unsigned i = 0; i < instr->num_srcs; i++) { > > > > + switch (instr->src[i].src_type) { > > > > + case nir_tex_src_lod: > > > > + case nir_tex_src_ddx: > > > > + case nir_tex_src_ddy: > > > > + return false; > > > > + default: > > > > + break; > > > > + } > > > > + } > > > > + return true; > > > > +} > > > > > > txf, tg4 and friends do not provide any of lod/ddx/ddy do they? > > > > > > > + > > > > static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, > > > > const nir_tex_instr *instr, > > > > struct ac_image_args *args) > > > > @@ -1394,6 +1418,11 @@ static LLVMValueRef > build_tex_intrinsic(struct ac_nir_context *ctx, > > > > } > > > > > > > > args->attributes = AC_FUNC_ATTR_READNONE; > > > > + /* Prevent texture instructions with implicit derivatives > from being > > > > +* sinked into branches. */ > > > > + if (has_implicit_derivatives(instr)) > > > > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > > > > + > > > > return ac_build_image_opcode(&ctx->ac, args); > > > > } > > > > > > > > -- > > > > 2.21.0 > > > > > > > ___ > > > mesa-dev mailing list > > > mesa-dev@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
Seems txf can(should?) have a lod supplied. txf_ms and tg4 always use the 0th level. I'll add txf, txf_ms and tg4 to the list of nir_texop which don't ever have implicit derivatives. On Thu, 30 May 2019 at 19:43, Ilia Mirkin wrote: > > txf supplies an lod, but tg4's is implicitly always 0. > > On Thu, May 30, 2019 at 2:26 PM Bas Nieuwenhuizen > wrote: > > > > On Thu, May 30, 2019 at 6:50 PM Rhys Perry wrote: > > > > > > Otherwise LLVM can sink them and their texture coordinate calculations > > > into divergent branches. > > > > > > Cc: > > > Signed-off-by: Rhys Perry > > > --- > > > src/amd/common/ac_nir_to_llvm.c | 29 + > > > 1 file changed, 29 insertions(+) > > > > > > diff --git a/src/amd/common/ac_nir_to_llvm.c > > > b/src/amd/common/ac_nir_to_llvm.c > > > index 265e3b636c4..d2dc617de36 100644 > > > --- a/src/amd/common/ac_nir_to_llvm.c > > > +++ b/src/amd/common/ac_nir_to_llvm.c > > > @@ -1316,6 +1316,30 @@ static nir_deref_instr > > > *get_tex_texture_deref(const nir_tex_instr *instr) > > > return texture_deref_instr; > > > } > > > > > > +static bool has_implicit_derivatives(const nir_tex_instr *instr) > > > +{ > > > + switch (instr->op) { > > > + case nir_texop_txs: > > > + case nir_texop_query_levels: > > > + case nir_texop_texture_samples: > > > + case nir_texop_samples_identical: > > > + return false; > > > + default: > > > + break; > > > + } > > > + for (unsigned i = 0; i < instr->num_srcs; i++) { > > > + switch (instr->src[i].src_type) { > > > + case nir_tex_src_lod: > > > + case nir_tex_src_ddx: > > > + case nir_tex_src_ddy: > > > + return false; > > > + default: > > > + break; > > > + } > > > + } > > > + return true; > > > +} > > > > txf, tg4 and friends do not provide any of lod/ddx/ddy do they? > > > > > + > > > static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, > > > const nir_tex_instr *instr, > > > struct ac_image_args *args) > > > @@ -1394,6 +1418,11 @@ static LLVMValueRef build_tex_intrinsic(struct > > > ac_nir_context *ctx, > > > } > > > > > > args->attributes = AC_FUNC_ATTR_READNONE; > > > + /* Prevent texture instructions with implicit derivatives from > > > being > > > +* sinked into branches. */ > > > + if (has_implicit_derivatives(instr)) > > > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > > > + > > > return ac_build_image_opcode(&ctx->ac, args); > > > } > > > > > > -- > > > 2.21.0 > > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
txf supplies an lod, but tg4's is implicitly always 0. On Thu, May 30, 2019 at 2:26 PM Bas Nieuwenhuizen wrote: > > On Thu, May 30, 2019 at 6:50 PM Rhys Perry wrote: > > > > Otherwise LLVM can sink them and their texture coordinate calculations > > into divergent branches. > > > > Cc: > > Signed-off-by: Rhys Perry > > --- > > src/amd/common/ac_nir_to_llvm.c | 29 + > > 1 file changed, 29 insertions(+) > > > > diff --git a/src/amd/common/ac_nir_to_llvm.c > > b/src/amd/common/ac_nir_to_llvm.c > > index 265e3b636c4..d2dc617de36 100644 > > --- a/src/amd/common/ac_nir_to_llvm.c > > +++ b/src/amd/common/ac_nir_to_llvm.c > > @@ -1316,6 +1316,30 @@ static nir_deref_instr *get_tex_texture_deref(const > > nir_tex_instr *instr) > > return texture_deref_instr; > > } > > > > +static bool has_implicit_derivatives(const nir_tex_instr *instr) > > +{ > > + switch (instr->op) { > > + case nir_texop_txs: > > + case nir_texop_query_levels: > > + case nir_texop_texture_samples: > > + case nir_texop_samples_identical: > > + return false; > > + default: > > + break; > > + } > > + for (unsigned i = 0; i < instr->num_srcs; i++) { > > + switch (instr->src[i].src_type) { > > + case nir_tex_src_lod: > > + case nir_tex_src_ddx: > > + case nir_tex_src_ddy: > > + return false; > > + default: > > + break; > > + } > > + } > > + return true; > > +} > > txf, tg4 and friends do not provide any of lod/ddx/ddy do they? > > > + > > static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, > > const nir_tex_instr *instr, > > struct ac_image_args *args) > > @@ -1394,6 +1418,11 @@ static LLVMValueRef build_tex_intrinsic(struct > > ac_nir_context *ctx, > > } > > > > args->attributes = AC_FUNC_ATTR_READNONE; > > + /* Prevent texture instructions with implicit derivatives from being > > +* sinked into branches. */ > > + if (has_implicit_derivatives(instr)) > > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > > + > > return ac_build_image_opcode(&ctx->ac, args); > > } > > > > -- > > 2.21.0 > > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
On Thu, May 30, 2019 at 6:50 PM Rhys Perry wrote: > > Otherwise LLVM can sink them and their texture coordinate calculations > into divergent branches. > > Cc: > Signed-off-by: Rhys Perry > --- > src/amd/common/ac_nir_to_llvm.c | 29 + > 1 file changed, 29 insertions(+) > > diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c > index 265e3b636c4..d2dc617de36 100644 > --- a/src/amd/common/ac_nir_to_llvm.c > +++ b/src/amd/common/ac_nir_to_llvm.c > @@ -1316,6 +1316,30 @@ static nir_deref_instr *get_tex_texture_deref(const > nir_tex_instr *instr) > return texture_deref_instr; > } > > +static bool has_implicit_derivatives(const nir_tex_instr *instr) > +{ > + switch (instr->op) { > + case nir_texop_txs: > + case nir_texop_query_levels: > + case nir_texop_texture_samples: > + case nir_texop_samples_identical: > + return false; > + default: > + break; > + } > + for (unsigned i = 0; i < instr->num_srcs; i++) { > + switch (instr->src[i].src_type) { > + case nir_tex_src_lod: > + case nir_tex_src_ddx: > + case nir_tex_src_ddy: > + return false; > + default: > + break; > + } > + } > + return true; > +} txf, tg4 and friends do not provide any of lod/ddx/ddy do they? > + > static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, > const nir_tex_instr *instr, > struct ac_image_args *args) > @@ -1394,6 +1418,11 @@ static LLVMValueRef build_tex_intrinsic(struct > ac_nir_context *ctx, > } > > args->attributes = AC_FUNC_ATTR_READNONE; > + /* Prevent texture instructions with implicit derivatives from being > +* sinked into branches. */ > + if (has_implicit_derivatives(instr)) > + args->attributes |= AC_FUNC_ATTR_CONVERGENT; > + > return ac_build_image_opcode(&ctx->ac, args); > } > > -- > 2.21.0 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] ac/nir: mark some texture intrinsics as convergent
Otherwise LLVM can sink them and their texture coordinate calculations into divergent branches. Cc: Signed-off-by: Rhys Perry --- src/amd/common/ac_nir_to_llvm.c | 29 + 1 file changed, 29 insertions(+) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 265e3b636c4..d2dc617de36 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1316,6 +1316,30 @@ static nir_deref_instr *get_tex_texture_deref(const nir_tex_instr *instr) return texture_deref_instr; } +static bool has_implicit_derivatives(const nir_tex_instr *instr) +{ + switch (instr->op) { + case nir_texop_txs: + case nir_texop_query_levels: + case nir_texop_texture_samples: + case nir_texop_samples_identical: + return false; + default: + break; + } + for (unsigned i = 0; i < instr->num_srcs; i++) { + switch (instr->src[i].src_type) { + case nir_tex_src_lod: + case nir_tex_src_ddx: + case nir_tex_src_ddy: + return false; + default: + break; + } + } + return true; +} + static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, const nir_tex_instr *instr, struct ac_image_args *args) @@ -1394,6 +1418,11 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, } args->attributes = AC_FUNC_ATTR_READNONE; + /* Prevent texture instructions with implicit derivatives from being +* sinked into branches. */ + if (has_implicit_derivatives(instr)) + args->attributes |= AC_FUNC_ATTR_CONVERGENT; + return ac_build_image_opcode(&ctx->ac, args); } -- 2.21.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev