mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-10-28 04:30:26 +00:00
This change implemented texture subresource on Vulkan. It added a new function to handle barriers for texture subresource for bind groups. It also simplified barriers which are set for texture clear and copy. Before this patch, all barriers are done upon all mip levels and all array layers. With this patch, barriers are done upon particular mip level(s) and array layer(s). We may need more texture subresource end2end tests for copy and clear opterations. I will visit that later. Bug: dawn:157 Change-Id: Ie2247c6315326494f2d3736334e84b2867a16c17 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22024 Commit-Queue: Yunchao He <yunchao.he@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
// Copyright 2018 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/vulkan/SwapChainVk.h"
|
|
|
|
#include "dawn_native/vulkan/DeviceVk.h"
|
|
#include "dawn_native/vulkan/TextureVk.h"
|
|
|
|
namespace dawn_native { namespace vulkan {
|
|
|
|
// static
|
|
SwapChain* SwapChain::Create(Device* device, const SwapChainDescriptor* descriptor) {
|
|
return new SwapChain(device, descriptor);
|
|
}
|
|
|
|
SwapChain::SwapChain(Device* device, const SwapChainDescriptor* descriptor)
|
|
: OldSwapChainBase(device, descriptor) {
|
|
const auto& im = GetImplementation();
|
|
DawnWSIContextVulkan wsiContext = {};
|
|
im.Init(im.userData, &wsiContext);
|
|
|
|
ASSERT(im.textureUsage != WGPUTextureUsage_None);
|
|
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
|
|
}
|
|
|
|
SwapChain::~SwapChain() {
|
|
}
|
|
|
|
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
|
const auto& im = GetImplementation();
|
|
DawnSwapChainNextTexture next = {};
|
|
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
|
|
|
if (error) {
|
|
GetDevice()->HandleError(InternalErrorType::Internal, error);
|
|
return nullptr;
|
|
}
|
|
|
|
VkImage nativeTexture =
|
|
VkImage::CreateFromHandle(reinterpret_cast<::VkImage>(next.texture.u64));
|
|
return Texture::CreateForSwapChain(ToBackend(GetDevice()), descriptor, nativeTexture)
|
|
.Detach();
|
|
}
|
|
|
|
MaybeError SwapChain::OnBeforePresent(TextureBase* texture) {
|
|
Device* device = ToBackend(GetDevice());
|
|
|
|
// Perform the necessary pipeline barriers for the texture to be used with the usage
|
|
// requested by the implementation.
|
|
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
|
ToBackend(texture)->TransitionFullUsage(recordingContext, mTextureUsage);
|
|
|
|
DAWN_TRY(device->SubmitPendingCommands());
|
|
|
|
return {};
|
|
}
|
|
|
|
}} // namespace dawn_native::vulkan
|