2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-05-31 00:03:44 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2019-01-04 10:30:40 +00:00
|
|
|
#ifndef DAWNNATIVE_DEVICE_H_
|
|
|
|
#define DAWNNATIVE_DEVICE_H_
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-01 03:20:19 +00:00
|
|
|
#include "common/Serial.h"
|
2020-08-20 13:29:39 +00:00
|
|
|
#include "dawn_native/Commands.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/Error.h"
|
2019-08-02 00:06:38 +00:00
|
|
|
#include "dawn_native/Extensions.h"
|
2019-07-18 09:25:04 +00:00
|
|
|
#include "dawn_native/Format.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/Forward.h"
|
2018-10-15 12:54:30 +00:00
|
|
|
#include "dawn_native/ObjectBase.h"
|
2019-04-26 07:52:57 +00:00
|
|
|
#include "dawn_native/Toggles.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-09-19 00:32:52 +00:00
|
|
|
#include "dawn_native/DawnNative.h"
|
2018-07-25 15:03:23 +00:00
|
|
|
#include "dawn_native/dawn_platform.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-09-06 13:26:48 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2019-01-10 10:50:54 +00:00
|
|
|
class AdapterBase;
|
2019-07-26 19:08:18 +00:00
|
|
|
class AttachmentState;
|
2019-08-13 22:12:54 +00:00
|
|
|
class AttachmentStateBlueprint;
|
2020-03-20 21:56:30 +00:00
|
|
|
class BindGroupLayoutBase;
|
|
|
|
class DynamicUploader;
|
2019-09-10 23:19:11 +00:00
|
|
|
class ErrorScope;
|
2019-09-17 18:24:07 +00:00
|
|
|
class ErrorScopeTracker;
|
2018-12-03 16:57:34 +00:00
|
|
|
class FenceSignalTracker;
|
2020-05-19 01:29:32 +00:00
|
|
|
class MapRequestTracker;
|
2019-01-29 00:10:07 +00:00
|
|
|
class StagingBufferBase;
|
2018-12-03 16:57:34 +00:00
|
|
|
|
2017-05-31 00:03:44 +00:00
|
|
|
class DeviceBase {
|
2017-11-24 18:59:42 +00:00
|
|
|
public:
|
2019-04-26 07:52:57 +00:00
|
|
|
DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor);
|
2017-11-24 18:59:42 +00:00
|
|
|
virtual ~DeviceBase();
|
|
|
|
|
2020-04-01 12:07:43 +00:00
|
|
|
void HandleError(InternalErrorType type, const char* message);
|
2017-11-24 18:59:42 +00:00
|
|
|
|
2018-07-16 15:40:08 +00:00
|
|
|
bool ConsumedError(MaybeError maybeError) {
|
2018-07-18 11:37:54 +00:00
|
|
|
if (DAWN_UNLIKELY(maybeError.IsError())) {
|
2019-09-18 21:03:41 +00:00
|
|
|
ConsumeError(maybeError.AcquireError());
|
2018-07-16 15:40:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:11:00 +00:00
|
|
|
template <typename T>
|
|
|
|
bool ConsumedError(ResultOrError<T> resultOrError, T* result) {
|
|
|
|
if (DAWN_UNLIKELY(resultOrError.IsError())) {
|
|
|
|
ConsumeError(resultOrError.AcquireError());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
*result = resultOrError.AcquireSuccess();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-02-13 13:09:18 +00:00
|
|
|
MaybeError ValidateObject(const ObjectBase* object) const;
|
|
|
|
|
2019-01-30 16:07:48 +00:00
|
|
|
AdapterBase* GetAdapter() const;
|
2019-08-13 19:00:34 +00:00
|
|
|
dawn_platform::Platform* GetPlatform() const;
|
2019-01-30 16:07:48 +00:00
|
|
|
|
2019-09-17 18:24:07 +00:00
|
|
|
ErrorScopeTracker* GetErrorScopeTracker() const;
|
2018-12-03 16:57:34 +00:00
|
|
|
FenceSignalTracker* GetFenceSignalTracker() const;
|
2020-05-19 01:29:32 +00:00
|
|
|
MapRequestTracker* GetMapRequestTracker() const;
|
2018-12-03 16:57:34 +00:00
|
|
|
|
2019-10-23 11:57:41 +00:00
|
|
|
// Returns the Format corresponding to the wgpu::TextureFormat or an error if the format
|
|
|
|
// isn't a valid wgpu::TextureFormat or isn't supported by this device.
|
2019-07-18 09:25:04 +00:00
|
|
|
// The pointer returned has the same lifetime as the device.
|
2019-10-23 11:57:41 +00:00
|
|
|
ResultOrError<const Format*> GetInternalFormat(wgpu::TextureFormat format) const;
|
2019-07-18 09:25:04 +00:00
|
|
|
|
2019-10-23 11:57:41 +00:00
|
|
|
// Returns the Format corresponding to the wgpu::TextureFormat and assumes the format is
|
2019-07-18 09:25:04 +00:00
|
|
|
// valid and supported.
|
|
|
|
// The reference returned has the same lifetime as the device.
|
2019-10-23 11:57:41 +00:00
|
|
|
const Format& GetValidInternalFormat(wgpu::TextureFormat format) const;
|
2019-07-18 09:25:04 +00:00
|
|
|
|
2019-07-10 20:43:13 +00:00
|
|
|
virtual CommandBufferBase* CreateCommandBuffer(
|
2019-11-13 17:00:37 +00:00
|
|
|
CommandEncoder* encoder,
|
2019-07-10 20:43:13 +00:00
|
|
|
const CommandBufferDescriptor* descriptor) = 0;
|
2017-11-24 18:59:42 +00:00
|
|
|
|
2020-05-07 21:52:54 +00:00
|
|
|
Serial GetCompletedCommandSerial() const;
|
|
|
|
Serial GetLastSubmittedCommandSerial() const;
|
2020-06-04 02:26:46 +00:00
|
|
|
Serial GetFutureCallbackSerial() const;
|
2020-05-07 21:52:54 +00:00
|
|
|
Serial GetPendingCommandSerial() const;
|
2019-10-07 15:32:10 +00:00
|
|
|
virtual MaybeError TickImpl() = 0;
|
2017-11-24 18:59:42 +00:00
|
|
|
|
2018-07-18 13:28:38 +00:00
|
|
|
// Many Dawn objects are completely immutable once created which means that if two
|
2019-04-01 21:48:38 +00:00
|
|
|
// creations are given the same arguments, they can return the same object. Reusing
|
2017-11-24 18:59:42 +00:00
|
|
|
// objects will help make comparisons between objects by a single pointer comparison.
|
|
|
|
//
|
|
|
|
// Technically no object is immutable as they have a reference count, and an
|
|
|
|
// application with reference-counting issues could "see" that objects are reused.
|
|
|
|
// This is solved by automatic-reference counting, and also the fact that when using
|
|
|
|
// the client-server wire every creation will get a different proxy object, with a
|
|
|
|
// different reference count.
|
|
|
|
//
|
2019-04-01 21:48:38 +00:00
|
|
|
// When trying to create an object, we give both the descriptor and an example of what
|
|
|
|
// the created object will be, the "blueprint". The blueprint is just a FooBase object
|
2017-11-24 18:59:42 +00:00
|
|
|
// instead of a backend Foo object. If the blueprint doesn't match an object in the
|
2019-04-01 21:48:38 +00:00
|
|
|
// cache, then the descriptor is used to make a new object.
|
2020-07-01 13:09:46 +00:00
|
|
|
ResultOrError<Ref<BindGroupLayoutBase>> GetOrCreateBindGroupLayout(
|
2018-07-25 15:03:23 +00:00
|
|
|
const BindGroupLayoutDescriptor* descriptor);
|
2017-11-24 18:59:42 +00:00
|
|
|
void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
|
|
|
|
|
2020-07-01 13:09:46 +00:00
|
|
|
BindGroupLayoutBase* GetEmptyBindGroupLayout();
|
2020-06-29 11:13:43 +00:00
|
|
|
|
2019-05-01 13:48:47 +00:00
|
|
|
ResultOrError<ComputePipelineBase*> GetOrCreateComputePipeline(
|
|
|
|
const ComputePipelineDescriptor* descriptor);
|
|
|
|
void UncacheComputePipeline(ComputePipelineBase* obj);
|
|
|
|
|
2019-05-01 12:57:27 +00:00
|
|
|
ResultOrError<PipelineLayoutBase*> GetOrCreatePipelineLayout(
|
|
|
|
const PipelineLayoutDescriptor* descriptor);
|
|
|
|
void UncachePipelineLayout(PipelineLayoutBase* obj);
|
|
|
|
|
2019-05-02 15:30:56 +00:00
|
|
|
ResultOrError<RenderPipelineBase*> GetOrCreateRenderPipeline(
|
|
|
|
const RenderPipelineDescriptor* descriptor);
|
|
|
|
void UncacheRenderPipeline(RenderPipelineBase* obj);
|
|
|
|
|
2019-05-20 18:16:34 +00:00
|
|
|
ResultOrError<SamplerBase*> GetOrCreateSampler(const SamplerDescriptor* descriptor);
|
|
|
|
void UncacheSampler(SamplerBase* obj);
|
|
|
|
|
2019-05-01 13:27:07 +00:00
|
|
|
ResultOrError<ShaderModuleBase*> GetOrCreateShaderModule(
|
|
|
|
const ShaderModuleDescriptor* descriptor);
|
|
|
|
void UncacheShaderModule(ShaderModuleBase* obj);
|
|
|
|
|
2019-08-13 22:12:54 +00:00
|
|
|
Ref<AttachmentState> GetOrCreateAttachmentState(AttachmentStateBlueprint* blueprint);
|
|
|
|
Ref<AttachmentState> GetOrCreateAttachmentState(
|
|
|
|
const RenderBundleEncoderDescriptor* descriptor);
|
2019-08-07 21:47:24 +00:00
|
|
|
Ref<AttachmentState> GetOrCreateAttachmentState(const RenderPipelineDescriptor* descriptor);
|
|
|
|
Ref<AttachmentState> GetOrCreateAttachmentState(const RenderPassDescriptor* descriptor);
|
2019-07-26 19:08:18 +00:00
|
|
|
void UncacheAttachmentState(AttachmentState* obj);
|
|
|
|
|
2018-07-18 13:20:28 +00:00
|
|
|
// Dawn API
|
2018-12-05 07:18:30 +00:00
|
|
|
BindGroupBase* CreateBindGroup(const BindGroupDescriptor* descriptor);
|
2018-07-25 15:03:23 +00:00
|
|
|
BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
|
2018-08-22 13:37:29 +00:00
|
|
|
BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
|
2019-11-13 17:00:37 +00:00
|
|
|
CommandEncoder* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
|
2018-08-27 21:12:56 +00:00
|
|
|
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
2018-07-25 15:03:23 +00:00
|
|
|
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
2020-06-11 00:34:14 +00:00
|
|
|
QuerySetBase* CreateQuerySet(const QuerySetDescriptor* descriptor);
|
2018-06-15 00:26:27 +00:00
|
|
|
QueueBase* CreateQueue();
|
2019-11-13 17:00:37 +00:00
|
|
|
RenderBundleEncoder* CreateRenderBundleEncoder(
|
2019-08-13 22:12:54 +00:00
|
|
|
const RenderBundleEncoderDescriptor* descriptor);
|
2018-12-10 19:47:22 +00:00
|
|
|
RenderPipelineBase* CreateRenderPipeline(const RenderPipelineDescriptor* descriptor);
|
2018-07-25 15:03:23 +00:00
|
|
|
SamplerBase* CreateSampler(const SamplerDescriptor* descriptor);
|
2018-08-20 15:01:20 +00:00
|
|
|
ShaderModuleBase* CreateShaderModule(const ShaderModuleDescriptor* descriptor);
|
2020-01-23 17:20:38 +00:00
|
|
|
SwapChainBase* CreateSwapChain(Surface* surface, const SwapChainDescriptor* descriptor);
|
2018-08-27 00:44:48 +00:00
|
|
|
TextureBase* CreateTexture(const TextureDescriptor* descriptor);
|
2018-10-12 08:32:58 +00:00
|
|
|
TextureViewBase* CreateTextureView(TextureBase* texture,
|
|
|
|
const TextureViewDescriptor* descriptor);
|
2017-11-24 18:59:42 +00:00
|
|
|
|
2020-06-15 23:42:13 +00:00
|
|
|
// For Dawn Wire
|
|
|
|
BufferBase* CreateErrorBuffer();
|
|
|
|
|
2020-04-17 16:45:17 +00:00
|
|
|
QueueBase* GetDefaultQueue();
|
|
|
|
|
2019-10-23 11:57:41 +00:00
|
|
|
void InjectError(wgpu::ErrorType type, const char* message);
|
2017-11-24 18:59:42 +00:00
|
|
|
void Tick();
|
2018-12-01 03:20:19 +00:00
|
|
|
|
2019-12-18 18:59:20 +00:00
|
|
|
void SetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata);
|
2019-10-23 11:57:41 +00:00
|
|
|
void SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
|
|
|
|
void PushErrorScope(wgpu::ErrorFilter filter);
|
|
|
|
bool PopErrorScope(wgpu::ErrorCallback callback, void* userdata);
|
2020-01-15 19:02:13 +00:00
|
|
|
|
|
|
|
MaybeError ValidateIsAlive() const;
|
|
|
|
|
2019-09-17 18:24:07 +00:00
|
|
|
ErrorScope* GetCurrentErrorScope();
|
2019-09-04 22:54:03 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
void Reference();
|
|
|
|
void Release();
|
|
|
|
|
2019-01-29 00:10:07 +00:00
|
|
|
virtual ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(
|
|
|
|
size_t size) = 0;
|
|
|
|
virtual MaybeError CopyFromStagingToBuffer(StagingBufferBase* source,
|
2019-04-05 20:51:29 +00:00
|
|
|
uint64_t sourceOffset,
|
2019-01-29 00:10:07 +00:00
|
|
|
BufferBase* destination,
|
2019-04-05 20:51:29 +00:00
|
|
|
uint64_t destinationOffset,
|
|
|
|
uint64_t size) = 0;
|
2020-08-20 13:29:39 +00:00
|
|
|
virtual MaybeError CopyFromStagingToTexture(const StagingBufferBase* source,
|
|
|
|
const TextureDataLayout& src,
|
|
|
|
TextureCopy* dst,
|
|
|
|
const Extent3D& copySizePixels) = 0;
|
2019-01-29 00:10:07 +00:00
|
|
|
|
2019-09-18 22:06:41 +00:00
|
|
|
DynamicUploader* GetDynamicUploader() const;
|
2019-02-15 21:18:40 +00:00
|
|
|
|
2020-04-07 16:19:47 +00:00
|
|
|
// The device state which is a combination of creation state and loss state.
|
|
|
|
//
|
|
|
|
// - BeingCreated: the device didn't finish creation yet and the frontend cannot be used
|
|
|
|
// (both for the application calling WebGPU, or re-entrant calls). No work exists on
|
|
|
|
// the GPU timeline.
|
|
|
|
// - Alive: the device is usable and might have work happening on the GPU timeline.
|
|
|
|
// - BeingDisconnected: the device is no longer usable because we are waiting for all
|
|
|
|
// work on the GPU timeline to finish. (this is to make validation prevent the
|
|
|
|
// application from adding more work during the transition from Available to
|
|
|
|
// Disconnected)
|
|
|
|
// - Disconnected: there is no longer work happening on the GPU timeline and the CPU data
|
|
|
|
// structures can be safely destroyed without additional synchronization.
|
|
|
|
enum class State {
|
|
|
|
BeingCreated,
|
|
|
|
Alive,
|
|
|
|
BeingDisconnected,
|
|
|
|
Disconnected,
|
|
|
|
};
|
|
|
|
State GetState() const;
|
|
|
|
bool IsLost() const;
|
|
|
|
|
2019-08-02 00:06:38 +00:00
|
|
|
std::vector<const char*> GetEnabledExtensions() const;
|
2019-04-26 07:52:57 +00:00
|
|
|
std::vector<const char*> GetTogglesUsed() const;
|
2019-08-02 00:06:38 +00:00
|
|
|
bool IsExtensionEnabled(Extension extension) const;
|
2019-04-26 07:52:57 +00:00
|
|
|
bool IsToggleEnabled(Toggle toggle) const;
|
2019-11-21 00:48:39 +00:00
|
|
|
bool IsValidationEnabled() const;
|
2020-07-01 21:37:57 +00:00
|
|
|
bool IsRobustnessEnabled() const;
|
2019-07-26 17:54:48 +00:00
|
|
|
size_t GetLazyClearCountForTesting();
|
|
|
|
void IncrementLazyClearCountForTesting();
|
2020-04-17 16:45:17 +00:00
|
|
|
size_t GetDeprecationWarningCountForTesting();
|
|
|
|
void EmitDeprecationWarning(const char* warning);
|
2020-01-15 19:02:13 +00:00
|
|
|
void LoseForTesting();
|
2020-06-04 02:26:46 +00:00
|
|
|
void AddFutureCallbackSerial(Serial serial);
|
2019-04-26 07:52:57 +00:00
|
|
|
|
2020-08-20 13:29:39 +00:00
|
|
|
virtual uint32_t GetOptimalBytesPerRowAlignment() const = 0;
|
|
|
|
virtual uint64_t GetOptimalBufferToTextureCopyOffsetAlignment() const = 0;
|
|
|
|
|
2019-02-15 21:18:40 +00:00
|
|
|
protected:
|
2019-04-26 07:52:57 +00:00
|
|
|
void SetToggle(Toggle toggle, bool isEnabled);
|
2020-04-06 16:55:22 +00:00
|
|
|
void ForceSetToggle(Toggle toggle, bool isEnabled);
|
2020-04-07 15:10:17 +00:00
|
|
|
|
2020-04-17 16:45:17 +00:00
|
|
|
MaybeError Initialize(QueueBase* defaultQueue);
|
2020-04-07 16:19:47 +00:00
|
|
|
void ShutDownBase();
|
2019-02-15 21:18:40 +00:00
|
|
|
|
2020-05-07 21:52:54 +00:00
|
|
|
// Incrememt mLastSubmittedSerial when we submit the next serial
|
|
|
|
void IncrementLastSubmittedCommandSerial();
|
|
|
|
// Check for passed fences and set the new completed serial
|
|
|
|
void CheckPassedSerials();
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
private:
|
2018-12-05 07:18:30 +00:00
|
|
|
virtual ResultOrError<BindGroupBase*> CreateBindGroupImpl(
|
|
|
|
const BindGroupDescriptor* descriptor) = 0;
|
2018-07-10 19:23:50 +00:00
|
|
|
virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
|
2018-07-25 15:03:23 +00:00
|
|
|
const BindGroupLayoutDescriptor* descriptor) = 0;
|
2020-07-08 19:45:40 +00:00
|
|
|
virtual ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
|
|
|
const BufferDescriptor* descriptor) = 0;
|
2018-08-27 21:12:56 +00:00
|
|
|
virtual ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
|
|
|
|
const ComputePipelineDescriptor* descriptor) = 0;
|
2018-06-27 23:21:39 +00:00
|
|
|
virtual ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
|
2018-07-25 15:03:23 +00:00
|
|
|
const PipelineLayoutDescriptor* descriptor) = 0;
|
2020-06-11 00:34:14 +00:00
|
|
|
virtual ResultOrError<QuerySetBase*> CreateQuerySetImpl(
|
|
|
|
const QuerySetDescriptor* descriptor) = 0;
|
2018-12-10 19:47:22 +00:00
|
|
|
virtual ResultOrError<RenderPipelineBase*> CreateRenderPipelineImpl(
|
|
|
|
const RenderPipelineDescriptor* descriptor) = 0;
|
2018-05-28 19:40:41 +00:00
|
|
|
virtual ResultOrError<SamplerBase*> CreateSamplerImpl(
|
2018-07-25 15:03:23 +00:00
|
|
|
const SamplerDescriptor* descriptor) = 0;
|
2018-08-20 15:01:20 +00:00
|
|
|
virtual ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
|
|
|
|
const ShaderModuleDescriptor* descriptor) = 0;
|
2019-02-15 11:15:58 +00:00
|
|
|
virtual ResultOrError<SwapChainBase*> CreateSwapChainImpl(
|
|
|
|
const SwapChainDescriptor* descriptor) = 0;
|
2020-01-25 10:05:40 +00:00
|
|
|
// Note that previousSwapChain may be nullptr, or come from a different backend.
|
|
|
|
virtual ResultOrError<NewSwapChainBase*> CreateSwapChainImpl(
|
2020-01-23 17:20:38 +00:00
|
|
|
Surface* surface,
|
2020-01-25 10:05:40 +00:00
|
|
|
NewSwapChainBase* previousSwapChain,
|
2020-01-23 17:20:38 +00:00
|
|
|
const SwapChainDescriptor* descriptor) = 0;
|
2020-04-23 19:47:12 +00:00
|
|
|
virtual ResultOrError<Ref<TextureBase>> CreateTextureImpl(
|
2018-08-27 00:44:48 +00:00
|
|
|
const TextureDescriptor* descriptor) = 0;
|
2018-10-12 08:32:58 +00:00
|
|
|
virtual ResultOrError<TextureViewBase*> CreateTextureViewImpl(
|
|
|
|
TextureBase* texture,
|
|
|
|
const TextureViewDescriptor* descriptor) = 0;
|
2018-05-17 21:09:07 +00:00
|
|
|
|
2020-07-01 13:09:46 +00:00
|
|
|
ResultOrError<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
|
|
|
|
|
2018-12-05 07:18:30 +00:00
|
|
|
MaybeError CreateBindGroupInternal(BindGroupBase** result,
|
|
|
|
const BindGroupDescriptor* descriptor);
|
2018-07-16 15:40:08 +00:00
|
|
|
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
|
2018-07-25 15:03:23 +00:00
|
|
|
const BindGroupLayoutDescriptor* descriptor);
|
2020-07-08 19:45:40 +00:00
|
|
|
ResultOrError<Ref<BufferBase>> CreateBufferInternal(const BufferDescriptor* descriptor);
|
2018-08-27 21:12:56 +00:00
|
|
|
MaybeError CreateComputePipelineInternal(ComputePipelineBase** result,
|
|
|
|
const ComputePipelineDescriptor* descriptor);
|
2018-07-16 15:40:08 +00:00
|
|
|
MaybeError CreatePipelineLayoutInternal(PipelineLayoutBase** result,
|
2018-07-25 15:03:23 +00:00
|
|
|
const PipelineLayoutDescriptor* descriptor);
|
2020-06-11 00:34:14 +00:00
|
|
|
MaybeError CreateQuerySetInternal(QuerySetBase** result,
|
|
|
|
const QuerySetDescriptor* descriptor);
|
2019-08-13 22:12:54 +00:00
|
|
|
MaybeError CreateRenderBundleEncoderInternal(
|
2019-11-13 17:00:37 +00:00
|
|
|
RenderBundleEncoder** result,
|
2019-08-13 22:12:54 +00:00
|
|
|
const RenderBundleEncoderDescriptor* descriptor);
|
2018-12-10 19:47:22 +00:00
|
|
|
MaybeError CreateRenderPipelineInternal(RenderPipelineBase** result,
|
|
|
|
const RenderPipelineDescriptor* descriptor);
|
2018-07-25 15:03:23 +00:00
|
|
|
MaybeError CreateSamplerInternal(SamplerBase** result, const SamplerDescriptor* descriptor);
|
2018-08-20 15:01:20 +00:00
|
|
|
MaybeError CreateShaderModuleInternal(ShaderModuleBase** result,
|
|
|
|
const ShaderModuleDescriptor* descriptor);
|
2019-02-15 11:15:58 +00:00
|
|
|
MaybeError CreateSwapChainInternal(SwapChainBase** result,
|
2020-01-23 17:20:38 +00:00
|
|
|
Surface* surface,
|
2019-02-15 11:15:58 +00:00
|
|
|
const SwapChainDescriptor* descriptor);
|
2020-04-23 19:47:12 +00:00
|
|
|
ResultOrError<Ref<TextureBase>> CreateTextureInternal(const TextureDescriptor* descriptor);
|
2018-10-12 08:32:58 +00:00
|
|
|
MaybeError CreateTextureViewInternal(TextureViewBase** result,
|
|
|
|
TextureBase* texture,
|
|
|
|
const TextureViewDescriptor* descriptor);
|
2018-07-16 15:40:08 +00:00
|
|
|
|
2020-04-06 16:55:22 +00:00
|
|
|
void ApplyToggleOverrides(const DeviceDescriptor* deviceDescriptor);
|
2019-08-02 00:06:38 +00:00
|
|
|
void ApplyExtensions(const DeviceDescriptor* deviceDescriptor);
|
|
|
|
|
2019-06-11 18:11:05 +00:00
|
|
|
void SetDefaultToggles();
|
2018-07-16 15:40:08 +00:00
|
|
|
|
2020-01-10 17:58:28 +00:00
|
|
|
void ConsumeError(std::unique_ptr<ErrorData> error);
|
2019-09-18 21:03:41 +00:00
|
|
|
|
2020-05-07 21:52:54 +00:00
|
|
|
// Each backend should implement to check their passed fences if there are any and return a
|
|
|
|
// completed serial. Return 0 should indicate no fences to check.
|
|
|
|
virtual Serial CheckAndUpdateCompletedSerials() = 0;
|
2020-06-04 02:26:46 +00:00
|
|
|
// During shut down of device, some operations might have been started since the last submit
|
|
|
|
// and waiting on a serial that doesn't have a corresponding fence enqueued. Fake serials to
|
|
|
|
// make all commands look completed.
|
|
|
|
void AssumeCommandsComplete();
|
2020-05-07 21:52:54 +00:00
|
|
|
// mCompletedSerial tracks the last completed command serial that the fence has returned.
|
|
|
|
// mLastSubmittedSerial tracks the last submitted command serial.
|
|
|
|
// During device removal, the serials could be artificially incremented
|
|
|
|
// to make it appear as if commands have been compeleted. They can also be artificially
|
|
|
|
// incremented when no work is being done in the GPU so CPU operations don't have to wait on
|
|
|
|
// stale serials.
|
2020-06-04 02:26:46 +00:00
|
|
|
// mFutureCallbackSerial tracks the largest serial we need to tick to for the callbacks to
|
|
|
|
// fire
|
2020-05-07 21:52:54 +00:00
|
|
|
Serial mCompletedSerial = 0;
|
|
|
|
Serial mLastSubmittedSerial = 0;
|
2020-06-04 02:26:46 +00:00
|
|
|
Serial mFutureCallbackSerial = 0;
|
2020-05-07 21:52:54 +00:00
|
|
|
|
2020-04-07 16:19:47 +00:00
|
|
|
// ShutDownImpl is used to clean up and release resources used by device, does not wait for
|
|
|
|
// GPU or check errors.
|
|
|
|
virtual void ShutDownImpl() = 0;
|
2019-12-16 23:36:16 +00:00
|
|
|
|
|
|
|
// WaitForIdleForDestruction waits for GPU to finish, checks errors and gets ready for
|
|
|
|
// destruction. This is only used when properly destructing the device. For a real
|
|
|
|
// device loss, this function doesn't need to be called since the driver already closed all
|
|
|
|
// resources.
|
|
|
|
virtual MaybeError WaitForIdleForDestruction() = 0;
|
|
|
|
|
2019-12-18 18:59:20 +00:00
|
|
|
wgpu::DeviceLostCallback mDeviceLostCallback = nullptr;
|
2020-04-07 16:19:47 +00:00
|
|
|
void* mDeviceLostUserdata = nullptr;
|
2019-12-18 18:59:20 +00:00
|
|
|
|
2019-01-10 10:50:54 +00:00
|
|
|
AdapterBase* mAdapter = nullptr;
|
|
|
|
|
2019-09-10 23:19:11 +00:00
|
|
|
Ref<ErrorScope> mRootErrorScope;
|
|
|
|
Ref<ErrorScope> mCurrentErrorScope;
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
// The object caches aren't exposed in the header as they would require a lot of
|
|
|
|
// additional includes.
|
|
|
|
struct Caches;
|
2018-09-06 13:26:48 +00:00
|
|
|
std::unique_ptr<Caches> mCaches;
|
2017-11-24 18:59:42 +00:00
|
|
|
|
2020-06-29 11:13:43 +00:00
|
|
|
Ref<BindGroupLayoutBase> mEmptyBindGroupLayout;
|
|
|
|
|
2020-04-07 16:19:47 +00:00
|
|
|
std::unique_ptr<DynamicUploader> mDynamicUploader;
|
2019-09-17 18:24:07 +00:00
|
|
|
std::unique_ptr<ErrorScopeTracker> mErrorScopeTracker;
|
2018-12-03 16:57:34 +00:00
|
|
|
std::unique_ptr<FenceSignalTracker> mFenceSignalTracker;
|
2020-05-19 01:29:32 +00:00
|
|
|
std::unique_ptr<MapRequestTracker> mMapRequestTracker;
|
2020-04-17 16:45:17 +00:00
|
|
|
Ref<QueueBase> mDefaultQueue;
|
|
|
|
|
|
|
|
struct DeprecationWarnings;
|
|
|
|
std::unique_ptr<DeprecationWarnings> mDeprecationWarnings;
|
2018-12-03 16:57:34 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
uint32_t mRefCount = 1;
|
2020-04-07 16:19:47 +00:00
|
|
|
State mState = State::BeingCreated;
|
2019-04-26 07:52:57 +00:00
|
|
|
|
2019-07-18 09:25:04 +00:00
|
|
|
FormatTable mFormatTable;
|
|
|
|
|
2020-04-06 08:32:01 +00:00
|
|
|
TogglesSet mEnabledToggles;
|
2020-04-06 16:55:22 +00:00
|
|
|
TogglesSet mOverridenToggles;
|
2019-07-26 17:54:48 +00:00
|
|
|
size_t mLazyClearCountForTesting = 0;
|
2019-08-02 00:06:38 +00:00
|
|
|
|
|
|
|
ExtensionsSet mEnabledExtensions;
|
2017-05-31 00:03:44 +00:00
|
|
|
};
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-01-04 10:30:40 +00:00
|
|
|
#endif // DAWNNATIVE_DEVICE_H_
|