summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h')
-rw-r--r--Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h b/Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h
new file mode 100644
index 0000000..8de6be8
--- /dev/null
+++ b/Runtime/GfxDevice/opengles30/FixedFunctionStateGLES30.h
@@ -0,0 +1,65 @@
+#ifndef FIXEDFUNCTIONSTATE_GLES30_H
+#define FIXEDFUNCTIONSTATE_GLES30_H
+
+#include "IncludesGLES30.h"
+#include "Runtime/GfxDevice/GfxDeviceTypes.h"
+#include <string>
+
+// we can use one var to determine both shift and mask, but let help out the compiler ;-)
+#define FFPSTATE_SET_MASK(target, idx, val, shift_mul, mask) \
+do{ \
+ target &= ~(mask << ((idx)*shift_mul)); \
+ target |= (val << ((idx)*shift_mul)); \
+}while(0) \
+
+
+
+class FixedFunctionStateGLES30
+{
+public:
+ FixedFunctionStateGLES30();
+
+ UInt32 texUnitColorCombiner[kMaxSupportedTextureUnitsGLES];
+ UInt32 texUnitAlphaCombiner[kMaxSupportedTextureUnitsGLES];
+ bool texUnitCube[kMaxSupportedTextureUnitsGLES];
+ int texUnitGen[kMaxSupportedTextureUnitsGLES];
+ int texUnitCount;
+
+ // we will use 4bits per light - this way we can handle up to 8 lights (though kMaxEmulatedVertexLights = 4)
+ UInt32 lightType;
+ // we will use 2 bits per tex unit - one for perspective divide, the other one for if we need matrix mul at all
+ // this way we can store 16 texunit info (though kMaxSupportedTextureUnitsGLES = 8)
+ UInt32 texUnitMatrix;
+
+
+ bool lightingEnabled;
+ bool specularEnabled;
+ bool onlyDirectionalLights;
+ int lightCount : 8;
+ FogMode fogMode : 8;
+ CompareFunction alphaTest : 8;
+
+ bool useUniformInsteadOfVertexColor;
+ bool useVertexColorAsAmbientAndDiffuse;
+ bool useVertexColorAsEmission;
+ bool addSpecularAfterTexturing;
+
+ unsigned GetLightType(int i) const { return (lightType >> (i*4)) & 0xF; }
+ void SetLightType(int i, unsigned type) { FFPSTATE_SET_MASK(lightType, i, type, 4, 0xF); }
+
+ bool NeedTexUnitMatrix(int i) const { return ((texUnitMatrix >> (i*2)) & 0x1) != 0; }
+ bool IsTexUnitProjected(int i) const { return ((texUnitMatrix >> (i*2)) & 0x2) != 0; }
+
+ void SetTexUnitMatrixParam(int i, bool hasMatrix, bool isProjected)
+ {
+ int mask = (hasMatrix ? 1 : 0) | (isProjected ? 2 : 0);
+ FFPSTATE_SET_MASK(texUnitMatrix, i, mask, 2, 0x3);
+ }
+
+ std::string ToString () const;
+};
+
+
+#undef FFPSTATE_SET_MASK
+
+#endif /* FIXEDFUNCTIONSTATE_GLES30_H */