mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-08 04:59:08 +00:00
This patch factors resource usage tracking so it is separate from command validation, allowing the bulk of command validation to be completely skipped. In DrawCallPerfRun/Vulkan_DynamicPipeline_DynamicBindGroup, disabling validation cuts roughly 74 nanoseconds (20%) of CPU time, per draw. In DrawCallPerfRun/Vulkan_DynamicBindGroup, disabling validation cuts roughly 35 nanoseconds (17%) of CPU time, per draw. In DrawCallPerfRun/Vulkan_MultipleBindGroups, disabling validation cuts roughly 45 nanoseconds (14%) of CPU time, per draw. Bug: dawn:271 Change-Id: I517b85840ba18c6a554b83f34a1d0aef1a8c56a6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13520 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
// Copyright 2019 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "dawn_native/PassResourceUsageTracker.h"
|
|
|
|
#include "dawn_native/Buffer.h"
|
|
#include "dawn_native/Texture.h"
|
|
|
|
namespace dawn_native {
|
|
|
|
void PassResourceUsageTracker::BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage) {
|
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
|
// before.
|
|
mBufferUsages[buffer] |= usage;
|
|
}
|
|
|
|
void PassResourceUsageTracker::TextureUsedAs(TextureBase* texture, wgpu::TextureUsage usage) {
|
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
|
// before.
|
|
mTextureUsages[texture] |= usage;
|
|
}
|
|
|
|
// Returns the per-pass usage for use by backends for APIs with explicit barriers.
|
|
PassResourceUsage PassResourceUsageTracker::AcquireResourceUsage() {
|
|
PassResourceUsage result;
|
|
result.buffers.reserve(mBufferUsages.size());
|
|
result.bufferUsages.reserve(mBufferUsages.size());
|
|
result.textures.reserve(mTextureUsages.size());
|
|
result.textureUsages.reserve(mTextureUsages.size());
|
|
|
|
for (auto& it : mBufferUsages) {
|
|
result.buffers.push_back(it.first);
|
|
result.bufferUsages.push_back(it.second);
|
|
}
|
|
|
|
for (auto& it : mTextureUsages) {
|
|
result.textures.push_back(it.first);
|
|
result.textureUsages.push_back(it.second);
|
|
}
|
|
|
|
mBufferUsages.clear();
|
|
mTextureUsages.clear();
|
|
|
|
return result;
|
|
}
|
|
|
|
} // namespace dawn_native
|