Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper

Overriding VK_DEFINE_NON_DISPATCHABLE_HANDLE changes the function
signatures of Vulkan functions, changing their ABI and making us
incompatible with real drivers. This removes that magic, and replaces it
with an explicit wrapper, VkHandle, which has much of the same
functionality as the original VkNonDispatchableHandle.

It adds definitions for dawn_native::vulkan::VkBuffer et al, which
shadow the native ::VkBuffer et al. This retains type safety throughout
the Vulkan backend without changing every single usage.

Notably, the following things had to change:
- An explicit conversion from VkBuffer* to ::VkBuffer* is needed for
  arrays. This is implemented as a reinterpret_cast, which is still
  safe as the new VkHandle still has the same memory layout properties
  as VkNonDispatchableHandle did.
- When pointing to a VkHandle as an output pointer, it's now necessary
  to explicitly get the native ::VkBuffer (via operator*) and point to
  it.

Previously reviewed on:
https://dawn-review.googlesource.com/c/dawn/+/15580

Bug: chromium:1046362
Change-Id: I7d34ec38a805025f92165ea9a7ee07ae5c182076
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15641
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Kai Ninomiya 2020-01-31 04:04:16 +00:00 committed by Commit Bot service account
parent 0a239045e3
commit f44a809f9a
27 changed files with 1094 additions and 1069 deletions

View File

