aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorCort Stratton <cort@google.com>2017-03-03 08:50:51 -0800
committerCort <cdwfs@users.noreply.github.com>2017-03-06 11:23:19 -0800
commitfe4a244b2abf872976457053da3918834f5904e4 (patch)
tree3e38297e88ba70fd58dfcf51bd5545cd8c791be3 /layers/core_validation.cpp
parent0ce7bb37372584dafecbd6a1de8a0e24dfdecddd (diff)
downloadusermoji-fe4a244b2abf872976457053da3918834f5904e4.tar.xz
layers: Added skip_checks to rangeIntersect()
This allows callers to skip redundant/unnecessary checks outside the validation path.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 28bffcd9..785b4cdf 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -5205,7 +5205,9 @@ VKAPI_ATTR VkResult VKAPI_CALL GetQueryPoolResults(VkDevice device, VkQueryPool
// pad_ranges bool indicates a linear and non-linear comparison which requires padding
// In the case where padding is required, if an alias is encountered then a validation error is reported and skip_call
// may be set by the callback function so caller should merge in skip_call value if padding case is possible.
-static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *range1, MEMORY_RANGE const *range2, bool *skip_call) {
+// This check can be skipped by passing skip_checks=true, for call sites outside the validation path.
+static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *range1, MEMORY_RANGE const *range2, bool *skip_call,
+ bool skip_checks) {
*skip_call = false;
auto r1_start = range1->start;
auto r1_end = range1->end;
@@ -5218,7 +5220,7 @@ static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *rang
if ((r1_end & ~(pad_align - 1)) < (r2_start & ~(pad_align - 1))) return false;
if ((r1_start & ~(pad_align - 1)) > (r2_end & ~(pad_align - 1))) return false;
- if (range1->linear != range2->linear) {
+ if (!skip_checks && (range1->linear != range2->linear)) {
// In linear vs. non-linear case, warn of aliasing
const char *r1_linear_str = range1->linear ? "Linear" : "Non-linear";
const char *r1_type_str = range1->image ? "image" : "buffer";
@@ -5245,7 +5247,7 @@ bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *range1, VkD
range_wrap.start = offset;
range_wrap.end = end;
bool tmp_bool;
- return rangesIntersect(dev_data, range1, &range_wrap, &tmp_bool);
+ return rangesIntersect(dev_data, range1, &range_wrap, &tmp_bool, true);
}
// For given mem_info, set all ranges valid that intersect [offset-end] range
// TODO : For ranges where there is no alias, we may want to create new buffer ranges that are valid
@@ -5256,7 +5258,7 @@ static void SetMemRangesValid(layer_data const *dev_data, DEVICE_MEM_INFO *mem_i
map_range.start = offset;
map_range.end = end;
for (auto &handle_range_pair : mem_info->bound_ranges) {
- if (rangesIntersect(dev_data, &handle_range_pair.second, &map_range, &tmp_bool)) {
+ if (rangesIntersect(dev_data, &handle_range_pair.second, &map_range, &tmp_bool, false)) {
// TODO : WARN here if tmp_bool true?
handle_range_pair.second.valid = true;
}
@@ -5283,7 +5285,7 @@ static bool ValidateInsertMemoryRange(layer_data const *dev_data, uint64_t handl
for (auto &obj_range_pair : mem_info->bound_ranges) {
auto check_range = &obj_range_pair.second;
bool intersection_error = false;
- if (rangesIntersect(dev_data, &range, check_range, &intersection_error)) {
+ if (rangesIntersect(dev_data, &range, check_range, &intersection_error, false)) {
skip |= intersection_error;
range.aliases.insert(check_range);
}
@@ -5329,8 +5331,7 @@ static void InsertMemoryRange(layer_data const *dev_data, uint64_t handle, DEVIC
for (auto &obj_range_pair : mem_info->bound_ranges) {
auto check_range = &obj_range_pair.second;
bool intersection_error = false;
- if (rangesIntersect(dev_data, &range, check_range, &intersection_error)) {
- assert(!intersection_error); // should have been caught in ValidateInsertMemoryRange()
+ if (rangesIntersect(dev_data, &range, check_range, &intersection_error, true)) {
range.aliases.insert(check_range);
tmp_alias_ranges.insert(check_range);
}