Pārlūkot izejas kodu

Take instruction length into account when copying shader bytecode / skipping comments.

Lasse Öörni 14 gadi atpakaļ
vecāks
revīzija
27f28faa6f
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      Tools/ShaderCompiler/ShaderCompiler.cpp

+ 9 - 1
Tools/ShaderCompiler/ShaderCompiler.cpp

@@ -722,10 +722,16 @@ void CopyStrippedCode(PODVector<unsigned char>& dest, void* src, unsigned srcSiz
     
     
     dest.Clear();
     dest.Clear();
     
     
+    unsigned instrLength = 0;
     for (unsigned i = 0; i < srcWordSize; ++i)
     for (unsigned i = 0; i < srcWordSize; ++i)
     {
     {
-        if ((srcWords[i] & 0xffff) != D3DSIO_COMMENT)
+        if ((instrLength) || (srcWords[i] & 0xffff) != D3DSIO_COMMENT)
         {
         {
+            if (!instrLength)
+                instrLength = (srcWords[i] & 0x0f000000) >> 24;
+            else
+                --instrLength;
+            
             // Not a comment, copy the data
             // Not a comment, copy the data
             unsigned char* srcBytes = (unsigned char*)(srcWords + i);
             unsigned char* srcBytes = (unsigned char*)(srcWords + i);
             dest.Push(srcBytes[0]);
             dest.Push(srcBytes[0]);
@@ -734,7 +740,9 @@ void CopyStrippedCode(PODVector<unsigned char>& dest, void* src, unsigned srcSiz
             dest.Push(srcBytes[3]);
             dest.Push(srcBytes[3]);
         }
         }
         else
         else
+        {
             // Skip the comment
             // Skip the comment
             i += (srcWords[i] >> 16);
             i += (srcWords[i] >> 16);
+        }
     }
     }
 }
 }