-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #723 from Sergio0694/dev/d2d-generator-tweaks
Check cancellation for D2D linked shaders, share code
- Loading branch information
Showing
16 changed files
with
350 additions
and
340 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/ComputeSharp.D2D1.SourceGenerators/Polyfills/EncodingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace System.Text; | ||
|
||
/// <summary> | ||
/// Extensions for the <see cref="Encoding"/> type. | ||
/// </summary> | ||
internal static class EncodingExtensions | ||
{ | ||
/// <summary> | ||
/// Encodes into a span of bytes a set of characters from the specified read-only span. | ||
/// </summary> | ||
/// <param name="encoding">The input <see cref="Encoding"/> instance to use.</param> | ||
/// <param name="chars">The span containing the set of characters to encode.</param> | ||
/// <param name="bytes">The byte span to hold the encoded bytes.</param> | ||
/// <returns>The number of encoded bytes.</returns> | ||
public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, Span<byte> bytes) | ||
{ | ||
fixed (char* charsPtr = chars) | ||
fixed (byte* bytesPtr = bytes) | ||
{ | ||
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/ComputeSharp.D2D1.SourceGenerators/SyntaxProcessors/HlslBytecodeSyntaxProcessor.D2D1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Threading; | ||
using ComputeSharp.D2D1.Shaders.Translation; | ||
using ComputeSharp.D2D1.SourceGenerators.Models; | ||
using Windows.Win32; | ||
using Windows.Win32.Graphics.Direct3D; | ||
|
||
namespace ComputeSharp.SourceGeneration.SyntaxProcessors; | ||
|
||
/// <inheritdoc/> | ||
partial class HlslBytecodeSyntaxProcessor | ||
{ | ||
/// <inheritdoc/> | ||
private static partial string GetRequiresDoublePrecisionSupportAttributeName() | ||
{ | ||
return "ComputeSharp.D2D1.D2DRequiresDoublePrecisionSupportAttribute"; | ||
} | ||
|
||
/// <inheritdoc/> | ||
private static partial ComPtr<ID3DBlob> Compile(HlslBytecodeInfoKey key, CancellationToken token) | ||
{ | ||
return D3DCompiler.Compile( | ||
key.HlslSource.AsSpan(), | ||
key.ShaderProfile, | ||
key.CompileOptions, | ||
token); | ||
} | ||
|
||
/// <inheritdoc/> | ||
private static unsafe partial bool IsDoublePrecisionSupportRequired(ID3DBlob* d3DBlob) | ||
{ | ||
return D3DCompiler.IsDoublePrecisionSupportRequired(d3DBlob); | ||
} | ||
|
||
/// <inheritdoc/> | ||
private static partial string FixupErrorMessage(string message) | ||
{ | ||
return D3DCompiler.PrettifyFxcErrorMessage(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.