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 "ResourceTracker.h"
17 #include "Resources.h"
18
19 namespace gfxstream {
20 namespace vk {
21
on_vkFlushMappedMemoryRanges(void *,VkResult,VkDevice,uint32_t memoryRangeCount,const VkMappedMemoryRange * pMemoryRanges)22 VkResult Validation::on_vkFlushMappedMemoryRanges(void*, VkResult, VkDevice,
23 uint32_t memoryRangeCount,
24 const VkMappedMemoryRange* pMemoryRanges) {
25 auto resources = ResourceTracker::get();
26
27 for (uint32_t i = 0; i < memoryRangeCount; ++i) {
28 if (!resources->isValidMemoryRange(pMemoryRanges[i])) {
29 return VK_ERROR_OUT_OF_HOST_MEMORY;
30 }
31 }
32
33 return VK_SUCCESS;
34 }
35
on_vkInvalidateMappedMemoryRanges(void *,VkResult,VkDevice,uint32_t memoryRangeCount,const VkMappedMemoryRange * pMemoryRanges)36 VkResult Validation::on_vkInvalidateMappedMemoryRanges(void*, VkResult, VkDevice,
37 uint32_t memoryRangeCount,
38 const VkMappedMemoryRange* pMemoryRanges) {
39 auto resources = ResourceTracker::get();
40
41 for (uint32_t i = 0; i < memoryRangeCount; ++i) {
42 if (!resources->isValidMemoryRange(pMemoryRanges[i])) {
43 return VK_ERROR_OUT_OF_HOST_MEMORY;
44 }
45 }
46
47 return VK_SUCCESS;
48 }
49
50 } // namespace vk
51 } // namespace gfxstream
52