Browse Source

0x002031c4,CFTTGraphicsDeviceOGLES::setVertexBuffe,317,317 bugfix

DESKTOP-AB9OQPJ\RED-10 3 years ago
parent
commit
26e9c0ea76
3 changed files with 244 additions and 2 deletions
  1. 1 1
      jni/CFTTGLES2Wrapper.cpp
  2. 1 1
      jni/CFTTGLES2Wrapper.h
  3. 242 0
      jni/CFTTGraphicsDeviceOGLES.cpp

+ 1 - 1
jni/CFTTGLES2Wrapper.cpp

@@ -27,7 +27,7 @@ float CFTTGLES2Wrapper::s_fClearColour[4];                     //005AA71C
 int CFTTGLES2Wrapper::s_iClearStencil;                         //005AA72C
 uint32_t CFTTGLES2Wrapper::s_uProgram;                         //005AA730
 int CFTTGLES2Wrapper::s_iStencilFuncRef;                       //005AA734
-bool CFTTGLES2Wrapper::s_bVertexAttribEnabled[8];              //005AA738
+char CFTTGLES2Wrapper::s_bVertexAttribEnabled[8];              //005AA738
 uchar CFTTGLES2Wrapper::s_cEnabledState[206];                  //005AA5F8
 
 //-------------------------------------------------------------------------------------------------

+ 1 - 1
jni/CFTTGLES2Wrapper.h

@@ -90,7 +90,7 @@ public:
   static int s_iClearStencil;
   static uint32_t s_uProgram;
   static int s_iStencilFuncRef;
-  static bool s_bVertexAttribEnabled[8];
+  static char s_bVertexAttribEnabled[8];
 
   //00348A50
   static bool s_bDepthMask;

+ 242 - 0
jni/CFTTGraphicsDeviceOGLES.cpp

