mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:18:05 +02:00
Finish removal of getRaw() and bit fields
This commit is contained in:
parent
8f65a90453
commit
367c5f39df
1 changed files with 78 additions and 49 deletions
|
@ -136,25 +136,26 @@ public:
|
||||||
uint8 getWriteMask() const { return writeMask; }
|
uint8 getWriteMask() const { return writeMask; }
|
||||||
|
|
||||||
bool operator==(const DepthTest& right) const {
|
bool operator==(const DepthTest& right) const {
|
||||||
return writeMask == right.writeMask && enabled == right.enabled && function == right.function;
|
return
|
||||||
|
writeMask == right.writeMask &&
|
||||||
|
enabled == right.enabled &&
|
||||||
|
function == right.function;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const DepthTest& right) const {
|
bool operator!=(const DepthTest& right) const {
|
||||||
return writeMask != right.writeMask || enabled != right.enabled || function != right.function;
|
return !(right == *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator QString() const {
|
operator QString() const {
|
||||||
return QString("{ writeMask = %1, enabled = %2, function = %3 }").arg(writeMask).arg(enabled).arg(function);
|
return QString("{ writeMask = %1, enabled = %2, function = %3 }").arg(writeMask).arg(enabled).arg(function);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StencilTest {
|
struct StencilTest {
|
||||||
ComparisonFunction function : 4;
|
ComparisonFunction function;
|
||||||
StencilOp failOp : 4;
|
StencilOp failOp;
|
||||||
StencilOp depthFailOp : 4;
|
StencilOp depthFailOp;
|
||||||
StencilOp passOp : 4;
|
StencilOp passOp;
|
||||||
int8 reference{ 0 };
|
int8 reference{ 0 };
|
||||||
uint8 readMask{ 0xff };
|
uint8 readMask{ 0xff };
|
||||||
|
|
||||||
|
@ -176,47 +177,56 @@ public:
|
||||||
int8 getReference() const { return reference; }
|
int8 getReference() const { return reference; }
|
||||||
uint8 getReadMask() const { return readMask; }
|
uint8 getReadMask() const { return readMask; }
|
||||||
|
|
||||||
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
bool operator==(const StencilTest& right) const {
|
||||||
StencilTest(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
return
|
||||||
bool operator==(const StencilTest& right) const { return getRaw() == right.getRaw(); }
|
function == right.function &&
|
||||||
bool operator!=(const StencilTest& right) const { return getRaw() != right.getRaw(); }
|
failOp == right.failOp &&
|
||||||
|
depthFailOp == right.depthFailOp &&
|
||||||
|
passOp == right.passOp &&
|
||||||
|
reference == right.reference &&
|
||||||
|
readMask == right.readMask;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const StencilTest &right) const { return !(right==*this); }
|
||||||
};
|
};
|
||||||
static_assert(sizeof(StencilTest) == sizeof(uint32_t), "StencilTest size check");
|
|
||||||
|
|
||||||
StencilTest stencilTestFront;
|
StencilTest stencilTestFront;
|
||||||
|
|
||||||
struct StencilActivation {
|
struct StencilActivation {
|
||||||
uint8 frontWriteMask = 0xFF;
|
uint8 frontWriteMask = 0xFF;
|
||||||
uint8 backWriteMask = 0xFF;
|
uint8 backWriteMask = 0xFF;
|
||||||
bool enabled : 1;
|
bool enabled;
|
||||||
uint8 _spare1 : 7;
|
|
||||||
uint8 _spare2{ 0 };
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StencilActivation(bool enabled = false, uint8 frontWriteMask = 0xFF, uint8 backWriteMask = 0xFF) :
|
StencilActivation(bool enabled = false, uint8 frontWriteMask = 0xFF, uint8 backWriteMask = 0xFF) :
|
||||||
frontWriteMask(frontWriteMask), backWriteMask(backWriteMask), enabled(enabled), _spare1{ 0 } {}
|
frontWriteMask(frontWriteMask), backWriteMask(backWriteMask), enabled(enabled) {}
|
||||||
|
|
||||||
bool isEnabled() const { return enabled; }
|
bool isEnabled() const { return enabled; }
|
||||||
uint8 getWriteMaskFront() const { return frontWriteMask; }
|
uint8 getWriteMaskFront() const { return frontWriteMask; }
|
||||||
uint8 getWriteMaskBack() const { return backWriteMask; }
|
uint8 getWriteMaskBack() const { return backWriteMask; }
|
||||||
|
|
||||||
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
bool operator==(const StencilActivation& right) const {
|
||||||
StencilActivation(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
return
|
||||||
bool operator==(const StencilActivation& right) const { return getRaw() == right.getRaw(); }
|
frontWriteMask == right.frontWriteMask &&
|
||||||
bool operator!=(const StencilActivation& right) const { return getRaw() != right.getRaw(); }
|
backWriteMask == right.backWriteMask &&
|
||||||
};
|
enabled == right.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
static_assert(sizeof(StencilActivation) == sizeof(uint32_t), "StencilActivation size check");
|
bool operator!=(const StencilActivation& right) const {
|
||||||
|
return !(right == *this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct BlendFunction {
|
struct BlendFunction {
|
||||||
// Using uint8 here will make the structure as a whole not align to 32 bits
|
// Using uint8 here will make the structure as a whole not align to 32 bits
|
||||||
uint16 enabled : 8;
|
uint16 enabled;
|
||||||
BlendArg sourceColor : 4;
|
BlendArg sourceColor;
|
||||||
BlendArg sourceAlpha : 4;
|
BlendArg sourceAlpha;
|
||||||
BlendArg destColor : 4;
|
BlendArg destColor;
|
||||||
BlendArg destAlpha : 4;
|
BlendArg destAlpha;
|
||||||
BlendOp opColor : 4;
|
BlendOp opColor;
|
||||||
BlendOp opAlpha : 4;
|
BlendOp opAlpha;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BlendFunction(bool enabled,
|
BlendFunction(bool enabled,
|
||||||
|
@ -227,7 +237,7 @@ public:
|
||||||
BlendOp operationAlpha,
|
BlendOp operationAlpha,
|
||||||
BlendArg destinationAlpha) :
|
BlendArg destinationAlpha) :
|
||||||
enabled(enabled),
|
enabled(enabled),
|
||||||
sourceColor(sourceColor), sourceAlpha(sourceAlpha),
|
sourceColor(sourceColor), sourceAlpha(sourceAlpha),
|
||||||
destColor(destinationColor), destAlpha(destinationAlpha),
|
destColor(destinationColor), destAlpha(destinationAlpha),
|
||||||
opColor(operationColor), opAlpha(operationAlpha) {}
|
opColor(operationColor), opAlpha(operationAlpha) {}
|
||||||
|
|
||||||
|
@ -244,32 +254,51 @@ public:
|
||||||
BlendArg getDestinationAlpha() const { return destAlpha; }
|
BlendArg getDestinationAlpha() const { return destAlpha; }
|
||||||
BlendOp getOperationAlpha() const { return opAlpha; }
|
BlendOp getOperationAlpha() const { return opAlpha; }
|
||||||
|
|
||||||
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
bool operator==(const BlendFunction& right) const {
|
||||||
BlendFunction(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
return
|
||||||
bool operator==(const BlendFunction& right) const { return getRaw() == right.getRaw(); }
|
enabled == right.enabled &&
|
||||||
bool operator!=(const BlendFunction& right) const { return getRaw() != right.getRaw(); }
|
sourceColor == right.sourceColor &&
|
||||||
};
|
sourceAlpha == right.sourceAlpha &&
|
||||||
|
destColor == right.destColor &&
|
||||||
|
destAlpha == right.destAlpha &&
|
||||||
|
opColor == right.opColor &&
|
||||||
|
opAlpha == right.opAlpha;
|
||||||
|
|
||||||
static_assert(sizeof(BlendFunction) == sizeof(uint32_t), "BlendFunction size check");
|
}
|
||||||
|
|
||||||
|
bool operator!=(const BlendFunction& right) const {
|
||||||
|
return !(right == *this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct Flags {
|
struct Flags {
|
||||||
Flags() :
|
Flags() :
|
||||||
frontFaceClockwise(false), depthClampEnable(false), scissorEnable(false), multisampleEnable(true),
|
frontFaceClockwise(false), depthClampEnable(false), scissorEnable(false), multisampleEnable(true),
|
||||||
antialisedLineEnable(true), alphaToCoverageEnable(false), _spare1(0) {}
|
antialisedLineEnable(true), alphaToCoverageEnable(false) {}
|
||||||
bool frontFaceClockwise : 1;
|
bool frontFaceClockwise;
|
||||||
bool depthClampEnable : 1;
|
bool depthClampEnable;
|
||||||
bool scissorEnable : 1;
|
bool scissorEnable;
|
||||||
bool multisampleEnable : 1;
|
bool multisampleEnable;
|
||||||
bool antialisedLineEnable : 1;
|
bool antialisedLineEnable;
|
||||||
bool alphaToCoverageEnable : 1;
|
bool alphaToCoverageEnable;
|
||||||
uint8 _spare1 : 2;
|
|
||||||
|
|
||||||
bool operator==(const Flags& right) const { return *(uint8*)this == *(uint8*)&right; }
|
|
||||||
bool operator!=(const Flags& right) const { return *(uint8*)this != *(uint8*)&right; }
|
bool operator==(const Flags& right) const {
|
||||||
|
return
|
||||||
|
frontFaceClockwise == right.frontFaceClockwise &&
|
||||||
|
depthClampEnable == right.depthClampEnable &&
|
||||||
|
scissorEnable == right.scissorEnable &&
|
||||||
|
multisampleEnable == right.multisampleEnable &&
|
||||||
|
antialisedLineEnable == right.antialisedLineEnable &&
|
||||||
|
alphaToCoverageEnable == right.alphaToCoverageEnable;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Flags& right) const {
|
||||||
|
return !(right == *this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(Flags) == sizeof(uint8), "Flags size check");
|
|
||||||
|
|
||||||
// The Data class is the full explicit description of the State class fields value.
|
// The Data class is the full explicit description of the State class fields value.
|
||||||
// Useful for having one const static called Default for reference or for the gpu::Backend to keep track of the current value
|
// Useful for having one const static called Default for reference or for the gpu::Backend to keep track of the current value
|
||||||
class Data {
|
class Data {
|
||||||
|
|
Loading…
Reference in a new issue