Renames DestroyApiObject* to Destroy* for simplicity.
- Also updates and adds tests for CommandBuffer since it is the last object with a Destroy name clash. Bug: dawn:628 Change-Id: I028e0101a91a785aa90d2b656556d48fe0d6e736 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68101 Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
4a24f9c261
commit
e9c84c071f
|
@ -418,8 +418,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
BindGroupLayoutBase::~BindGroupLayoutBase() = default;
|
BindGroupLayoutBase::~BindGroupLayoutBase() = default;
|
||||||
|
|
||||||
bool BindGroupLayoutBase::DestroyApiObject() {
|
bool BindGroupLayoutBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
||||||
GetDevice()->UncacheBindGroupLayout(this);
|
GetDevice()->UncacheBindGroupLayout(this);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static BindGroupLayoutBase* MakeError(DeviceBase* device);
|
static BindGroupLayoutBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
// A map from the BindingNumber to its packed BindingIndex.
|
// A map from the BindingNumber to its packed BindingIndex.
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace dawn_native {
|
||||||
mFakeMappedData.reset();
|
mFakeMappedData.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override {
|
void DestroyImpl() override {
|
||||||
mFakeMappedData.reset();
|
mFakeMappedData.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ namespace dawn_native {
|
||||||
ASSERT(mState == BufferState::Unmapped || mState == BufferState::Destroyed);
|
ASSERT(mState == BufferState::Unmapped || mState == BufferState::Destroyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferBase::DestroyApiObject() {
|
bool BufferBase::Destroy() {
|
||||||
bool marked = MarkDestroyed();
|
bool marked = MarkDestroyed();
|
||||||
if (!marked) {
|
if (!marked) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -197,7 +197,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyApiObjectImpl();
|
DestroyImpl();
|
||||||
mState = BufferState::Destroyed;
|
mState = BufferState::Destroyed;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::APIDestroy() {
|
void BufferBase::APIDestroy() {
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError BufferBase::CopyFromStagingBuffer() {
|
MaybeError BufferBase::CopyFromStagingBuffer() {
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static BufferBase* MakeError(DeviceBase* device, const BufferDescriptor* descriptor);
|
static BufferBase* MakeError(DeviceBase* device, const BufferDescriptor* descriptor);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
uint64_t GetSize() const;
|
uint64_t GetSize() const;
|
||||||
|
|
|
@ -29,16 +29,18 @@ namespace dawn_native {
|
||||||
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||||
mCommands(encoder->AcquireCommands()),
|
mCommands(encoder->AcquireCommands()),
|
||||||
mResourceUsages(encoder->AcquireResourceUsages()) {
|
mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||||
|
TrackInDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandBufferBase::CommandBufferBase(DeviceBase* device)
|
||||||
|
: ApiObjectBase(device, kLabelNotImplemented) {
|
||||||
|
TrackInDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||||
: ApiObjectBase(device, tag) {
|
: ApiObjectBase(device, tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBufferBase::~CommandBufferBase() {
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CommandBufferBase* CommandBufferBase::MakeError(DeviceBase* device) {
|
CommandBufferBase* CommandBufferBase::MakeError(DeviceBase* device) {
|
||||||
return new CommandBufferBase(device, ObjectBase::kError);
|
return new CommandBufferBase(device, ObjectBase::kError);
|
||||||
|
@ -51,14 +53,13 @@ namespace dawn_native {
|
||||||
MaybeError CommandBufferBase::ValidateCanUseInSubmitNow() const {
|
MaybeError CommandBufferBase::ValidateCanUseInSubmitNow() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
DAWN_INVALID_IF(mDestroyed, "%s cannot be submitted more than once.", this);
|
DAWN_INVALID_IF(!IsAlive(), "%s cannot be submitted more than once.", this);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandBufferBase::Destroy() {
|
void CommandBufferBase::DestroyImpl() {
|
||||||
FreeCommands(&mCommands);
|
FreeCommands(&mCommands);
|
||||||
mResourceUsages = {};
|
mResourceUsages = {};
|
||||||
mDestroyed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CommandBufferResourceUsage& CommandBufferBase::GetResourceUsages() const {
|
const CommandBufferResourceUsage& CommandBufferBase::GetResourceUsages() const {
|
||||||
|
|
|
@ -36,17 +36,18 @@ namespace dawn_native {
|
||||||
|
|
||||||
static CommandBufferBase* MakeError(DeviceBase* device);
|
static CommandBufferBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
|
void DestroyImpl() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
MaybeError ValidateCanUseInSubmitNow() const;
|
MaybeError ValidateCanUseInSubmitNow() const;
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
const CommandBufferResourceUsage& GetResourceUsages() const;
|
const CommandBufferResourceUsage& GetResourceUsages() const;
|
||||||
|
|
||||||
CommandIterator* GetCommandIteratorForTesting();
|
CommandIterator* GetCommandIteratorForTesting();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~CommandBufferBase() override;
|
// Constructor used only for mocking and testing.
|
||||||
|
CommandBufferBase(DeviceBase* device);
|
||||||
|
|
||||||
CommandIterator mCommands;
|
CommandIterator mCommands;
|
||||||
|
|
||||||
|
@ -54,7 +55,6 @@ namespace dawn_native {
|
||||||
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
|
|
||||||
CommandBufferResourceUsage mResourceUsages;
|
CommandBufferResourceUsage mResourceUsages;
|
||||||
bool mDestroyed = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
||||||
|
|
|
@ -60,8 +60,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
ComputePipelineBase::~ComputePipelineBase() = default;
|
ComputePipelineBase::~ComputePipelineBase() = default;
|
||||||
|
|
||||||
bool ComputePipelineBase::DestroyApiObject() {
|
bool ComputePipelineBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
||||||
GetDevice()->UncacheComputePipeline(this);
|
GetDevice()->UncacheComputePipeline(this);
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static ComputePipelineBase* MakeError(DeviceBase* device);
|
static ComputePipelineBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
// Functors necessary for the unordered_set<ComputePipelineBase*>-based cache.
|
// Functors necessary for the unordered_set<ComputePipelineBase*>-based cache.
|
||||||
|
|
|
@ -269,7 +269,8 @@ namespace dawn_native {
|
||||||
// TODO(dawn/628) Add types into the array as they are implemented.
|
// TODO(dawn/628) Add types into the array as they are implemented.
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static constexpr std::array<ObjectType, 13> kObjectTypeDependencyOrder = {
|
static constexpr std::array<ObjectType, 14> kObjectTypeDependencyOrder = {
|
||||||
|
ObjectType::CommandBuffer,
|
||||||
ObjectType::RenderPipeline,
|
ObjectType::RenderPipeline,
|
||||||
ObjectType::ComputePipeline,
|
ObjectType::ComputePipeline,
|
||||||
ObjectType::PipelineLayout,
|
ObjectType::PipelineLayout,
|
||||||
|
@ -296,7 +297,7 @@ namespace dawn_native {
|
||||||
objList.objects.MoveInto(&objects);
|
objList.objects.MoveInto(&objects);
|
||||||
}
|
}
|
||||||
for (LinkNode<ApiObjectBase>* node : objects) {
|
for (LinkNode<ApiObjectBase>* node : objects) {
|
||||||
node->value()->DestroyApiObject();
|
node->value()->Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,12 @@ namespace dawn_native {
|
||||||
if (GetDevice()->ConsumedError(GetDevice()->ValidateObject(this))) {
|
if (GetDevice()->ConsumedError(GetDevice()->ValidateObject(this))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalTextureBase::DestroyApiObject() {
|
bool ExternalTextureBase::Destroy() {
|
||||||
mState = ExternalTextureState::Destroyed;
|
mState = ExternalTextureState::Destroyed;
|
||||||
return ApiObjectBase::DestroyApiObject();
|
return ApiObjectBase::Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static ExternalTextureBase* MakeError(DeviceBase* device);
|
static ExternalTextureBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
void APIDestroy();
|
void APIDestroy();
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiObjectBase::DeleteThis() {
|
void ApiObjectBase::DeleteThis() {
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
RefCounted::DeleteThis();
|
RefCounted::DeleteThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ namespace dawn_native {
|
||||||
return RemoveFromList();
|
return RemoveFromList();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApiObjectBase::DestroyApiObject() {
|
bool ApiObjectBase::Destroy() {
|
||||||
bool marked = MarkDestroyed();
|
bool marked = MarkDestroyed();
|
||||||
if (marked) {
|
if (marked) {
|
||||||
DestroyApiObjectImpl();
|
DestroyImpl();
|
||||||
}
|
}
|
||||||
return marked;
|
return marked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiObjectBase::DestroyApiObjectImpl() {
|
void ApiObjectBase::DestroyImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -65,17 +65,17 @@ namespace dawn_native {
|
||||||
// class's implementation in the override. This needs to be public because it can be called
|
// class's implementation in the override. This needs to be public because it can be called
|
||||||
// from the device owning the object. Returns true iff destruction occurs. Upon any re-calls
|
// from the device owning the object. Returns true iff destruction occurs. Upon any re-calls
|
||||||
// of the function it will return false to indicate no further operations should be taken.
|
// of the function it will return false to indicate no further operations should be taken.
|
||||||
virtual bool DestroyApiObject();
|
virtual bool Destroy();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void APISetLabel(const char* label);
|
void APISetLabel(const char* label);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overriding of the RefCounted's DeleteThis function ensures that instances of objects
|
// Overriding of the RefCounted's DeleteThis function ensures that instances of objects
|
||||||
// always call their derived class implementation of DestroyApiObject prior to the derived
|
// always call their derived class implementation of Destroy prior to the derived
|
||||||
// class being destroyed. This guarantees that when ApiObjects' reference counts drop to 0,
|
// class being destroyed. This guarantees that when ApiObjects' reference counts drop to 0,
|
||||||
// then the underlying backend's Destroy calls are executed. We cannot naively put the call
|
// then the underlying backend's Destroy calls are executed. We cannot naively put the call
|
||||||
// to DestroyApiObject in the destructor of this class because it calls DestroyApiObjectImpl
|
// to Destroy in the destructor of this class because it calls DestroyImpl
|
||||||
// which is a virtual function often implemented in the Derived class which would already
|
// which is a virtual function often implemented in the Derived class which would already
|
||||||
// have been destroyed by the time ApiObject's destructor is called by C++'s destruction
|
// have been destroyed by the time ApiObject's destructor is called by C++'s destruction
|
||||||
// order. Note that some classes like BindGroup may override the DeleteThis function again,
|
// order. Note that some classes like BindGroup may override the DeleteThis function again,
|
||||||
|
@ -89,7 +89,7 @@ namespace dawn_native {
|
||||||
// pre-destruction steps that need to occur only once, i.e. Buffer needs to be unmapped
|
// pre-destruction steps that need to occur only once, i.e. Buffer needs to be unmapped
|
||||||
// before being destroyed.
|
// before being destroyed.
|
||||||
bool MarkDestroyed();
|
bool MarkDestroyed();
|
||||||
virtual void DestroyApiObjectImpl();
|
virtual void DestroyImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void SetLabelImpl();
|
virtual void SetLabelImpl();
|
||||||
|
|
|
@ -85,8 +85,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
PipelineLayoutBase::~PipelineLayoutBase() = default;
|
PipelineLayoutBase::~PipelineLayoutBase() = default;
|
||||||
|
|
||||||
bool PipelineLayoutBase::DestroyApiObject() {
|
bool PipelineLayoutBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint
|
// Do not uncache the actual cached object if we are a blueprint
|
||||||
GetDevice()->UncachePipelineLayout(this);
|
GetDevice()->UncachePipelineLayout(this);
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace dawn_native {
|
||||||
DeviceBase* device,
|
DeviceBase* device,
|
||||||
std::vector<StageAndDescriptor> stages);
|
std::vector<StageAndDescriptor> stages);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
const BindGroupLayoutBase* GetBindGroupLayout(BindGroupIndex group) const;
|
const BindGroupLayoutBase* GetBindGroupLayout(BindGroupIndex group) const;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DestroyApiObjectImpl() override {
|
void DestroyImpl() override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -126,9 +126,9 @@ namespace dawn_native {
|
||||||
ASSERT(mState == QuerySetState::Unavailable || mState == QuerySetState::Destroyed);
|
ASSERT(mState == QuerySetState::Unavailable || mState == QuerySetState::Destroyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuerySetBase::DestroyApiObject() {
|
bool QuerySetBase::Destroy() {
|
||||||
mState = QuerySetState::Destroyed;
|
mState = QuerySetState::Destroyed;
|
||||||
return ApiObjectBase::DestroyApiObject();
|
return ApiObjectBase::Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -170,7 +170,7 @@ namespace dawn_native {
|
||||||
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError QuerySetBase::ValidateDestroy() const {
|
MaybeError QuerySetBase::ValidateDestroy() const {
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static QuerySetBase* MakeError(DeviceBase* device);
|
static QuerySetBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
wgpu::QueryType GetQueryType() const;
|
wgpu::QueryType GetQueryType() const;
|
||||||
|
|
|
@ -683,8 +683,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
RenderPipelineBase::~RenderPipelineBase() = default;
|
RenderPipelineBase::~RenderPipelineBase() = default;
|
||||||
|
|
||||||
bool RenderPipelineBase::DestroyApiObject() {
|
bool RenderPipelineBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
||||||
GetDevice()->UncacheRenderPipeline(this);
|
GetDevice()->UncacheRenderPipeline(this);
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static RenderPipelineBase* MakeError(DeviceBase* device);
|
static RenderPipelineBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
const ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>&
|
const ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>&
|
||||||
|
|
|
@ -100,8 +100,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
SamplerBase::~SamplerBase() = default;
|
SamplerBase::~SamplerBase() = default;
|
||||||
|
|
||||||
bool SamplerBase::DestroyApiObject() {
|
bool SamplerBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
||||||
GetDevice()->UncacheSampler(this);
|
GetDevice()->UncacheSampler(this);
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static SamplerBase* MakeError(DeviceBase* device);
|
static SamplerBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
bool IsComparison() const;
|
bool IsComparison() const;
|
||||||
|
|
|
@ -1204,8 +1204,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
ShaderModuleBase::~ShaderModuleBase() = default;
|
ShaderModuleBase::~ShaderModuleBase() = default;
|
||||||
|
|
||||||
bool ShaderModuleBase::DestroyApiObject() {
|
bool ShaderModuleBase::Destroy() {
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
if (wasDestroyed && IsCachedReference()) {
|
if (wasDestroyed && IsCachedReference()) {
|
||||||
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
// Do not uncache the actual cached object if we are a blueprint or already destroyed.
|
||||||
GetDevice()->UncacheShaderModule(this);
|
GetDevice()->UncacheShaderModule(this);
|
||||||
|
|
|
@ -248,7 +248,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static Ref<ShaderModuleBase> MakeError(DeviceBase* device);
|
static Ref<ShaderModuleBase> MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
// Return true iff the program has an entrypoint called `entryPoint`.
|
// Return true iff the program has an entrypoint called `entryPoint`.
|
||||||
|
|
|
@ -483,12 +483,12 @@ namespace dawn_native {
|
||||||
: ApiObjectBase(device, tag), mFormat(kUnusedFormat) {
|
: ApiObjectBase(device, tag), mFormat(kUnusedFormat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureBase::DestroyApiObject() {
|
bool TextureBase::Destroy() {
|
||||||
// We need to run the destroy operations prior to setting the state to destroyed so that
|
// We need to run the destroy operations prior to setting the state to destroyed so that
|
||||||
// the state is both consistent, and implementations of the destroy that may check the
|
// the state is both consistent, and implementations of the destroy that may check the
|
||||||
// state do not skip operations unintentionally. (Example in Vulkan backend, the destroy
|
// state do not skip operations unintentionally. (Example in Vulkan backend, the destroy
|
||||||
// implementation will not be ran if we are already in the Destroyed state.)
|
// implementation will not be ran if we are already in the Destroyed state.)
|
||||||
bool wasDestroyed = ApiObjectBase::DestroyApiObject();
|
bool wasDestroyed = ApiObjectBase::Destroy();
|
||||||
mState = TextureState::Destroyed;
|
mState = TextureState::Destroyed;
|
||||||
return wasDestroyed;
|
return wasDestroyed;
|
||||||
}
|
}
|
||||||
|
@ -686,7 +686,7 @@ namespace dawn_native {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError TextureBase::ValidateDestroy() const {
|
MaybeError TextureBase::ValidateDestroy() const {
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
static TextureBase* MakeError(DeviceBase* device);
|
static TextureBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
bool DestroyApiObject() override;
|
bool Destroy() override;
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
wgpu::TextureDimension GetDimension() const;
|
wgpu::TextureDimension GetDimension() const;
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
BindGroup::~BindGroup() = default;
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
void BindGroup::DestroyApiObjectImpl() {
|
void BindGroup::DestroyImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this, &mCPUViewAllocation);
|
ToBackend(GetLayout())->DeallocateBindGroup(this, &mCPUViewAllocation);
|
||||||
ASSERT(!mCPUViewAllocation.IsValid());
|
ASSERT(!mCPUViewAllocation.IsValid());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry;
|
Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
return mMappedData;
|
return mMappedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::DestroyApiObjectImpl() {
|
void Buffer::DestroyImpl() {
|
||||||
// TODO(crbug.com/dawn/1189) Reintroduce optimization to skip flushing the writes to the GPU
|
// TODO(crbug.com/dawn/1189) Reintroduce optimization to skip flushing the writes to the GPU
|
||||||
// memory when we unmap in destruction case since the buffer will be destroyed anyways.
|
// memory when we unmap in destruction case since the buffer will be destroyed anyways.
|
||||||
ToBackend(GetDevice())->DeallocateMemory(mResourceAllocation);
|
ToBackend(GetDevice())->DeallocateMemory(mResourceAllocation);
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
MaybeError Initialize(bool mappedAtCreation);
|
MaybeError Initialize(bool mappedAtCreation);
|
||||||
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
bool IsCPUWritableAtCreation() const override;
|
bool IsCPUWritableAtCreation() const override;
|
||||||
virtual MaybeError MapAtCreationImpl() override;
|
virtual MaybeError MapAtCreationImpl() override;
|
||||||
void* GetMappedPointerImpl() override;
|
void* GetMappedPointerImpl() override;
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() = default;
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
void ComputePipeline::DestroyApiObjectImpl() {
|
void ComputePipeline::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
ComPtr<ID3D12PipelineState> mPipelineState;
|
ComPtr<ID3D12PipelineState> mPipelineState;
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
QuerySet::~QuerySet() = default;
|
QuerySet::~QuerySet() = default;
|
||||||
|
|
||||||
void QuerySet::DestroyApiObjectImpl() {
|
void QuerySet::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->ReferenceUntilUnused(mQueryHeap);
|
ToBackend(GetDevice())->ReferenceUntilUnused(mQueryHeap);
|
||||||
mQueryHeap = nullptr;
|
mQueryHeap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
ComPtr<ID3D12QueryHeap> mQueryHeap;
|
ComPtr<ID3D12QueryHeap> mQueryHeap;
|
||||||
};
|
};
|
||||||
|
|
|
@ -419,7 +419,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() = default;
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
void RenderPipeline::DestroyApiObjectImpl() {
|
void RenderPipeline::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
||||||
|
|
|
@ -143,7 +143,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
SwapChain::~SwapChain() = default;
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
void SwapChain::DestroyApiObjectImpl() {
|
void SwapChain::DestroyImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
|
|
|
@ -649,7 +649,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
Texture::~Texture() {
|
Texture::~Texture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::DestroyApiObjectImpl() {
|
void Texture::DestroyImpl() {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
// In PIX's D3D12-only mode, there is no way to determine frame boundaries
|
// In PIX's D3D12-only mode, there is no way to determine frame boundaries
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetLabelImpl() override;
|
void SetLabelImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
MaybeError ClearTexture(CommandRecordingContext* commandContext,
|
MaybeError ClearTexture(CommandRecordingContext* commandContext,
|
||||||
const SubresourceRange& range,
|
const SubresourceRange& range,
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_native { namespace metal {
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::metal
|
}} // namespace dawn_native::metal
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
BindGroup::~BindGroup() = default;
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
void BindGroup::DestroyApiObjectImpl() {
|
void BindGroup::DestroyImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace dawn_native { namespace metal {
|
||||||
~Buffer() override;
|
~Buffer() override;
|
||||||
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
void* GetMappedPointerImpl() override;
|
void* GetMappedPointerImpl() override;
|
||||||
bool IsCPUWritableAtCreation() const override;
|
bool IsCPUWritableAtCreation() const override;
|
||||||
MaybeError MapAtCreationImpl() override;
|
MaybeError MapAtCreationImpl() override;
|
||||||
|
|
|
@ -171,7 +171,7 @@ namespace dawn_native { namespace metal {
|
||||||
// Nothing to do, Metal StorageModeShared buffers are always mapped.
|
// Nothing to do, Metal StorageModeShared buffers are always mapped.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::DestroyApiObjectImpl() {
|
void Buffer::DestroyImpl() {
|
||||||
mMtlBuffer = nullptr;
|
mMtlBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace dawn_native { namespace metal {
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
NSPRef<id<MTLBuffer>> mVisibilityBuffer;
|
NSPRef<id<MTLBuffer>> mVisibilityBuffer;
|
||||||
// Note that mCounterSampleBuffer cannot be an NSRef because the API_AVAILABLE macros don't
|
// Note that mCounterSampleBuffer cannot be an NSRef because the API_AVAILABLE macros don't
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
QuerySet::~QuerySet() = default;
|
QuerySet::~QuerySet() = default;
|
||||||
|
|
||||||
void QuerySet::DestroyApiObjectImpl() {
|
void QuerySet::DestroyImpl() {
|
||||||
mVisibilityBuffer = nullptr;
|
mVisibilityBuffer = nullptr;
|
||||||
|
|
||||||
// mCounterSampleBuffer isn't an NSRef because API_AVAILABLE doesn't work will with
|
// mCounterSampleBuffer isn't an NSRef because API_AVAILABLE doesn't work will with
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
|
||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
SwapChain::~SwapChain() = default;
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
void SwapChain::DestroyApiObjectImpl() {
|
void SwapChain::DestroyImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace dawn_native { namespace metal {
|
||||||
void InitializeAsWrapping(const TextureDescriptor* descriptor,
|
void InitializeAsWrapping(const TextureDescriptor* descriptor,
|
||||||
NSPRef<id<MTLTexture>> wrapped);
|
NSPRef<id<MTLTexture>> wrapped);
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
MaybeError ClearTexture(CommandRecordingContext* commandContext,
|
MaybeError ClearTexture(CommandRecordingContext* commandContext,
|
||||||
const SubresourceRange& range,
|
const SubresourceRange& range,
|
||||||
|
|
|
@ -495,7 +495,7 @@ namespace dawn_native { namespace metal {
|
||||||
Texture::~Texture() {
|
Texture::~Texture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::DestroyApiObjectImpl() {
|
void Texture::DestroyImpl() {
|
||||||
mMtlTexture = nullptr;
|
mMtlTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ namespace dawn_native { namespace null {
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::DestroyApiObjectImpl() {
|
void Buffer::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->DecrementMemoryUsage(GetSize());
|
ToBackend(GetDevice())->DecrementMemoryUsage(GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ namespace dawn_native { namespace null {
|
||||||
: QuerySetBase(device, descriptor) {
|
: QuerySetBase(device, descriptor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuerySet::DestroyApiObjectImpl() {
|
void QuerySet::DestroyImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue
|
// Queue
|
||||||
|
|
|
@ -228,7 +228,7 @@ namespace dawn_native { namespace null {
|
||||||
private:
|
private:
|
||||||
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
bool IsCPUWritableAtCreation() const override;
|
bool IsCPUWritableAtCreation() const override;
|
||||||
MaybeError MapAtCreationImpl() override;
|
MaybeError MapAtCreationImpl() override;
|
||||||
void* GetMappedPointerImpl() override;
|
void* GetMappedPointerImpl() override;
|
||||||
|
@ -246,7 +246,7 @@ namespace dawn_native { namespace null {
|
||||||
QuerySet(Device* device, const QuerySetDescriptor* descriptor);
|
QuerySet(Device* device, const QuerySetDescriptor* descriptor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Queue final : public QueueBase {
|
class Queue final : public QueueBase {
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
BindGroup::~BindGroup() = default;
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
void BindGroup::DestroyApiObjectImpl() {
|
void BindGroup::DestroyImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
|
@ -174,7 +174,7 @@ namespace dawn_native { namespace opengl {
|
||||||
mMappedData = nullptr;
|
mMappedData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::DestroyApiObjectImpl() {
|
void Buffer::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->gl.DeleteBuffers(1, &mBuffer);
|
ToBackend(GetDevice())->gl.DeleteBuffers(1, &mBuffer);
|
||||||
mBuffer = 0;
|
mBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native { namespace opengl {
|
||||||
~Buffer() override;
|
~Buffer() override;
|
||||||
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
bool IsCPUWritableAtCreation() const override;
|
bool IsCPUWritableAtCreation() const override;
|
||||||
MaybeError MapAtCreationImpl() override;
|
MaybeError MapAtCreationImpl() override;
|
||||||
void* GetMappedPointerImpl() override;
|
void* GetMappedPointerImpl() override;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() = default;
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
void ComputePipeline::DestroyApiObjectImpl() {
|
void ComputePipeline::DestroyImpl() {
|
||||||
DeleteProgram(ToBackend(GetDevice())->gl);
|
DeleteProgram(ToBackend(GetDevice())->gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
QuerySet::~QuerySet() = default;
|
QuerySet::~QuerySet() = default;
|
||||||
|
|
||||||
void QuerySet::DestroyApiObjectImpl() {
|
void QuerySet::DestroyImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
~QuerySet() override;
|
~QuerySet() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
|
@ -236,7 +236,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() = default;
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
void RenderPipeline::DestroyApiObjectImpl() {
|
void RenderPipeline::DestroyImpl() {
|
||||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
gl.DeleteVertexArrays(1, &mVertexArrayObject);
|
gl.DeleteVertexArrays(1, &mVertexArrayObject);
|
||||||
gl.BindVertexArray(0);
|
gl.BindVertexArray(0);
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor);
|
RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor);
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
void CreateVAOForVertexState();
|
void CreateVAOForVertexState();
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
Sampler::~Sampler() = default;
|
Sampler::~Sampler() = default;
|
||||||
|
|
||||||
void Sampler::DestroyApiObjectImpl() {
|
void Sampler::DestroyImpl() {
|
||||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
gl.DeleteSamplers(1, &mFilteringHandle);
|
gl.DeleteSamplers(1, &mFilteringHandle);
|
||||||
gl.DeleteSamplers(1, &mNonFilteringHandle);
|
gl.DeleteSamplers(1, &mNonFilteringHandle);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~Sampler() override;
|
~Sampler() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
void SetupGLSampler(GLuint sampler, const SamplerDescriptor* descriptor, bool forceNearest);
|
void SetupGLSampler(GLuint sampler, const SamplerDescriptor* descriptor, bool forceNearest);
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace dawn_native { namespace opengl {
|
||||||
Texture::~Texture() {
|
Texture::~Texture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::DestroyApiObjectImpl() {
|
void Texture::DestroyImpl() {
|
||||||
if (GetTextureState() == TextureState::OwnedInternal) {
|
if (GetTextureState() == TextureState::OwnedInternal) {
|
||||||
ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
|
ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
|
||||||
mHandle = 0;
|
mHandle = 0;
|
||||||
|
@ -560,7 +560,7 @@ namespace dawn_native { namespace opengl {
|
||||||
TextureView::~TextureView() {
|
TextureView::~TextureView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureView::DestroyApiObjectImpl() {
|
void TextureView::DestroyImpl() {
|
||||||
if (mOwnsHandle) {
|
if (mOwnsHandle) {
|
||||||
ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
|
ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
~Texture() override;
|
~Texture() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
MaybeError ClearTexture(const SubresourceRange& range, TextureBase::ClearValue clearValue);
|
MaybeError ClearTexture(const SubresourceRange& range, TextureBase::ClearValue clearValue);
|
||||||
|
|
||||||
GLuint mHandle;
|
GLuint mHandle;
|
||||||
|
@ -57,7 +57,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~TextureView() override;
|
~TextureView() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
GLuint mHandle;
|
GLuint mHandle;
|
||||||
GLenum mTarget;
|
GLenum mTarget;
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
BindGroup::~BindGroup() = default;
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
void BindGroup::DestroyApiObjectImpl() {
|
void BindGroup::DestroyImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this, &mDescriptorSetAllocation);
|
ToBackend(GetLayout())->DeallocateBindGroup(this, &mDescriptorSetAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
||||||
// the BindGroupLayout which is referenced by the BindGroup.
|
// the BindGroupLayout which is referenced by the BindGroup.
|
||||||
|
|
|
@ -329,7 +329,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::DestroyApiObjectImpl() {
|
void Buffer::DestroyImpl() {
|
||||||
ToBackend(GetDevice())->GetResourceMemoryAllocator()->Deallocate(&mMemoryAllocation);
|
ToBackend(GetDevice())->GetResourceMemoryAllocator()->Deallocate(&mMemoryAllocation);
|
||||||
|
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
bool IsCPUWritableAtCreation() const override;
|
bool IsCPUWritableAtCreation() const override;
|
||||||
MaybeError MapAtCreationImpl() override;
|
MaybeError MapAtCreationImpl() override;
|
||||||
void* GetMappedPointerImpl() override;
|
void* GetMappedPointerImpl() override;
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() = default;
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
void ComputePipeline::DestroyApiObjectImpl() {
|
void ComputePipeline::DestroyImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
|
|
||||||
VkPipeline mHandle = VK_NULL_HANDLE;
|
VkPipeline mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
PipelineLayout::~PipelineLayout() = default;
|
PipelineLayout::~PipelineLayout() = default;
|
||||||
|
|
||||||
void PipelineLayout::DestroyApiObjectImpl() {
|
void PipelineLayout::DestroyImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~PipelineLayout() override;
|
~PipelineLayout() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using PipelineLayoutBase::PipelineLayoutBase;
|
using PipelineLayoutBase::PipelineLayoutBase;
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
QuerySet::~QuerySet() = default;
|
QuerySet::~QuerySet() = default;
|
||||||
|
|
||||||
void QuerySet::DestroyApiObjectImpl() {
|
void QuerySet::DestroyImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
using QuerySetBase::QuerySetBase;
|
using QuerySetBase::QuerySetBase;
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
VkQueryPool mHandle = VK_NULL_HANDLE;
|
VkQueryPool mHandle = VK_NULL_HANDLE;
|
||||||
};
|
};
|
||||||
|
|
|
@ -601,7 +601,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() = default;
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
void RenderPipeline::DestroyApiObjectImpl() {
|
void RenderPipeline::DestroyImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
|
|
||||||
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
Sampler::~Sampler() = default;
|
Sampler::~Sampler() = default;
|
||||||
|
|
||||||
void Sampler::DestroyApiObjectImpl() {
|
void Sampler::DestroyImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~Sampler() override;
|
~Sampler() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
using SamplerBase::SamplerBase;
|
using SamplerBase::SamplerBase;
|
||||||
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
SwapChain::~SwapChain() = default;
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
void SwapChain::DestroyApiObjectImpl() {
|
void SwapChain::DestroyImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
private:
|
private:
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
// Information that's passed to vulkan swapchain creation.
|
// Information that's passed to vulkan swapchain creation.
|
||||||
|
|
|
@ -792,7 +792,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
mSignalSemaphore = VK_NULL_HANDLE;
|
mSignalSemaphore = VK_NULL_HANDLE;
|
||||||
|
|
||||||
// Destroy the texture so it can't be used again
|
// Destroy the texture so it can't be used again
|
||||||
DestroyApiObject();
|
Destroy();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
SetLabelHelper("Dawn_InternalTexture");
|
SetLabelHelper("Dawn_InternalTexture");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::DestroyApiObjectImpl() {
|
void Texture::DestroyImpl() {
|
||||||
if (GetTextureState() == TextureState::OwnedInternal) {
|
if (GetTextureState() == TextureState::OwnedInternal) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
|
@ -1301,7 +1301,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
TextureView::~TextureView() {
|
TextureView::~TextureView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureView::DestroyApiObjectImpl() {
|
void TextureView::DestroyImpl() {
|
||||||
Device* device = ToBackend(GetTexture()->GetDevice());
|
Device* device = ToBackend(GetTexture()->GetDevice());
|
||||||
|
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
external_memory::Service* externalMemoryService);
|
external_memory::Service* externalMemoryService);
|
||||||
void InitializeForSwapChain(VkImage nativeImage);
|
void InitializeForSwapChain(VkImage nativeImage);
|
||||||
|
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
MaybeError ClearTexture(CommandRecordingContext* recordingContext,
|
MaybeError ClearTexture(CommandRecordingContext* recordingContext,
|
||||||
const SubresourceRange& range,
|
const SubresourceRange& range,
|
||||||
TextureBase::ClearValue);
|
TextureBase::ClearValue);
|
||||||
|
@ -176,7 +176,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~TextureView() override;
|
~TextureView() override;
|
||||||
void DestroyApiObjectImpl() override;
|
void DestroyImpl() override;
|
||||||
using TextureViewBase::TextureViewBase;
|
using TextureViewBase::TextureViewBase;
|
||||||
MaybeError Initialize(const TextureViewDescriptor* descriptor);
|
MaybeError Initialize(const TextureViewDescriptor* descriptor);
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ source_set("dawn_native_mocks_sources") {
|
||||||
sources = [
|
sources = [
|
||||||
"unittests/native/mocks/BindGroupLayoutMock.h",
|
"unittests/native/mocks/BindGroupLayoutMock.h",
|
||||||
"unittests/native/mocks/BindGroupMock.h",
|
"unittests/native/mocks/BindGroupMock.h",
|
||||||
|
"unittests/native/mocks/CommandBufferMock.h",
|
||||||
"unittests/native/mocks/ComputePipelineMock.h",
|
"unittests/native/mocks/ComputePipelineMock.h",
|
||||||
"unittests/native/mocks/DeviceMock.h",
|
"unittests/native/mocks/DeviceMock.h",
|
||||||
"unittests/native/mocks/ExternalTextureMock.h",
|
"unittests/native/mocks/ExternalTextureMock.h",
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "mocks/BindGroupLayoutMock.h"
|
#include "mocks/BindGroupLayoutMock.h"
|
||||||
#include "mocks/BindGroupMock.h"
|
#include "mocks/BindGroupMock.h"
|
||||||
#include "mocks/BufferMock.h"
|
#include "mocks/BufferMock.h"
|
||||||
|
#include "mocks/CommandBufferMock.h"
|
||||||
#include "mocks/ComputePipelineMock.h"
|
#include "mocks/ComputePipelineMock.h"
|
||||||
#include "mocks/DeviceMock.h"
|
#include "mocks/DeviceMock.h"
|
||||||
#include "mocks/ExternalTextureMock.h"
|
#include "mocks/ExternalTextureMock.h"
|
||||||
|
@ -52,7 +53,7 @@ namespace dawn_native { namespace {
|
||||||
}
|
}
|
||||||
mTexture =
|
mTexture =
|
||||||
AcquireRef(new TextureMock(&mDevice, TextureBase::TextureState::OwnedInternal));
|
AcquireRef(new TextureMock(&mDevice, TextureBase::TextureState::OwnedInternal));
|
||||||
EXPECT_CALL(*mTexture.Get(), DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*mTexture.Get(), DestroyImpl).Times(1);
|
||||||
return mTexture;
|
return mTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ namespace dawn_native { namespace {
|
||||||
return mPipelineLayout;
|
return mPipelineLayout;
|
||||||
}
|
}
|
||||||
mPipelineLayout = AcquireRef(new PipelineLayoutMock(&mDevice));
|
mPipelineLayout = AcquireRef(new PipelineLayoutMock(&mDevice));
|
||||||
EXPECT_CALL(*mPipelineLayout.Get(), DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*mPipelineLayout.Get(), DestroyImpl).Times(1);
|
||||||
return mPipelineLayout;
|
return mPipelineLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ namespace dawn_native { namespace {
|
||||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||||
})"),
|
})"),
|
||||||
{ ASSERT(false); }, mVsModule);
|
{ ASSERT(false); }, mVsModule);
|
||||||
EXPECT_CALL(*mVsModule.Get(), DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*mVsModule.Get(), DestroyImpl).Times(1);
|
||||||
return mVsModule;
|
return mVsModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ namespace dawn_native { namespace {
|
||||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||||
})"),
|
})"),
|
||||||
{ ASSERT(false); }, mCsModule);
|
{ ASSERT(false); }, mCsModule);
|
||||||
EXPECT_CALL(*mCsModule.Get(), DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*mCsModule.Get(), DestroyImpl).Times(1);
|
||||||
return mCsModule;
|
return mCsModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,10 +106,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, BindGroupExplicit) {
|
TEST_F(DestroyObjectTests, BindGroupExplicit) {
|
||||||
BindGroupMock bindGroupMock(&mDevice);
|
BindGroupMock bindGroupMock(&mDevice);
|
||||||
EXPECT_CALL(bindGroupMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(bindGroupMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(bindGroupMock.IsAlive());
|
EXPECT_TRUE(bindGroupMock.IsAlive());
|
||||||
bindGroupMock.DestroyApiObject();
|
bindGroupMock.Destroy();
|
||||||
EXPECT_FALSE(bindGroupMock.IsAlive());
|
EXPECT_FALSE(bindGroupMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, BindGroupImplicit) {
|
TEST_F(DestroyObjectTests, BindGroupImplicit) {
|
||||||
BindGroupMock* bindGroupMock = new BindGroupMock(&mDevice);
|
BindGroupMock* bindGroupMock = new BindGroupMock(&mDevice);
|
||||||
EXPECT_CALL(*bindGroupMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bindGroupMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
BindGroupDescriptor desc = {};
|
BindGroupDescriptor desc = {};
|
||||||
Ref<BindGroupBase> bindGroup;
|
Ref<BindGroupBase> bindGroup;
|
||||||
|
@ -130,10 +131,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, BindGroupLayoutExplicit) {
|
TEST_F(DestroyObjectTests, BindGroupLayoutExplicit) {
|
||||||
BindGroupLayoutMock bindGroupLayoutMock(&mDevice);
|
BindGroupLayoutMock bindGroupLayoutMock(&mDevice);
|
||||||
EXPECT_CALL(bindGroupLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(bindGroupLayoutMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(bindGroupLayoutMock.IsAlive());
|
EXPECT_TRUE(bindGroupLayoutMock.IsAlive());
|
||||||
bindGroupLayoutMock.DestroyApiObject();
|
bindGroupLayoutMock.Destroy();
|
||||||
EXPECT_FALSE(bindGroupLayoutMock.IsAlive());
|
EXPECT_FALSE(bindGroupLayoutMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, BindGroupLayoutImplicit) {
|
TEST_F(DestroyObjectTests, BindGroupLayoutImplicit) {
|
||||||
BindGroupLayoutMock* bindGroupLayoutMock = new BindGroupLayoutMock(&mDevice);
|
BindGroupLayoutMock* bindGroupLayoutMock = new BindGroupLayoutMock(&mDevice);
|
||||||
EXPECT_CALL(*bindGroupLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bindGroupLayoutMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
BindGroupLayoutDescriptor desc = {};
|
BindGroupLayoutDescriptor desc = {};
|
||||||
Ref<BindGroupLayoutBase> bindGroupLayout;
|
Ref<BindGroupLayoutBase> bindGroupLayout;
|
||||||
|
@ -157,10 +158,10 @@ namespace dawn_native { namespace {
|
||||||
TEST_F(DestroyObjectTests, BufferExplicit) {
|
TEST_F(DestroyObjectTests, BufferExplicit) {
|
||||||
{
|
{
|
||||||
BufferMock bufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
BufferMock bufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
||||||
EXPECT_CALL(bufferMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(bufferMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(bufferMock.IsAlive());
|
EXPECT_TRUE(bufferMock.IsAlive());
|
||||||
bufferMock.DestroyApiObject();
|
bufferMock.Destroy();
|
||||||
EXPECT_FALSE(bufferMock.IsAlive());
|
EXPECT_FALSE(bufferMock.IsAlive());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -168,11 +169,11 @@ namespace dawn_native { namespace {
|
||||||
{
|
{
|
||||||
InSequence seq;
|
InSequence seq;
|
||||||
EXPECT_CALL(bufferMock, UnmapImpl).Times(1);
|
EXPECT_CALL(bufferMock, UnmapImpl).Times(1);
|
||||||
EXPECT_CALL(bufferMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(bufferMock, DestroyImpl).Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(bufferMock.IsAlive());
|
EXPECT_TRUE(bufferMock.IsAlive());
|
||||||
bufferMock.DestroyApiObject();
|
bufferMock.Destroy();
|
||||||
EXPECT_FALSE(bufferMock.IsAlive());
|
EXPECT_FALSE(bufferMock.IsAlive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ namespace dawn_native { namespace {
|
||||||
TEST_F(DestroyObjectTests, BufferImplicit) {
|
TEST_F(DestroyObjectTests, BufferImplicit) {
|
||||||
{
|
{
|
||||||
BufferMock* bufferMock = new BufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
BufferMock* bufferMock = new BufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
||||||
EXPECT_CALL(*bufferMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bufferMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
BufferDescriptor desc = {};
|
BufferDescriptor desc = {};
|
||||||
Ref<BufferBase> buffer;
|
Ref<BufferBase> buffer;
|
||||||
|
@ -198,7 +199,7 @@ namespace dawn_native { namespace {
|
||||||
{
|
{
|
||||||
InSequence seq;
|
InSequence seq;
|
||||||
EXPECT_CALL(*bufferMock, UnmapImpl).Times(1);
|
EXPECT_CALL(*bufferMock, UnmapImpl).Times(1);
|
||||||
EXPECT_CALL(*bufferMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bufferMock, DestroyImpl).Times(1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
BufferDescriptor desc = {};
|
BufferDescriptor desc = {};
|
||||||
|
@ -212,12 +213,37 @@ namespace dawn_native { namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DestroyObjectTests, CommandBufferExplicit) {
|
||||||
|
CommandBufferMock commandBufferMock(&mDevice);
|
||||||
|
EXPECT_CALL(commandBufferMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
|
EXPECT_TRUE(commandBufferMock.IsAlive());
|
||||||
|
commandBufferMock.Destroy();
|
||||||
|
EXPECT_FALSE(commandBufferMock.IsAlive());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the reference count on API objects reach 0, they should delete themselves. Note that GTest
|
||||||
|
// will also complain if there is a memory leak.
|
||||||
|
TEST_F(DestroyObjectTests, CommandBufferImplicit) {
|
||||||
|
CommandBufferMock* commandBufferMock = new CommandBufferMock(&mDevice);
|
||||||
|
EXPECT_CALL(*commandBufferMock, DestroyImpl).Times(1);
|
||||||
|
{
|
||||||
|
CommandBufferDescriptor desc = {};
|
||||||
|
Ref<CommandBufferBase> commandBuffer;
|
||||||
|
EXPECT_CALL(mDevice, CreateCommandBuffer)
|
||||||
|
.WillOnce(Return(ByMove(AcquireRef(commandBufferMock))));
|
||||||
|
DAWN_ASSERT_AND_ASSIGN(commandBuffer, mDevice.CreateCommandBuffer(nullptr, &desc));
|
||||||
|
|
||||||
|
EXPECT_TRUE(commandBuffer->IsAlive());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, ComputePipelineExplicit) {
|
TEST_F(DestroyObjectTests, ComputePipelineExplicit) {
|
||||||
ComputePipelineMock computePipelineMock(&mDevice);
|
ComputePipelineMock computePipelineMock(&mDevice);
|
||||||
EXPECT_CALL(computePipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(computePipelineMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(computePipelineMock.IsAlive());
|
EXPECT_TRUE(computePipelineMock.IsAlive());
|
||||||
computePipelineMock.DestroyApiObject();
|
computePipelineMock.Destroy();
|
||||||
EXPECT_FALSE(computePipelineMock.IsAlive());
|
EXPECT_FALSE(computePipelineMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +259,7 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
// Compute pipelines are initialized during their creation via the device.
|
// Compute pipelines are initialized during their creation via the device.
|
||||||
EXPECT_CALL(*computePipelineMock, Initialize).Times(1);
|
EXPECT_CALL(*computePipelineMock, Initialize).Times(1);
|
||||||
EXPECT_CALL(*computePipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*computePipelineMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
{
|
{
|
||||||
ComputePipelineDescriptor desc = {};
|
ComputePipelineDescriptor desc = {};
|
||||||
|
@ -252,10 +278,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, ExternalTextureExplicit) {
|
TEST_F(DestroyObjectTests, ExternalTextureExplicit) {
|
||||||
ExternalTextureMock externalTextureMock(&mDevice);
|
ExternalTextureMock externalTextureMock(&mDevice);
|
||||||
EXPECT_CALL(externalTextureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(externalTextureMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(externalTextureMock.IsAlive());
|
EXPECT_TRUE(externalTextureMock.IsAlive());
|
||||||
externalTextureMock.DestroyApiObject();
|
externalTextureMock.Destroy();
|
||||||
EXPECT_FALSE(externalTextureMock.IsAlive());
|
EXPECT_FALSE(externalTextureMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,10 +296,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, PipelineLayoutExplicit) {
|
TEST_F(DestroyObjectTests, PipelineLayoutExplicit) {
|
||||||
PipelineLayoutMock pipelineLayoutMock(&mDevice);
|
PipelineLayoutMock pipelineLayoutMock(&mDevice);
|
||||||
EXPECT_CALL(pipelineLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(pipelineLayoutMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(pipelineLayoutMock.IsAlive());
|
EXPECT_TRUE(pipelineLayoutMock.IsAlive());
|
||||||
pipelineLayoutMock.DestroyApiObject();
|
pipelineLayoutMock.Destroy();
|
||||||
EXPECT_FALSE(pipelineLayoutMock.IsAlive());
|
EXPECT_FALSE(pipelineLayoutMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +307,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, PipelineLayoutImplicit) {
|
TEST_F(DestroyObjectTests, PipelineLayoutImplicit) {
|
||||||
PipelineLayoutMock* pipelineLayoutMock = new PipelineLayoutMock(&mDevice);
|
PipelineLayoutMock* pipelineLayoutMock = new PipelineLayoutMock(&mDevice);
|
||||||
EXPECT_CALL(*pipelineLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*pipelineLayoutMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
PipelineLayoutDescriptor desc = {};
|
PipelineLayoutDescriptor desc = {};
|
||||||
Ref<PipelineLayoutBase> pipelineLayout;
|
Ref<PipelineLayoutBase> pipelineLayout;
|
||||||
|
@ -296,10 +322,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, QuerySetExplicit) {
|
TEST_F(DestroyObjectTests, QuerySetExplicit) {
|
||||||
QuerySetMock querySetMock(&mDevice);
|
QuerySetMock querySetMock(&mDevice);
|
||||||
EXPECT_CALL(querySetMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(querySetMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(querySetMock.IsAlive());
|
EXPECT_TRUE(querySetMock.IsAlive());
|
||||||
querySetMock.DestroyApiObject();
|
querySetMock.Destroy();
|
||||||
EXPECT_FALSE(querySetMock.IsAlive());
|
EXPECT_FALSE(querySetMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +333,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, QuerySetImplicit) {
|
TEST_F(DestroyObjectTests, QuerySetImplicit) {
|
||||||
QuerySetMock* querySetMock = new QuerySetMock(&mDevice);
|
QuerySetMock* querySetMock = new QuerySetMock(&mDevice);
|
||||||
EXPECT_CALL(*querySetMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*querySetMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
QuerySetDescriptor desc = {};
|
QuerySetDescriptor desc = {};
|
||||||
Ref<QuerySetBase> querySet;
|
Ref<QuerySetBase> querySet;
|
||||||
|
@ -321,10 +347,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, RenderPipelineExplicit) {
|
TEST_F(DestroyObjectTests, RenderPipelineExplicit) {
|
||||||
RenderPipelineMock renderPipelineMock(&mDevice);
|
RenderPipelineMock renderPipelineMock(&mDevice);
|
||||||
EXPECT_CALL(renderPipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(renderPipelineMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(renderPipelineMock.IsAlive());
|
EXPECT_TRUE(renderPipelineMock.IsAlive());
|
||||||
renderPipelineMock.DestroyApiObject();
|
renderPipelineMock.Destroy();
|
||||||
EXPECT_FALSE(renderPipelineMock.IsAlive());
|
EXPECT_FALSE(renderPipelineMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +366,7 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
// Render pipelines are initialized during their creation via the device.
|
// Render pipelines are initialized during their creation via the device.
|
||||||
EXPECT_CALL(*renderPipelineMock, Initialize).Times(1);
|
EXPECT_CALL(*renderPipelineMock, Initialize).Times(1);
|
||||||
EXPECT_CALL(*renderPipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*renderPipelineMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
{
|
{
|
||||||
RenderPipelineDescriptor desc = {};
|
RenderPipelineDescriptor desc = {};
|
||||||
|
@ -359,10 +385,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, SamplerExplicit) {
|
TEST_F(DestroyObjectTests, SamplerExplicit) {
|
||||||
SamplerMock samplerMock(&mDevice);
|
SamplerMock samplerMock(&mDevice);
|
||||||
EXPECT_CALL(samplerMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(samplerMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(samplerMock.IsAlive());
|
EXPECT_TRUE(samplerMock.IsAlive());
|
||||||
samplerMock.DestroyApiObject();
|
samplerMock.Destroy();
|
||||||
EXPECT_FALSE(samplerMock.IsAlive());
|
EXPECT_FALSE(samplerMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +396,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, SamplerImplicit) {
|
TEST_F(DestroyObjectTests, SamplerImplicit) {
|
||||||
SamplerMock* samplerMock = new SamplerMock(&mDevice);
|
SamplerMock* samplerMock = new SamplerMock(&mDevice);
|
||||||
EXPECT_CALL(*samplerMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*samplerMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
SamplerDescriptor desc = {};
|
SamplerDescriptor desc = {};
|
||||||
Ref<SamplerBase> sampler;
|
Ref<SamplerBase> sampler;
|
||||||
|
@ -385,10 +411,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, ShaderModuleExplicit) {
|
TEST_F(DestroyObjectTests, ShaderModuleExplicit) {
|
||||||
ShaderModuleMock shaderModuleMock(&mDevice);
|
ShaderModuleMock shaderModuleMock(&mDevice);
|
||||||
EXPECT_CALL(shaderModuleMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(shaderModuleMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(shaderModuleMock.IsAlive());
|
EXPECT_TRUE(shaderModuleMock.IsAlive());
|
||||||
shaderModuleMock.DestroyApiObject();
|
shaderModuleMock.Destroy();
|
||||||
EXPECT_FALSE(shaderModuleMock.IsAlive());
|
EXPECT_FALSE(shaderModuleMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +422,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, ShaderModuleImplicit) {
|
TEST_F(DestroyObjectTests, ShaderModuleImplicit) {
|
||||||
ShaderModuleMock* shaderModuleMock = new ShaderModuleMock(&mDevice);
|
ShaderModuleMock* shaderModuleMock = new ShaderModuleMock(&mDevice);
|
||||||
EXPECT_CALL(*shaderModuleMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*shaderModuleMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
ShaderModuleWGSLDescriptor wgslDesc;
|
ShaderModuleWGSLDescriptor wgslDesc;
|
||||||
wgslDesc.source = R"(
|
wgslDesc.source = R"(
|
||||||
|
@ -417,10 +443,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, SwapChainExplicit) {
|
TEST_F(DestroyObjectTests, SwapChainExplicit) {
|
||||||
SwapChainMock swapChainMock(&mDevice);
|
SwapChainMock swapChainMock(&mDevice);
|
||||||
EXPECT_CALL(swapChainMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(swapChainMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(swapChainMock.IsAlive());
|
EXPECT_TRUE(swapChainMock.IsAlive());
|
||||||
swapChainMock.DestroyApiObject();
|
swapChainMock.Destroy();
|
||||||
EXPECT_FALSE(swapChainMock.IsAlive());
|
EXPECT_FALSE(swapChainMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +454,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, SwapChainImplicit) {
|
TEST_F(DestroyObjectTests, SwapChainImplicit) {
|
||||||
SwapChainMock* swapChainMock = new SwapChainMock(&mDevice);
|
SwapChainMock* swapChainMock = new SwapChainMock(&mDevice);
|
||||||
EXPECT_CALL(*swapChainMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*swapChainMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
SwapChainDescriptor desc = {};
|
SwapChainDescriptor desc = {};
|
||||||
Ref<SwapChainBase> swapChain;
|
Ref<SwapChainBase> swapChain;
|
||||||
|
@ -443,18 +469,18 @@ namespace dawn_native { namespace {
|
||||||
TEST_F(DestroyObjectTests, TextureExplicit) {
|
TEST_F(DestroyObjectTests, TextureExplicit) {
|
||||||
{
|
{
|
||||||
TextureMock textureMock(&mDevice, TextureBase::TextureState::OwnedInternal);
|
TextureMock textureMock(&mDevice, TextureBase::TextureState::OwnedInternal);
|
||||||
EXPECT_CALL(textureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(textureMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(textureMock.IsAlive());
|
EXPECT_TRUE(textureMock.IsAlive());
|
||||||
textureMock.DestroyApiObject();
|
textureMock.Destroy();
|
||||||
EXPECT_FALSE(textureMock.IsAlive());
|
EXPECT_FALSE(textureMock.IsAlive());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TextureMock textureMock(&mDevice, TextureBase::TextureState::OwnedExternal);
|
TextureMock textureMock(&mDevice, TextureBase::TextureState::OwnedExternal);
|
||||||
EXPECT_CALL(textureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(textureMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(textureMock.IsAlive());
|
EXPECT_TRUE(textureMock.IsAlive());
|
||||||
textureMock.DestroyApiObject();
|
textureMock.Destroy();
|
||||||
EXPECT_FALSE(textureMock.IsAlive());
|
EXPECT_FALSE(textureMock.IsAlive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,7 +491,7 @@ namespace dawn_native { namespace {
|
||||||
{
|
{
|
||||||
TextureMock* textureMock =
|
TextureMock* textureMock =
|
||||||
new TextureMock(&mDevice, TextureBase::TextureState::OwnedInternal);
|
new TextureMock(&mDevice, TextureBase::TextureState::OwnedInternal);
|
||||||
EXPECT_CALL(*textureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*textureMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
TextureDescriptor desc = {};
|
TextureDescriptor desc = {};
|
||||||
Ref<TextureBase> texture;
|
Ref<TextureBase> texture;
|
||||||
|
@ -479,7 +505,7 @@ namespace dawn_native { namespace {
|
||||||
{
|
{
|
||||||
TextureMock* textureMock =
|
TextureMock* textureMock =
|
||||||
new TextureMock(&mDevice, TextureBase::TextureState::OwnedExternal);
|
new TextureMock(&mDevice, TextureBase::TextureState::OwnedExternal);
|
||||||
EXPECT_CALL(*textureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*textureMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
TextureDescriptor desc = {};
|
TextureDescriptor desc = {};
|
||||||
Ref<TextureBase> texture;
|
Ref<TextureBase> texture;
|
||||||
|
@ -494,10 +520,10 @@ namespace dawn_native { namespace {
|
||||||
|
|
||||||
TEST_F(DestroyObjectTests, TextureViewExplicit) {
|
TEST_F(DestroyObjectTests, TextureViewExplicit) {
|
||||||
TextureViewMock textureViewMock(GetTexture().Get());
|
TextureViewMock textureViewMock(GetTexture().Get());
|
||||||
EXPECT_CALL(textureViewMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(textureViewMock, DestroyImpl).Times(1);
|
||||||
|
|
||||||
EXPECT_TRUE(textureViewMock.IsAlive());
|
EXPECT_TRUE(textureViewMock.IsAlive());
|
||||||
textureViewMock.DestroyApiObject();
|
textureViewMock.Destroy();
|
||||||
EXPECT_FALSE(textureViewMock.IsAlive());
|
EXPECT_FALSE(textureViewMock.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +531,7 @@ namespace dawn_native { namespace {
|
||||||
// will also complain if there is a memory leak.
|
// will also complain if there is a memory leak.
|
||||||
TEST_F(DestroyObjectTests, TextureViewImplicit) {
|
TEST_F(DestroyObjectTests, TextureViewImplicit) {
|
||||||
TextureViewMock* textureViewMock = new TextureViewMock(GetTexture().Get());
|
TextureViewMock* textureViewMock = new TextureViewMock(GetTexture().Get());
|
||||||
EXPECT_CALL(*textureViewMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*textureViewMock, DestroyImpl).Times(1);
|
||||||
{
|
{
|
||||||
TextureViewDescriptor desc = {};
|
TextureViewDescriptor desc = {};
|
||||||
Ref<TextureViewBase> textureView;
|
Ref<TextureViewBase> textureView;
|
||||||
|
@ -524,6 +550,7 @@ namespace dawn_native { namespace {
|
||||||
BindGroupMock* bindGroupMock = new BindGroupMock(&mDevice);
|
BindGroupMock* bindGroupMock = new BindGroupMock(&mDevice);
|
||||||
BindGroupLayoutMock* bindGroupLayoutMock = new BindGroupLayoutMock(&mDevice);
|
BindGroupLayoutMock* bindGroupLayoutMock = new BindGroupLayoutMock(&mDevice);
|
||||||
BufferMock* bufferMock = new BufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
BufferMock* bufferMock = new BufferMock(&mDevice, BufferBase::BufferState::Unmapped);
|
||||||
|
CommandBufferMock* commandBufferMock = new CommandBufferMock(&mDevice);
|
||||||
ComputePipelineMock* computePipelineMock = new ComputePipelineMock(&mDevice);
|
ComputePipelineMock* computePipelineMock = new ComputePipelineMock(&mDevice);
|
||||||
PipelineLayoutMock* pipelineLayoutMock = new PipelineLayoutMock(&mDevice);
|
PipelineLayoutMock* pipelineLayoutMock = new PipelineLayoutMock(&mDevice);
|
||||||
QuerySetMock* querySetMock = new QuerySetMock(&mDevice);
|
QuerySetMock* querySetMock = new QuerySetMock(&mDevice);
|
||||||
|
@ -536,18 +563,19 @@ namespace dawn_native { namespace {
|
||||||
TextureViewMock* textureViewMock = new TextureViewMock(GetTexture().Get());
|
TextureViewMock* textureViewMock = new TextureViewMock(GetTexture().Get());
|
||||||
{
|
{
|
||||||
InSequence seq;
|
InSequence seq;
|
||||||
EXPECT_CALL(*renderPipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*commandBufferMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*computePipelineMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*renderPipelineMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*pipelineLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*computePipelineMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*swapChainMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*pipelineLayoutMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*bindGroupMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*swapChainMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*bindGroupLayoutMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bindGroupMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*shaderModuleMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*bindGroupLayoutMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*textureViewMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*shaderModuleMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*textureMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*textureViewMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*querySetMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*textureMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*samplerMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*querySetMock, DestroyImpl).Times(1);
|
||||||
EXPECT_CALL(*bufferMock, DestroyApiObjectImpl).Times(1);
|
EXPECT_CALL(*samplerMock, DestroyImpl).Times(1);
|
||||||
|
EXPECT_CALL(*bufferMock, DestroyImpl).Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<BindGroupBase> bindGroup;
|
Ref<BindGroupBase> bindGroup;
|
||||||
|
@ -577,6 +605,15 @@ namespace dawn_native { namespace {
|
||||||
EXPECT_TRUE(buffer->IsAlive());
|
EXPECT_TRUE(buffer->IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<CommandBufferBase> commandBuffer;
|
||||||
|
{
|
||||||
|
CommandBufferDescriptor desc = {};
|
||||||
|
EXPECT_CALL(mDevice, CreateCommandBuffer)
|
||||||
|
.WillOnce(Return(ByMove(AcquireRef(commandBufferMock))));
|
||||||
|
DAWN_ASSERT_AND_ASSIGN(commandBuffer, mDevice.CreateCommandBuffer(nullptr, &desc));
|
||||||
|
EXPECT_TRUE(commandBuffer->IsAlive());
|
||||||
|
}
|
||||||
|
|
||||||
Ref<ComputePipelineBase> computePipeline;
|
Ref<ComputePipelineBase> computePipeline;
|
||||||
{
|
{
|
||||||
// Compute pipelines usually set their hash values at construction, but the mock does
|
// Compute pipelines usually set their hash values at construction, but the mock does
|
||||||
|
@ -704,6 +741,7 @@ namespace dawn_native { namespace {
|
||||||
EXPECT_FALSE(bindGroup->IsAlive());
|
EXPECT_FALSE(bindGroup->IsAlive());
|
||||||
EXPECT_FALSE(bindGroupLayout->IsAlive());
|
EXPECT_FALSE(bindGroupLayout->IsAlive());
|
||||||
EXPECT_FALSE(buffer->IsAlive());
|
EXPECT_FALSE(buffer->IsAlive());
|
||||||
|
EXPECT_FALSE(commandBuffer->IsAlive());
|
||||||
EXPECT_FALSE(computePipeline->IsAlive());
|
EXPECT_FALSE(computePipeline->IsAlive());
|
||||||
EXPECT_FALSE(externalTexture->IsAlive());
|
EXPECT_FALSE(externalTexture->IsAlive());
|
||||||
EXPECT_FALSE(pipelineLayout->IsAlive());
|
EXPECT_FALSE(pipelineLayout->IsAlive());
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~BindGroupLayoutMock() override = default;
|
~BindGroupLayoutMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~BindGroupMock() override = default;
|
~BindGroupMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~BufferMock() override = default;
|
~BufferMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
|
|
||||||
MOCK_METHOD(MaybeError, MapAtCreationImpl, (), (override));
|
MOCK_METHOD(MaybeError, MapAtCreationImpl, (), (override));
|
||||||
MOCK_METHOD(MaybeError,
|
MOCK_METHOD(MaybeError,
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2021 The Dawn Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#ifndef TESTS_UNITTESTS_NATIVE_MOCKS_COMMANDBUFFER_MOCK_H_
|
||||||
|
#define TESTS_UNITTESTS_NATIVE_MOCKS_COMMANDBUFFER_MOCK_H_
|
||||||
|
|
||||||
|
#include "dawn_native/CommandBuffer.h"
|
||||||
|
#include "dawn_native/Device.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
namespace dawn_native {
|
||||||
|
|
||||||
|
class CommandBufferMock : public CommandBufferBase {
|
||||||
|
public:
|
||||||
|
CommandBufferMock(DeviceBase* device) : CommandBufferBase(device) {
|
||||||
|
}
|
||||||
|
~CommandBufferMock() override = default;
|
||||||
|
|
||||||
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dawn_native
|
||||||
|
|
||||||
|
#endif // TESTS_UNITTESTS_NATIVE_MOCKS_COMMANDBUFFER_MOCK_H_
|
|
@ -30,7 +30,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
MOCK_METHOD(MaybeError, Initialize, (), (override));
|
MOCK_METHOD(MaybeError, Initialize, (), (override));
|
||||||
MOCK_METHOD(size_t, ComputeContentHash, (), (override));
|
MOCK_METHOD(size_t, ComputeContentHash, (), (override));
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~ExternalTextureMock() override = default;
|
~ExternalTextureMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~PipelineLayoutMock() override = default;
|
~PipelineLayoutMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~QuerySetMock() override = default;
|
~QuerySetMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
MOCK_METHOD(MaybeError, Initialize, (), (override));
|
MOCK_METHOD(MaybeError, Initialize, (), (override));
|
||||||
MOCK_METHOD(size_t, ComputeContentHash, (), (override));
|
MOCK_METHOD(size_t, ComputeContentHash, (), (override));
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~SamplerMock() override = default;
|
~SamplerMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~ShaderModuleMock() override = default;
|
~ShaderModuleMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
|
|
||||||
// Creates a shader module mock based on the wgsl source.
|
// Creates a shader module mock based on the wgsl source.
|
||||||
static ResultOrError<Ref<ShaderModuleMock>> Create(DeviceBase* device, const char* source);
|
static ResultOrError<Ref<ShaderModuleMock>> Create(DeviceBase* device, const char* source);
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~SwapChainMock() override = default;
|
~SwapChainMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
|
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
APIConfigure,
|
APIConfigure,
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~TextureMock() override = default;
|
~TextureMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureViewMock : public TextureViewBase {
|
class TextureViewMock : public TextureViewBase {
|
||||||
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
~TextureViewMock() override = default;
|
~TextureViewMock() override = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyApiObjectImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
Loading…
Reference in New Issue