Skip to content

Commit

Permalink
icd: Add special fault injection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Mar 19, 2024
1 parent 2225f5c commit 0dfd39f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion icd/generated/function_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,14 @@ static VKAPI_ATTR VkResult VKAPI_CALL QueueSubmit(
const VkSubmitInfo* pSubmits,
VkFence fence)
{
//Not a CREATE or DESTROY function
// Special way to cause DEVICE_LOST
// Picked VkExportFenceCreateInfo because needed some struct that wouldn't get cleared by validation Safe Struct
// ... TODO - It would be MUCH nicer to have a layer or other setting control when this occured
// For now this is used to allow Validation Layers test reacting to device losts
auto pNext = reinterpret_cast<const VkBaseInStructure *>(pSubmits[0].pNext);
if (pNext && pNext->sType == VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO && pNext->pNext == nullptr) {
return VK_ERROR_DEVICE_LOST;
}
return VK_SUCCESS;
}

Expand Down
11 changes: 11 additions & 0 deletions scripts/mock_icd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,17 @@
*pFence = (VkFence)global_unique_handle++;
return VK_SUCCESS;
''',
'vkQueueSubmit': '''
// Special way to cause DEVICE_LOST
// Picked VkExportFenceCreateInfo because needed some struct that wouldn't get cleared by validation Safe Struct
// ... TODO - It would be MUCH nicer to have a layer or other setting control when this occured
// For now this is used to allow Validation Layers test reacting to device losts
auto pNext = reinterpret_cast<const VkBaseInStructure *>(pSubmits[0].pNext);
if (pNext && pNext->sType == VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO && pNext->pNext == nullptr) {
return VK_ERROR_DEVICE_LOST;
}
return VK_SUCCESS;
''',
}

# MockICDGeneratorOptions - subclass of GeneratorOptions.
Expand Down

0 comments on commit 0dfd39f

Please sign in to comment.