[Bf-blender-cvs] [83e91485d09] master: GPU: Fix NOT ~ operator for eGPUSamplerState

Ankit Meel noreply at git.blender.org
Fri Oct 9 14:05:54 CEST 2020


Commit: 83e91485d096e64e9cfa45e19292dd76378abe73
Author: Ankit Meel
Date:   Fri Oct 9 16:27:39 2020 +0530
Branches: master
https://developer.blender.org/rB83e91485d096e64e9cfa45e19292dd76378abe73

GPU: Fix NOT ~ operator for eGPUSamplerState

The real maximum was `GPU_SAMPLER_ICON`, not `GPU_SAMPLER_REPEAT`, my
bad. {rBa31a87f8943aa40}

Move `GPU_SAMPLER_MAX` out of the enum since it's used as an `int`
at many places.
Also, the macro `ENUM_OPERATORS` needs a maximum, and this enumerator
cannot be used as the argument of that macro. It creates wrong values
in the `~` NOT operator.

Thanks @deadpin for catching this.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D9157

===================================================================

M	source/blender/gpu/GPU_texture.h

===================================================================

diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 25af7d592f7..e9c081abd22 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -58,11 +58,13 @@ typedef enum eGPUSamplerState {
   GPU_SAMPLER_ICON = (1 << 8),
 
   GPU_SAMPLER_REPEAT = (GPU_SAMPLER_REPEAT_S | GPU_SAMPLER_REPEAT_T | GPU_SAMPLER_REPEAT_R),
-  /* Don't use that. */
-  GPU_SAMPLER_MAX = (GPU_SAMPLER_ICON + 1),
 } eGPUSamplerState;
 
-ENUM_OPERATORS(eGPUSamplerState, GPU_SAMPLER_REPEAT)
+/* `GPU_SAMPLER_MAX` is not a valid enum value, but only a limit.
+ * It also creates a bad mask for the `NOT` operator in `ENUM_OPERATORS`.
+ */
+static const int GPU_SAMPLER_MAX = (GPU_SAMPLER_ICON + 1);
+ENUM_OPERATORS(eGPUSamplerState, GPU_SAMPLER_ICON)
 
 #ifdef __cplusplus
 extern "C" {



More information about the Bf-blender-cvs mailing list