Refactors dawn_native objects for list tracking and adds destroy skeleton API.
Adds generated headers in dawn_native for object type tracking similar to that used in dawn_wire. Splits ObjectBase into ObjectBase and ApiObjectBase for clearly differentiation, and adds virtual function to identify the type of ApiObjects. Updates error generation to utilize new object typing for generating messages. Bug: dawn:628, dawn:840, dawn:563 Change-Id: Ia4f831fcbfb29a70ed5a35d47ed622921e744c84 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64820 Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
7b04930aa0
commit
8d195d511d
|
@ -845,6 +845,14 @@ class MultiGeneratorFromDawnJSON(Generator):
|
|||
FileRender('dawn_native/webgpu_absl_format.cpp',
|
||||
'src/dawn_native/webgpu_absl_format_autogen.cpp',
|
||||
frontend_params))
|
||||
renders.append(
|
||||
FileRender('dawn_native/ObjectType.h',
|
||||
'src/dawn_native/ObjectType_autogen.h',
|
||||
frontend_params))
|
||||
renders.append(
|
||||
FileRender('dawn_native/ObjectType.cpp',
|
||||
'src/dawn_native/ObjectType_autogen.cpp',
|
||||
frontend_params))
|
||||
|
||||
if 'dawn_wire' in targets:
|
||||
additional_params = compute_wire_params(params_dawn, wire_json)
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
//* Copyright 2020 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.
|
||||
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
const char* ObjectTypeAsString(ObjectType type) {
|
||||
switch (type) {
|
||||
{% for type in by_category["object"] %}
|
||||
case ObjectType::{{type.name.CamelCase()}}:
|
||||
return "{{type.name.CamelCase()}}";
|
||||
{% endfor %}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
|
@ -0,0 +1,36 @@
|
|||
//* Copyright 2020 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 DAWNNATIVE_OBJECTTPYE_AUTOGEN_H_
|
||||
#define DAWNNATIVE_OBJECTTPYE_AUTOGEN_H_
|
||||
|
||||
#include "common/ityp_array.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
enum class ObjectType : uint32_t {
|
||||
{% for type in by_category["object"] %}
|
||||
{{type.name.CamelCase()}},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using PerObjectType = ityp::array<ObjectType, T, {{len(by_category["object"])}}>;
|
||||
|
||||
const char* ObjectTypeAsString(ObjectType type);
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
|
||||
#endif // DAWNNATIVE_OBJECTTPYE_AUTOGEN_H_
|
|
@ -14,13 +14,10 @@
|
|||
|
||||
#include "dawn_native/webgpu_absl_format_autogen.h"
|
||||
|
||||
{% set skip_types = ["texture view", "instance", "surface"] %}
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% if type.name.canonical_case() not in skip_types %}
|
||||
#include "dawn_native/{{type.name.CamelCase()}}.h"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
|
@ -28,12 +25,11 @@ namespace dawn_native {
|
|||
// Objects
|
||||
//
|
||||
|
||||
// TODO(dawn:563) Detect the type of ObjectBase references and use the right formatter.
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const ObjectBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[Object");
|
||||
AbslFormatConvert(const DeviceBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[Device");
|
||||
const std::string& label = value->GetLabel();
|
||||
if (!label.empty()) {
|
||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||
|
@ -42,30 +38,26 @@ namespace dawn_native {
|
|||
return {true};
|
||||
}
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% if type.name.canonical_case() not in skip_types %}
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const {{as_frontendType(type)}} value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[{{as_cppType(type.name)}}");
|
||||
const std::string& label = value->GetLabel();
|
||||
if (!label.empty()) {
|
||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||
}
|
||||
s->Append("]");
|
||||
return {true};
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const ApiObjectBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[");
|
||||
s->Append(ObjectTypeAsString(value->GetType()));
|
||||
const std::string& label = value->GetLabel();
|
||||
if (!label.empty()) {
|
||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||
}
|
||||
s->Append("]");
|
||||
return {true};
|
||||
}
|
||||
|
||||
// Special case for textureViews, since frequently the texture will be the
|
||||
// thing that's labeled.
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const TextureViewBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[TextureView");
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s) {
|
||||
s->Append("[");
|
||||
s->Append(ObjectTypeAsString(value->GetType()));
|
||||
const std::string& label = value->GetLabel();
|
||||
if (!label.empty()) {
|
||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||
|
|
|
@ -21,29 +21,29 @@
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
{% set skip_types = ["instance", "surface"] %}
|
||||
{% set pure_frontend_types = ["command encoder", "compute pass encoder", "render pass encoder", "render bundle encoder"] %}
|
||||
|
||||
//
|
||||
// Objects
|
||||
//
|
||||
|
||||
class ObjectBase;
|
||||
class DeviceBase;
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const ObjectBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
AbslFormatConvert(const DeviceBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% set Base = "" if type.name.canonical_case() in pure_frontend_types else "Base" %}
|
||||
{% if type.name.canonical_case() not in skip_types %}
|
||||
class {{type.name.CamelCase()}}{{Base}};
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const {{type.name.CamelCase()}}{{Base}}* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
class ApiObjectBase;
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const ApiObjectBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
|
||||
// Special case for TextureViews, since frequently the texture will be the
|
||||
// thing that's labeled.
|
||||
class TextureViewBase;
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const TextureViewBase* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
|
||||
//
|
||||
// Descriptors
|
||||
|
@ -55,8 +55,8 @@ namespace dawn_native {
|
|||
{% if member.name.canonical_case() == "label" %}
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert(const {{as_cppType(type.name)}}* value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
@ -71,8 +71,8 @@ namespace wgpu {
|
|||
{% for type in by_category["enum"] %}
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert({{as_cppType(type.name)}} value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
{% endfor %}
|
||||
|
||||
//
|
||||
|
@ -82,8 +82,8 @@ namespace wgpu {
|
|||
{% for type in by_category["bitmask"] %}
|
||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString>
|
||||
AbslFormatConvert({{as_cppType(type.name)}} value,
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
const absl::FormatConversionSpec& spec,
|
||||
absl::FormatSink* s);
|
||||
{% endfor %}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
AttachmentState::AttachmentState(DeviceBase* device, const AttachmentStateBlueprint& blueprint)
|
||||
: AttachmentStateBlueprint(blueprint), CachedObject(device, kLabelNotImplemented) {
|
||||
: AttachmentStateBlueprint(blueprint), ObjectBase(device) {
|
||||
}
|
||||
|
||||
AttachmentState::~AttachmentState() {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "common/ityp_bitset.h"
|
||||
#include "dawn_native/CachedObject.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
|
@ -59,7 +60,9 @@ namespace dawn_native {
|
|||
uint32_t mSampleCount = 0;
|
||||
};
|
||||
|
||||
class AttachmentState final : public AttachmentStateBlueprint, public CachedObject {
|
||||
class AttachmentState final : public AttachmentStateBlueprint,
|
||||
public ObjectBase,
|
||||
public CachedObject {
|
||||
public:
|
||||
AttachmentState(DeviceBase* device, const AttachmentStateBlueprint& blueprint);
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ dawn_json_generator("dawn_native_utils_gen") {
|
|||
"src/dawn_native/ValidationUtils_autogen.cpp",
|
||||
"src/dawn_native/webgpu_absl_format_autogen.h",
|
||||
"src/dawn_native/webgpu_absl_format_autogen.cpp",
|
||||
"src/dawn_native/ObjectType_autogen.h",
|
||||
"src/dawn_native/ObjectType_autogen.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "dawn_native/ChainUtils_autogen.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ExternalTexture.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Sampler.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
|
||||
|
@ -317,7 +319,7 @@ namespace dawn_native {
|
|||
BindGroupBase::BindGroupBase(DeviceBase* device,
|
||||
const BindGroupDescriptor* descriptor,
|
||||
void* bindingDataStart)
|
||||
: ObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
mLayout(descriptor->layout),
|
||||
mBindingData(mLayout->ComputeBindingDataPointers(bindingDataStart)) {
|
||||
for (BindingIndex i{0}; i < mLayout->GetBindingCount(); ++i) {
|
||||
|
@ -397,7 +399,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
BindGroupBase::BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag), mBindingData() {
|
||||
: ApiObjectBase(device, tag), mBindingData() {
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -405,6 +407,10 @@ namespace dawn_native {
|
|||
return new BindGroupBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType BindGroupBase::GetType() const {
|
||||
return ObjectType::BindGroup;
|
||||
}
|
||||
|
||||
BindGroupLayoutBase* BindGroupBase::GetLayout() {
|
||||
ASSERT(!IsError());
|
||||
return mLayout.Get();
|
||||
|
|
|
@ -39,10 +39,12 @@ namespace dawn_native {
|
|||
uint64_t size;
|
||||
};
|
||||
|
||||
class BindGroupBase : public ObjectBase {
|
||||
class BindGroupBase : public ApiObjectBase {
|
||||
public:
|
||||
static BindGroupBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
BindGroupLayoutBase* GetLayout();
|
||||
const BindGroupLayoutBase* GetLayout() const;
|
||||
BufferBinding GetBindingAsBufferBinding(BindingIndex bindingIndex);
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
#include "dawn_native/ChainUtils_autogen.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/ObjectContentHasher.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/PerStage.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
||||
|
@ -359,7 +361,7 @@ namespace dawn_native {
|
|||
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
|
||||
const BindGroupLayoutDescriptor* descriptor,
|
||||
PipelineCompatibilityToken pipelineCompatibilityToken)
|
||||
: CachedObject(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
mBindingInfo(BindingIndex(descriptor->entryCount)),
|
||||
mPipelineCompatibilityToken(pipelineCompatibilityToken) {
|
||||
std::vector<BindGroupLayoutEntry> sortedBindings(
|
||||
|
@ -386,7 +388,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: CachedObject(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
BindGroupLayoutBase::~BindGroupLayoutBase() {
|
||||
|
@ -401,6 +403,10 @@ namespace dawn_native {
|
|||
return new BindGroupLayoutBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType BindGroupLayoutBase::GetType() const {
|
||||
return ObjectType::BindGroupLayout;
|
||||
}
|
||||
|
||||
const BindGroupLayoutBase::BindingMap& BindGroupLayoutBase::GetBindingMap() const {
|
||||
ASSERT(!IsError());
|
||||
return mBindingMap;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "dawn_native/CachedObject.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
|
@ -39,7 +40,7 @@ namespace dawn_native {
|
|||
// Bindings are specified as a |BindingNumber| in the BindGroupLayoutDescriptor.
|
||||
// These numbers may be arbitrary and sparse. Internally, Dawn packs these numbers
|
||||
// into a packed range of |BindingIndex| integers.
|
||||
class BindGroupLayoutBase : public CachedObject {
|
||||
class BindGroupLayoutBase : public ApiObjectBase, public CachedObject {
|
||||
public:
|
||||
BindGroupLayoutBase(DeviceBase* device,
|
||||
const BindGroupLayoutDescriptor* descriptor,
|
||||
|
@ -48,6 +49,8 @@ namespace dawn_native {
|
|||
|
||||
static BindGroupLayoutBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
// A map from the BindingNumber to its packed BindingIndex.
|
||||
using BindingMap = std::map<BindingNumber, BindingIndex>;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/DynamicUploader.h"
|
||||
#include "dawn_native/ErrorData.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Queue.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
||||
|
@ -128,7 +129,7 @@ namespace dawn_native {
|
|||
// Buffer
|
||||
|
||||
BufferBase::BufferBase(DeviceBase* device, const BufferDescriptor* descriptor)
|
||||
: ObjectBase(device, descriptor->label),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mSize(descriptor->size),
|
||||
mUsage(descriptor->usage),
|
||||
mState(BufferState::Unmapped) {
|
||||
|
@ -158,7 +159,7 @@ namespace dawn_native {
|
|||
BufferBase::BufferBase(DeviceBase* device,
|
||||
const BufferDescriptor* descriptor,
|
||||
ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag), mSize(descriptor->size), mState(BufferState::Unmapped) {
|
||||
: ApiObjectBase(device, tag), mSize(descriptor->size), mState(BufferState::Unmapped) {
|
||||
if (descriptor->mappedAtCreation) {
|
||||
mState = BufferState::MappedAtCreation;
|
||||
mMapOffset = 0;
|
||||
|
@ -178,6 +179,10 @@ namespace dawn_native {
|
|||
return new ErrorBuffer(device, descriptor);
|
||||
}
|
||||
|
||||
ObjectType BufferBase::GetType() const {
|
||||
return ObjectType::Buffer;
|
||||
}
|
||||
|
||||
uint64_t BufferBase::GetSize() const {
|
||||
ASSERT(!IsError());
|
||||
return mSize;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace dawn_native {
|
|||
static constexpr wgpu::BufferUsage kMappableBufferUsages =
|
||||
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite;
|
||||
|
||||
class BufferBase : public ObjectBase {
|
||||
class BufferBase : public ApiObjectBase {
|
||||
enum class BufferState {
|
||||
Unmapped,
|
||||
Mapped,
|
||||
|
@ -53,6 +53,8 @@ namespace dawn_native {
|
|||
|
||||
static BufferBase* MakeError(DeviceBase* device, const BufferDescriptor* descriptor);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
uint64_t GetSize() const;
|
||||
uint64_t GetAllocatedSize() const;
|
||||
wgpu::BufferUsage GetUsage() const;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
#ifndef DAWNNATIVE_CACHED_OBJECT_H_
|
||||
#define DAWNNATIVE_CACHED_OBJECT_H_
|
||||
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -25,10 +23,8 @@ namespace dawn_native {
|
|||
// we increase the refcount of an existing object.
|
||||
// When an object is successfully created, the device should call
|
||||
// SetIsCachedReference() and insert the object into the cache.
|
||||
class CachedObject : public ObjectBase {
|
||||
class CachedObject {
|
||||
public:
|
||||
using ObjectBase::ObjectBase;
|
||||
|
||||
bool IsCachedReference() const;
|
||||
|
||||
// Functor necessary for the unordered_set<CachedObject*>-based cache.
|
||||
|
|
|
@ -20,18 +20,19 @@
|
|||
#include "dawn_native/CommandValidation.h"
|
||||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/Format.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
CommandBufferBase::CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor*)
|
||||
: ObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||
mCommands(encoder->AcquireCommands()),
|
||||
mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||
}
|
||||
|
||||
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
CommandBufferBase::~CommandBufferBase() {
|
||||
|
@ -51,6 +52,10 @@ namespace dawn_native {
|
|||
return new CommandBufferBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType CommandBufferBase::GetType() const {
|
||||
return ObjectType::CommandBuffer;
|
||||
}
|
||||
|
||||
MaybeError CommandBufferBase::ValidateCanUseInSubmitNow() const {
|
||||
ASSERT(!IsError());
|
||||
|
||||
|
|
|
@ -30,19 +30,21 @@ namespace dawn_native {
|
|||
struct CopyTextureToBufferCmd;
|
||||
struct TextureCopy;
|
||||
|
||||
class CommandBufferBase : public ObjectBase {
|
||||
class CommandBufferBase : public ApiObjectBase {
|
||||
public:
|
||||
CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
|
||||
|
||||
static CommandBufferBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
MaybeError ValidateCanUseInSubmitNow() const;
|
||||
void Destroy();
|
||||
|
||||
const CommandBufferResourceUsage& GetResourceUsages() const;
|
||||
|
||||
protected:
|
||||
~CommandBufferBase();
|
||||
~CommandBufferBase() override;
|
||||
|
||||
void DoNextSetValidatedBufferLocationsInternal();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "dawn_native/ComputePassEncoder.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ErrorData.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/QueryHelper.h"
|
||||
#include "dawn_native/QuerySet.h"
|
||||
#include "dawn_native/Queue.h"
|
||||
|
@ -447,7 +448,11 @@ namespace dawn_native {
|
|||
} // namespace
|
||||
|
||||
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor*)
|
||||
: ObjectBase(device, kLabelNotImplemented), mEncodingContext(device, this) {
|
||||
: ApiObjectBase(device, kLabelNotImplemented), mEncodingContext(device, this) {
|
||||
}
|
||||
|
||||
ObjectType CommandEncoder::GetType() const {
|
||||
return ObjectType::CommandEncoder;
|
||||
}
|
||||
|
||||
CommandBufferResourceUsage CommandEncoder::AcquireResourceUsages() {
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
class CommandEncoder final : public ObjectBase {
|
||||
class CommandEncoder final : public ApiObjectBase {
|
||||
public:
|
||||
CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor);
|
||||
|
||||
ObjectType GetType() const;
|
||||
|
||||
CommandIterator AcquireCommands();
|
||||
CommandBufferResourceUsage AcquireResourceUsages();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/ComputePipeline.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/PassResourceUsageTracker.h"
|
||||
#include "dawn_native/QuerySet.h"
|
||||
|
||||
|
@ -57,6 +58,10 @@ namespace dawn_native {
|
|||
return new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType ComputePassEncoder::GetType() const {
|
||||
return ObjectType::ComputePassEncoder;
|
||||
}
|
||||
|
||||
void ComputePassEncoder::APIEndPass() {
|
||||
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||
if (IsValidationEnabled()) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "dawn_native/CommandBufferStateTracker.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/PassResourceUsageTracker.h"
|
||||
#include "dawn_native/ProgrammablePassEncoder.h"
|
||||
|
||||
|
@ -34,6 +35,8 @@ namespace dawn_native {
|
|||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
void APIEndPass();
|
||||
|
||||
void APIDispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectContentHasher.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
|
@ -65,6 +66,10 @@ namespace dawn_native {
|
|||
return new ComputePipelineBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType ComputePipelineBase::GetType() const {
|
||||
return ObjectType::ComputePipeline;
|
||||
}
|
||||
|
||||
bool ComputePipelineBase::EqualityFunc::operator()(const ComputePipelineBase* a,
|
||||
const ComputePipelineBase* b) const {
|
||||
return PipelineBase::EqualForCache(a, b);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define DAWNNATIVE_COMPUTEPIPELINE_H_
|
||||
|
||||
#include "common/NonCopyable.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/Pipeline.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -33,6 +34,8 @@ namespace dawn_native {
|
|||
|
||||
static ComputePipelineBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
// Functors necessary for the unordered_set<ComputePipelineBase*>-based cache.
|
||||
struct EqualityFunc {
|
||||
bool operator()(const ComputePipelineBase* a, const ComputePipelineBase* b) const;
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
const char* GetObjectLabelForTesting(void* objectHandle) {
|
||||
ObjectBase* object = reinterpret_cast<ObjectBase*>(objectHandle);
|
||||
ApiObjectBase* object = reinterpret_cast<ApiObjectBase*>(objectHandle);
|
||||
return object->GetLabel().c_str();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "dawn_native/ExternalTexture.h"
|
||||
#include "dawn_native/Instance.h"
|
||||
#include "dawn_native/InternalPipelineStore.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/PersistentCache.h"
|
||||
#include "dawn_native/PipelineLayout.h"
|
||||
#include "dawn_native/QuerySet.h"
|
||||
|
@ -47,6 +48,7 @@
|
|||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -471,7 +473,7 @@ namespace dawn_native {
|
|||
return mPersistentCache.get();
|
||||
}
|
||||
|
||||
MaybeError DeviceBase::ValidateObject(const ObjectBase* object) const {
|
||||
MaybeError DeviceBase::ValidateObject(const ApiObjectBase* object) const {
|
||||
ASSERT(object != nullptr);
|
||||
DAWN_INVALID_IF(object->GetDevice() != this,
|
||||
"%s is associated with %s, and cannot be used with %s.", object,
|
||||
|
@ -506,6 +508,10 @@ namespace dawn_native {
|
|||
return mState != State::Alive;
|
||||
}
|
||||
|
||||
std::mutex* DeviceBase::GetObjectListMutex(ObjectType type) {
|
||||
return &mObjectLists[type].mutex;
|
||||
}
|
||||
|
||||
AdapterBase* DeviceBase::GetAdapter() const {
|
||||
return mAdapter;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/Limits.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/StagingBuffer.h"
|
||||
#include "dawn_native/Toggles.h"
|
||||
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
namespace dawn_platform {
|
||||
|
@ -75,7 +78,7 @@ namespace dawn_native {
|
|||
return false;
|
||||
}
|
||||
|
||||
MaybeError ValidateObject(const ObjectBase* object) const;
|
||||
MaybeError ValidateObject(const ApiObjectBase* object) const;
|
||||
|
||||
AdapterBase* GetAdapter() const;
|
||||
dawn_platform::Platform* GetPlatform() const;
|
||||
|
@ -257,6 +260,7 @@ namespace dawn_native {
|
|||
};
|
||||
State GetState() const;
|
||||
bool IsLost() const;
|
||||
std::mutex* GetObjectListMutex(ObjectType type);
|
||||
|
||||
std::vector<const char*> GetEnabledExtensions() const;
|
||||
std::vector<const char*> GetTogglesUsed() const;
|
||||
|
@ -451,6 +455,14 @@ namespace dawn_native {
|
|||
|
||||
State mState = State::BeingCreated;
|
||||
|
||||
// Encompasses the mutex and the actual list that contains all live objects "owned" by the
|
||||
// device.
|
||||
struct ApiObjectList {
|
||||
std::mutex mutex;
|
||||
LinkedList<ApiObjectBase> objects;
|
||||
};
|
||||
PerObjectType<ApiObjectList> mObjectLists;
|
||||
|
||||
FormatTable mFormatTable;
|
||||
|
||||
TogglesSet mEnabledToggles;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "dawn_native/ExternalTexture.h"
|
||||
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
@ -86,12 +87,12 @@ namespace dawn_native {
|
|||
|
||||
ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
|
||||
const ExternalTextureDescriptor* descriptor)
|
||||
: ObjectBase(device, kLabelNotImplemented), mState(ExternalTextureState::Alive) {
|
||||
: ApiObjectBase(device, kLabelNotImplemented), mState(ExternalTextureState::Alive) {
|
||||
textureViews[0] = descriptor->plane0;
|
||||
}
|
||||
|
||||
ExternalTextureBase::ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
const std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat>&
|
||||
|
@ -120,4 +121,8 @@ namespace dawn_native {
|
|||
return new ExternalTextureBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType ExternalTextureBase::GetType() const {
|
||||
return ObjectType::ExternalTexture;
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
|
@ -16,6 +16,7 @@
|
|||
#define DAWNNATIVE_EXTERNALTEXTURE_H_
|
||||
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/Subresource.h"
|
||||
|
||||
|
@ -29,7 +30,7 @@ namespace dawn_native {
|
|||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||
const ExternalTextureDescriptor* descriptor);
|
||||
|
||||
class ExternalTextureBase : public ObjectBase {
|
||||
class ExternalTextureBase : public ApiObjectBase {
|
||||
public:
|
||||
static ResultOrError<Ref<ExternalTextureBase>> Create(
|
||||
DeviceBase* device,
|
||||
|
@ -41,6 +42,8 @@ namespace dawn_native {
|
|||
|
||||
static ExternalTextureBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
void APIDestroy();
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,6 +22,8 @@ class Ref;
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
enum class ObjectType : uint32_t;
|
||||
|
||||
class AdapterBase;
|
||||
class BindGroupBase;
|
||||
class BindGroupLayoutBase;
|
||||
|
|
|
@ -13,29 +13,21 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/Device.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
static constexpr uint64_t kErrorPayload = 0;
|
||||
static constexpr uint64_t kNotErrorPayload = 1;
|
||||
|
||||
ObjectBase::ObjectBase(DeviceBase* device, const char* label)
|
||||
: RefCounted(kNotErrorPayload), mDevice(device) {
|
||||
if (label) {
|
||||
mLabel = label;
|
||||
}
|
||||
ObjectBase::ObjectBase(DeviceBase* device) : RefCounted(kNotErrorPayload), mDevice(device) {
|
||||
}
|
||||
|
||||
ObjectBase::ObjectBase(DeviceBase* device, ErrorTag)
|
||||
: RefCounted(kErrorPayload), mDevice(device) {
|
||||
}
|
||||
ObjectBase::ObjectBase(DeviceBase* device, LabelNotImplementedTag)
|
||||
: RefCounted(kNotErrorPayload), mDevice(device) {
|
||||
}
|
||||
|
||||
const std::string& ObjectBase::GetLabel() const {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
DeviceBase* ObjectBase::GetDevice() const {
|
||||
return mDevice;
|
||||
|
@ -45,12 +37,37 @@ namespace dawn_native {
|
|||
return GetRefCountPayload() == kErrorPayload;
|
||||
}
|
||||
|
||||
void ObjectBase::APISetLabel(const char* label) {
|
||||
bool ObjectBase::IsAlive() const {
|
||||
return mDevice != nullptr;
|
||||
}
|
||||
|
||||
void ObjectBase::DestroyObject() {
|
||||
mDevice = nullptr;
|
||||
}
|
||||
|
||||
ApiObjectBase::ApiObjectBase(DeviceBase* device, const char* label) : ObjectBase(device) {
|
||||
if (label) {
|
||||
mLabel = label;
|
||||
}
|
||||
}
|
||||
|
||||
ApiObjectBase::ApiObjectBase(DeviceBase* device, ErrorTag tag) : ObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
ApiObjectBase::ApiObjectBase(DeviceBase* device, LabelNotImplementedTag tag)
|
||||
: ObjectBase(device) {
|
||||
}
|
||||
|
||||
void ApiObjectBase::APISetLabel(const char* label) {
|
||||
mLabel = label;
|
||||
SetLabelImpl();
|
||||
}
|
||||
|
||||
void ObjectBase::SetLabelImpl() {
|
||||
const std::string& ApiObjectBase::GetLabel() const {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
void ApiObjectBase::SetLabelImpl() {
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#ifndef DAWNNATIVE_OBJECTBASE_H_
|
||||
#define DAWNNATIVE_OBJECTBASE_H_
|
||||
|
||||
#include "common/LinkedList.h"
|
||||
#include "common/RefCounted.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -27,16 +29,32 @@ namespace dawn_native {
|
|||
public:
|
||||
struct ErrorTag {};
|
||||
static constexpr ErrorTag kError = {};
|
||||
struct LabelNotImplementedTag {};
|
||||
static constexpr LabelNotImplementedTag kLabelNotImplemented = {};
|
||||
|
||||
ObjectBase(DeviceBase* device, LabelNotImplementedTag tag);
|
||||
ObjectBase(DeviceBase* device, const char* label);
|
||||
explicit ObjectBase(DeviceBase* device);
|
||||
ObjectBase(DeviceBase* device, ErrorTag tag);
|
||||
|
||||
DeviceBase* GetDevice() const;
|
||||
const std::string& GetLabel() const;
|
||||
bool IsError() const;
|
||||
bool IsAlive() const;
|
||||
void DestroyObject();
|
||||
|
||||
private:
|
||||
// Pointer to owning device, if nullptr, that means that the object is no longer alive or
|
||||
// valid.
|
||||
DeviceBase* mDevice;
|
||||
};
|
||||
|
||||
class ApiObjectBase : public ObjectBase, public LinkNode<ApiObjectBase> {
|
||||
public:
|
||||
struct LabelNotImplementedTag {};
|
||||
static constexpr LabelNotImplementedTag kLabelNotImplemented = {};
|
||||
|
||||
ApiObjectBase(DeviceBase* device, LabelNotImplementedTag tag);
|
||||
ApiObjectBase(DeviceBase* device, const char* label);
|
||||
ApiObjectBase(DeviceBase* device, ErrorTag tag);
|
||||
|
||||
virtual ObjectType GetType() const = 0;
|
||||
const std::string& GetLabel() const;
|
||||
|
||||
// Dawn API
|
||||
void APISetLabel(const char* label);
|
||||
|
@ -44,9 +62,7 @@ namespace dawn_native {
|
|||
private:
|
||||
virtual void SetLabelImpl();
|
||||
|
||||
// TODO(dawn:840): Optimize memory footprint for objects that don't have labels.
|
||||
std::string mLabel;
|
||||
DeviceBase* mDevice;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/BindGroupLayout.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/ObjectContentHasher.h"
|
||||
#include "dawn_native/PipelineLayout.h"
|
||||
#include "dawn_native/ShaderModule.h"
|
||||
|
@ -52,7 +53,7 @@ namespace dawn_native {
|
|||
PipelineLayoutBase* layout,
|
||||
const char* label,
|
||||
std::vector<StageAndDescriptor> stages)
|
||||
: CachedObject(device, label), mLayout(layout) {
|
||||
: ApiObjectBase(device, label), mLayout(layout) {
|
||||
ASSERT(!stages.empty());
|
||||
|
||||
for (const StageAndDescriptor& stage : stages) {
|
||||
|
@ -89,7 +90,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
PipelineBase::PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: CachedObject(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
PipelineLayoutBase* PipelineBase::GetLayout() {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "dawn_native/CachedObject.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/PerStage.h"
|
||||
#include "dawn_native/PipelineLayout.h"
|
||||
#include "dawn_native/ShaderModule.h"
|
||||
|
@ -42,7 +43,7 @@ namespace dawn_native {
|
|||
const EntryPointMetadata* metadata = nullptr;
|
||||
};
|
||||
|
||||
class PipelineBase : public CachedObject {
|
||||
class PipelineBase : public ApiObjectBase, public CachedObject {
|
||||
public:
|
||||
PipelineLayoutBase* GetLayout();
|
||||
const PipelineLayoutBase* GetLayout() const;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/BindGroupLayout.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectContentHasher.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/ShaderModule.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -57,7 +58,7 @@ namespace dawn_native {
|
|||
|
||||
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
|
||||
const PipelineLayoutDescriptor* descriptor)
|
||||
: CachedObject(device, kLabelNotImplemented) {
|
||||
: ApiObjectBase(device, kLabelNotImplemented) {
|
||||
ASSERT(descriptor->bindGroupLayoutCount <= kMaxBindGroups);
|
||||
for (BindGroupIndex group(0); group < BindGroupIndex(descriptor->bindGroupLayoutCount);
|
||||
++group) {
|
||||
|
@ -67,7 +68,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: CachedObject(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
PipelineLayoutBase::~PipelineLayoutBase() {
|
||||
|
@ -322,6 +323,10 @@ namespace dawn_native {
|
|||
return std::move(result);
|
||||
}
|
||||
|
||||
ObjectType PipelineLayoutBase::GetType() const {
|
||||
return ObjectType::PipelineLayout;
|
||||
}
|
||||
|
||||
const BindGroupLayoutBase* PipelineLayoutBase::GetBindGroupLayout(BindGroupIndex group) const {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(group < kMaxBindGroupsTyped);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "dawn_native/CachedObject.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
|
@ -45,7 +46,7 @@ namespace dawn_native {
|
|||
std::string entryPoint;
|
||||
};
|
||||
|
||||
class PipelineLayoutBase : public CachedObject {
|
||||
class PipelineLayoutBase : public ApiObjectBase, public CachedObject {
|
||||
public:
|
||||
PipelineLayoutBase(DeviceBase* device, const PipelineLayoutDescriptor* descriptor);
|
||||
~PipelineLayoutBase() override;
|
||||
|
@ -55,6 +56,8 @@ namespace dawn_native {
|
|||
DeviceBase* device,
|
||||
std::vector<StageAndDescriptor> stages);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
const BindGroupLayoutBase* GetBindGroupLayout(BindGroupIndex group) const;
|
||||
BindGroupLayoutBase* GetBindGroupLayout(BindGroupIndex group);
|
||||
const BindGroupLayoutMask& GetBindGroupLayoutsMask() const;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "dawn_native/CommandBuffer.h"
|
||||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
||||
#include <cstring>
|
||||
|
@ -29,7 +30,7 @@ namespace dawn_native {
|
|||
|
||||
ProgrammablePassEncoder::ProgrammablePassEncoder(DeviceBase* device,
|
||||
EncodingContext* encodingContext)
|
||||
: ObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
mEncodingContext(encodingContext),
|
||||
mValidationEnabled(device->IsValidationEnabled()) {
|
||||
}
|
||||
|
@ -37,7 +38,7 @@ namespace dawn_native {
|
|||
ProgrammablePassEncoder::ProgrammablePassEncoder(DeviceBase* device,
|
||||
EncodingContext* encodingContext,
|
||||
ErrorTag errorTag)
|
||||
: ObjectBase(device, errorTag),
|
||||
: ApiObjectBase(device, errorTag),
|
||||
mEncodingContext(encodingContext),
|
||||
mValidationEnabled(device->IsValidationEnabled()) {
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "dawn_native/CommandEncoder.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
|
@ -27,7 +28,7 @@ namespace dawn_native {
|
|||
class DeviceBase;
|
||||
|
||||
// Base class for shared functionality between ComputePassEncoder and RenderPassEncoder.
|
||||
class ProgrammablePassEncoder : public ObjectBase {
|
||||
class ProgrammablePassEncoder : public ApiObjectBase {
|
||||
public:
|
||||
ProgrammablePassEncoder(DeviceBase* device, EncodingContext* encodingContext);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/Extensions.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
||||
#include <set>
|
||||
|
@ -114,7 +115,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
QuerySetBase::QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor)
|
||||
: ObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
mQueryType(descriptor->type),
|
||||
mQueryCount(descriptor->count),
|
||||
mState(QuerySetState::Available) {
|
||||
|
@ -126,7 +127,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
QuerySetBase::QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
QuerySetBase::~QuerySetBase() {
|
||||
|
@ -139,6 +140,10 @@ namespace dawn_native {
|
|||
return new ErrorQuerySet(device);
|
||||
}
|
||||
|
||||
ObjectType QuerySetBase::GetType() const {
|
||||
return ObjectType::QuerySet;
|
||||
}
|
||||
|
||||
wgpu::QueryType QuerySetBase::GetQueryType() const {
|
||||
return mQueryType;
|
||||
}
|
||||
|
|
|
@ -25,12 +25,14 @@ namespace dawn_native {
|
|||
|
||||
MaybeError ValidateQuerySetDescriptor(DeviceBase* device, const QuerySetDescriptor* descriptor);
|
||||
|
||||
class QuerySetBase : public ObjectBase {
|
||||
class QuerySetBase : public ApiObjectBase {
|
||||
public:
|
||||
QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor);
|
||||
|
||||
static QuerySetBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
wgpu::QueryType GetQueryType() const;
|
||||
uint32_t GetQueryCount() const;
|
||||
const std::vector<wgpu::PipelineStatisticName>& GetPipelineStatistics() const;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/DynamicUploader.h"
|
||||
#include "dawn_native/ExternalTexture.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/QuerySet.h"
|
||||
#include "dawn_native/RenderPassEncoder.h"
|
||||
#include "dawn_native/RenderPipeline.h"
|
||||
|
@ -161,10 +162,11 @@ namespace dawn_native {
|
|||
QueueBase::TaskInFlight::~TaskInFlight() {
|
||||
}
|
||||
|
||||
QueueBase::QueueBase(DeviceBase* device) : ObjectBase(device, kLabelNotImplemented) {
|
||||
QueueBase::QueueBase(DeviceBase* device) : ApiObjectBase(device, kLabelNotImplemented) {
|
||||
}
|
||||
|
||||
QueueBase::QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag) : ObjectBase(device, tag) {
|
||||
QueueBase::QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
QueueBase::~QueueBase() {
|
||||
|
@ -176,6 +178,10 @@ namespace dawn_native {
|
|||
return new ErrorQueue(device);
|
||||
}
|
||||
|
||||
ObjectType QueueBase::GetType() const {
|
||||
return ObjectType::Queue;
|
||||
}
|
||||
|
||||
void QueueBase::APISubmit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||
SubmitInternal(commandCount, commands);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
class QueueBase : public ObjectBase {
|
||||
class QueueBase : public ApiObjectBase {
|
||||
public:
|
||||
struct TaskInFlight {
|
||||
virtual ~TaskInFlight();
|
||||
|
@ -33,9 +33,12 @@ namespace dawn_native {
|
|||
virtual void HandleDeviceLoss() = 0;
|
||||
};
|
||||
|
||||
static QueueBase* MakeError(DeviceBase* device);
|
||||
~QueueBase() override;
|
||||
|
||||
static QueueBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
// Dawn API
|
||||
void APISubmit(uint32_t commandCount, CommandBufferBase* const* commands);
|
||||
void APIOnSubmittedWorkDone(uint64_t signalValue,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "common/BitSetIterator.h"
|
||||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/RenderBundleEncoder.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -26,7 +27,7 @@ namespace dawn_native {
|
|||
Ref<AttachmentState> attachmentState,
|
||||
RenderPassResourceUsage resourceUsage,
|
||||
IndirectDrawMetadata indirectDrawMetadata)
|
||||
: ObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||
mCommands(encoder->AcquireCommands()),
|
||||
mIndirectDrawMetadata(std::move(indirectDrawMetadata)),
|
||||
mAttachmentState(std::move(attachmentState)),
|
||||
|
@ -43,7 +44,11 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
RenderBundleBase::RenderBundleBase(DeviceBase* device, ErrorTag errorTag)
|
||||
: ObjectBase(device, errorTag) {
|
||||
: ApiObjectBase(device, errorTag) {
|
||||
}
|
||||
|
||||
ObjectType RenderBundleBase::GetType() const {
|
||||
return ObjectType::RenderBundle;
|
||||
}
|
||||
|
||||
CommandIterator* RenderBundleBase::GetCommands() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "dawn_native/AttachmentState.h"
|
||||
#include "dawn_native/CommandAllocator.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IndirectDrawMetadata.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/PassResourceUsage.h"
|
||||
|
@ -32,7 +33,7 @@ namespace dawn_native {
|
|||
struct RenderBundleDescriptor;
|
||||
class RenderBundleEncoder;
|
||||
|
||||
class RenderBundleBase : public ObjectBase {
|
||||
class RenderBundleBase : public ApiObjectBase {
|
||||
public:
|
||||
RenderBundleBase(RenderBundleEncoder* encoder,
|
||||
const RenderBundleDescriptor* descriptor,
|
||||
|
@ -42,6 +43,8 @@ namespace dawn_native {
|
|||
|
||||
static RenderBundleBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
CommandIterator* GetCommands();
|
||||
|
||||
const AttachmentState* GetAttachmentState() const;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/Format.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/RenderPipeline.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
|
@ -102,6 +103,10 @@ namespace dawn_native {
|
|||
return new RenderBundleEncoder(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType RenderBundleEncoder::GetType() const {
|
||||
return ObjectType::RenderBundleEncoder;
|
||||
}
|
||||
|
||||
CommandIterator RenderBundleEncoder::AcquireCommands() {
|
||||
return mBundleEncodingContext.AcquireCommands();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "dawn_native/EncodingContext.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/RenderBundle.h"
|
||||
#include "dawn_native/RenderEncoderBase.h"
|
||||
|
||||
|
@ -32,6 +33,8 @@ namespace dawn_native {
|
|||
const RenderBundleEncoderDescriptor* descriptor);
|
||||
static RenderBundleEncoder* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
RenderBundleBase* APIFinish(const RenderBundleDescriptor* descriptor);
|
||||
|
||||
CommandIterator AcquireCommands();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/CommandValidation.h"
|
||||
#include "dawn_native/Commands.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/QuerySet.h"
|
||||
#include "dawn_native/RenderBundle.h"
|
||||
#include "dawn_native/RenderPipeline.h"
|
||||
|
@ -77,6 +78,10 @@ namespace dawn_native {
|
|||
return new RenderPassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType RenderPassEncoder::GetType() const {
|
||||
return ObjectType::RenderPassEncoder;
|
||||
}
|
||||
|
||||
void RenderPassEncoder::TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex) {
|
||||
DAWN_ASSERT(querySet != nullptr);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define DAWNNATIVE_RENDERPASSENCODER_H_
|
||||
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/RenderEncoderBase.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -37,6 +38,8 @@ namespace dawn_native {
|
|||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
void APIEndPass();
|
||||
|
||||
void APISetStencilReference(uint32_t reference);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/InternalPipelineStore.h"
|
||||
#include "dawn_native/ObjectContentHasher.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
#include "dawn_native/VertexFormat.h"
|
||||
|
||||
|
@ -559,6 +560,10 @@ namespace dawn_native {
|
|||
return new RenderPipelineBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType RenderPipelineBase::GetType() const {
|
||||
return ObjectType::RenderPipeline;
|
||||
}
|
||||
|
||||
RenderPipelineBase::~RenderPipelineBase() {
|
||||
if (IsCachedReference()) {
|
||||
GetDevice()->UncacheRenderPipeline(this);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "common/TypedInteger.h"
|
||||
#include "dawn_native/AttachmentState.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/Pipeline.h"
|
||||
|
||||
|
@ -62,6 +63,8 @@ namespace dawn_native {
|
|||
|
||||
static RenderPipelineBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
const ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>&
|
||||
GetAttributeLocationsUsed() const;
|
||||
const VertexAttributeInfo& GetAttribute(VertexAttributeLocation location) const;
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace dawn_native {
|
|||
// SamplerBase
|
||||
|
||||
SamplerBase::SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor)
|
||||
: CachedObject(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
mAddressModeU(descriptor->addressModeU),
|
||||
mAddressModeV(descriptor->addressModeV),
|
||||
mAddressModeW(descriptor->addressModeW),
|
||||
|
@ -86,7 +86,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: CachedObject(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
SamplerBase::~SamplerBase() {
|
||||
|
@ -100,6 +100,10 @@ namespace dawn_native {
|
|||
return new SamplerBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType SamplerBase::GetType() const {
|
||||
return ObjectType::Sampler;
|
||||
}
|
||||
|
||||
bool SamplerBase::IsComparison() const {
|
||||
return mCompareFunction != wgpu::CompareFunction::Undefined;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "dawn_native/CachedObject.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
|
@ -26,13 +28,15 @@ namespace dawn_native {
|
|||
|
||||
MaybeError ValidateSamplerDescriptor(DeviceBase* device, const SamplerDescriptor* descriptor);
|
||||
|
||||
class SamplerBase : public CachedObject {
|
||||
class SamplerBase : public ApiObjectBase, public CachedObject {
|
||||
public:
|
||||
SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor);
|
||||
~SamplerBase() override;
|
||||
|
||||
static SamplerBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
bool IsComparison() const;
|
||||
bool IsFiltering() const;
|
||||
|
||||
|
|
|
@ -1139,7 +1139,7 @@ namespace dawn_native {
|
|||
// ShaderModuleBase
|
||||
|
||||
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor)
|
||||
: CachedObject(device, descriptor->label), mType(Type::Undefined) {
|
||||
: ApiObjectBase(device, descriptor->label), mType(Type::Undefined) {
|
||||
ASSERT(descriptor->nextInChain != nullptr);
|
||||
const ShaderModuleSPIRVDescriptor* spirvDesc = nullptr;
|
||||
FindInChain(descriptor->nextInChain, &spirvDesc);
|
||||
|
@ -1157,7 +1157,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: CachedObject(device, tag), mType(Type::Undefined) {
|
||||
: ApiObjectBase(device, tag), mType(Type::Undefined) {
|
||||
}
|
||||
|
||||
ShaderModuleBase::~ShaderModuleBase() {
|
||||
|
@ -1171,6 +1171,10 @@ namespace dawn_native {
|
|||
return AcquireRef(new ShaderModuleBase(device, ObjectBase::kError));
|
||||
}
|
||||
|
||||
ObjectType ShaderModuleBase::GetType() const {
|
||||
return ObjectType::ShaderModule;
|
||||
}
|
||||
|
||||
bool ShaderModuleBase::HasEntryPoint(const std::string& entryPoint) const {
|
||||
return mEntryPoints.count(entryPoint) > 0;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "dawn_native/Format.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
#include "dawn_native/PerStage.h"
|
||||
#include "dawn_native/VertexFormat.h"
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
@ -195,13 +196,15 @@ namespace dawn_native {
|
|||
SingleShaderStage stage;
|
||||
};
|
||||
|
||||
class ShaderModuleBase : public CachedObject {
|
||||
class ShaderModuleBase : public ApiObjectBase, public CachedObject {
|
||||
public:
|
||||
ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor);
|
||||
~ShaderModuleBase() override;
|
||||
|
||||
static Ref<ShaderModuleBase> MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
// Return true iff the program has an entrypoint called `entryPoint`.
|
||||
bool HasEntryPoint(const std::string& entryPoint) const;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "common/Constants.h"
|
||||
#include "dawn_native/Adapter.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/Surface.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
@ -112,11 +113,11 @@ namespace dawn_native {
|
|||
|
||||
// SwapChainBase
|
||||
|
||||
SwapChainBase::SwapChainBase(DeviceBase* device) : ObjectBase(device, kLabelNotImplemented) {
|
||||
SwapChainBase::SwapChainBase(DeviceBase* device) : ApiObjectBase(device, kLabelNotImplemented) {
|
||||
}
|
||||
|
||||
SwapChainBase::SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag) {
|
||||
: ApiObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
SwapChainBase::~SwapChainBase() {
|
||||
|
@ -127,6 +128,10 @@ namespace dawn_native {
|
|||
return new ErrorSwapChain(device);
|
||||
}
|
||||
|
||||
ObjectType SwapChainBase::GetType() const {
|
||||
return ObjectType::SwapChain;
|
||||
}
|
||||
|
||||
// OldSwapChainBase
|
||||
|
||||
OldSwapChainBase::OldSwapChainBase(DeviceBase* device, const SwapChainDescriptor* descriptor)
|
||||
|
|
|
@ -30,12 +30,14 @@ namespace dawn_native {
|
|||
|
||||
TextureDescriptor GetSwapChainBaseTextureDescriptor(NewSwapChainBase* swapChain);
|
||||
|
||||
class SwapChainBase : public ObjectBase {
|
||||
class SwapChainBase : public ApiObjectBase {
|
||||
public:
|
||||
SwapChainBase(DeviceBase* device);
|
||||
|
||||
static SwapChainBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
// Dawn API
|
||||
virtual void APIConfigure(wgpu::TextureFormat format,
|
||||
wgpu::TextureUsage allowedUsage,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "dawn_native/ChainUtils_autogen.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/EnumMaskIterator.h"
|
||||
#include "dawn_native/ObjectType_autogen.h"
|
||||
#include "dawn_native/PassResourceUsage.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
|
||||
|
@ -445,7 +446,7 @@ namespace dawn_native {
|
|||
TextureBase::TextureBase(DeviceBase* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
TextureState state)
|
||||
: ObjectBase(device, descriptor->label),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mDimension(descriptor->dimension),
|
||||
mFormat(device->GetValidInternalFormat(descriptor->format)),
|
||||
mSize(descriptor->size),
|
||||
|
@ -468,7 +469,7 @@ namespace dawn_native {
|
|||
static Format kUnusedFormat;
|
||||
|
||||
TextureBase::TextureBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag), mFormat(kUnusedFormat) {
|
||||
: ApiObjectBase(device, tag), mFormat(kUnusedFormat) {
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -476,6 +477,10 @@ namespace dawn_native {
|
|||
return new TextureBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType TextureBase::GetType() const {
|
||||
return ObjectType::Texture;
|
||||
}
|
||||
|
||||
wgpu::TextureDimension TextureBase::GetDimension() const {
|
||||
ASSERT(!IsError());
|
||||
return mDimension;
|
||||
|
@ -684,7 +689,7 @@ namespace dawn_native {
|
|||
// TextureViewBase
|
||||
|
||||
TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor)
|
||||
: ObjectBase(texture->GetDevice(), kLabelNotImplemented),
|
||||
: ApiObjectBase(texture->GetDevice(), kLabelNotImplemented),
|
||||
mTexture(texture),
|
||||
mFormat(GetDevice()->GetValidInternalFormat(descriptor->format)),
|
||||
mDimension(descriptor->dimension),
|
||||
|
@ -694,7 +699,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
TextureViewBase::TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag), mFormat(kUnusedFormat) {
|
||||
: ApiObjectBase(device, tag), mFormat(kUnusedFormat) {
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -702,6 +707,10 @@ namespace dawn_native {
|
|||
return new TextureViewBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
ObjectType TextureViewBase::GetType() const {
|
||||
return ObjectType::TextureView;
|
||||
}
|
||||
|
||||
const TextureBase* TextureViewBase::GetTexture() const {
|
||||
ASSERT(!IsError());
|
||||
return mTexture.Get();
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native {
|
|||
static constexpr wgpu::TextureUsage kReadOnlyTextureUsages =
|
||||
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding;
|
||||
|
||||
class TextureBase : public ObjectBase {
|
||||
class TextureBase : public ApiObjectBase {
|
||||
public:
|
||||
enum class TextureState { OwnedInternal, OwnedExternal, Destroyed };
|
||||
enum class ClearValue { Zero, NonZero };
|
||||
|
@ -50,6 +50,8 @@ namespace dawn_native {
|
|||
|
||||
static TextureBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
wgpu::TextureDimension GetDimension() const;
|
||||
const Format& GetFormat() const;
|
||||
const Extent3D& GetSize() const;
|
||||
|
@ -113,12 +115,14 @@ namespace dawn_native {
|
|||
std::vector<bool> mIsSubresourceContentInitializedAtIndex;
|
||||
};
|
||||
|
||||
class TextureViewBase : public ObjectBase {
|
||||
class TextureViewBase : public ApiObjectBase {
|
||||
public:
|
||||
TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor);
|
||||
|
||||
static TextureViewBase* MakeError(DeviceBase* device);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
const TextureBase* GetTexture() const;
|
||||
TextureBase* GetTexture();
|
||||
|
||||
|
|
Loading…
Reference in New Issue