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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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