@ -18,6 +18,9 @@
#if !defined(DAWN_ENABLE_BACKEND_VULKAN)
# error "vulkan_platform.h included without the Vulkan backend enabled"
#endif
#if defined(VULKAN_CORE_H_)
# error "vulkan.h included before vulkan_platform.h"
#endif
#include "common/Platform.h"
@ -33,10 +36,9 @@
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
#if defined(DAWN_PLATFORM_64_BIT)
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
using object##Native = struct object##_T*;
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
#elif defined(DAWN_PLATFORM_32_BIT)
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object##Native = uint64_t;
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
#else
# error "Unsupported platform"
#endif
@ -53,105 +55,106 @@ DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(VkSomeHandle)
// One way to get the alignment inside structures of a type is to look at the alignment of it
// wrapped in a structure. Hence VkSameHandleNativeWrappe
template <typename T>
struct WrapperStruct {
T member;
};
namespace dawn_native { namespace vulkan {
template <typename T>
static constexpr size_t AlignOfInStruct = alignof(WrapperStruct<T>);
namespace detail {
template <typename T>
struct WrapperStruct {
T member;
};
static constexpr size_t kNativeVkHandleAlignment = AlignOfInStruct<VkSomeHandleNative>;
static constexpr size_t kUint64Alignment = AlignOfInStruct<VkSomeHandleNative>;
template <typename T>
static constexpr size_t AlignOfInStruct = alignof(WrapperStruct<T>);
// Simple handle types that supports "nullptr_t" as a 0 value.
template <typename Tag, typename HandleType>
class alignas(kNativeVkHandleAlignment) VkNonDispatchableHandle {
public:
// Default constructor and assigning of VK_NULL_HANDLE
VkNonDispatchableHandle() = default;
VkNonDispatchableHandle(std::nullptr_t) : mHandle(0) {
static constexpr size_t kNativeVkHandleAlignment = AlignOfInStruct<VkSomeHandle>;
static constexpr size_t kUint64Alignment = AlignOfInStruct<uint64_t>;
// Simple handle types that supports "nullptr_t" as a 0 value.
template <typename Tag, typename HandleType>
class alignas(detail::kNativeVkHandleAlignment) VkHandle {
public:
// Default constructor and assigning of VK_NULL_HANDLE
VkHandle() = default;
VkHandle(std::nullptr_t) {
}
// Use default copy constructor/assignment
VkHandle(const VkHandle<Tag, HandleType>& other) = default;
VkHandle& operator=(const VkHandle<Tag, HandleType>&) = default;
// Comparisons between handles
bool operator==(VkHandle<Tag, HandleType> other) const {
return mHandle == other.mHandle;
}
bool operator!=(VkHandle<Tag, HandleType> other) const {
return mHandle != other.mHandle;
}
// Comparisons between handles and VK_NULL_HANDLE
bool operator==(std::nullptr_t) const {
return mHandle == 0;
}
bool operator!=(std::nullptr_t) const {
return mHandle != 0;
}
// Implicit conversion to real Vulkan types.
operator HandleType() const {
return GetHandle();
}
HandleType GetHandle() const {
return mHandle;
}
HandleType& operator*() {
return mHandle;
}
static VkHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
return VkHandle{handle};
}
private:
explicit VkHandle(HandleType handle) : mHandle(handle) {
}
HandleType mHandle = 0;
};
} // namespace detail
static constexpr std::nullptr_t VK_NULL_HANDLE = nullptr;
template <typename Tag, typename HandleType>
HandleType* AsVkArray(detail::VkHandle<Tag, HandleType>* handle) {
return reinterpret_cast<HandleType*>(handle);
}
// Use default copy constructor/assignment
VkNonDispatchableHandle(const VkNonDispatchableHandle<Tag, HandleType>& other) = default;
VkNonDispatchableHandle& operator=(const VkNonDispatchableHandle<Tag, HandleType>&) = default;
}} // namespace dawn_native::vulkan
// Comparisons between handles
bool operator==(VkNonDispatchableHandle<Tag, HandleType> other) const {
return mHandle == other.mHandle;
}
bool operator!=(VkNonDispatchableHandle<Tag, HandleType> other) const {
return mHandle != other.mHandle;
}
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) \
DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
namespace dawn_native { namespace vulkan { \
using object = detail::VkHandle<struct VkTag##object, ::object>; \
static_assert(sizeof(object) == sizeof(uint64_t), ""); \
static_assert(alignof(object) == detail::kUint64Alignment, ""); \
static_assert(sizeof(object) == sizeof(::object), ""); \
static_assert(alignof(object) == detail::kNativeVkHandleAlignment, ""); \
} \
} // namespace dawn_native::vulkan
// Comparisons between handles and VK_NULL_HANDLE
bool operator==(std::nullptr_t) const {
return mHandle == 0;
}
bool operator!=(std::nullptr_t) const {
return mHandle != 0;
}
// The regular Vulkan handle type depends on the pointer width but is always 64 bits wide.
// - On 64bit it is an opaque pointer type, probably to help with type safety
// - On 32bit it is a uint64_t because pointers aren't wide enough (and non dispatchable
// handles can be optimized to not be pointer but contain GPU virtual addresses or the
// data in a packed form).
// Because of this we need two types of conversions from our handle type: to uint64_t and to
// the "native" Vulkan type that may not be an uint64_t
static VkNonDispatchableHandle<Tag, HandleType> CreateFromU64(uint64_t handle) {
return {handle};
}
uint64_t GetU64() const {
return mHandle;
}
#include <vulkan/vulkan.h>
// Redefine VK_NULL_HANDLE for better type safety where possible.
#undef VK_NULL_HANDLE
#if defined(DAWN_PLATFORM_64_BIT)
static VkNonDispatchableHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
return CreateFromU64(static_cast<uint64_t>(reinterpret_cast<intptr_t>(handle)));
}
HandleType GetHandle() const {
return mHandle;
}
static constexpr nullptr_t VK_NULL_HANDLE = nullptr;
#elif defined(DAWN_PLATFORM_32_BIT)
static VkNonDispatchableHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
return {handle};
}
HandleType GetHandle() const {
return mHandle;
}
static constexpr uint64_t VK_NULL_HANDLE = 0;
#else
# error "Unsupported platform"
#endif
private:
VkNonDispatchableHandle(uint64_t handle) : mHandle(handle) {
}
uint64_t mHandle = 0;
};
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) \
struct VkTag##object; \
DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
using object = VkNonDispatchableHandle<VkTag##object, object##Native>; \
static_assert(sizeof(object) == sizeof(uint64_t), ""); \
static_assert(alignof(object) == kUint64Alignment, ""); \
static_assert(sizeof(object) == sizeof(object##Native), ""); \
static_assert(alignof(object) == kNativeVkHandleAlignment, "");
# include <vulkan/vulkan.h>
// VK_NULL_HANDLE is defined to 0 but we don't want our handle type to compare to arbitrary
// integers. Redefine VK_NULL_HANDLE to nullptr that has its own type.
# undef VK_NULL_HANDLE
# define VK_NULL_HANDLE nullptr
// Remove windows.h macros after vulkan_platform's include of windows.h
#if defined(DAWN_PLATFORM_WINDOWS)
# include "common/windows_with_undefs.h"

View File

@ -272,7 +272,7 @@ namespace dawn_native { namespace vulkan {
createInfo.pUserData = this;
return CheckVkSuccess(mFunctions.CreateDebugReportCallbackEXT(
mInstance, &createInfo, nullptr, &mDebugReportCallback),
mInstance, &createInfo, nullptr, &*mDebugReportCallback),
"vkCreateDebugReportcallback");
}

View File

@ -105,7 +105,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice());
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorSetLayout(
device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateDescriptorSetLayout"));
// Compute the size of descriptor pools used for this layout.
@ -171,7 +171,7 @@ namespace dawn_native { namespace vulkan {
VkDescriptorPool descriptorPool;
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorPool(device->GetVkDevice(), &createInfo,
nullptr, &descriptorPool),
nullptr, &*descriptorPool),
"CreateDescriptorPool"));
// Allocate our single set.
@ -180,12 +180,13 @@ namespace dawn_native { namespace vulkan {
allocateInfo.pNext = nullptr;
allocateInfo.descriptorPool = descriptorPool;
allocateInfo.descriptorSetCount = 1;
allocateInfo.pSetLayouts = &mHandle;
allocateInfo.pSetLayouts = &*mHandle;
VkDescriptorSet descriptorSet;
MaybeError result = CheckVkSuccess(
device->fn.AllocateDescriptorSets(device->GetVkDevice(), &allocateInfo, &descriptorSet),
"AllocateDescriptorSets");
MaybeError result =
CheckVkSuccess(device->fn.AllocateDescriptorSets(device->GetVkDevice(), &allocateInfo,
&*descriptorSet),
"AllocateDescriptorSets");
if (result.IsError()) {
// On an error we can destroy the pool immediately because no command references it.

View File

@ -17,6 +17,7 @@
#include "dawn_native/BindGroup.h"
#include "common/vulkan_platform.h"
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
namespace dawn_native { namespace vulkan {

View File

@ -147,7 +147,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice());
DAWN_TRY(CheckVkSuccess(
device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"vkCreateBuffer"));
VkMemoryRequirements requirements;

View File

@ -106,7 +106,7 @@ namespace dawn_native { namespace vulkan {
? dynamicOffsets[dirtyIndex].data()
: nullptr;
device->fn.CmdBindDescriptorSets(commands, bindPoint, pipelineLayout, dirtyIndex, 1,
&set, dynamicOffsetCounts[dirtyIndex],
&*set, dynamicOffsetCounts[dirtyIndex],
dynamicOffset);
}
}
@ -255,14 +255,14 @@ namespace dawn_native { namespace vulkan {
createInfo.flags = 0;
createInfo.renderPass = renderPassVK;
createInfo.attachmentCount = attachmentCount;
createInfo.pAttachments = attachments.data();
createInfo.pAttachments = AsVkArray(attachments.data());
createInfo.width = renderPass->width;
createInfo.height = renderPass->height;
createInfo.layers = 1;
DAWN_TRY(
CheckVkSuccess(device->fn.CreateFramebuffer(device->GetVkDevice(), &createInfo,
nullptr, &framebuffer),
nullptr, &*framebuffer),
"CreateFramebuffer"));
// We don't reuse VkFramebuffers so mark the framebuffer for deletion as soon as the
@ -827,7 +827,7 @@ namespace dawn_native { namespace vulkan {
VkBuffer buffer = ToBackend(cmd->buffer)->GetHandle();
VkDeviceSize offset = static_cast<VkDeviceSize>(cmd->offset);
device->fn.CmdBindVertexBuffers(commands, cmd->slot, 1, &buffer, &offset);
device->fn.CmdBindVertexBuffers(commands, cmd->slot, 1, &*buffer, &offset);
} break;
default:

View File

@ -38,7 +38,7 @@ namespace dawn_native { namespace vulkan {
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.layout = ToBackend(descriptor->layout)->GetHandle();
createInfo.basePipelineHandle = VK_NULL_HANDLE;
createInfo.basePipelineHandle = ::VK_NULL_HANDLE;
createInfo.basePipelineIndex = -1;
createInfo.stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@ -51,8 +51,8 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice());
return CheckVkSuccess(
device->fn.CreateComputePipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1, &createInfo,
nullptr, &mHandle),
device->fn.CreateComputePipelines(device->GetVkDevice(), ::VK_NULL_HANDLE, 1,
&createInfo, nullptr, &*mHandle),
"CreateComputePipeline");
}

View File

@ -272,13 +272,13 @@ namespace dawn_native { namespace vulkan {
submitInfo.pNext = nullptr;
submitInfo.waitSemaphoreCount =
static_cast<uint32_t>(mRecordingContext.waitSemaphores.size());
submitInfo.pWaitSemaphores = mRecordingContext.waitSemaphores.data();
submitInfo.pWaitSemaphores = AsVkArray(mRecordingContext.waitSemaphores.data());
submitInfo.pWaitDstStageMask = dstStageMasks.data();
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &mRecordingContext.commandBuffer;
submitInfo.signalSemaphoreCount =
static_cast<uint32_t>(mRecordingContext.signalSemaphores.size());
submitInfo.pSignalSemaphores = mRecordingContext.signalSemaphores.data();
submitInfo.pSignalSemaphores = AsVkArray(mRecordingContext.signalSemaphores.data());
VkFence fence = VK_NULL_HANDLE;
DAWN_TRY_ASSIGN(fence, GetUnusedFence());
@ -474,7 +474,7 @@ namespace dawn_native { namespace vulkan {
ResultOrError<VkFence> Device::GetUnusedFence() {
if (!mUnusedFences.empty()) {
VkFence fence = mUnusedFences.back();
DAWN_TRY(CheckVkSuccess(fn.ResetFences(mVkDevice, 1, &fence), "vkResetFences"));
DAWN_TRY(CheckVkSuccess(fn.ResetFences(mVkDevice, 1, &*fence), "vkResetFences"));
mUnusedFences.pop_back();
return fence;
@ -486,7 +486,7 @@ namespace dawn_native { namespace vulkan {
createInfo.flags = 0;
VkFence fence = VK_NULL_HANDLE;
DAWN_TRY(CheckVkSuccess(fn.CreateFence(mVkDevice, &createInfo, nullptr, &fence),
DAWN_TRY(CheckVkSuccess(fn.CreateFence(mVkDevice, &createInfo, nullptr, &*fence),
"vkCreateFence"));
return fence;
@ -539,7 +539,7 @@ namespace dawn_native { namespace vulkan {
createInfo.queueFamilyIndex = mQueueFamily;
DAWN_TRY(CheckVkSuccess(fn.CreateCommandPool(mVkDevice, &createInfo, nullptr,
&mRecordingContext.commandPool),
&*mRecordingContext.commandPool),
"vkCreateCommandPool"));
VkCommandBufferAllocateInfo allocateInfo;
@ -756,7 +756,7 @@ namespace dawn_native { namespace vulkan {
VkResult result = VkResult::WrapUnsafe(VK_TIMEOUT);
do {
result = VkResult::WrapUnsafe(
INJECT_ERROR_OR_RUN(fn.WaitForFences(mVkDevice, 1, &fence, true, UINT64_MAX),
INJECT_ERROR_OR_RUN(fn.WaitForFences(mVkDevice, 1, &*fence, true, UINT64_MAX),
VK_ERROR_DEVICE_LOST));
} while (result == VK_TIMEOUT);

View File

@ -136,7 +136,7 @@ namespace dawn_native { namespace vulkan {
createInfo.oldSwapchain = oldSwapchain;
if (mDevice->fn.CreateSwapchainKHR(mDevice->GetVkDevice(), &createInfo, nullptr,
&mSwapChain) != VK_SUCCESS) {
&*mSwapChain) != VK_SUCCESS) {
ASSERT(false);
}
@ -151,7 +151,7 @@ namespace dawn_native { namespace vulkan {
ASSERT(count >= mConfig.minImageCount);
mSwapChainImages.resize(count);
if (mDevice->fn.GetSwapchainImagesKHR(mDevice->GetVkDevice(), mSwapChain, &count,
mSwapChainImages.data()) != VK_SUCCESS) {
AsVkArray(mSwapChainImages.data())) != VK_SUCCESS) {
ASSERT(false);
}
@ -168,7 +168,7 @@ namespace dawn_native { namespace vulkan {
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
barrier.srcQueueFamilyIndex = 0;
barrier.dstQueueFamilyIndex = 0;
barrier.image = image;
barrier.image = *image;
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
barrier.subresourceRange.baseMipLevel = 0;
barrier.subresourceRange.levelCount = 1;
@ -197,18 +197,22 @@ namespace dawn_native { namespace vulkan {
createInfo.pNext = nullptr;
createInfo.flags = 0;
if (mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &createInfo, nullptr,
&semaphore) != VK_SUCCESS) {
&*semaphore) != VK_SUCCESS) {
ASSERT(false);
}
}
if (mDevice->fn.AcquireNextImageKHR(mDevice->GetVkDevice(), mSwapChain,
std::numeric_limits<uint64_t>::max(), semaphore,
VK_NULL_HANDLE, &mLastImageIndex) != VK_SUCCESS) {
VkFence{}, &mLastImageIndex) != VK_SUCCESS) {
ASSERT(false);
}
nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetU64();
nextTexture->texture.u64 =
#if defined(DAWN_PLATFORM_64_BIT)
reinterpret_cast<uint64_t>
#endif
(*mSwapChainImages[mLastImageIndex]);
mDevice->GetPendingRecordingContext()->waitSemaphores.push_back(semaphore);
return DAWN_SWAP_CHAIN_NO_ERROR;
@ -227,7 +231,7 @@ namespace dawn_native { namespace vulkan {
presentInfo.waitSemaphoreCount = 0;
presentInfo.pWaitSemaphores = nullptr;
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &mSwapChain;
presentInfo.pSwapchains = &*mSwapChain;
presentInfo.pImageIndices = &mLastImageIndex;
presentInfo.pResults = nullptr;

View File

@ -48,13 +48,13 @@ namespace dawn_native { namespace vulkan {
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.setLayoutCount = numSetLayouts;
createInfo.pSetLayouts = setLayouts.data();
createInfo.pSetLayouts = AsVkArray(setLayouts.data());
createInfo.pushConstantRangeCount = 0;
createInfo.pPushConstantRanges = nullptr;
Device* device = ToBackend(GetDevice());
return CheckVkSuccess(
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreatePipelineLayout");
}

View File

@ -191,9 +191,9 @@ namespace dawn_native { namespace vulkan {
// Create the render pass from the zillion parameters
VkRenderPass renderPass;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateRenderPass(mDevice->GetVkDevice(), &createInfo, nullptr, &renderPass),
"CreateRenderPass"));
DAWN_TRY(CheckVkSuccess(mDevice->fn.CreateRenderPass(mDevice->GetVkDevice(), &createInfo,
nullptr, &*renderPass),
"CreateRenderPass"));
return renderPass;
}

View File

@ -495,12 +495,12 @@ namespace dawn_native { namespace vulkan {
createInfo.layout = ToBackend(GetLayout())->GetHandle();
createInfo.renderPass = renderPass;
createInfo.subpass = 0;
createInfo.basePipelineHandle = VK_NULL_HANDLE;
createInfo.basePipelineHandle = VkPipeline{};
createInfo.basePipelineIndex = -1;
return CheckVkSuccess(
device->fn.CreateGraphicsPipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1,
&createInfo, nullptr, &mHandle),
device->fn.CreateGraphicsPipelines(device->GetVkDevice(), VkPipelineCache{}, 1,
&createInfo, nullptr, &*mHandle),
"CreateGraphicsPipeline");
}

View File

@ -73,7 +73,7 @@ namespace dawn_native { namespace vulkan {
// First check OOM that we want to surface to the application.
DAWN_TRY(CheckVkOOMThenSuccess(
mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr,
&allocatedMemory),
&*allocatedMemory),
"vkAllocateMemory"));
ASSERT(allocatedMemory != VK_NULL_HANDLE);

View File

@ -87,7 +87,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice());
return CheckVkSuccess(
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateSampler");
}

View File

@ -74,7 +74,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice());
return CheckVkSuccess(
device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateShaderModule");
}

View File

@ -36,7 +36,7 @@ namespace dawn_native { namespace vulkan {
createInfo.pQueueFamilyIndices = 0;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr, &mBuffer),
mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr, &*mBuffer),
"vkCreateBuffer"));
VkMemoryRequirements requirements;

View File

@ -47,7 +47,8 @@ namespace dawn_native { namespace vulkan {
return nullptr;
}
VkImage nativeTexture = VkImage::CreateFromU64(next.texture.u64);
VkImage nativeTexture =
VkImage::CreateFromHandle(reinterpret_cast<::VkImage>(next.texture.u64));
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
}

View File

@ -460,7 +460,7 @@ namespace dawn_native { namespace vulkan {
createInfo.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
DAWN_TRY(CheckVkSuccess(
device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateImage"));
// Create the image memory and associate it with the container
@ -806,7 +806,7 @@ namespace dawn_native { namespace vulkan {
createInfo.subresourceRange.layerCount = descriptor->arrayLayerCount;
return CheckVkSuccess(
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateImageView");
}

View File

@ -42,7 +42,7 @@ namespace dawn_native { namespace vulkan {
// Explicitly export this function because it uses the "native" type for surfaces while the
// header as seen in this file uses the wrapped type.
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
CreateNativeSwapChainImpl(WGPUDevice device, VkSurfaceKHRNative surfaceNative) {
CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surfaceNative) {
Device* backendDevice = reinterpret_cast<Device*>(device);
VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);

View File

@ -196,7 +196,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
memoryDedicatedAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
memoryDedicatedAllocateInfo.pNext = nullptr;
memoryDedicatedAllocateInfo.image = image;
memoryDedicatedAllocateInfo.buffer = VK_NULL_HANDLE;
memoryDedicatedAllocateInfo.buffer = VkBuffer{};
VkImportMemoryFdInfoKHR importMemoryFdInfo;
importMemoryFdInfo.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR;
@ -213,7 +213,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
DAWN_TRY(
CheckVkSuccess(mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &memoryAllocateInfo,
nullptr, &allocatedMemory),
nullptr, &*allocatedMemory),
"vkAllocateMemory"));
return allocatedMemory;
}
@ -264,7 +264,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
// Create a new VkImage with tiling equal to the DRM format modifier.
VkImage image;
DAWN_TRY(CheckVkSuccess(mDevice->fn.CreateImage(device, &createInfo, nullptr, &image),
DAWN_TRY(CheckVkSuccess(mDevice->fn.CreateImage(device, &createInfo, nullptr, &*image),
"CreateImage"));
return image;
}

View File

@ -130,7 +130,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
DAWN_TRY(CheckVkSuccess(mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo,
nullptr, &allocatedMemory),
nullptr, &*allocatedMemory),
"vkAllocateMemory"));
return allocatedMemory;
}
@ -146,7 +146,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
VkImage image;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &image),
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &*image),
"CreateImage"));
return image;
}

View File

@ -130,7 +130,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
DAWN_TRY(CheckVkSuccess(mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo,
nullptr, &allocatedMemory),
nullptr, &*allocatedMemory),
"vkAllocateMemory"));
return allocatedMemory;
}
@ -146,7 +146,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
VkImage image;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &image),
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &*image),
"CreateImage"));
return image;
}

View File

@ -72,7 +72,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
info.flags = 0;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &semaphore),
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &*semaphore),
"vkCreateSemaphore"));
VkImportSemaphoreFdInfoKHR importSemaphoreFdInfo;
@ -109,7 +109,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
VkSemaphore signalSemaphore;
DAWN_TRY(
CheckVkSuccess(mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &semaphoreCreateInfo,
nullptr, &signalSemaphore),
nullptr, &*signalSemaphore),
"vkCreateSemaphore"));
return signalSemaphore;
}

View File

@ -72,7 +72,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
info.flags = 0;
DAWN_TRY(CheckVkSuccess(
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &semaphore),
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &*semaphore),
"vkCreateSemaphore"));
VkImportSemaphoreZirconHandleInfoFUCHSIA importSempahoreHandleInfo;
@ -112,7 +112,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
VkSemaphore signalSemaphore;
DAWN_TRY(
CheckVkSuccess(mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &semaphoreCreateInfo,
nullptr, &signalSemaphore),
nullptr, &*signalSemaphore),
"vkCreateSemaphore"));
return signalSemaphore;
}

