diff --git a/GPU/Directx9/ShaderManagerDX9.cpp b/GPU/Directx9/ShaderManagerDX9.cpp index fc466d97b6..8d2e7a68e1 100644 --- a/GPU/Directx9/ShaderManagerDX9.cpp +++ b/GPU/Directx9/ShaderManagerDX9.cpp @@ -123,7 +123,7 @@ LinkedShaderDX9::LinkedShaderDX9(VSShader *vs, PSShader *fs, u32 vertType, bool u_world = GetConstantByName("u_world"); u_texmtx = GetConstantByName("u_texmtx"); - if (gstate.getWeightMask() != 0) + if (vertTypeGetWeightMask(vertType) != 0) numBones = TranslateNumBonesDX9(vertTypeGetNumBoneWeights(vertType)); else numBones = 0; diff --git a/GPU/Directx9/SplineDX9.cpp b/GPU/Directx9/SplineDX9.cpp index 0bc4315df4..97e38a12cc 100644 --- a/GPU/Directx9/SplineDX9.cpp +++ b/GPU/Directx9/SplineDX9.cpp @@ -60,7 +60,7 @@ void TransformDrawEngineDX9::DrawBezier(int ucount, int vcount) { } } - if (!gstate.getTexCoordMask()) { + if (!vertTypeGetTexCoordMask(gstate.vertType)) { VertexDecoderDX9 *dec = GetVertexDecoder(gstate.vertType); dec->SetVertexType(gstate.vertType); u32 newVertType = dec->InjectUVs(decoded2, Memory::GetPointer(gstate_c.vertexAddr), customUV, 16); diff --git a/GPU/Directx9/VertexShaderGeneratorDX9.cpp b/GPU/Directx9/VertexShaderGeneratorDX9.cpp index 00e2343660..8cb2f71c91 100644 --- a/GPU/Directx9/VertexShaderGeneratorDX9.cpp +++ b/GPU/Directx9/VertexShaderGeneratorDX9.cpp @@ -56,7 +56,7 @@ void ComputeVertexShaderIDDX9(VertexShaderIDDX9 *id, int prim, bool useHWTransfo bool hasColor = (vertType & GE_VTYPE_COL_MASK) != 0; bool hasNormal = (vertType & GE_VTYPE_NRM_MASK) != 0; - bool hasBones = gstate.getWeightMask() != GE_VTYPE_WEIGHT_NONE; + bool hasBones = vertTypeGetWeightMask(vertType) != GE_VTYPE_WEIGHT_NONE; bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear(); bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); @@ -171,7 +171,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, "float4x4 u_view;\n"); if (gstate.getUVGenMode() == 1) WRITE(p, "float4x4 u_texmtx;\n"); - if (gstate.getWeightMask() != GE_VTYPE_WEIGHT_NONE) { + if (vertTypeGetWeightMask(vertType) != GE_VTYPE_WEIGHT_NONE) { int numBones = TranslateNumBonesDX9(vertTypeGetNumBoneWeights(vertType)); #ifdef USE_BONE_ARRAY WRITE(p, "float4x4 u_bone[%i];\n", numBones); @@ -222,7 +222,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, " struct VS_IN \n"); WRITE(p, " \n"); WRITE(p, " { \n"); - if (gstate.getWeightMask() != GE_VTYPE_WEIGHT_NONE) { + if (vertTypeGetWeightMask(vertType) != GE_VTYPE_WEIGHT_NONE) { WRITE(p, "%s", boneWeightAttrDecl[TranslateNumBonesDX9(vertTypeGetNumBoneWeights(vertType))]); } if (doTexture) { @@ -278,7 +278,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, " VS_OUT Out = (VS_OUT)0; \n"); if (useHWTransform) { // Step 1: World Transform / Skinning - if (gstate.getWeightMask() == GE_VTYPE_WEIGHT_NONE) { + if (vertTypeGetWeightMask(vertType) == GE_VTYPE_WEIGHT_NONE) { // No skinning, just standard T&L. WRITE(p, " float3 worldpos = mul(float4(In.ObjPos.xyz, 1.0), u_world).xyz;\n"); if (hasNormal) @@ -289,7 +289,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { int numWeights = TranslateNumBonesDX9(vertTypeGetNumBoneWeights(vertType)); static const char *rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f}; - const char *factor = rescale[gstate.getWeightMask() >> GE_VTYPE_WEIGHT_SHIFT]; + const char *factor = rescale[vertTypeGetWeightMask(vertType) >> GE_VTYPE_WEIGHT_SHIFT]; static const char * const boneWeightAttr[8] = { "a_w1.x", "a_w1.y", "a_w1.z", "a_w1.w", diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 74116aad53..c25cb83266 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -343,7 +343,7 @@ void LinkedShader::updateUniforms() { // Not sure what GE_TEXMAP_UNKNOWN is, but seen in Riviera. Treating the same as GE_TEXMAP_TEXTURE_COORDS works. if (gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_COORDS || gstate.getUVGenMode() == GE_TEXMAP_UNKNOWN) { static const float rescale[4] = {1.0f, 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f}; - float factor = rescale[gstate.getTexCoordMask() >> GE_VTYPE_TC_SHIFT]; + float factor = rescale[(gstate.vertType & GE_VTYPE_TC_MASK) >> GE_VTYPE_TC_SHIFT]; uvscaleoff[0] = gstate_c.uv.uScale * factor * widthFactor; uvscaleoff[1] = gstate_c.uv.vScale * factor * heightFactor; uvscaleoff[2] = gstate_c.uv.uOff * widthFactor; diff --git a/GPU/GLES/Spline.cpp b/GPU/GLES/Spline.cpp index e38a0f341a..c28bc3b7fa 100644 --- a/GPU/GLES/Spline.cpp +++ b/GPU/GLES/Spline.cpp @@ -174,7 +174,7 @@ void TransformDrawEngine::DrawBezier(int ucount, int vcount) { } } - if (!gstate.getTexCoordMask()) { + if (!vertTypeGetTexCoordMask(gstate.vertType)) { VertexDecoder *dec = GetVertexDecoder(gstate.vertType); dec->SetVertexType(gstate.vertType); u32 newVertType = dec->InjectUVs(decoded2, Memory::GetPointer(gstate_c.vertexAddr), customUV, 16); diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index f7922f8c4b..fe278a357b 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -107,7 +107,7 @@ void ComputeVertexShaderID(VertexShaderID *id, u32 vertType, int prim, bool useH } } id->d[1] |= gstate.isLightingEnabled() << 24; - id->d[1] |= (gstate.getWeightMask() >> GE_VTYPE_WEIGHT_SHIFT) << 25; + id->d[1] |= (vertTypeGetWeightMask(vertType) >> GE_VTYPE_WEIGHT_SHIFT) << 25; } } @@ -308,7 +308,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf int numWeights = TranslateNumBones(vertTypeGetNumBoneWeights(vertType)); static const char *rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f}; - const char *factor = rescale[gstate.getWeightMask() >> GE_VTYPE_WEIGHT_SHIFT]; + const char *factor = rescale[vertTypeGetWeightMask(vertType) >> GE_VTYPE_WEIGHT_SHIFT]; static const char * const boneWeightAttr[8] = { "a_w1.x", "a_w1.y", "a_w1.z", "a_w1.w", diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 3d03aead06..7ac66a15d1 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -368,8 +368,6 @@ struct GPUgstate // Vertex type bool isModeThrough() const { return (vertType & GE_VTYPE_THROUGH) != 0; } - int getWeightMask() const { return vertType & GE_VTYPE_WEIGHT_MASK; } - int getTexCoordMask() const { return vertType & GE_VTYPE_TC_MASK; } bool areNormalsReversed() const { return reversenormals & 1; } GEPatchPrimType getPatchPrimitiveType() const { return static_cast(patchprimitive & 3); } @@ -402,6 +400,7 @@ enum SkipDrawReasonFlags { inline bool vertTypeIsSkinningEnabled(u32 vertType) { return ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE); } inline int vertTypeGetNumBoneWeights(u32 vertType) { return 1 + ((vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT); } inline int vertTypeGetWeightMask(u32 vertType) { return vertType & GE_VTYPE_WEIGHT_MASK; } +inline int vertTypeGetTexCoordMask(u32 vertType) { return vertType & GE_VTYPE_TC_MASK; } // The rest is cached simplified/converted data for fast access.