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