renderer/metal: provide MTLTextureUsage render target for custom shaders (#8749)
This fixes a Metal validation error in Xcode when using custom shaders. I suspect this is one part of custom shaders not working properly on Intel macs (probably anything with a discrete GPU). This happens to work on Apple Silicon but this is undefined behavior and we're just getting lucky. There is one more issue I'm chasing down that I think is also still blocking custom shaders working on Intel macs.1.2.x
parent
1cd0fb5dab
commit
51292a9793
|
|
@ -273,6 +273,15 @@ pub inline fn textureOptions(self: Metal) Texture.Options {
|
||||||
.cpu_cache_mode = .write_combined,
|
.cpu_cache_mode = .write_combined,
|
||||||
.storage_mode = self.default_storage_mode,
|
.storage_mode = self.default_storage_mode,
|
||||||
},
|
},
|
||||||
|
.usage = .{
|
||||||
|
// textureOptions is currently only used for custom shaders,
|
||||||
|
// which require both the shader read (for when multiple shaders
|
||||||
|
// are chained) and render target (for the final output) usage.
|
||||||
|
// Disabling either of these will lead to metal validation
|
||||||
|
// errors in Xcode.
|
||||||
|
.shader_read = true,
|
||||||
|
.render_target = true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,6 +320,10 @@ pub inline fn imageTextureOptions(
|
||||||
.cpu_cache_mode = .write_combined,
|
.cpu_cache_mode = .write_combined,
|
||||||
.storage_mode = self.default_storage_mode,
|
.storage_mode = self.default_storage_mode,
|
||||||
},
|
},
|
||||||
|
.usage = .{
|
||||||
|
// We only need to read from this texture from a shader.
|
||||||
|
.shader_read = true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,6 +347,10 @@ pub fn initAtlasTexture(
|
||||||
.cpu_cache_mode = .write_combined,
|
.cpu_cache_mode = .write_combined,
|
||||||
.storage_mode = self.default_storage_mode,
|
.storage_mode = self.default_storage_mode,
|
||||||
},
|
},
|
||||||
|
.usage = .{
|
||||||
|
// We only need to read from this texture from a shader.
|
||||||
|
.shader_read = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
atlas.size,
|
atlas.size,
|
||||||
atlas.size,
|
atlas.size,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ pub const Options = struct {
|
||||||
device: objc.Object,
|
device: objc.Object,
|
||||||
pixel_format: mtl.MTLPixelFormat,
|
pixel_format: mtl.MTLPixelFormat,
|
||||||
resource_options: mtl.MTLResourceOptions,
|
resource_options: mtl.MTLResourceOptions,
|
||||||
|
usage: mtl.MTLTextureUsage,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The underlying MTLTexture Object.
|
/// The underlying MTLTexture Object.
|
||||||
|
|
@ -57,6 +58,7 @@ pub fn init(
|
||||||
desc.setProperty("width", @as(c_ulong, width));
|
desc.setProperty("width", @as(c_ulong, width));
|
||||||
desc.setProperty("height", @as(c_ulong, height));
|
desc.setProperty("height", @as(c_ulong, height));
|
||||||
desc.setProperty("resourceOptions", opts.resource_options);
|
desc.setProperty("resourceOptions", opts.resource_options);
|
||||||
|
desc.setProperty("usage", opts.usage);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
const id = opts.device.msgSend(
|
const id = opts.device.msgSend(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue