Rename vulkan::Adapter -> vulkan::PhysicalDevice.

Bug: dawn:1774
Change-Id: Iad2896033fc4ae04513444db1a0c941c6c1681ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131000
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Stephen White 2023-05-02 20:48:09 +00:00 committed by Dawn LUCI CQ
parent c970e806db
commit ebafab6556
21 changed files with 183 additions and 169 deletions

View File

@ -679,8 +679,6 @@ source_set("sources") {
deps += [ "${dawn_vulkan_tools_dir}:vulkan_tools_headers" ]
public_deps += [ "${dawn_vulkan_headers_dir}:vulkan_headers" ]
sources += [
"vulkan/AdapterVk.cpp",
"vulkan/AdapterVk.h",
"vulkan/BackendVk.cpp",
"vulkan/BackendVk.h",
"vulkan/BindGroupLayoutVk.cpp",
@ -703,6 +701,8 @@ source_set("sources") {
"vulkan/FencedDeleter.cpp",
"vulkan/FencedDeleter.h",
"vulkan/Forward.h",
"vulkan/PhysicalDeviceVk.cpp",
"vulkan/PhysicalDeviceVk.h",
"vulkan/PipelineCacheVk.cpp",
"vulkan/PipelineCacheVk.h",
"vulkan/PipelineLayoutVk.cpp",

View File

@ -551,8 +551,6 @@ endif()
if (DAWN_ENABLE_VULKAN)
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn/native/VulkanBackend.h"
"vulkan/AdapterVk.cpp"
"vulkan/AdapterVk.h"
"vulkan/BackendVk.cpp"
"vulkan/BackendVk.h"
"vulkan/BindGroupLayoutVk.cpp"
@ -575,6 +573,8 @@ if (DAWN_ENABLE_VULKAN)
"vulkan/FencedDeleter.cpp"
"vulkan/FencedDeleter.h"
"vulkan/Forward.h"
"vulkan/PhysicalDeviceVk.cpp"
"vulkan/PhysicalDeviceVk.h"
"vulkan/PipelineCacheVk.cpp"
"vulkan/PipelineCacheVk.h"
"vulkan/PipelineLayoutVk.cpp"

View File

@ -23,8 +23,8 @@
#include "dawn/common/SystemUtils.h"
#include "dawn/native/Instance.h"
#include "dawn/native/VulkanBackend.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -222,8 +222,8 @@ const VulkanGlobalInfo& VulkanInstance::GetGlobalInfo() const {
return mGlobalInfo;
}
const std::vector<VkPhysicalDevice>& VulkanInstance::GetPhysicalDevices() const {
return mPhysicalDevices;
const std::vector<VkPhysicalDevice>& VulkanInstance::GetVkPhysicalDevices() const {
return mVkPhysicalDevices;
}
// static
@ -308,7 +308,7 @@ MaybeError VulkanInstance::Initialize(const InstanceBase* instance, ICD icd) {
DAWN_TRY(RegisterDebugUtils());
}
DAWN_TRY_ASSIGN(mPhysicalDevices, GatherPhysicalDevices(mInstance, mFunctions));
DAWN_TRY_ASSIGN(mVkPhysicalDevices, GatherPhysicalDevices(mInstance, mFunctions));
return {};
}
@ -476,7 +476,7 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
const AdapterDiscoveryOptions* options =
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
std::vector<Ref<PhysicalDeviceBase>> adapters;
std::vector<Ref<PhysicalDeviceBase>> physicalDevices;
InstanceBase* instance = GetInstance();
for (ICD icd : kICDs) {
@ -496,18 +496,18 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
// Instance failed to initialize.
continue;
}
const std::vector<VkPhysicalDevice>& physicalDevices =
mVulkanInstances[icd]->GetPhysicalDevices();
for (uint32_t i = 0; i < physicalDevices.size(); ++i) {
Ref<Adapter> adapter = AcquireRef(new Adapter(instance, mVulkanInstances[icd].Get(),
physicalDevices[i], adapterToggles));
if (instance->ConsumedError(adapter->Initialize())) {
const std::vector<VkPhysicalDevice>& vkPhysicalDevices =
mVulkanInstances[icd]->GetVkPhysicalDevices();
for (uint32_t i = 0; i < vkPhysicalDevices.size(); ++i) {
Ref<PhysicalDevice> physicalDevice = AcquireRef(new PhysicalDevice(
instance, mVulkanInstances[icd].Get(), vkPhysicalDevices[i], adapterToggles));
if (instance->ConsumedError(physicalDevice->Initialize())) {
continue;
}
adapters.push_back(std::move(adapter));
physicalDevices.push_back(std::move(physicalDevice));
}
}
return adapters;
return physicalDevices;
}
BackendConnection* Connect(InstanceBase* instance) {

View File

@ -53,7 +53,7 @@ class VulkanInstance : public RefCounted {
const VulkanFunctions& GetFunctions() const;
VkInstance GetVkInstance() const;
const VulkanGlobalInfo& GetGlobalInfo() const;
const std::vector<VkPhysicalDevice>& GetPhysicalDevices() const;
const std::vector<VkPhysicalDevice>& GetVkPhysicalDevices() const;
// TODO(dawn:831): This set of functions guards may need to be adjusted when Dawn is updated
// to support multithreading.
@ -76,7 +76,7 @@ class VulkanInstance : public RefCounted {
VkDebugUtilsMessengerEXT mDebugUtilsMessenger = VK_NULL_HANDLE;
std::vector<VkPhysicalDevice> mPhysicalDevices;
std::vector<VkPhysicalDevice> mVkPhysicalDevices;
// Devices keep the VulkanInstance alive, so as long as devices remove themselves from this
// map on destruction the pointers it contains should remain valid.

View File

@ -24,13 +24,13 @@
#include "dawn/native/DynamicUploader.h"
#include "dawn/native/EnumMaskIterator.h"
#include "dawn/native/RenderBundle.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BindGroupVk.h"
#include "dawn/native/vulkan/BufferVk.h"
#include "dawn/native/vulkan/CommandRecordingContext.h"
#include "dawn/native/vulkan/ComputePipelineVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/FencedDeleter.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/PipelineLayoutVk.h"
#include "dawn/native/vulkan/QuerySetVk.h"
#include "dawn/native/vulkan/RenderPassCache.h"

View File

@ -23,7 +23,6 @@
#include "dawn/native/ErrorData.h"
#include "dawn/native/Instance.h"
#include "dawn/native/VulkanBackend.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/BindGroupLayoutVk.h"
#include "dawn/native/vulkan/BindGroupVk.h"
@ -31,6 +30,7 @@
#include "dawn/native/vulkan/CommandBufferVk.h"
#include "dawn/native/vulkan/ComputePipelineVk.h"
#include "dawn/native/vulkan/FencedDeleter.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/PipelineCacheVk.h"
#include "dawn/native/vulkan/PipelineLayoutVk.h"
#include "dawn/native/vulkan/QuerySetVk.h"
@ -88,7 +88,7 @@ void DestroyCommandPoolAndBuffer(const VulkanFunctions& fn,
} // namespace
// static
ResultOrError<Ref<Device>> Device::Create(Adapter* adapter,
ResultOrError<Ref<Device>> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles));
@ -96,28 +96,28 @@ ResultOrError<Ref<Device>> Device::Create(Adapter* adapter,
return device;
}
Device::Device(Adapter* adapter,
Device::Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles)
: DeviceBase(adapter, descriptor, deviceToggles), mDebugPrefix(GetNextDeviceDebugPrefix()) {}
MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
// Copy the adapter's device info to the device so that we can change the "knobs"
mDeviceInfo = ToBackend(GetAdapter())->GetDeviceInfo();
mDeviceInfo = ToBackend(GetPhysicalDevice())->GetDeviceInfo();
// Initialize the "instance" procs of our local function table.
VulkanFunctions* functions = GetMutableFunctions();
*functions = ToBackend(GetAdapter())->GetVulkanInstance()->GetFunctions();
*functions = ToBackend(GetPhysicalDevice())->GetVulkanInstance()->GetFunctions();
// Two things are crucial if device initialization fails: the function pointers to destroy
// objects, and the fence deleter that calls these functions. Do not do anything before
// these two are set up, so that a failed initialization doesn't cause a crash in
// DestroyImpl()
{
VkPhysicalDevice physicalDevice = ToBackend(GetAdapter())->GetPhysicalDevice();
VkPhysicalDevice vkPhysicalDevice = ToBackend(GetPhysicalDevice())->GetVkPhysicalDevice();
VulkanDeviceKnobs usedDeviceKnobs = {};
DAWN_TRY_ASSIGN(usedDeviceKnobs, CreateDevice(physicalDevice));
DAWN_TRY_ASSIGN(usedDeviceKnobs, CreateDevice(vkPhysicalDevice));
*static_cast<VulkanDeviceKnobs*>(&mDeviceInfo) = usedDeviceKnobs;
DAWN_TRY(functions->LoadDeviceProcs(mVkDevice, mDeviceInfo));
@ -139,7 +139,7 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
SetLabelImpl();
ToBackend(GetAdapter())->GetVulkanInstance()->StartListeningForDeviceMessages(this);
ToBackend(GetPhysicalDevice())->GetVulkanInstance()->StartListeningForDeviceMessages(this);
return DeviceBase::Initialize(Queue::Create(this, &descriptor->defaultQueue));
}
@ -246,14 +246,14 @@ MaybeError Device::TickImpl() {
}
VkInstance Device::GetVkInstance() const {
return ToBackend(GetAdapter())->GetVulkanInstance()->GetVkInstance();
return ToBackend(GetPhysicalDevice())->GetVulkanInstance()->GetVkInstance();
}
const VulkanDeviceInfo& Device::GetDeviceInfo() const {
return mDeviceInfo;
}
const VulkanGlobalInfo& Device::GetGlobalInfo() const {
return ToBackend(GetAdapter())->GetVulkanInstance()->GetGlobalInfo();
return ToBackend(GetPhysicalDevice())->GetVulkanInstance()->GetGlobalInfo();
}
VkDevice Device::GetVkDevice() const {
@ -396,7 +396,7 @@ MaybeError Device::SubmitPendingCommands() {
return {};
}
ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice physicalDevice) {
ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice vkPhysicalDevice) {
VulkanDeviceKnobs usedKnobs = {};
// Default to asking for all avilable known extensions.
@ -474,29 +474,32 @@ ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice physicalD
}
if (HasFeature(Feature::TextureCompressionBC)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionBC == VK_TRUE);
ASSERT(ToBackend(GetPhysicalDevice())->GetDeviceInfo().features.textureCompressionBC ==
VK_TRUE);
usedKnobs.features.textureCompressionBC = VK_TRUE;
}
if (HasFeature(Feature::TextureCompressionETC2)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionETC2 == VK_TRUE);
ASSERT(ToBackend(GetPhysicalDevice())->GetDeviceInfo().features.textureCompressionETC2 ==
VK_TRUE);
usedKnobs.features.textureCompressionETC2 = VK_TRUE;
}
if (HasFeature(Feature::TextureCompressionASTC)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionASTC_LDR ==
VK_TRUE);
ASSERT(
ToBackend(GetPhysicalDevice())->GetDeviceInfo().features.textureCompressionASTC_LDR ==
VK_TRUE);
usedKnobs.features.textureCompressionASTC_LDR = VK_TRUE;
}
if (HasFeature(Feature::PipelineStatisticsQuery)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery ==
ASSERT(ToBackend(GetPhysicalDevice())->GetDeviceInfo().features.pipelineStatisticsQuery ==
VK_TRUE);
usedKnobs.features.pipelineStatisticsQuery = VK_TRUE;
}
if (HasFeature(Feature::DepthClipControl)) {
const VulkanDeviceInfo& deviceInfo = ToBackend(GetAdapter())->GetDeviceInfo();
const VulkanDeviceInfo& deviceInfo = ToBackend(GetPhysicalDevice())->GetDeviceInfo();
ASSERT(deviceInfo.HasExt(DeviceExt::DepthClipEnable) &&
deviceInfo.depthClipEnableFeatures.depthClipEnable == VK_TRUE);
@ -509,7 +512,7 @@ ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice physicalD
// TODO(dawn:1510, tint:1473): After implementing a transform to handle the pipeline input /
// output if necessary, relax the requirement of storageInputOutput16.
if (HasFeature(Feature::ShaderF16)) {
const VulkanDeviceInfo& deviceInfo = ToBackend(GetAdapter())->GetDeviceInfo();
const VulkanDeviceInfo& deviceInfo = ToBackend(GetPhysicalDevice())->GetDeviceInfo();
ASSERT(deviceInfo.HasExt(DeviceExt::ShaderFloat16Int8) &&
deviceInfo.shaderFloat16Int8Features.shaderFloat16 == VK_TRUE &&
deviceInfo.HasExt(DeviceExt::_16BitStorage) &&
@ -583,7 +586,7 @@ ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice physicalD
createInfo.pEnabledFeatures = &usedKnobs.features;
}
DAWN_TRY(CheckVkSuccess(fn.CreateDevice(physicalDevice, &createInfo, nullptr, &mVkDevice),
DAWN_TRY(CheckVkSuccess(fn.CreateDevice(vkPhysicalDevice, &createInfo, nullptr, &mVkDevice),
"vkCreateDevice"));
return usedKnobs;
@ -960,7 +963,8 @@ void Device::OnDebugMessage(std::string message) {
}
MaybeError Device::CheckDebugLayerAndGenerateErrors() {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled() || mDebugMessages.empty()) {
if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled() ||
mDebugMessages.empty()) {
return {};
}
@ -972,7 +976,7 @@ MaybeError Device::CheckDebugLayerAndGenerateErrors() {
}
void Device::AppendDebugLayerMessages(ErrorData* error) {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) {
if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) {
return;
}
@ -983,7 +987,8 @@ void Device::AppendDebugLayerMessages(ErrorData* error) {
}
void Device::CheckDebugMessagesAfterDestruction() const {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled() || mDebugMessages.empty()) {
if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled() ||
mDebugMessages.empty()) {
return;
}
@ -1068,7 +1073,7 @@ void Device::DestroyImpl() {
// Enough of the Device's initialization happened that we can now do regular robust
// deinitialization.
ToBackend(GetAdapter())->GetVulkanInstance()->StopListeningForDeviceMessages(this);
ToBackend(GetPhysicalDevice())->GetVulkanInstance()->StopListeningForDeviceMessages(this);
// Immediately tag the recording context as unused so we don't try to submit it in Tick.
mRecordingContext.needsSubmit = false;

View File

@ -43,7 +43,7 @@ class ResourceMemoryAllocator;
class Device final : public DeviceBase {
public:
static ResultOrError<Ref<Device>> Create(Adapter* adapter,
static ResultOrError<Ref<Device>> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles);
~Device() override;
@ -118,7 +118,9 @@ class Device final : public DeviceBase {
void ForceEventualFlushOfCommands() override;
private:
Device(Adapter* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles);
Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles);
ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) override;
@ -158,7 +160,7 @@ class Device final : public DeviceBase {
ResultOrError<wgpu::TextureUsage> GetSupportedSurfaceUsageImpl(
const Surface* surface) const override;
ResultOrError<VulkanDeviceKnobs> CreateDevice(VkPhysicalDevice physicalDevice);
ResultOrError<VulkanDeviceKnobs> CreateDevice(VkPhysicalDevice vkPhysicalDevice);
void GatherQueueFromDevice();
uint32_t FindComputeSubgroupSize() const;

View File

@ -19,13 +19,13 @@
namespace dawn::native::vulkan {
class Adapter;
class BindGroup;
class BindGroupLayout;
class Buffer;
class CommandBuffer;
class ComputePipeline;
class Device;
class PhysicalDevice;
class PipelineCache;
class PipelineLayout;
class QuerySet;
@ -45,7 +45,7 @@ struct VulkanBackendTraits {
using CommandBufferType = CommandBuffer;
using ComputePipelineType = ComputePipeline;
using DeviceType = Device;
using PhysicalDeviceType = Adapter;
using PhysicalDeviceType = PhysicalDevice;
using PipelineCacheType = PipelineCache;
using PipelineLayoutType = PipelineLayout;
using QuerySetType = QuerySet;

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include <algorithm>
#include <string>
@ -56,39 +56,39 @@ gpu_info::DriverVersion DecodeVulkanDriverVersion(uint32_t vendorID, uint32_t ve
} // anonymous namespace
Adapter::Adapter(InstanceBase* instance,
VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice,
const TogglesState& adapterToggles)
PhysicalDevice::PhysicalDevice(InstanceBase* instance,
VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice,
const TogglesState& adapterToggles)
: PhysicalDeviceBase(instance, wgpu::BackendType::Vulkan, adapterToggles),
mPhysicalDevice(physicalDevice),
mVkPhysicalDevice(physicalDevice),
mVulkanInstance(vulkanInstance) {}
Adapter::~Adapter() = default;
PhysicalDevice::~PhysicalDevice() = default;
const VulkanDeviceInfo& Adapter::GetDeviceInfo() const {
const VulkanDeviceInfo& PhysicalDevice::GetDeviceInfo() const {
return mDeviceInfo;
}
VkPhysicalDevice Adapter::GetPhysicalDevice() const {
return mPhysicalDevice;
VkPhysicalDevice PhysicalDevice::GetVkPhysicalDevice() const {
return mVkPhysicalDevice;
}
VulkanInstance* Adapter::GetVulkanInstance() const {
VulkanInstance* PhysicalDevice::GetVulkanInstance() const {
return mVulkanInstance.Get();
}
bool Adapter::IsDepthStencilFormatSupported(VkFormat format) const {
bool PhysicalDevice::IsDepthStencilFormatSupported(VkFormat format) const {
ASSERT(format == VK_FORMAT_D16_UNORM_S8_UINT || format == VK_FORMAT_D24_UNORM_S8_UINT ||
format == VK_FORMAT_D32_SFLOAT_S8_UINT || format == VK_FORMAT_S8_UINT);
VkFormatProperties properties;
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(mPhysicalDevice, format,
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(mVkPhysicalDevice, format,
&properties);
return properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
MaybeError Adapter::InitializeImpl() {
MaybeError PhysicalDevice::InitializeImpl() {
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
mDriverVersion = DecodeVulkanDriverVersion(mDeviceInfo.properties.vendorID,
@ -183,7 +183,7 @@ MaybeError Adapter::InitializeImpl() {
return {};
}
void Adapter::InitializeSupportedFeaturesImpl() {
void PhysicalDevice::InitializeSupportedFeaturesImpl() {
// Initialize supported extensions
if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) {
EnableFeature(Feature::TextureCompressionBC);
@ -243,7 +243,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
VkFormatProperties rg11b10Properties;
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mPhysicalDevice, VK_FORMAT_B10G11R11_UFLOAT_PACK32, &rg11b10Properties);
mVkPhysicalDevice, VK_FORMAT_B10G11R11_UFLOAT_PACK32, &rg11b10Properties);
if (IsSubset(static_cast<VkFormatFeatureFlags>(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT),
@ -253,7 +253,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
VkFormatProperties bgra8unormProperties;
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mPhysicalDevice, VK_FORMAT_B8G8R8A8_UNORM, &bgra8unormProperties);
mVkPhysicalDevice, VK_FORMAT_B8G8R8A8_UNORM, &bgra8unormProperties);
if (bgra8unormProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) {
EnableFeature(Feature::BGRA8UnormStorage);
}
@ -267,7 +267,7 @@ void Adapter::InitializeSupportedFeaturesImpl() {
EnableFeature(Feature::SurfaceCapabilities);
}
MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
GetDefaultLimits(&limits->v1);
CombinedLimits baseLimits = *limits;
@ -422,14 +422,14 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
return {};
}
bool Adapter::SupportsExternalImages() const {
bool PhysicalDevice::SupportsExternalImages() const {
// Via dawn::native::vulkan::WrapVulkanImage
return external_memory::Service::CheckSupport(mDeviceInfo) &&
external_semaphore::Service::CheckSupport(mDeviceInfo, mPhysicalDevice,
external_semaphore::Service::CheckSupport(mDeviceInfo, mVkPhysicalDevice,
mVulkanInstance->GetFunctions());
}
void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
// TODO(crbug.com/dawn/857): tighten this workaround when this issue is fixed in both
// Vulkan SPEC and drivers.
deviceToggles->Default(Toggle::UseTemporaryBufferInCompressedTextureToTextureCopy, true);
@ -504,18 +504,19 @@ void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
deviceToggles->Default(Toggle::UsePlaceholderFragmentInVertexOnlyPipeline, true);
}
ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) {
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) {
return Device::Create(this, descriptor, deviceToggles);
}
MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature,
const TogglesState& toggles) const {
MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
wgpu::FeatureName feature,
const TogglesState& toggles) const {
return {};
}
// Android devices with Qualcomm GPUs have a myriad of known issues. (dawn:1549)
bool Adapter::IsAndroidQualcomm() const {
bool PhysicalDevice::IsAndroidQualcomm() const {
#if DAWN_PLATFORM_IS(ANDROID)
return gpu_info::IsQualcomm(GetVendorId());
#else
@ -523,7 +524,7 @@ bool Adapter::IsAndroidQualcomm() const {
#endif
}
bool Adapter::IsIntelMesa() const {
bool PhysicalDevice::IsIntelMesa() const {
if (mDeviceInfo.HasExt(DeviceExt::DriverProperties)) {
return mDeviceInfo.driverProperties.driverID == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR;
}

View File

@ -25,19 +25,19 @@ namespace dawn::native::vulkan {
class VulkanInstance;
class Adapter : public PhysicalDeviceBase {
class PhysicalDevice : public PhysicalDeviceBase {
public:
Adapter(InstanceBase* instance,
VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice,
const TogglesState& adapterToggles);
~Adapter() override;
PhysicalDevice(InstanceBase* instance,
VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice,
const TogglesState& adapterToggles);
~PhysicalDevice() override;
// PhysicalDeviceBase Implementation
bool SupportsExternalImages() const override;
const VulkanDeviceInfo& GetDeviceInfo() const;
VkPhysicalDevice GetPhysicalDevice() const;
VkPhysicalDevice GetVkPhysicalDevice() const;
VulkanInstance* GetVulkanInstance() const;
bool IsDepthStencilFormatSupported(VkFormat format) const;
@ -57,7 +57,7 @@ class Adapter : public PhysicalDeviceBase {
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) override;
VkPhysicalDevice mPhysicalDevice;
VkPhysicalDevice mVkPhysicalDevice;
Ref<VulkanInstance> mVulkanInstance;
VulkanDeviceInfo mDeviceInfo = {};
};

View File

@ -21,10 +21,10 @@
#include "dawn/common/Compiler.h"
#include "dawn/native/Instance.h"
#include "dawn/native/Surface.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/FencedDeleter.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/TextureVk.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -36,10 +36,11 @@ namespace dawn::native::vulkan {
namespace {
ResultOrError<VkSurfaceKHR> CreateVulkanSurface(const Adapter* adapter, const Surface* surface) {
const VulkanGlobalInfo& info = adapter->GetVulkanInstance()->GetGlobalInfo();
const VulkanFunctions& fn = adapter->GetVulkanInstance()->GetFunctions();
VkInstance instance = adapter->GetVulkanInstance()->GetVkInstance();
ResultOrError<VkSurfaceKHR> CreateVulkanSurface(const PhysicalDevice* physicalDevice,
const Surface* surface) {
const VulkanGlobalInfo& info = physicalDevice->GetVulkanInstance()->GetGlobalInfo();
const VulkanFunctions& fn = physicalDevice->GetVulkanInstance()->GetFunctions();
VkInstance instance = physicalDevice->GetVulkanInstance()->GetVkInstance();
// May not be used in the platform-specific switches below.
DAWN_UNUSED(info);
@ -148,7 +149,8 @@ ResultOrError<VkSurfaceKHR> CreateVulkanSurface(const Adapter* adapter, const Su
// Fall back to using XCB surfaces if the Xlib extension isn't available.
// See https://xcb.freedesktop.org/MixingCalls/ for more information about
// interoperability between Xlib and XCB
const XlibXcbFunctions* xlibXcb = adapter->GetInstance()->GetOrCreateXlibXcbFunctions();
const XlibXcbFunctions* xlibXcb =
physicalDevice->GetInstance()->GetOrCreateXlibXcbFunctions();
ASSERT(xlibXcb != nullptr);
if (info.HasExt(InstanceExt::XcbSurface) && xlibXcb->IsLoaded()) {
@ -208,17 +210,17 @@ uint32_t MinImageCountForPresentMode(VkPresentModeKHR mode) {
// static
ResultOrError<wgpu::TextureUsage> SwapChain::GetSupportedSurfaceUsage(const Device* device,
const Surface* surface) {
Adapter* adapter = ToBackend(device->GetAdapter());
const VulkanFunctions& fn = adapter->GetVulkanInstance()->GetFunctions();
VkInstance instanceVk = adapter->GetVulkanInstance()->GetVkInstance();
VkPhysicalDevice physicalDeviceVk = adapter->GetPhysicalDevice();
PhysicalDevice* physicalDevice = ToBackend(device->GetPhysicalDevice());
const VulkanFunctions& fn = physicalDevice->GetVulkanInstance()->GetFunctions();
VkInstance instanceVk = physicalDevice->GetVulkanInstance()->GetVkInstance();
VkPhysicalDevice vkPhysicalDevice = physicalDevice->GetVkPhysicalDevice();
VkSurfaceKHR surfaceVk;
VkSurfaceCapabilitiesKHR surfaceCapsVk;
DAWN_TRY_ASSIGN(surfaceVk, CreateVulkanSurface(adapter, surface));
DAWN_TRY_ASSIGN(surfaceVk, CreateVulkanSurface(physicalDevice, surface));
DAWN_TRY(CheckVkSuccess(
fn.GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDeviceVk, surfaceVk, &surfaceCapsVk),
fn.GetPhysicalDeviceSurfaceCapabilitiesKHR(vkPhysicalDevice, surfaceVk, &surfaceCapsVk),
"GetPhysicalDeviceSurfaceCapabilitiesKHR"));
wgpu::TextureUsage supportedUsages = wgpu::TextureUsage::RenderAttachment;
@ -253,7 +255,7 @@ void SwapChain::DestroyImpl() {
// previousSwapChain can be set to `this`.
MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
Device* device = ToBackend(GetDevice());
Adapter* adapter = ToBackend(GetDevice()->GetAdapter());
PhysicalDevice* physicalDevice = ToBackend(GetDevice()->GetPhysicalDevice());
VkSwapchainKHR previousVkSwapChain = VK_NULL_HANDLE;
@ -292,11 +294,11 @@ MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
}
if (mVkSurface == VK_NULL_HANDLE) {
DAWN_TRY_ASSIGN(mVkSurface, CreateVulkanSurface(adapter, GetSurface()));
DAWN_TRY_ASSIGN(mVkSurface, CreateVulkanSurface(physicalDevice, GetSurface()));
}
VulkanSurfaceInfo surfaceInfo;
DAWN_TRY_ASSIGN(surfaceInfo, GatherSurfaceInfo(*adapter, mVkSurface));
DAWN_TRY_ASSIGN(surfaceInfo, GatherSurfaceInfo(*physicalDevice, mVkSurface));
DAWN_TRY_ASSIGN(mConfig, ChooseConfig(surfaceInfo));

View File

@ -22,11 +22,11 @@
#include "dawn/native/EnumMaskIterator.h"
#include "dawn/native/Error.h"
#include "dawn/native/VulkanBackend.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BufferVk.h"
#include "dawn/native/vulkan/CommandRecordingContext.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/FencedDeleter.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/ResourceHeapVk.h"
#include "dawn/native/vulkan/ResourceMemoryAllocatorVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
@ -621,10 +621,10 @@ bool IsSampleCountSupported(const dawn::native::vulkan::Device* device,
const VkImageCreateInfo& imageCreateInfo) {
ASSERT(device);
VkPhysicalDevice physicalDevice = ToBackend(device->GetAdapter())->GetPhysicalDevice();
VkPhysicalDevice vkPhysicalDevice = ToBackend(device->GetAdapter())->GetVkPhysicalDevice();
VkImageFormatProperties properties;
if (device->fn.GetPhysicalDeviceImageFormatProperties(
physicalDevice, imageCreateInfo.format, imageCreateInfo.imageType,
vkPhysicalDevice, imageCreateInfo.format, imageCreateInfo.imageType,
imageCreateInfo.tiling, imageCreateInfo.usage, imageCreateInfo.flags,
&properties) != VK_SUCCESS) {
UNREACHABLE();

View File

@ -19,8 +19,8 @@
#include <unordered_map>
#include <utility>
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -131,27 +131,27 @@ ResultOrError<std::vector<VkPhysicalDevice>> GatherPhysicalDevices(
return DAWN_INTERNAL_ERROR("vkEnumeratePhysicalDevices");
}
std::vector<VkPhysicalDevice> physicalDevices(count);
std::vector<VkPhysicalDevice> vkPhysicalDevices(count);
DAWN_TRY(CheckVkSuccess(
vkFunctions.EnumeratePhysicalDevices(instance, &count, physicalDevices.data()),
vkFunctions.EnumeratePhysicalDevices(instance, &count, vkPhysicalDevices.data()),
"vkEnumeratePhysicalDevices"));
return std::move(physicalDevices);
return std::move(vkPhysicalDevices);
}
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const PhysicalDevice& device) {
VulkanDeviceInfo info = {};
VkPhysicalDevice physicalDevice = adapter.GetPhysicalDevice();
const VulkanGlobalInfo& globalInfo = adapter.GetVulkanInstance()->GetGlobalInfo();
const VulkanFunctions& vkFunctions = adapter.GetVulkanInstance()->GetFunctions();
VkPhysicalDevice vkPhysicalDevice = device.GetVkPhysicalDevice();
const VulkanGlobalInfo& globalInfo = device.GetVulkanInstance()->GetGlobalInfo();
const VulkanFunctions& vkFunctions = device.GetVulkanInstance()->GetFunctions();
// Query the device properties first to get the ICD's `apiVersion`
vkFunctions.GetPhysicalDeviceProperties(physicalDevice, &info.properties);
vkFunctions.GetPhysicalDeviceProperties(vkPhysicalDevice, &info.properties);
// Gather info about device memory.
{
VkPhysicalDeviceMemoryProperties memory;
vkFunctions.GetPhysicalDeviceMemoryProperties(physicalDevice, &memory);
vkFunctions.GetPhysicalDeviceMemoryProperties(vkPhysicalDevice, &memory);
info.memoryTypes.assign(memory.memoryTypes, memory.memoryTypes + memory.memoryTypeCount);
info.memoryHeaps.assign(memory.memoryHeaps, memory.memoryHeaps + memory.memoryHeapCount);
@ -160,10 +160,10 @@ ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
// Gather info about device queue families
{
uint32_t count = 0;
vkFunctions.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count, nullptr);
vkFunctions.GetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, &count, nullptr);
info.queueFamilies.resize(count);
vkFunctions.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count,
vkFunctions.GetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, &count,
info.queueFamilies.data());
}
@ -171,22 +171,22 @@ ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
{
uint32_t count = 0;
VkResult result = VkResult::WrapUnsafe(
vkFunctions.EnumerateDeviceLayerProperties(physicalDevice, &count, nullptr));
vkFunctions.EnumerateDeviceLayerProperties(vkPhysicalDevice, &count, nullptr));
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return DAWN_INTERNAL_ERROR("vkEnumerateDeviceLayerProperties");
}
info.layers.resize(count);
DAWN_TRY(CheckVkSuccess(
vkFunctions.EnumerateDeviceLayerProperties(physicalDevice, &count, info.layers.data()),
"vkEnumerateDeviceLayerProperties"));
DAWN_TRY(CheckVkSuccess(vkFunctions.EnumerateDeviceLayerProperties(vkPhysicalDevice, &count,
info.layers.data()),
"vkEnumerateDeviceLayerProperties"));
}
// Gather the info about the device extensions
{
uint32_t count = 0;
VkResult result = VkResult::WrapUnsafe(vkFunctions.EnumerateDeviceExtensionProperties(
physicalDevice, nullptr, &count, nullptr));
vkPhysicalDevice, nullptr, &count, nullptr));
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return DAWN_INTERNAL_ERROR("vkEnumerateDeviceExtensionProperties");
}
@ -194,7 +194,7 @@ ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
std::vector<VkExtensionProperties> extensionsProperties;
extensionsProperties.resize(count);
DAWN_TRY(CheckVkSuccess(vkFunctions.EnumerateDeviceExtensionProperties(
physicalDevice, nullptr, &count, extensionsProperties.data()),
vkPhysicalDevice, nullptr, &count, extensionsProperties.data()),
"vkEnumerateDeviceExtensionProperties"));
std::unordered_map<std::string, DeviceExt> knownExts = CreateDeviceExtNameMap();
@ -270,11 +270,11 @@ ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
// Use vkGetPhysicalDevice{Features,Properties}2 if required to gather information about
// the extensions. DeviceExt::GetPhysicalDeviceProperties2 is guaranteed to be available
// because these extensions (transitively) depend on it in `EnsureDependencies`
vkFunctions.GetPhysicalDeviceProperties2(physicalDevice, &properties2);
vkFunctions.GetPhysicalDeviceFeatures2(physicalDevice, &features2);
vkFunctions.GetPhysicalDeviceProperties2(vkPhysicalDevice, &properties2);
vkFunctions.GetPhysicalDeviceFeatures2(vkPhysicalDevice, &features2);
info.features = features2.features;
} else {
vkFunctions.GetPhysicalDeviceFeatures(physicalDevice, &info.features);
vkFunctions.GetPhysicalDeviceFeatures(vkPhysicalDevice, &info.features);
}
// TODO(cwallez@chromium.org): gather info about formats
@ -282,26 +282,27 @@ ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
return std::move(info);
}
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter, VkSurfaceKHR surface) {
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const PhysicalDevice& device,
VkSurfaceKHR surface) {
VulkanSurfaceInfo info = {};
VkPhysicalDevice physicalDevice = adapter.GetPhysicalDevice();
const VulkanFunctions& vkFunctions = adapter.GetVulkanInstance()->GetFunctions();
VkPhysicalDevice vkPhysicalDevice = device.GetVkPhysicalDevice();
const VulkanFunctions& vkFunctions = device.GetVulkanInstance()->GetFunctions();
// Get the surface capabilities
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceCapabilitiesKHR(
physicalDevice, surface, &info.capabilities),
vkPhysicalDevice, surface, &info.capabilities),
"vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
// Query which queue families support presenting this surface
{
size_t nQueueFamilies = adapter.GetDeviceInfo().queueFamilies.size();
size_t nQueueFamilies = device.GetDeviceInfo().queueFamilies.size();
info.supportedQueueFamilies.resize(nQueueFamilies, false);
for (uint32_t i = 0; i < nQueueFamilies; ++i) {
VkBool32 supported = VK_FALSE;
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceSupportKHR(
physicalDevice, i, surface, &supported),
vkPhysicalDevice, i, surface, &supported),
"vkGetPhysicalDeviceSurfaceSupportKHR"));
info.supportedQueueFamilies[i] = (supported == VK_TRUE);
@ -312,14 +313,14 @@ ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter, VkSur
{
uint32_t count = 0;
VkResult result = VkResult::WrapUnsafe(vkFunctions.GetPhysicalDeviceSurfaceFormatsKHR(
physicalDevice, surface, &count, nullptr));
vkPhysicalDevice, surface, &count, nullptr));
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return DAWN_INTERNAL_ERROR("vkGetPhysicalDeviceSurfaceFormatsKHR");
}
info.formats.resize(count);
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfaceFormatsKHR(
physicalDevice, surface, &count, info.formats.data()),
vkPhysicalDevice, surface, &count, info.formats.data()),
"vkGetPhysicalDeviceSurfaceFormatsKHR"));
}
@ -327,14 +328,14 @@ ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter, VkSur
{
uint32_t count = 0;
VkResult result = VkResult::WrapUnsafe(vkFunctions.GetPhysicalDeviceSurfacePresentModesKHR(
physicalDevice, surface, &count, nullptr));
vkPhysicalDevice, surface, &count, nullptr));
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return DAWN_INTERNAL_ERROR("vkGetPhysicalDeviceSurfacePresentModesKHR");
}
info.presentModes.resize(count);
DAWN_TRY(CheckVkSuccess(vkFunctions.GetPhysicalDeviceSurfacePresentModesKHR(
physicalDevice, surface, &count, info.presentModes.data()),
vkPhysicalDevice, surface, &count, info.presentModes.data()),
"vkGetPhysicalDeviceSurfacePresentModesKHR"));
}

View File

@ -24,7 +24,7 @@
namespace dawn::native::vulkan {
class Adapter;
class PhysicalDevice;
class Backend;
struct VulkanFunctions;
@ -86,8 +86,9 @@ ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const VulkanFunctions& vkFuncti
ResultOrError<std::vector<VkPhysicalDevice>> GatherPhysicalDevices(
VkInstance instance,
const VulkanFunctions& vkFunctions);
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter);
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter, VkSurfaceKHR surface);
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const PhysicalDevice& physicalDevice);
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const PhysicalDevice& physicalDevice,
VkSurfaceKHR surface);
} // namespace dawn::native::vulkan
#endif // SRC_DAWN_NATIVE_VULKAN_VULKANINFO_H_

View File

@ -14,9 +14,9 @@
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationAHardwareBuffer.h"
#include "dawn/common/Assert.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/TextureVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -74,7 +74,8 @@ class ServiceImplementationAHardwareBuffer : public ServiceImplementation {
VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR);
VkResult result = VkResult::WrapUnsafe(mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
ToBackend(mDevice->GetAdapter())->GetPhysicalDevice(), &formatInfo, &formatProperties));
ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice(), &formatInfo,
&formatProperties));
// If handle not supported, result == VK_ERROR_FORMAT_NOT_SUPPORTED
if (result != VK_SUCCESS) {

View File

@ -15,9 +15,9 @@
#include <vector>
#include "dawn/common/Assert.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/ResourceMemoryAllocatorVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -29,7 +29,7 @@ namespace dawn::native::vulkan::external_memory {
namespace {
bool GetFormatModifierProps(const VulkanFunctions& fn,
VkPhysicalDevice physicalDevice,
VkPhysicalDevice vkPhysicalDevice,
VkFormat format,
uint64_t modifier,
VkDrmFormatModifierPropertiesEXT* formatModifierProps) {
@ -44,13 +44,13 @@ bool GetFormatModifierProps(const VulkanFunctions& fn,
formatPropsChain.Add(&formatModifierPropsList,
VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
fn.GetPhysicalDeviceFormatProperties2(physicalDevice, format, &formatProps);
fn.GetPhysicalDeviceFormatProperties2(vkPhysicalDevice, format, &formatProps);
uint32_t modifierCount = formatModifierPropsList.drmFormatModifierCount;
formatModifierPropsVector.resize(modifierCount);
formatModifierPropsList.pDrmFormatModifierProperties = formatModifierPropsVector.data();
fn.GetPhysicalDeviceFormatProperties2(physicalDevice, format, &formatProps);
fn.GetPhysicalDeviceFormatProperties2(vkPhysicalDevice, format, &formatProps);
for (const auto& props : formatModifierPropsVector) {
if (props.drmFormatModifier == modifier) {
*formatModifierProps = props;
@ -63,11 +63,11 @@ bool GetFormatModifierProps(const VulkanFunctions& fn,
// Some modifiers use multiple planes (for example, see the comment for
// I915_FORMAT_MOD_Y_TILED_CCS in drm/drm_fourcc.h).
ResultOrError<uint32_t> GetModifierPlaneCount(const VulkanFunctions& fn,
VkPhysicalDevice physicalDevice,
VkPhysicalDevice vkPhysicalDevice,
VkFormat format,
uint64_t modifier) {
VkDrmFormatModifierPropertiesEXT props;
if (GetFormatModifierProps(fn, physicalDevice, format, modifier, &props)) {
if (GetFormatModifierProps(fn, vkPhysicalDevice, format, modifier, &props)) {
return static_cast<uint32_t>(props.drmFormatModifierPlaneCount);
}
return DAWN_VALIDATION_ERROR("DRM format modifier not supported.");
@ -103,12 +103,12 @@ bool IsMultiPlanarVkFormat(VkFormat format) {
}
bool SupportsDisjoint(const VulkanFunctions& fn,
VkPhysicalDevice physicalDevice,
VkPhysicalDevice vkPhysicalDevice,
VkFormat format,
uint64_t modifier) {
if (IsMultiPlanarVkFormat(format)) {
VkDrmFormatModifierPropertiesEXT props;
return (GetFormatModifierProps(fn, physicalDevice, format, modifier, &props) &&
return (GetFormatModifierProps(fn, vkPhysicalDevice, format, modifier, &props) &&
(props.drmFormatModifierTilingFeatures & VK_FORMAT_FEATURE_DISJOINT_BIT));
}
return false;
@ -153,9 +153,9 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
static_cast<const ExternalImageDescriptorDmaBuf*>(descriptor);
// Verify plane count for the modifier.
VkPhysicalDevice physicalDevice = ToBackend(mDevice->GetAdapter())->GetPhysicalDevice();
VkPhysicalDevice vkPhysicalDevice = ToBackend(mDevice->GetAdapter())->GetVkPhysicalDevice();
uint32_t planeCount = 0;
if (mDevice->ConsumedError(GetModifierPlaneCount(mDevice->fn, physicalDevice, format,
if (mDevice->ConsumedError(GetModifierPlaneCount(mDevice->fn, vkPhysicalDevice, format,
dmaBufDescriptor->drmModifier),
&planeCount)) {
return false;
@ -168,7 +168,7 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
return false;
}
*supportsDisjoint =
SupportsDisjoint(mDevice->fn, physicalDevice, format, dmaBufDescriptor->drmModifier);
SupportsDisjoint(mDevice->fn, vkPhysicalDevice, format, dmaBufDescriptor->drmModifier);
// Verify that the format modifier of the external memory and the requested Vulkan format
// are actually supported together in a dma-buf import.
@ -216,7 +216,7 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES);
VkResult result = VkResult::WrapUnsafe(mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
physicalDevice, &imageFormatInfo, &imageFormatProps));
vkPhysicalDevice, &imageFormatInfo, &imageFormatProps));
if (result != VK_SUCCESS) {
return false;
}
@ -303,12 +303,12 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
const ExternalImageDescriptorDmaBuf* dmaBufDescriptor =
static_cast<const ExternalImageDescriptorDmaBuf*>(descriptor);
VkPhysicalDevice physicalDevice = ToBackend(mDevice->GetAdapter())->GetPhysicalDevice();
VkPhysicalDevice vkPhysicalDevice = ToBackend(mDevice->GetAdapter())->GetVkPhysicalDevice();
VkDevice device = mDevice->GetVkDevice();
uint32_t planeCount;
DAWN_TRY_ASSIGN(planeCount,
GetModifierPlaneCount(mDevice->fn, physicalDevice, baseCreateInfo.format,
GetModifierPlaneCount(mDevice->fn, vkPhysicalDevice, baseCreateInfo.format,
dmaBufDescriptor->drmModifier));
VkImageCreateInfo createInfo = baseCreateInfo;

View File

@ -14,9 +14,9 @@
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationOpaqueFD.h"
#include "dawn/common/Assert.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/TextureVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -67,7 +67,8 @@ class ServiceImplementationOpaqueFD : public ServiceImplementation {
formatProperties.pNext = &externalFormatProperties;
VkResult result = VkResult::WrapUnsafe(mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
ToBackend(mDevice->GetAdapter())->GetPhysicalDevice(), &formatInfo, &formatProperties));
ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice(), &formatInfo,
&formatProperties));
// If handle not supported, result == VK_ERROR_FORMAT_NOT_SUPPORTED
if (result != VK_SUCCESS) {

View File

@ -14,9 +14,9 @@
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationZirconHandle.h"
#include "dawn/common/Assert.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/TextureVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
@ -67,7 +67,8 @@ class ServiceImplementationZicronHandle : public ServiceImplementation {
formatProperties.pNext = &externalFormatProperties;
VkResult result = mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
ToBackend(mDevice->GetAdapter())->GetPhysicalDevice(), &formatInfo, &formatProperties);
ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice(), &formatInfo,
&formatProperties);
// If handle not supported, result == VK_ERROR_FORMAT_NOT_SUPPORTED
if (result != VK_SUCCESS) {

View File

@ -15,9 +15,9 @@
#include <unistd.h>
#include <utility>
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/VulkanError.h"
#include "dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementation.h"
#include "dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationFD.h"
@ -36,7 +36,7 @@ class ServiceImplementationFD : public ServiceImplementation {
explicit ServiceImplementationFD(Device* device)
: ServiceImplementation(device),
mSupported(CheckSupport(device->GetDeviceInfo(),
ToBackend(device->GetAdapter())->GetPhysicalDevice(),
ToBackend(device->GetPhysicalDevice())->GetVkPhysicalDevice(),
device->fn)) {}
~ServiceImplementationFD() override = default;

View File

@ -15,9 +15,9 @@
#include <zircon/syscalls.h>
#include <utility>
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/BackendVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/VulkanError.h"
#include "dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementation.h"
#include "dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationZirconHandle.h"
@ -29,14 +29,14 @@ class ServiceImplementationZirconHandle : public ServiceImplementation {
explicit ServiceImplementationZirconHandle(Device* device)
: ServiceImplementation(device),
mSupported(CheckSupport(device->GetDeviceInfo(),
ToBackend(device->GetAdapter())->GetPhysicalDevice(),
ToBackend(device->GetAdapter())->GetVkPhysicalDevice(),
device->fn)) {}
~ServiceImplementationZirconHandle() override = default;
static bool CheckSupport(
const VulkanDeviceInfo& deviceInfo,
VkPhysicalDevice physicalDevice,
VkPhysicalDevice vkPhysicalDevice,
const VulkanFunctions& fn) static void CloseHandle(ExternalSemaphoreHandle handle) {
if (!deviceInfo.HasExt(DeviceExt::ExternalSemaphoreZirconHandle)) {
return false;
@ -51,7 +51,7 @@ class ServiceImplementationZirconHandle : public ServiceImplementation {
semaphoreProperties.sType = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES_KHR;
semaphoreProperties.pNext = nullptr;
fn.GetPhysicalDeviceExternalSemaphoreProperties(physicalDevice, &semaphoreInfo,
fn.GetPhysicalDeviceExternalSemaphoreProperties(vkPhysicalDevice, &semaphoreInfo,
&semaphoreProperties);
VkFlags requiredFlags = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR |
@ -160,9 +160,9 @@ std::unique_ptr<ServiceImplementation> CreateZirconHandleService(Device* device)
return td::make_unique<ServiceImplementationZirconHandle>(device);
}
bool CheckZirconHandleSupport(const VulkanDeviceInfo& deviceInfo,
VkPhysicalDevice physicalDevice,
VkPhysicalDevice vkPhysicalDevice,
const VulkanFunctions& fn) {
return ServiceImplementationZirconHandle::CheckSupport(deviceInfo, physicalDevice, fn);
return ServiceImplementationZirconHandle::CheckSupport(deviceInfo, vkPhysicalDevice, fn);
}
} // namespace dawn::native::vulkan::external_semaphore

View File

@ -15,8 +15,8 @@
#include <utility>
#include "dawn/common/Math.h"
#include "dawn/native/vulkan/AdapterVk.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/tests/DawnTest.h"
#include "dawn/tests/white_box/VulkanImageWrappingTests.h"
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
@ -265,8 +265,7 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
}
// Create another device based on the original
backendAdapter =
dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())->GetAdapter());
adapterBase = dawn::native::FromAPI(device.Get())->GetAdapter();
deviceDescriptor.nextInChain = &deviceTogglesDesc;
deviceTogglesDesc.enabledToggles = GetParam().forceEnabledWorkarounds.data();
deviceTogglesDesc.enabledTogglesCount = GetParam().forceEnabledWorkarounds.size();
@ -274,12 +273,12 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
deviceTogglesDesc.disabledTogglesCount = GetParam().forceDisabledWorkarounds.size();
secondDeviceVk =
dawn::native::vulkan::ToBackend(backendAdapter->APICreateDevice(&deviceDescriptor));
dawn::native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor));
secondDevice = wgpu::Device::Acquire(dawn::native::ToAPI(secondDeviceVk));
}
protected:
dawn::native::vulkan::Adapter* backendAdapter;
dawn::native::AdapterBase* adapterBase;
dawn::native::DeviceDescriptor deviceDescriptor;
dawn::native::DawnTogglesDescriptor deviceTogglesDesc;
@ -615,7 +614,7 @@ TEST_P(VulkanImageWrappingUsageTests, ChainTextureCopy) {
// device 2 = |secondDevice|
// Create device 3
dawn::native::vulkan::Device* thirdDeviceVk =
dawn::native::vulkan::ToBackend(backendAdapter->APICreateDevice(&deviceDescriptor));
dawn::native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor));
wgpu::Device thirdDevice = wgpu::Device::Acquire(dawn::native::ToAPI(thirdDeviceVk));
// Make queue for device 2 and 3