mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
metal: blending
This commit is contained in:
@ -810,7 +810,16 @@ fn initPipelineState(device: objc.Object, library: objc.Object) !objc.Object {
|
|||||||
|
|
||||||
// Value is MTLPixelFormatBGRA8Unorm
|
// Value is MTLPixelFormatBGRA8Unorm
|
||||||
attachment.setProperty("pixelFormat", @as(c_ulong, 80));
|
attachment.setProperty("pixelFormat", @as(c_ulong, 80));
|
||||||
|
|
||||||
|
// Blending. This is required so that our text we render on top
|
||||||
|
// of our drawable properly blends into the bg.
|
||||||
attachment.setProperty("blendingEnabled", true);
|
attachment.setProperty("blendingEnabled", true);
|
||||||
|
attachment.setProperty("rgbBlendOperation", @enumToInt(MTLBlendOperation.add));
|
||||||
|
attachment.setProperty("alphaBlendOperation", @enumToInt(MTLBlendOperation.add));
|
||||||
|
attachment.setProperty("sourceRGBBlendFactor", @enumToInt(MTLBlendFactor.source_alpha));
|
||||||
|
attachment.setProperty("sourceAlphaBlendFactor", @enumToInt(MTLBlendFactor.source_alpha));
|
||||||
|
attachment.setProperty("destinationRGBBlendFactor", @enumToInt(MTLBlendFactor.one_minus_source_alpha));
|
||||||
|
attachment.setProperty("destinationAlphaBlendFactor", @enumToInt(MTLBlendFactor.one_minus_source_alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make our state
|
// Make our state
|
||||||
@ -939,6 +948,38 @@ const MTLPurgeableState = enum(c_ulong) {
|
|||||||
empty = 4,
|
empty = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// https://developer.apple.com/documentation/metal/mtlblendfactor?language=objc
|
||||||
|
const MTLBlendFactor = enum(c_ulong) {
|
||||||
|
zero = 0,
|
||||||
|
one = 1,
|
||||||
|
source_color = 2,
|
||||||
|
one_minus_source_color = 3,
|
||||||
|
source_alpha = 4,
|
||||||
|
one_minus_source_alpha = 5,
|
||||||
|
dest_color = 6,
|
||||||
|
one_minus_dest_color = 7,
|
||||||
|
dest_alpha = 8,
|
||||||
|
one_minus_dest_alpha = 9,
|
||||||
|
source_alpha_saturated = 10,
|
||||||
|
blend_color = 11,
|
||||||
|
one_minus_blend_color = 12,
|
||||||
|
blend_alpha = 13,
|
||||||
|
one_minus_blend_alpha = 14,
|
||||||
|
source_1_color = 15,
|
||||||
|
one_minus_source_1_color = 16,
|
||||||
|
source_1_alpha = 17,
|
||||||
|
one_minus_source_1_alpha = 18,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// https://developer.apple.com/documentation/metal/mtlblendoperation?language=objc
|
||||||
|
const MTLBlendOperation = enum(c_ulong) {
|
||||||
|
add = 0,
|
||||||
|
subtract = 1,
|
||||||
|
reverse_subtract = 2,
|
||||||
|
min = 3,
|
||||||
|
max = 4,
|
||||||
|
};
|
||||||
|
|
||||||
/// https://developer.apple.com/documentation/metal/mtlresourceoptions?language=objc
|
/// https://developer.apple.com/documentation/metal/mtlresourceoptions?language=objc
|
||||||
/// (incomplete, we only use this mode so we just hardcode it)
|
/// (incomplete, we only use this mode so we just hardcode it)
|
||||||
const MTLResourceStorageModeShared: c_ulong = @enumToInt(MTLStorageMode.shared) << 4;
|
const MTLResourceStorageModeShared: c_ulong = @enumToInt(MTLStorageMode.shared) << 4;
|
||||||
|
Reference in New Issue
Block a user