mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 03:11:29 +00:00
Revert "Remove VK_DEFINE_NON_DISPATCHABLE_HANDLE magic, use explicit VkHandle wrapper"
This reverts commit 4e17d5c2483b63d4863162d692a1a961d1dcb958. Reason for revert: broken on chromeos Original change's description: > 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. > > Bug: chromium:1046362 > Change-Id: I9c5691b6e295aca1b46d4e3d0203956e4d570285 > Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15580 > Reviewed-by: Austin Eng <enga@chromium.org> > Reviewed-by: Kai Ninomiya <kainino@chromium.org> > Commit-Queue: Kai Ninomiya <kainino@chromium.org> TBR=cwallez@chromium.org,kainino@chromium.org,enga@chromium.org Change-Id: I500df2e34fd0f245ad04c517ff028ddd7bb5a2bf No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:1046362 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15620 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
4e17d5c248
commit
f28d0ae614
@ -18,9 +18,6 @@
|
|||||||
#if !defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#if !defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
# error "vulkan_platform.h included without the Vulkan backend enabled"
|
# error "vulkan_platform.h included without the Vulkan backend enabled"
|
||||||
#endif
|
#endif
|
||||||
#if defined(VULKAN_CORE_H_)
|
|
||||||
# error "vulkan.h included before vulkan_platform.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "common/Platform.h"
|
#include "common/Platform.h"
|
||||||
|
|
||||||
@ -36,9 +33,10 @@
|
|||||||
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
|
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if defined(DAWN_PLATFORM_64_BIT)
|
||||||
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
|
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
|
||||||
|
using object##Native = struct object##_T*;
|
||||||
#elif defined(DAWN_PLATFORM_32_BIT)
|
#elif defined(DAWN_PLATFORM_32_BIT)
|
||||||
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
|
# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object##Native = uint64_t;
|
||||||
#else
|
#else
|
||||||
# error "Unsupported platform"
|
# error "Unsupported platform"
|
||||||
#endif
|
#endif
|
||||||
@ -55,38 +53,35 @@ 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
|
// 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
|
// wrapped in a structure. Hence VkSameHandleNativeWrappe
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
template <typename T>
|
||||||
|
struct WrapperStruct {
|
||||||
namespace detail {
|
|
||||||
template <typename T>
|
|
||||||
struct WrapperStruct {
|
|
||||||
T member;
|
T member;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static constexpr size_t AlignOfInStruct = alignof(WrapperStruct<T>);
|
static constexpr size_t AlignOfInStruct = alignof(WrapperStruct<T>);
|
||||||
|
|
||||||
static constexpr size_t kNativeVkHandleAlignment = AlignOfInStruct<VkSomeHandle>;
|
static constexpr size_t kNativeVkHandleAlignment = AlignOfInStruct<VkSomeHandleNative>;
|
||||||
static constexpr size_t kUint64Alignment = AlignOfInStruct<uint64_t>;
|
static constexpr size_t kUint64Alignment = AlignOfInStruct<VkSomeHandleNative>;
|
||||||
|
|
||||||
// Simple handle types that supports "nullptr_t" as a 0 value.
|
// Simple handle types that supports "nullptr_t" as a 0 value.
|
||||||
template <typename Tag, typename HandleType>
|
template <typename Tag, typename HandleType>
|
||||||
class alignas(detail::kNativeVkHandleAlignment) VkHandle {
|
class alignas(kNativeVkHandleAlignment) VkNonDispatchableHandle {
|
||||||
public:
|
public:
|
||||||
// Default constructor and assigning of VK_NULL_HANDLE
|
// Default constructor and assigning of VK_NULL_HANDLE
|
||||||
VkHandle() = default;
|
VkNonDispatchableHandle() = default;
|
||||||
VkHandle(std::nullptr_t) {
|
VkNonDispatchableHandle(std::nullptr_t) : mHandle(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use default copy constructor/assignment
|
// Use default copy constructor/assignment
|
||||||
VkHandle(const VkHandle<Tag, HandleType>& other) = default;
|
VkNonDispatchableHandle(const VkNonDispatchableHandle<Tag, HandleType>& other) = default;
|
||||||
VkHandle& operator=(const VkHandle<Tag, HandleType>&) = default;
|
VkNonDispatchableHandle& operator=(const VkNonDispatchableHandle<Tag, HandleType>&) = default;
|
||||||
|
|
||||||
// Comparisons between handles
|
// Comparisons between handles
|
||||||
bool operator==(VkHandle<Tag, HandleType> other) const {
|
bool operator==(VkNonDispatchableHandle<Tag, HandleType> other) const {
|
||||||
return mHandle == other.mHandle;
|
return mHandle == other.mHandle;
|
||||||
}
|
}
|
||||||
bool operator!=(VkHandle<Tag, HandleType> other) const {
|
bool operator!=(VkNonDispatchableHandle<Tag, HandleType> other) const {
|
||||||
return mHandle != other.mHandle;
|
return mHandle != other.mHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,63 +93,65 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return mHandle != 0;
|
return mHandle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implicit conversion to real Vulkan types.
|
// The regular Vulkan handle type depends on the pointer width but is always 64 bits wide.
|
||||||
operator HandleType() const {
|
// - On 64bit it is an opaque pointer type, probably to help with type safety
|
||||||
return GetHandle();
|
// - 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 {
|
HandleType GetHandle() const {
|
||||||
return mHandle;
|
return mHandle;
|
||||||
}
|
}
|
||||||
|
#elif defined(DAWN_PLATFORM_32_BIT)
|
||||||
|
static VkNonDispatchableHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
|
||||||
|
return {handle};
|
||||||
|
}
|
||||||
|
|
||||||
HandleType& operator*() {
|
HandleType GetHandle() const {
|
||||||
return mHandle;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}} // namespace dawn_native::vulkan
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#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 constexpr nullptr_t VK_NULL_HANDLE = nullptr;
|
|
||||||
#elif defined(DAWN_PLATFORM_32_BIT)
|
|
||||||
static constexpr uint64_t VK_NULL_HANDLE = 0;
|
|
||||||
#else
|
#else
|
||||||
# error "Unsupported platform"
|
# error "Unsupported platform"
|
||||||
#endif
|
#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
|
// Remove windows.h macros after vulkan_platform's include of windows.h
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||||
# include "common/windows_with_undefs.h"
|
# include "common/windows_with_undefs.h"
|
||||||
|
@ -272,7 +272,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pUserData = this;
|
createInfo.pUserData = this;
|
||||||
|
|
||||||
return CheckVkSuccess(mFunctions.CreateDebugReportCallbackEXT(
|
return CheckVkSuccess(mFunctions.CreateDebugReportCallbackEXT(
|
||||||
mInstance, &createInfo, nullptr, &*mDebugReportCallback),
|
mInstance, &createInfo, nullptr, &mDebugReportCallback),
|
||||||
"vkCreateDebugReportcallback");
|
"vkCreateDebugReportcallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorSetLayout(
|
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorSetLayout(
|
||||||
device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreateDescriptorSetLayout"));
|
"CreateDescriptorSetLayout"));
|
||||||
|
|
||||||
// Compute the size of descriptor pools used for this layout.
|
// Compute the size of descriptor pools used for this layout.
|
||||||
@ -171,7 +171,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
VkDescriptorPool descriptorPool;
|
VkDescriptorPool descriptorPool;
|
||||||
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorPool(device->GetVkDevice(), &createInfo,
|
DAWN_TRY(CheckVkSuccess(device->fn.CreateDescriptorPool(device->GetVkDevice(), &createInfo,
|
||||||
nullptr, &*descriptorPool),
|
nullptr, &descriptorPool),
|
||||||
"CreateDescriptorPool"));
|
"CreateDescriptorPool"));
|
||||||
|
|
||||||
// Allocate our single set.
|
// Allocate our single set.
|
||||||
@ -180,12 +180,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
allocateInfo.pNext = nullptr;
|
allocateInfo.pNext = nullptr;
|
||||||
allocateInfo.descriptorPool = descriptorPool;
|
allocateInfo.descriptorPool = descriptorPool;
|
||||||
allocateInfo.descriptorSetCount = 1;
|
allocateInfo.descriptorSetCount = 1;
|
||||||
allocateInfo.pSetLayouts = &*mHandle;
|
allocateInfo.pSetLayouts = &mHandle;
|
||||||
|
|
||||||
VkDescriptorSet descriptorSet;
|
VkDescriptorSet descriptorSet;
|
||||||
MaybeError result =
|
MaybeError result = CheckVkSuccess(
|
||||||
CheckVkSuccess(device->fn.AllocateDescriptorSets(device->GetVkDevice(), &allocateInfo,
|
device->fn.AllocateDescriptorSets(device->GetVkDevice(), &allocateInfo, &descriptorSet),
|
||||||
&*descriptorSet),
|
|
||||||
"AllocateDescriptorSets");
|
"AllocateDescriptorSets");
|
||||||
|
|
||||||
if (result.IsError()) {
|
if (result.IsError()) {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "dawn_native/BindGroup.h"
|
#include "dawn_native/BindGroup.h"
|
||||||
|
|
||||||
#include "common/vulkan_platform.h"
|
|
||||||
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
|
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
@ -147,7 +147,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
DAWN_TRY(CheckVkSuccess(
|
DAWN_TRY(CheckVkSuccess(
|
||||||
device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"vkCreateBuffer"));
|
"vkCreateBuffer"));
|
||||||
|
|
||||||
VkMemoryRequirements requirements;
|
VkMemoryRequirements requirements;
|
||||||
|
@ -106,7 +106,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
? dynamicOffsets[dirtyIndex].data()
|
? dynamicOffsets[dirtyIndex].data()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
device->fn.CmdBindDescriptorSets(commands, bindPoint, pipelineLayout, dirtyIndex, 1,
|
device->fn.CmdBindDescriptorSets(commands, bindPoint, pipelineLayout, dirtyIndex, 1,
|
||||||
&*set, dynamicOffsetCounts[dirtyIndex],
|
&set, dynamicOffsetCounts[dirtyIndex],
|
||||||
dynamicOffset);
|
dynamicOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,14 +255,14 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
createInfo.renderPass = renderPassVK;
|
createInfo.renderPass = renderPassVK;
|
||||||
createInfo.attachmentCount = attachmentCount;
|
createInfo.attachmentCount = attachmentCount;
|
||||||
createInfo.pAttachments = AsVkArray(attachments.data());
|
createInfo.pAttachments = attachments.data();
|
||||||
createInfo.width = renderPass->width;
|
createInfo.width = renderPass->width;
|
||||||
createInfo.height = renderPass->height;
|
createInfo.height = renderPass->height;
|
||||||
createInfo.layers = 1;
|
createInfo.layers = 1;
|
||||||
|
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
CheckVkSuccess(device->fn.CreateFramebuffer(device->GetVkDevice(), &createInfo,
|
CheckVkSuccess(device->fn.CreateFramebuffer(device->GetVkDevice(), &createInfo,
|
||||||
nullptr, &*framebuffer),
|
nullptr, &framebuffer),
|
||||||
"CreateFramebuffer"));
|
"CreateFramebuffer"));
|
||||||
|
|
||||||
// We don't reuse VkFramebuffers so mark the framebuffer for deletion as soon as the
|
// 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();
|
VkBuffer buffer = ToBackend(cmd->buffer)->GetHandle();
|
||||||
VkDeviceSize offset = static_cast<VkDeviceSize>(cmd->offset);
|
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;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -38,7 +38,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
createInfo.layout = ToBackend(descriptor->layout)->GetHandle();
|
createInfo.layout = ToBackend(descriptor->layout)->GetHandle();
|
||||||
createInfo.basePipelineHandle = ::VK_NULL_HANDLE;
|
createInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
createInfo.basePipelineIndex = -1;
|
createInfo.basePipelineIndex = -1;
|
||||||
|
|
||||||
createInfo.stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
createInfo.stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
@ -51,8 +51,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreateComputePipelines(device->GetVkDevice(), ::VK_NULL_HANDLE, 1,
|
device->fn.CreateComputePipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1, &createInfo,
|
||||||
&createInfo, nullptr, &*mHandle),
|
nullptr, &mHandle),
|
||||||
"CreateComputePipeline");
|
"CreateComputePipeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,13 +272,13 @@ namespace dawn_native { namespace vulkan {
|
|||||||
submitInfo.pNext = nullptr;
|
submitInfo.pNext = nullptr;
|
||||||
submitInfo.waitSemaphoreCount =
|
submitInfo.waitSemaphoreCount =
|
||||||
static_cast<uint32_t>(mRecordingContext.waitSemaphores.size());
|
static_cast<uint32_t>(mRecordingContext.waitSemaphores.size());
|
||||||
submitInfo.pWaitSemaphores = AsVkArray(mRecordingContext.waitSemaphores.data());
|
submitInfo.pWaitSemaphores = mRecordingContext.waitSemaphores.data();
|
||||||
submitInfo.pWaitDstStageMask = dstStageMasks.data();
|
submitInfo.pWaitDstStageMask = dstStageMasks.data();
|
||||||
submitInfo.commandBufferCount = 1;
|
submitInfo.commandBufferCount = 1;
|
||||||
submitInfo.pCommandBuffers = &mRecordingContext.commandBuffer;
|
submitInfo.pCommandBuffers = &mRecordingContext.commandBuffer;
|
||||||
submitInfo.signalSemaphoreCount =
|
submitInfo.signalSemaphoreCount =
|
||||||
static_cast<uint32_t>(mRecordingContext.signalSemaphores.size());
|
static_cast<uint32_t>(mRecordingContext.signalSemaphores.size());
|
||||||
submitInfo.pSignalSemaphores = AsVkArray(mRecordingContext.signalSemaphores.data());
|
submitInfo.pSignalSemaphores = mRecordingContext.signalSemaphores.data();
|
||||||
|
|
||||||
VkFence fence = VK_NULL_HANDLE;
|
VkFence fence = VK_NULL_HANDLE;
|
||||||
DAWN_TRY_ASSIGN(fence, GetUnusedFence());
|
DAWN_TRY_ASSIGN(fence, GetUnusedFence());
|
||||||
@ -474,7 +474,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
ResultOrError<VkFence> Device::GetUnusedFence() {
|
ResultOrError<VkFence> Device::GetUnusedFence() {
|
||||||
if (!mUnusedFences.empty()) {
|
if (!mUnusedFences.empty()) {
|
||||||
VkFence fence = mUnusedFences.back();
|
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();
|
mUnusedFences.pop_back();
|
||||||
return fence;
|
return fence;
|
||||||
@ -486,7 +486,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
|
|
||||||
VkFence fence = VK_NULL_HANDLE;
|
VkFence fence = VK_NULL_HANDLE;
|
||||||
DAWN_TRY(CheckVkSuccess(fn.CreateFence(mVkDevice, &createInfo, nullptr, &*fence),
|
DAWN_TRY(CheckVkSuccess(fn.CreateFence(mVkDevice, &createInfo, nullptr, &fence),
|
||||||
"vkCreateFence"));
|
"vkCreateFence"));
|
||||||
|
|
||||||
return fence;
|
return fence;
|
||||||
@ -539,7 +539,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.queueFamilyIndex = mQueueFamily;
|
createInfo.queueFamilyIndex = mQueueFamily;
|
||||||
|
|
||||||
DAWN_TRY(CheckVkSuccess(fn.CreateCommandPool(mVkDevice, &createInfo, nullptr,
|
DAWN_TRY(CheckVkSuccess(fn.CreateCommandPool(mVkDevice, &createInfo, nullptr,
|
||||||
&*mRecordingContext.commandPool),
|
&mRecordingContext.commandPool),
|
||||||
"vkCreateCommandPool"));
|
"vkCreateCommandPool"));
|
||||||
|
|
||||||
VkCommandBufferAllocateInfo allocateInfo;
|
VkCommandBufferAllocateInfo allocateInfo;
|
||||||
@ -756,7 +756,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
VkResult result = VkResult::WrapUnsafe(VK_TIMEOUT);
|
VkResult result = VkResult::WrapUnsafe(VK_TIMEOUT);
|
||||||
do {
|
do {
|
||||||
result = VkResult::WrapUnsafe(
|
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));
|
VK_ERROR_DEVICE_LOST));
|
||||||
} while (result == VK_TIMEOUT);
|
} while (result == VK_TIMEOUT);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.oldSwapchain = oldSwapchain;
|
createInfo.oldSwapchain = oldSwapchain;
|
||||||
|
|
||||||
if (mDevice->fn.CreateSwapchainKHR(mDevice->GetVkDevice(), &createInfo, nullptr,
|
if (mDevice->fn.CreateSwapchainKHR(mDevice->GetVkDevice(), &createInfo, nullptr,
|
||||||
&*mSwapChain) != VK_SUCCESS) {
|
&mSwapChain) != VK_SUCCESS) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
ASSERT(count >= mConfig.minImageCount);
|
ASSERT(count >= mConfig.minImageCount);
|
||||||
mSwapChainImages.resize(count);
|
mSwapChainImages.resize(count);
|
||||||
if (mDevice->fn.GetSwapchainImagesKHR(mDevice->GetVkDevice(), mSwapChain, &count,
|
if (mDevice->fn.GetSwapchainImagesKHR(mDevice->GetVkDevice(), mSwapChain, &count,
|
||||||
AsVkArray(mSwapChainImages.data())) != VK_SUCCESS) {
|
mSwapChainImages.data()) != VK_SUCCESS) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
barrier.srcQueueFamilyIndex = 0;
|
barrier.srcQueueFamilyIndex = 0;
|
||||||
barrier.dstQueueFamilyIndex = 0;
|
barrier.dstQueueFamilyIndex = 0;
|
||||||
barrier.image = *image;
|
barrier.image = image;
|
||||||
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
barrier.subresourceRange.baseMipLevel = 0;
|
barrier.subresourceRange.baseMipLevel = 0;
|
||||||
barrier.subresourceRange.levelCount = 1;
|
barrier.subresourceRange.levelCount = 1;
|
||||||
@ -197,22 +197,18 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
if (mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &createInfo, nullptr,
|
if (mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &createInfo, nullptr,
|
||||||
&*semaphore) != VK_SUCCESS) {
|
&semaphore) != VK_SUCCESS) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDevice->fn.AcquireNextImageKHR(mDevice->GetVkDevice(), mSwapChain,
|
if (mDevice->fn.AcquireNextImageKHR(mDevice->GetVkDevice(), mSwapChain,
|
||||||
std::numeric_limits<uint64_t>::max(), semaphore,
|
std::numeric_limits<uint64_t>::max(), semaphore,
|
||||||
VkFence{}, &mLastImageIndex) != VK_SUCCESS) {
|
VK_NULL_HANDLE, &mLastImageIndex) != VK_SUCCESS) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTexture->texture.u64 =
|
nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetU64();
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
|
||||||
reinterpret_cast<uint64_t>
|
|
||||||
#endif
|
|
||||||
(*mSwapChainImages[mLastImageIndex]);
|
|
||||||
mDevice->GetPendingRecordingContext()->waitSemaphores.push_back(semaphore);
|
mDevice->GetPendingRecordingContext()->waitSemaphores.push_back(semaphore);
|
||||||
|
|
||||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
@ -231,7 +227,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
presentInfo.waitSemaphoreCount = 0;
|
presentInfo.waitSemaphoreCount = 0;
|
||||||
presentInfo.pWaitSemaphores = nullptr;
|
presentInfo.pWaitSemaphores = nullptr;
|
||||||
presentInfo.swapchainCount = 1;
|
presentInfo.swapchainCount = 1;
|
||||||
presentInfo.pSwapchains = &*mSwapChain;
|
presentInfo.pSwapchains = &mSwapChain;
|
||||||
presentInfo.pImageIndices = &mLastImageIndex;
|
presentInfo.pImageIndices = &mLastImageIndex;
|
||||||
presentInfo.pResults = nullptr;
|
presentInfo.pResults = nullptr;
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
createInfo.setLayoutCount = numSetLayouts;
|
createInfo.setLayoutCount = numSetLayouts;
|
||||||
createInfo.pSetLayouts = AsVkArray(setLayouts.data());
|
createInfo.pSetLayouts = setLayouts.data();
|
||||||
createInfo.pushConstantRangeCount = 0;
|
createInfo.pushConstantRangeCount = 0;
|
||||||
createInfo.pPushConstantRanges = nullptr;
|
createInfo.pPushConstantRanges = nullptr;
|
||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreatePipelineLayout");
|
"CreatePipelineLayout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +191,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
// Create the render pass from the zillion parameters
|
// Create the render pass from the zillion parameters
|
||||||
VkRenderPass renderPass;
|
VkRenderPass renderPass;
|
||||||
DAWN_TRY(CheckVkSuccess(mDevice->fn.CreateRenderPass(mDevice->GetVkDevice(), &createInfo,
|
DAWN_TRY(CheckVkSuccess(
|
||||||
nullptr, &*renderPass),
|
mDevice->fn.CreateRenderPass(mDevice->GetVkDevice(), &createInfo, nullptr, &renderPass),
|
||||||
"CreateRenderPass"));
|
"CreateRenderPass"));
|
||||||
return renderPass;
|
return renderPass;
|
||||||
}
|
}
|
||||||
|
@ -495,12 +495,12 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.layout = ToBackend(GetLayout())->GetHandle();
|
createInfo.layout = ToBackend(GetLayout())->GetHandle();
|
||||||
createInfo.renderPass = renderPass;
|
createInfo.renderPass = renderPass;
|
||||||
createInfo.subpass = 0;
|
createInfo.subpass = 0;
|
||||||
createInfo.basePipelineHandle = VkPipeline{};
|
createInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
createInfo.basePipelineIndex = -1;
|
createInfo.basePipelineIndex = -1;
|
||||||
|
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreateGraphicsPipelines(device->GetVkDevice(), VkPipelineCache{}, 1,
|
device->fn.CreateGraphicsPipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1,
|
||||||
&createInfo, nullptr, &*mHandle),
|
&createInfo, nullptr, &mHandle),
|
||||||
"CreateGraphicsPipeline");
|
"CreateGraphicsPipeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
// First check OOM that we want to surface to the application.
|
// First check OOM that we want to surface to the application.
|
||||||
DAWN_TRY(CheckVkOOMThenSuccess(
|
DAWN_TRY(CheckVkOOMThenSuccess(
|
||||||
mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr,
|
mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr,
|
||||||
&*allocatedMemory),
|
&allocatedMemory),
|
||||||
"vkAllocateMemory"));
|
"vkAllocateMemory"));
|
||||||
|
|
||||||
ASSERT(allocatedMemory != VK_NULL_HANDLE);
|
ASSERT(allocatedMemory != VK_NULL_HANDLE);
|
||||||
|
@ -87,7 +87,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreateSampler");
|
"CreateSampler");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreateShaderModule");
|
"CreateShaderModule");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pQueueFamilyIndices = 0;
|
createInfo.pQueueFamilyIndices = 0;
|
||||||
|
|
||||||
DAWN_TRY(CheckVkSuccess(
|
DAWN_TRY(CheckVkSuccess(
|
||||||
mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr, &*mBuffer),
|
mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr, &mBuffer),
|
||||||
"vkCreateBuffer"));
|
"vkCreateBuffer"));
|
||||||
|
|
||||||
VkMemoryRequirements requirements;
|
VkMemoryRequirements requirements;
|
||||||
|
@ -47,8 +47,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImage nativeTexture =
|
VkImage nativeTexture = VkImage::CreateFromU64(next.texture.u64);
|
||||||
VkImage::CreateFromHandle(reinterpret_cast<::VkImage>(next.texture.u64));
|
|
||||||
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
|
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
createInfo.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
|
|
||||||
DAWN_TRY(CheckVkSuccess(
|
DAWN_TRY(CheckVkSuccess(
|
||||||
device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreateImage"));
|
"CreateImage"));
|
||||||
|
|
||||||
// Create the image memory and associate it with the container
|
// Create the image memory and associate it with the container
|
||||||
@ -806,7 +806,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.subresourceRange.layerCount = descriptor->arrayLayerCount;
|
createInfo.subresourceRange.layerCount = descriptor->arrayLayerCount;
|
||||||
|
|
||||||
return CheckVkSuccess(
|
return CheckVkSuccess(
|
||||||
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
|
||||||
"CreateImageView");
|
"CreateImageView");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
// Explicitly export this function because it uses the "native" type for surfaces while the
|
// Explicitly export this function because it uses the "native" type for surfaces while the
|
||||||
// header as seen in this file uses the wrapped type.
|
// header as seen in this file uses the wrapped type.
|
||||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
||||||
CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surfaceNative) {
|
CreateNativeSwapChainImpl(WGPUDevice device, VkSurfaceKHRNative surfaceNative) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);
|
VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
|
|||||||
|
|
||||||
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
|
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
|
||||||
DAWN_TRY(CheckVkSuccess(mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo,
|
DAWN_TRY(CheckVkSuccess(mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo,
|
||||||
nullptr, &*allocatedMemory),
|
nullptr, &allocatedMemory),
|
||||||
"vkAllocateMemory"));
|
"vkAllocateMemory"));
|
||||||
return allocatedMemory;
|
return allocatedMemory;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ namespace dawn_native { namespace vulkan { namespace external_memory {
|
|||||||
|
|
||||||
VkImage image;
|
VkImage image;
|
||||||
DAWN_TRY(CheckVkSuccess(
|
DAWN_TRY(CheckVkSuccess(
|
||||||
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &*image),
|
mDevice->fn.CreateImage(mDevice->GetVkDevice(), &createInfo, nullptr, &image),
|
||||||
"CreateImage"));
|
"CreateImage"));
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
|
|||||||
info.flags = 0;
|
info.flags = 0;
|
||||||
|
|
||||||
DAWN_TRY(CheckVkSuccess(
|
DAWN_TRY(CheckVkSuccess(
|
||||||
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &*semaphore),
|
mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &info, nullptr, &semaphore),
|
||||||
"vkCreateSemaphore"));
|
"vkCreateSemaphore"));
|
||||||
|
|
||||||
VkImportSemaphoreFdInfoKHR importSemaphoreFdInfo;
|
VkImportSemaphoreFdInfoKHR importSemaphoreFdInfo;
|
||||||
@ -109,7 +109,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
|
|||||||
VkSemaphore signalSemaphore;
|
VkSemaphore signalSemaphore;
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
CheckVkSuccess(mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &semaphoreCreateInfo,
|
CheckVkSuccess(mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &semaphoreCreateInfo,
|
||||||
nullptr, &*signalSemaphore),
|
nullptr, &signalSemaphore),
|
||||||
"vkCreateSemaphore"));
|
"vkCreateSemaphore"));
|
||||||
return signalSemaphore;
|
return signalSemaphore;
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
|
DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
||||||
CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surface);
|
VkSurfaceKHR surface);
|
||||||
DAWN_NATIVE_EXPORT WGPUTextureFormat
|
DAWN_NATIVE_EXPORT WGPUTextureFormat
|
||||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||||
|
|
||||||
|
@ -32,30 +32,30 @@
|
|||||||
// them.
|
// them.
|
||||||
#define EXPECT_BUFFER_U32_EQ(expected, buffer, offset) \
|
#define EXPECT_BUFFER_U32_EQ(expected, buffer, offset) \
|
||||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t), \
|
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) \
|
#define EXPECT_BUFFER_U32_RANGE_EQ(expected, buffer, offset, count) \
|
||||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t) * 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.
|
// Test a pixel of the mip level 0 of a 2D texture.
|
||||||
#define EXPECT_PIXEL_RGBA8_EQ(expected, texture, x, y) \
|
#define EXPECT_PIXEL_RGBA8_EQ(expected, texture, x, y) \
|
||||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, 0, sizeof(RGBA8), \
|
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) \
|
#define EXPECT_TEXTURE_RGBA8_EQ(expected, texture, x, y, width, height, level, slice) \
|
||||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
|
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
|
||||||
sizeof(RGBA8), \
|
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) \
|
#define EXPECT_PIXEL_FLOAT_EQ(expected, texture, x, y) \
|
||||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, 0, sizeof(float), \
|
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) \
|
#define EXPECT_TEXTURE_FLOAT_EQ(expected, texture, x, y, width, height, level, slice) \
|
||||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
|
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, slice, \
|
||||||
sizeof(float), \
|
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
|
// Should only be used to test validation of function that can't be tested by regular validation
|
||||||
// tests;
|
// tests;
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class VulkanImageWrappingTestBase : public DawnTest {
|
class VulkanImageWrappingTestBase : public DawnTest {
|
||||||
public:
|
public:
|
||||||
@ -40,7 +38,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates a VkImage with external memory
|
// Creates a VkImage with external memory
|
||||||
::VkResult CreateImage(dawn_native::vulkan::Device* deviceVk,
|
VkResult CreateImage(dawn_native::vulkan::Device* deviceVk,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
VkFormat format,
|
VkFormat format,
|
||||||
@ -70,20 +68,18 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.pQueueFamilyIndices = nullptr;
|
createInfo.pQueueFamilyIndices = nullptr;
|
||||||
createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
|
||||||
return deviceVk->fn.CreateImage(deviceVk->GetVkDevice(), &createInfo, nullptr,
|
return deviceVk->fn.CreateImage(deviceVk->GetVkDevice(), &createInfo, nullptr, image);
|
||||||
&**image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocates memory for an image
|
// Allocates memory for an image
|
||||||
::VkResult AllocateMemory(dawn_native::vulkan::Device* deviceVk,
|
VkResult AllocateMemory(dawn_native::vulkan::Device* deviceVk,
|
||||||
VkImage handle,
|
VkImage handle,
|
||||||
VkDeviceMemory* allocation,
|
VkDeviceMemory* allocation,
|
||||||
VkDeviceSize* allocationSize,
|
VkDeviceSize* allocationSize,
|
||||||
uint32_t* memoryTypeIndex) {
|
uint32_t* memoryTypeIndex) {
|
||||||
// Create the image memory and associate it with the container
|
// Create the image memory and associate it with the container
|
||||||
VkMemoryRequirements requirements;
|
VkMemoryRequirements requirements;
|
||||||
deviceVk->fn.GetImageMemoryRequirements(deviceVk->GetVkDevice(), handle,
|
deviceVk->fn.GetImageMemoryRequirements(deviceVk->GetVkDevice(), handle, &requirements);
|
||||||
&requirements);
|
|
||||||
|
|
||||||
// Import memory from file descriptor
|
// Import memory from file descriptor
|
||||||
VkExportMemoryAllocateInfoKHR externalInfo;
|
VkExportMemoryAllocateInfoKHR externalInfo;
|
||||||
@ -103,11 +99,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
*memoryTypeIndex = allocateInfo.memoryTypeIndex;
|
*memoryTypeIndex = allocateInfo.memoryTypeIndex;
|
||||||
|
|
||||||
return deviceVk->fn.AllocateMemory(deviceVk->GetVkDevice(), &allocateInfo, nullptr,
|
return deviceVk->fn.AllocateMemory(deviceVk->GetVkDevice(), &allocateInfo, nullptr,
|
||||||
&**allocation);
|
allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binds memory to an image
|
// Binds memory to an image
|
||||||
::VkResult BindMemory(dawn_native::vulkan::Device* deviceVk,
|
VkResult BindMemory(dawn_native::vulkan::Device* deviceVk,
|
||||||
VkImage handle,
|
VkImage handle,
|
||||||
VkDeviceMemory* memory) {
|
VkDeviceMemory* memory) {
|
||||||
return deviceVk->fn.BindImageMemory(deviceVk->GetVkDevice(), handle, *memory, 0);
|
return deviceVk->fn.BindImageMemory(deviceVk->GetVkDevice(), handle, *memory, 0);
|
||||||
@ -138,10 +134,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
VkDeviceSize* allocationSize,
|
VkDeviceSize* allocationSize,
|
||||||
uint32_t* memoryTypeIndex,
|
uint32_t* memoryTypeIndex,
|
||||||
int* memoryFd) {
|
int* memoryFd) {
|
||||||
::VkResult result = CreateImage(deviceVk, width, height, format, handle);
|
VkResult result = CreateImage(deviceVk, width, height, format, handle);
|
||||||
EXPECT_EQ(result, VK_SUCCESS) << "Failed to create external image";
|
EXPECT_EQ(result, VK_SUCCESS) << "Failed to create external image";
|
||||||
|
|
||||||
::VkResult resultBool =
|
VkResult resultBool =
|
||||||
AllocateMemory(deviceVk, *handle, allocation, allocationSize, memoryTypeIndex);
|
AllocateMemory(deviceVk, *handle, allocation, allocationSize, memoryTypeIndex);
|
||||||
EXPECT_EQ(resultBool, VK_SUCCESS) << "Failed to allocate external memory";
|
EXPECT_EQ(resultBool, VK_SUCCESS) << "Failed to allocate external memory";
|
||||||
|
|
||||||
@ -169,8 +165,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
descriptor.memoryFD = memoryFd;
|
descriptor.memoryFD = memoryFd;
|
||||||
descriptor.waitFDs = waitFDs;
|
descriptor.waitFDs = waitFDs;
|
||||||
|
|
||||||
WGPUTexture texture =
|
WGPUTexture texture = dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
|
||||||
dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
|
|
||||||
|
|
||||||
if (expectValid) {
|
if (expectValid) {
|
||||||
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
|
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
|
||||||
@ -183,8 +178,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Exports the signal from a wrapped texture and ignores it
|
// Exports the signal from a wrapped texture and ignores it
|
||||||
// We have to export the signal before destroying the wrapped texture else it's an
|
// We have to export the signal before destroying the wrapped texture else it's an assertion
|
||||||
// assertion failure
|
// failure
|
||||||
void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
|
void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
|
||||||
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
|
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
|
||||||
wrappedTexture.Get());
|
wrappedTexture.Get());
|
||||||
@ -196,9 +191,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
dawn_native::vulkan::Device* deviceVk;
|
dawn_native::vulkan::Device* deviceVk;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
class VulkanImageWrappingValidationTests : public VulkanImageWrappingTestBase {
|
class VulkanImageWrappingValidationTests : public VulkanImageWrappingTestBase {
|
||||||
public:
|
public:
|
||||||
void TestSetUp() override {
|
void TestSetUp() override {
|
||||||
VulkanImageWrappingTestBase::TestSetUp();
|
VulkanImageWrappingTestBase::TestSetUp();
|
||||||
@ -207,8 +202,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CreateBindExportImage(deviceVk, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, &defaultImage,
|
CreateBindExportImage(deviceVk, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, &defaultImage,
|
||||||
&defaultAllocation, &defaultAllocationSize,
|
&defaultAllocation, &defaultAllocationSize, &defaultMemoryTypeIndex,
|
||||||
&defaultMemoryTypeIndex, &defaultFd);
|
&defaultFd);
|
||||||
defaultDescriptor.dimension = wgpu::TextureDimension::e2D;
|
defaultDescriptor.dimension = wgpu::TextureDimension::e2D;
|
||||||
defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
defaultDescriptor.size = {1, 1, 1};
|
defaultDescriptor.size = {1, 1, 1};
|
||||||
@ -237,29 +232,29 @@ namespace dawn_native { namespace vulkan {
|
|||||||
VkDeviceSize defaultAllocationSize;
|
VkDeviceSize defaultAllocationSize;
|
||||||
uint32_t defaultMemoryTypeIndex;
|
uint32_t defaultMemoryTypeIndex;
|
||||||
int defaultFd;
|
int defaultFd;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test no error occurs if the import is valid
|
// Test no error occurs if the import is valid
|
||||||
TEST_P(VulkanImageWrappingValidationTests, SuccessfulImport) {
|
TEST_P(VulkanImageWrappingValidationTests, SuccessfulImport) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
wgpu::Texture texture =
|
wgpu::Texture texture =
|
||||||
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, true);
|
defaultMemoryTypeIndex, {}, true, true);
|
||||||
EXPECT_NE(texture.Get(), nullptr);
|
EXPECT_NE(texture.Get(), nullptr);
|
||||||
IgnoreSignalSemaphore(device, texture);
|
IgnoreSignalSemaphore(device, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the texture descriptor is missing
|
// Test an error occurs if the texture descriptor is missing
|
||||||
TEST_P(VulkanImageWrappingValidationTests, MissingTextureDescriptor) {
|
TEST_P(VulkanImageWrappingValidationTests, MissingTextureDescriptor) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
ASSERT_DEVICE_ERROR(wgpu::Texture texture =
|
ASSERT_DEVICE_ERROR(wgpu::Texture texture =
|
||||||
WrapVulkanImage(device, nullptr, defaultFd, defaultAllocationSize,
|
WrapVulkanImage(device, nullptr, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the texture descriptor is invalid
|
// Test an error occurs if the texture descriptor is invalid
|
||||||
TEST_P(VulkanImageWrappingValidationTests, InvalidTextureDescriptor) {
|
TEST_P(VulkanImageWrappingValidationTests, InvalidTextureDescriptor) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
wgpu::ChainedStruct chainedDescriptor;
|
wgpu::ChainedStruct chainedDescriptor;
|
||||||
defaultDescriptor.nextInChain = &chainedDescriptor;
|
defaultDescriptor.nextInChain = &chainedDescriptor;
|
||||||
@ -268,10 +263,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the descriptor dimension isn't 2D
|
// Test an error occurs if the descriptor dimension isn't 2D
|
||||||
TEST_P(VulkanImageWrappingValidationTests, InvalidTextureDimension) {
|
TEST_P(VulkanImageWrappingValidationTests, InvalidTextureDimension) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
defaultDescriptor.dimension = wgpu::TextureDimension::e1D;
|
defaultDescriptor.dimension = wgpu::TextureDimension::e1D;
|
||||||
|
|
||||||
@ -279,10 +274,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the descriptor mip level count isn't 1
|
// Test an error occurs if the descriptor mip level count isn't 1
|
||||||
TEST_P(VulkanImageWrappingValidationTests, InvalidMipLevelCount) {
|
TEST_P(VulkanImageWrappingValidationTests, InvalidMipLevelCount) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
defaultDescriptor.mipLevelCount = 2;
|
defaultDescriptor.mipLevelCount = 2;
|
||||||
|
|
||||||
@ -290,10 +285,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the descriptor array layer count isn't 1
|
// Test an error occurs if the descriptor array layer count isn't 1
|
||||||
TEST_P(VulkanImageWrappingValidationTests, InvalidArrayLayerCount) {
|
TEST_P(VulkanImageWrappingValidationTests, InvalidArrayLayerCount) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
defaultDescriptor.arrayLayerCount = 2;
|
defaultDescriptor.arrayLayerCount = 2;
|
||||||
|
|
||||||
@ -301,10 +296,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if the descriptor sample count isn't 1
|
// Test an error occurs if the descriptor sample count isn't 1
|
||||||
TEST_P(VulkanImageWrappingValidationTests, InvalidSampleCount) {
|
TEST_P(VulkanImageWrappingValidationTests, InvalidSampleCount) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
defaultDescriptor.sampleCount = 4;
|
defaultDescriptor.sampleCount = 4;
|
||||||
|
|
||||||
@ -312,45 +307,45 @@ namespace dawn_native { namespace vulkan {
|
|||||||
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, false));
|
defaultMemoryTypeIndex, {}, true, false));
|
||||||
EXPECT_EQ(texture.Get(), nullptr);
|
EXPECT_EQ(texture.Get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if we try to export the signal semaphore twice
|
// Test an error occurs if we try to export the signal semaphore twice
|
||||||
TEST_P(VulkanImageWrappingValidationTests, DoubleSignalSemaphoreExport) {
|
TEST_P(VulkanImageWrappingValidationTests, DoubleSignalSemaphoreExport) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
wgpu::Texture texture =
|
wgpu::Texture texture =
|
||||||
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
||||||
defaultMemoryTypeIndex, {}, true, true);
|
defaultMemoryTypeIndex, {}, true, true);
|
||||||
ASSERT_NE(texture.Get(), nullptr);
|
ASSERT_NE(texture.Get(), nullptr);
|
||||||
IgnoreSignalSemaphore(device, texture);
|
IgnoreSignalSemaphore(device, texture);
|
||||||
ASSERT_DEVICE_ERROR(int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(
|
ASSERT_DEVICE_ERROR(
|
||||||
device.Get(), texture.Get()));
|
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(), texture.Get()));
|
||||||
ASSERT_EQ(fd, -1);
|
ASSERT_EQ(fd, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if we try to export the signal semaphore from a normal texture
|
// Test an error occurs if we try to export the signal semaphore from a normal texture
|
||||||
TEST_P(VulkanImageWrappingValidationTests, NormalTextureSignalSemaphoreExport) {
|
TEST_P(VulkanImageWrappingValidationTests, NormalTextureSignalSemaphoreExport) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
wgpu::Texture texture = device.CreateTexture(&defaultDescriptor);
|
wgpu::Texture texture = device.CreateTexture(&defaultDescriptor);
|
||||||
ASSERT_NE(texture.Get(), nullptr);
|
ASSERT_NE(texture.Get(), nullptr);
|
||||||
ASSERT_DEVICE_ERROR(int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(
|
ASSERT_DEVICE_ERROR(
|
||||||
device.Get(), texture.Get()));
|
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(), texture.Get()));
|
||||||
ASSERT_EQ(fd, -1);
|
ASSERT_EQ(fd, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test an error occurs if we try to export the signal semaphore from a destroyed texture
|
// Test an error occurs if we try to export the signal semaphore from a destroyed texture
|
||||||
TEST_P(VulkanImageWrappingValidationTests, DestroyedTextureSignalSemaphoreExport) {
|
TEST_P(VulkanImageWrappingValidationTests, DestroyedTextureSignalSemaphoreExport) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
wgpu::Texture texture = device.CreateTexture(&defaultDescriptor);
|
wgpu::Texture texture = device.CreateTexture(&defaultDescriptor);
|
||||||
ASSERT_NE(texture.Get(), nullptr);
|
ASSERT_NE(texture.Get(), nullptr);
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
ASSERT_DEVICE_ERROR(int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(
|
ASSERT_DEVICE_ERROR(
|
||||||
device.Get(), texture.Get()));
|
int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(), texture.Get()));
|
||||||
ASSERT_EQ(fd, -1);
|
ASSERT_EQ(fd, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fixture to test using external memory textures through different usages.
|
// Fixture to test using external memory textures through different usages.
|
||||||
// These tests are skipped if the harness is using the wire.
|
// These tests are skipped if the harness is using the wire.
|
||||||
class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
|
class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
|
||||||
public:
|
public:
|
||||||
void TestSetUp() override {
|
void TestSetUp() override {
|
||||||
VulkanImageWrappingTestBase::TestSetUp();
|
VulkanImageWrappingTestBase::TestSetUp();
|
||||||
@ -359,8 +354,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create another device based on the original
|
// Create another device based on the original
|
||||||
backendAdapter =
|
backendAdapter = reinterpret_cast<dawn_native::vulkan::Adapter*>(deviceVk->GetAdapter());
|
||||||
reinterpret_cast<dawn_native::vulkan::Adapter*>(deviceVk->GetAdapter());
|
|
||||||
deviceDescriptor.forceEnabledToggles = GetParam().forceEnabledWorkarounds;
|
deviceDescriptor.forceEnabledToggles = GetParam().forceEnabledWorkarounds;
|
||||||
deviceDescriptor.forceDisabledToggles = GetParam().forceDisabledWorkarounds;
|
deviceDescriptor.forceDisabledToggles = GetParam().forceDisabledWorkarounds;
|
||||||
|
|
||||||
@ -369,8 +363,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
secondDevice = wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(secondDeviceVk));
|
secondDevice = wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(secondDeviceVk));
|
||||||
|
|
||||||
CreateBindExportImage(deviceVk, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, &defaultImage,
|
CreateBindExportImage(deviceVk, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, &defaultImage,
|
||||||
&defaultAllocation, &defaultAllocationSize,
|
&defaultAllocation, &defaultAllocationSize, &defaultMemoryTypeIndex,
|
||||||
&defaultMemoryTypeIndex, &defaultFd);
|
&defaultFd);
|
||||||
defaultDescriptor.dimension = wgpu::TextureDimension::e2D;
|
defaultDescriptor.dimension = wgpu::TextureDimension::e2D;
|
||||||
defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
defaultDescriptor.size = {1, 1, 1};
|
defaultDescriptor.size = {1, 1, 1};
|
||||||
@ -449,11 +443,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear an image in |secondDevice|
|
// Clear an image in |secondDevice|
|
||||||
// Verify clear color is visible in |device|
|
// Verify clear color is visible in |device|
|
||||||
TEST_P(VulkanImageWrappingUsageTests, ClearImageAcrossDevices) {
|
TEST_P(VulkanImageWrappingUsageTests, ClearImageAcrossDevices) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
@ -477,19 +471,18 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import texture to |device| and |secondDevice|
|
// Import texture to |device| and |secondDevice|
|
||||||
// Clear image in |secondDevice|
|
// Clear image in |secondDevice|
|
||||||
// Verify clear color is visible in |device|
|
// Verify clear color is visible in |device|
|
||||||
// Verify the very first import into |device| also sees the change, since it should
|
// Verify the very first import into |device| also sees the change, since it should
|
||||||
// alias the same memory
|
// alias the same memory
|
||||||
TEST_P(VulkanImageWrappingUsageTests, ClearImageAcrossDevicesAliased) {
|
TEST_P(VulkanImageWrappingUsageTests, ClearImageAcrossDevicesAliased) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
// Import the image on |device
|
// Import the image on |device
|
||||||
wgpu::Texture wrappedTextureAlias =
|
wgpu::Texture wrappedTextureAlias = WrapVulkanImage(
|
||||||
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize, defaultMemoryTypeIndex, {});
|
||||||
defaultMemoryTypeIndex, {});
|
|
||||||
|
|
||||||
int memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
int memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
||||||
|
|
||||||
@ -518,11 +511,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
IgnoreSignalSemaphore(device, wrappedTextureAlias);
|
IgnoreSignalSemaphore(device, wrappedTextureAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear an image in |secondDevice|
|
// Clear an image in |secondDevice|
|
||||||
// Verify clear color is not visible in |device| if we import the texture as not cleared
|
// Verify clear color is not visible in |device| if we import the texture as not cleared
|
||||||
TEST_P(VulkanImageWrappingUsageTests, UnclearedTextureIsCleared) {
|
TEST_P(VulkanImageWrappingUsageTests, UnclearedTextureIsCleared) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
@ -546,12 +539,12 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 0, 0, 0), nextWrappedTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 0, 0, 0), nextWrappedTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import a texture into |secondDevice|
|
// Import a texture into |secondDevice|
|
||||||
// Issue a copy of the imported texture inside |device| to |copyDstTexture|
|
// Issue a copy of the imported texture inside |device| to |copyDstTexture|
|
||||||
// Verify the clear color from |secondDevice| is visible in |copyDstTexture|
|
// Verify the clear color from |secondDevice| is visible in |copyDstTexture|
|
||||||
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToTextureSrcSync) {
|
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToTextureSrcSync) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
@ -581,23 +574,22 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), copyDstTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), copyDstTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import a texture into |device|
|
// Import a texture into |device|
|
||||||
// Copy color A into texture on |device|
|
// Copy color A into texture on |device|
|
||||||
// Import same texture into |secondDevice|, waiting on the copy signal
|
// Import same texture into |secondDevice|, waiting on the copy signal
|
||||||
// Copy color B using Texture to Texture copy on |secondDevice|
|
// Copy color B using Texture to Texture copy on |secondDevice|
|
||||||
// Import texture back into |device|, waiting on color B signal
|
// Import texture back into |device|, waiting on color B signal
|
||||||
// Verify texture contains color B
|
// Verify texture contains color B
|
||||||
// If texture destination isn't synchronized, |secondDevice| could copy color B
|
// If texture destination isn't synchronized, |secondDevice| could copy color B
|
||||||
// into the texture first, then |device| writes color A
|
// into the texture first, then |device| writes color A
|
||||||
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToTextureDstSync) {
|
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToTextureDstSync) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |device|
|
// Import the image on |device|
|
||||||
wgpu::Texture wrappedTexture =
|
wgpu::Texture wrappedTexture = WrapVulkanImage(
|
||||||
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize, defaultMemoryTypeIndex, {});
|
||||||
defaultMemoryTypeIndex, {});
|
|
||||||
|
|
||||||
// Clear |wrappedTexture| on |device|
|
// Clear |wrappedTexture| on |device|
|
||||||
ClearImage(device, wrappedTexture, {5 / 255.0f, 6 / 255.0f, 7 / 255.0f, 8 / 255.0f});
|
ClearImage(device, wrappedTexture, {5 / 255.0f, 6 / 255.0f, 7 / 255.0f, 8 / 255.0f});
|
||||||
@ -621,8 +613,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
secondDeviceWrappedTexture);
|
secondDeviceWrappedTexture);
|
||||||
|
|
||||||
// Re-import back into |device|, waiting on |secondDevice|'s signal
|
// Re-import back into |device|, waiting on |secondDevice|'s signal
|
||||||
signalFd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(
|
signalFd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(secondDevice.Get(),
|
||||||
secondDevice.Get(), secondDeviceWrappedTexture.Get());
|
secondDeviceWrappedTexture.Get());
|
||||||
memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
||||||
|
|
||||||
wgpu::Texture nextWrappedTexture =
|
wgpu::Texture nextWrappedTexture =
|
||||||
@ -633,12 +625,12 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import a texture from |secondDevice|
|
// Import a texture from |secondDevice|
|
||||||
// Issue a copy of the imported texture inside |device| to |copyDstBuffer|
|
// Issue a copy of the imported texture inside |device| to |copyDstBuffer|
|
||||||
// Verify the clear color from |secondDevice| is visible in |copyDstBuffer|
|
// Verify the clear color from |secondDevice| is visible in |copyDstBuffer|
|
||||||
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToBufferSrcSync) {
|
TEST_P(VulkanImageWrappingUsageTests, CopyTextureToBufferSrcSync) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
@ -689,23 +681,22 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_BUFFER_U32_EQ(expected, copyDstBuffer, 0);
|
EXPECT_BUFFER_U32_EQ(expected, copyDstBuffer, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import a texture into |device|
|
// Import a texture into |device|
|
||||||
// Copy color A into texture on |device|
|
// Copy color A into texture on |device|
|
||||||
// Import same texture into |secondDevice|, waiting on the copy signal
|
// Import same texture into |secondDevice|, waiting on the copy signal
|
||||||
// Copy color B using Buffer to Texture copy on |secondDevice|
|
// Copy color B using Buffer to Texture copy on |secondDevice|
|
||||||
// Import texture back into |device|, waiting on color B signal
|
// Import texture back into |device|, waiting on color B signal
|
||||||
// Verify texture contains color B
|
// Verify texture contains color B
|
||||||
// If texture destination isn't synchronized, |secondDevice| could copy color B
|
// If texture destination isn't synchronized, |secondDevice| could copy color B
|
||||||
// into the texture first, then |device| writes color A
|
// into the texture first, then |device| writes color A
|
||||||
TEST_P(VulkanImageWrappingUsageTests, CopyBufferToTextureDstSync) {
|
TEST_P(VulkanImageWrappingUsageTests, CopyBufferToTextureDstSync) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |device|
|
// Import the image on |device|
|
||||||
wgpu::Texture wrappedTexture =
|
wgpu::Texture wrappedTexture = WrapVulkanImage(
|
||||||
WrapVulkanImage(device, &defaultDescriptor, defaultFd, defaultAllocationSize,
|
device, &defaultDescriptor, defaultFd, defaultAllocationSize, defaultMemoryTypeIndex, {});
|
||||||
defaultMemoryTypeIndex, {});
|
|
||||||
|
|
||||||
// Clear |wrappedTexture| on |device|
|
// Clear |wrappedTexture| on |device|
|
||||||
ClearImage(device, wrappedTexture, {5 / 255.0f, 6 / 255.0f, 7 / 255.0f, 8 / 255.0f});
|
ClearImage(device, wrappedTexture, {5 / 255.0f, 6 / 255.0f, 7 / 255.0f, 8 / 255.0f});
|
||||||
@ -747,8 +738,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
secondDeviceQueue.Submit(1, &commands);
|
secondDeviceQueue.Submit(1, &commands);
|
||||||
|
|
||||||
// Re-import back into |device|, waiting on |secondDevice|'s signal
|
// Re-import back into |device|, waiting on |secondDevice|'s signal
|
||||||
signalFd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(
|
signalFd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(secondDevice.Get(),
|
||||||
secondDevice.Get(), secondDeviceWrappedTexture.Get());
|
secondDeviceWrappedTexture.Get());
|
||||||
memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
memoryFd = GetMemoryFd(deviceVk, defaultAllocation);
|
||||||
|
|
||||||
wgpu::Texture nextWrappedTexture =
|
wgpu::Texture nextWrappedTexture =
|
||||||
@ -759,13 +750,13 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), nextWrappedTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import a texture from |secondDevice|
|
// Import a texture from |secondDevice|
|
||||||
// Issue a copy of the imported texture inside |device| to |copyDstTexture|
|
// Issue a copy of the imported texture inside |device| to |copyDstTexture|
|
||||||
// Issue second copy to |secondCopyDstTexture|
|
// Issue second copy to |secondCopyDstTexture|
|
||||||
// Verify the clear color from |secondDevice| is visible in both copies
|
// Verify the clear color from |secondDevice| is visible in both copies
|
||||||
TEST_P(VulkanImageWrappingUsageTests, DoubleTextureUsage) {
|
TEST_P(VulkanImageWrappingUsageTests, DoubleTextureUsage) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
@ -804,17 +795,17 @@ namespace dawn_native { namespace vulkan {
|
|||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), secondCopyDstTexture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 3, 4), secondCopyDstTexture, 0, 0);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
IgnoreSignalSemaphore(device, deviceWrappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tex A on device 3 (external export)
|
// Tex A on device 3 (external export)
|
||||||
// Tex B on device 2 (external export)
|
// Tex B on device 2 (external export)
|
||||||
// Tex C on device 1 (external export)
|
// Tex C on device 1 (external export)
|
||||||
// Clear color for A on device 3
|
// Clear color for A on device 3
|
||||||
// Copy A->B on device 3
|
// Copy A->B on device 3
|
||||||
// Copy B->C on device 2 (wait on B from previous op)
|
// Copy B->C on device 2 (wait on B from previous op)
|
||||||
// Copy C->D on device 1 (wait on C from previous op)
|
// Copy C->D on device 1 (wait on C from previous op)
|
||||||
// Verify D has same color as A
|
// Verify D has same color as A
|
||||||
TEST_P(VulkanImageWrappingUsageTests, ChainTextureCopy) {
|
TEST_P(VulkanImageWrappingUsageTests, ChainTextureCopy) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
|
||||||
// Close |defaultFd| since this test doesn't import it anywhere
|
// Close |defaultFd| since this test doesn't import it anywhere
|
||||||
@ -825,8 +816,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
// Create device 3
|
// Create device 3
|
||||||
dawn_native::vulkan::Device* thirdDeviceVk = reinterpret_cast<dawn_native::vulkan::Device*>(
|
dawn_native::vulkan::Device* thirdDeviceVk = reinterpret_cast<dawn_native::vulkan::Device*>(
|
||||||
backendAdapter->CreateDevice(&deviceDescriptor));
|
backendAdapter->CreateDevice(&deviceDescriptor));
|
||||||
wgpu::Device thirdDevice =
|
wgpu::Device thirdDevice = wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(thirdDeviceVk));
|
||||||
wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(thirdDeviceVk));
|
|
||||||
|
|
||||||
// Make queue for device 2 and 3
|
// Make queue for device 2 and 3
|
||||||
wgpu::Queue secondDeviceQueue = secondDevice.CreateQueue();
|
wgpu::Queue secondDeviceQueue = secondDevice.CreateQueue();
|
||||||
@ -858,15 +848,14 @@ namespace dawn_native { namespace vulkan {
|
|||||||
&allocationSizeC, &memoryTypeIndexC, &memoryFdC);
|
&allocationSizeC, &memoryTypeIndexC, &memoryFdC);
|
||||||
|
|
||||||
// Import TexA, TexB on device 3
|
// Import TexA, TexB on device 3
|
||||||
wgpu::Texture wrappedTexADevice3 = WrapVulkanImage(
|
wgpu::Texture wrappedTexADevice3 = WrapVulkanImage(thirdDevice, &defaultDescriptor, memoryFdA,
|
||||||
thirdDevice, &defaultDescriptor, memoryFdA, allocationSizeA, memoryTypeIndexA, {});
|
allocationSizeA, memoryTypeIndexA, {});
|
||||||
|
|
||||||
wgpu::Texture wrappedTexBDevice3 = WrapVulkanImage(
|
wgpu::Texture wrappedTexBDevice3 = WrapVulkanImage(thirdDevice, &defaultDescriptor, memoryFdB,
|
||||||
thirdDevice, &defaultDescriptor, memoryFdB, allocationSizeB, memoryTypeIndexB, {});
|
allocationSizeB, memoryTypeIndexB, {});
|
||||||
|
|
||||||
// Clear TexA
|
// Clear TexA
|
||||||
ClearImage(thirdDevice, wrappedTexADevice3,
|
ClearImage(thirdDevice, wrappedTexADevice3, {1 / 255.0f, 2 / 255.0f, 3 / 255.0f, 4 / 255.0f});
|
||||||
{1 / 255.0f, 2 / 255.0f, 3 / 255.0f, 4 / 255.0f});
|
|
||||||
|
|
||||||
// Copy A->B
|
// Copy A->B
|
||||||
SimpleCopyTextureToTexture(thirdDevice, thirdDeviceQueue, wrappedTexADevice3,
|
SimpleCopyTextureToTexture(thirdDevice, thirdDeviceQueue, wrappedTexADevice3,
|
||||||
@ -882,8 +871,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
WrapVulkanImage(secondDevice, &defaultDescriptor, memoryFdB, allocationSizeB,
|
WrapVulkanImage(secondDevice, &defaultDescriptor, memoryFdB, allocationSizeB,
|
||||||
memoryTypeIndexB, {signalFdTexBDevice3});
|
memoryTypeIndexB, {signalFdTexBDevice3});
|
||||||
|
|
||||||
wgpu::Texture wrappedTexCDevice2 = WrapVulkanImage(
|
wgpu::Texture wrappedTexCDevice2 = WrapVulkanImage(secondDevice, &defaultDescriptor, memoryFdC,
|
||||||
secondDevice, &defaultDescriptor, memoryFdC, allocationSizeC, memoryTypeIndexC, {});
|
allocationSizeC, memoryTypeIndexC, {});
|
||||||
|
|
||||||
// Copy B->C on device 2
|
// Copy B->C on device 2
|
||||||
SimpleCopyTextureToTexture(secondDevice, secondDeviceQueue, wrappedTexBDevice2,
|
SimpleCopyTextureToTexture(secondDevice, secondDeviceQueue, wrappedTexBDevice2,
|
||||||
@ -896,8 +885,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
// Import TexC on device 1
|
// Import TexC on device 1
|
||||||
memoryFdC = GetMemoryFd(deviceVk, allocationC);
|
memoryFdC = GetMemoryFd(deviceVk, allocationC);
|
||||||
wgpu::Texture wrappedTexCDevice1 =
|
wgpu::Texture wrappedTexCDevice1 =
|
||||||
WrapVulkanImage(device, &defaultDescriptor, memoryFdC, allocationSizeC,
|
WrapVulkanImage(device, &defaultDescriptor, memoryFdC, allocationSizeC, memoryTypeIndexC,
|
||||||
memoryTypeIndexC, {signalFdTexCDevice2});
|
{signalFdTexCDevice2});
|
||||||
|
|
||||||
// Create TexD on device 1
|
// Create TexD on device 1
|
||||||
wgpu::Texture texD = device.CreateTexture(&defaultDescriptor);
|
wgpu::Texture texD = device.CreateTexture(&defaultDescriptor);
|
||||||
@ -916,11 +905,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
deviceVk->GetFencedDeleter()->DeleteWhenUnused(allocationC);
|
deviceVk->GetFencedDeleter()->DeleteWhenUnused(allocationC);
|
||||||
|
|
||||||
IgnoreSignalSemaphore(device, wrappedTexCDevice1);
|
IgnoreSignalSemaphore(device, wrappedTexCDevice1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests a larger image is preserved when importing
|
// Tests a larger image is preserved when importing
|
||||||
// TODO(http://crbug.com/dawn/206): This fails on AMD
|
// TODO(http://crbug.com/dawn/206): This fails on AMD
|
||||||
TEST_P(VulkanImageWrappingUsageTests, LargerImage) {
|
TEST_P(VulkanImageWrappingUsageTests, LargerImage) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire() || IsAMD());
|
DAWN_SKIP_TEST_IF(UsesWire() || IsAMD());
|
||||||
|
|
||||||
close(defaultFd);
|
close(defaultFd);
|
||||||
@ -950,8 +939,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
int memoryFdA;
|
int memoryFdA;
|
||||||
VkDeviceSize allocationSizeA;
|
VkDeviceSize allocationSizeA;
|
||||||
uint32_t memoryTypeIndexA;
|
uint32_t memoryTypeIndexA;
|
||||||
CreateBindExportImage(secondDeviceVk, 640, 480, VK_FORMAT_R8G8B8A8_UNORM, &imageA,
|
CreateBindExportImage(secondDeviceVk, 640, 480, VK_FORMAT_R8G8B8A8_UNORM, &imageA, &allocationA,
|
||||||
&allocationA, &allocationSizeA, &memoryTypeIndexA, &memoryFdA);
|
&allocationSizeA, &memoryTypeIndexA, &memoryFdA);
|
||||||
|
|
||||||
// Import the image on |secondDevice|
|
// Import the image on |secondDevice|
|
||||||
wgpu::Texture wrappedTexture = WrapVulkanImage(secondDevice, &descriptor, memoryFdA,
|
wgpu::Texture wrappedTexture = WrapVulkanImage(secondDevice, &descriptor, memoryFdA,
|
||||||
@ -979,8 +968,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
{
|
{
|
||||||
wgpu::Buffer copySrcBuffer =
|
wgpu::Buffer copySrcBuffer =
|
||||||
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc);
|
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc);
|
||||||
wgpu::BufferCopyView copySrc =
|
wgpu::BufferCopyView copySrc = utils::CreateBufferCopyView(copySrcBuffer, 0, rowPitch, 0);
|
||||||
utils::CreateBufferCopyView(copySrcBuffer, 0, rowPitch, 0);
|
|
||||||
wgpu::TextureCopyView copyDst =
|
wgpu::TextureCopyView copyDst =
|
||||||
utils::CreateTextureCopyView(wrappedTexture, 0, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(wrappedTexture, 0, 0, {0, 0, 0});
|
||||||
wgpu::Extent3D copySize = {width, height, 1};
|
wgpu::Extent3D copySize = {width, height, 1};
|
||||||
@ -1007,8 +995,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
{
|
{
|
||||||
wgpu::TextureCopyView copySrc =
|
wgpu::TextureCopyView copySrc =
|
||||||
utils::CreateTextureCopyView(nextWrappedTexture, 0, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(nextWrappedTexture, 0, 0, {0, 0, 0});
|
||||||
wgpu::BufferCopyView copyDst =
|
wgpu::BufferCopyView copyDst = utils::CreateBufferCopyView(copyDstBuffer, 0, rowPitch, 0);
|
||||||
utils::CreateBufferCopyView(copyDstBuffer, 0, rowPitch, 0);
|
|
||||||
|
|
||||||
wgpu::Extent3D copySize = {width, height, 1};
|
wgpu::Extent3D copySize = {width, height, 1};
|
||||||
|
|
||||||
@ -1024,9 +1011,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
IgnoreSignalSemaphore(device, nextWrappedTexture);
|
||||||
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(imageA);
|
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(imageA);
|
||||||
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(allocationA);
|
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(allocationA);
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(VulkanImageWrappingValidationTests, VulkanBackend);
|
DAWN_INSTANTIATE_TEST(VulkanImageWrappingValidationTests, VulkanBackend);
|
||||||
DAWN_INSTANTIATE_TEST(VulkanImageWrappingUsageTests, VulkanBackend);
|
DAWN_INSTANTIATE_TEST(VulkanImageWrappingUsageTests, VulkanBackend);
|
||||||
|
|
||||||
}} // namespace dawn_native::vulkan
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user