Cycles: Disable lossless MTLTexture compression & render up to 2% faster
Disallow lossless texture compression in MetalDevice. Path-tracing texture access patterns are very random, and cache reuse gains are typically too low to offset the decompression overheads. This change doesn't increase memory usage for any of the benchmark scenes (https://projects.blender.org/blender/blender-benchmarks/src/branch/main/cycles) as most textures are high entropy and don't compress well using lossless methods. Pull Request: https://projects.blender.org/blender/blender/pulls/143074
This commit is contained in:
committed by
Michael Jones (Apple)
parent
2582630702
commit
6f1c63597d
@@ -1072,6 +1072,11 @@ void MetalDevice::tex_alloc(device_texture &mem)
|
||||
desc.storageMode = MTLStorageModeShared;
|
||||
desc.usage = MTLTextureUsageShaderRead;
|
||||
|
||||
/* Disallow lossless texture compression. Path-tracing texture access patterns are very
|
||||
* random, and cache reuse gains are typically too low to offset the decompression overheads.
|
||||
*/
|
||||
desc.allowGPUOptimizedContents = false;
|
||||
|
||||
LOG_WORK << "Texture 2D allocate: " << mem.name << ", "
|
||||
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
|
||||
<< string_human_readable_size(mem.memory_size()) << ")";
|
||||
@@ -1124,13 +1129,6 @@ void MetalDevice::tex_alloc(device_texture &mem)
|
||||
}
|
||||
}
|
||||
|
||||
/* Optimize the texture for GPU access. */
|
||||
id<MTLCommandBuffer> commandBuffer = [mtlGeneralCommandQueue commandBuffer];
|
||||
id<MTLBlitCommandEncoder> blitCommandEncoder = [commandBuffer blitCommandEncoder];
|
||||
[blitCommandEncoder optimizeContentsForGPUAccess:mtlTexture];
|
||||
[blitCommandEncoder endEncoding];
|
||||
[commandBuffer commit];
|
||||
|
||||
/* Set Mapping. */
|
||||
texture_slot_map[slot] = mtlTexture;
|
||||
texture_info[slot] = mem.info;
|
||||
|
||||
Reference in New Issue
Block a user