Fix thousands of 'is too small to hold all values' warnings on Linux

When building with GCC, it generates 3020 warnings like this:

libraries/gpu/src/gpu/State.h:208:18: warning: ‘gpu::State::BlendFunction::destColor’
is too small to hold all values of ‘enum gpu::State::BlendArg’

This is because ‘enum gpu::State::BlendArg’ is declared as an enum
of uint16 size, and gpu::State::BlendFunction::destColor is a bit
field.

GCC correctly deduces that a 16 bit value won't always fit in a 4
bit field, and emits a warning.

The problem is that the amount is such that it floods the output and hides
other warnings.

Changing the 'enum foo : uint16' declarations to 'enum foo' stops gcc
from emitting the warning.

Making this change required the removal of a set of assertion checks. At least
empirically they seem unnecessary -- the interface compiles and runs fine.
This commit is contained in:
Dale Glass 2020-01-08 00:12:30 +01:00
parent 0bdfdfff4a
commit ea36e7a239
2 changed files with 7 additions and 23 deletions

View file

@ -377,7 +377,7 @@ public:
};
enum ComparisonFunction : uint16 {
enum ComparisonFunction {
NEVER = 0,
LESS,
EQUAL,

View file

@ -46,7 +46,7 @@ public:
typedef ::gpu::ComparisonFunction ComparisonFunction;
enum FillMode : uint8
enum FillMode
{
FILL_POINT = 0,
FILL_LINE,
@ -55,7 +55,7 @@ public:
NUM_FILL_MODES,
};
enum CullMode : uint8
enum CullMode
{
CULL_NONE = 0,
CULL_FRONT,
@ -64,7 +64,7 @@ public:
NUM_CULL_MODES,
};
enum StencilOp : uint16
enum StencilOp
{
STENCIL_OP_KEEP = 0,
STENCIL_OP_ZERO,
@ -78,7 +78,7 @@ public:
NUM_STENCIL_OPS,
};
enum BlendArg : uint16
enum BlendArg
{
ZERO = 0,
ONE,
@ -99,7 +99,7 @@ public:
NUM_BLEND_ARGS,
};
enum BlendOp : uint16
enum BlendOp
{
BLEND_OP_ADD = 0,
BLEND_OP_SUBTRACT,
@ -110,7 +110,7 @@ public:
NUM_BLEND_OPS,
};
enum ColorMask : uint8
enum ColorMask
{
WRITE_NONE = 0,
WRITE_RED = 1,
@ -140,8 +140,6 @@ public:
bool operator!=(const DepthTest& right) const { return getRaw() != right.getRaw(); }
};
static_assert(sizeof(DepthTest) == sizeof(uint32_t), "DepthTest size check");
struct StencilTest {
ComparisonFunction function : 4;
StencilOp failOp : 4;
@ -282,20 +280,6 @@ public:
Flags flags;
};
static_assert(offsetof(Data, depthBias) == 0, "Data offsets");
static_assert(offsetof(Data, depthBiasSlopeScale) == 4, "Data offsets");
static_assert(offsetof(Data, depthTest) == 8, "Data offsets");
static_assert(offsetof(Data, stencilActivation) == 12, "Data offsets");
static_assert(offsetof(Data, stencilTestFront) == 16, "Data offsets");
static_assert(offsetof(Data, stencilTestBack) == 20, "Data offsets");
static_assert(offsetof(Data, sampleMask) == 24, "Data offsets");
static_assert(offsetof(Data, blendFunction) == 28, "Data offsets");
static_assert(offsetof(Data, fillMode) == 32, "Data offsets");
static_assert(offsetof(Data, cullMode) == 33, "Data offsets");
static_assert(offsetof(Data, colorWriteMask) == 34, "Data offsets");
static_assert(offsetof(Data, flags) == 35, "Data offsets");
static_assert(sizeof(Data) == 36, "Data Size Check");
std::string getKey() const;
// The unique default values for all the fields