Skip to content

Commit ffc52e8

Browse files
authored
Merge pull request #6 from DarthAffe/VorticeUpdate
Vortice update
2 parents cb66b08 + 67fb24b commit ffc52e8

File tree

4 files changed

+68
-48
lines changed

4 files changed

+68
-48
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Vortice.DXGI;
2+
3+
namespace ScreenCapture.NET;
4+
5+
// DarthAffe 22.02.2023: These helper-methods where removed from Vortice and are readded here since they are used.
6+
internal static class DX11CompatibilityExtensions
7+
{
8+
public static IDXGIAdapter1 GetAdapter1(this IDXGIFactory1 factory, int index)
9+
{
10+
factory.EnumAdapters1(index, out IDXGIAdapter1 adapter).CheckError();
11+
return adapter;
12+
}
13+
14+
public static IDXGIOutput GetOutput(this IDXGIAdapter1 adapter, int index)
15+
{
16+
adapter.EnumOutputs(index, out IDXGIOutput output).CheckError();
17+
return output;
18+
}
19+
}

ScreenCapture.NET/DirectX/DX11ScreenCapture.cs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -305,37 +305,37 @@ private void ValidateCaptureZoneAndThrow(int x, int y, int width, int height)
305305
private void InitializeCaptureZone(in CaptureZone captureZone)
306306
{
307307
Texture2DDescription stagingTextureDesc = new()
308-
{
309-
CpuAccessFlags = CpuAccessFlags.Read,
310-
BindFlags = BindFlags.None,
311-
Format = Format.B8G8R8A8_UNorm,
312-
Width = captureZone.Width,
313-
Height = captureZone.Height,
314-
OptionFlags = ResourceOptionFlags.None,
315-
MipLevels = 1,
316-
ArraySize = 1,
317-
SampleDescription = { Count = 1, Quality = 0 },
318-
Usage = ResourceUsage.Staging
319-
};
308+
{
309+
CPUAccessFlags = CpuAccessFlags.Read,
310+
BindFlags = BindFlags.None,
311+
Format = Format.B8G8R8A8_UNorm,
312+
Width = captureZone.Width,
313+
Height = captureZone.Height,
314+
MiscFlags = ResourceOptionFlags.None,
315+
MipLevels = 1,
316+
ArraySize = 1,
317+
SampleDescription = { Count = 1, Quality = 0 },
318+
Usage = ResourceUsage.Staging
319+
};
320320
ID3D11Texture2D stagingTexture = _device!.CreateTexture2D(stagingTextureDesc);
321321

322322
ID3D11Texture2D? scalingTexture = null;
323323
ID3D11ShaderResourceView? scalingTextureView = null;
324324
if (captureZone.DownscaleLevel > 0)
325325
{
326326
Texture2DDescription scalingTextureDesc = new()
327-
{
328-
CpuAccessFlags = CpuAccessFlags.None,
329-
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
330-
Format = Format.B8G8R8A8_UNorm,
331-
Width = captureZone.UnscaledWidth,
332-
Height = captureZone.UnscaledHeight,
333-
OptionFlags = ResourceOptionFlags.GenerateMips,
334-
MipLevels = captureZone.DownscaleLevel + 1,
335-
ArraySize = 1,
336-
SampleDescription = { Count = 1, Quality = 0 },
337-
Usage = ResourceUsage.Default
338-
};
327+
{
328+
CPUAccessFlags = CpuAccessFlags.None,
329+
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
330+
Format = Format.B8G8R8A8_UNorm,
331+
Width = captureZone.UnscaledWidth,
332+
Height = captureZone.UnscaledHeight,
333+
MiscFlags = ResourceOptionFlags.GenerateMips,
334+
MipLevels = captureZone.DownscaleLevel + 1,
335+
ArraySize = 1,
336+
SampleDescription = { Count = 1, Quality = 0 },
337+
Usage = ResourceUsage.Default
338+
};
339339
scalingTexture = _device!.CreateTexture2D(scalingTextureDesc);
340340
scalingTextureView = _device.CreateShaderResourceView(scalingTexture);
341341
}
@@ -362,18 +362,18 @@ public void Restart()
362362
using IDXGIOutput5 output = _output.QueryInterface<IDXGIOutput5>();
363363

364364
Texture2DDescription captureTextureDesc = new()
365-
{
366-
CpuAccessFlags = CpuAccessFlags.None,
367-
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
368-
Format = Format.B8G8R8A8_UNorm,
369-
Width = Display.Width,
370-
Height = Display.Height,
371-
OptionFlags = ResourceOptionFlags.None,
372-
MipLevels = 1,
373-
ArraySize = 1,
374-
SampleDescription = { Count = 1, Quality = 0 },
375-
Usage = ResourceUsage.Default
376-
};
365+
{
366+
CPUAccessFlags = CpuAccessFlags.None,
367+
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
368+
Format = Format.B8G8R8A8_UNorm,
369+
Width = Display.Width,
370+
Height = Display.Height,
371+
MiscFlags = ResourceOptionFlags.None,
372+
MipLevels = 1,
373+
ArraySize = 1,
374+
SampleDescription = { Count = 1, Quality = 0 },
375+
Usage = ResourceUsage.Default
376+
};
377377
_captureTexture = _device.CreateTexture2D(captureTextureDesc);
378378

379379
lock (_captureZones)
@@ -383,7 +383,7 @@ public void Restart()
383383
}
384384

