| 1 |
/* |
| 2 |
* Copyright 2018 Google |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
#include "Validation.h" |
| 6 |
|
| 7 |
#include "ResourceTracker.h" |
| 8 |
#include "Resources.h" |
| 9 |
|
| 10 |
namespace gfxstream { |
| 11 |
namespace vk { |
| 12 |
|
| 13 |
VkResult Validation::on_vkFlushMappedMemoryRanges(void*, VkResult, VkDevice, |
| 14 |
uint32_t memoryRangeCount, |
| 15 |
const VkMappedMemoryRange* pMemoryRanges) { |
| 16 |
auto resources = ResourceTracker::get(); |
| 17 |
|
| 18 |
for (uint32_t i = 0; i < memoryRangeCount; ++i) { |
| 19 |
if (!resources->isValidMemoryRange(pMemoryRanges[i])) { |
| 20 |
return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
return VK_SUCCESS; |
| 25 |
} |
| 26 |
|
| 27 |
VkResult Validation::on_vkInvalidateMappedMemoryRanges(void*, VkResult, VkDevice, |
| 28 |
uint32_t memoryRangeCount, |
| 29 |
const VkMappedMemoryRange* pMemoryRanges) { |
| 30 |
auto resources = ResourceTracker::get(); |
| 31 |
|
| 32 |
for (uint32_t i = 0; i < memoryRangeCount; ++i) { |
| 33 |
if (!resources->isValidMemoryRange(pMemoryRanges[i])) { |
| 34 |
return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
return VK_SUCCESS; |
| 39 |
} |
| 40 |
|
| 41 |
} // namespace vk |
| 42 |
} // namespace gfxstream |