Metal: avoid uses of autorelease
BUG=chromium:947089 Change-Id: I1e7ef4a91a8b1c6108485b8c99e88a53a25ebb7b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6160 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
0ae00a187d
commit
19179e180b
|
@ -238,17 +238,17 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
}
|
||||
|
||||
MTLDepthStencilDescriptor* ComputeDepthStencilDesc(
|
||||
MTLDepthStencilDescriptor* MakeDepthStencilDesc(
|
||||
const DepthStencilStateDescriptor* descriptor) {
|
||||
MTLDepthStencilDescriptor* mtlDepthStencilDescriptor =
|
||||
[[MTLDepthStencilDescriptor new] autorelease];
|
||||
MTLDepthStencilDescriptor* mtlDepthStencilDescriptor = [MTLDepthStencilDescriptor new];
|
||||
|
||||
mtlDepthStencilDescriptor.depthCompareFunction =
|
||||
ToMetalCompareFunction(descriptor->depthCompare);
|
||||
mtlDepthStencilDescriptor.depthWriteEnabled = descriptor->depthWriteEnabled;
|
||||
|
||||
if (StencilTestEnabled(descriptor)) {
|
||||
MTLStencilDescriptor* backFaceStencil = [[MTLStencilDescriptor new] autorelease];
|
||||
MTLStencilDescriptor* frontFaceStencil = [[MTLStencilDescriptor new] autorelease];
|
||||
MTLStencilDescriptor* backFaceStencil = [MTLStencilDescriptor new];
|
||||
MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
|
||||
|
||||
backFaceStencil.stencilCompareFunction =
|
||||
ToMetalCompareFunction(descriptor->stencilBack.compare);
|
||||
|
@ -274,7 +274,11 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
mtlDepthStencilDescriptor.backFaceStencil = backFaceStencil;
|
||||
mtlDepthStencilDescriptor.frontFaceStencil = frontFaceStencil;
|
||||
|
||||
[backFaceStencil release];
|
||||
[frontFaceStencil release];
|
||||
}
|
||||
|
||||
return mtlDepthStencilDescriptor;
|
||||
}
|
||||
|
||||
|
@ -316,7 +320,9 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
descriptorMTL.inputPrimitiveTopology = MTLInputPrimitiveTopology(GetPrimitiveTopology());
|
||||
|
||||
descriptorMTL.vertexDescriptor = MakeVertexDesc();
|
||||
MTLVertexDescriptor* vertexDesc = MakeVertexDesc();
|
||||
descriptorMTL.vertexDescriptor = vertexDesc;
|
||||
[vertexDesc release];
|
||||
|
||||
// TODO(kainino@chromium.org): push constants, textures, samplers
|
||||
|
||||
|
@ -324,7 +330,6 @@ namespace dawn_native { namespace metal {
|
|||
NSError* error = nil;
|
||||
mMtlRenderPipelineState = [mtlDevice newRenderPipelineStateWithDescriptor:descriptorMTL
|
||||
error:&error];
|
||||
[descriptorMTL.vertexDescriptor release];
|
||||
[descriptorMTL release];
|
||||
if (error != nil) {
|
||||
NSLog(@" error => %@", error);
|
||||
|
@ -333,12 +338,13 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
}
|
||||
|
||||
// create depth stencil state and cache it, fetch the cached depth stencil state when we
|
||||
// call setDepthStencilState() for a given render pipeline in CommandBuffer, in order to
|
||||
// Create depth stencil state and cache it, fetch the cached depth stencil state when we
|
||||
// call setDepthStencilState() for a given render pipeline in CommandEncoder, in order to
|
||||
// improve performance.
|
||||
mMtlDepthStencilState =
|
||||
[mtlDevice newDepthStencilStateWithDescriptor:ComputeDepthStencilDesc(
|
||||
GetDepthStencilStateDescriptor())];
|
||||
MTLDepthStencilDescriptor* depthStencilDesc =
|
||||
MakeDepthStencilDesc(GetDepthStencilStateDescriptor());
|
||||
mMtlDepthStencilState = [mtlDevice newDepthStencilStateWithDescriptor:depthStencilDesc];
|
||||
[depthStencilDesc release];
|
||||
}
|
||||
|
||||
RenderPipeline::~RenderPipeline() {
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace dawn_native { namespace metal {
|
|||
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
||||
: SamplerBase(device, descriptor) {
|
||||
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
|
||||
[mtlDesc autorelease];
|
||||
|
||||
mtlDesc.minFilter = FilterModeToMinMagFilter(descriptor->minFilter);
|
||||
mtlDesc.magFilter = FilterModeToMinMagFilter(descriptor->magFilter);
|
||||
mtlDesc.mipFilter = FilterModeToMipFilter(descriptor->mipmapFilter);
|
||||
|
@ -81,6 +81,8 @@ namespace dawn_native { namespace metal {
|
|||
mtlDesc.borderColor = BorderColor(descriptor->borderColor);
|
||||
|
||||
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
||||
|
||||
[mtlDesc release];
|
||||
}
|
||||
|
||||
Sampler::~Sampler() {
|
||||
|
|
Loading…
Reference in New Issue