@@ -363,7 +363,249 @@ void CFTTGraphicsDeviceOGLES::setStencilOp(EFTTStencilOp esfail,
 //-------------------------------------------------------------------------------------------------
 //002031C4 //-_- 经过单元测试,功能正常
 void CFTTGraphicsDeviceOGLES::setVertexBuffer(CFTTGraphicsBuffer *pGraphBuf, uint a2, uint a3, uint a4) {
+  uchar *r4_pbuf = (uchar *)a4;
+  CFTTGraphicsBufferOGLES *pBufOGLES = (CFTTGraphicsBufferOGLES *)pGraphBuf;
+  if (CFTTGLES2Wrapper::s_uBoundArrayBuffer != pBufOGLES->bindBuf_10) {
+    CFTTGLES2Wrapper::s_uBoundArrayBuffer = pBufOGLES->bindBuf_10;
+    glBindBuffer(GL_ARRAY_BUFFER, pBufOGLES->bindBuf_10);
+  }
+   //LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[1]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[2]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[3]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[4]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[5]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[6]);
+  // LOGE("CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]=%x",CFTTGLES2Wrapper::s_bVertexAttribEnabled[7]);
+
+  // loc_2031EA
+  if (!pBufOGLES->bindBuf_10)
+    r4_pbuf = pBufOGLES->pBuf_C + a4;  // 002031EE 04 44  ADD R4, R0
+
+  // loc_2031F0
+  uint r11_uint = a2 & 0xF00;
+  uint r5_uint = a2 & 0xF000;
+  uint r10_uint = r11_uint;
+  if ((a2 & 0xF000000) != 0x2000000)
+    r10_uint = 0;
+
+  // 0020320C
+  if (a2 & 0xF) {
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]!=1) {
+      // 0020321A
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[0] = 1;
+      glEnableVertexAttribArray(0);
+    }
+
+    // loc_203224
+    switch (a2 & 0xF) {
+      case 1:
+        // loc_203238
+        glVertexAttribPointer(0, 3, GL_FLOAT, false, a3, (const void *)r4_pbuf);  // GL_FLOAT
+        r4_pbuf += 12;
+        break;
+
+      case 2:
+        // loc_20325C
+        glVertexAttribPointer(0, 3, GL_SHORT, true, a3, (const void *)r4_pbuf);
+        r4_pbuf += 8;
+        break;
+
+      case 3:
+        // loc_203266
+        glVertexAttribPointer(0, 3, GL_BYTE, false, a3, (const void *)r4_pbuf);  // GL_BYTE
+        r4_pbuf += 4;
+        break;
+
+      case 4:
+        // loc_20327C
+        glVertexAttribPointer(0, 2, GL_FLOAT, false, a3, (const void *)r4_pbuf);  // GL_FLOAT
+        r4_pbuf += 8;
+        break;
+
+      case 5:
+        // loc_20328C
+        glVertexAttribPointer(0, 4, GL_SHORT, true, a3, (const void *)r4_pbuf);  // GL_SHORT
+        r4_pbuf += 8;
+        break;
+
+      default:
+        break;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[0]) {  // loc_20324E
+    // 00203250
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[0] = false;
+    glDisableVertexAttribArray(0);
+  }
+
+  // break_20322E
+  if (r5_uint) {
+    // 002032A8
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[2]!=1) {
+      // 002032AC
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[2] = 1;
+      glEnableVertexAttribArray(2);
+    }
+
+    // loc_2032B6
+    switch (r5_uint) {
+      case 0x3000:
+        // loc_2032EC
+        glVertexAttribPointer(2, 3, GL_BYTE, true, a3, (const void *)r4_pbuf);
+        r4_pbuf += 4;
+        break;
+
+      case 0x2000u:
+        // loc_203302
+        glVertexAttribPointer(2, 4, GL_SHORT, true, a3, (const void *)r4_pbuf);
+        r4_pbuf += 8;
+        break;
+
+      case 0x1000u:
+        // 002032C8
+        glVertexAttribPointer(2, 3, GL_FLOAT, false, a3, (const void *)r4_pbuf);
+        r4_pbuf += 12;
+        break;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[2]) {  // loc_2032DE
+    // 002032E0
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[2] = false;
+    glDisableVertexAttribArray(2);
+  }
+
+  // loc_203316
+  uint r7_uint = a2 & 0xF0;
+  if (r7_uint) {
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[1]!=1) {
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[1] = 1;
+      glEnableVertexAttribArray(1);
+    }
+
+    // loc_203328
+    if (r7_uint == 32) {
+      // loc_203354
+      glVertexAttribPointer(1, 4, GL_FLOAT, false, a3, (const void *)r4_pbuf);
+      r4_pbuf += 16;
+    } else if (r7_uint == 16) {
+      // 00203330
+      glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, true, a3, (const void *)r4_pbuf);
+      r4_pbuf += 4;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[1]) {  // loc_203346
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[1] = false;
+    glDisableVertexAttribArray(1);
+  }
+
+  // loc_203368
+  if (r11_uint) {
+    // 00203370
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[3]!=1) {
+      // 00203374
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[3] = 1;
+      glEnableVertexAttribArray(3);
+    }
+
+    // loc_20337E
+    r11_uint=r11_uint&0xFFF;
+    if (r11_uint == 0x200) {
+      // loc_2033B2
+      glVertexAttribPointer(3, 2, GL_SHORT, true, a3, (const void *)r4_pbuf);
+      r4_pbuf += 4;
+    } else if (r11_uint == 0x100) {
+      // 0020338E
+      glVertexAttribPointer(3, 2, GL_FLOAT, false, a3, (const void *)r4_pbuf);
+      r4_pbuf += 8;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[3]) {  // loc_2033A4
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[3] = false;
+    glDisableVertexAttribArray(3);
+  }
+
+  // loc_2033C6
+  if (r10_uint) {
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[4]!=1) {
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[4] = 1;
+      glEnableVertexAttribArray(4);
+    }
+
+    // loc_2033E0
+    if ((r10_uint & 0xFFF) == 0x200) {
+      // loc_203414
+      glVertexAttribPointer(4, 2, GL_SHORT, true, a3, (const void *)r4_pbuf);
+      r4_pbuf += 4;
+    } else if ((r10_uint & 0xFFF) == 0x100) {
+      // loc_203428
+      glVertexAttribPointer(4, 2, GL_FLOAT, false, a3, (const void *)r4_pbuf);
+      r4_pbuf += 8;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[4]) {  // loc_203406
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[4] = false;
+    glDisableVertexAttribArray(4);
+  }
+
+  // loc_203428
+  r5_uint = a2 & 0xF00000;  ////loc_2033C6
+  if (r5_uint) {
+    // 0020342C
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[5]!=1) {
+      // 00203430
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[5] = true;
+      glEnableVertexAttribArray(5);
+    }
+
+    // loc_20343A
+    if ((r5_uint&0xffffff) == 0x300000) {
+      // loc_203474
+      glVertexAttribPointer(5, 3, GL_BYTE, true, a3, (const void *)r4_pbuf);
+      r4_pbuf += 4;
+    } else if ((r5_uint&0xffffff) == 0x200000) {
+      // loc_20348A
+      glVertexAttribPointer(5, 4, GL_SHORT, true, a3, (const void *)r4_pbuf);
+      r4_pbuf += 8;
+    } else if ((r5_uint&0xffffff) == 0x100000) {
+      // 00203450
+      glVertexAttribPointer(5, 3, GL_FLOAT, false, a3, (const void *)r4_pbuf);
+      r4_pbuf += 12;
+    }
+  } else if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[5]) {
+    CFTTGLES2Wrapper::s_bVertexAttribEnabled[5] = false;
+    glDisableVertexAttribArray(5);
+  }
+
+  // loc_20349E
+  if (a3 >= 0x10000000) {
+    // 002034A6
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[6]!=1) {
+      // 002034AA
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[6] = 0;
+      glEnableVertexAttribArray(6);
+    }
+
+    // loc_2034B4
+    glVertexAttribPointer(6, 4, GL_UNSIGNED_BYTE, false, a3, (const void *)r4_pbuf);
+    r4_pbuf += 4;  // 002034C8 04 34 ADDS            R4, #4
+
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[7]!=1) {
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[7] = 1;
+      glEnableVertexAttribArray(7);
+    }
+    // loc_2034D8
+    glVertexAttribPointer(7, 4, GL_UNSIGNED_SHORT, true, a3, r4_pbuf);
+  } else {
+    // loc_2034EE
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[6]) {
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[6] = false;
+      glDisableVertexAttribArray(6);
+    }
+
+    // loc_2034FA
+    if (CFTTGLES2Wrapper::s_bVertexAttribEnabled[7]) {
+      CFTTGLES2Wrapper::s_bVertexAttribEnabled[7] = false;
+      glDisableVertexAttribArray(7);
+    }
+  }
 }
+
 //-------------------------------------------------------------------------------------------------
 //00202CE4
 void CFTTGraphicsDeviceOGLES::setWindowHandle(void *) {