385385
if (_useNewDuplicationAdapter)
386-
_duplicatedOutput = output.DuplicateOutput1(_device, Format.B8G8R8A8_UNorm); // DarthAffe 27.02.2021: This prepares for the use of 10bit color depth
386+
_duplicatedOutput = output.DuplicateOutput1(_device, new[] { Format.B8G8R8A8_UNorm }); // DarthAffe 27.02.2021: This prepares for the use of 10bit color depth
387387
else
388388
_duplicatedOutput = output.DuplicateOutput(_device);
389389
}

ScreenCapture.NET/Model/CaptureZone.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public sealed class CaptureZone
102102
/// <param name="y">The y-location of the region on the screen.</param>
103103
/// <param name="width">The width of the region on the screen.</param>
104104
/// <param name="height">The height of the region on the screen.</param>
105+
/// <param name="bytesPerPixel">The number of bytes per pixel.</param>
105106
/// <param name="downscaleLevel">The level of downscaling applied to the image of this region before copying to local memory.</param>
106107
/// <param name="unscaledWidth">The original width of the region.</param>
107108
/// <param name="unscaledHeight">The original height of the region</param>
@@ -141,7 +142,7 @@ public void SetUpdated()
141142
IsUpdateRequested = false;
142143
BlackBars.InvalidateCache();
143144

144-
Updated?.Invoke(this, new EventArgs());
145+
Updated?.Invoke(this, EventArgs.Empty);
145146
}
146147

147148
/// <summary>

ScreenCapture.NET/ScreenCapture.NET.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
3+
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
44
<LangVersion>latest</LangVersion>
55
<Nullable>enable</Nullable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -16,8 +16,8 @@
1616
<RootNamespace>ScreenCapture.NET</RootNamespace>
1717
<Description>Vortice based Screen-Capturing</Description>
1818
<Summary>Vortice based Screen-Capturing using Desktop Duplication</Summary>
19-
<Copyright>Copyright © Darth Affe 2022</Copyright>
20-
<PackageCopyright>Copyright © Darth Affe 2022</PackageCopyright>
19+
<Copyright>Copyright © Darth Affe 2023</Copyright>
20+
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
2121
<PackageIcon>icon.png</PackageIcon>
2222
<PackageProjectUrl>https://github.com/DarthAffe/ScreenCapture.NET</PackageProjectUrl>
2323
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
@@ -26,14 +26,14 @@
2626
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2727

2828
<PackageReleaseNotes>
29-
- Added IScreenCapture.UpdateCaptureZone to modify existing CaptureZones without having to remove and add them again.
30-
(This has performance benefits when only X and/or Y is changed, changes to width, height and downscale are internally still reinitializing the zone.)
31-
- Fixed ambiguous equals in Display
29+
- Updated Vortice
30+
- Added .NET 7 Target
31+
- Removed unsupported .NET 5 Target
3232
</PackageReleaseNotes>
3333

34-
<Version>1.2.0</Version>
35-
<AssemblyVersion>1.2.0</AssemblyVersion>
36-
<FileVersion>1.2.0</FileVersion>
34+
<Version>1.2.1</Version>
35+
<AssemblyVersion>1.2.1</AssemblyVersion>
36+
<FileVersion>1.2.1</FileVersion>
3737

3838
<OutputPath>..\bin\</OutputPath>
3939
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -64,7 +64,7 @@
6464
</ItemGroup>
6565

6666
<ItemGroup>
67-
<PackageReference Include="Vortice.Direct3D11" Version="1.9.143" />
67+
<PackageReference Include="Vortice.Direct3D11" Version="2.3.0" />
6868
</ItemGroup>
6969

7070
</Project>

0 commit comments

Comments
 (0)