Added Mark's change to track Fence submit
authorTobin Ehlis <tobin@lunarg.com>
Fri, 16 Jan 2015 15:56:30 +0000 (08:56 -0700)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 5 Feb 2015 00:58:10 +0000 (17:58 -0700)
Conflicts:
layers/object_track.h

layers/object_track.h
xgl-layer-generate.py

index 9e9dc9b395a6b34c5c24c64926f9d5050794fcf0..883b5e3e7affb2bdb760e3bda6509bbd4f5daca9 100644 (file)
@@ -33,8 +33,16 @@ typedef enum _OBJECT_TRACK_ERROR
     OBJTRACK_MISSING_OBJECT,                    // Attempted look-up on object that isn't in global object list
     OBJTRACK_OBJECT_LEAK,                       // OBJECT was not correctly freed/destroyed
     OBJTRACK_OBJCOUNT_MAX_EXCEEDED,             // Request for Object data in excess of max obj count
+    OBJTRACK_INVALID_FENCE,                     // Requested status of unsubmitted fence object
 } OBJECT_TRACK_ERROR;
 
+// Object Status -- used to track state of individual objects
+typedef enum _OBJECT_STATUS
+{
+    OBJSTATUS_NONE,                             // No status is set
+    OBJSTATUS_FENCE_IS_SUBMITTED,               // Fence has been submitted
+} OBJECT_STATUS;
+// TODO : Make this code-generated
 // Object type enum
 typedef enum _XGL_OBJECT_TYPE
 {
@@ -143,6 +151,7 @@ typedef struct _OBJTRACK_NODE {
     void            *pObj;
     XGL_OBJECT_TYPE objType;
     uint64_t        numUses;
+    OBJECT_STATUS   status;
 } OBJTRACK_NODE;
 // prototype for extension functions
 uint64_t objTrackGetObjectCount(XGL_OBJECT_TYPE type);
index 77622d1acb2a520bb44bc5113da156c58f7bf44f..a157ecef4e12778e69d570333ea945eda94d0f61 100755 (executable)
@@ -577,6 +577,11 @@ class Subcommand(object):
                         using_line = ''
                     else:
                         using_line = '    ll_increment_use_count((void*)%s, %s);\n' % (param0_name, obj_type_mapping[p0_type])
+                    if 'QueueSubmit' in proto.name:
+                        using_line += '    set_status((void*)fence, XGL_OBJECT_TYPE_FENCE, OBJSTATUS_FENCE_IS_SUBMITTED);\n'
+                    elif 'GetFenceStatus' in proto.name:
+                        using_line += '    // Warn if submitted_flag is not set\n'
+                        using_line += '    validate_status((void*)fence, XGL_OBJECT_TYPE_FENCE, OBJSTATUS_FENCE_IS_SUBMITTED, "Status Requested for Unsubmitted Fence");\n'
                     if 'AllocDescriptor' in proto.name: # Allocates array of DSs
                         create_line =  '    for (uint32_t i; i < *pCount; i++) {\n'
                         create_line += '        ll_insert_obj((void*)pDescriptorSets[i], XGL_OBJECT_TYPE_DESCRIPTOR_SET);\n'
@@ -1189,6 +1194,41 @@ class ObjectTrackerSubcommand(Subcommand):
         header_txt.append('    sprintf(str, "Unable to remove obj %p. Was it created? Has it already been destroyed?", pObj);')
         header_txt.append('    layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pObj, 0, OBJTRACK_DESTROY_OBJECT_FAILED, "OBJTRACK", str);')
         header_txt.append('}')
+        header_txt.append('// Set selected flag state for an object node')
+        header_txt.append('static void set_status(void* pObj, XGL_OBJECT_TYPE objType, OBJECT_STATUS status_flag) {')
+        header_txt.append('    objNode *pTrav = pObjectHead[objType];')
+        header_txt.append('    while (pTrav) {')
+        header_txt.append('        if (pTrav->obj.pObj == pObj) {')
+        header_txt.append('            pTrav->obj.status |= status_flag;')
+        header_txt.append('            return;')
+        header_txt.append('        }')
+        header_txt.append('        pTrav = pTrav->pNextObj;')
+        header_txt.append('    }')
+        header_txt.append('    // If we do not find it print an error')
+        header_txt.append('    char str[1024];')
+        header_txt.append('    sprintf(str, "Unable to set status for non-existent object %p of %s type", pObj, string_XGL_OBJECT_TYPE(objType));')
+        header_txt.append('    layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", str);')
+        header_txt.append('}')
+        header_txt.append('')
+        header_txt.append('// Check object status for selected flag state')
+        header_txt.append('static void validate_status(void* pObj, XGL_OBJECT_TYPE objType, OBJECT_STATUS status_flag, char* fail_msg) {')
+        header_txt.append('    objNode *pTrav = pObjectHead[objType];')
+        header_txt.append('    while (pTrav) {')
+        header_txt.append('        if (pTrav->obj.pObj == pObj) {')
+        header_txt.append('            if ((pTrav->obj.status && status_flag) != status_flag) {')
+        header_txt.append('                char str[1024];')
+        header_txt.append('                sprintf(str, "OBJECT VALIDATION WARNING: %s object %p: %s", string_XGL_OBJECT_TYPE(objType), (void*)pObj, fail_msg);')
+        header_txt.append('                layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pObj, 0, OBJTRACK_INVALID_FENCE, "OBJTRACK", str);')
+        header_txt.append('            }')
+        header_txt.append('            return;')
+        header_txt.append('        }')
+        header_txt.append('        pTrav = pTrav->pNextObj;')
+        header_txt.append('    }')
+        header_txt.append('    // If we do not find it print an error')
+        header_txt.append('    char str[1024];')
+        header_txt.append('    sprintf(str, "Unable to obtain status for non-existent object %p of %s type", pObj, string_XGL_OBJECT_TYPE(objType));')
+        header_txt.append('    layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", str);')
+        header_txt.append('}')
 
         return "\n".join(header_txt)