Ver código fonte

shader_cache: Correct versioning and size calculation.

Fernando Sahmkow 7 anos atrás
pai
commit
51ba60b27e

+ 6 - 1
src/video_core/renderer_opengl/gl_shader_cache.cpp

@@ -103,15 +103,20 @@ constexpr std::tuple<const char*, const char*, u32> GetPrimitiveDescription(GLen
 /// Calculates the size of a program stream
 /// Calculates the size of a program stream
 std::size_t CalculateProgramSize(const GLShader::ProgramCode& program) {
 std::size_t CalculateProgramSize(const GLShader::ProgramCode& program) {
     constexpr std::size_t start_offset = 10;
     constexpr std::size_t start_offset = 10;
+    constexpr u64 key = 0xE2400FFFFF07000FULL;
+    constexpr u64 mask =0xFFFFFFFFFF7FFFFFULL;
     std::size_t offset = start_offset;
     std::size_t offset = start_offset;
     std::size_t size = start_offset * sizeof(u64);
     std::size_t size = start_offset * sizeof(u64);
     while (offset < program.size()) {
     while (offset < program.size()) {
         const u64 instruction = program[offset];
         const u64 instruction = program[offset];
         if (!IsSchedInstruction(offset, start_offset)) {
         if (!IsSchedInstruction(offset, start_offset)) {
-            if (instruction == 0 || (instruction >> 52) == 0x50b) {
+            if ((instruction & mask) == key) {
                 // End on Maxwell's "nop" instruction
                 // End on Maxwell's "nop" instruction
                 break;
                 break;
             }
             }
+            if (instruction == 0) {
+                break;
+            }
         }
         }
         size += sizeof(u64);
         size += sizeof(u64);
         offset++;
         offset++;

+ 1 - 1
src/video_core/renderer_opengl/gl_shader_disk_cache.cpp

@@ -34,7 +34,7 @@ enum class PrecompiledEntryKind : u32 {
     Dump,
     Dump,
 };
 };
 
 
-constexpr u32 NativeVersion = 3;
+constexpr u32 NativeVersion = 4;
 
 
 // Making sure sizes doesn't change by accident
 // Making sure sizes doesn't change by accident
 static_assert(sizeof(BaseBindings) == 16);
 static_assert(sizeof(BaseBindings) == 16);