mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 14:13:39 +00:00
Validate that sampler compare function requires iOS GPU family 3v1
Bug: b/149025333 Change-Id: I8683188c6189a9390ac6568e4ab5434a6c1a99f9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15942 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
e51f8dd09a
commit
0aa86a7ae8
@ -106,7 +106,7 @@ namespace dawn_native { namespace metal {
|
|||||||
return RenderPipeline::Create(this, descriptor);
|
return RenderPipeline::Create(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
|
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(this, descriptor);
|
return Sampler::Create(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
|
ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
|
||||||
const ShaderModuleDescriptor* descriptor) {
|
const ShaderModuleDescriptor* descriptor) {
|
||||||
|
@ -25,12 +25,13 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
class Sampler : public SamplerBase {
|
class Sampler : public SamplerBase {
|
||||||
public:
|
public:
|
||||||
Sampler(Device* device, const SamplerDescriptor* descriptor);
|
static ResultOrError<Sampler*> Create(Device* device, const SamplerDescriptor* descriptor);
|
||||||
~Sampler();
|
~Sampler();
|
||||||
|
|
||||||
id<MTLSamplerState> GetMTLSamplerState();
|
id<MTLSamplerState> GetMTLSamplerState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Sampler(Device* device, const SamplerDescriptor* descriptor);
|
||||||
id<MTLSamplerState> mMtlSamplerState = nil;
|
id<MTLSamplerState> mMtlSamplerState = nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,6 +50,20 @@ namespace dawn_native { namespace metal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
ResultOrError<Sampler*> Sampler::Create(Device* device, const SamplerDescriptor* descriptor) {
|
||||||
|
#if defined(DAWN_PLATFORM_IOS)
|
||||||
|
if (descriptor->compare != wgpu::CompareFunction::Never &&
|
||||||
|
![device->GetMTLDevice() supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) {
|
||||||
|
// Unsupported before A9.
|
||||||
|
// TODO(b/149025333): Investigate emulation -- possibly expensive.
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Sampler compare function requires at least iOS GPU family 3, version 1");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return new Sampler(device, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
||||||
: SamplerBase(device, descriptor) {
|
: SamplerBase(device, descriptor) {
|
||||||
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
|
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
|
||||||
@ -64,7 +78,12 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
||||||
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
||||||
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compare);
|
|
||||||
|
if (descriptor->compare != wgpu::CompareFunction::Never) {
|
||||||
|
// Anything other than Never is unsupported before A9, which we validate in
|
||||||
|
// Sampler::Create.
|
||||||
|
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compare);
|
||||||
|
}
|
||||||
|
|
||||||
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user