layers: Improve xglCreateRenderPass validation.
authorJeremy Hayes <jeremy@lunarg.com>
Tue, 7 Apr 2015 15:49:05 +0000 (09:49 -0600)
committerChia-I Wu <olv@lunarg.com>
Thu, 16 Apr 2015 09:33:28 +0000 (17:33 +0800)
layers/param_checker.cpp

index 3256e47..8c3dfa1 100644 (file)
@@ -165,7 +165,7 @@ void PreCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreate
     if(gpu == nullptr)
     {
         char const str[] = "xglCreateDevice parameter, XGL_PHYSICAL_GPU gpu, is nullptr "\
-            "(postcondition).";
+            "(precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -173,7 +173,7 @@ void PreCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreate
     if(pCreateInfo == nullptr)
     {
         char const str[] = "xglCreateDevice parameter, XGL_DEVICE_CREATE_INFO* pCreateInfo, is "\
-            "nullptr (postcondition).";
+            "nullptr (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -189,7 +189,7 @@ void PreCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreate
     if(pCreateInfo->queueRecordCount == 0)
     {
         char const str[] = "xglCreateDevice parameter, uint32_t pCreateInfo->queueRecordCount, is "\
-            "zero (postcondition).";
+            "zero (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -197,7 +197,7 @@ void PreCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreate
     if(pCreateInfo->pRequestedQueues == nullptr)
     {
         char const str[] = "xglCreateDevice parameter, XGL_DEVICE_QUEUE_CREATE_INFO* pCreateInfo->pRequestedQueues, is "\
-            "nullptr (postcondition).";
+            "nullptr (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -217,7 +217,7 @@ void PreCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreate
     if(!validate_XGL_VALIDATION_LEVEL(pCreateInfo->maxValidationLevel))
     {
         char const str[] = "xglCreateDevice parameter, XGL_VALIDATION_LEVEL pCreateInfo->maxValidationLevel, is "\
-            "unrecognized (postcondition).";
+            "unrecognized (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -658,32 +658,32 @@ void PreCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo)
 {
     if(pCreateInfo == nullptr)
     {
-        char const str[] = "xglCreateImage parameter, XGL_IMAGE_CREATE_INFO* pCreateInfo, is \
-            nullptr (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_IMAGE_CREATE_INFO* pCreateInfo, is "\
+            "nullptr (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
 
     if(pCreateInfo->sType != XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
     {
-        char const str[] = "xglCreateImage parameter, XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO \
-            pCreateInfo->sType, is not XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO "\
+            "pCreateInfo->sType, is not XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
 
     if (!validate_XGL_IMAGE_TYPE(pCreateInfo->imageType))
     {
-        char const str[] = "xglCreateImage parameter, XGL_IMAGE_TYPE pCreateInfo->imageType, is \
-            unrecognized (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_IMAGE_TYPE pCreateInfo->imageType, is "\
+            "unrecognized (precondition).";
         layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
 
     if (!validate_XGL_FORMAT(pCreateInfo->format))
     {
-        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, is \
-            unrecognized (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, is "\
+            "unrecognized (precondition).";
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -694,16 +694,16 @@ void PreCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo)
         XGL_INFO_TYPE_FORMAT_PROPERTIES, &size, &properties);
     if(result != XGL_SUCCESS)
     {
-        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, cannot be \
-            validated (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, cannot be "\
+            "validated (precondition).";
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
 
     if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
     {
-        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, contains \
-            unsupported format (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_FORMAT pCreateInfo->format, contains "\
+            "unsupported format (precondition).";
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -711,16 +711,16 @@ void PreCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo)
     // TODO: Can we check device-specific limits?
     if (!xgl_validate_xgl_extent3d(&pCreateInfo->extent))
     {
-        char const str[] = "xglCreateImage parameter, XGL_EXTENT3D pCreateInfo->extent, is invalid \
-            (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_EXTENT3D pCreateInfo->extent, is invalid "\
+            "(precondition).";
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
 
     if (!validate_XGL_IMAGE_TILING(pCreateInfo->tiling))
     {
-        char const str[] = "xglCreateImage parameter, XGL_IMAGE_TILING pCreateInfo->tiling, is \
-            unrecoginized (precondition).";
+        char const str[] = "xglCreateImage parameter, XGL_IMAGE_TILING pCreateInfo->tiling, is "\
+            "unrecoginized (precondition).";
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
@@ -1662,6 +1662,34 @@ void PreCreateRenderPass(XGL_DEVICE device, const XGL_RENDER_PASS_CREATE_INFO* p
         layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
         return;
     }
+
+    if(pCreateInfo->pColorStoreOps == nullptr)
+    {
+        char const str[] = "xglCreateRenderPass parameter, XGL_ATTACHMENT_STORE_OP* pCreateInfo->pColorStoreOps, \
+            is nullptr (precondition).";
+        layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
+        return;
+    }
+
+    for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
+    {
+        if(!validate_XGL_ATTACHMENT_STORE_OP(pCreateInfo->pColorStoreOps[i]))
+        {
+            std::stringstream ss;
+            ss << "xglCreateRenderPass parameter, XGL_ATTACHMENT_STORE_OP pCreateInfo->pColorStoreOps[" << i <<
+                "], is unrecognized (precondition).";
+            layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
+            continue;
+        }
+    }
+
+    if(pCreateInfo->pColorLoadClearValues == nullptr)
+    {
+        char const str[] = "xglCreateRenderPass parameter, XGL_CLEAR_COLOR* pCreateInfo->\
+            pColorLoadClearValues, is nullptr (precondition).";
+        layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
+        return;
+    }
    
     for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
     {