Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | #include "Validation.h" |
| 15 | |
| 16 | #include "Resources.h" |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame^] | 17 | #include "ResourceTracker.h" |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 18 | |
| 19 | namespace goldfish_vk { |
| 20 | |
Lingfeng Yang | 29c99d9 | 2018-11-30 11:15:29 -0800 | [diff] [blame] | 21 | VkResult Validation::on_vkFlushMappedMemoryRanges( |
| 22 | void*, |
| 23 | VkResult, |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 24 | VkDevice, |
| 25 | uint32_t memoryRangeCount, |
| 26 | const VkMappedMemoryRange* pMemoryRanges) { |
| 27 | |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame^] | 28 | auto resources = ResourceTracker::get(); |
| 29 | |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 30 | for (uint32_t i = 0; i < memoryRangeCount; ++i) { |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame^] | 31 | if (!resources->isValidMemoryRange(pMemoryRanges[i])) { |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 32 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return VK_SUCCESS; |
| 37 | } |
| 38 | |
Lingfeng Yang | 29c99d9 | 2018-11-30 11:15:29 -0800 | [diff] [blame] | 39 | VkResult Validation::on_vkInvalidateMappedMemoryRanges( |
| 40 | void*, |
| 41 | VkResult, |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 42 | VkDevice, |
| 43 | uint32_t memoryRangeCount, |
| 44 | const VkMappedMemoryRange* pMemoryRanges) { |
| 45 | |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame^] | 46 | auto resources = ResourceTracker::get(); |
| 47 | |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 48 | for (uint32_t i = 0; i < memoryRangeCount; ++i) { |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame^] | 49 | if (!resources->isValidMemoryRange(pMemoryRanges[i])) { |
Lingfeng Yang | 60b411d | 2018-11-29 00:26:45 -0800 | [diff] [blame] | 50 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return VK_SUCCESS; |
| 55 | } |
| 56 | |
| 57 | } // namespace goldfish_vk |