Make Device::CreateSamplerImpl to return a ResultOrError
This will allow backends to do error-handling internally for things like allocation failures though non of them take advantage of it yet.
This commit is contained in:
parent
50e0986e0e
commit
79d9e16d3c
|
@ -139,7 +139,13 @@ namespace backend {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return CreateSamplerImpl(descriptor);
|
||||
ResultOrError<SamplerBase*> maybeSampler = CreateSamplerImpl(descriptor);
|
||||
if (maybeSampler.IsError()) {
|
||||
// TODO(cwallez@chromium.org): Implement the WebGPU error handling mechanism.
|
||||
delete validation.AcquireError();
|
||||
return nullptr;
|
||||
}
|
||||
return maybeSampler.AcquireSuccess();
|
||||
}
|
||||
ShaderModuleBuilder* DeviceBase::CreateShaderModuleBuilder() {
|
||||
return new ShaderModuleBuilder(this);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef BACKEND_DEVICEBASE_H_
|
||||
#define BACKEND_DEVICEBASE_H_
|
||||
|
||||
#include "backend/Error.h"
|
||||
#include "backend/Forward.h"
|
||||
#include "backend/RefCounted.h"
|
||||
|
||||
|
@ -98,7 +99,8 @@ namespace backend {
|
|||
void Release();
|
||||
|
||||
private:
|
||||
virtual SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) = 0;
|
||||
virtual ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) = 0;
|
||||
|
||||
// The object caches aren't exposed in the header as they would require a lot of
|
||||
// additional includes.
|
||||
|
|
|
@ -298,7 +298,8 @@ namespace backend { namespace d3d12 {
|
|||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) {
|
||||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
|
|
|
@ -128,7 +128,8 @@ namespace backend { namespace d3d12 {
|
|||
void ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists);
|
||||
|
||||
private:
|
||||
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||
ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) override;
|
||||
|
||||
uint64_t mSerial = 0;
|
||||
ComPtr<ID3D12Fence> mFence;
|
||||
|
|
|
@ -118,7 +118,8 @@ namespace backend { namespace metal {
|
|||
ResourceUploader* GetResourceUploader() const;
|
||||
|
||||
private:
|
||||
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||
ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) override;
|
||||
|
||||
void OnCompletedHandler();
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ namespace backend { namespace metal {
|
|||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) {
|
||||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
|
|
|
@ -76,7 +76,8 @@ namespace backend { namespace null {
|
|||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) {
|
||||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
|
|
|
@ -120,7 +120,8 @@ namespace backend { namespace null {
|
|||
std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();
|
||||
|
||||
private:
|
||||
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||
ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) override;
|
||||
|
||||
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
|
||||
};
|
||||
|
|
|
@ -86,7 +86,8 @@ namespace backend { namespace opengl {
|
|||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) {
|
||||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
|
|
|
@ -105,7 +105,8 @@ namespace backend { namespace opengl {
|
|||
void TickImpl() override;
|
||||
|
||||
private:
|
||||
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||
ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) override;
|
||||
};
|
||||
|
||||
class BindGroup : public BindGroupBase {
|
||||
|
|
|
@ -253,7 +253,8 @@ namespace backend { namespace vulkan {
|
|||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) {
|
||||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
|
|
|
@ -133,7 +133,8 @@ namespace backend { namespace vulkan {
|
|||
void TickImpl() override;
|
||||
|
||||
private:
|
||||
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||
ResultOrError<SamplerBase*> CreateSamplerImpl(
|
||||
const nxt::SamplerDescriptor* descriptor) override;
|
||||
|
||||
bool CreateInstance(VulkanGlobalKnobs* usedKnobs,
|
||||
const std::vector<const char*>& requiredExtensions);
|
||||
|
|
Loading…
Reference in New Issue