View File

@ -47,8 +47,8 @@ namespace dawn_native { namespace vulkan {
DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
VkSurfaceKHR surface);
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surface);
DAWN_NATIVE_EXPORT WGPUTextureFormat
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);

View File

@ -32,30 +32,30 @@
// them.
#define EXPECT_BUFFER_U32_EQ(expected, buffer, offset) \
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t), \
new detail::ExpectEq<uint32_t>(expected))
new ::detail::ExpectEq<uint32_t>(expected))
#define EXPECT_BUFFER_U32_RANGE_EQ(expected, buffer, offset, count) \
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t) * count, \
new detail::ExpectEq<uint32_t>(expected, count))
new ::detail::ExpectEq<uint32_t>(expected, count))
// Test a pixel of the mip level 0 of a 2D texture.
#define EXPECT_PIXEL_RGBA8_EQ(expected, texture, x, y) \
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, 0, sizeof(RGBA8), \
new detail::ExpectEq<RGBA8>(expected))
new ::detail::ExpectEq<RGBA8>(expected))
#define EXPECT_TEXTURE_RGBA8_EQ(expected, texture, x, y, width, height, level, slice) \
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
sizeof(RGBA8), \
new detail::ExpectEq<RGBA8>(expected, (width) * (height)))
new ::detail::ExpectEq<RGBA8>(expected, (width) * (height)))
#define EXPECT_PIXEL_FLOAT_EQ(expected, texture, x, y) \
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, 0, sizeof(float), \
new detail::ExpectEq<float>(expected))
new ::detail::ExpectEq<float>(expected))
#define EXPECT_TEXTURE_FLOAT_EQ(expected, texture, x, y, width, height, level, slice) \
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
sizeof(float), \
new detail::ExpectEq<float>(expected, (width) * (height)))
new ::detail::ExpectEq<float>(expected, (width) * (height)))
// Should only be used to test validation of function that can't be tested by regular validation
// tests;

File diff suppressed because it is too large Load Diff