Improve in CheckFeatureSupport support across library.

This commit is contained in:
Amer Koleci
2023-01-13 17:43:17 +01:00
parent 9cbc67cbb4
commit 568352435f
5 changed files with 207 additions and 70 deletions

View File

@@ -14,7 +14,7 @@
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<RestoreConfigFile>$(MSBuildThisFileDirectory)NuGet.config</RestoreConfigFile> <RestoreConfigFile>$(MSBuildThisFileDirectory)NuGet.config</RestoreConfigFile>
<VersionPrefix>1.9.12</VersionPrefix> <VersionPrefix>1.9.13</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix> <VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@@ -9,180 +9,241 @@ using static Win32.Graphics.Direct2D.Apis;
namespace Win32.Graphics.Direct2D; namespace Win32.Graphics.Direct2D;
public unsafe partial struct ID2D1DeviceContext public static unsafe class ID2D1DeviceContextExtensions
{ {
public HResult CreateBitmap(Size size, BitmapProperties* bitmapProperties, ID2D1Bitmap** bitmap) public static HResult CreateBitmapt<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, Size size, BitmapProperties* bitmapProperties, ID2D1Bitmap** bitmap)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateBitmap(size, null, 0, bitmapProperties, bitmap); return self.CreateBitmap(size, null, 0, bitmapProperties, bitmap);
} }
public HResult CreateBitmapFromWicBitmap(IWICBitmapSource* wicBitmapSource, ID2D1Bitmap** bitmap) public static HResult CreateBitmapFromWicBitmapt<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, IWICBitmapSource* wicBitmapSource, ID2D1Bitmap** bitmap)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap); return self.CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
} }
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, ID2D1BitmapBrush** bitmapBrush) public static HResult CreateBitmapBrusht<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, ID2D1BitmapBrush** bitmapBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateBitmapBrush(bitmap, null, null, bitmapBrush); return self.CreateBitmapBrush(bitmap, null, null, bitmapBrush);
} }
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, BitmapBrushProperties* bitmapBrushProperties, ID2D1BitmapBrush** bitmapBrush) public static HResult CreateBitmapBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, BitmapBrushProperties* bitmapBrushProperties, ID2D1BitmapBrush** bitmapBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateBitmapBrush(bitmap, bitmapBrushProperties, null, bitmapBrush); return self.CreateBitmapBrush(bitmap, bitmapBrushProperties, null, bitmapBrush);
} }
public HResult CreateSolidColorBrush(Color4* color, ID2D1SolidColorBrush** solidColorBrush) public static HResult CreateSolidColorBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, Color4* color, ID2D1SolidColorBrush** solidColorBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateSolidColorBrush(color, null, solidColorBrush); return self.CreateSolidColorBrush(color, null, solidColorBrush);
} }
public HResult CreateGradientStopCollection(GradientStop* gradientStops, uint gradientStopsCount, ID2D1GradientStopCollection** gradientStopCollection) public static HResult CreateSolidColorBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, Color4 color, ID2D1SolidColorBrush** solidColorBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateGradientStopCollection(gradientStops, gradientStopsCount, Gamma.Gamma_2_2, ExtendMode.Clamp, gradientStopCollection); return self.CreateSolidColorBrush(&color, null, solidColorBrush);
} }
public HResult CreateLinearGradientBrush(LinearGradientBrushProperties* linearGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1LinearGradientBrush** linearGradientBrush) public static HResult CreateGradientStopCollection<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, GradientStop* gradientStops, int gradientStopsCount, ID2D1GradientStopCollection** gradientStopCollection)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateLinearGradientBrush(linearGradientBrushProperties, null, gradientStopCollection, linearGradientBrush); return self.CreateGradientStopCollection(gradientStops, (uint)gradientStopsCount, Gamma.Gamma_2_2, ExtendMode.Clamp, gradientStopCollection);
} }
public HResult CreateRadialGradientBrush(RadialGradientBrushProperties* radialGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1RadialGradientBrush** radialGradientBrush) public static HResult CreateLinearGradientBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, LinearGradientBrushProperties* linearGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1LinearGradientBrush** linearGradientBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateRadialGradientBrush(radialGradientBrushProperties, null, gradientStopCollection, radialGradientBrush); return self.CreateLinearGradientBrush(linearGradientBrushProperties, null, gradientStopCollection, linearGradientBrush);
} }
public HResult CreateCompatibleRenderTarget(ID2D1BitmapRenderTarget** bitmapRenderTarget) public static HResult CreateRadialGradientBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, RadialGradientBrushProperties* radialGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1RadialGradientBrush** radialGradientBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateCompatibleRenderTarget(null, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget); return self.CreateRadialGradientBrush(radialGradientBrushProperties, null, gradientStopCollection, radialGradientBrush);
} }
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, ID2D1BitmapRenderTarget** bitmapRenderTarget) public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1BitmapRenderTarget** bitmapRenderTarget)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateCompatibleRenderTarget(&desiredSize, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget); return self.CreateCompatibleRenderTarget(null, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
} }
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, ID2D1BitmapRenderTarget** bitmapRenderTarget) public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, SizeF desiredSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget); return self.CreateCompatibleRenderTarget(&desiredSize, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
} }
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, ID2D1BitmapRenderTarget** bitmapRenderTarget) public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, CompatibleRenderTargetOptions.None, bitmapRenderTarget); return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
} }
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, CompatibleRenderTargetOptions options, ID2D1BitmapRenderTarget** bitmapRenderTarget) public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, ID2D1BitmapRenderTarget** bitmapRenderTarget)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, options, bitmapRenderTarget); return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
} }
public HResult CreateLayer(SizeF size, ID2D1Layer** layer) public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, CompatibleRenderTargetOptions options, ID2D1BitmapRenderTarget** bitmapRenderTarget)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateLayer(&size, layer); return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, options, bitmapRenderTarget);
} }
public HResult CreateLayer(ID2D1Layer** layer) public static HResult CreateLayer<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, SizeF size, ID2D1Layer** layer)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateLayer(null, layer); return self.CreateLayer(&size, layer);
}
public HResult CreateBitmapFromWicBitmap(IWICBitmapSource* wicBitmapSource, ID2D1Bitmap1** bitmap)
{
return CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
} }
public HResult CreateImageBrush(ID2D1Image* image, ImageBrushProperties* imageBrushProperties, ID2D1ImageBrush** imageBrush) public static HResult CreateLayer<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Layer** layer)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateImageBrush(image, imageBrushProperties, null, imageBrush); return self.CreateLayer(null, layer);
}
public static HResult CreateBitmapFromWicBitmap<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, IWICBitmapSource* wicBitmapSource, ID2D1Bitmap1** bitmap)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{
return self.CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
} }
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, ID2D1BitmapBrush1** bitmapBrush) public static HResult CreateImageBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Image* image, ImageBrushProperties* imageBrushProperties, ID2D1ImageBrush** imageBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateBitmapBrush(bitmap, null, null, bitmapBrush); return self.CreateImageBrush(image, imageBrushProperties, null, imageBrush);
} }
public HResult CreateEffect(in Guid effectId, ID2D1Effect** effect) public static HResult CreateBitmapBrush<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, ID2D1BitmapBrush1** bitmapBrush)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
return CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect); return self.CreateBitmapBrush(bitmap, null, null, bitmapBrush);
} }
public ComPtr<ID2D1Effect> CreateEffect(in Guid effectId) public static HResult CreateEffect<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, in Guid effectId, ID2D1Effect** effect)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{
return self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect);
}
public static ComPtr<ID2D1Effect> CreateEffect<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, in Guid effectId)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
using ComPtr<ID2D1Effect> effect = default; using ComPtr<ID2D1Effect> effect = default;
ThrowIfFailed(CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf())); ThrowIfFailed(self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf()));
return effect.Move(); return effect.Move();
} }
public void DrawImage( public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self,
ID2D1Effect* effect, ID2D1Effect* effect,
Vector2* targetOffset = null, Vector2* targetOffset = null,
RectF* imageRectangle = null, RectF* imageRectangle = null,
InterpolationMode interpolationMode = InterpolationMode.Linear, InterpolationMode interpolationMode = InterpolationMode.Linear,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
ID2D1Image* output = null; ID2D1Image* output = null;
effect->GetOutput(&output); effect->GetOutput(&output);
DrawImage(output, targetOffset, imageRectangle, interpolationMode, compositeMode); self.DrawImage(output, targetOffset, imageRectangle, interpolationMode, compositeMode);
_ = output->Release(); _ = output->Release();
} }
public void DrawImage( public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self,
ID2D1Image* image, ID2D1Image* image,
InterpolationMode interpolationMode, InterpolationMode interpolationMode,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(image, null, null, interpolationMode, compositeMode); self.DrawImage(image, null, null, interpolationMode, compositeMode);
} }
public void DrawImage(ID2D1Effect* effect, public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self,
ID2D1Effect* effect,
InterpolationMode interpolationMode, InterpolationMode interpolationMode,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(effect, null, null, interpolationMode, compositeMode); self.DrawImage(effect, null, null, interpolationMode, compositeMode);
} }
public void DrawImage(ID2D1Image* image, public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Image* image,
Vector2 targetOffset, Vector2 targetOffset,
InterpolationMode interpolationMode = InterpolationMode.Linear, InterpolationMode interpolationMode = InterpolationMode.Linear,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(image, &targetOffset, null, interpolationMode, compositeMode); self.DrawImage(image, &targetOffset, null, interpolationMode, compositeMode);
} }
public void DrawImage(ID2D1Effect* effect, public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Effect* effect,
Vector2 targetOffset, Vector2 targetOffset,
InterpolationMode interpolationMode = InterpolationMode.Linear, InterpolationMode interpolationMode = InterpolationMode.Linear,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(effect, &targetOffset, null, interpolationMode, compositeMode); self.DrawImage(effect, &targetOffset, null, interpolationMode, compositeMode);
} }
public void DrawImage(ID2D1Image* image, public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Image* image,
Vector2 targetOffset, Vector2 targetOffset,
RectF* imageRectangle, RectF* imageRectangle,
InterpolationMode interpolationMode = InterpolationMode.Linear, InterpolationMode interpolationMode = InterpolationMode.Linear,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(image, &targetOffset, imageRectangle, interpolationMode, compositeMode); self.DrawImage(image, &targetOffset, imageRectangle, interpolationMode, compositeMode);
} }
public void DrawImage(ID2D1Effect* effect, public static void DrawImage<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1Effect* effect,
Vector2 targetOffset, Vector2 targetOffset,
RectF* imageRectangle, RectF* imageRectangle,
InterpolationMode interpolationMode = InterpolationMode.Linear, InterpolationMode interpolationMode = InterpolationMode.Linear,
CompositeMode compositeMode = CompositeMode.SourceOver) CompositeMode compositeMode = CompositeMode.SourceOver)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawImage(effect, &targetOffset, imageRectangle, interpolationMode, compositeMode); self.DrawImage(effect, &targetOffset, imageRectangle, interpolationMode, compositeMode);
} }
public void DrawGdiMetafile(ID2D1GdiMetafile* gdiMetafile, Vector2 targetOffset) public static void DrawGdiMetafile<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ID2D1GdiMetafile* gdiMetafile, Vector2 targetOffset)
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
{ {
DrawGdiMetafile(gdiMetafile, &targetOffset); self.DrawGdiMetafile(gdiMetafile, &targetOffset);
}
} }
public static unsafe partial class ID2D1DeviceContextExtensions
{
public static HResult SetDpiCompensatedEffectInput<TD2D1DeviceContext>( public static HResult SetDpiCompensatedEffectInput<TD2D1DeviceContext>(
ref this TD2D1DeviceContext self, ref this TD2D1DeviceContext self,
ID2D1Effect* effect, ID2D1Effect* effect,

View File

@@ -5,17 +5,42 @@ using static Win32.Apis;
namespace Win32.Graphics.Direct2D; namespace Win32.Graphics.Direct2D;
public unsafe partial struct ID2D1EffectContext public static unsafe class ID2D1EffectContextExtensions
{ {
public HResult CreateEffect(in Guid effectId, ID2D1Effect** effect) [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TFeature CheckFeatureSupport<TID2D1EffectContext, TFeature>(ref this TID2D1EffectContext self, Feature feature)
where TID2D1EffectContext : unmanaged, ID2D1EffectContext.Interface
where TFeature : unmanaged
{ {
return CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect); TFeature featureData = default;
ThrowIfFailed(self.CheckFeatureSupport(feature, &featureData, (uint)sizeof(TFeature)));
return featureData;
} }
public ComPtr<ID2D1Effect> CreateEffect(in Guid effectId) [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static HResult CheckFeatureSupport<TID2D1EffectContext, TFeature>(ref this TID2D1EffectContext self, Feature feature, ref TFeature featureData)
where TID2D1EffectContext : unmanaged, ID2D1EffectContext.Interface
where TFeature : unmanaged
{
fixed (TFeature* featureDataPtr = &featureData)
{
return self.CheckFeatureSupport(feature, featureDataPtr, (uint)sizeof(TFeature));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static HResult CreateEffect<TID2D1EffectContext>(ref this TID2D1EffectContext self, in Guid effectId, ID2D1Effect** effect)
where TID2D1EffectContext : unmanaged, ID2D1EffectContext.Interface
{
return self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ComPtr<ID2D1Effect> CreateEffect<TID2D1EffectContext>(ref this TID2D1EffectContext self, in Guid effectId)
where TID2D1EffectContext : unmanaged, ID2D1EffectContext.Interface
{ {
using ComPtr<ID2D1Effect> effect = default; using ComPtr<ID2D1Effect> effect = default;
ThrowIfFailed(CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf())); ThrowIfFailed(self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf()));
return effect.Move(); return effect.Move();
} }
} }

View File

@@ -5,9 +5,30 @@ using static Win32.Apis;
namespace Win32.Graphics.Direct3D11; namespace Win32.Graphics.Direct3D11;
public static unsafe class ID3D11DeviceExtension public static unsafe class ID3D11DeviceExtensions
{ {
public static ComPtr<ID3D11Buffer> CheckFeatureSupport<TD3D11Device>(ref this TD3D11Device self, BufferDescription* description, SubresourceData* initialData = default) [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TFeature CheckFeatureSupport<TD3D11Device, TFeature>(ref this TD3D11Device self, Feature feature)
where TD3D11Device : unmanaged, ID3D11Device.Interface
where TFeature : unmanaged
{
TFeature featureData = default;
ThrowIfFailed(self.CheckFeatureSupport(feature, &featureData, sizeof(TFeature)));
return featureData;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static HResult CheckFeatureSupport<TD3D11Device, TFeature>(ref this TD3D11Device self, Feature feature, ref TFeature featureData)
where TD3D11Device : unmanaged, ID3D11Device.Interface
where TFeature : unmanaged
{
fixed (TFeature* featureDataPtr = &featureData)
{
return self.CheckFeatureSupport(feature, featureDataPtr, sizeof(TFeature));
}
}
public static ComPtr<ID3D11Buffer> CreateBuffer<TD3D11Device>(ref this TD3D11Device self, BufferDescription* description, SubresourceData* initialData = default)
where TD3D11Device : unmanaged, ID3D11Device.Interface where TD3D11Device : unmanaged, ID3D11Device.Interface
{ {
using ComPtr<ID3D11Buffer> buffer = default; using ComPtr<ID3D11Buffer> buffer = default;

View File

@@ -0,0 +1,30 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using static Win32.Apis;
namespace Win32.Graphics.Direct3D11;
public static unsafe class ID3D11VideoDevice2Extensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TFeature CheckFeatureSupport<TD3D11VideoDevice2, TFeature>(ref this TD3D11VideoDevice2 self, FeatureVideo feature)
where TD3D11VideoDevice2 : unmanaged, ID3D11VideoDevice2.Interface
where TFeature : unmanaged
{
TFeature featureData = default;
ThrowIfFailed(self.CheckFeatureSupport(feature, &featureData, sizeof(TFeature)));
return featureData;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static HResult CheckFeatureSupport<TD3D11VideoDevice2, TFeature>(ref this TD3D11VideoDevice2 self, FeatureVideo feature, ref TFeature featureData)
where TD3D11VideoDevice2 : unmanaged, ID3D11VideoDevice2.Interface
where TFeature : unmanaged
{
fixed (TFeature* featureDataPtr = &featureData)
{
return self.CheckFeatureSupport(feature, featureDataPtr, sizeof(TFeature));
}
}
}