From b703def640ba50aea8055b5facb9fefd77babfcc Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 14 Jun 2018 20:26:27 -0400 Subject: [PATCH] Add Device::CreateQueue() instead of the builder We are changing all object creation to use descriptors but there is no creation argument to pass for queue, so instead Device::CreateQueue takes no argument. --- examples/Animometer.cpp | 2 +- examples/CHelloTriangle.cpp | 7 +------ examples/ComputeBoids.cpp | 2 +- examples/HelloCompute.cpp | 2 +- examples/HelloDepthStencil.cpp | 2 +- examples/HelloIndices.cpp | 2 +- examples/HelloInstancing.cpp | 2 +- examples/HelloTriangle.cpp | 2 +- examples/HelloUBO.cpp | 2 +- examples/HelloVertices.cpp | 2 +- examples/RenderToTexture.cpp | 2 +- examples/glTFViewer/glTFViewer.cpp | 2 +- next.json | 13 ++----------- src/backend/Device.cpp | 12 +++++++++--- src/backend/Device.h | 4 ++-- src/backend/Forward.h | 1 - src/backend/Queue.cpp | 11 +---------- src/backend/Queue.h | 11 +---------- src/backend/d3d12/D3D12Backend.cpp | 4 ++-- src/backend/d3d12/D3D12Backend.h | 2 +- src/backend/d3d12/QueueD3D12.cpp | 12 +++++++----- src/backend/d3d12/QueueD3D12.h | 4 +--- src/backend/metal/MetalBackend.h | 10 ++-------- src/backend/metal/MetalBackend.mm | 19 ++++--------------- src/backend/null/NullBackend.cpp | 6 +++--- src/backend/null/NullBackend.h | 4 ++-- src/backend/opengl/OpenGLBackend.cpp | 6 +++--- src/backend/opengl/OpenGLBackend.h | 4 ++-- src/backend/vulkan/VulkanBackend.cpp | 6 +++--- src/backend/vulkan/VulkanBackend.h | 4 ++-- src/tests/NXTTest.cpp | 2 +- src/tests/unittests/WireTests.cpp | 10 ++-------- .../validation/BufferValidationTests.cpp | 2 +- .../PushConstantsValidationTests.cpp | 2 +- .../validation/UsageValidationTests.cpp | 2 +- 35 files changed, 65 insertions(+), 115 deletions(-) diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp index f483075b2a..7194a187c8 100644 --- a/examples/Animometer.cpp +++ b/examples/Animometer.cpp @@ -46,7 +46,7 @@ static std::vector shaderData; void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp index 456aefa31b..df0f5e693c 100644 --- a/examples/CHelloTriangle.cpp +++ b/examples/CHelloTriangle.cpp @@ -26,12 +26,7 @@ nxtTextureFormat swapChainFormat; void init() { device = CreateCppNXTDevice().Release(); - - { - nxtQueueBuilder builder = nxtDeviceCreateQueueBuilder(device); - queue = nxtQueueBuilderGetResult(builder); - nxtQueueBuilderRelease(builder); - } + queue = nxtDeviceCreateQueue(device); { nxtSwapChainBuilder builder = nxtDeviceCreateSwapChainBuilder(device); diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index d3e37992f2..ca399e0ae9 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -286,7 +286,7 @@ nxt::CommandBuffer createCommandBuffer(const nxt::RenderPassDescriptor& renderPa void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloCompute.cpp b/examples/HelloCompute.cpp index a9f2c8a568..eb02f177fd 100644 --- a/examples/HelloCompute.cpp +++ b/examples/HelloCompute.cpp @@ -32,7 +32,7 @@ nxt::BindGroup computeBindGroup; void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloDepthStencil.cpp b/examples/HelloDepthStencil.cpp index f0506929c9..2252d01cf6 100644 --- a/examples/HelloDepthStencil.cpp +++ b/examples/HelloDepthStencil.cpp @@ -113,7 +113,7 @@ struct CameraData { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloIndices.cpp b/examples/HelloIndices.cpp index 3a350fa2aa..b628480191 100644 --- a/examples/HelloIndices.cpp +++ b/examples/HelloIndices.cpp @@ -46,7 +46,7 @@ void initBuffers() { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloInstancing.cpp b/examples/HelloInstancing.cpp index 7b62e94811..6146a2c82f 100644 --- a/examples/HelloInstancing.cpp +++ b/examples/HelloInstancing.cpp @@ -49,7 +49,7 @@ void initBuffers() { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloTriangle.cpp b/examples/HelloTriangle.cpp index 20767243a3..3d1636fcce 100644 --- a/examples/HelloTriangle.cpp +++ b/examples/HelloTriangle.cpp @@ -79,7 +79,7 @@ void initTextures() { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloUBO.cpp b/examples/HelloUBO.cpp index 1c280a19cb..55cc9cbedf 100644 --- a/examples/HelloUBO.cpp +++ b/examples/HelloUBO.cpp @@ -30,7 +30,7 @@ struct {uint32_t a; float b;} s; void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/HelloVertices.cpp b/examples/HelloVertices.cpp index 798aef106d..34c348b598 100644 --- a/examples/HelloVertices.cpp +++ b/examples/HelloVertices.cpp @@ -40,7 +40,7 @@ void initBuffers() { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/RenderToTexture.cpp b/examples/RenderToTexture.cpp index 41cd131f65..996f6d4c9a 100644 --- a/examples/RenderToTexture.cpp +++ b/examples/RenderToTexture.cpp @@ -150,7 +150,7 @@ void initPipelinePost() { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index bb00f357f1..eca552da06 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -458,7 +458,7 @@ namespace { void init() { device = CreateCppNXTDevice(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); swapchain = GetSwapChain(device); swapchain.Configure(GetPreferredSwapChainTextureFormat(), nxt::TextureUsageBit::OutputAttachment, 640, 480); diff --git a/next.json b/next.json index 0e9e30d99a..938556af1d 100644 --- a/next.json +++ b/next.json @@ -612,8 +612,8 @@ "returns": "pipeline layout builder" }, { - "name": "create queue builder", - "returns": "queue builder" + "name": "create queue", + "returns": "queue" }, { "name": "create sampler", @@ -808,15 +808,6 @@ } ] }, - "queue builder": { - "category": "object", - "methods": [ - { - "name": "get result", - "returns": "queue" - } - ] - }, "render pass descriptor builder": { "category": "object", "methods": [ diff --git a/src/backend/Device.cpp b/src/backend/Device.cpp index 760626b6c5..8b08a40713 100644 --- a/src/backend/Device.cpp +++ b/src/backend/Device.cpp @@ -122,8 +122,14 @@ namespace backend { PipelineLayoutBuilder* DeviceBase::CreatePipelineLayoutBuilder() { return new PipelineLayoutBuilder(this); } - QueueBuilder* DeviceBase::CreateQueueBuilder() { - return new QueueBuilder(this); + QueueBase* DeviceBase::CreateQueue() { + ResultOrError maybeQueue = CreateQueueImpl(); + if (maybeQueue.IsError()) { + // TODO(cwallez@chromium.org): Implement the WebGPU error handling mechanism. + delete maybeQueue.AcquireError(); + return nullptr; + } + return maybeQueue.AcquireSuccess(); } RenderPassDescriptorBuilder* DeviceBase::CreateRenderPassDescriptorBuilder() { return new RenderPassDescriptorBuilder(this); @@ -142,7 +148,7 @@ namespace backend { ResultOrError maybeSampler = CreateSamplerImpl(descriptor); if (maybeSampler.IsError()) { // TODO(cwallez@chromium.org): Implement the WebGPU error handling mechanism. - delete validation.AcquireError(); + delete maybeSampler.AcquireError(); return nullptr; } return maybeSampler.AcquireSuccess(); diff --git a/src/backend/Device.h b/src/backend/Device.h index cc7d8e31a7..93dee15ff1 100644 --- a/src/backend/Device.h +++ b/src/backend/Device.h @@ -46,7 +46,6 @@ namespace backend { DepthStencilStateBuilder* builder) = 0; virtual InputStateBase* CreateInputState(InputStateBuilder* builder) = 0; virtual PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) = 0; - virtual QueueBase* CreateQueue(QueueBuilder* builder) = 0; virtual RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) = 0; virtual RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) = 0; @@ -85,7 +84,7 @@ namespace backend { DepthStencilStateBuilder* CreateDepthStencilStateBuilder(); InputStateBuilder* CreateInputStateBuilder(); PipelineLayoutBuilder* CreatePipelineLayoutBuilder(); - QueueBuilder* CreateQueueBuilder(); + QueueBase* CreateQueue(); RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder(); RenderPipelineBuilder* CreateRenderPipelineBuilder(); SamplerBase* CreateSampler(const nxt::SamplerDescriptor* descriptor); @@ -99,6 +98,7 @@ namespace backend { void Release(); private: + virtual ResultOrError CreateQueueImpl() = 0; virtual ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) = 0; diff --git a/src/backend/Forward.h b/src/backend/Forward.h index 3c76d8d7e7..4e06a8070c 100644 --- a/src/backend/Forward.h +++ b/src/backend/Forward.h @@ -40,7 +40,6 @@ namespace backend { class PipelineLayoutBase; class PipelineLayoutBuilder; class QueueBase; - class QueueBuilder; class RenderPassDescriptorBase; class RenderPassDescriptorBuilder; class RenderPipelineBase; diff --git a/src/backend/Queue.cpp b/src/backend/Queue.cpp index 8a8ef7b5b8..a8d140bc3f 100644 --- a/src/backend/Queue.cpp +++ b/src/backend/Queue.cpp @@ -21,7 +21,7 @@ namespace backend { // QueueBase - QueueBase::QueueBase(QueueBuilder* builder) : mDevice(builder->mDevice) { + QueueBase::QueueBase(DeviceBase* device) : mDevice(device) { } DeviceBase* QueueBase::GetDevice() { @@ -32,13 +32,4 @@ namespace backend { return command->ValidateResourceUsagesImmediate(); } - // QueueBuilder - - QueueBuilder::QueueBuilder(DeviceBase* device) : Builder(device) { - } - - QueueBase* QueueBuilder::GetResultImpl() { - return mDevice->CreateQueue(this); - } - } // namespace backend diff --git a/src/backend/Queue.h b/src/backend/Queue.h index daa04ab434..3ae10ef077 100644 --- a/src/backend/Queue.h +++ b/src/backend/Queue.h @@ -25,7 +25,7 @@ namespace backend { class QueueBase : public RefCounted { public: - QueueBase(QueueBuilder* builder); + QueueBase(DeviceBase* device); DeviceBase* GetDevice(); @@ -48,15 +48,6 @@ namespace backend { DeviceBase* mDevice; }; - class QueueBuilder : public Builder { - public: - QueueBuilder(DeviceBase* device); - - private: - friend class QueueBase; - QueueBase* GetResultImpl() override; - }; - } // namespace backend #endif // BACKEND_QUEUE_H_ diff --git a/src/backend/d3d12/D3D12Backend.cpp b/src/backend/d3d12/D3D12Backend.cpp index 9e4d863d84..c5a85b1efe 100644 --- a/src/backend/d3d12/D3D12Backend.cpp +++ b/src/backend/d3d12/D3D12Backend.cpp @@ -288,8 +288,8 @@ namespace backend { namespace d3d12 { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { return new PipelineLayout(this, builder); } - QueueBase* Device::CreateQueue(QueueBuilder* builder) { - return new Queue(this, builder); + ResultOrError Device::CreateQueueImpl() { + return new Queue(this); } RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) { diff --git a/src/backend/d3d12/D3D12Backend.h b/src/backend/d3d12/D3D12Backend.h index 4269a46d87..03392957c8 100644 --- a/src/backend/d3d12/D3D12Backend.h +++ b/src/backend/d3d12/D3D12Backend.h @@ -96,7 +96,6 @@ namespace backend { namespace d3d12 { DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override; - QueueBase* CreateQueue(QueueBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override; @@ -128,6 +127,7 @@ namespace backend { namespace d3d12 { void ExecuteCommandLists(std::initializer_list commandLists); private: + ResultOrError CreateQueueImpl() override; ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) override; diff --git a/src/backend/d3d12/QueueD3D12.cpp b/src/backend/d3d12/QueueD3D12.cpp index 861ba18f82..b67d6aaa1c 100644 --- a/src/backend/d3d12/QueueD3D12.cpp +++ b/src/backend/d3d12/QueueD3D12.cpp @@ -19,21 +19,23 @@ namespace backend { namespace d3d12 { - Queue::Queue(Device* device, QueueBuilder* builder) : QueueBase(builder), mDevice(device) { + Queue::Queue(Device* device) : QueueBase(device) { } void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { - mDevice->Tick(); + Device* device = ToBackend(GetDevice()); - mDevice->OpenCommandList(&mCommandList); + device->Tick(); + + device->OpenCommandList(&mCommandList); for (uint32_t i = 0; i < numCommands; ++i) { commands[i]->FillCommands(mCommandList); } ASSERT_SUCCESS(mCommandList->Close()); - mDevice->ExecuteCommandLists({mCommandList.Get()}); + device->ExecuteCommandLists({mCommandList.Get()}); - mDevice->NextSerial(); + device->NextSerial(); } }} // namespace backend::d3d12 diff --git a/src/backend/d3d12/QueueD3D12.h b/src/backend/d3d12/QueueD3D12.h index c0adb2a7b6..14fa21e0c0 100644 --- a/src/backend/d3d12/QueueD3D12.h +++ b/src/backend/d3d12/QueueD3D12.h @@ -26,14 +26,12 @@ namespace backend { namespace d3d12 { class Queue : public QueueBase { public: - Queue(Device* device, QueueBuilder* builder); + Queue(Device* device); // NXT API void Submit(uint32_t numCommands, CommandBuffer* const* commands); private: - Device* mDevice; - ComPtr mCommandList; }; diff --git a/src/backend/metal/MetalBackend.h b/src/backend/metal/MetalBackend.h index e96575e596..b9d72b4dd7 100644 --- a/src/backend/metal/MetalBackend.h +++ b/src/backend/metal/MetalBackend.h @@ -97,7 +97,6 @@ namespace backend { namespace metal { DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override; - QueueBase* CreateQueue(QueueBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override; @@ -118,6 +117,7 @@ namespace backend { namespace metal { ResourceUploader* GetResourceUploader() const; private: + ResultOrError CreateQueueImpl() override; ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) override; @@ -145,16 +145,10 @@ namespace backend { namespace metal { class Queue : public QueueBase { public: - Queue(QueueBuilder* builder); - ~Queue(); - - id GetMTLCommandQueue(); + Queue(Device* device); // NXT API void Submit(uint32_t numCommands, CommandBuffer* const* commands); - - private: - id mCommandQueue = nil; }; class RenderPassDescriptor : public RenderPassDescriptorBase { diff --git a/src/backend/metal/MetalBackend.mm b/src/backend/metal/MetalBackend.mm index 6071caca94..30cb797a72 100644 --- a/src/backend/metal/MetalBackend.mm +++ b/src/backend/metal/MetalBackend.mm @@ -107,9 +107,6 @@ namespace backend { namespace metal { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { return new PipelineLayout(builder); } - QueueBase* Device::CreateQueue(QueueBuilder* builder) { - return new Queue(builder); - } RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) { return new RenderPassDescriptor(builder); @@ -117,6 +114,9 @@ namespace backend { namespace metal { RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { return new RenderPipeline(builder); } + ResultOrError Device::CreateQueueImpl() { + return new Queue(this); + } ResultOrError Device::CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) { return new Sampler(this, descriptor); @@ -203,18 +203,7 @@ namespace backend { namespace metal { // Queue - Queue::Queue(QueueBuilder* builder) : QueueBase(builder) { - Device* device = ToBackend(builder->GetDevice()); - mCommandQueue = [device->GetMTLDevice() newCommandQueue]; - } - - Queue::~Queue() { - [mCommandQueue release]; - mCommandQueue = nil; - } - - id Queue::GetMTLCommandQueue() { - return mCommandQueue; + Queue::Queue(Device* device) : QueueBase(device) { } void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { diff --git a/src/backend/null/NullBackend.cpp b/src/backend/null/NullBackend.cpp index 82b8405930..26da79a21f 100644 --- a/src/backend/null/NullBackend.cpp +++ b/src/backend/null/NullBackend.cpp @@ -66,8 +66,8 @@ namespace backend { namespace null { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { return new PipelineLayout(builder); } - QueueBase* Device::CreateQueue(QueueBuilder* builder) { - return new Queue(builder); + ResultOrError Device::CreateQueueImpl() { + return new Queue(this); } RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) { @@ -205,7 +205,7 @@ namespace backend { namespace null { // Queue - Queue::Queue(QueueBuilder* builder) : QueueBase(builder) { + Queue::Queue(Device* device) : QueueBase(device) { } Queue::~Queue() { diff --git a/src/backend/null/NullBackend.h b/src/backend/null/NullBackend.h index 1c22689c37..9af570bd78 100644 --- a/src/backend/null/NullBackend.h +++ b/src/backend/null/NullBackend.h @@ -105,7 +105,6 @@ namespace backend { namespace null { DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override; - QueueBase* CreateQueue(QueueBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override; @@ -120,6 +119,7 @@ namespace backend { namespace null { std::vector> AcquirePendingOperations(); private: + ResultOrError CreateQueueImpl() override; ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) override; @@ -159,7 +159,7 @@ namespace backend { namespace null { class Queue : public QueueBase { public: - Queue(QueueBuilder* builder); + Queue(Device* device); ~Queue(); // NXT API diff --git a/src/backend/opengl/OpenGLBackend.cpp b/src/backend/opengl/OpenGLBackend.cpp index e8638f8da7..6aec34db1e 100644 --- a/src/backend/opengl/OpenGLBackend.cpp +++ b/src/backend/opengl/OpenGLBackend.cpp @@ -76,8 +76,8 @@ namespace backend { namespace opengl { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { return new PipelineLayout(builder); } - QueueBase* Device::CreateQueue(QueueBuilder* builder) { - return new Queue(builder); + ResultOrError Device::CreateQueueImpl() { + return new Queue(this); } RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) { @@ -119,7 +119,7 @@ namespace backend { namespace opengl { // Queue - Queue::Queue(QueueBuilder* builder) : QueueBase(builder) { + Queue::Queue(Device* device) : QueueBase(device) { } void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { diff --git a/src/backend/opengl/OpenGLBackend.h b/src/backend/opengl/OpenGLBackend.h index 6c292aab73..a6dc1b7f4e 100644 --- a/src/backend/opengl/OpenGLBackend.h +++ b/src/backend/opengl/OpenGLBackend.h @@ -93,7 +93,6 @@ namespace backend { namespace opengl { DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override; - QueueBase* CreateQueue(QueueBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override; @@ -105,6 +104,7 @@ namespace backend { namespace opengl { void TickImpl() override; private: + ResultOrError CreateQueueImpl() override; ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) override; }; @@ -121,7 +121,7 @@ namespace backend { namespace opengl { class Queue : public QueueBase { public: - Queue(QueueBuilder* builder); + Queue(Device* device); // NXT API void Submit(uint32_t numCommands, CommandBuffer* const* commands); diff --git a/src/backend/vulkan/VulkanBackend.cpp b/src/backend/vulkan/VulkanBackend.cpp index e6a5425de7..326c95c342 100644 --- a/src/backend/vulkan/VulkanBackend.cpp +++ b/src/backend/vulkan/VulkanBackend.cpp @@ -243,8 +243,8 @@ namespace backend { namespace vulkan { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { return new PipelineLayout(builder); } - QueueBase* Device::CreateQueue(QueueBuilder* builder) { - return new Queue(builder); + ResultOrError Device::CreateQueueImpl() { + return new Queue(this); } RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) { @@ -677,7 +677,7 @@ namespace backend { namespace vulkan { // Queue - Queue::Queue(QueueBuilder* builder) : QueueBase(builder) { + Queue::Queue(Device* device) : QueueBase(device) { } Queue::~Queue() { diff --git a/src/backend/vulkan/VulkanBackend.h b/src/backend/vulkan/VulkanBackend.h index acfdd61779..c2f45591a3 100644 --- a/src/backend/vulkan/VulkanBackend.h +++ b/src/backend/vulkan/VulkanBackend.h @@ -121,7 +121,6 @@ namespace backend { namespace vulkan { DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override; - QueueBase* CreateQueue(QueueBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override; @@ -133,6 +132,7 @@ namespace backend { namespace vulkan { void TickImpl() override; private: + ResultOrError CreateQueueImpl() override; ResultOrError CreateSamplerImpl( const nxt::SamplerDescriptor* descriptor) override; @@ -203,7 +203,7 @@ namespace backend { namespace vulkan { class Queue : public QueueBase { public: - Queue(QueueBuilder* builder); + Queue(Device* device); ~Queue(); // NXT API diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index 5ecebda60a..12d24c933d 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -167,7 +167,7 @@ void NXTTest::SetUp() { // deferred expectations. nxtSetProcs(&procs); device = nxt::Device::Acquire(cDevice); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); // The swapchain isn't used by tests but is useful when debugging with graphics debuggers that // capture at frame boundaries. diff --git a/src/tests/unittests/WireTests.cpp b/src/tests/unittests/WireTests.cpp index 7c82545ed8..8c0381a011 100644 --- a/src/tests/unittests/WireTests.cpp +++ b/src/tests/unittests/WireTests.cpp @@ -367,15 +367,9 @@ TEST_F(WireTests, ObjectsAsPointerArgument) { } // Create queue - nxtQueueBuilder queueBuilder = nxtDeviceCreateQueueBuilder(device); - nxtQueue queue = nxtQueueBuilderGetResult(queueBuilder); - - nxtQueueBuilder apiQueueBuilder = api.GetNewQueueBuilder(); - EXPECT_CALL(api, DeviceCreateQueueBuilder(apiDevice)) - .WillOnce(Return(apiQueueBuilder)); - + nxtQueue queue = nxtDeviceCreateQueue(device); nxtQueue apiQueue = api.GetNewQueue(); - EXPECT_CALL(api, QueueBuilderGetResult(apiQueueBuilder)) + EXPECT_CALL(api, DeviceCreateQueue(apiDevice)) .WillOnce(Return(apiQueue)); // Submit command buffer and check we got a call with both API-side command buffers diff --git a/src/tests/unittests/validation/BufferValidationTests.cpp b/src/tests/unittests/validation/BufferValidationTests.cpp index 675eefabc1..5836c0b11f 100644 --- a/src/tests/unittests/validation/BufferValidationTests.cpp +++ b/src/tests/unittests/validation/BufferValidationTests.cpp @@ -72,7 +72,7 @@ class BufferValidationTest : public ValidationTest { mockBufferMapReadCallback = new MockBufferMapReadCallback; mockBufferMapWriteCallback = new MockBufferMapWriteCallback; - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); } void TearDown() override { diff --git a/src/tests/unittests/validation/PushConstantsValidationTests.cpp b/src/tests/unittests/validation/PushConstantsValidationTests.cpp index ee4d02fe18..22ea42423b 100644 --- a/src/tests/unittests/validation/PushConstantsValidationTests.cpp +++ b/src/tests/unittests/validation/PushConstantsValidationTests.cpp @@ -40,7 +40,7 @@ class PushConstantTest : public ValidationTest { private: void SetUp() override { ValidationTest::SetUp(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); } }; diff --git a/src/tests/unittests/validation/UsageValidationTests.cpp b/src/tests/unittests/validation/UsageValidationTests.cpp index 0b18d67955..4b24cb3163 100644 --- a/src/tests/unittests/validation/UsageValidationTests.cpp +++ b/src/tests/unittests/validation/UsageValidationTests.cpp @@ -25,7 +25,7 @@ class UsageValidationTest : public ValidationTest { private: void SetUp() override { ValidationTest::SetUp(); - queue = device.CreateQueueBuilder().GetResult(); + queue = device.CreateQueue(); } };