blob: e50fa270055c8e23e15d0b5e9f9830a95410de35 [file] [log] [blame]
Lingfeng Yang60b411d2018-11-29 00:26:45 -08001// 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 Yangdef88ba2018-12-13 12:43:17 -080017#include "ResourceTracker.h"
Lingfeng Yang60b411d2018-11-29 00:26:45 -080018
19namespace goldfish_vk {
20
Lingfeng Yang29c99d92018-11-30 11:15:29 -080021VkResult Validation::on_vkFlushMappedMemoryRanges(
22 void*,
23 VkResult,
Lingfeng Yang60b411d2018-11-29 00:26:45 -080024 VkDevice,
25 uint32_t memoryRangeCount,
26 const VkMappedMemoryRange* pMemoryRanges) {
27
Lingfeng Yangdef88ba2018-12-13 12:43:17 -080028 auto resources = ResourceTracker::get();
29
Lingfeng Yang60b411d2018-11-29 00:26:45 -080030 for (uint32_t i = 0; i < memoryRangeCount; ++i) {
Lingfeng Yangdef88ba2018-12-13 12:43:17 -080031 if (!resources->isValidMemoryRange(pMemoryRanges[i])) {
Lingfeng Yang60b411d2018-11-29 00:26:45 -080032 return VK_ERROR_OUT_OF_HOST_MEMORY;
33 }
34 }
35
36 return VK_SUCCESS;
37}
38
Lingfeng Yang29c99d92018-11-30 11:15:29 -080039VkResult Validation::on_vkInvalidateMappedMemoryRanges(
40 void*,
41 VkResult,
Lingfeng Yang60b411d2018-11-29 00:26:45 -080042 VkDevice,
43 uint32_t memoryRangeCount,
44 const VkMappedMemoryRange* pMemoryRanges) {
45
Lingfeng Yangdef88ba2018-12-13 12:43:17 -080046 auto resources = ResourceTracker::get();
47
Lingfeng Yang60b411d2018-11-29 00:26:45 -080048 for (uint32_t i = 0; i < memoryRangeCount; ++i) {
Lingfeng Yangdef88ba2018-12-13 12:43:17 -080049 if (!resources->isValidMemoryRange(pMemoryRanges[i])) {
Lingfeng Yang60b411d2018-11-29 00:26:45 -080050 return VK_ERROR_OUT_OF_HOST_MEMORY;
51 }
52 }
53
54 return VK_SUCCESS;
55}
56
57} // namespace goldfish_vk