Fix a memory leak in metal ShaderModule.
Make the MetalFunctionData object returned by GetFunction() own a reference to the MTLFunction and release it on destruction.
This commit is contained in:
parent
1ec5782bff
commit
8f2050540d
|
@ -76,8 +76,9 @@ namespace backend { namespace metal {
|
|||
const auto& module = ToBackend(builder->GetStageInfo(stage).module);
|
||||
|
||||
const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
|
||||
id<MTLFunction> function =
|
||||
module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout())).function;
|
||||
ShaderModule::MetalFunctionData data =
|
||||
module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout()));
|
||||
id<MTLFunction> function = data.function;
|
||||
|
||||
switch (stage) {
|
||||
case nxt::ShaderStage::Vertex:
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace backend { namespace metal {
|
|||
struct MetalFunctionData {
|
||||
id<MTLFunction> function;
|
||||
MTLSize localWorkgroupSize;
|
||||
~MetalFunctionData() {
|
||||
[function release];
|
||||
}
|
||||
};
|
||||
MetalFunctionData GetFunction(const char* functionName, const PipelineLayout* layout) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue