ac: fix possibly incorrect bindless atomic code in visit_image_atomic

Submitted by Marek Olšák on April 12, 2019, 3:40 p.m.

Details

Message ID 20190412154017.28877-1-maraeo@gmail.com
State New
Headers show
Series "ac: fix possibly incorrect bindless atomic code in visit_image_atomic" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák April 12, 2019, 3:40 p.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 src/amd/common/ac_nir_to_llvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 55c64e2aacb..afdd9318fff 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2543,25 +2543,25 @@  static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
 	int param_count = 0;
 
 	bool cmpswap = instr->intrinsic == nir_intrinsic_image_deref_atomic_comp_swap ||
 		       instr->intrinsic == nir_intrinsic_bindless_image_atomic_comp_swap;
 	const char *atomic_name;
 	char intrinsic_name[64];
 	enum ac_atomic_op atomic_subop;
 	MAYBE_UNUSED int length;
 
 	enum glsl_sampler_dim dim;
-	bool is_unsigned;
+	bool is_unsigned = false;
 	bool is_array;
 	if (bindless) {
-		if (instr->intrinsic == nir_intrinsic_image_atomic_min ||
-		    instr->intrinsic == nir_intrinsic_image_atomic_max) {
+		if (instr->intrinsic == nir_intrinsic_bindless_image_atomic_min ||
+		    instr->intrinsic == nir_intrinsic_bindless_image_atomic_max) {
 			const GLenum format = nir_intrinsic_format(instr);
 			assert(format == GL_R32UI || format == GL_R32I);
 			is_unsigned = format == GL_R32UI;
 		}
 		dim = nir_intrinsic_image_dim(instr);
 		is_array = nir_intrinsic_image_array(instr);
 	} else {
 		const struct glsl_type *type = get_image_deref(instr)->type;
 		is_unsigned = glsl_get_sampler_result_type(type) == GLSL_TYPE_UINT;
 		dim = glsl_get_sampler_dim(type);

Comments

possibly? :)

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>

On 4/12/19 5:40 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> ---
>   src/amd/common/ac_nir_to_llvm.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 55c64e2aacb..afdd9318fff 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -2543,25 +2543,25 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
>   	int param_count = 0;
>   
>   	bool cmpswap = instr->intrinsic == nir_intrinsic_image_deref_atomic_comp_swap ||
>   		       instr->intrinsic == nir_intrinsic_bindless_image_atomic_comp_swap;
>   	const char *atomic_name;
>   	char intrinsic_name[64];
>   	enum ac_atomic_op atomic_subop;
>   	MAYBE_UNUSED int length;
>   
>   	enum glsl_sampler_dim dim;
> -	bool is_unsigned;
> +	bool is_unsigned = false;
>   	bool is_array;
>   	if (bindless) {
> -		if (instr->intrinsic == nir_intrinsic_image_atomic_min ||
> -		    instr->intrinsic == nir_intrinsic_image_atomic_max) {
> +		if (instr->intrinsic == nir_intrinsic_bindless_image_atomic_min ||
> +		    instr->intrinsic == nir_intrinsic_bindless_image_atomic_max) {
>   			const GLenum format = nir_intrinsic_format(instr);
>   			assert(format == GL_R32UI || format == GL_R32I);
>   			is_unsigned = format == GL_R32UI;
>   		}
>   		dim = nir_intrinsic_image_dim(instr);
>   		is_array = nir_intrinsic_image_array(instr);
>   	} else {
>   		const struct glsl_type *type = get_image_deref(instr)->type;
>   		is_unsigned = glsl_get_sampler_result_type(type) == GLSL_TYPE_UINT;
>   		dim = glsl_get_sampler_dim(type);
Thanks I didn't see this and sent the same patch. Please add the 
following to the commit message:

Coverity: CID 1444664

Fixes: d62d434fe920 ("ac/nir_to_llvm: add image bindless support")

With those:

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>

On 13/4/19 1:40 am, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
> 
> ---
>   src/amd/common/ac_nir_to_llvm.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 55c64e2aacb..afdd9318fff 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -2543,25 +2543,25 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
>   	int param_count = 0;
>   
>   	bool cmpswap = instr->intrinsic == nir_intrinsic_image_deref_atomic_comp_swap ||
>   		       instr->intrinsic == nir_intrinsic_bindless_image_atomic_comp_swap;
>   	const char *atomic_name;
>   	char intrinsic_name[64];
>   	enum ac_atomic_op atomic_subop;
>   	MAYBE_UNUSED int length;
>   
>   	enum glsl_sampler_dim dim;
> -	bool is_unsigned;
> +	bool is_unsigned = false;
>   	bool is_array;
>   	if (bindless) {
> -		if (instr->intrinsic == nir_intrinsic_image_atomic_min ||
> -		    instr->intrinsic == nir_intrinsic_image_atomic_max) {
> +		if (instr->intrinsic == nir_intrinsic_bindless_image_atomic_min ||
> +		    instr->intrinsic == nir_intrinsic_bindless_image_atomic_max) {
>   			const GLenum format = nir_intrinsic_format(instr);
>   			assert(format == GL_R32UI || format == GL_R32I);
>   			is_unsigned = format == GL_R32UI;
>   		}
>   		dim = nir_intrinsic_image_dim(instr);
>   		is_array = nir_intrinsic_image_array(instr);
>   	} else {
>   		const struct glsl_type *type = get_image_deref(instr)->type;
>   		is_unsigned = glsl_get_sampler_result_type(type) == GLSL_TYPE_UINT;
>   		dim = glsl_get_sampler_dim(type);
>