layers: Pass VkResults to PostCallRecord functions

In several cases, PostCallRecordApi functions need to do different
things depending upon the return code. The most flexible way to handle
this is to allow each validation object's PCR routines to decide this
for themselves.

All PostCallRecord functions returning a VkResult will now have a
VkResult as an additional, final parameter.

Change-Id: Ibd9d7c25f8c290dd228409e793f065bf0cd253fb
diff --git a/scripts/layer_chassis_generator.py b/scripts/layer_chassis_generator.py
index b204c0a..4bc84c9 100644
--- a/scripts/layer_chassis_generator.py
+++ b/scripts/layer_chassis_generator.py
@@ -568,7 +568,7 @@
 #endif
 
     for (auto intercept : framework->object_dispatch) {
-        intercept->PostCallRecordCreateInstance(pCreateInfo, pAllocator, pInstance);
+        intercept->PostCallRecordCreateInstance(pCreateInfo, pAllocator, pInstance, result);
     }
 
     InstanceExtensionWhitelist(framework, pCreateInfo, *pInstance);
@@ -712,7 +712,7 @@
 
     for (auto intercept : instance_interceptor->object_dispatch) {
         intercept->write_lock();
-        intercept->PostCallRecordCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
+        intercept->PostCallRecordCreateDevice(gpu, pCreateInfo, pAllocator, pDevice, result);
         intercept->write_unlock();
     }
 
@@ -769,7 +769,7 @@
     result = layer_create_report_callback(layer_data->report_data, false, pCreateInfo, pAllocator, pCallback);
     """ + postcallrecord_loop + """
         intercept->write_lock();
-        intercept->PostCallRecordCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
+        intercept->PostCallRecordCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback, result);
         intercept->write_unlock();
     }
     return result;
@@ -1005,6 +1005,9 @@
         pre_call_validate = pre_call_validate.replace("{}", " { return false; }")
         pre_call_record = 'virtual void PreCallRecord' + prototype
         post_call_record = 'virtual void PostCallRecord' + prototype
+        resulttype = elem.find('proto/type')
+        if resulttype.text == 'VkResult':
+            post_call_record = post_call_record.replace(')', ', VkResult result)')
         return '        %s\n        %s\n        %s\n' % (pre_call_validate, pre_call_record, post_call_record)
     #
     # Command generation
@@ -1110,24 +1113,14 @@
             self.appendSection('command', '    }')
 
         # Generate post-call object processing source code
-        return_type_indent = ''
-
         self.appendSection('command', '    %s' % self.postcallrecord_loop)
+        returnparam = ''
         if (resulttype.text == 'VkResult'):
-            return_type_indent = '    '
-            if name in self.alt_ret_codes:
-                self.appendSection('command', '%s    if (((VK_SUCCESS == result) || (VK_INCOMPLETE == result)) || (intercept->container_type == LayerObjectTypeThreading)) {' % return_type_indent)
-            else:
-                self.appendSection('command', '%s    if ((VK_SUCCESS == result)  || (intercept->container_type == LayerObjectTypeThreading)) {' % return_type_indent)
-
-        #self.appendSection('command', '%s    %s' % (return_type_indent, self.postcallrecord_loop))
-        self.appendSection('command', '%s        intercept->write_lock();' % return_type_indent)
-        self.appendSection('command', '%s        intercept->PostCallRecord%s(%s);' % (return_type_indent,api_function_name[2:], paramstext))
-        self.appendSection('command', '%s        intercept->write_unlock();' % return_type_indent)
-        self.appendSection('command', '%s    }' % return_type_indent)
-        if (resulttype.text == 'VkResult'):
-            self.appendSection('command', '    }')
-
+            returnparam = ', result'
+        self.appendSection('command', '        intercept->write_lock();')
+        self.appendSection('command', '        intercept->PostCallRecord%s(%s%s);' % (api_function_name[2:], paramstext, returnparam))
+        self.appendSection('command', '        intercept->write_unlock();')
+        self.appendSection('command', '    }')
         # Return result variable, if any.
         if (resulttype.text != 'void'):
             self.appendSection('command', '    return result;')