[Vulkan] Ensure entire scaled range fits within the buffer.
Fixes devices lost errors when using resolution scaling Co-authored-by: Herman S. <429230+has207@users.noreply.github.com>
This commit is contained in:
@@ -2856,15 +2856,24 @@ bool VulkanTextureCache::MakeScaledResolveRangeCurrent(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t draw_resolution_scale_area =
|
const uint32_t draw_resolution_scale_area =
|
||||||
draw_resolution_scale_x() * draw_resolution_scale_y();
|
draw_resolution_scale_x() * draw_resolution_scale_y();
|
||||||
uint64_t start_scaled = uint64_t(start_unscaled) * draw_resolution_scale_area;
|
const uint64_t start_scaled =
|
||||||
|
uint64_t(start_unscaled) * draw_resolution_scale_area;
|
||||||
|
|
||||||
// Find which buffer contains this range
|
const uint64_t length_scaled_alignment_bits =
|
||||||
|
(UINT64_C(1) << length_scaled_alignment_log2) - 1;
|
||||||
|
const uint64_t length_scaled =
|
||||||
|
(uint64_t(length_unscaled) * draw_resolution_scale_area +
|
||||||
|
length_scaled_alignment_bits) &
|
||||||
|
~length_scaled_alignment_bits;
|
||||||
|
const uint64_t end_scaled = start_scaled + length_scaled;
|
||||||
|
|
||||||
|
// Find which buffer contains this entire range (not just the start)
|
||||||
for (size_t i = 0; i < scaled_resolve_buffers_.size(); ++i) {
|
for (size_t i = 0; i < scaled_resolve_buffers_.size(); ++i) {
|
||||||
const ScaledResolveBuffer& buffer = scaled_resolve_buffers_[i];
|
const ScaledResolveBuffer& buffer = scaled_resolve_buffers_[i];
|
||||||
if (start_scaled >= buffer.range_start_scaled &&
|
if (start_scaled >= buffer.range_start_scaled &&
|
||||||
start_scaled <
|
end_scaled <=
|
||||||
(buffer.range_start_scaled + buffer.range_length_scaled)) {
|
(buffer.range_start_scaled + buffer.range_length_scaled)) {
|
||||||
scaled_resolve_current_buffer_index_ = i;
|
scaled_resolve_current_buffer_index_ = i;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user