mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-15 09:35:57 +00:00
dawn_native: Prefix all API methods with API
This means that calling wgpu::Object::DoStuff will translate to a call to dawn_native::ObjectBase::APIDoStuff. This will clarify the difference between reentrant calls and internal calls in dawn_native. Avoiding issues in the future. This CL only changes the code generator to prefix with "API", performs renames needed to make the code compile, and adds TODOs for things that should be fixed in follow-up CLs. Bug: dawn:723 Change-Id: Ie24471fa093adc4179d33d13323429847d076ecb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45921 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
b745df8537
commit
2ce4b905b2
@ -64,7 +64,7 @@ namespace dawn_native {
|
|||||||
{% if method.return_type.name.canonical_case() != "void" %}
|
{% if method.return_type.name.canonical_case() != "void" %}
|
||||||
auto result =
|
auto result =
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
self->{{method.name.CamelCase()}}(
|
self->API{{method.name.CamelCase()}}(
|
||||||
{%- for arg in method.arguments -%}
|
{%- for arg in method.arguments -%}
|
||||||
{%- if not loop.first %}, {% endif -%}
|
{%- if not loop.first %}, {% endif -%}
|
||||||
{{as_varName(arg.name)}}_
|
{{as_varName(arg.name)}}_
|
||||||
|
@ -73,6 +73,14 @@ void RefCounted::Release() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RefCounted::APIReference() {
|
||||||
|
Reference();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefCounted::APIRelease() {
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
void RefCounted::DeleteThis() {
|
void RefCounted::DeleteThis() {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,12 @@ class RefCounted {
|
|||||||
uint64_t GetRefCountForTesting() const;
|
uint64_t GetRefCountForTesting() const;
|
||||||
uint64_t GetRefCountPayload() const;
|
uint64_t GetRefCountPayload() const;
|
||||||
|
|
||||||
// Dawn API
|
|
||||||
void Reference();
|
void Reference();
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
|
void APIReference();
|
||||||
|
void APIRelease();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~RefCounted() = default;
|
virtual ~RefCounted() = default;
|
||||||
// A Derived class may override this if they require a custom deleter.
|
// A Derived class may override this if they require a custom deleter.
|
||||||
|
@ -186,11 +186,13 @@ namespace dawn_native {
|
|||||||
|
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
if (device->IsToggleEnabled(Toggle::LazyClearResourceOnFirstUse)) {
|
if (device->IsToggleEnabled(Toggle::LazyClearResourceOnFirstUse)) {
|
||||||
memset(GetMappedRange(0, mSize), uint8_t(0u), mSize);
|
// TODO(dawn:723): propagate any errors from GetMappedRange.
|
||||||
|
memset(APIGetMappedRange(0, mSize), uint8_t(0u), mSize);
|
||||||
SetIsDataInitialized();
|
SetIsDataInitialized();
|
||||||
device->IncrementLazyClearCountForTesting();
|
device->IncrementLazyClearCountForTesting();
|
||||||
} else if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
|
} else if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
|
||||||
memset(GetMappedRange(0, mSize), uint8_t(1u), mSize);
|
// TODO(dawn:723): propagate any errors from GetMappedRange.
|
||||||
|
memset(APIGetMappedRange(0, mSize), uint8_t(1u), mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -252,11 +254,11 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::MapAsync(wgpu::MapMode mode,
|
void BufferBase::APIMapAsync(wgpu::MapMode mode,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
size_t size,
|
size_t size,
|
||||||
WGPUBufferMapCallback callback,
|
WGPUBufferMapCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
// Handle the defaulting of size required by WebGPU, even if in webgpu_cpp.h it is not
|
// Handle the defaulting of size required by WebGPU, even if in webgpu_cpp.h it is not
|
||||||
// possible to default the function argument (because there is the callback later in the
|
// possible to default the function argument (because there is the callback later in the
|
||||||
// argument list)
|
// argument list)
|
||||||
@ -287,15 +289,16 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
std::unique_ptr<MapRequestTask> request =
|
std::unique_ptr<MapRequestTask> request =
|
||||||
std::make_unique<MapRequestTask>(this, mLastMapID);
|
std::make_unique<MapRequestTask>(this, mLastMapID);
|
||||||
GetDevice()->GetQueue()->TrackTask(std::move(request),
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
GetDevice()->GetPendingCommandSerial());
|
GetDevice()->APIGetQueue()->TrackTask(std::move(request),
|
||||||
|
GetDevice()->GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
void* BufferBase::GetMappedRange(size_t offset, size_t size) {
|
void* BufferBase::APIGetMappedRange(size_t offset, size_t size) {
|
||||||
return GetMappedRangeInternal(true, offset, size);
|
return GetMappedRangeInternal(true, offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* BufferBase::GetConstMappedRange(size_t offset, size_t size) {
|
const void* BufferBase::APIGetConstMappedRange(size_t offset, size_t size) {
|
||||||
return GetMappedRangeInternal(false, offset, size);
|
return GetMappedRangeInternal(false, offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +317,7 @@ namespace dawn_native {
|
|||||||
return start == nullptr ? nullptr : start + offset;
|
return start == nullptr ? nullptr : start + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::Destroy() {
|
void BufferBase::APIDestroy() {
|
||||||
if (IsError()) {
|
if (IsError()) {
|
||||||
// It is an error to call Destroy() on an ErrorBuffer, but we still need to reclaim the
|
// It is an error to call Destroy() on an ErrorBuffer, but we still need to reclaim the
|
||||||
// fake mapped staging data.
|
// fake mapped staging data.
|
||||||
@ -354,7 +357,7 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::Unmap() {
|
void BufferBase::APIUnmap() {
|
||||||
UnmapInternal(WGPUBufferMapAsyncStatus_UnmappedBeforeCallback);
|
UnmapInternal(WGPUBufferMapAsyncStatus_UnmappedBeforeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,15 +62,15 @@ namespace dawn_native {
|
|||||||
void SetIsDataInitialized();
|
void SetIsDataInitialized();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void MapAsync(wgpu::MapMode mode,
|
void APIMapAsync(wgpu::MapMode mode,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
size_t size,
|
size_t size,
|
||||||
WGPUBufferMapCallback callback,
|
WGPUBufferMapCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void* GetMappedRange(size_t offset, size_t size);
|
void* APIGetMappedRange(size_t offset, size_t size);
|
||||||
const void* GetConstMappedRange(size_t offset, size_t size);
|
const void* APIGetConstMappedRange(size_t offset, size_t size);
|
||||||
void Unmap();
|
void APIUnmap();
|
||||||
void Destroy();
|
void APIDestroy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BufferBase(DeviceBase* device,
|
BufferBase(DeviceBase* device,
|
||||||
|
@ -416,10 +416,13 @@ namespace dawn_native {
|
|||||||
BufferDescriptor availabilityDesc = {};
|
BufferDescriptor availabilityDesc = {};
|
||||||
availabilityDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst;
|
availabilityDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst;
|
||||||
availabilityDesc.size = querySet->GetQueryCount() * sizeof(uint32_t);
|
availabilityDesc.size = querySet->GetQueryCount() * sizeof(uint32_t);
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
Ref<BufferBase> availabilityBuffer =
|
Ref<BufferBase> availabilityBuffer =
|
||||||
AcquireRef(device->CreateBuffer(&availabilityDesc));
|
AcquireRef(device->APICreateBuffer(&availabilityDesc));
|
||||||
device->GetQueue()->WriteBuffer(availabilityBuffer.Get(), 0, availability.data(),
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
availability.size() * sizeof(uint32_t));
|
// TODO(dawn:723): propagate any errors from WriteBuffer.
|
||||||
|
device->APIGetQueue()->APIWriteBuffer(availabilityBuffer.Get(), 0, availability.data(),
|
||||||
|
availability.size() * sizeof(uint32_t));
|
||||||
|
|
||||||
// Timestamp params uniform buffer
|
// Timestamp params uniform buffer
|
||||||
TimestampParams params = {queryCount, static_cast<uint32_t>(destinationOffset),
|
TimestampParams params = {queryCount, static_cast<uint32_t>(destinationOffset),
|
||||||
@ -427,8 +430,11 @@ namespace dawn_native {
|
|||||||
BufferDescriptor parmsDesc = {};
|
BufferDescriptor parmsDesc = {};
|
||||||
parmsDesc.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst;
|
parmsDesc.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst;
|
||||||
parmsDesc.size = sizeof(params);
|
parmsDesc.size = sizeof(params);
|
||||||
Ref<BufferBase> paramsBuffer = AcquireRef(device->CreateBuffer(&parmsDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
device->GetQueue()->WriteBuffer(paramsBuffer.Get(), 0, ¶ms, sizeof(params));
|
Ref<BufferBase> paramsBuffer = AcquireRef(device->APICreateBuffer(&parmsDesc));
|
||||||
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
|
// TODO(dawn:723): propagate any errors from WriteBuffer.
|
||||||
|
device->APIGetQueue()->APIWriteBuffer(paramsBuffer.Get(), 0, ¶ms, sizeof(params));
|
||||||
|
|
||||||
EncodeConvertTimestampsToNanoseconds(encoder, destination, availabilityBuffer.Get(),
|
EncodeConvertTimestampsToNanoseconds(encoder, destination, availabilityBuffer.Get(),
|
||||||
paramsBuffer.Get());
|
paramsBuffer.Get());
|
||||||
@ -476,7 +482,8 @@ namespace dawn_native {
|
|||||||
|
|
||||||
// Implementation of the API's command recording methods
|
// Implementation of the API's command recording methods
|
||||||
|
|
||||||
ComputePassEncoder* CommandEncoder::BeginComputePass(const ComputePassDescriptor* descriptor) {
|
ComputePassEncoder* CommandEncoder::APIBeginComputePass(
|
||||||
|
const ComputePassDescriptor* descriptor) {
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
|
|
||||||
bool success =
|
bool success =
|
||||||
@ -498,7 +505,7 @@ namespace dawn_native {
|
|||||||
return ComputePassEncoder::MakeError(device, this, &mEncodingContext);
|
return ComputePassEncoder::MakeError(device, this, &mEncodingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPassEncoder* CommandEncoder::BeginRenderPass(const RenderPassDescriptor* descriptor) {
|
RenderPassEncoder* CommandEncoder::APIBeginRenderPass(const RenderPassDescriptor* descriptor) {
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
|
|
||||||
PassResourceUsageTracker usageTracker(PassType::Render);
|
PassResourceUsageTracker usageTracker(PassType::Render);
|
||||||
@ -581,11 +588,11 @@ namespace dawn_native {
|
|||||||
return RenderPassEncoder::MakeError(device, this, &mEncodingContext);
|
return RenderPassEncoder::MakeError(device, this, &mEncodingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::CopyBufferToBuffer(BufferBase* source,
|
void CommandEncoder::APICopyBufferToBuffer(BufferBase* source,
|
||||||
uint64_t sourceOffset,
|
uint64_t sourceOffset,
|
||||||
BufferBase* destination,
|
BufferBase* destination,
|
||||||
uint64_t destinationOffset,
|
uint64_t destinationOffset,
|
||||||
uint64_t size) {
|
uint64_t size) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(source));
|
DAWN_TRY(GetDevice()->ValidateObject(source));
|
||||||
@ -622,9 +629,9 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::CopyBufferToTexture(const ImageCopyBuffer* source,
|
void CommandEncoder::APICopyBufferToTexture(const ImageCopyBuffer* source,
|
||||||
const ImageCopyTexture* destination,
|
const ImageCopyTexture* destination,
|
||||||
const Extent3D* copySize) {
|
const Extent3D* copySize) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
Extent3D fixedCopySize = *copySize;
|
Extent3D fixedCopySize = *copySize;
|
||||||
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
||||||
@ -681,9 +688,9 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::CopyTextureToBuffer(const ImageCopyTexture* source,
|
void CommandEncoder::APICopyTextureToBuffer(const ImageCopyTexture* source,
|
||||||
const ImageCopyBuffer* destination,
|
const ImageCopyBuffer* destination,
|
||||||
const Extent3D* copySize) {
|
const Extent3D* copySize) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
Extent3D fixedCopySize = *copySize;
|
Extent3D fixedCopySize = *copySize;
|
||||||
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
||||||
@ -739,9 +746,9 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::CopyTextureToTexture(const ImageCopyTexture* source,
|
void CommandEncoder::APICopyTextureToTexture(const ImageCopyTexture* source,
|
||||||
const ImageCopyTexture* destination,
|
const ImageCopyTexture* destination,
|
||||||
const Extent3D* copySize) {
|
const Extent3D* copySize) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
Extent3D fixedCopySize = *copySize;
|
Extent3D fixedCopySize = *copySize;
|
||||||
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize));
|
||||||
@ -786,13 +793,13 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::InjectValidationError(const char* message) {
|
void CommandEncoder::APIInjectValidationError(const char* message) {
|
||||||
if (mEncodingContext.CheckCurrentEncoder(this)) {
|
if (mEncodingContext.CheckCurrentEncoder(this)) {
|
||||||
mEncodingContext.HandleError(InternalErrorType::Validation, message);
|
mEncodingContext.HandleError(InternalErrorType::Validation, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::InsertDebugMarker(const char* groupLabel) {
|
void CommandEncoder::APIInsertDebugMarker(const char* groupLabel) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
InsertDebugMarkerCmd* cmd =
|
InsertDebugMarkerCmd* cmd =
|
||||||
allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker);
|
allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker);
|
||||||
@ -805,7 +812,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::PopDebugGroup() {
|
void CommandEncoder::APIPopDebugGroup() {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
if (mDebugGroupStackSize == 0) {
|
if (mDebugGroupStackSize == 0) {
|
||||||
@ -819,7 +826,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::PushDebugGroup(const char* groupLabel) {
|
void CommandEncoder::APIPushDebugGroup(const char* groupLabel) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
PushDebugGroupCmd* cmd =
|
PushDebugGroupCmd* cmd =
|
||||||
allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup);
|
allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup);
|
||||||
@ -834,11 +841,11 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::ResolveQuerySet(QuerySetBase* querySet,
|
void CommandEncoder::APIResolveQuerySet(QuerySetBase* querySet,
|
||||||
uint32_t firstQuery,
|
uint32_t firstQuery,
|
||||||
uint32_t queryCount,
|
uint32_t queryCount,
|
||||||
BufferBase* destination,
|
BufferBase* destination,
|
||||||
uint64_t destinationOffset) {
|
uint64_t destinationOffset) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
||||||
@ -872,7 +879,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
void CommandEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
||||||
@ -890,7 +897,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBufferBase* CommandEncoder::Finish(const CommandBufferDescriptor* descriptor) {
|
CommandBufferBase* CommandEncoder::APIFinish(const CommandBufferDescriptor* descriptor) {
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
// Even if mEncodingContext.Finish() validation fails, calling it will mutate the internal
|
// Even if mEncodingContext.Finish() validation fails, calling it will mutate the internal
|
||||||
// state of the encoding context. The internal state is set to finished, and subsequent
|
// state of the encoding context. The internal state is set to finished, and subsequent
|
||||||
|
@ -41,37 +41,37 @@ namespace dawn_native {
|
|||||||
const QueryAvailabilityMap& GetQueryAvailabilityMap() const;
|
const QueryAvailabilityMap& GetQueryAvailabilityMap() const;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
ComputePassEncoder* BeginComputePass(const ComputePassDescriptor* descriptor);
|
ComputePassEncoder* APIBeginComputePass(const ComputePassDescriptor* descriptor);
|
||||||
RenderPassEncoder* BeginRenderPass(const RenderPassDescriptor* descriptor);
|
RenderPassEncoder* APIBeginRenderPass(const RenderPassDescriptor* descriptor);
|
||||||
|
|
||||||
void CopyBufferToBuffer(BufferBase* source,
|
void APICopyBufferToBuffer(BufferBase* source,
|
||||||
uint64_t sourceOffset,
|
uint64_t sourceOffset,
|
||||||
|
BufferBase* destination,
|
||||||
|
uint64_t destinationOffset,
|
||||||
|
uint64_t size);
|
||||||
|
void APICopyBufferToTexture(const ImageCopyBuffer* source,
|
||||||
|
const ImageCopyTexture* destination,
|
||||||
|
const Extent3D* copySize);
|
||||||
|
void APICopyTextureToBuffer(const ImageCopyTexture* source,
|
||||||
|
const ImageCopyBuffer* destination,
|
||||||
|
const Extent3D* copySize);
|
||||||
|
void APICopyTextureToTexture(const ImageCopyTexture* source,
|
||||||
|
const ImageCopyTexture* destination,
|
||||||
|
const Extent3D* copySize);
|
||||||
|
|
||||||
|
void APIInjectValidationError(const char* message);
|
||||||
|
void APIInsertDebugMarker(const char* groupLabel);
|
||||||
|
void APIPopDebugGroup();
|
||||||
|
void APIPushDebugGroup(const char* groupLabel);
|
||||||
|
|
||||||
|
void APIResolveQuerySet(QuerySetBase* querySet,
|
||||||
|
uint32_t firstQuery,
|
||||||
|
uint32_t queryCount,
|
||||||
BufferBase* destination,
|
BufferBase* destination,
|
||||||
uint64_t destinationOffset,
|
uint64_t destinationOffset);
|
||||||
uint64_t size);
|
void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
||||||
void CopyBufferToTexture(const ImageCopyBuffer* source,
|
|
||||||
const ImageCopyTexture* destination,
|
|
||||||
const Extent3D* copySize);
|
|
||||||
void CopyTextureToBuffer(const ImageCopyTexture* source,
|
|
||||||
const ImageCopyBuffer* destination,
|
|
||||||
const Extent3D* copySize);
|
|
||||||
void CopyTextureToTexture(const ImageCopyTexture* source,
|
|
||||||
const ImageCopyTexture* destination,
|
|
||||||
const Extent3D* copySize);
|
|
||||||
|
|
||||||
void InjectValidationError(const char* message);
|
CommandBufferBase* APIFinish(const CommandBufferDescriptor* descriptor = nullptr);
|
||||||
void InsertDebugMarker(const char* groupLabel);
|
|
||||||
void PopDebugGroup();
|
|
||||||
void PushDebugGroup(const char* groupLabel);
|
|
||||||
|
|
||||||
void ResolveQuerySet(QuerySetBase* querySet,
|
|
||||||
uint32_t firstQuery,
|
|
||||||
uint32_t queryCount,
|
|
||||||
BufferBase* destination,
|
|
||||||
uint64_t destinationOffset);
|
|
||||||
void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
|
||||||
|
|
||||||
CommandBufferBase* Finish(const CommandBufferDescriptor* descriptor = nullptr);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError ValidateFinish(CommandIterator* commands,
|
MaybeError ValidateFinish(CommandIterator* commands,
|
||||||
|
@ -45,7 +45,7 @@ namespace dawn_native {
|
|||||||
return new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
|
return new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::EndPass() {
|
void ComputePassEncoder::APIEndPass() {
|
||||||
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateProgrammableEncoderEnd());
|
DAWN_TRY(ValidateProgrammableEncoderEnd());
|
||||||
@ -59,7 +59,7 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
|
void ComputePassEncoder::APIDispatch(uint32_t x, uint32_t y, uint32_t z) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(mCommandBufferState.ValidateCanDispatch());
|
DAWN_TRY(mCommandBufferState.ValidateCanDispatch());
|
||||||
@ -78,7 +78,8 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
void ComputePassEncoder::APIDispatchIndirect(BufferBase* indirectBuffer,
|
||||||
|
uint64_t indirectOffset) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||||
@ -116,7 +117,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::SetPipeline(ComputePipelineBase* pipeline) {
|
void ComputePassEncoder::APISetPipeline(ComputePipelineBase* pipeline) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
|
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
|
||||||
@ -132,7 +133,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
void ComputePassEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
||||||
|
@ -30,13 +30,13 @@ namespace dawn_native {
|
|||||||
CommandEncoder* commandEncoder,
|
CommandEncoder* commandEncoder,
|
||||||
EncodingContext* encodingContext);
|
EncodingContext* encodingContext);
|
||||||
|
|
||||||
void EndPass();
|
void APIEndPass();
|
||||||
|
|
||||||
void Dispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1);
|
void APIDispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1);
|
||||||
void DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
void APIDispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
void SetPipeline(ComputePipelineBase* pipeline);
|
void APISetPipeline(ComputePipelineBase* pipeline);
|
||||||
|
|
||||||
void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComputePassEncoder(DeviceBase* device,
|
ComputePassEncoder(DeviceBase* device,
|
||||||
|
@ -137,8 +137,9 @@ namespace dawn_native {
|
|||||||
wgslDesc.source = sCopyTextureForBrowserVertex;
|
wgslDesc.source = sCopyTextureForBrowserVertex;
|
||||||
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
||||||
|
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
store->copyTextureForBrowserVS =
|
store->copyTextureForBrowserVS =
|
||||||
AcquireRef(device->CreateShaderModule(&descriptor));
|
AcquireRef(device->APICreateShaderModule(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderModuleBase* vertexModule = store->copyTextureForBrowserVS.Get();
|
ShaderModuleBase* vertexModule = store->copyTextureForBrowserVS.Get();
|
||||||
@ -149,8 +150,9 @@ namespace dawn_native {
|
|||||||
ShaderModuleWGSLDescriptor wgslDesc;
|
ShaderModuleWGSLDescriptor wgslDesc;
|
||||||
wgslDesc.source = sCopyTextureForBrowserFragment;
|
wgslDesc.source = sCopyTextureForBrowserFragment;
|
||||||
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
store->copyTextureForBrowserFS =
|
store->copyTextureForBrowserFS =
|
||||||
AcquireRef(device->CreateShaderModule(&descriptor));
|
AcquireRef(device->APICreateShaderModule(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderModuleBase* fragmentModule = store->copyTextureForBrowserFS.Get();
|
ShaderModuleBase* fragmentModule = store->copyTextureForBrowserFS.Get();
|
||||||
@ -183,8 +185,9 @@ namespace dawn_native {
|
|||||||
fragment.targetCount = 1;
|
fragment.targetCount = 1;
|
||||||
fragment.targets = ⌖
|
fragment.targets = ⌖
|
||||||
|
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
store->copyTextureForBrowserPipelines.insert(
|
store->copyTextureForBrowserPipelines.insert(
|
||||||
{dstFormat, AcquireRef(device->CreateRenderPipeline2(&renderPipelineDesc))});
|
{dstFormat, AcquireRef(device->APICreateRenderPipeline2(&renderPipelineDesc))});
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetCachedPipeline(store, dstFormat);
|
return GetCachedPipeline(store, dstFormat);
|
||||||
@ -242,7 +245,8 @@ namespace dawn_native {
|
|||||||
device, destination->texture->GetFormat().format);
|
device, destination->texture->GetFormat().format);
|
||||||
|
|
||||||
// Prepare bind group layout.
|
// Prepare bind group layout.
|
||||||
Ref<BindGroupLayoutBase> layout = AcquireRef(pipeline->GetBindGroupLayout(0));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<BindGroupLayoutBase> layout = AcquireRef(pipeline->APIGetBindGroupLayout(0));
|
||||||
|
|
||||||
// Prepare bind group descriptor
|
// Prepare bind group descriptor
|
||||||
BindGroupEntry bindGroupEntries[3] = {};
|
BindGroupEntry bindGroupEntries[3] = {};
|
||||||
@ -266,21 +270,27 @@ namespace dawn_native {
|
|||||||
BufferDescriptor uniformDesc = {};
|
BufferDescriptor uniformDesc = {};
|
||||||
uniformDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
uniformDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
||||||
uniformDesc.size = sizeof(uniformData);
|
uniformDesc.size = sizeof(uniformData);
|
||||||
Ref<BufferBase> uniformBuffer = AcquireRef(device->CreateBuffer(&uniformDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<BufferBase> uniformBuffer = AcquireRef(device->APICreateBuffer(&uniformDesc));
|
||||||
|
|
||||||
device->GetQueue()->WriteBuffer(uniformBuffer.Get(), 0, uniformData, sizeof(uniformData));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
// TODO(dawn:723): propagate any errors from WriteBuffer.
|
||||||
|
device->APIGetQueue()->APIWriteBuffer(uniformBuffer.Get(), 0, uniformData,
|
||||||
|
sizeof(uniformData));
|
||||||
|
|
||||||
// Prepare binding 1 resource: sampler
|
// Prepare binding 1 resource: sampler
|
||||||
// Use default configuration, filterMode set to Nearest for min and mag.
|
// Use default configuration, filterMode set to Nearest for min and mag.
|
||||||
SamplerDescriptor samplerDesc = {};
|
SamplerDescriptor samplerDesc = {};
|
||||||
Ref<SamplerBase> sampler = AcquireRef(device->CreateSampler(&samplerDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<SamplerBase> sampler = AcquireRef(device->APICreateSampler(&samplerDesc));
|
||||||
|
|
||||||
// Prepare binding 2 resource: sampled texture
|
// Prepare binding 2 resource: sampled texture
|
||||||
TextureViewDescriptor srcTextureViewDesc = {};
|
TextureViewDescriptor srcTextureViewDesc = {};
|
||||||
srcTextureViewDesc.baseMipLevel = source->mipLevel;
|
srcTextureViewDesc.baseMipLevel = source->mipLevel;
|
||||||
srcTextureViewDesc.mipLevelCount = 1;
|
srcTextureViewDesc.mipLevelCount = 1;
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
Ref<TextureViewBase> srcTextureView =
|
Ref<TextureViewBase> srcTextureView =
|
||||||
AcquireRef(source->texture->CreateView(&srcTextureViewDesc));
|
AcquireRef(source->texture->APICreateView(&srcTextureViewDesc));
|
||||||
|
|
||||||
// Set bind group entries.
|
// Set bind group entries.
|
||||||
bindGroupEntries[0].binding = 0;
|
bindGroupEntries[0].binding = 0;
|
||||||
@ -292,18 +302,21 @@ namespace dawn_native {
|
|||||||
bindGroupEntries[2].textureView = srcTextureView.Get();
|
bindGroupEntries[2].textureView = srcTextureView.Get();
|
||||||
|
|
||||||
// Create bind group after all binding entries are set.
|
// Create bind group after all binding entries are set.
|
||||||
Ref<BindGroupBase> bindGroup = AcquireRef(device->CreateBindGroup(&bgDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<BindGroupBase> bindGroup = AcquireRef(device->APICreateBindGroup(&bgDesc));
|
||||||
|
|
||||||
// Create command encoder.
|
// Create command encoder.
|
||||||
CommandEncoderDescriptor encoderDesc = {};
|
CommandEncoderDescriptor encoderDesc = {};
|
||||||
Ref<CommandEncoder> encoder = AcquireRef(device->CreateCommandEncoder(&encoderDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<CommandEncoder> encoder = AcquireRef(device->APICreateCommandEncoder(&encoderDesc));
|
||||||
|
|
||||||
// Prepare dst texture view as color Attachment.
|
// Prepare dst texture view as color Attachment.
|
||||||
TextureViewDescriptor dstTextureViewDesc;
|
TextureViewDescriptor dstTextureViewDesc;
|
||||||
dstTextureViewDesc.baseMipLevel = destination->mipLevel;
|
dstTextureViewDesc.baseMipLevel = destination->mipLevel;
|
||||||
dstTextureViewDesc.mipLevelCount = 1;
|
dstTextureViewDesc.mipLevelCount = 1;
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
Ref<TextureViewBase> dstView =
|
Ref<TextureViewBase> dstView =
|
||||||
AcquireRef(destination->texture->CreateView(&dstTextureViewDesc));
|
AcquireRef(destination->texture->APICreateView(&dstTextureViewDesc));
|
||||||
|
|
||||||
// Prepare render pass color attachment descriptor.
|
// Prepare render pass color attachment descriptor.
|
||||||
RenderPassColorAttachmentDescriptor colorAttachmentDesc;
|
RenderPassColorAttachmentDescriptor colorAttachmentDesc;
|
||||||
@ -317,22 +330,26 @@ namespace dawn_native {
|
|||||||
RenderPassDescriptor renderPassDesc;
|
RenderPassDescriptor renderPassDesc;
|
||||||
renderPassDesc.colorAttachmentCount = 1;
|
renderPassDesc.colorAttachmentCount = 1;
|
||||||
renderPassDesc.colorAttachments = &colorAttachmentDesc;
|
renderPassDesc.colorAttachments = &colorAttachmentDesc;
|
||||||
Ref<RenderPassEncoder> passEncoder = AcquireRef(encoder->BeginRenderPass(&renderPassDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<RenderPassEncoder> passEncoder =
|
||||||
|
AcquireRef(encoder->APIBeginRenderPass(&renderPassDesc));
|
||||||
|
|
||||||
// Start pipeline and encode commands to complete
|
// Start pipeline and encode commands to complete
|
||||||
// the copy from src texture to dst texture with transformation.
|
// the copy from src texture to dst texture with transformation.
|
||||||
passEncoder->SetPipeline(pipeline);
|
passEncoder->APISetPipeline(pipeline);
|
||||||
passEncoder->SetBindGroup(0, bindGroup.Get());
|
passEncoder->APISetBindGroup(0, bindGroup.Get());
|
||||||
passEncoder->Draw(3);
|
passEncoder->APIDraw(3);
|
||||||
passEncoder->EndPass();
|
passEncoder->APIEndPass();
|
||||||
|
|
||||||
// Finsh encoding.
|
// Finsh encoding.
|
||||||
Ref<CommandBufferBase> commandBuffer = AcquireRef(encoder->Finish());
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<CommandBufferBase> commandBuffer = AcquireRef(encoder->APIFinish());
|
||||||
CommandBufferBase* submitCommandBuffer = commandBuffer.Get();
|
CommandBufferBase* submitCommandBuffer = commandBuffer.Get();
|
||||||
|
|
||||||
// Submit command buffer.
|
// Submit command buffer.
|
||||||
Ref<QueueBase> queue = AcquireRef(device->GetQueue());
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
queue->Submit(1, &submitCommandBuffer);
|
Ref<QueueBase> queue = AcquireRef(device->APIGetQueue());
|
||||||
|
queue->APISubmit(1, &submitCommandBuffer);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device) {
|
DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device) {
|
||||||
dawn_native::DeviceBase* deviceBase = reinterpret_cast<dawn_native::DeviceBase*>(device);
|
dawn_native::DeviceBase* deviceBase = reinterpret_cast<dawn_native::DeviceBase*>(device);
|
||||||
return deviceBase->Tick();
|
return deviceBase->APITick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExternalImageDescriptor
|
// ExternalImageDescriptor
|
||||||
|
@ -176,7 +176,8 @@ namespace dawn_native {
|
|||||||
// Tick the queue-related tasks since they should be complete. This must be done before
|
// Tick the queue-related tasks since they should be complete. This must be done before
|
||||||
// ShutDownImpl() it may relinquish resources that will be freed by backends in the
|
// ShutDownImpl() it may relinquish resources that will be freed by backends in the
|
||||||
// ShutDownImpl() call.
|
// ShutDownImpl() call.
|
||||||
GetQueue()->Tick(GetCompletedCommandSerial());
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
|
APIGetQueue()->Tick(GetCompletedCommandSerial());
|
||||||
// Call TickImpl once last time to clean up resources
|
// Call TickImpl once last time to clean up resources
|
||||||
// Ignore errors so that we can continue with destruction
|
// Ignore errors so that we can continue with destruction
|
||||||
IgnoreErrors(TickImpl());
|
IgnoreErrors(TickImpl());
|
||||||
@ -251,7 +252,7 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::InjectError(wgpu::ErrorType type, const char* message) {
|
void DeviceBase::APIInjectError(wgpu::ErrorType type, const char* message) {
|
||||||
if (ConsumedError(ValidateErrorType(type))) {
|
if (ConsumedError(ValidateErrorType(type))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -278,24 +279,24 @@ namespace dawn_native {
|
|||||||
HandleError(error->GetType(), ss.str().c_str());
|
HandleError(error->GetType(), ss.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) {
|
void DeviceBase::APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) {
|
||||||
mUncapturedErrorCallback = callback;
|
mUncapturedErrorCallback = callback;
|
||||||
mUncapturedErrorUserdata = userdata;
|
mUncapturedErrorUserdata = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::SetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata) {
|
void DeviceBase::APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata) {
|
||||||
mDeviceLostCallback = callback;
|
mDeviceLostCallback = callback;
|
||||||
mDeviceLostUserdata = userdata;
|
mDeviceLostUserdata = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::PushErrorScope(wgpu::ErrorFilter filter) {
|
void DeviceBase::APIPushErrorScope(wgpu::ErrorFilter filter) {
|
||||||
if (ConsumedError(ValidateErrorFilter(filter))) {
|
if (ConsumedError(ValidateErrorFilter(filter))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mErrorScopeStack->Push(filter);
|
mErrorScopeStack->Push(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceBase::PopErrorScope(wgpu::ErrorCallback callback, void* userdata) {
|
bool DeviceBase::APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata) {
|
||||||
if (mErrorScopeStack->Empty()) {
|
if (mErrorScopeStack->Empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -331,7 +332,7 @@ namespace dawn_native {
|
|||||||
return DAWN_VALIDATION_ERROR("Device is lost");
|
return DAWN_VALIDATION_ERROR("Device is lost");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::LoseForTesting() {
|
void DeviceBase::APILoseForTesting() {
|
||||||
if (mState != State::Alive) {
|
if (mState != State::Alive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -664,7 +665,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
// Object creation API methods
|
// Object creation API methods
|
||||||
|
|
||||||
BindGroupBase* DeviceBase::CreateBindGroup(const BindGroupDescriptor* descriptor) {
|
BindGroupBase* DeviceBase::APICreateBindGroup(const BindGroupDescriptor* descriptor) {
|
||||||
BindGroupBase* result = nullptr;
|
BindGroupBase* result = nullptr;
|
||||||
|
|
||||||
if (ConsumedError(CreateBindGroupInternal(&result, descriptor))) {
|
if (ConsumedError(CreateBindGroupInternal(&result, descriptor))) {
|
||||||
@ -673,7 +674,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout(
|
BindGroupLayoutBase* DeviceBase::APICreateBindGroupLayout(
|
||||||
const BindGroupLayoutDescriptor* descriptor) {
|
const BindGroupLayoutDescriptor* descriptor) {
|
||||||
BindGroupLayoutBase* result = nullptr;
|
BindGroupLayoutBase* result = nullptr;
|
||||||
|
|
||||||
@ -683,7 +684,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
BufferBase* DeviceBase::CreateBuffer(const BufferDescriptor* descriptor) {
|
BufferBase* DeviceBase::APICreateBuffer(const BufferDescriptor* descriptor) {
|
||||||
Ref<BufferBase> result = nullptr;
|
Ref<BufferBase> result = nullptr;
|
||||||
if (ConsumedError(CreateBufferInternal(descriptor), &result)) {
|
if (ConsumedError(CreateBufferInternal(descriptor), &result)) {
|
||||||
ASSERT(result == nullptr);
|
ASSERT(result == nullptr);
|
||||||
@ -692,10 +693,11 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result.Detach();
|
return result.Detach();
|
||||||
}
|
}
|
||||||
CommandEncoder* DeviceBase::CreateCommandEncoder(const CommandEncoderDescriptor* descriptor) {
|
CommandEncoder* DeviceBase::APICreateCommandEncoder(
|
||||||
|
const CommandEncoderDescriptor* descriptor) {
|
||||||
return new CommandEncoder(this, descriptor);
|
return new CommandEncoder(this, descriptor);
|
||||||
}
|
}
|
||||||
ComputePipelineBase* DeviceBase::CreateComputePipeline(
|
ComputePipelineBase* DeviceBase::APICreateComputePipeline(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
ComputePipelineBase* result = nullptr;
|
ComputePipelineBase* result = nullptr;
|
||||||
|
|
||||||
@ -705,9 +707,9 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void DeviceBase::CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
ComputePipelineBase* result = nullptr;
|
ComputePipelineBase* result = nullptr;
|
||||||
|
|
||||||
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||||
@ -730,7 +732,7 @@ namespace dawn_native {
|
|||||||
std::make_unique<CreateComputePipelineAsyncTask>(result, callback, userdata);
|
std::make_unique<CreateComputePipelineAsyncTask>(result, callback, userdata);
|
||||||
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
|
PipelineLayoutBase* DeviceBase::APICreatePipelineLayout(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
PipelineLayoutBase* result = nullptr;
|
PipelineLayoutBase* result = nullptr;
|
||||||
|
|
||||||
@ -740,7 +742,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
QuerySetBase* DeviceBase::CreateQuerySet(const QuerySetDescriptor* descriptor) {
|
QuerySetBase* DeviceBase::APICreateQuerySet(const QuerySetDescriptor* descriptor) {
|
||||||
QuerySetBase* result = nullptr;
|
QuerySetBase* result = nullptr;
|
||||||
|
|
||||||
if (ConsumedError(CreateQuerySetInternal(&result, descriptor))) {
|
if (ConsumedError(CreateQuerySetInternal(&result, descriptor))) {
|
||||||
@ -749,7 +751,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
SamplerBase* DeviceBase::CreateSampler(const SamplerDescriptor* descriptor) {
|
SamplerBase* DeviceBase::APICreateSampler(const SamplerDescriptor* descriptor) {
|
||||||
SamplerBase* result = nullptr;
|
SamplerBase* result = nullptr;
|
||||||
|
|
||||||
if (ConsumedError(CreateSamplerInternal(&result, descriptor))) {
|
if (ConsumedError(CreateSamplerInternal(&result, descriptor))) {
|
||||||
@ -758,9 +760,9 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void DeviceBase::CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
|
void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
RenderPipelineBase* result = nullptr;
|
RenderPipelineBase* result = nullptr;
|
||||||
|
|
||||||
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||||
@ -783,7 +785,7 @@ namespace dawn_native {
|
|||||||
std::make_unique<CreateRenderPipelineAsyncTask>(result, callback, userdata);
|
std::make_unique<CreateRenderPipelineAsyncTask>(result, callback, userdata);
|
||||||
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
RenderBundleEncoder* DeviceBase::CreateRenderBundleEncoder(
|
RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder(
|
||||||
const RenderBundleEncoderDescriptor* descriptor) {
|
const RenderBundleEncoderDescriptor* descriptor) {
|
||||||
RenderBundleEncoder* result = nullptr;
|
RenderBundleEncoder* result = nullptr;
|
||||||
|
|
||||||
@ -793,7 +795,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
RenderPipelineBase* DeviceBase::CreateRenderPipeline(
|
RenderPipelineBase* DeviceBase::APICreateRenderPipeline(
|
||||||
const RenderPipelineDescriptor* descriptor) {
|
const RenderPipelineDescriptor* descriptor) {
|
||||||
RenderPipelineBase* result = nullptr;
|
RenderPipelineBase* result = nullptr;
|
||||||
|
|
||||||
@ -809,7 +811,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
RenderPipelineBase* DeviceBase::CreateRenderPipeline2(
|
RenderPipelineBase* DeviceBase::APICreateRenderPipeline2(
|
||||||
const RenderPipelineDescriptor2* descriptor) {
|
const RenderPipelineDescriptor2* descriptor) {
|
||||||
RenderPipelineBase* result = nullptr;
|
RenderPipelineBase* result = nullptr;
|
||||||
|
|
||||||
@ -819,7 +821,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
ShaderModuleBase* DeviceBase::CreateShaderModule(const ShaderModuleDescriptor* descriptor) {
|
ShaderModuleBase* DeviceBase::APICreateShaderModule(const ShaderModuleDescriptor* descriptor) {
|
||||||
ShaderModuleBase* result = nullptr;
|
ShaderModuleBase* result = nullptr;
|
||||||
|
|
||||||
if (ConsumedError(CreateShaderModuleInternal(&result, descriptor))) {
|
if (ConsumedError(CreateShaderModuleInternal(&result, descriptor))) {
|
||||||
@ -828,8 +830,8 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
SwapChainBase* DeviceBase::CreateSwapChain(Surface* surface,
|
SwapChainBase* DeviceBase::APICreateSwapChain(Surface* surface,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
SwapChainBase* result = nullptr;
|
SwapChainBase* result = nullptr;
|
||||||
|
|
||||||
if (ConsumedError(CreateSwapChainInternal(&result, surface, descriptor))) {
|
if (ConsumedError(CreateSwapChainInternal(&result, surface, descriptor))) {
|
||||||
@ -838,7 +840,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
TextureBase* DeviceBase::CreateTexture(const TextureDescriptor* descriptor) {
|
TextureBase* DeviceBase::APICreateTexture(const TextureDescriptor* descriptor) {
|
||||||
Ref<TextureBase> result;
|
Ref<TextureBase> result;
|
||||||
|
|
||||||
if (ConsumedError(CreateTextureInternal(descriptor), &result)) {
|
if (ConsumedError(CreateTextureInternal(descriptor), &result)) {
|
||||||
@ -860,7 +862,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
// For Dawn Wire
|
// For Dawn Wire
|
||||||
|
|
||||||
BufferBase* DeviceBase::CreateErrorBuffer() {
|
BufferBase* DeviceBase::APICreateErrorBuffer() {
|
||||||
BufferDescriptor desc = {};
|
BufferDescriptor desc = {};
|
||||||
return BufferBase::MakeError(this, &desc);
|
return BufferBase::MakeError(this, &desc);
|
||||||
}
|
}
|
||||||
@ -868,7 +870,7 @@ namespace dawn_native {
|
|||||||
// Other Device API methods
|
// Other Device API methods
|
||||||
|
|
||||||
// Returns true if future ticking is needed.
|
// Returns true if future ticking is needed.
|
||||||
bool DeviceBase::Tick() {
|
bool DeviceBase::APITick() {
|
||||||
if (ConsumedError(ValidateIsAlive())) {
|
if (ConsumedError(ValidateIsAlive())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -894,7 +896,8 @@ namespace dawn_native {
|
|||||||
// tick the dynamic uploader before the backend resource allocators. This would allow
|
// tick the dynamic uploader before the backend resource allocators. This would allow
|
||||||
// reclaiming resources one tick earlier.
|
// reclaiming resources one tick earlier.
|
||||||
mDynamicUploader->Deallocate(mCompletedSerial);
|
mDynamicUploader->Deallocate(mCompletedSerial);
|
||||||
GetQueue()->Tick(mCompletedSerial);
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
|
APIGetQueue()->Tick(mCompletedSerial);
|
||||||
|
|
||||||
mCreatePipelineAsyncTracker->Tick(mCompletedSerial);
|
mCreatePipelineAsyncTracker->Tick(mCompletedSerial);
|
||||||
}
|
}
|
||||||
@ -902,7 +905,7 @@ namespace dawn_native {
|
|||||||
return !IsDeviceIdle();
|
return !IsDeviceIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueBase* DeviceBase::GetQueue() {
|
QueueBase* DeviceBase::APIGetQueue() {
|
||||||
// Backends gave the primary queue during initialization.
|
// Backends gave the primary queue during initialization.
|
||||||
ASSERT(mQueue != nullptr);
|
ASSERT(mQueue != nullptr);
|
||||||
|
|
||||||
@ -911,10 +914,10 @@ namespace dawn_native {
|
|||||||
return mQueue.Get();
|
return mQueue.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueBase* DeviceBase::GetDefaultQueue() {
|
QueueBase* DeviceBase::APIGetDefaultQueue() {
|
||||||
EmitDeprecationWarning(
|
EmitDeprecationWarning(
|
||||||
"Device::GetDefaultQueue is deprecated, use Device::GetQueue() instead");
|
"Device::GetDefaultQueue is deprecated, use Device::GetQueue() instead");
|
||||||
return GetQueue();
|
return APIGetQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::ApplyExtensions(const DeviceDescriptor* deviceDescriptor) {
|
void DeviceBase::ApplyExtensions(const DeviceDescriptor* deviceDescriptor) {
|
||||||
|
@ -139,45 +139,45 @@ namespace dawn_native {
|
|||||||
void UncacheAttachmentState(AttachmentState* obj);
|
void UncacheAttachmentState(AttachmentState* obj);
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
BindGroupBase* CreateBindGroup(const BindGroupDescriptor* descriptor);
|
BindGroupBase* APICreateBindGroup(const BindGroupDescriptor* descriptor);
|
||||||
BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
|
BindGroupLayoutBase* APICreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
|
||||||
BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
|
BufferBase* APICreateBuffer(const BufferDescriptor* descriptor);
|
||||||
CommandEncoder* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
|
CommandEncoder* APICreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
|
||||||
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
ComputePipelineBase* APICreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
||||||
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
PipelineLayoutBase* APICreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
||||||
QuerySetBase* CreateQuerySet(const QuerySetDescriptor* descriptor);
|
QuerySetBase* APICreateQuerySet(const QuerySetDescriptor* descriptor);
|
||||||
void CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
void APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
|
void APICreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
RenderBundleEncoder* CreateRenderBundleEncoder(
|
RenderBundleEncoder* APICreateRenderBundleEncoder(
|
||||||
const RenderBundleEncoderDescriptor* descriptor);
|
const RenderBundleEncoderDescriptor* descriptor);
|
||||||
RenderPipelineBase* CreateRenderPipeline(const RenderPipelineDescriptor* descriptor);
|
RenderPipelineBase* APICreateRenderPipeline(const RenderPipelineDescriptor* descriptor);
|
||||||
RenderPipelineBase* CreateRenderPipeline2(const RenderPipelineDescriptor2* descriptor);
|
RenderPipelineBase* APICreateRenderPipeline2(const RenderPipelineDescriptor2* descriptor);
|
||||||
SamplerBase* CreateSampler(const SamplerDescriptor* descriptor);
|
SamplerBase* APICreateSampler(const SamplerDescriptor* descriptor);
|
||||||
ShaderModuleBase* CreateShaderModule(const ShaderModuleDescriptor* descriptor);
|
ShaderModuleBase* APICreateShaderModule(const ShaderModuleDescriptor* descriptor);
|
||||||
SwapChainBase* CreateSwapChain(Surface* surface, const SwapChainDescriptor* descriptor);
|
SwapChainBase* APICreateSwapChain(Surface* surface, const SwapChainDescriptor* descriptor);
|
||||||
TextureBase* CreateTexture(const TextureDescriptor* descriptor);
|
TextureBase* APICreateTexture(const TextureDescriptor* descriptor);
|
||||||
TextureViewBase* CreateTextureView(TextureBase* texture,
|
TextureViewBase* CreateTextureView(TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor);
|
const TextureViewDescriptor* descriptor);
|
||||||
InternalPipelineStore* GetInternalPipelineStore();
|
InternalPipelineStore* GetInternalPipelineStore();
|
||||||
|
|
||||||
// For Dawn Wire
|
// For Dawn Wire
|
||||||
BufferBase* CreateErrorBuffer();
|
BufferBase* APICreateErrorBuffer();
|
||||||
|
|
||||||
// TODO(dawn:22): Remove once the deprecation period is finished.
|
// TODO(dawn:22): Remove once the deprecation period is finished.
|
||||||
QueueBase* GetDefaultQueue();
|
QueueBase* APIGetDefaultQueue();
|
||||||
QueueBase* GetQueue();
|
QueueBase* APIGetQueue();
|
||||||
|
|
||||||
void InjectError(wgpu::ErrorType type, const char* message);
|
void APIInjectError(wgpu::ErrorType type, const char* message);
|
||||||
bool Tick();
|
bool APITick();
|
||||||
|
|
||||||
void SetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata);
|
void APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata);
|
||||||
void SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
|
void APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
|
||||||
void PushErrorScope(wgpu::ErrorFilter filter);
|
void APIPushErrorScope(wgpu::ErrorFilter filter);
|
||||||
bool PopErrorScope(wgpu::ErrorCallback callback, void* userdata);
|
bool APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata);
|
||||||
|
|
||||||
MaybeError ValidateIsAlive() const;
|
MaybeError ValidateIsAlive() const;
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ namespace dawn_native {
|
|||||||
void IncrementLazyClearCountForTesting();
|
void IncrementLazyClearCountForTesting();
|
||||||
size_t GetDeprecationWarningCountForTesting();
|
size_t GetDeprecationWarningCountForTesting();
|
||||||
void EmitDeprecationWarning(const char* warning);
|
void EmitDeprecationWarning(const char* warning);
|
||||||
void LoseForTesting();
|
void APILoseForTesting();
|
||||||
|
|
||||||
// AddFutureSerial is used to update the mFutureSerial with the max serial needed to be
|
// AddFutureSerial is used to update the mFutureSerial with the max serial needed to be
|
||||||
// ticked in order to clean up all pending callback work or to execute asynchronous resource
|
// ticked in order to clean up all pending callback work or to execute asynchronous resource
|
||||||
|
@ -73,16 +73,16 @@ namespace dawn_native {
|
|||||||
return new Fence(device, ObjectBase::kError);
|
return new Fence(device, ObjectBase::kError);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Fence::GetCompletedValue() const {
|
uint64_t Fence::APIGetCompletedValue() const {
|
||||||
if (IsError()) {
|
if (IsError()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return uint64_t(mCompletedValue);
|
return uint64_t(mCompletedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fence::OnCompletion(uint64_t apiValue,
|
void Fence::APIOnCompletion(uint64_t apiValue,
|
||||||
wgpu::FenceOnCompletionCallback callback,
|
wgpu::FenceOnCompletionCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
FenceAPISerial value(apiValue);
|
FenceAPISerial value(apiValue);
|
||||||
|
|
||||||
WGPUFenceCompletionStatus status;
|
WGPUFenceCompletionStatus status;
|
||||||
@ -136,8 +136,9 @@ namespace dawn_native {
|
|||||||
std::make_unique<FenceInFlight>(fence, value);
|
std::make_unique<FenceInFlight>(fence, value);
|
||||||
|
|
||||||
// TODO: use GetLastSubmittedCommandSerial in the future for perforamnce
|
// TODO: use GetLastSubmittedCommandSerial in the future for perforamnce
|
||||||
GetDevice()->GetQueue()->TrackTask(std::move(fenceInFlight),
|
// TODO(dawn:723): do not get a new reference to the Queue.
|
||||||
GetDevice()->GetPendingCommandSerial());
|
GetDevice()->APIGetQueue()->TrackTask(std::move(fenceInFlight),
|
||||||
|
GetDevice()->GetPendingCommandSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Fence::ValidateOnCompletion(FenceAPISerial value,
|
MaybeError Fence::ValidateOnCompletion(FenceAPISerial value,
|
||||||
|
@ -39,8 +39,10 @@ namespace dawn_native {
|
|||||||
const QueueBase* GetQueue() const;
|
const QueueBase* GetQueue() const;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
uint64_t GetCompletedValue() const;
|
uint64_t APIGetCompletedValue() const;
|
||||||
void OnCompletion(uint64_t value, wgpu::FenceOnCompletionCallback callback, void* userdata);
|
void APIOnCompletion(uint64_t value,
|
||||||
|
wgpu::FenceOnCompletionCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class QueueBase;
|
friend class QueueBase;
|
||||||
|
@ -238,7 +238,7 @@ namespace dawn_native {
|
|||||||
#endif // defined(DAWN_USE_X11)
|
#endif // defined(DAWN_USE_X11)
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface* InstanceBase::CreateSurface(const SurfaceDescriptor* descriptor) {
|
Surface* InstanceBase::APICreateSurface(const SurfaceDescriptor* descriptor) {
|
||||||
if (ConsumedError(ValidateSurfaceDescriptor(this, descriptor))) {
|
if (ConsumedError(ValidateSurfaceDescriptor(this, descriptor))) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace dawn_native {
|
|||||||
const XlibXcbFunctions* GetOrCreateXlibXcbFunctions();
|
const XlibXcbFunctions* GetOrCreateXlibXcbFunctions();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
Surface* CreateSurface(const SurfaceDescriptor* descriptor);
|
Surface* APICreateSurface(const SurfaceDescriptor* descriptor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InstanceBase() = default;
|
InstanceBase() = default;
|
||||||
|
@ -125,7 +125,7 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BindGroupLayoutBase* PipelineBase::GetBindGroupLayout(uint32_t groupIndexIn) {
|
BindGroupLayoutBase* PipelineBase::APIGetBindGroupLayout(uint32_t groupIndexIn) {
|
||||||
if (GetDevice()->ConsumedError(ValidateGetBindGroupLayout(groupIndexIn))) {
|
if (GetDevice()->ConsumedError(ValidateGetBindGroupLayout(groupIndexIn))) {
|
||||||
return BindGroupLayoutBase::MakeError(GetDevice());
|
return BindGroupLayoutBase::MakeError(GetDevice());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace dawn_native {
|
|||||||
const ProgrammableStage& GetStage(SingleShaderStage stage) const;
|
const ProgrammableStage& GetStage(SingleShaderStage stage) const;
|
||||||
const PerStage<ProgrammableStage>& GetAllStages() const;
|
const PerStage<ProgrammableStage>& GetAllStages() const;
|
||||||
|
|
||||||
BindGroupLayoutBase* GetBindGroupLayout(uint32_t groupIndex);
|
BindGroupLayoutBase* APIGetBindGroupLayout(uint32_t groupIndex);
|
||||||
|
|
||||||
// Helper functions for std::unordered_map-based pipeline caches.
|
// Helper functions for std::unordered_map-based pipeline caches.
|
||||||
size_t ComputeContentHash() override;
|
size_t ComputeContentHash() override;
|
||||||
|
@ -111,7 +111,7 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgrammablePassEncoder::InsertDebugMarker(const char* groupLabel) {
|
void ProgrammablePassEncoder::APIInsertDebugMarker(const char* groupLabel) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
InsertDebugMarkerCmd* cmd =
|
InsertDebugMarkerCmd* cmd =
|
||||||
allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker);
|
allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker);
|
||||||
@ -124,7 +124,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgrammablePassEncoder::PopDebugGroup() {
|
void ProgrammablePassEncoder::APIPopDebugGroup() {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
if (mDebugGroupStackSize == 0) {
|
if (mDebugGroupStackSize == 0) {
|
||||||
@ -138,7 +138,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgrammablePassEncoder::PushDebugGroup(const char* groupLabel) {
|
void ProgrammablePassEncoder::APIPushDebugGroup(const char* groupLabel) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
PushDebugGroupCmd* cmd =
|
PushDebugGroupCmd* cmd =
|
||||||
allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup);
|
allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup);
|
||||||
@ -153,10 +153,10 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgrammablePassEncoder::SetBindGroup(uint32_t groupIndexIn,
|
void ProgrammablePassEncoder::APISetBindGroup(uint32_t groupIndexIn,
|
||||||
BindGroupBase* group,
|
BindGroupBase* group,
|
||||||
uint32_t dynamicOffsetCountIn,
|
uint32_t dynamicOffsetCountIn,
|
||||||
const uint32_t* dynamicOffsetsIn) {
|
const uint32_t* dynamicOffsetsIn) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
BindGroupIndex groupIndex(groupIndexIn);
|
BindGroupIndex groupIndex(groupIndexIn);
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ namespace dawn_native {
|
|||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
PassType passType);
|
PassType passType);
|
||||||
|
|
||||||
void InsertDebugMarker(const char* groupLabel);
|
void APIInsertDebugMarker(const char* groupLabel);
|
||||||
void PopDebugGroup();
|
void APIPopDebugGroup();
|
||||||
void PushDebugGroup(const char* groupLabel);
|
void APIPushDebugGroup(const char* groupLabel);
|
||||||
|
|
||||||
void SetBindGroup(uint32_t groupIndex,
|
void APISetBindGroup(uint32_t groupIndex,
|
||||||
BindGroupBase* group,
|
BindGroupBase* group,
|
||||||
uint32_t dynamicOffsetCount = 0,
|
uint32_t dynamicOffsetCount = 0,
|
||||||
const uint32_t* dynamicOffsets = nullptr);
|
const uint32_t* dynamicOffsets = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool IsValidationEnabled() const;
|
bool IsValidationEnabled() const;
|
||||||
|
@ -116,7 +116,8 @@ namespace dawn_native {
|
|||||||
wgslDesc.source = sConvertTimestampsToNanoseconds;
|
wgslDesc.source = sConvertTimestampsToNanoseconds;
|
||||||
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
descriptor.nextInChain = reinterpret_cast<ChainedStruct*>(&wgslDesc);
|
||||||
|
|
||||||
store->timestampCS = AcquireRef(device->CreateShaderModule(&descriptor));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
store->timestampCS = AcquireRef(device->APICreateShaderModule(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ComputePipeline.
|
// Create ComputePipeline.
|
||||||
@ -126,8 +127,9 @@ namespace dawn_native {
|
|||||||
computePipelineDesc.computeStage.module = store->timestampCS.Get();
|
computePipelineDesc.computeStage.module = store->timestampCS.Get();
|
||||||
computePipelineDesc.computeStage.entryPoint = "main";
|
computePipelineDesc.computeStage.entryPoint = "main";
|
||||||
|
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
store->timestampComputePipeline =
|
store->timestampComputePipeline =
|
||||||
AcquireRef(device->CreateComputePipeline(&computePipelineDesc));
|
AcquireRef(device->APICreateComputePipeline(&computePipelineDesc));
|
||||||
}
|
}
|
||||||
|
|
||||||
return store->timestampComputePipeline.Get();
|
return store->timestampComputePipeline.Get();
|
||||||
@ -144,7 +146,8 @@ namespace dawn_native {
|
|||||||
ComputePipelineBase* pipeline = GetOrCreateTimestampComputePipeline(device);
|
ComputePipelineBase* pipeline = GetOrCreateTimestampComputePipeline(device);
|
||||||
|
|
||||||
// Prepare bind group layout.
|
// Prepare bind group layout.
|
||||||
Ref<BindGroupLayoutBase> layout = AcquireRef(pipeline->GetBindGroupLayout(0));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<BindGroupLayoutBase> layout = AcquireRef(pipeline->APIGetBindGroupLayout(0));
|
||||||
|
|
||||||
// Prepare bind group descriptor
|
// Prepare bind group descriptor
|
||||||
std::array<BindGroupEntry, 3> bindGroupEntries = {};
|
std::array<BindGroupEntry, 3> bindGroupEntries = {};
|
||||||
@ -165,15 +168,18 @@ namespace dawn_native {
|
|||||||
bindGroupEntries[2].size = params->GetSize();
|
bindGroupEntries[2].size = params->GetSize();
|
||||||
|
|
||||||
// Create bind group after all binding entries are set.
|
// Create bind group after all binding entries are set.
|
||||||
Ref<BindGroupBase> bindGroup = AcquireRef(device->CreateBindGroup(&bgDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<BindGroupBase> bindGroup = AcquireRef(device->APICreateBindGroup(&bgDesc));
|
||||||
|
|
||||||
// Create compute encoder and issue dispatch.
|
// Create compute encoder and issue dispatch.
|
||||||
ComputePassDescriptor passDesc = {};
|
ComputePassDescriptor passDesc = {};
|
||||||
Ref<ComputePassEncoder> pass = AcquireRef(encoder->BeginComputePass(&passDesc));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
pass->SetPipeline(pipeline);
|
Ref<ComputePassEncoder> pass = AcquireRef(encoder->APIBeginComputePass(&passDesc));
|
||||||
pass->SetBindGroup(0, bindGroup.Get());
|
pass->APISetPipeline(pipeline);
|
||||||
pass->Dispatch(static_cast<uint32_t>((timestamps->GetSize() / sizeof(uint64_t) + 7) / 8));
|
pass->APISetBindGroup(0, bindGroup.Get());
|
||||||
pass->EndPass();
|
pass->APIDispatch(
|
||||||
|
static_cast<uint32_t>((timestamps->GetSize() / sizeof(uint64_t) + 7) / 8));
|
||||||
|
pass->APIEndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -153,7 +153,7 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuerySetBase::Destroy() {
|
void QuerySetBase::APIDestroy() {
|
||||||
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError ValidateCanUseInSubmitNow() const;
|
MaybeError ValidateCanUseInSubmitNow() const;
|
||||||
|
|
||||||
void Destroy();
|
void APIDestroy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
|
@ -176,7 +176,7 @@ namespace dawn_native {
|
|||||||
return new ErrorQueue(device);
|
return new ErrorQueue(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
void QueueBase::APISubmit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
SubmitInternal(commandCount, commands);
|
SubmitInternal(commandCount, commands);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
@ -184,7 +184,7 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::Signal(Fence* fence, uint64_t apiSignalValue) {
|
void QueueBase::APISignal(Fence* fence, uint64_t apiSignalValue) {
|
||||||
FenceAPISerial signalValue(apiSignalValue);
|
FenceAPISerial signalValue(apiSignalValue);
|
||||||
|
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
@ -197,9 +197,9 @@ namespace dawn_native {
|
|||||||
fence->UpdateFenceOnComplete(fence, signalValue);
|
fence->UpdateFenceOnComplete(fence, signalValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::OnSubmittedWorkDone(uint64_t signalValue,
|
void QueueBase::APIOnSubmittedWorkDone(uint64_t signalValue,
|
||||||
WGPUQueueWorkDoneCallback callback,
|
WGPUQueueWorkDoneCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
// The error status depends on the type of error so we let the validation function choose it
|
// The error status depends on the type of error so we let the validation function choose it
|
||||||
WGPUQueueWorkDoneStatus status;
|
WGPUQueueWorkDoneStatus status;
|
||||||
if (GetDevice()->ConsumedError(ValidateOnSubmittedWorkDone(signalValue, &status))) {
|
if (GetDevice()->ConsumedError(ValidateOnSubmittedWorkDone(signalValue, &status))) {
|
||||||
@ -236,7 +236,7 @@ namespace dawn_native {
|
|||||||
mTasksInFlight.Clear();
|
mTasksInFlight.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Fence* QueueBase::CreateFence(const FenceDescriptor* descriptor) {
|
Fence* QueueBase::APICreateFence(const FenceDescriptor* descriptor) {
|
||||||
// TODO(chromium:1177476): Remove once the deprecation period is finished.
|
// TODO(chromium:1177476): Remove once the deprecation period is finished.
|
||||||
GetDevice()->EmitDeprecationWarning(
|
GetDevice()->EmitDeprecationWarning(
|
||||||
"Fences are deprecated, use Queue::OnSubmittedWorkDone instead.");
|
"Fences are deprecated, use Queue::OnSubmittedWorkDone instead.");
|
||||||
@ -252,10 +252,10 @@ namespace dawn_native {
|
|||||||
return new Fence(this, descriptor);
|
return new Fence(this, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::WriteBuffer(BufferBase* buffer,
|
void QueueBase::APIWriteBuffer(BufferBase* buffer,
|
||||||
uint64_t bufferOffset,
|
uint64_t bufferOffset,
|
||||||
const void* data,
|
const void* data,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
GetDevice()->ConsumedError(WriteBufferInternal(buffer, bufferOffset, data, size));
|
GetDevice()->ConsumedError(WriteBufferInternal(buffer, bufferOffset, data, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,11 +291,11 @@ namespace dawn_native {
|
|||||||
buffer, bufferOffset, size);
|
buffer, bufferOffset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::WriteTexture(const ImageCopyTexture* destination,
|
void QueueBase::APIWriteTexture(const ImageCopyTexture* destination,
|
||||||
const void* data,
|
const void* data,
|
||||||
size_t dataSize,
|
size_t dataSize,
|
||||||
const TextureDataLayout* dataLayout,
|
const TextureDataLayout* dataLayout,
|
||||||
const Extent3D* writeSize) {
|
const Extent3D* writeSize) {
|
||||||
GetDevice()->ConsumedError(
|
GetDevice()->ConsumedError(
|
||||||
WriteTextureInternal(destination, data, dataSize, dataLayout, writeSize));
|
WriteTextureInternal(destination, data, dataSize, dataLayout, writeSize));
|
||||||
}
|
}
|
||||||
@ -366,10 +366,10 @@ namespace dawn_native {
|
|||||||
&textureCopy, writeSizePixel);
|
&textureCopy, writeSizePixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueBase::CopyTextureForBrowser(const ImageCopyTexture* source,
|
void QueueBase::APICopyTextureForBrowser(const ImageCopyTexture* source,
|
||||||
const ImageCopyTexture* destination,
|
const ImageCopyTexture* destination,
|
||||||
const Extent3D* copySize,
|
const Extent3D* copySize,
|
||||||
const CopyTextureForBrowserOptions* options) {
|
const CopyTextureForBrowserOptions* options) {
|
||||||
GetDevice()->ConsumedError(
|
GetDevice()->ConsumedError(
|
||||||
CopyTextureForBrowserInternal(source, destination, copySize, options));
|
CopyTextureForBrowserInternal(source, destination, copySize, options));
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,25 @@ namespace dawn_native {
|
|||||||
~QueueBase() override;
|
~QueueBase() override;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void Submit(uint32_t commandCount, CommandBufferBase* const* commands);
|
void APISubmit(uint32_t commandCount, CommandBufferBase* const* commands);
|
||||||
void Signal(Fence* fence, uint64_t signalValue);
|
void APISignal(Fence* fence, uint64_t signalValue);
|
||||||
Fence* CreateFence(const FenceDescriptor* descriptor);
|
Fence* APICreateFence(const FenceDescriptor* descriptor);
|
||||||
void OnSubmittedWorkDone(uint64_t signalValue,
|
void APIOnSubmittedWorkDone(uint64_t signalValue,
|
||||||
WGPUQueueWorkDoneCallback callback,
|
WGPUQueueWorkDoneCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void WriteBuffer(BufferBase* buffer, uint64_t bufferOffset, const void* data, size_t size);
|
void APIWriteBuffer(BufferBase* buffer,
|
||||||
void WriteTexture(const ImageCopyTexture* destination,
|
uint64_t bufferOffset,
|
||||||
const void* data,
|
const void* data,
|
||||||
size_t dataSize,
|
size_t size);
|
||||||
const TextureDataLayout* dataLayout,
|
void APIWriteTexture(const ImageCopyTexture* destination,
|
||||||
const Extent3D* writeSize);
|
const void* data,
|
||||||
void CopyTextureForBrowser(const ImageCopyTexture* source,
|
size_t dataSize,
|
||||||
const ImageCopyTexture* destination,
|
const TextureDataLayout* dataLayout,
|
||||||
const Extent3D* copySize,
|
const Extent3D* writeSize);
|
||||||
const CopyTextureForBrowserOptions* options);
|
void APICopyTextureForBrowser(const ImageCopyTexture* source,
|
||||||
|
const ImageCopyTexture* destination,
|
||||||
|
const Extent3D* copySize,
|
||||||
|
const CopyTextureForBrowserOptions* options);
|
||||||
|
|
||||||
void TrackTask(std::unique_ptr<TaskInFlight> task, ExecutionSerial serial);
|
void TrackTask(std::unique_ptr<TaskInFlight> task, ExecutionSerial serial);
|
||||||
void Tick(ExecutionSerial finishedSerial);
|
void Tick(ExecutionSerial finishedSerial);
|
||||||
|
@ -99,7 +99,7 @@ namespace dawn_native {
|
|||||||
return mBundleEncodingContext.AcquireCommands();
|
return mBundleEncodingContext.AcquireCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderBundleBase* RenderBundleEncoder::Finish(const RenderBundleDescriptor* descriptor) {
|
RenderBundleBase* RenderBundleEncoder::APIFinish(const RenderBundleDescriptor* descriptor) {
|
||||||
RenderBundleBase* result = nullptr;
|
RenderBundleBase* result = nullptr;
|
||||||
|
|
||||||
if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result)) {
|
if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result)) {
|
||||||
|
@ -32,7 +32,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
static RenderBundleEncoder* MakeError(DeviceBase* device);
|
static RenderBundleEncoder* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
RenderBundleBase* Finish(const RenderBundleDescriptor* descriptor);
|
RenderBundleBase* APIFinish(const RenderBundleDescriptor* descriptor);
|
||||||
|
|
||||||
CommandIterator AcquireCommands();
|
CommandIterator AcquireCommands();
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ namespace dawn_native {
|
|||||||
return std::move(mAttachmentState);
|
return std::move(mAttachmentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::Draw(uint32_t vertexCount,
|
void RenderEncoderBase::APIDraw(uint32_t vertexCount,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
uint32_t firstVertex,
|
uint32_t firstVertex,
|
||||||
uint32_t firstInstance) {
|
uint32_t firstInstance) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(mCommandBufferState.ValidateCanDraw());
|
DAWN_TRY(mCommandBufferState.ValidateCanDraw());
|
||||||
@ -79,11 +79,11 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::DrawIndexed(uint32_t indexCount,
|
void RenderEncoderBase::APIDrawIndexed(uint32_t indexCount,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
uint32_t firstIndex,
|
uint32_t firstIndex,
|
||||||
int32_t baseVertex,
|
int32_t baseVertex,
|
||||||
uint32_t firstInstance) {
|
uint32_t firstInstance) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed());
|
DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed());
|
||||||
@ -115,7 +115,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
void RenderEncoderBase::APIDrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||||
@ -142,8 +142,8 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::DrawIndexedIndirect(BufferBase* indirectBuffer,
|
void RenderEncoderBase::APIDrawIndexedIndirect(BufferBase* indirectBuffer,
|
||||||
uint64_t indirectOffset) {
|
uint64_t indirectOffset) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||||
@ -181,7 +181,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::SetPipeline(RenderPipelineBase* pipeline) {
|
void RenderEncoderBase::APISetPipeline(RenderPipelineBase* pipeline) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
|
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
|
||||||
@ -203,18 +203,20 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format,
|
void RenderEncoderBase::APISetIndexBufferWithFormat(BufferBase* buffer,
|
||||||
uint64_t offset, uint64_t size) {
|
wgpu::IndexFormat format,
|
||||||
|
uint64_t offset,
|
||||||
|
uint64_t size) {
|
||||||
GetDevice()->EmitDeprecationWarning(
|
GetDevice()->EmitDeprecationWarning(
|
||||||
"RenderEncoderBase::SetIndexBufferWithFormat is deprecated. Use "
|
"RenderEncoderBase::SetIndexBufferWithFormat is deprecated. Use "
|
||||||
"RenderEncoderBase::SetIndexBuffer instead.");
|
"RenderEncoderBase::SetIndexBuffer instead.");
|
||||||
SetIndexBuffer(buffer, format, offset, size);
|
APISetIndexBuffer(buffer, format, offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer,
|
void RenderEncoderBase::APISetIndexBuffer(BufferBase* buffer,
|
||||||
wgpu::IndexFormat format,
|
wgpu::IndexFormat format,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint64_t size) {
|
uint64_t size) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
||||||
@ -259,10 +261,10 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEncoderBase::SetVertexBuffer(uint32_t slot,
|
void RenderEncoderBase::APISetVertexBuffer(uint32_t slot,
|
||||||
BufferBase* buffer,
|
BufferBase* buffer,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint64_t size) {
|
uint64_t size) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
||||||
|
@ -27,28 +27,30 @@ namespace dawn_native {
|
|||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
Ref<AttachmentState> attachmentState);
|
Ref<AttachmentState> attachmentState);
|
||||||
|
|
||||||
void Draw(uint32_t vertexCount,
|
void APIDraw(uint32_t vertexCount,
|
||||||
uint32_t instanceCount = 1,
|
uint32_t instanceCount = 1,
|
||||||
uint32_t firstVertex = 0,
|
uint32_t firstVertex = 0,
|
||||||
uint32_t firstInstance = 0);
|
uint32_t firstInstance = 0);
|
||||||
void DrawIndexed(uint32_t vertexCount,
|
void APIDrawIndexed(uint32_t vertexCount,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
uint32_t firstIndex,
|
uint32_t firstIndex,
|
||||||
int32_t baseVertex,
|
int32_t baseVertex,
|
||||||
uint32_t firstInstance);
|
uint32_t firstInstance);
|
||||||
|
|
||||||
void DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
void APIDrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
void DrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
void APIDrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
|
|
||||||
void SetPipeline(RenderPipelineBase* pipeline);
|
void APISetPipeline(RenderPipelineBase* pipeline);
|
||||||
|
|
||||||
void SetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset, uint64_t size);
|
void APISetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset, uint64_t size);
|
||||||
void SetIndexBuffer(BufferBase* buffer,
|
void APISetIndexBuffer(BufferBase* buffer,
|
||||||
wgpu::IndexFormat format,
|
wgpu::IndexFormat format,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint64_t size);
|
uint64_t size);
|
||||||
void SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format, uint64_t offset,
|
void APISetIndexBufferWithFormat(BufferBase* buffer,
|
||||||
uint64_t size);
|
wgpu::IndexFormat format,
|
||||||
|
uint64_t offset,
|
||||||
|
uint64_t size);
|
||||||
|
|
||||||
const AttachmentState* GetAttachmentState() const;
|
const AttachmentState* GetAttachmentState() const;
|
||||||
Ref<AttachmentState> AcquireAttachmentState();
|
Ref<AttachmentState> AcquireAttachmentState();
|
||||||
|
@ -93,7 +93,7 @@ namespace dawn_native {
|
|||||||
return mQueryAvailabilityMap;
|
return mQueryAvailabilityMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::EndPass() {
|
void RenderPassEncoder::APIEndPass() {
|
||||||
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateProgrammableEncoderEnd());
|
DAWN_TRY(ValidateProgrammableEncoderEnd());
|
||||||
@ -110,7 +110,7 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::SetStencilReference(uint32_t reference) {
|
void RenderPassEncoder::APISetStencilReference(uint32_t reference) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
SetStencilReferenceCmd* cmd =
|
SetStencilReferenceCmd* cmd =
|
||||||
allocator->Allocate<SetStencilReferenceCmd>(Command::SetStencilReference);
|
allocator->Allocate<SetStencilReferenceCmd>(Command::SetStencilReference);
|
||||||
@ -120,7 +120,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::SetBlendColor(const Color* color) {
|
void RenderPassEncoder::APISetBlendColor(const Color* color) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
|
SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
|
||||||
cmd->color = *color;
|
cmd->color = *color;
|
||||||
@ -129,12 +129,12 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::SetViewport(float x,
|
void RenderPassEncoder::APISetViewport(float x,
|
||||||
float y,
|
float y,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
float minDepth,
|
float minDepth,
|
||||||
float maxDepth) {
|
float maxDepth) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
if ((isnan(x) || isnan(y) || isnan(width) || isnan(height) || isnan(minDepth) ||
|
if ((isnan(x) || isnan(y) || isnan(width) || isnan(height) || isnan(minDepth) ||
|
||||||
@ -170,10 +170,10 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::SetScissorRect(uint32_t x,
|
void RenderPassEncoder::APISetScissorRect(uint32_t x,
|
||||||
uint32_t y,
|
uint32_t y,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
if (width > mRenderTargetWidth || height > mRenderTargetHeight ||
|
if (width > mRenderTargetWidth || height > mRenderTargetHeight ||
|
||||||
@ -194,7 +194,8 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles) {
|
void RenderPassEncoder::APIExecuteBundles(uint32_t count,
|
||||||
|
RenderBundleBase* const* renderBundles) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
for (uint32_t i = 0; i < count; ++i) {
|
for (uint32_t i = 0; i < count; ++i) {
|
||||||
@ -232,7 +233,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::BeginOcclusionQuery(uint32_t queryIndex) {
|
void RenderPassEncoder::APIBeginOcclusionQuery(uint32_t queryIndex) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
if (mOcclusionQuerySet.Get() == nullptr) {
|
if (mOcclusionQuerySet.Get() == nullptr) {
|
||||||
@ -271,7 +272,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::EndOcclusionQuery() {
|
void RenderPassEncoder::APIEndOcclusionQuery() {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
if (!mOcclusionQueryActive) {
|
if (!mOcclusionQueryActive) {
|
||||||
@ -293,7 +294,7 @@ namespace dawn_native {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
void RenderPassEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) {
|
||||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
DAWN_TRY(GetDevice()->ValidateObject(querySet));
|
||||||
|
@ -40,23 +40,23 @@ namespace dawn_native {
|
|||||||
void TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex);
|
void TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex);
|
||||||
const QueryAvailabilityMap& GetQueryAvailabilityMap() const;
|
const QueryAvailabilityMap& GetQueryAvailabilityMap() const;
|
||||||
|
|
||||||
void EndPass();
|
void APIEndPass();
|
||||||
|
|
||||||
void SetStencilReference(uint32_t reference);
|
void APISetStencilReference(uint32_t reference);
|
||||||
void SetBlendColor(const Color* color);
|
void APISetBlendColor(const Color* color);
|
||||||
void SetViewport(float x,
|
void APISetViewport(float x,
|
||||||
float y,
|
float y,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
float minDepth,
|
float minDepth,
|
||||||
float maxDepth);
|
float maxDepth);
|
||||||
void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
void APISetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||||
void ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles);
|
void APIExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles);
|
||||||
|
|
||||||
void BeginOcclusionQuery(uint32_t queryIndex);
|
void APIBeginOcclusionQuery(uint32_t queryIndex);
|
||||||
void EndOcclusionQuery();
|
void APIEndOcclusionQuery();
|
||||||
|
|
||||||
void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderPassEncoder(DeviceBase* device,
|
RenderPassEncoder(DeviceBase* device,
|
||||||
|
@ -31,19 +31,19 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Configure(wgpu::TextureFormat format,
|
void APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) override {
|
uint32_t height) override {
|
||||||
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBase* GetCurrentTextureView() override {
|
TextureViewBase* APIGetCurrentTextureView() override {
|
||||||
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
||||||
return TextureViewBase::MakeError(GetDevice());
|
return TextureViewBase::MakeError(GetDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Present() override {
|
void APIPresent() override {
|
||||||
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -142,10 +142,10 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OldSwapChainBase::Configure(wgpu::TextureFormat format,
|
void OldSwapChainBase::APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
|
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ namespace dawn_native {
|
|||||||
static_cast<WGPUTextureUsage>(allowedUsage), width, height);
|
static_cast<WGPUTextureUsage>(allowedUsage), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBase* OldSwapChainBase::GetCurrentTextureView() {
|
TextureViewBase* OldSwapChainBase::APIGetCurrentTextureView() {
|
||||||
if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) {
|
if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) {
|
||||||
return TextureViewBase::MakeError(GetDevice());
|
return TextureViewBase::MakeError(GetDevice());
|
||||||
}
|
}
|
||||||
@ -190,11 +190,11 @@ namespace dawn_native {
|
|||||||
// of dawn_native
|
// of dawn_native
|
||||||
mCurrentTexture = AcquireRef(GetNextTextureImpl(&descriptor));
|
mCurrentTexture = AcquireRef(GetNextTextureImpl(&descriptor));
|
||||||
|
|
||||||
mCurrentTextureView = mCurrentTexture->CreateView();
|
mCurrentTextureView = mCurrentTexture->APICreateView();
|
||||||
return mCurrentTextureView.Get();
|
return mCurrentTextureView.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OldSwapChainBase::Present() {
|
void OldSwapChainBase::APIPresent() {
|
||||||
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -292,15 +292,15 @@ namespace dawn_native {
|
|||||||
mAttached = true;
|
mAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::Configure(wgpu::TextureFormat format,
|
void NewSwapChainBase::APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
GetDevice()->ConsumedError(
|
GetDevice()->ConsumedError(
|
||||||
DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains"));
|
DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBase* NewSwapChainBase::GetCurrentTextureView() {
|
TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() {
|
||||||
if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) {
|
if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) {
|
||||||
return TextureViewBase::MakeError(GetDevice());
|
return TextureViewBase::MakeError(GetDevice());
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ namespace dawn_native {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::Present() {
|
void NewSwapChainBase::APIPresent() {
|
||||||
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ namespace dawn_native {
|
|||||||
static SwapChainBase* MakeError(DeviceBase* device);
|
static SwapChainBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
virtual void Configure(wgpu::TextureFormat format,
|
virtual void APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) = 0;
|
uint32_t height) = 0;
|
||||||
virtual TextureViewBase* GetCurrentTextureView() = 0;
|
virtual TextureViewBase* APIGetCurrentTextureView() = 0;
|
||||||
virtual void Present() = 0;
|
virtual void APIPresent() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
@ -57,12 +57,12 @@ namespace dawn_native {
|
|||||||
static SwapChainBase* MakeError(DeviceBase* device);
|
static SwapChainBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void Configure(wgpu::TextureFormat format,
|
void APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) override;
|
uint32_t height) override;
|
||||||
TextureViewBase* GetCurrentTextureView() override;
|
TextureViewBase* APIGetCurrentTextureView() override;
|
||||||
void Present() override;
|
void APIPresent() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~OldSwapChainBase() override;
|
~OldSwapChainBase() override;
|
||||||
@ -114,12 +114,12 @@ namespace dawn_native {
|
|||||||
void SetIsAttached();
|
void SetIsAttached();
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void Configure(wgpu::TextureFormat format,
|
void APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) override;
|
uint32_t height) override;
|
||||||
TextureViewBase* GetCurrentTextureView() override;
|
TextureViewBase* APIGetCurrentTextureView() override;
|
||||||
void Present() override;
|
void APIPresent() override;
|
||||||
|
|
||||||
uint32_t GetWidth() const;
|
uint32_t GetWidth() const;
|
||||||
uint32_t GetHeight() const;
|
uint32_t GetHeight() const;
|
||||||
|
@ -609,11 +609,11 @@ namespace dawn_native {
|
|||||||
return {clampedCopyExtentWidth, clampedCopyExtentHeight, extent.depthOrArrayLayers};
|
return {clampedCopyExtentWidth, clampedCopyExtentHeight, extent.depthOrArrayLayers};
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBase* TextureBase::CreateView(const TextureViewDescriptor* descriptor) {
|
TextureViewBase* TextureBase::APICreateView(const TextureViewDescriptor* descriptor) {
|
||||||
return GetDevice()->CreateTextureView(this, descriptor);
|
return GetDevice()->CreateTextureView(this, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureBase::Destroy() {
|
void TextureBase::APIDestroy() {
|
||||||
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
if (GetDevice()->ConsumedError(ValidateDestroy())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ namespace dawn_native {
|
|||||||
const Extent3D& extent) const;
|
const Extent3D& extent) const;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
TextureViewBase* CreateView(const TextureViewDescriptor* descriptor = nullptr);
|
TextureViewBase* APICreateView(const TextureViewDescriptor* descriptor = nullptr);
|
||||||
void Destroy();
|
void APIDestroy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DestroyInternal();
|
void DestroyInternal();
|
||||||
|
@ -240,8 +240,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||||
tempBufferDescriptor.size = tempBufferSize.AcquireSuccess();
|
tempBufferDescriptor.size = tempBufferSize.AcquireSuccess();
|
||||||
Device* device = ToBackend(srcCopy.texture->GetDevice());
|
Device* device = ToBackend(srcCopy.texture->GetDevice());
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
Ref<Buffer> tempBuffer =
|
Ref<Buffer> tempBuffer =
|
||||||
AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor)));
|
AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor)));
|
||||||
|
|
||||||
// Copy from source texture into tempBuffer
|
// Copy from source texture into tempBuffer
|
||||||
Texture* srcTexture = ToBackend(srcCopy.texture).Get();
|
Texture* srcTexture = ToBackend(srcCopy.texture).Get();
|
||||||
|
@ -32,7 +32,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
device->Tick();
|
// TODO(dawn:723): propagate any errors from Tick.
|
||||||
|
device->APITick();
|
||||||
|
|
||||||
CommandRecordingContext* commandContext;
|
CommandRecordingContext* commandContext;
|
||||||
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
|
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
|
||||||
|
@ -31,7 +31,10 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
device->Tick();
|
|
||||||
|
// TODO(dawn:723): propagate any errors from Tick.
|
||||||
|
device->APITick();
|
||||||
|
|
||||||
CommandRecordingContext* commandContext = device->GetPendingCommandContext();
|
CommandRecordingContext* commandContext = device->GetPendingCommandContext();
|
||||||
|
|
||||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
||||||
|
@ -113,7 +113,7 @@ namespace dawn_native { namespace metal {
|
|||||||
ASSERT(mCurrentDrawable != nullptr);
|
ASSERT(mCurrentDrawable != nullptr);
|
||||||
[*mCurrentDrawable present];
|
[*mCurrentDrawable present];
|
||||||
|
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
|
|
||||||
mCurrentDrawable = nullptr;
|
mCurrentDrawable = nullptr;
|
||||||
@ -127,16 +127,18 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this);
|
TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this);
|
||||||
|
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
mTexture = AcquireRef(
|
mTexture = AcquireRef(
|
||||||
new Texture(ToBackend(GetDevice()), &textureDesc, [*mCurrentDrawable texture]));
|
new Texture(ToBackend(GetDevice()), &textureDesc, [*mCurrentDrawable texture]));
|
||||||
return mTexture->CreateView();
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
return mTexture->APICreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapChain::DetachFromSurfaceImpl() {
|
void SwapChain::DetachFromSurfaceImpl() {
|
||||||
ASSERT((mTexture == nullptr) == (mCurrentDrawable == nullptr));
|
ASSERT((mTexture == nullptr) == (mCurrentDrawable == nullptr));
|
||||||
|
|
||||||
if (mTexture != nullptr) {
|
if (mTexture != nullptr) {
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
|
|
||||||
mCurrentDrawable = nullptr;
|
mCurrentDrawable = nullptr;
|
||||||
|
@ -375,21 +375,23 @@ namespace dawn_native { namespace null {
|
|||||||
SwapChain::~SwapChain() = default;
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
MaybeError SwapChain::PresentImpl() {
|
MaybeError SwapChain::PresentImpl() {
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<TextureViewBase*> SwapChain::GetCurrentTextureViewImpl() {
|
ResultOrError<TextureViewBase*> SwapChain::GetCurrentTextureViewImpl() {
|
||||||
TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this);
|
TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this);
|
||||||
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
mTexture = AcquireRef(
|
mTexture = AcquireRef(
|
||||||
new Texture(GetDevice(), &textureDesc, TextureBase::TextureState::OwnedInternal));
|
new Texture(GetDevice(), &textureDesc, TextureBase::TextureState::OwnedInternal));
|
||||||
return mTexture->CreateView();
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
return mTexture->APICreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapChain::DetachFromSurfaceImpl() {
|
void SwapChain::DetachFromSurfaceImpl() {
|
||||||
if (mTexture != nullptr) {
|
if (mTexture != nullptr) {
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +414,7 @@ namespace dawn_native { namespace null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
||||||
return GetDevice()->CreateTexture(descriptor);
|
return GetDevice()->APICreateTexture(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase*) {
|
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase*) {
|
||||||
|
@ -383,8 +383,10 @@ namespace dawn_native { namespace opengl {
|
|||||||
DAWN_TRY_ASSIGN(srcBuffer, Buffer::CreateInternalBuffer(device, &descriptor, false));
|
DAWN_TRY_ASSIGN(srcBuffer, Buffer::CreateInternalBuffer(device, &descriptor, false));
|
||||||
|
|
||||||
// Fill the buffer with clear color
|
// Fill the buffer with clear color
|
||||||
memset(srcBuffer->GetMappedRange(0, descriptor.size), clearColor, descriptor.size);
|
// TODO(dawn:723): propagate any errors from GetMappedRange.
|
||||||
srcBuffer->Unmap();
|
memset(srcBuffer->APIGetMappedRange(0, descriptor.size), clearColor, descriptor.size);
|
||||||
|
// TODO(dawn:723): propagate any errors from Unmap.
|
||||||
|
srcBuffer->APIUnmap();
|
||||||
|
|
||||||
// Bind buffer and texture, and make the buffer to texture copy
|
// Bind buffer and texture, and make the buffer to texture copy
|
||||||
gl.PixelStorei(GL_UNPACK_ROW_LENGTH,
|
gl.PixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||||
|
@ -465,7 +465,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
Ref<Buffer> tempBuffer = AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor)));
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
Ref<Buffer> tempBuffer =
|
||||||
|
AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor)));
|
||||||
|
|
||||||
BufferCopy tempBufferCopy;
|
BufferCopy tempBufferCopy;
|
||||||
tempBufferCopy.buffer = tempBuffer.Get();
|
tempBufferCopy.buffer = tempBuffer.Get();
|
||||||
|
@ -41,7 +41,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
device->Tick();
|
// TODO(dawn:723): propagate any errors from Tick.
|
||||||
|
device->APITick();
|
||||||
|
|
||||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
||||||
"CommandBufferVk::RecordCommands");
|
"CommandBufferVk::RecordCommands");
|
||||||
|
@ -496,7 +496,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
// TODO(cwallez@chromium.org): Find a way to reuse the blit texture between frames
|
// TODO(cwallez@chromium.org): Find a way to reuse the blit texture between frames
|
||||||
// instead of creating a new one every time. This will involve "un-destroying" the
|
// instead of creating a new one every time. This will involve "un-destroying" the
|
||||||
// texture or making the blit texture "external".
|
// texture or making the blit texture "external".
|
||||||
mBlitTexture->Destroy();
|
mBlitTexture->APIDestroy();
|
||||||
mBlitTexture = nullptr;
|
mBlitTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
presentInfo.pResults = nullptr;
|
presentInfo.pResults = nullptr;
|
||||||
|
|
||||||
// Free the texture before present so error handling doesn't skip that step.
|
// Free the texture before present so error handling doesn't skip that step.
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
|
|
||||||
VkResult result =
|
VkResult result =
|
||||||
@ -620,7 +620,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
// In the happy path we can use the swapchain image directly.
|
// In the happy path we can use the swapchain image directly.
|
||||||
if (!mConfig.needsBlit) {
|
if (!mConfig.needsBlit) {
|
||||||
return mTexture->CreateView();
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
return mTexture->APICreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The blit texture always perfectly matches what the user requested for the swapchain.
|
// The blit texture always perfectly matches what the user requested for the swapchain.
|
||||||
@ -628,17 +629,18 @@ namespace dawn_native { namespace vulkan {
|
|||||||
TextureDescriptor desc = GetSwapChainBaseTextureDescriptor(this);
|
TextureDescriptor desc = GetSwapChainBaseTextureDescriptor(this);
|
||||||
DAWN_TRY_ASSIGN(mBlitTexture,
|
DAWN_TRY_ASSIGN(mBlitTexture,
|
||||||
Texture::Create(device, &desc, VK_IMAGE_USAGE_TRANSFER_SRC_BIT));
|
Texture::Create(device, &desc, VK_IMAGE_USAGE_TRANSFER_SRC_BIT));
|
||||||
return mBlitTexture->CreateView();
|
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation.
|
||||||
|
return mBlitTexture->APICreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapChain::DetachFromSurfaceImpl() {
|
void SwapChain::DetachFromSurfaceImpl() {
|
||||||
if (mTexture != nullptr) {
|
if (mTexture != nullptr) {
|
||||||
mTexture->Destroy();
|
mTexture->APIDestroy();
|
||||||
mTexture = nullptr;
|
mTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBlitTexture != nullptr) {
|
if (mBlitTexture != nullptr) {
|
||||||
mBlitTexture->Destroy();
|
mBlitTexture->APIDestroy();
|
||||||
mBlitTexture = nullptr;
|
mBlitTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInPendingAndMultipleSubmits) {
|
|||||||
|
|
||||||
// Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|.
|
// Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|.
|
||||||
for (uint32_t i = 0; i < kFrameDepth; i++) {
|
for (uint32_t i = 0; i < kFrameDepth; i++) {
|
||||||
mD3DDevice->Tick();
|
mD3DDevice->APITick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch-over |kNumOfSwitches| again reusing the same heaps.
|
// Switch-over |kNumOfSwitches| again reusing the same heaps.
|
||||||
@ -359,7 +359,7 @@ TEST_P(D3D12DescriptorHeapTests, GrowHeapsInMultipleSubmits) {
|
|||||||
ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
|
ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
|
||||||
EXPECT_TRUE(std::find(heaps.begin(), heaps.end(), heap) == heaps.end());
|
EXPECT_TRUE(std::find(heaps.begin(), heaps.end(), heap) == heaps.end());
|
||||||
heaps.insert(heap);
|
heaps.insert(heap);
|
||||||
mD3DDevice->Tick();
|
mD3DDevice->APITick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the number of switches equals the size of heaps allocated (minus the initial).
|
// Verify the number of switches equals the size of heaps allocated (minus the initial).
|
||||||
@ -416,7 +416,7 @@ TEST_P(D3D12DescriptorHeapTests, GrowAndPoolHeapsInPendingAndMultipleSubmits) {
|
|||||||
|
|
||||||
// Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|.
|
// Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|.
|
||||||
for (uint32_t i = 0; i < kFrameDepth; i++) {
|
for (uint32_t i = 0; i < kFrameDepth; i++) {
|
||||||
mD3DDevice->Tick();
|
mD3DDevice->APITick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch-over the pool-allocated heaps.
|
// Switch-over the pool-allocated heaps.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user