diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..7d5239b3
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,350 @@
+# Remove the line below if you want to inherit .editorconfig settings from higher directories
+root = true
+
+# All files
+[*]
+
+#### Core EditorConfig Options ####
+
+# Encoding
+charset = utf-8
+
+# Indentation and spacing
+tab_width = 4
+indent_size = 4
+indent_style = space
+
+# New line preferences
+insert_final_newline = false
+trim_trailing_whitespace = true
+
+#### Build files ####
+
+# Solution files
+[*.{sln,slnx}]
+tab_width = 4
+indent_size = 4
+indent_style = tab
+
+# Configuration files
+[*.{json,xml,yml,config,runsettings}]
+indent_size = 2
+
+# MSBuild files
+[*.{slnf,props,targets,projitems,csproj,shproj}]
+indent_size = 2
+
+#### Source files ####
+
+# Markdown files
+[*.md]
+indent_size = 2
+insert_final_newline = true
+
+# XAML files
+[*.xaml]
+indent_size = 4
+
+# C# files
+[*.cs]
+
+#### .NET Coding Conventions ####
+
+# this. and Me. preferences
+dotnet_style_qualification_for_event = false:warning
+dotnet_style_qualification_for_field = true:warning
+dotnet_style_qualification_for_method = false:warning
+dotnet_style_qualification_for_property = false:warning
+
+# Language keywords vs BCL types preferences
+dotnet_style_predefined_type_for_locals_parameters_members = true:warning
+dotnet_style_predefined_type_for_member_access = true:warning
+
+# Parentheses preferences
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
+
+# Modifier preferences (set to silent until https://github.com/dotnet/roslyn/issues/52904 is resolved)
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
+
+# Code block preferences
+dotnet_style_allow_multiple_blank_lines_experimental = false:warning
+dotnet_style_allow_statement_immediately_after_block_experimental = false:warning
+
+# Expression-level preferences
+csharp_style_deconstructed_variable_declaration = true:suggestion
+csharp_style_inlined_variable_declaration = true:warning
+csharp_style_throw_expression = true:suggestion
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:warning
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
+csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
+
+# Field preferences
+dotnet_style_readonly_field = true:warning
+
+#### C# Coding Conventions ####
+
+# var preferences
+csharp_style_var_elsewhere = false:warning
+csharp_style_var_for_built_in_types = false:warning
+csharp_style_var_when_type_is_apparent = false:warning
+
+# Expression-bodied members
+csharp_style_expression_bodied_accessors = when_on_single_line:warning
+csharp_style_expression_bodied_constructors = false:warning
+csharp_style_expression_bodied_indexers = when_on_single_line:warning
+csharp_style_expression_bodied_lambdas = when_on_single_line:warning
+csharp_style_expression_bodied_methods = false:warning
+csharp_style_expression_bodied_operators = when_on_single_line:warning
+csharp_style_expression_bodied_properties = when_on_single_line:warning
+
+# Pattern matching preferences
+csharp_style_prefer_pattern_matching = true:suggestion
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+
+# Null-checking preferences
+csharp_style_conditional_delegate_call = true:suggestion
+
+# Modifier preferences
+csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
+
+# Code-block preferences
+csharp_prefer_braces = true:suggestion
+csharp_using_directive_placement = outside_namespace:warning
+csharp_style_namespace_declarations = file_scoped:warning
+csharp_style_unused_value_assignment_preference = discard_variable:warning
+csharp_style_unused_value_expression_statement_preference = discard_variable:warning
+csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning
+
+# Expression-level preferences
+csharp_prefer_simple_default_expression = true:suggestion
+csharp_prefer_static_local_function = true:warning
+csharp_style_pattern_local_over_anonymous_function = true:warning
+
+#### C# Formatting Rules ####
+
+# New line preferences
+csharp_new_line_before_catch = true
+csharp_new_line_before_else = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_anonymous_types = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_open_brace = all
+csharp_new_line_between_query_expression_clauses = true
+
+# Indentation preferences
+csharp_indent_block_contents = true
+csharp_indent_braces = false
+csharp_indent_case_contents = true
+csharp_indent_case_contents_when_block = false
+csharp_indent_labels = no_change
+csharp_indent_switch_labels = true
+
+# Space preferences
+csharp_space_after_cast = false
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_after_comma = true
+csharp_space_after_dot = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_after_semicolon_in_for_statement = true
+csharp_space_around_binary_operators = before_and_after
+csharp_space_around_declaration_statements = false
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_before_comma = false
+csharp_space_before_dot = false
+csharp_space_before_open_square_brackets = false
+csharp_space_before_semicolon_in_for_statement = false
+csharp_space_between_empty_square_brackets = false
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_name_and_open_parenthesis = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_parentheses = false
+csharp_space_between_square_brackets = false
+
+# Wrapping preferences
+csharp_preserve_single_line_blocks = true
+csharp_preserve_single_line_statements = true
+
+# Naming Symbols
+
+# constant_fields - Define constant fields
+dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
+dotnet_naming_symbols.constant_fields.applicable_kinds = field
+dotnet_naming_symbols.constant_fields.required_modifiers = const
+# static_readonly_fields - Define all static readonly fields
+dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = *
+dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
+dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
+# non_private_fields - Define all fields that are not private
+dotnet_naming_symbols.non_private_fields.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_private_fields.applicable_kinds = field
+# private_fields - Define all private fields
+dotnet_naming_symbols.private_fields.applicable_accessibilities = private
+dotnet_naming_symbols.private_fields.applicable_kinds = field
+# public_symbols - Define any public symbol
+dotnet_naming_symbols.public_symbols.applicable_accessibilities = *
+dotnet_naming_symbols.public_symbols.applicable_kinds = method, property, event, delegate, class, struct, enum, delegate
+# parameters - Defines any parameter
+dotnet_naming_symbols.parameters.applicable_accessibilities = *
+dotnet_naming_symbols.parameters.applicable_kinds = parameter
+# interface_types - Defines interfaces
+dotnet_naming_symbols.interface_types.applicable_accessibilities = *
+dotnet_naming_symbols.interface_types.applicable_kinds = interface
+
+# Naming Styles
+
+# camel_case - Define the camelCase style
+dotnet_naming_style.camel_case.capitalization = camel_case
+# pascal_case - Define the PascalCase style
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+# prefix_interface_interface_with_i - Interfaces must be PascalCase and the first character of an interface must be an 'I'
+dotnet_naming_style.prefix_interface_interface_with_i.capitalization = pascal_case
+dotnet_naming_style.prefix_interface_interface_with_i.required_prefix = I
+
+# Naming Rules
+
+# Async methods should have the "Async" suffix (disabled because it can't currently exclude async void methods)
+dotnet_naming_rule.async_methods_end_in_async.severity = none
+dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
+dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
+
+dotnet_naming_symbols.any_async_methods.applicable_kinds = method
+dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
+dotnet_naming_symbols.any_async_methods.required_modifiers = async
+
+dotnet_naming_style.end_in_async.required_suffix = Async
+dotnet_naming_style.end_in_async.capitalization = pascal_case
+
+# Private fields must be camelCase
+dotnet_naming_rule.private_fields_must_be_pascal_case.severity = warning
+dotnet_naming_rule.private_fields_must_be_pascal_case.symbols = private_fields
+dotnet_naming_rule.private_fields_must_be_pascal_case.style = camel_case
+# Constant fields must be PascalCase
+dotnet_naming_rule.constant_fields_must_be_pascal_case.severity = warning
+dotnet_naming_rule.constant_fields_must_be_pascal_case.symbols = constant_fields
+dotnet_naming_rule.constant_fields_must_be_pascal_case.style = pascal_case
+# Static readonly fields must be PascalCase
+dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.severity = warning
+dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.symbols = static_readonly_fields
+dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.style = pascal_case
+# Non private fields must be PascalCase
+dotnet_naming_rule.non_private_fields_must_be_pascal_case.severity = warning
+dotnet_naming_rule.non_private_fields_must_be_pascal_case.symbols = non_private_fields
+dotnet_naming_rule.non_private_fields_must_be_pascal_case.style = pascal_case
+# Public symbols must be capitalized
+dotnet_naming_rule.public_symbols_must_be_capitalized.severity = warning
+dotnet_naming_rule.public_symbols_must_be_capitalized.symbols = public_symbols
+dotnet_naming_rule.public_symbols_must_be_capitalized.style = pascal_case
+# Parameters must be camelCase (ignored because some use PascalCase to match Win32 parameter names)
+dotnet_naming_rule.parameters_must_be_camel_case.severity = none
+dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters
+dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case
+# Interfaces must be PascalCase and start with an 'I'
+dotnet_naming_rule.interface_types_must_be_prefixed_with_i.severity = warning
+dotnet_naming_rule.interface_types_must_be_prefixed_with_i.symbols = interface_types
+dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i
+
+# .NET Code Analysis
+
+dotnet_diagnostic.CA1001.severity = warning
+dotnet_diagnostic.CA1009.severity = warning
+dotnet_diagnostic.CA1016.severity = warning
+dotnet_diagnostic.CA1033.severity = warning
+dotnet_diagnostic.CA1049.severity = warning
+dotnet_diagnostic.CA1060.severity = warning
+dotnet_diagnostic.CA1061.severity = warning
+dotnet_diagnostic.CA1063.severity = warning
+dotnet_diagnostic.CA1065.severity = warning
+dotnet_diagnostic.CA1301.severity = warning
+dotnet_diagnostic.CA1400.severity = warning
+dotnet_diagnostic.CA1401.severity = warning
+dotnet_diagnostic.CA1403.severity = warning
+dotnet_diagnostic.CA1404.severity = warning
+dotnet_diagnostic.CA1405.severity = warning
+dotnet_diagnostic.CA1410.severity = warning
+dotnet_diagnostic.CA1415.severity = warning
+dotnet_diagnostic.CA1821.severity = warning
+dotnet_diagnostic.CA1900.severity = warning
+dotnet_diagnostic.CA1901.severity = warning
+dotnet_diagnostic.CA2002.severity = warning
+dotnet_diagnostic.CA2100.severity = warning
+dotnet_diagnostic.CA2101.severity = warning
+dotnet_diagnostic.CA2108.severity = warning
+dotnet_diagnostic.CA2111.severity = warning
+dotnet_diagnostic.CA2112.severity = warning
+dotnet_diagnostic.CA2114.severity = warning
+dotnet_diagnostic.CA2116.severity = warning
+dotnet_diagnostic.CA2117.severity = warning
+dotnet_diagnostic.CA2122.severity = warning
+dotnet_diagnostic.CA2123.severity = warning
+dotnet_diagnostic.CA2124.severity = warning
+dotnet_diagnostic.CA2126.severity = warning
+dotnet_diagnostic.CA2131.severity = warning
+dotnet_diagnostic.CA2132.severity = warning
+dotnet_diagnostic.CA2133.severity = warning
+dotnet_diagnostic.CA2134.severity = warning
+dotnet_diagnostic.CA2137.severity = warning
+dotnet_diagnostic.CA2138.severity = warning
+dotnet_diagnostic.CA2140.severity = warning
+dotnet_diagnostic.CA2141.severity = warning
+dotnet_diagnostic.CA2146.severity = warning
+dotnet_diagnostic.CA2147.severity = warning
+dotnet_diagnostic.CA2149.severity = warning
+dotnet_diagnostic.CA2200.severity = warning
+dotnet_diagnostic.CA2202.severity = warning
+dotnet_diagnostic.CA2207.severity = warning
+dotnet_diagnostic.CA2212.severity = warning
+dotnet_diagnostic.CA2213.severity = warning
+dotnet_diagnostic.CA2214.severity = warning
+dotnet_diagnostic.CA2216.severity = warning
+dotnet_diagnostic.CA2220.severity = warning
+dotnet_diagnostic.CA2229.severity = warning
+dotnet_diagnostic.CA2231.severity = warning
+dotnet_diagnostic.CA2232.severity = warning
+dotnet_diagnostic.CA2235.severity = warning
+dotnet_diagnostic.CA2236.severity = warning
+dotnet_diagnostic.CA2237.severity = warning
+dotnet_diagnostic.CA2238.severity = warning
+dotnet_diagnostic.CA2240.severity = warning
+dotnet_diagnostic.CA2241.severity = warning
+dotnet_diagnostic.CA2242.severity = warning
+
+## CodeStyle Code Analysis
+
+dotnet_diagnostic.IDE0010.severity = none
+dotnet_diagnostic.IDE0130.severity = none
+dotnet_diagnostic.IDE0060.severity = none
+dotnet_diagnostic.IDE1006.severity = none
+dotnet_diagnostic.IDE0023.severity = none
+dotnet_diagnostic.IDE0024.severity = none
+dotnet_diagnostic.IDE0060.severity = none
+dotnet_diagnostic.IDE0057.severity = none
+dotnet_diagnostic.IDE0046.severity = none
+dotnet_diagnostic.IDE0072.severity = none
+dotnet_diagnostic.IDE0064.severity = none
+dotnet_diagnostic.IDE0160.severity = none
+dotnet_diagnostic.IDE0040.severity = none
+dotnet_diagnostic.IDE0045.severity = none
+dotnet_diagnostic.IDE0032.severity = none
+dotnet_diagnostic.IDE0056.severity = none
+dotnet_diagnostic.IDE0032.severity = none
+dotnet_diagnostic.IDE0042.severity = none
+dotnet_diagnostic.IDE0180.severity = none
+dotnet_diagnostic.IDE0061.severity = none
+dotnet_diagnostic.IDE0078.severity = none
+dotnet_diagnostic.IDE0066.severity = none
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..a5096e90
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,51 @@
+# Set default file-type attributes
+
+# All file types
+* text=auto
+
+# Markups
+*.md text=auto diff=markdown
+*.mdx text=auto diff=markdown
+
+# Solutions
+*.sln text=auto eol=crlf
+*.slnx text=auto
+
+# Projects
+*.*proj text=auto
+*.tasks text=auto
+*.props text=auto
+*.targets text=auto
+
+# Sources
+*.cs text=auto diff=csharp
+*.csx text=auto diff=csharp
+*.fs text=auto diff=fsharp
+*.resx text=auto
+
+# Scripts
+*.in text eol=lf
+*.sh text eol=lf
+*.bat text eol=crlf
+*.cmd text eol=crlf
+
+# Images
+*.png binary
+*.jpg binary
+*.gif binary
+
+# Keys
+*.snk binary
+*.pfx binary
+*.cer binary
+
+# Others
+
+# Preserve Line endings in diff and patch files
+*.diff -text
+*.patch -text
+
+# Exclude git meta files from exporting
+.gitattributes export-ignore
+.gitignore export-ignore
+.gitkeep export-ignore
\ No newline at end of file
diff --git a/ComputeSharp.sln b/ComputeSharp.sln
index 01972b73..85170bc5 100644
--- a/ComputeSharp.sln
+++ b/ComputeSharp.sln
@@ -19,6 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Tests.Internal
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SolutionItems", "_SolutionItems", "{1A9C4108-F61A-4ABE-B5CF-F524521EAE2D}"
ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
src\Directory.Build.props = src\Directory.Build.props
diff --git a/Directory.Build.props b/Directory.Build.props
index e4ce4160..d1ad3df7 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,13 +3,45 @@
true
11.0
enable
- strict
true
+
+
+ 7
+
+
+ 7-all
+
+
+ strict
+
+
+
+
+
$(NoWarn);MSB3270
+
+
+ $(NoWarn);CA1060
+
@@ -37,7 +69,7 @@
-
+
true
$([System.Text.RegularExpressions.Regex]::Match($(GITHUB_REF_NAME), $(ReleaseVersionParsingRegex)).Groups[1].Value)
$([System.Text.RegularExpressions.Regex]::Match($(GITHUB_REF_NAME), $(ReleaseVersionParsingRegex)).Groups[2].Value)
@@ -58,7 +90,7 @@
https://github.com/Sergio0694/ComputeSharp/
git
true
- https://github.com/Sergio0694/ComputeSharp/
+ https://github.com/Sergio0694/ComputeSharp/
Sergio Pedri
Sergio Pedri
Sergio Pedri
@@ -71,7 +103,7 @@
true
-
+
diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
index 326d0527..e786756b 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
@@ -1,8 +1,10 @@
-using System;
+using System;
using System.Buffers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
+#pragma warning disable CA1063
+
namespace ComputeSharp.Benchmark.Blas;
///
@@ -17,64 +19,64 @@ public class BlasBenchmark : IDisposable
private const int C = 128;
///
- /// The nummber of rows in the matrix.
+ /// The nummber of rows in the matrix.
///
private const int N = 512;
///
- /// The number of columns in the matrix (same as the number of rows in the matrix)
+ /// The number of columns in the matrix (same as the number of rows in the matrix)
///
private const int M = 512;
///
- /// The number of columns in the matrix.
+ /// The number of columns in the matrix.
///
private const int P = 256;
///
/// The input tensor.
///
- private float[]? X;
+ private float[]? x;
///
/// The weights tensor.
///
- private float[]? W;
+ private float[]? w;
///
/// The bias tensor.
///
- private float[]? B;
+ private float[]? b;
///
/// The result tensor.
///
- private float[]? Y;
+ private float[]? y;
///
/// The input tensor (GPU).
///
- private ReadOnlyBuffer? BufferX;
+ private ReadOnlyBuffer? bufferX;
///
/// The weights tensor (GPU).
///
- private ReadOnlyBuffer? BufferW;
+ private ReadOnlyBuffer? bufferW;
///
/// The bias tensor (GPU).
///
- private ReadOnlyBuffer? BufferB;
+ private ReadOnlyBuffer? bufferB;
///
/// The result tensor (GPU).
///
- private ReadWriteBuffer? BufferY;
+ private ReadWriteBuffer? bufferY;
///
/// A instance to initialize the tensors.
///
- private readonly Random Random = new Random();
+ private readonly Random random = new();
///
/// Initial setup for a benchmarking session.
@@ -89,21 +91,21 @@ public class BlasBenchmark : IDisposable
foreach (ref float x in array.AsSpan())
{
- x = (float)Random.NextDouble();
+ x = (float)this.random.NextDouble();
}
return array;
}
- X = CreateRandomArray(C * N * M);
- W = CreateRandomArray(M * P);
- B = CreateRandomArray(P);
- Y = CreateRandomArray(C * N * P);
+ this.x = CreateRandomArray(C * N * M);
+ this.w = CreateRandomArray(M * P);
+ this.b = CreateRandomArray(P);
+ this.y = CreateRandomArray(C * N * P);
- BufferX = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(X);
- BufferW = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(W);
- BufferB = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(B);
- BufferY = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(Y);
+ this.bufferX = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.x);
+ this.bufferW = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.w);
+ this.bufferB = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.b);
+ this.bufferY = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(this.y);
Cpu();
GpuWithNoTemporaryBuffers();
@@ -114,15 +116,15 @@ public class BlasBenchmark : IDisposable
[GlobalCleanup]
public void Dispose()
{
- ArrayPool.Shared.Return(X!);
- ArrayPool.Shared.Return(W!);
- ArrayPool.Shared.Return(B!);
- ArrayPool.Shared.Return(Y!);
+ ArrayPool.Shared.Return(this.x!);
+ ArrayPool.Shared.Return(this.w!);
+ ArrayPool.Shared.Return(this.b!);
+ ArrayPool.Shared.Return(this.y!);
- BufferX!.Dispose();
- BufferW!.Dispose();
- BufferB!.Dispose();
- BufferY!.Dispose();
+ this.bufferX!.Dispose();
+ this.bufferW!.Dispose();
+ this.bufferB!.Dispose();
+ this.bufferY!.Dispose();
}
///
@@ -131,7 +133,7 @@ public class BlasBenchmark : IDisposable
[Benchmark(Baseline = true)]
public void Cpu()
{
- BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X!, W!, B!, Y!);
+ BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, this.x!, this.w!, this.b!, this.y!);
}
///
@@ -140,7 +142,7 @@ public class BlasBenchmark : IDisposable
[Benchmark]
public void GpuWithNoTemporaryBuffers()
{
- BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.GetDefault(), C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
+ BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.GetDefault(), C, N, M, P, this.bufferX!, this.bufferW!, this.bufferB!, this.bufferY!);
}
///
@@ -149,13 +151,13 @@ public class BlasBenchmark : IDisposable
[Benchmark]
public void GpuWithTemporaryBuffers()
{
- using ReadOnlyBuffer x = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(X!);
- using ReadOnlyBuffer w = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(W!);
- using ReadOnlyBuffer b = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(B!);
- using ReadWriteBuffer y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(Y!.Length);
+ using ReadOnlyBuffer x = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.x!);
+ using ReadOnlyBuffer w = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.w!);
+ using ReadOnlyBuffer b = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(this.b!);
+ using ReadWriteBuffer y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(this.y!.Length);
BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.GetDefault(), C, N, M, P, x, w, b, y);
- y.CopyTo(Y);
+ y.CopyTo(this.y);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
index b58acb8e..a2d94d21 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace ComputeSharp.Benchmark.Blas;
@@ -39,7 +39,7 @@ internal static partial class BlasHelpers
for (int k = 0; k < m; k++)
{
- result += Unsafe.Add(ref rx, x_offset + k) * Unsafe.Add(ref rw, k * p + j);
+ result += Unsafe.Add(ref rx, x_offset + k) * Unsafe.Add(ref rw, (k * p) + j);
}
Unsafe.Add(ref ry, y_offset + j) = result + Unsafe.Add(ref rb, j);
@@ -47,7 +47,7 @@ internal static partial class BlasHelpers
}
}
- Parallel.For(0, c, Kernel);
+ _ = Parallel.For(0, c, Kernel);
}
///
@@ -83,26 +83,26 @@ internal static partial class BlasHelpers
[AutoConstructor]
public readonly partial struct FullyConnectedForwardKernel : IComputeShader
{
- public readonly int n;
- public readonly int m;
- public readonly int p;
- public readonly ReadOnlyBuffer x;
- public readonly ReadOnlyBuffer w;
- public readonly ReadOnlyBuffer b;
- public readonly ReadWriteBuffer y;
+ private readonly int n;
+ private readonly int m;
+ private readonly int p;
+ private readonly ReadOnlyBuffer x;
+ private readonly ReadOnlyBuffer w;
+ private readonly ReadOnlyBuffer b;
+ private readonly ReadWriteBuffer y;
///
public void Execute()
{
- int x_offset = ThreadIds.X * n * p + ThreadIds.Y * m;
+ int x_offset = (ThreadIds.X * this.n * this.p) + (ThreadIds.Y * this.m);
float result = 0f;
- for (int k = 0; k < m; k++)
+ for (int k = 0; k < this.m; k++)
{
- result += x[x_offset + k] * w[k * p + ThreadIds.Z];
+ result += this.x[x_offset + k] * this.w[(k * this.p) + ThreadIds.Z];
}
- y[ThreadIds.X * n * p + ThreadIds.Y * p + ThreadIds.Z] = result + b[ThreadIds.Z];
+ this.y[(ThreadIds.X * this.n * this.p) + (ThreadIds.Y * this.p) + ThreadIds.Z] = result + this.b[ThreadIds.Z];
}
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
index f7c71449..a3ec85a8 100644
--- a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
@@ -1,8 +1,10 @@
-using System;
+using System;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
+#pragma warning disable CA1063
+
namespace ComputeSharp.Benchmark.Blas;
///
@@ -15,7 +17,7 @@ public partial class DispatchingBenchmark : IDisposable
///
/// The test buffer.
///
- private ReadWriteBuffer? Buffer;
+ private ReadWriteBuffer? buffer;
///
/// Initial setup for a benchmarking session.
@@ -23,14 +25,14 @@ public partial class DispatchingBenchmark : IDisposable
[GlobalSetup]
public void Setup()
{
- Buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(128);
+ this.buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(128);
}
///
[GlobalCleanup]
public void Dispose()
{
- Buffer!.Dispose();
+ this.buffer!.Dispose();
}
///
@@ -40,7 +42,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public void Compute_Single()
{
- GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(this.buffer!));
}
///
@@ -50,9 +52,9 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public void Compute_Single_WithContext()
{
- using var context = GraphicsDevice.GetDefault().CreateComputeContext();
+ using ComputeContext context = GraphicsDevice.GetDefault().CreateComputeContext();
- context.For(64, new TestShader(Buffer!));
+ context.For(64, new TestShader(this.buffer!));
}
///
@@ -62,9 +64,9 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public async Task Compute_Single_WithContext_Async()
{
- await using var context = GraphicsDevice.GetDefault().CreateComputeContext();
+ await using ComputeContext context = GraphicsDevice.GetDefault().CreateComputeContext();
- context.For(64, new TestShader(Buffer!));
+ context.For(64, new TestShader(this.buffer!));
}
///
@@ -74,8 +76,8 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public void Compute_Multiple()
{
- GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
- GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(this.buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(this.buffer!));
}
///
@@ -85,11 +87,11 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public void Compute_Multiple_WithContext()
{
- using var context = GraphicsDevice.GetDefault().CreateComputeContext();
+ using ComputeContext context = GraphicsDevice.GetDefault().CreateComputeContext();
- context.For(64, new TestShader(Buffer!));
- context.Barrier(Buffer!);
- context.For(64, new TestShader(Buffer!));
+ context.For(64, new TestShader(this.buffer!));
+ context.Barrier(this.buffer!);
+ context.For(64, new TestShader(this.buffer!));
}
///
@@ -99,21 +101,21 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public async Task Compute_Multiple_WithContext_Async()
{
- await using var context = GraphicsDevice.GetDefault().CreateComputeContext();
+ await using ComputeContext context = GraphicsDevice.GetDefault().CreateComputeContext();
- context.For(64, new TestShader(Buffer!));
- context.Barrier(Buffer!);
- context.For(64, new TestShader(Buffer!));
+ context.For(64, new TestShader(this.buffer!));
+ context.Barrier(this.buffer!);
+ context.For(64, new TestShader(this.buffer!));
}
[AutoConstructor]
internal readonly partial struct TestShader : IComputeShader
{
- public readonly ReadWriteBuffer buffer;
+ private readonly ReadWriteBuffer buffer;
///
public void Execute()
{
}
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
index 12ecc013..84ef323f 100644
--- a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Reflection;
using BenchmarkDotNet.Attributes;
@@ -10,6 +10,8 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Convolution;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
+#pragma warning disable CA1063
+
namespace ComputeSharp.Benchmark.Imaging;
///
@@ -89,4 +91,4 @@ public class ImagingBenchmark : IDisposable
{
this.image!.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Benchmark/Program.cs b/samples/ComputeSharp.Benchmark/Program.cs
index c6be10ee..d095abb2 100644
--- a/samples/ComputeSharp.Benchmark/Program.cs
+++ b/samples/ComputeSharp.Benchmark/Program.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using BenchmarkDotNet.Running;
// =================
@@ -8,4 +8,4 @@ using BenchmarkDotNet.Running;
// it as the startup project for the solution and run it without the debugger
// (CTRL + F5), or compile it and then go to its bin\Release\net6.0 folder,
// open a cmd prompt and run "dotnet ComputeSharp.Benchmark.dll".
-BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);
+BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs b/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs
index 37aeea99..03c2ab44 100644
--- a/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs
+++ b/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Runtime.CompilerServices;
@@ -41,5 +41,5 @@ internal readonly struct Complex64
/// The scalar to use to multiply the value.
/// The result.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar);
-}
+ public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar);
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Primitives/ComplexVector4.cs b/samples/ComputeSharp.ImageProcessing/Primitives/ComplexVector4.cs
index 3d3431f4..a7effc7b 100644
--- a/samples/ComputeSharp.ImageProcessing/Primitives/ComplexVector4.cs
+++ b/samples/ComputeSharp.ImageProcessing/Primitives/ComplexVector4.cs
@@ -1,9 +1,11 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using System.Runtime.CompilerServices;
+#pragma warning disable IDE0022
+
namespace SixLabors.ImageSharp;
///
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
index f2b1f4c7..f6435bbc 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using CommunityToolkit.Diagnostics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
@@ -77,8 +77,8 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format.");
}
- var processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle);
+ Implementation processor = new(this, configuration, Unsafe.As>(source), sourceRectangle);
return Unsafe.As>(processor);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
index 2677d2a2..cb4a3949 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Numerics;
@@ -23,37 +23,37 @@ public sealed partial class HlslBokehBlurProcessor
///
/// The instance in use.
///
- private readonly GraphicsDevice GraphicsDevice;
+ private readonly GraphicsDevice graphicsDevice;
///
/// The kernel radius.
///
- private readonly int Radius;
+ private readonly int radius;
///
/// The maximum size of the kernel in either direction.
///
- private readonly int KernelSize;
+ private readonly int kernelSize;
///
/// The number of components to use when applying the bokeh blur.
///
- private readonly int ComponentsCount;
+ private readonly int componentsCount;
///
/// The kernel parameters to use for the current instance (a: X, b: Y, A: Z, B: W)
///
- private readonly Vector4[] KernelParameters;
+ private readonly Vector4[] kernelParameters;
///
/// The kernel components for the current instance.
///
- private readonly Complex64[][] Kernels;
+ private readonly Complex64[][] kernels;
///
/// The scaling factor for kernel values.
///
- private readonly float KernelsScale;
+ private readonly float kernelsScale;
///
/// The mapping of initialized complex kernels and parameters, to speed up the initialization of new instances.
@@ -70,29 +70,30 @@ public sealed partial class HlslBokehBlurProcessor
public Implementation(HlslBokehBlurProcessor definition, Configuration configuration, Image source, Rectangle sourceRectangle)
: base(configuration, source, sourceRectangle)
{
- GraphicsDevice = definition.GraphicsDevice;
- Radius = definition.Radius;
- KernelSize = Radius * 2 + 1;
- ComponentsCount = definition.Components;
+ this.graphicsDevice = definition.GraphicsDevice;
+ this.radius = definition.Radius;
+ this.kernelSize = (this.radius * 2) + 1;
+ this.componentsCount = definition.Components;
// Reuse the initialized values from the cache, if possible
- var parameters = (Radius, ComponentsCount);
- if (Cache.TryGetValue(parameters, out var info))
+ (int radius, int componentsCount) parameters = (this.radius, this.componentsCount);
+
+ if (Cache.TryGetValue(parameters, out (Vector4[] Parameters, float Scale, Complex64[][] Kernels) info))
{
- KernelParameters = info.Parameters;
- KernelsScale = info.Scale;
- Kernels = info.Kernels;
+ this.kernelParameters = info.Parameters;
+ this.kernelsScale = info.Scale;
+ this.kernels = info.Kernels;
}
else
{
// Initialize the complex kernels and parameters with the current arguments
- (KernelParameters, KernelsScale) = GetParameters();
- Kernels = CreateComplexKernels();
+ (this.kernelParameters, this.kernelsScale) = GetParameters();
+ this.kernels = CreateComplexKernels();
NormalizeKernels();
// Store them in the cache for future use
- Cache.TryAdd(parameters, (KernelParameters, KernelsScale, Kernels));
+ _ = Cache.TryAdd(parameters, (this.kernelParameters, this.kernelsScale, this.kernels));
}
}
@@ -161,7 +162,7 @@ public sealed partial class HlslBokehBlurProcessor
private (Vector4[] Parameters, float Scale) GetParameters()
{
// Prepare the kernel components
- int index = Math.Max(0, Math.Min(ComponentsCount - 1, KernelComponents.Count));
+ int index = Math.Max(0, Math.Min(this.componentsCount - 1, KernelComponents.Count));
return (KernelComponents[index], KernelScales[index]);
}
@@ -171,10 +172,10 @@ public sealed partial class HlslBokehBlurProcessor
///
private Complex64[][] CreateComplexKernels()
{
- var kernels = new Complex64[KernelParameters.Length][];
- ref Vector4 baseRef = ref MemoryMarshal.GetReference(KernelParameters.AsSpan());
+ Complex64[][] kernels = new Complex64[this.kernelParameters.Length][];
+ ref Vector4 baseRef = ref MemoryMarshal.GetReference(this.kernelParameters.AsSpan());
- for (int i = 0; i < KernelParameters.Length; i++)
+ for (int i = 0; i < this.kernelParameters.Length; i++)
{
ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, i);
@@ -191,15 +192,15 @@ public sealed partial class HlslBokehBlurProcessor
/// The angle component for each complex component.
private Complex64[] CreateComplex1DKernel(float a, float b)
{
- var kernel = new Complex64[KernelSize];
+ Complex64[] kernel = new Complex64[this.kernelSize];
ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan());
- int r = Radius;
+ int r = this.radius;
int n = -r;
- for (int i = 0; i < KernelSize; i++, n++)
+ for (int i = 0; i < this.kernelSize; i++, n++)
{
// Incrementally compute the range values
- float value = n * KernelsScale * (1f / r);
+ float value = n * this.kernelsScale * (1f / r);
value *= value;
@@ -219,11 +220,11 @@ public sealed partial class HlslBokehBlurProcessor
{
// Calculate the complex weighted sum
float total = 0;
- Span kernelsSpan = Kernels.AsSpan();
+ Span kernelsSpan = this.kernels.AsSpan();
ref Complex64[] baseKernelsRef = ref MemoryMarshal.GetReference(kernelsSpan);
- ref Vector4 baseParamsRef = ref MemoryMarshal.GetReference(KernelParameters.AsSpan());
+ ref Vector4 baseParamsRef = ref MemoryMarshal.GetReference(this.kernelParameters.AsSpan());
- for (int i = 0; i < KernelParameters.Length; i++)
+ for (int i = 0; i < this.kernelParameters.Length; i++)
{
ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, i);
int length = kernelRef.Length;
@@ -238,8 +239,8 @@ public sealed partial class HlslBokehBlurProcessor
ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k);
total +=
- paramsRef.Z * (jRef.Real * kRef.Real - jRef.Imaginary * kRef.Imaginary)
- + paramsRef.W * (jRef.Real * kRef.Imaginary + jRef.Imaginary * kRef.Real);
+ (paramsRef.Z * ((jRef.Real * kRef.Real) - (jRef.Imaginary * kRef.Imaginary)))
+ + (paramsRef.W * ((jRef.Real * kRef.Imaginary) + (jRef.Imaginary * kRef.Real)));
}
}
}
@@ -270,23 +271,23 @@ public sealed partial class HlslBokehBlurProcessor
Span span = MemoryMarshal.Cast(pixelMemory.Span);
- using ReadWriteTexture2D texture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
- using ReadWriteTexture2D temporary = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear);
- using ReadWriteTexture2D reals = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadWriteTexture2D imaginaries = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadOnlyBuffer kernel = GraphicsDevice.AllocateReadOnlyBuffer(KernelSize);
+ using ReadWriteTexture2D texture = this.graphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
+ using ReadWriteTexture2D temporary = this.graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear);
+ using ReadWriteTexture2D reals = this.graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadWriteTexture2D imaginaries = this.graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadOnlyBuffer kernel = this.graphicsDevice.AllocateReadOnlyBuffer(this.kernelSize);
// Preliminary gamma highlight pass
- GraphicsDevice.For(source.Height, new(texture));
+ this.graphicsDevice.For(source.Height, new(texture));
// Perform two 1D convolutions for each component in the current instance
- for (int j = 0; j < Kernels.Length; j++)
+ for (int j = 0; j < this.kernels.Length; j++)
{
- Vector4 parameters = KernelParameters[j];
+ Vector4 parameters = this.kernelParameters[j];
- kernel.CopyFrom(Kernels[j]);
+ kernel.CopyFrom(this.kernels[j]);
- using var context = GraphicsDevice.CreateComputeContext();
+ using ComputeContext context = this.graphicsDevice.CreateComputeContext();
context.For(
source.Width,
@@ -303,7 +304,7 @@ public sealed partial class HlslBokehBlurProcessor
}
// Apply the inverse gamma exposure pass
- GraphicsDevice.For(source.Height, new(temporary, texture));
+ this.graphicsDevice.For(source.Height, new(temporary, texture));
// Write the final pixel data
texture.CopyTo(span);
@@ -313,36 +314,36 @@ public sealed partial class HlslBokehBlurProcessor
/// Kernel for the vertical convolution pass.
///
[AutoConstructor]
- internal partial struct VerticalConvolutionProcessor : IComputeShader
+ internal readonly partial struct VerticalConvolutionProcessor : IComputeShader
{
- public IReadWriteNormalizedTexture2D source;
- public ReadWriteTexture2D reals;
- public ReadWriteTexture2D imaginaries;
- public ReadOnlyBuffer kernel;
+ private readonly IReadWriteNormalizedTexture2D source;
+ private readonly ReadWriteTexture2D reals;
+ private readonly ReadWriteTexture2D imaginaries;
+ private readonly ReadOnlyBuffer kernel;
///
public void Execute()
{
float4 real = float4.Zero;
float4 imaginary = float4.Zero;
- int maxY = source.Height;
- int maxX = source.Width;
- int kernelLength = kernel.Length;
+ int maxY = this.source.Height;
+ int maxX = this.source.Width;
+ int kernelLength = this.kernel.Length;
int radiusY = kernelLength >> 1;
for (int i = 0; i < kernelLength; i++)
{
int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
- float4 color = source[offsetX, offsetY];
- Complex64 factors = kernel[i];
+ float4 color = this.source[offsetX, offsetY];
+ Complex64 factors = this.kernel[i];
real += factors.Real * color;
imaginary += factors.Imaginary * color;
}
- reals[ThreadIds.XY] = real;
- imaginaries[ThreadIds.XY] = imaginary;
+ this.reals[ThreadIds.XY] = real;
+ this.imaginaries[ThreadIds.XY] = imaginary;
}
}
@@ -350,22 +351,22 @@ public sealed partial class HlslBokehBlurProcessor
/// Kernel for the horizontal convolution pass.
///
[AutoConstructor]
- internal partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
+ internal readonly partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
{
- public float z;
- public float w;
+ private readonly float z;
+ private readonly float w;
- public ReadWriteTexture2D reals;
- public ReadWriteTexture2D imaginaries;
- public ReadWriteTexture2D target;
- public ReadOnlyBuffer kernel;
+ private readonly ReadWriteTexture2D reals;
+ private readonly ReadWriteTexture2D imaginaries;
+ private readonly ReadWriteTexture2D target;
+ private readonly ReadOnlyBuffer kernel;
///
public void Execute()
{
- int maxY = target.Height;
- int maxX = target.Width;
- int kernelLength = kernel.Length;
+ int maxY = this.target.Height;
+ int maxX = this.target.Width;
+ int kernelLength = this.kernel.Length;
int radiusX = kernelLength >> 1;
int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
ComplexVector4 result = default;
@@ -373,15 +374,15 @@ public sealed partial class HlslBokehBlurProcessor
for (int i = 0; i < kernelLength; i++)
{
int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
- float4 sourceReal = reals[offsetX, offsetY];
- float4 sourceImaginary = imaginaries[offsetX, offsetY];
- Complex64 factors = kernel[i];
+ float4 sourceReal = this.reals[offsetX, offsetY];
+ float4 sourceImaginary = this.imaginaries[offsetX, offsetY];
+ Complex64 factors = this.kernel[i];
- result.Real += (Vector4)(factors.Real * sourceReal - factors.Imaginary * sourceImaginary);
- result.Imaginary += (Vector4)(factors.Real * sourceImaginary + factors.Imaginary * sourceReal);
+ result.Real += (Vector4)((factors.Real * sourceReal) - (factors.Imaginary * sourceImaginary));
+ result.Imaginary += (Vector4)((factors.Real * sourceImaginary) + (factors.Imaginary * sourceReal));
}
- target[ThreadIds.XY] += (float4)result.WeightedSum(z, w);
+ this.target[ThreadIds.XY] += (float4)result.WeightedSum(this.z, this.w);
}
}
@@ -391,20 +392,20 @@ public sealed partial class HlslBokehBlurProcessor
[AutoConstructor]
internal readonly partial struct GammaHighlightProcessor : IComputeShader
{
- public readonly IReadWriteNormalizedTexture2D source;
+ private readonly IReadWriteNormalizedTexture2D source;
///
public void Execute()
{
- int width = source.Width;
+ int width = this.source.Width;
for (int i = 0; i < width; i++)
{
- float4 v = source[i, ThreadIds.X];
+ float4 v = this.source[i, ThreadIds.X];
v.XYZ = v.XYZ * v.XYZ * v.XYZ;
- source[i, ThreadIds.X] = v;
+ this.source[i, ThreadIds.X] = v;
}
}
}
@@ -415,24 +416,24 @@ public sealed partial class HlslBokehBlurProcessor
[AutoConstructor]
internal readonly partial struct InverseGammaHighlightProcessor : IComputeShader
{
- public readonly ReadWriteTexture2D source;
- public readonly IReadWriteNormalizedTexture2D target;
+ private readonly ReadWriteTexture2D source;
+ private readonly IReadWriteNormalizedTexture2D target;
///
public void Execute()
{
- int width = source.Width;
+ int width = this.source.Width;
for (int i = 0; i < width; i++)
{
- float4 v = source[i, ThreadIds.X];
+ float4 v = this.source[i, ThreadIds.X];
v = Hlsl.Clamp(v, 0, float.MaxValue);
v.XYZ = Hlsl.Pow(v.XYZ, 1 / 3f);
- target[i, ThreadIds.X] = v;
+ this.target[i, ThreadIds.X] = v;
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
index b046b334..c2e67e9d 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using CommunityToolkit.Diagnostics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
@@ -52,7 +52,8 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
/// The radius value representing the size of the area to sample (this should be at least twice the sigma value)
public HlslGaussianBlurProcessor(GraphicsDevice device, float sigma, int radius)
{
- GraphicsDevice = device;
+ this.graphicsDevice = device;
+
Sigma = sigma;
Radius = radius;
}
@@ -60,7 +61,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
///
/// The instance in use.
///
- private readonly GraphicsDevice GraphicsDevice;
+ private readonly GraphicsDevice graphicsDevice;
///
/// Gets the sigma value representing the weight of the blur.
@@ -81,8 +82,8 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format.");
}
- var processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle);
+ Implementation processor = new(this, configuration, Unsafe.As>(source), sourceRectangle);
return Unsafe.As>(processor);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
index d6edd6e6..e24a82a2 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using CommunityToolkit.Diagnostics;
@@ -19,12 +19,12 @@ public sealed partial class HlslGaussianBlurProcessor
///
/// The instance in use.
///
- private readonly GraphicsDevice GraphicsDevice;
+ private readonly GraphicsDevice graphicsDevice;
///
/// The 1D kernel to apply.
///
- private readonly float[] Kernel;
+ private readonly float[] kernel;
///
/// Initializes a new instance of the class.
@@ -36,10 +36,10 @@ public sealed partial class HlslGaussianBlurProcessor
public Implementation(HlslGaussianBlurProcessor definition, Configuration configuration, Image source, Rectangle sourceRectangle)
: base(configuration, source, sourceRectangle)
{
- int kernelSize = definition.Radius * 2 + 1;
+ int kernelSize = (definition.Radius * 2) + 1;
- GraphicsDevice = definition.GraphicsDevice;
- Kernel = CreateGaussianBlurKernel(kernelSize, definition.Sigma);
+ this.graphicsDevice = definition.graphicsDevice;
+ this.kernel = CreateGaussianBlurKernel(kernelSize, definition.Sigma);
}
///
@@ -100,11 +100,11 @@ public sealed partial class HlslGaussianBlurProcessor
Span span = MemoryMarshal.Cast(pixelMemory.Span);
- using ReadWriteTexture2D sourceTexture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
- using ReadWriteTexture2D firstPassTexture = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadOnlyBuffer kernelBuffer = GraphicsDevice.AllocateReadOnlyBuffer(Kernel);
+ using ReadWriteTexture2D sourceTexture = this.graphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
+ using ReadWriteTexture2D firstPassTexture = this.graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadOnlyBuffer kernelBuffer = this.graphicsDevice.AllocateReadOnlyBuffer(this.kernel);
- using (var context = GraphicsDevice.CreateComputeContext())
+ using (ComputeContext context = this.graphicsDevice.CreateComputeContext())
{
context.For(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer));
context.Barrier(firstPassTexture);
@@ -120,29 +120,29 @@ public sealed partial class HlslGaussianBlurProcessor
[AutoConstructor]
internal readonly partial struct VerticalConvolutionProcessor : IComputeShader
{
- public readonly IReadWriteNormalizedTexture2D source;
- public readonly IReadWriteNormalizedTexture2D target;
- public readonly ReadOnlyBuffer kernel;
+ private readonly IReadWriteNormalizedTexture2D source;
+ private readonly IReadWriteNormalizedTexture2D target;
+ private readonly ReadOnlyBuffer kernel;
///
public void Execute()
{
float4 result = float4.Zero;
- int maxY = source.Height - 1;
- int maxX = source.Width - 1;
- int kernelLength = kernel.Length;
+ int maxY = this.source.Height - 1;
+ int maxX = this.source.Width - 1;
+ int kernelLength = this.kernel.Length;
int radiusY = kernelLength >> 1;
for (int i = 0; i < kernelLength; i++)
{
int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
- float4 color = source[offsetX, offsetY];
+ float4 color = this.source[offsetX, offsetY];
- result += kernel[i] * color;
+ result += this.kernel[i] * color;
}
- target[ThreadIds.XY] = result;
+ this.target[ThreadIds.XY] = result;
}
}
@@ -152,30 +152,30 @@ public sealed partial class HlslGaussianBlurProcessor
[AutoConstructor]
internal readonly partial struct HorizontalConvolutionProcessor : IComputeShader
{
- public readonly IReadWriteNormalizedTexture2D source;
- public readonly IReadWriteNormalizedTexture2D target;
- public readonly ReadOnlyBuffer kernel;
+ private readonly IReadWriteNormalizedTexture2D source;
+ private readonly IReadWriteNormalizedTexture2D target;
+ private readonly ReadOnlyBuffer kernel;
///
public void Execute()
{
float4 result = float4.Zero;
- int maxY = source.Height - 1;
- int maxX = source.Width - 1;
- int kernelLength = kernel.Length;
+ int maxY = this.source.Height - 1;
+ int maxX = this.source.Width - 1;
+ int kernelLength = this.kernel.Length;
int radiusX = kernelLength >> 1;
int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
for (int i = 0; i < kernelLength; i++)
{
int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
- float4 color = source[offsetX, offsetY];
+ float4 color = this.source[offsetX, offsetY];
- result += kernel[i] * color;
+ result += this.kernel[i] * color;
}
- target[ThreadIds.XY] = result;
+ this.target[ThreadIds.XY] = result;
}
}
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs
index 9d862a93..7b764178 100644
--- a/samples/ComputeSharp.ImageProcessing/Program.cs
+++ b/samples/ComputeSharp.ImageProcessing/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Reflection;
using ComputeSharp.BokehBlur.Processors;
@@ -15,7 +15,7 @@ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly()
using Image image = Image.Load(path);
// Apply a series of processors and save the results
-foreach (var effect in new (string Name, IImageProcessor Processor)[]
+foreach ((string Name, IImageProcessor Processor) effect in new (string Name, IImageProcessor Processor)[]
{
("bokeh", new HlslBokehBlurProcessor(80, 2)),
("gaussian", new HlslGaussianBlurProcessor(80))
@@ -37,4 +37,4 @@ foreach (var effect in new (string Name, IImageProcessor Processor)[]
targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
copy.Save(targetPath);
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs b/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs
index 4d20dfb6..3b9e6f98 100644
--- a/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs
+++ b/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.Sample.FSharp.Shaders;
+namespace ComputeSharp.Sample.FSharp.Shaders;
///
/// A sample shader thaat just multiplies items in a buffer by two.
@@ -6,11 +6,11 @@
[AutoConstructor]
public readonly partial struct MultiplyByTwo : IComputeShader
{
- public readonly ReadWriteBuffer buffer;
+ private readonly ReadWriteBuffer buffer;
///
public void Execute()
{
- buffer[ThreadIds.X] *= 2;
+ this.buffer[ThreadIds.X] *= 2;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Sample/Helpers/Formatting.cs b/samples/ComputeSharp.Sample/Helpers/Formatting.cs
index 6fbe1b6e..54c23634 100644
--- a/samples/ComputeSharp.Sample/Helpers/Formatting.cs
+++ b/samples/ComputeSharp.Sample/Helpers/Formatting.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Globalization;
using System.Linq;
using CommunityToolkit.Diagnostics;
@@ -34,12 +34,12 @@ internal static class Formatting
for (int i = 0; i < height; i++)
{
- var row = array.AsSpan(i * width, width).ToArray();
- var text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth)));
+ float[] row = array.AsSpan(i * width, width).ToArray();
+ string text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth)));
Console.WriteLine(text);
}
Console.WriteLine(new string('=', 50));
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.Sample/Program.cs b/samples/ComputeSharp.Sample/Program.cs
index 64294e81..21e050fa 100644
--- a/samples/ComputeSharp.Sample/Program.cs
+++ b/samples/ComputeSharp.Sample/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using ComputeSharp;
using ComputeSharp.Sample;
@@ -26,11 +26,11 @@ Formatting.PrintMatrix(array, 10, 10, "AFTER");
[AutoConstructor]
internal readonly partial struct MultiplyByTwo : IComputeShader
{
- public readonly ReadWriteBuffer buffer;
+ private readonly ReadWriteBuffer buffer;
///
public void Execute()
{
- buffer[ThreadIds.X] *= 2;
+ this.buffer[ThreadIds.X] *= 2;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs
index fa6f2fce..3665d3dd 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Core.Constants;
+namespace ComputeSharp.SwapChain.Core.Constants;
///
/// A with the collection of tracked errors for analytics.
@@ -7,4 +7,4 @@ public static class Error
{
public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)";
public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)";
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs
index 171865b4..67d2b89d 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Core.Constants;
+namespace ComputeSharp.SwapChain.Core.Constants;
///
/// A with the collection of tracked events for analytics.
@@ -12,4 +12,4 @@ public static class Event
public const string IsRenderingPausedChanged = "[SETTINGS] IsRenderingPaused";
public const string OpenShaderSelectionPanel = "[SHELL] Open ShaderSelectionPanel";
public const string CloseShaderSelectionPanel = "[SHELL] Close ShaderSelectionPanel";
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs
index 18c8479b..3a04208c 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs
@@ -1,4 +1,4 @@
-#if WINDOWS_UWP
+#if WINDOWS_UWP
using Windows.UI.Xaml.Controls;
#else
using Microsoft.UI.Xaml.Controls;
@@ -20,4 +20,4 @@ public static class RenderingPauseConverter
{
return value ? Symbol.Play : Symbol.Pause;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/ResolutionScaleConverter.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/ResolutionScaleConverter.cs
index b13c844a..a7be9a73 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/ResolutionScaleConverter.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/ResolutionScaleConverter.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Core.Converters;
+namespace ComputeSharp.SwapChain.Core.Converters;
///
/// A class with some static converters for resolution scale settings.
@@ -24,4 +24,4 @@ public static class ResolutionScaleConverter
{
return value / 100.0;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
index c3945e56..d022277a 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
using System.Text;
@@ -16,13 +16,13 @@ public sealed class DebugAnalyticsService : IAnalyticsService
{
StringBuilder builder = new();
- builder.AppendLine($"[EVENT]: \"{title}\"");
+ _ = builder.AppendLine($"[EVENT]: \"{title}\"");
if (data is not null)
{
- foreach (var info in data)
+ foreach ((string Property, object? Value) info in data)
{
- builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
+ _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
}
}
@@ -34,18 +34,18 @@ public sealed class DebugAnalyticsService : IAnalyticsService
{
StringBuilder builder = new();
- builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
- builder.AppendLine(">> Stack trace");
- builder.AppendLine(exception.StackTrace);
+ _ = builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
+ _ = builder.AppendLine(">> Stack trace");
+ _ = builder.AppendLine(exception.StackTrace);
if (data is not null)
{
- foreach (var info in data)
+ foreach ((string Property, object? Value) info in data)
{
- builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
+ _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
}
}
Trace.Write(builder);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
index d5c0a92e..34313347 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
#nullable enable
@@ -22,4 +22,4 @@ public interface IAnalyticsService
/// The exception that has been thrown.
/// The optional event properties.
void Log(Exception exception, params (string Property, object? Value)[]? data);
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
index 09804b6b..43e65539 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
@@ -39,4 +39,4 @@ public sealed class ContouredLayersRunner : IShaderRunner
return true;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
index e4e2cbae..ebcd4a34 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using CommunityToolkit.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -170,4 +170,4 @@ public sealed partial class MainViewModel : ObservableObject
{
IsRenderingPaused = !IsRenderingPaused;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/ShaderRunnerViewModel.cs b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/ShaderRunnerViewModel.cs
index c8cafd7c..7931cbd8 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/ShaderRunnerViewModel.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/ShaderRunnerViewModel.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using CommunityToolkit.Mvvm.ComponentModel;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
index 13437cbd..932b1ffc 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader creating an abstract and colorful animation.
@@ -15,7 +15,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
/// The total number of layers for the final animation.
@@ -32,7 +32,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader
///
private float4 Tex(float3 p)
{
- float t = time + 78.0f;
+ float t = this.time + 78.0f;
float4 o = new(p.X, p.Y, p.Z, 3.0f * Hlsl.Sin(t * 0.1f));
float4 dec =
new float4(1.0f, 0.9f, 0.1f, 0.15f) +
@@ -40,7 +40,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader
for (int i = 0; i++ < NumberOfIterations;)
{
- o.XZYW = Hlsl.Abs(o / Hlsl.Dot(o, o) - dec);
+ o.XZYW = Hlsl.Abs((o / Hlsl.Dot(o, o)) - dec);
}
return o;
@@ -49,9 +49,9 @@ internal readonly partial struct ColorfulInfinity : IPixelShader
///
public float4 Execute()
{
- float2 uv = (ThreadIds.XY - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
+ float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float3 col = 0;
- float t = time * 0.3f;
+ float t = this.time * 0.3f;
for (float i = 0.0f; i <= 1.0f; i += 1.0f / NumberOfLayers)
{
@@ -68,4 +68,4 @@ internal readonly partial struct ColorfulInfinity : IPixelShader
return new(col.X, col.Y, col.Z, 1.0f);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
index 91b0b04d..04b6f7ab 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// Constructing some concise contoured layers, then applying various edge and shading effects to produce some faux depth.
@@ -14,12 +14,12 @@ internal readonly partial struct ContouredLayers : IPixelShader
///
/// The current time Hlsl.Since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
/// The background texture to sample.
///
- public readonly IReadOnlyNormalizedTexture2D texture;
+ private readonly IReadOnlyNormalizedTexture2D texture;
// float3 to float hash.
private static float Hash21(float2 p)
@@ -34,7 +34,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
p = Hlsl.Frac(new float2(262144, 32768) * n);
- return Hlsl.Sin(p * 6.2831853f + time);
+ return Hlsl.Sin((p * 6.2831853f) + this.time);
}
// float2 to float2 hash.
@@ -42,7 +42,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
{
float n = Hlsl.Sin(Hlsl.Dot(p, new float2(41, 289)));
- return Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f - 1.0f;
+ return (Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f) - 1.0f;
}
// Smooth 2D noise
@@ -59,7 +59,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
v.Z = Hlsl.Dot(Hash22B(i + float2.UnitY), p - float2.UnitY);
v.W = Hlsl.Dot(Hash22B(i + 1.0f), p - 1.0f);
- p = p * p * (3.0f - 2.0f * p);
+ p = p * p * (3.0f - (2.0f * p));
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
}
@@ -68,7 +68,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
private float Noise2D3G(float2 p)
{
float2 i = Hlsl.Floor(p);
-
+
p -= i;
float4 v = default;
@@ -78,7 +78,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
v.Z = Hlsl.Dot(Hash22(i + float2.UnitY), p - float2.UnitY);
v.W = Hlsl.Dot(Hash22(i + 1.0f), p - 1.0f);
- p = p * p * p * (p * (p * 6.0f - 15.0f) + 10.0f);
+ p = p * p * p * ((p * ((p * 6.0f) - 15.0f)) + 10.0f);
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
}
@@ -86,7 +86,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
// Map function with noise layers
private float MapNoise(float3 p, float i)
{
- return Noise2D3G(p.XY * 3.0f) * 0.66f + Noise2D3G(p.XY * 6.0f) * 0.34f + i / 10.0f * 1.0f - 0.15f;
+ return (Noise2D3G(p.XY * 3.0f) * 0.66f) + (Noise2D3G(p.XY * 6.0f) * 0.34f) + (i / 10.0f * 1.0f) - 0.15f;
}
// 2D derivative function.
@@ -111,13 +111,13 @@ internal readonly partial struct ContouredLayers : IPixelShader
// Layer color. Based on the shade, layer number and smoothing factor.
private float3 GetColor(float2 p, float sh, float fi)
{
- float3 tx = texture.Sample(p + Hash21(new float2(sh, fi))).XYZ;
-
+ float3 tx = this.texture.Sample(p + Hash21(new float2(sh, fi))).XYZ;
+
tx *= tx;
float3 col;
- col = (float3)1.0 * (1.0f - 0.75f / (1.0f + sh * sh * 2.0f));
+ col = (float3)1.0 * (1.0f - (0.75f / (1.0f + (sh * sh * 2.0f))));
col = Hlsl.Min(col * tx * 3.0f, 1.0f);
return col;
@@ -128,12 +128,15 @@ internal readonly partial struct ContouredLayers : IPixelShader
{
p *= res / 16.0f;
- float hatch = Hlsl.Clamp(Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f + 0.5f, 0.0f, 1.0f);
+ float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f);
float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f);
- if (hRnd > 0.66f) hatch = hRnd;
+ if (hRnd > 0.66f)
+ {
+ hatch = hRnd;
+ }
- hatch = hatch * 0.75f + 0.5f;
+ hatch = (hatch * 0.75f) + 0.5f;
return hatch;
}
@@ -143,7 +146,7 @@ internal readonly partial struct ContouredLayers : IPixelShader
{
float2 fragCoord = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
float res = Hlsl.Min(DispatchSize.Y, 700.0f);
- float2 uv = (fragCoord - (float2)DispatchSize.XY * 0.5f) / res;
+ float2 uv = (fragCoord - ((float2)DispatchSize.XY * 0.5f)) / res;
float sf = 1.0f / DispatchSize.Y;
float3 col = GetColor(uv, 0.0f, 0.0f);
float pL = 0.0f;
@@ -161,8 +164,8 @@ internal readonly partial struct ContouredLayers : IPixelShader
hatch = Hatch(uv + Hlsl.Sin(new float2(41.0f, 289.0f) * (fi + 1.0f)), res);
float4 c = MapLayer(new float3(uv, 1.0f), fi);
- float4 cSh = MapLayer(new float3(uv - new float2(0.03f, -0.03f) * ((flNum - fi) / flNum * 0.5f + 0.5f), 1.0f), fi);
- float sh = (fi + 1.0f) / (flNum);
+ float4 cSh = MapLayer(new float3(uv - (new float2(0.03f, -0.03f) * (((flNum - fi) / flNum * 0.5f) + 0.5f)), 1.0f), fi);
+ float sh = (fi + 1.0f) / flNum;
float3 lCol = GetColor(uv, sh, fi + 1.0f);
float3 ld = Hlsl.Normalize(new float3(-1, 1, -0.25f));
float3 n = Hlsl.Normalize(new float3(0.0f, 0.0f, -1.0f) + c.YZW);
@@ -178,17 +181,17 @@ internal readonly partial struct ContouredLayers : IPixelShader
col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfLSh, Hlsl.Max(cSh.X, pL))) * shF);
col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL * 3.0f, c.X)) * 0.25f);
col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X)) * 0.85f);
- col = Hlsl.Lerp(col, eCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + Hlsl.Length(c.YZX) * 0.003f)));
- col = Hlsl.Lerp(col, lCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + Hlsl.Length(c.YZX) * 0.006f)));
+ col = Hlsl.Lerp(col, eCol * hatch, 1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.003f)));
+ col = Hlsl.Lerp(col, lCol * hatch, 1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.006f)));
pL = c.X;
}
col *= Hlsl.Lerp(new float3(1.8f, 1, 0.7f).ZYX, new float3(1.8f, 1, 0.7f).XZY, Noise2D(uv * 2.0f));
- float3 rn3 = Noise2D(uv * DispatchSize.Y / 1.0f + 1.7f) - Noise2D(uv * DispatchSize.Y / 1.0f + 3.4f);
+ float3 rn3 = Noise2D((uv * DispatchSize.Y / 1.0f) + 1.7f) - Noise2D((uv * DispatchSize.Y / 1.0f) + 3.4f);
- col *= 0.93f + 0.07f * rn3.XYZ + 0.07f * Hlsl.Dot(rn3, new float3(0.299f, 0.587f, 0.114f));
+ col *= 0.93f + (0.07f * rn3.XYZ) + (0.07f * Hlsl.Dot(rn3, new float3(0.299f, 0.587f, 0.114f)));
uv = fragCoord / DispatchSize.XY;
@@ -196,4 +199,4 @@ internal readonly partial struct ContouredLayers : IPixelShader
return new float4(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
index dbaf8d63..888530d8 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A basic extruded square grid-based blobby Truchet pattern.
@@ -14,7 +14,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
/// Curve shape - Round: 0, Semi-round: 1, Octagonal: 2, Superellipse: 3, Straight: 4.
@@ -48,11 +48,14 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
{
return Hlsl.Length(p);
}
- else p = Hlsl.Abs(p);
+ else
+ {
+ p = Hlsl.Abs(p);
+ }
switch (SHAPE)
{
- case 1: return Hlsl.Max(Hlsl.Length(p), (p.X + p.Y) * 0.7071f + 0.015f);
+ case 1: return Hlsl.Max(Hlsl.Length(p), ((p.X + p.Y) * 0.7071f) + 0.015f);
case 2: return Hlsl.Max((p.X + p.Y) * 0.7071f, Hlsl.Max(p.X, p.Y));
case 3: return Hlsl.Pow(Hlsl.Dot(Hlsl.Pow(p, 3), 1), 1.0f / 3.0f);
default: return (p.X + p.Y) * 0.7071f;
@@ -62,7 +65,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
// GLSL's mod function
private static float Mod(float x, float y)
{
- return x - y * Hlsl.Floor(x / y);
+ return x - (y * Hlsl.Floor(x / y));
}
// A standard square grid 2D blobby Truchet routine: Render circles
@@ -77,17 +80,27 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
float rnd = Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(ip, new float2(1, 113))) * 45758.5453f);
- if (rnd < 0.5f) p.Y = -p.Y;
+ if (rnd < 0.5f)
+ {
+ p.Y = -p.Y;
+ }
- float d = Hlsl.Min(Distance(p - 0.5f * sc), Distance(p + 0.5f * sc)) - 0.5f * sc;
+ float d = Hlsl.Min(Distance(p - (0.5f * sc)), Distance(p + (0.5f * sc))) - (0.5f * sc);
if (SHAPE == 4)
{
- d += (0.5f - 0.5f / Hlsl.Sqrt(2.0f)) * sc;
+ d += (0.5f - (0.5f / Hlsl.Sqrt(2.0f))) * sc;
}
- if (rnd < 0.5f) d = -d;
- if (Mod(ip.X + ip.Y, 2.0f) < 0.5f) d = -d;
+ if (rnd < 0.5f)
+ {
+ d = -d;
+ }
+
+ if (Mod(ip.X + ip.Y, 2.0f) < 0.5f)
+ {
+ d = -d;
+ }
return d - 0.03f;
}
@@ -100,18 +113,18 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
float fl = -p.Z;
float obj = Truchet(p.XY);
- obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f;
+ obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - (Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f);
float studs = 1e5f;
const float sc = 0.5f;
- float2 q = p.XY + 0.5f * sc;
+ float2 q = p.XY + (0.5f * sc);
float2 iq = Hlsl.Floor(q / sc) + 0.5f;
q -= iq * sc;
if (Mod(iq.X + iq.Y, 2.0f) > 0.5f)
{
- studs = Hlsl.Max(Hlsl.Length(q) - 0.1f * sc - 0.02f, Hlsl.Abs(p.Z) - 0.26f);
+ studs = Hlsl.Max(Hlsl.Length(q) - (0.1f * sc) - 0.02f, Hlsl.Abs(p.Z) - 0.26f);
}
objID = fl < obj && fl < studs ? 0 : obj < studs ? 1 : 2;
@@ -136,18 +149,20 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
for (int i = 0; i < iter; i++)
{
- float d = M(ro + rd * t);
+ float d = M(ro + (rd * t));
shade = Hlsl.Min(shade, k * d / t);
t += Hlsl.Clamp(d, 0.01f, 0.25f);
- if (d < 0.0f || t > end) break;
+ if (d < 0.0f || t > end)
+ {
+ break;
+ }
}
return Hlsl.Max(shade, 0.0f);
}
-
// I keep a collection of occlusion routines... OK, that sounded really nerdy. :)
// Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original.
private float CalculateAO(in float3 p, in float3 n)
@@ -155,15 +170,18 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
float sca = 2.0f;
float occ = 0.0f;
- for (int i = (int)Hlsl.Min(time, 0f); i < 5; i++)
+ for (int i = (int)Hlsl.Min(this.time, 0f); i < 5; i++)
{
float hr = (i + 1f) * 0.15f / 5.0f;
- float d = M(p + n * hr);
+ float d = M(p + (n * hr));
occ += (hr - d) * sca;
sca *= 0.7f;
- if (sca > 1e5f) break;
+ if (sca > 1e5f)
+ {
+ break;
+ }
}
return Hlsl.Clamp(1.0f - occ, 0.0f, 1.0f);
@@ -184,31 +202,34 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
public float4 Execute()
{
int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
- float2 u = (coords - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
+ float2 u = (coords - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float3 r = Hlsl.Normalize(new float3(u, 1));
- float3 o = new(0, time / 2.0f, -3);
+ float3 o = new(0, this.time / 2.0f, -3);
float3 l = o + new float3(0.25f, 0.25f, 2.0f);
r.YZ = Hlsl.Mul(Rotate2x2(0.15f), r.YZ);
- r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(time * 3.14159f / 32.0f) / 8.0f), r.XZ);
- r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(time * 3.14159f / 32.0f) / 8.0f), r.XY);
+ r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(this.time * 3.14159f / 32.0f) / 8.0f), r.XZ);
+ r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(this.time * 3.14159f / 32.0f) / 8.0f), r.XY);
float d;
- float t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f;
+ float t = Hash21((r.XY * 57.0f) + Hlsl.Frac(this.time)) * 0.5f;
float glow = 0;
for (int i = 0; i < 96; i++)
{
- d = M(o + r * t);
+ d = M(o + (r * t));
- if (Hlsl.Abs(d) < 0.001f) break;
+ if (Hlsl.Abs(d) < 0.001f)
+ {
+ break;
+ }
t += d * 0.7f;
- glow += 0.2f / (1.0f + Hlsl.Abs(d) * 5.0f);
+ glow += 0.2f / (1.0f + (Hlsl.Abs(d) * 5.0f));
}
int gObjID = objID;
- float3 p = o + r * t;
+ float3 p = o + (r * t);
float3 n = Normal(p);
float2 uv = p.XY;
float sc = 0.5f;
@@ -216,21 +237,21 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
uv -= iuv * sc;
- float2 uv2 = p.XY + 0.5f * sc;
+ float2 uv2 = p.XY + (0.5f * sc);
float2 iuv2 = Hlsl.Floor(uv2 / sc) + 0.5f;
uv2 -= iuv2 * sc;
- float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - 0.5f * sc;
+ float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - (0.5f * sc);
bord = Hlsl.Abs(bord) - 0.002f;
d = Truchet(p.XY);
float lSc = 20.0f;
- float pat = (Hlsl.Abs(Hlsl.Frac((uv.X - uv.Y) * lSc - 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc;
- float pat2 = (Hlsl.Abs(Hlsl.Frac((uv.X + uv.Y) * lSc + 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc;
+ float pat = ((Hlsl.Abs(Hlsl.Frac(((uv.X - uv.Y) * lSc) - 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc;
+ float pat2 = ((Hlsl.Abs(Hlsl.Frac(((uv.X + uv.Y) * lSc) + 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc;
float sf = Hlsl.Dot(Hlsl.Sin(p.XY - Hlsl.Cos(p.YX * 2.0f)), 0.5f);
- float sf2 = Hlsl.Dot(Hlsl.Sin(p.XY * 1.5f - Hlsl.Cos(p.YX * 3.0f)), 0.5f);
+ float sf2 = Hlsl.Dot(Hlsl.Sin((p.XY * 1.5f) - Hlsl.Cos(p.YX * 3.0f)), 0.5f);
float4 col1 = Hlsl.Lerp(new float4(1, 0.75f, 0.6f, 0), new float4(1, 0.85f, 0.65f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf));
float4 col2 = Hlsl.Lerp(new float4(0.4f, 0.7f, 1, 0), new float4(0.3f, 0.85f, 0.95f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf2) * 0.5f);
@@ -244,7 +265,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
oCol = Hlsl.Lerp(col2, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, pat2)) * 0.35f);
oCol = Hlsl.Lerp(oCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, bord)) * 0.8f);
- if (Mod(iuv.X + iuv.Y, 2.0f) > 0.5f) oCol *= 0.8f;
+ if (Mod(iuv.X + iuv.Y, 2.0f) > 0.5f)
+ {
+ oCol *= 0.8f;
+ }
oCol = Hlsl.Lerp(oCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, d - 0.015f)) * 0.8f);
}
@@ -254,7 +278,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
float4 fCol = Hlsl.Lerp(col1, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, pat)) * 0.35f);
fCol = Hlsl.Lerp(fCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, bord)) * 0.8f);
- if (Mod(iuv.X + iuv.Y, 2.0f) < 0.5f) fCol *= 0.8f;
+ if (Mod(iuv.X + iuv.Y, 2.0f) < 0.5f)
+ {
+ fCol *= 0.8f;
+ }
oCol = Hlsl.Lerp(oCol, fCol, 1 - Hlsl.SmoothStep(0, 0.01f, d + 0.08f));
oCol = Hlsl.Lerp(oCol, 0, (1 - Hlsl.SmoothStep(0, 0.01f, Hlsl.Length(uv2) - 0.08f)) * 0.8f);
@@ -283,16 +310,16 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader
ld /= lDist;
- float at = 1.0f / (1.0f + lDist * lDist * 0.125f);
+ float at = 1.0f / (1.0f + (lDist * lDist * 0.125f));
float sh = SoftShadow(p, l, n, 8);
float ao = CalculateAO(p, n);
float df = Hlsl.Max(Hlsl.Dot(n, ld), 0);
float sp = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(r, n), ld), 0), 32);
- float4 c = oCol * (df * sh + sp * sh + 0.5f) * at * ao;
+ float4 c = oCol * ((df * sh) + (sp * sh) + 0.5f) * at * ao;
c = Hlsl.Sqrt(Hlsl.Max(c, 0));
return c;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
index 7fa9a2ef..dc14ebe5 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader which interpolates four different colors into a rotating gradient pattern.
@@ -15,13 +15,13 @@ internal readonly partial struct FourColorGradient : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
// Colors to blend together
- private static readonly float3 colorOne = new(0.999f, 0.999f, 0.999f);
- private static readonly float3 colorTwo = new(0.999f, 0f, 0f);
- private static readonly float3 colorThree = new(0f, 0.999f, 0f);
- private static readonly float3 colorFour = new(0f, 0f, 0.999f);
+ private static readonly float3 ColorOne = new(0.999f, 0.999f, 0.999f);
+ private static readonly float3 ColorTwo = new(0.999f, 0f, 0f);
+ private static readonly float3 ColorThree = new(0f, 0.999f, 0f);
+ private static readonly float3 ColorFour = new(0f, 0f, 0.999f);
///
/// Standard 2D rotation formula.
@@ -55,24 +55,23 @@ internal readonly partial struct FourColorGradient : IPixelShader
{
float2 i = Hlsl.Floor(p);
float2 f = Hlsl.Frac(p);
- float2 u = f * f * (3.0f - 2.0f * f);
+ float2 u = f * f * (3.0f - (2.0f * f));
// Mix -> Lerp
float n = Hlsl.Lerp(
Hlsl.Lerp(
- Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(0.0f, 0.0f)), f - new float2(0.0f, 0.0f)),
- Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(1.0f, 0.0f)), f - new float2(1.0f, 0.0f)),
+ Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(0.0f, 0.0f))), f - new float2(0.0f, 0.0f)),
+ Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(1.0f, 0.0f))), f - new float2(1.0f, 0.0f)),
u.X),
Hlsl.Lerp(
- Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(0.0f, 1.0f)), f - new float2(0.0f, 1.0f)),
- Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(1.0f, 1.0f)), f - new float2(1.0f, 1.0f)),
- u.X),
+ Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(0.0f, 1.0f))), f - new float2(0.0f, 1.0f)),
+ Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(1.0f, 1.0f))), f - new float2(1.0f, 1.0f)),
+ u.X),
u.Y);
- return 0.5f + 0.5f * n;
+ return 0.5f + (0.5f * n);
}
-
///
public float4 Execute()
{
@@ -84,25 +83,25 @@ internal readonly partial struct FourColorGradient : IPixelShader
tuv -= 0.5f;
// Rotate with noise
- float degree = Noise(new float2(time * 0.1f, tuv.X * tuv.Y));
+ float degree = Noise(new float2(this.time * 0.1f, tuv.X * tuv.Y));
tuv.Y *= 1.0f / ratio;
- tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians((degree - 0.5f) * 720.0f + 180.0f)));
+ tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(((degree - 0.5f) * 720.0f) + 180.0f)));
tuv.Y *= ratio;
// Wave warp with sin
float frequency = 5.0f;
float amplitude = 30.0f;
- float speed = time * 2.0f;
+ float speed = this.time * 2.0f;
- tuv.X += Hlsl.Sin(tuv.Y * frequency + speed) / amplitude;
- tuv.Y += Hlsl.Sin(tuv.X * frequency * 1.5f + speed) / (amplitude * 0.5f);
+ tuv.X += Hlsl.Sin((tuv.Y * frequency) + speed) / amplitude;
+ tuv.Y += Hlsl.Sin((tuv.X * frequency * 1.5f) + speed) / (amplitude * 0.5f);
// Draw the image
- float3 layer1 = Hlsl.Lerp(colorOne, colorTwo, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X));
- float3 layer2 = Hlsl.Lerp(colorThree, colorFour, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X));
+ float3 layer1 = Hlsl.Lerp(ColorOne, ColorTwo, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X));
+ float3 layer2 = Hlsl.Lerp(ColorThree, ColorFour, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X));
float3 col = Hlsl.Lerp(layer1, layer2, Hlsl.SmoothStep(0.5f, -0.3f, tuv.Y));
return new(col, 1.0f);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
index 06cf1d1e..5b7b8d56 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader creating a fractal tiling animation.
@@ -15,12 +15,12 @@ internal readonly partial struct FractalTiling : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
public float4 Execute()
{
- float2 position = ((float2)(256 * ThreadIds.XY)) / DispatchSize.X + time;
+ float2 position = (((float2)(256 * ThreadIds.XY)) / DispatchSize.X) + this.time;
float4 color = 0;
for (int i = 0; i < 6; i++)
@@ -28,7 +28,7 @@ internal readonly partial struct FractalTiling : IPixelShader
float2 a = Hlsl.Floor(position);
float2 b = Hlsl.Frac(position);
float4 w = Hlsl.Frac(
- (Hlsl.Sin(a.X * 7 + 31.0f * a.Y + 0.01f * time) +
+ (Hlsl.Sin((a.X * 7) + (31.0f * a.Y) + (0.01f * this.time)) +
new float4(0.035f, 0.01f, 0, 0.7f))
* 13.545317f);
@@ -45,4 +45,4 @@ internal readonly partial struct FractalTiling : IPixelShader
return color;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
index 793c234a..1fa112b7 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A simple shader to get started with based on shadertoy new shader template.
@@ -13,7 +13,7 @@ internal readonly partial struct HelloWorld : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
public float4 Execute()
@@ -22,9 +22,9 @@ internal readonly partial struct HelloWorld : IPixelShader
float2 uv = ThreadIds.Normalized.XY;
// Time varying pixel color
- float3 col = 0.5f + 0.5f * Hlsl.Cos(time + new float3(uv, uv.X) + new float3(0, 2, 4));
+ float3 col = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4)));
// Output to screen
return new(col, 1f);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
index 37f655d6..58eab595 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader creating a flythrough in a Menger system.
@@ -14,7 +14,7 @@ internal readonly partial struct MengerJourney : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
private const int MaxSteps = 30;
private const float MinimumDistance = 0.0009f;
@@ -39,7 +39,7 @@ internal readonly partial struct MengerJourney : IPixelShader
///
private static float2 Rotate(float2 v, float a)
{
- return new(Hlsl.Cos(a) * v.X + Hlsl.Sin(a) * v.Y, -Hlsl.Sin(a) * v.X + Hlsl.Cos(a) * v.Y);
+ return new((Hlsl.Cos(a) * v.X) + (Hlsl.Sin(a) * v.Y), (-Hlsl.Sin(a) * v.X) + (Hlsl.Cos(a) * v.Y));
}
///
@@ -55,8 +55,8 @@ internal readonly partial struct MengerJourney : IPixelShader
float diffuse2 = Hlsl.Max(0.0f, Hlsl.Dot(-normal, lightDir2));
return
- (diffuse * Diffuse) * (LightColor * color) +
- (diffuse2 * Diffuse) * (LightColor2 * color);
+ (diffuse * Diffuse * (LightColor * color)) +
+ (diffuse2 * Diffuse * (LightColor2 * color));
}
///
@@ -68,7 +68,7 @@ internal readonly partial struct MengerJourney : IPixelShader
// Performs the GLSL mod function.
static float3 Mod(float3 x, float y)
{
- return x - y * Hlsl.Floor(x / y);
+ return x - (y * Hlsl.Floor(x / y));
}
z = Hlsl.Abs(1.0f - Mod(z, 2.0f));
@@ -77,14 +77,16 @@ internal readonly partial struct MengerJourney : IPixelShader
for (int n = 0; n < Iterations; n++)
{
- z.XY = Rotate(z.XY, 4.0f + 2.0f * Hlsl.Cos(time / 8.0f));
+ z.XY = Rotate(z.XY, 4.0f + (2.0f * Hlsl.Cos(this.time / 8.0f)));
z = Hlsl.Abs(z);
if (z.X < z.Y) { z.XY = z.YX; }
+
if (z.X < z.Z) { z.XZ = z.ZX; }
+
if (z.Y < z.Z) { z.YZ = z.ZY; }
- z = Scale * z - Offset * (Scale - 1.0f);
+ z = (Scale * z) - (Offset * (Scale - 1.0f));
if (z.Z < -0.5f * Offset.Z * (Scale - 1.0))
{
@@ -100,7 +102,7 @@ internal readonly partial struct MengerJourney : IPixelShader
///
/// Calculates the finite difference normal at a given position.
///
- private float3 getNormal(in float3 pos)
+ private float3 GetNormal(in float3 pos)
{
float3 e = new(0.0f, NormalDistance, 0.0f);
@@ -121,7 +123,7 @@ internal readonly partial struct MengerJourney : IPixelShader
return Hlsl.Frac(Hlsl.Cos(Hlsl.Dot(co, new float2(4.898f, 7.23f))) * 23421.631f);
}
- float totalDistance = Jitter * Rand(fragCoord.XY + time);
+ float totalDistance = Jitter * Rand(fragCoord.XY + this.time);
float3 dir2 = dir;
float distance = 0;
int steps = 0;
@@ -129,23 +131,26 @@ internal readonly partial struct MengerJourney : IPixelShader
for (int i = 0; i < MaxSteps; i++)
{
- dir.ZY = Rotate(dir2.ZY, totalDistance * Hlsl.Cos(time / 4.0f) * NonLinearPerspective);
- pos = from + totalDistance * dir;
+ dir.ZY = Rotate(dir2.ZY, totalDistance * Hlsl.Cos(this.time / 4.0f) * NonLinearPerspective);
+ pos = from + (totalDistance * dir);
distance = DE(pos) * FudgeFactor;
totalDistance += distance;
- if (distance < MinimumDistance) break;
+ if (distance < MinimumDistance)
+ {
+ break;
+ }
steps = i;
}
- float smoothStep = steps + distance / MinimumDistance;
- float ao = 1.1f - smoothStep / MaxSteps;
- float3 normal = getNormal(pos - dir * NormalDistance * 3.0f);
+ float smoothStep = steps + (distance / MinimumDistance);
+ float ao = 1.1f - (smoothStep / MaxSteps);
+ float3 normal = GetNormal(pos - (dir * NormalDistance * 3.0f));
float3 color = 1.0f;
float3 light = GetLight(color, normal);
- color = (color * Ambient + light) * ao;
+ color = ((color * Ambient) + light) * ao;
return new(color.X, color.Y, color.Z, 1.0f);
}
@@ -153,20 +158,20 @@ internal readonly partial struct MengerJourney : IPixelShader
///
public float4 Execute()
{
- float3 camPos = 0.5f * time * new float3(1.0f, 0.0f, 0.0f);
- float3 target = camPos + new float3(1.0f, 0.0f * Hlsl.Cos(time), 0.0f * Hlsl.Sin(0.4f * time));
+ float3 camPos = 0.5f * this.time * new float3(1.0f, 0.0f, 0.0f);
+ float3 target = camPos + new float3(1.0f, 0.0f * Hlsl.Cos(this.time), 0.0f * Hlsl.Sin(0.4f * this.time));
float3 camDir = Hlsl.Normalize(target - camPos);
float3 camUp = new(0.0f, 1.0f, 0.0f);
- camUp = Hlsl.Normalize(camUp - Hlsl.Dot(camDir, camUp) * camDir);
+ camUp = Hlsl.Normalize(camUp - (Hlsl.Dot(camDir, camUp) * camDir));
float3 camRight = Hlsl.Normalize(Hlsl.Cross(camDir, camUp));
- float2 coord = -1.0f + 2.0f * (float2)ThreadIds.XY / DispatchSize.XY;
+ float2 coord = -1.0f + (2.0f * (float2)ThreadIds.XY / DispatchSize.XY);
coord.X *= (float)DispatchSize.X / DispatchSize.Y;
- float3 rayDir = Hlsl.Normalize(camDir + (coord.X * camRight + coord.Y * camUp) * FieldOfView);
+ float3 rayDir = Hlsl.Normalize(camDir + (((coord.X * camRight) + (coord.Y * camUp)) * FieldOfView));
return RayMarch(camPos, rayDir, ThreadIds.XY);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
index cf09264b..f10aa0c3 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader creating an octagram animation, inspired by arabesque.
@@ -14,7 +14,7 @@ internal readonly partial struct Octagrams : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
private static float2x2 Rotate(float a)
{
@@ -53,25 +53,25 @@ internal readonly partial struct Octagrams : IPixelShader
pos.Y += Hlsl.Sin(gTime * 0.4f) * 2.5f;
pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f));
- float box1 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f);
+ float box1 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f));
pos = pos_origin;
pos.Y -= Hlsl.Sin(gTime * 0.4f) * 2.5f;
pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f));
- float box2 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f);
+ float box2 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f));
pos = pos_origin;
pos.X += Hlsl.Sin(gTime * 0.4f) * 2.5f;
pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f));
- float box3 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f);
+ float box3 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f));
pos = pos_origin;
pos.X -= Hlsl.Sin(gTime * 0.4f) * 2.5f;
pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f));
- float box4 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f);
+ float box4 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f));
pos = pos_origin;
pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f));
@@ -89,12 +89,12 @@ internal readonly partial struct Octagrams : IPixelShader
///
public float4 Execute()
{
- float2 p = ((float2)ThreadIds.XY * 2.0f - DispatchSize.XY) / Hlsl.Min(DispatchSize.X, DispatchSize.Y);
- float3 ro = new(0.0f, -0.2f, time * 4.0f);
+ float2 p = (((float2)ThreadIds.XY * 2.0f) - DispatchSize.XY) / Hlsl.Min(DispatchSize.X, DispatchSize.Y);
+ float3 ro = new(0.0f, -0.2f, this.time * 4.0f);
float3 ray = Hlsl.Normalize(new float3(p, 1.5f));
- ray.XY = Hlsl.Mul(ray.XY, Rotate(Hlsl.Sin(time * 0.03f) * 5.0f));
- ray.YZ = Hlsl.Mul(ray.YZ, Rotate(Hlsl.Sin(time * 0.05f) * 0.2f));
+ ray.XY = Hlsl.Mul(ray.XY, Rotate(Hlsl.Sin(this.time * 0.03f) * 5.0f));
+ ray.YZ = Hlsl.Mul(ray.YZ, Rotate(Hlsl.Sin(this.time * 0.05f) * 0.2f));
float t = 0.1f;
float ac = 0.0f;
@@ -103,14 +103,14 @@ internal readonly partial struct Octagrams : IPixelShader
{
static float3 Mod(float3 x, float y)
{
- return x - y * Hlsl.Floor(x / y);
+ return x - (y * Hlsl.Floor(x / y));
}
- float3 pos = ro + ray * t;
+ float3 pos = ro + (ray * t);
pos = Mod(pos - 2.0f, 4.0f) - 2.0f;
- float gTime = time - i * 0.01f;
+ float gTime = this.time - (i * 0.01f);
float d = BoxSet(pos, gTime);
d = Hlsl.Max(Hlsl.Abs(d), 0.01f);
@@ -118,9 +118,9 @@ internal readonly partial struct Octagrams : IPixelShader
t += d * 0.55f;
}
- float3 col = ac * 0.02f + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(time)), 0.5f + Hlsl.Sin(time) * 0.2f);
- float4 color = new(col, 1.0f - t * (0.02f + 0.02f * Hlsl.Sin(time)));
+ float3 col = (ac * 0.02f) + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(this.time)), 0.5f + (Hlsl.Sin(this.time) * 0.2f));
+ float4 color = new(col, 1.0f - (t * (0.02f + (0.02f * Hlsl.Sin(this.time)))));
return color;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
index 550ef977..33b358bc 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// Fully procedural 3D animated volume with three evaluations per step (for shading).
@@ -15,15 +15,15 @@ internal readonly partial struct ProteanClouds : IPixelShader
///
/// The current time Hlsl.Since the start of the application.
///
- public readonly float time;
+ private readonly float time;
- private static readonly float3x3 m3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f;
+ private static readonly float3x3 M3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f;
private static float2x2 Rotate(in float a)
{
float c = Hlsl.Cos(a);
float s = Hlsl.Sin(a);
-
+
return new(c, s, -s, c);
}
@@ -42,7 +42,7 @@ internal readonly partial struct ProteanClouds : IPixelShader
float3 p2 = p;
p2.XY -= Disp(p.Z).XY;
- p.XY = Hlsl.Mul(p.XY, Rotate(Hlsl.Sin(p.Z + time) * (0.1f + prm1 * 0.05f) + time * 0.09f));
+ p.XY = Hlsl.Mul(p.XY, Rotate((Hlsl.Sin(p.Z + this.time) * (0.1f + (prm1 * 0.05f))) + (this.time * 0.09f)));
float cl = Hlsl.Dot(p2.XY, p2.XY);
float d = 0.0f;
@@ -51,21 +51,21 @@ internal readonly partial struct ProteanClouds : IPixelShader
float z = 1.0f;
float trk = 1.0f;
- float dspAmp = 0.1f + prm1 * 0.2f;
+ float dspAmp = 0.1f + (prm1 * 0.2f);
for (int i = 0; i < 5; i++)
{
- p += Hlsl.Sin(p.ZXY * 0.75f * trk + time * trk * 0.8f) * dspAmp;
+ p += Hlsl.Sin((p.ZXY * 0.75f * trk) + (this.time * trk * 0.8f)) * dspAmp;
d -= Hlsl.Abs(Hlsl.Dot(Hlsl.Cos(p), Hlsl.Sin(p.YZX)) * z);
z *= 0.57f;
trk *= 1.4f;
- p = Hlsl.Mul(p, m3);
+ p = Hlsl.Mul(p, M3);
}
- d = Hlsl.Abs(d + prm1 * 3.0f) + prm1 * 0.3f - 2.5f + bsMo.Y;
+ d = Hlsl.Abs(d + (prm1 * 3.0f)) + (prm1 * 0.3f) - 2.5f + bsMo.Y;
- return new float2(d + cl * 0.2f + 0.25f, cl);
+ return new float2(d + (cl * 0.2f) + 0.25f, cl);
}
private float4 Render(float3 ro, float3 rd, float time, float prm1, float2 bsMo)
@@ -76,33 +76,36 @@ internal readonly partial struct ProteanClouds : IPixelShader
for (int i = 0; i < 130; i++)
{
- if (rez.A > 0.99f) break;
+ if (rez.A > 0.99f)
+ {
+ break;
+ }
- float3 pos = ro + t * rd;
+ float3 pos = ro + (t * rd);
float2 mpv = Map(pos, prm1, bsMo);
float den = Hlsl.Clamp(mpv.X - 0.3f, 0.0f, 1.0f) * 1.12f;
- float dn = Hlsl.Clamp((mpv.X + 2.0f), 0.0f, 3.0f);
+ float dn = Hlsl.Clamp(mpv.X + 2.0f, 0.0f, 3.0f);
float4 col = 0f;
if (mpv.X > 0.6f)
{
- col = new float4(Hlsl.Sin(new float3(5.0f, 0.4f, 0.2f) + mpv.Y * 0.1f + Hlsl.Sin(pos.Z * 0.4f) * 0.5f + 1.8f) * 0.5f + 0.5f, 0.08f);
+ col = new float4((Hlsl.Sin(new float3(5.0f, 0.4f, 0.2f) + (mpv.Y * 0.1f) + (Hlsl.Sin(pos.Z * 0.4f) * 0.5f) + 1.8f) * 0.5f) + 0.5f, 0.08f);
col *= den * den * den;
col.RGB *= LinStep(4.0f, -2.5f, mpv.X) * 2.3f;
float dif = Hlsl.Clamp((den - Map(pos + 0.8f, prm1, bsMo).X) / 9.0f, 0.001f, 1.0f);
dif += Hlsl.Clamp((den - Map(pos + 0.35f, prm1, bsMo).X) / 2.5f, 0.001f, 1.0f);
- col.XYZ *= den * (new float3(0.005f, 0.045f, 0.075f) + 1.5f * new float3(0.033f, 0.07f, 0.03f) * dif);
+ col.XYZ *= den * (new float3(0.005f, 0.045f, 0.075f) + (1.5f * new float3(0.033f, 0.07f, 0.03f) * dif));
}
- float fogC = Hlsl.Exp(t * 0.2f - 2.2f);
+ float fogC = Hlsl.Exp((t * 0.2f) - 2.2f);
col += new float4(0.06f, 0.11f, 0.11f, 0.1f) * Hlsl.Clamp(fogC - fogT, 0.0f, 1.0f);
fogT = fogC;
rez += col * (1.0f - rez.A);
- t += Hlsl.Clamp(0.5f - dn * dn * 0.05f, 0.09f, 0.3f);
+ t += Hlsl.Clamp(0.5f - (dn * dn * 0.05f), 0.09f, 0.3f);
}
return Hlsl.Clamp(rez, 0.0f, 1.0f);
@@ -120,7 +123,7 @@ internal readonly partial struct ProteanClouds : IPixelShader
{
float3 ic = Hlsl.Lerp(a, b, x) + new float3((float)1e-6, 0.0f, 0.0f);
float sd = Hlsl.Abs(GetSaturation(ic) - Hlsl.Lerp(GetSaturation(a), GetSaturation(b), x));
- float3 dir = Hlsl.Normalize(new float3(2.0f * ic.X - ic.Y - ic.Z, 2.0f * ic.Y - ic.X - ic.Z, 2.0f * ic.Z - ic.Y - ic.X));
+ float3 dir = Hlsl.Normalize(new float3((2.0f * ic.X) - ic.Y - ic.Z, (2.0f * ic.Y) - ic.X - ic.Z, (2.0f * ic.Z) - ic.Y - ic.X));
float lgt = Hlsl.Dot(1.0f, ic);
float ff = Hlsl.Dot(dir, Hlsl.Normalize(ic));
@@ -133,12 +136,12 @@ internal readonly partial struct ProteanClouds : IPixelShader
public float4 Execute()
{
float2 q = (float2)ThreadIds.XY / DispatchSize.XY;
- float2 p = (ThreadIds.XY - 0.5f * (float2)DispatchSize.XY) / DispatchSize.Y;
+ float2 p = (ThreadIds.XY - (0.5f * (float2)DispatchSize.XY)) / DispatchSize.Y;
float2 bsMo = -0.5f * (float2)DispatchSize.XY / DispatchSize.Y;
- float scaledTime = time * 3.0f;
+ float scaledTime = this.time * 3.0f;
float3 ro = new(0, 0, scaledTime);
- ro += new float3(Hlsl.Sin(time) * 0.5f, Hlsl.Sin(time * 1.0f) * 0.0f, 0);
+ ro += new float3(Hlsl.Sin(this.time) * 0.5f, Hlsl.Sin(this.time * 1.0f) * 0.0f, 0);
float dspAmp = 0.85f;
@@ -154,18 +157,18 @@ internal readonly partial struct ProteanClouds : IPixelShader
rightdir = Hlsl.Normalize(Hlsl.Cross(updir, target));
- float3 rd = Hlsl.Normalize((p.X * rightdir + p.Y * updir) * 1.0f - target);
+ float3 rd = Hlsl.Normalize((((p.X * rightdir) + (p.Y * updir)) * 1.0f) - target);
- rd.XY = Hlsl.Mul(rd.XY, Rotate(-Disp(scaledTime + 3.5f).X * 0.2f + bsMo.X));
+ rd.XY = Hlsl.Mul(rd.XY, Rotate((-Disp(scaledTime + 3.5f).X * 0.2f) + bsMo.X));
- float prm1 = Hlsl.SmoothStep(-0.4f, 0.4f, Hlsl.Sin(time * 0.3f));
+ float prm1 = Hlsl.SmoothStep(-0.4f, 0.4f, Hlsl.Sin(this.time * 0.3f));
float4 scn = Render(ro, rd, scaledTime, prm1, bsMo);
float3 col = scn.RGB;
col = ILerp(col.BGR, col.RGB, Hlsl.Clamp(1.0f - prm1, 0.05f, 1.0f));
col = Hlsl.Pow(col, new float3(0.55f, 0.65f, 0.6f)) * new float3(1.0f, 0.97f, 0.9f);
- col *= Hlsl.Pow(16.0f * q.X * q.Y * (1.0f - q.X) * (1.0f - q.Y), 0.12f) * 0.7f + 0.3f;
+ col *= (Hlsl.Pow(16.0f * q.X * q.Y * (1.0f - q.X) * (1.0f - q.Y), 0.12f) * 0.7f) + 0.3f;
return new(col, 1.0f);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
index b441299e..ce8988f3 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// An offset grid of square-based pyramids whose tips have been offset according to an underlying directional noise field.
@@ -15,7 +15,7 @@ internal readonly partial struct PyramidPattern : IPixelShader
///
/// The current time Hlsl.Since the start of the application.
///
- public readonly float time;
+ private readonly float time;
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
@@ -37,14 +37,14 @@ internal readonly partial struct PyramidPattern : IPixelShader
{
float n = Hlsl.Sin(Hlsl.Dot(p, new float2(41, 289)));
- return Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f - 1.0f;
+ return (Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f) - 1.0f;
}
// Based on IQ's gradient noise formula.
private static float N2D3G(float2 p)
{
float2 i = Hlsl.Floor(p);
-
+
p -= i;
float4 v = default;
@@ -54,7 +54,7 @@ internal readonly partial struct PyramidPattern : IPixelShader
v.Z = Hlsl.Dot(Hash22B(i + float2.UnitY), p - float2.UnitY);
v.W = Hlsl.Dot(Hash22B(i + 1.0f), p - 1.0f);
- p = p * p * (3.0f - 2.0f * p);
+ p = p * p * (3.0f - (2.0f * p));
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
}
@@ -62,13 +62,13 @@ internal readonly partial struct PyramidPattern : IPixelShader
// Two layers of noise.
private static float FBM(float2 p)
{
- return N2D3G(p) * 0.66f + N2D3G(p * 2.0f) * 0.34f;
+ return (N2D3G(p) * 0.66f) + (N2D3G(p * 2.0f) * 0.34f);
}
// HLSL mod from GLSL
private static float Mod(float x, float y)
{
- return x - y * Hlsl.Floor(x / y);
+ return x - (y * Hlsl.Floor(x / y));
}
private float BMap(float2 p)
@@ -84,20 +84,31 @@ internal readonly partial struct PyramidPattern : IPixelShader
p -= ip + 0.5f;
- float ang = -3.14159f * 3.0f / 5.0f + (FBM(ip / 8.0f + time / 3.0f)) * 6.2831f * 2.0f;
+ float ang = (-3.14159f * 3.0f / 5.0f) + (FBM((ip / 8.0f) + (this.time / 3.0f)) * 6.2831f * 2.0f);
float2 offs = new float2(Hlsl.Cos(ang), Hlsl.Sin(ang)) * 0.35f;
- if (p.X < offs.X) p.X = 1.0f - (p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f);
- else p.X = (p.X - offs.X) / (0.5f - offs.X);
+ if (p.X < offs.X)
+ {
+ p.X = 1.0f - ((p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f));
+ }
+ else
+ {
+ p.X = (p.X - offs.X) / (0.5f - offs.X);
+ }
- if (p.Y < offs.Y) p.Y = 1.0f - (p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f);
- else p.Y = (p.Y - offs.Y) / (0.5f - offs.Y);
+ if (p.Y < offs.Y)
+ {
+ p.Y = 1.0f - ((p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f));
+ }
+ else
+ {
+ p.Y = (p.Y - offs.Y) / (0.5f - offs.Y);
+ }
return 1.0f - Hlsl.Max(p.X, p.Y);
}
-
// Standard function-based bump mapping function, with an edge value included for good measure
private float3 DoBumpMap(in float2 p, in float3 n, float bumpfactor, ref float edge)
{
@@ -109,26 +120,28 @@ internal readonly partial struct PyramidPattern : IPixelShader
float fx2 = BMap(p + e.XY);
float fy2 = BMap(p + e.YX);
- float3 grad = (new float3(fx - fx2, fy - fx2, 0)) / e.X / 2.0f;
+ float3 grad = new float3(fx - fx2, fy - fx2, 0) / e.X / 2.0f;
- edge = Hlsl.Length(new float2(fx, fy) + new float2(fx2, fy2) - f * 2.0f);
+ edge = Hlsl.Length(new float2(fx, fy) + new float2(fx2, fy2) - (f * 2.0f));
edge = Hlsl.SmoothStep(0.0f, 1.0f, edge / e.X);
grad -= n * Hlsl.Dot(n, grad);
- return Hlsl.Normalize(n + grad * bumpfactor);
+ return Hlsl.Normalize(n + (grad * bumpfactor));
}
-
// A hatch-like algorithm, or a stipple... or some kind of textured pattern
private float DoHatch(float2 p, float res)
{
p *= res / 16.0f;
- float hatch = Hlsl.Clamp(Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f + 0.5f, 0.0f, 1.0f);
+ float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f);
float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f);
- if (hRnd > 0.66f) hatch = hRnd;
+ if (hRnd > 0.66f)
+ {
+ hatch = hRnd;
+ }
return hatch;
}
@@ -138,10 +151,10 @@ internal readonly partial struct PyramidPattern : IPixelShader
{
int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
float iRes = Hlsl.Min(DispatchSize.Y, 800.0f);
- float2 uv = (coordinate - (float2)DispatchSize.XY * 0.5f) / iRes;
+ float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / iRes;
float3 rd = Hlsl.Normalize(new float3(uv, 0.5f));
const float gSc = 10.0f;
- float2 p = uv * gSc + new float2(0, time / 2.0f);
+ float2 p = (uv * gSc) + new float2(0, this.time / 2.0f);
float2 oP = p;
float m = BMap(p);
float3 n = new(0, 0, -1);
@@ -150,7 +163,7 @@ internal readonly partial struct PyramidPattern : IPixelShader
n = DoBumpMap(p, n, bumpFactor, ref edge);
- float3 lp = new float3(-0.0f + Hlsl.Sin(time) * 0.3f, 0.0f + Hlsl.Cos(time * 1.3f) * 0.3f, -1) - new float3(uv, 0);
+ float3 lp = new float3(-0.0f + (Hlsl.Sin(this.time) * 0.3f), 0.0f + (Hlsl.Cos(this.time * 1.3f) * 0.3f), -1) - new float3(uv, 0);
float lDist = Hlsl.Max(Hlsl.Length(lp), 0.001f);
float3 ld = lp / lDist;
float diff = Hlsl.Max(Hlsl.Dot(n, ld), 0.0f);
@@ -159,20 +172,20 @@ internal readonly partial struct PyramidPattern : IPixelShader
float spec = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(-ld, n), -rd), 0.0f), 16.0f);
float fre = Hlsl.Min(Hlsl.Pow(Hlsl.Max(1.0f + Hlsl.Dot(n, rd), 0.0f), 4.0f), 3.0f);
- float3 col = 0.15f * (diff + 0.251f + spec * new float3(1, 0.7f, 0.3f) * 9.0f + fre * new float3(0.1f, 0.3f, 1) * 12.0f);
- float rf = Hlsl.SmoothStep(0.0f, 0.35f, BMap(Hlsl.Reflect(rd, n).XY * 2.0f) * FBM(Hlsl.Reflect(rd, n).XY * 3.0f) + 0.1f);
+ float3 col = 0.15f * (diff + 0.251f + (spec * new float3(1, 0.7f, 0.3f) * 9.0f) + (fre * new float3(0.1f, 0.3f, 1) * 12.0f));
+ float rf = Hlsl.SmoothStep(0.0f, 0.35f, (BMap(Hlsl.Reflect(rd, n).XY * 2.0f) * FBM(Hlsl.Reflect(rd, n).XY * 3.0f)) + 0.1f);
col += col * col * rf * rf * new float3(1, 0.1f, 0.1f) * 15.0f;
- float shade = m * 0.83f + 0.17f;
+ float shade = (m * 0.83f) + 0.17f;
col *= shade;
- col *= 1.0f - edge * 0.8f;
+ col *= 1.0f - (edge * 0.8f);
float hatch = DoHatch(oP / gSc, iRes);
- col *= hatch * 0.5f + 0.7f;
+ col *= (hatch * 0.5f) + 0.7f;
return new(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
index a54daecf..52c87473 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// Utilizing a 2D simplex grid to construct the isolines of a noise function.
@@ -14,7 +14,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
///
/// The current time Hlsl.Since the start of the application.
///
- public readonly float time;
+ private readonly float time;
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
@@ -38,14 +38,14 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
p = Hlsl.Frac(new float2(262144, 32768) * n);
- return Hlsl.Sin(p * 6.2831853f + time);
+ return Hlsl.Sin((p * 6.2831853f) + this.time);
}
// Based on IQ's gradient noise formula.
private float N2D3G(float2 p)
{
float2 i = Hlsl.Floor(p);
-
+
p -= i;
float4 v = default;
@@ -55,16 +55,15 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
v.Z = Hlsl.Dot(Hash22(i + float2.UnitY), p - float2.UnitY);
v.W = Hlsl.Dot(Hash22(i + 1.0f), p - 1.0f);
- p = p * p * p * (p * (p * 6.0f - 15.0f) + 10.0f);
+ p = p * p * p * ((p * ((p * 6.0f) - 15.0f)) + 10.0f);
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
}
-
// The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate.
private float IsoFunction(in float2 p)
{
- return N2D3G(p / 4.0f + 0.07f);
+ return N2D3G((p / 4.0f) + 0.07f);
}
// Unsigned distance to the segment joining "a" and "b".
@@ -74,11 +73,11 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
float h = Hlsl.Clamp(Hlsl.Dot(a, b) / Hlsl.Dot(b, b), 0.0f, 1.0f);
- return Hlsl.Length(a - b * h);
+ return Hlsl.Length(a - (b * h));
}
// Based on IQ's signed distance to the segment joining "a" and "b".
- private static float distEdge(float2 a, float2 b)
+ private static float DistEdge(float2 a, float2 b)
{
return Hlsl.Dot((a + b) * 0.5f, Hlsl.Normalize((b - a).YX * new float2(-1, 1)));
}
@@ -86,7 +85,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
// Interpolating along the edge connecting vertices v1 and v2 with respect to the isovalue.
private static float2 Interpolate(in float2 p1, in float2 p2, float v1, float v2, float isovalue)
{
- return Hlsl.Lerp(p1, p2, (isovalue - v1) / (v2 - v1) * 0.75f + 0.25f / 2.0f);
+ return Hlsl.Lerp(p1, p2, ((isovalue - v1) / (v2 - v1) * 0.75f) + (0.25f / 2.0f));
}
// Isoline function.
@@ -105,9 +104,20 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
int iTh = 0;
- if (n3.X > isovalue) iTh += 4;
- if (n3.Y > isovalue) iTh += 2;
- if (n3.Z > isovalue) iTh += 1;
+ if (n3.X > isovalue)
+ {
+ iTh += 4;
+ }
+
+ if (n3.Y > isovalue)
+ {
+ iTh += 2;
+ }
+
+ if (n3.Z > isovalue)
+ {
+ iTh += 1;
+ }
if (iTh == 1 || iTh == 6)
{
@@ -130,7 +140,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
if (iTh >= 4 && iTh <= 6)
{
float2 tmp = p0;
-
+
p0 = p1;
p1 = tmp;
}
@@ -138,7 +148,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
if (i == 0.0f)
{
float2 tmp = p0;
-
+
p0 = p1;
p1 = tmp;
}
@@ -154,11 +164,11 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
float2 oP = p;
- p += new float2(N2D3G(p * 3.5f), N2D3G(p * 3.5f + 7.3f)) * 0.015f;
+ p += new float2(N2D3G(p * 3.5f), N2D3G((p * 3.5f) + 7.3f)) * 0.015f;
- float2 s = Hlsl.Floor(p + (p.X + p.Y) * 0.36602540378f);
+ float2 s = Hlsl.Floor(p + ((p.X + p.Y) * 0.36602540378f));
- p -= s - (s.X + s.Y) * 0.211324865f;
+ p -= s - ((s.X + s.Y) * 0.211324865f);
float i = p.X < p.Y ? 1.0f : 0.0f;
float2 ioffs = new(1.0f - i, i);
@@ -188,14 +198,14 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
float2 p1 = default;
int iTh = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
- d = Hlsl.Min(d, distEdge(p - p0, p - p1));
+ d = Hlsl.Min(d, DistEdge(p - p0, p - p1));
if (iTh == 7)
{
d = 0;
}
- d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1)));
+ d3 = Hlsl.Min(d3, DistLine(p - p0, p - p1));
d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1)));
float tri = Hlsl.Min(Hlsl.Min(DistLine(p - ip0, p - ip1), DistLine(p - ip1, p - ip2)), DistLine(p - ip2, p - ip0));
@@ -206,15 +216,20 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
int iTh2 = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
- d2 = Hlsl.Min(d2, distEdge(p - p0, p - p1));
+ d2 = Hlsl.Min(d2, DistEdge(p - p0, p - p1));
- float oldD2 = d2;
+ if (iTh2 == 7)
+ {
+ d2 = 0.0f;
+ }
- if (iTh2 == 7) d2 = 0.0f;
- if (iTh == 7) d2 = 1e5f;
+ if (iTh == 7)
+ {
+ d2 = 1e5f;
+ }
d2 = Hlsl.Max(d2, -d);
- d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1)));
+ d3 = Hlsl.Min(d3, DistLine(p - p0, p - p1));
d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1)));
d4 -= 0.075f;
d3 -= 0.0125f;
@@ -227,35 +242,48 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
float3 col = new(1, 0.85f, 0.6f);
float sf = 0.004f;
- if (d > 0.0f && d2 > 0.0f) col = new float3(1, 1.8f, 3) * 0.45f;
- if (d > 0.0f) col = Hlsl.Lerp(col, new float3(1, 1.85f, 3) * 0.3f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d2 - 0.012f)));
+ if (d > 0.0f && d2 > 0.0f)
+ {
+ col = new float3(1, 1.8f, 3) * 0.45f;
+ }
- col = Hlsl.Lerp(col, new float3(1.1f, 0.85f, 0.6f), (1.0f - Hlsl.SmoothStep(0.0f, sf, d2)));
- col = Hlsl.Lerp(col, new float3(1.5f, 0.9f, 0.6f) * 0.6f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f)));
- col = Hlsl.Lerp(col, new float3(1, 0.8f, 0.6f) * new float3(0.7f, 1.0f, 0.75f) * 0.95f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d)));
+ if (d > 0.0f)
+ {
+ col = Hlsl.Lerp(col, new float3(1, 1.85f, 3) * 0.3f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d2 - 0.012f));
+ }
- if (d2 > 0.0f) col *= (Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f + 1.25f) / 2.0f;
- else col *= Hlsl.Max(2.0f - (Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f, 0.0f);
+ col = Hlsl.Lerp(col, new float3(1.1f, 0.85f, 0.6f), 1.0f - Hlsl.SmoothStep(0.0f, sf, d2));
+ col = Hlsl.Lerp(col, new float3(1.5f, 0.9f, 0.6f) * 0.6f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f));
+ col = Hlsl.Lerp(col, new float3(1, 0.8f, 0.6f) * new float3(0.7f, 1.0f, 0.75f) * 0.95f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d));
- float pat = Hlsl.Abs(Hlsl.Frac(tri * 12.5f + 0.4f) - 0.5f) * 2.0f;
+ if (d2 > 0.0f)
+ {
+ col *= ((Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f) + 1.25f) / 2.0f;
+ }
+ else
+ {
+ col *= Hlsl.Max(2.0f - ((Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f), 0.0f);
+ }
- col *= pat * 0.425f + 0.75f;
+ float pat = Hlsl.Abs(Hlsl.Frac((tri * 12.5f) + 0.4f) - 0.5f) * 2.0f;
+
+ col *= (pat * 0.425f) + 0.75f;
col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d5)) * 0.95f);
- col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d3)));
- col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4)));
- col = Hlsl.Lerp(col, float3.One, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4 + 0.005f)));
+ col = Hlsl.Lerp(col, float3.Zero, 1.0f - Hlsl.SmoothStep(0.0f, sf, d3));
+ col = Hlsl.Lerp(col, float3.Zero, 1.0f - Hlsl.SmoothStep(0.0f, sf, d4));
+ col = Hlsl.Lerp(col, float3.One, 1.0f - Hlsl.SmoothStep(0.0f, sf, d4 + 0.005f));
float2 q = oP * 1.5f;
col = Hlsl.Min(col, 1.0f);
float gr = Hlsl.Sqrt(Hlsl.Dot(col, new float3(0.299f, 0.587f, 0.114f))) * 1.25f;
- float ns = (N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f;
+ float ns = (((N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f) + (N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f)) * 0.5f) + 0.5f;
ns = gr - ns;
q = Hlsl.Mul(q, Rotate2x2(3.14159f / 3.0f));
- float ns2 = (N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f;
+ float ns2 = (((N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f) + (N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f)) * 0.5f) + 0.5f;
ns2 = gr - ns2;
ns = Hlsl.SmoothStep(0.0f, 1.0f, Hlsl.Min(ns, ns2));
@@ -268,8 +296,8 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
public float4 Execute()
{
int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
- float2 uv = (coordinate - (float2)DispatchSize.XY * 0.5f) / Hlsl.Min(650.0f, DispatchSize.Y);
- float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + new float2(0.8660254f, 0.5f) * time / 16.0f;
+ float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / Hlsl.Min(650.0f, DispatchSize.Y);
+ float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + (new float2(0.8660254f, 0.5f) * this.time / 16.0f);
float3 col = SimplexContour(p);
uv = coordinate / (float2)DispatchSize.XY;
@@ -277,4 +305,4 @@ internal readonly partial struct TriangleGridContouring : IPixelShader
return new(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
index 9c07eaac..701344da 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp.SwapChain.Shaders;
+namespace ComputeSharp.SwapChain.Shaders;
///
/// A shader creating an animated two-tiles Truchet arrangement.
@@ -14,7 +14,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader
///
/// The current time since the start of the application.
///
- public readonly float time;
+ private readonly float time;
///
/// Calculates the Truchet distance field.
@@ -33,7 +33,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader
// HLSL's port of the GLSL mod intrinsic
static float Mod(float x, float y)
{
- return x - y * Hlsl.Floor(x / y);
+ return x - (y * Hlsl.Floor(x / y));
}
float2 ip2 = Hlsl.Floor(p / 2.0f);
@@ -106,7 +106,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader
ang *= 2.0f;
}
- ang = Hlsl.Frac(ang + time / 4.0f);
+ ang = Hlsl.Frac(ang + (this.time / 4.0f));
return d;
}
@@ -114,28 +114,28 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader
///
public float4 Execute()
{
- float2 uv = (ThreadIds.XY - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
+ float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float gSc = 7.0f;
- float2 p = uv * gSc - new float2(-1, -0.5f) * time / 2.0f;
+ float2 p = (uv * gSc) - (new float2(-1, -0.5f) * this.time / 2.0f);
float sf = 2.0f / DispatchSize.Y * gSc;
float lSc = 6.0f;
float lw = 1.0f / lSc / gSc;
- float2 d = DistanceField(p, out float2 ang) - 2.5f / lSc;
+ float2 d = DistanceField(p, out float2 ang) - (2.5f / lSc);
float3 col = new(1.0f, 0.9f, 0.8f);
for (int i = 0; i < 2; i++)
{
- float di = d[i] - lw / 4.0f;
- float tracks = Hlsl.Clamp(Hlsl.Sin(ang[i] * 6.2831f + time * 6.0f) * 4.0f, 0.0f, 1.0f);
+ float di = d[i] - (lw / 4.0f);
+ float tracks = Hlsl.Clamp(Hlsl.Sin((ang[i] * 6.2831f) + (this.time * 6.0f)) * 4.0f, 0.0f, 1.0f);
float gap = 1.0f + lw;
col = Hlsl.Lerp(col, 0, (1.0f - Hlsl.SmoothStep(0.0f, sf * 6.0f, di)) * 0.35f);
col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di));
- col = Hlsl.Lerp(col, new(1.0f, 0.9f, 0.8f), 1.0f - Hlsl.SmoothStep(0.0f, sf, di + lw * 2.0f));
- col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + gap / lSc));
- col = Hlsl.Lerp(col, 1, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + gap / lSc + lw));
- col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + 2.0f * gap / lSc));
- col = Hlsl.Lerp(col, 1 * tracks, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + 2.0f * gap / lSc + lw));
+ col = Hlsl.Lerp(col, new(1.0f, 0.9f, 0.8f), 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (lw * 2.0f)));
+ col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (gap / lSc)));
+ col = Hlsl.Lerp(col, 1, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (gap / lSc) + lw));
+ col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (2.0f * gap / lSc)));
+ col = Hlsl.Lerp(col, 1 * tracks, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (2.0f * gap / lSc) + lw));
}
float3 rgb = Hlsl.Sqrt(Hlsl.Max(col, 0.0f));
@@ -143,4 +143,4 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader
return color;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs
index 4db963a7..763ad27f 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs
@@ -1,4 +1,4 @@
-#if !DEBUG
+#if !DEBUG
using System;
using System.Diagnostics;
using System.Reflection;
@@ -112,4 +112,4 @@ sealed partial class App : Application
coreTitleBar.ExtendViewIntoTitleBar = true;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
index 9b937baa..0c24c4cd 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
+++ b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
@@ -3,7 +3,7 @@
Debug
- x86
+ x64
{FBD388A5-7855-4408-98FF-E689F509DB5A}
AppContainerExe
Properties
@@ -18,58 +18,14 @@
{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
true
false
-
-
- true
- bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x86
- false
- prompt
- true
-
-
- bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x86
- false
- prompt
- true
- true
-
-
- true
- bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- ARM
- false
- prompt
- true
-
-
- bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- ARM
- false
- prompt
- true
- true
+ x64;ARM64
+ $(NoWarn);IDE0240
true
bin\ARM64\Debug\
DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
+ $(NoWarn);2008
full
ARM64
false
@@ -81,7 +37,7 @@
bin\ARM64\Release\
TRACE;NETFX_CORE;WINDOWS_UWP
true
- ;2008
+ $(NoWarn);2008
pdbonly
ARM64
false
@@ -93,7 +49,7 @@
true
bin\x64\Debug\
DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
+ $(NoWarn);2008
full
x64
false
@@ -104,7 +60,7 @@
bin\x64\Release\
TRACE;NETFX_CORE;WINDOWS_UWP
true
- ;2008
+ $(NoWarn);2008
pdbonly
x64
false
@@ -252,11 +208,4 @@
powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)\build\CreateBlankAppCenterToken.ps1
-
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs b/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
index 52587761..61e44ce9 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System.IO;
using System.Reflection;
using CommunityToolkit.Diagnostics;
@@ -41,4 +41,4 @@ public static class AssemblyExtensions
return false;
}
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Properties/AssemblyInfo.cs b/samples/ComputeSharp.SwapChain.Uwp/Properties/AssemblyInfo.cs
index 0ed0ddff..bf5595ef 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Properties/AssemblyInfo.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Properties/SkipLocalsInitAttribute.cs b/samples/ComputeSharp.SwapChain.Uwp/Properties/SkipLocalsInitAttribute.cs
index 894d04db..56e0896b 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Properties/SkipLocalsInitAttribute.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Properties/SkipLocalsInitAttribute.cs
@@ -1,4 +1,4 @@
-namespace System.Runtime.CompilerServices;
+namespace System.Runtime.CompilerServices;
///
/// Used to indicate to the compiler that the .locals init flag should not be set in method headers.
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
index 13f204c7..af5e4f99 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using ComputeSharp.SwapChain.Core.Services;
@@ -58,4 +58,4 @@ public sealed class AppCenterService : IAnalyticsService
: $"|{text.Substring(text.Length - PropertyStringMaxLength)}";
});
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs
index 2b3f0f9e..9973a613 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using CommunityToolkit.Mvvm.DependencyInjection;
using ComputeSharp.SwapChain.Core.Constants;
using ComputeSharp.SwapChain.Core.Services;
@@ -31,8 +31,8 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService().Log(Event.OpenShaderSelectionPanel);
- Root.Resources.Remove("ShaderSelectionPanel");
- Root.Children.Add(ShaderSelectionPanel);
+ _ = this.Root.Resources.Remove("ShaderSelectionPanel");
+ this.Root.Children.Add(this.ShaderSelectionPanel);
}
// Hides the shader selection panel
@@ -40,13 +40,13 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService().Log(Event.CloseShaderSelectionPanel);
- Root.Children.Remove(ShaderSelectionPanel);
+ _ = this.Root.Children.Remove(this.ShaderSelectionPanel);
}
// Updates the size of the shaders list panel
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
- ShadersListContainerPanel.Height = Math.Round(e.NewSize.Height * 0.35);
+ this.ShadersListContainerPanel.Height = Math.Round(e.NewSize.Height * 0.35);
}
// Logs rendering failed in the main panel
@@ -54,7 +54,7 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService().Log(args.Exception, (nameof(Error), Error.RenderingFailedOnMainPanel));
- RenderingErrorInfoBar.IsOpen = true;
+ this.RenderingErrorInfoBar.IsOpen = true;
}
// Logs rendering failed in a secondary panel
@@ -62,6 +62,6 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService().Log(args.Exception, (nameof(Error), Error.RenderingFailedOnSelectionPanel));
- RenderingErrorInfoBar.IsOpen = true;
+ this.RenderingErrorInfoBar.IsOpen = true;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs
index 6068c97f..c4a547d4 100644
--- a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs
+++ b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs
@@ -1,8 +1,10 @@
-using System;
+using System;
using System.Threading;
using ComputeSharp.SwapChain.WinUI.Views;
using Microsoft.UI.Xaml;
+#pragma warning disable CA1001, IDE0052
+
namespace ComputeSharp.SwapChain.WinUI;
///
@@ -27,25 +29,26 @@ public sealed partial class App : Application
///
public App()
{
- this.InitializeComponent();
+ InitializeComponent();
}
///
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
- mainWindow = new MainWindow();
- mainWindow.Closed += (_, _) =>
+ this.mainWindow = new MainWindow();
+ this.mainWindow.Closed += (_, _) =>
{
// Due to an issue (https://discord.com/channels/372137812037730304/663434534087426129/979543152853663744), the WinUI 3 app
// will keep running after the window is closed if any render thread is still going. To work around this, each loaded shader
// panel is tracked in a conditional weak table, and then when the window is closed they're all manually stopped by setting
// their shader runners to null. After this, the app should just be able to close automatically when the panels are done.
- mainWindow.OnShutdown();
+ this.mainWindow.OnShutdown();
// For good measure, also start a timer of one second. If the app is still alive by then (ie. if the timer callback is
// executed at all), then just force the whole process to terminate, and exit with the E_APPLICATION_EXITING error code.
- shutdownTimer = new Timer(_ => Environment.Exit(unchecked((int)(0x8000001A))), this, 1000, Timeout.Infinite);
+ this.shutdownTimer = new Timer(_ => Environment.Exit(unchecked((int)0x8000001A)), this, 1000, Timeout.Infinite);
};
- mainWindow.Activate();
+
+ this.mainWindow.Activate();
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
index b1a2f94d..c93fd788 100644
--- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
+++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
@@ -1,4 +1,4 @@
-
+
WinExe
net6.0-windows10.0.19041.0
@@ -11,6 +11,7 @@
true
true
$(DefineConstants);SAMPLE_APP
+ $(NoWarn);IDE0240
diff --git a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs
index 3c7257c3..0d03b5a1 100644
--- a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs
+++ b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.CompilerServices;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.ViewModels;
@@ -23,24 +23,24 @@ public sealed partial class MainWindow : Window
this.InitializeComponent();
this.ExtendsContentIntoTitleBar = true;
- SetTitleBar(TitleBarRectangle);
+ SetTitleBar(this.TitleBarRectangle);
- Root.DataContext = new MainViewModel(new DebugAnalyticsService());
+ this.Root.DataContext = new MainViewModel(new DebugAnalyticsService());
}
///
/// Gets the instance for the current view.
///
- public MainViewModel ViewModel => (MainViewModel)Root.DataContext;
+ public MainViewModel ViewModel => (MainViewModel)this.Root.DataContext;
///
/// Stops all rendering when the application is closing.
///
public void OnShutdown()
{
- ShaderPanel.ShaderRunner = null;
+ this.ShaderPanel.ShaderRunner = null;
- foreach (var (panel, _) in this.shaderPanels)
+ foreach ((AnimatedComputeShaderPanel panel, object _) in this.shaderPanels)
{
panel.ShaderRunner = null;
}
@@ -49,20 +49,20 @@ public sealed partial class MainWindow : Window
// Opens the shader selection panel
private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e)
{
- Root.Resources.Remove("ShaderSelectionPanel");
- Root.Children.Add(ShaderSelectionPanel);
+ _ = this.Root.Resources.Remove("ShaderSelectionPanel");
+ this.Root.Children.Add(this.ShaderSelectionPanel);
}
// Hides the shader selection panel
private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e)
{
- Root.Children.Remove(ShaderSelectionPanel);
+ _ = this.Root.Children.Remove(this.ShaderSelectionPanel);
}
// Updates the size of the shaders list panel
private void UserControl_SizeChanged(object sender, WindowSizeChangedEventArgs e)
{
- ShadersListContainerPanel.Height = Math.Round(e.Size.Height * 0.35);
+ this.ShadersListContainerPanel.Height = Math.Round(e.Size.Height * 0.35);
}
// Tracks the current panel
@@ -70,4 +70,4 @@ public sealed partial class MainWindow : Window
{
this.shaderPanels.AddOrUpdate((AnimatedComputeShaderPanel)sender, null);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
index 4931207c..9affa55c 100644
--- a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
+++ b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using ComputeSharp.Interop;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -100,7 +100,7 @@ internal sealed class SwapChainApplication : Win32Application
d3D12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAGS.D3D12_COMMAND_QUEUE_FLAG_NONE;
d3D12CommandQueueDesc.NodeMask = 0;
- _ = d3D12Device.Get()->CreateCommandQueue(
+ _ = this.d3D12Device.Get()->CreateCommandQueue(
&d3D12CommandQueueDesc,
Windows.__uuidof(),
(void**)d3D12CommandQueue);
@@ -136,7 +136,7 @@ internal sealed class SwapChainApplication : Win32Application
dxgiSwapChainDesc1.SwapEffect = DXGI_SWAP_EFFECT.DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
_ = dxgiFactory2.Get()->CreateSwapChainForHwnd(
- (IUnknown*)d3D12CommandQueue.Get(),
+ (IUnknown*)this.d3D12CommandQueue.Get(),
hwnd,
&dxgiSwapChainDesc1,
null,
@@ -147,7 +147,7 @@ internal sealed class SwapChainApplication : Win32Application
// Create the command allocator to use
fixed (ID3D12CommandAllocator** d3D12CommandAllocator = this.d3D12CommandAllocator)
{
- this.d3D12Device.Get()->CreateCommandAllocator(
+ _ = this.d3D12Device.Get()->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
Windows.__uuidof(),
(void**)d3D12CommandAllocator);
@@ -156,17 +156,17 @@ internal sealed class SwapChainApplication : Win32Application
// Create the reusable command list to copy data to the back buffers
fixed (ID3D12GraphicsCommandList** d3D12GraphicsCommandList = this.d3D12GraphicsCommandList)
{
- this.d3D12Device.Get()->CreateCommandList(
+ _ = this.d3D12Device.Get()->CreateCommandList(
0,
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
- d3D12CommandAllocator,
+ this.d3D12CommandAllocator,
null,
Windows.__uuidof(),
(void**)d3D12GraphicsCommandList);
}
// Close the command list to prepare it for future use
- this.d3D12GraphicsCommandList.Get()->Close();
+ _ = this.d3D12GraphicsCommandList.Get()->Close();
}
///
@@ -180,10 +180,10 @@ internal sealed class SwapChainApplication : Win32Application
///
private unsafe void ApplyResize()
{
- this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
+ _ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
// Wait for the fence again to ensure there are no pending operations
- this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
+ _ = this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
this.nextD3D12FenceValue++;
@@ -192,7 +192,7 @@ internal sealed class SwapChainApplication : Win32Application
this.d3D12Resource1.Dispose();
// Resize the swap chain buffers
- this.dxgiSwapChain1.Get()->ResizeBuffers(0, 0, 0, DXGI_FORMAT.DXGI_FORMAT_UNKNOWN, 0);
+ _ = this.dxgiSwapChain1.Get()->ResizeBuffers(0, 0, 0, DXGI_FORMAT.DXGI_FORMAT_UNKNOWN, 0);
// Get the index of the initial back buffer
using (ComPtr dxgiSwapChain3 = default)
@@ -206,8 +206,8 @@ internal sealed class SwapChainApplication : Win32Application
fixed (ID3D12Resource** d3D12Resource0 = this.d3D12Resource0)
fixed (ID3D12Resource** d3D12Resource1 = this.d3D12Resource1)
{
- _ = dxgiSwapChain1.Get()->GetBuffer(0, Windows.__uuidof(), (void**)d3D12Resource0);
- _ = dxgiSwapChain1.Get()->GetBuffer(1, Windows.__uuidof(), (void**)d3D12Resource1);
+ _ = this.dxgiSwapChain1.Get()->GetBuffer(0, Windows.__uuidof(), (void**)d3D12Resource0);
+ _ = this.dxgiSwapChain1.Get()->GetBuffer(1, Windows.__uuidof(), (void**)d3D12Resource1);
}
this.texture?.Dispose();
@@ -249,8 +249,8 @@ internal sealed class SwapChainApplication : Win32Application
this.currentBufferIndex ^= 1;
// Reset the command list and command allocator
- this.d3D12CommandAllocator.Get()->Reset();
- this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);
+ _ = this.d3D12CommandAllocator.Get()->Reset();
+ _ = this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);
D3D12_RESOURCE_BARRIER* d3D12ResourceBarriers = stackalloc D3D12_RESOURCE_BARRIER[]
{
@@ -265,10 +265,10 @@ internal sealed class SwapChainApplication : Win32Application
};
// Transition the resources to COPY_DEST and COPY_SOURCE respectively
- d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
+ this.d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
// Copy the generated frame to the target back buffer
- d3D12GraphicsCommandList.Get()->CopyResource(d3D12ResourceBackBuffer, d3D12Resource.Get());
+ this.d3D12GraphicsCommandList.Get()->CopyResource(d3D12ResourceBackBuffer, d3D12Resource.Get());
d3D12ResourceBarriers[0] = D3D12_RESOURCE_BARRIER.InitTransition(
d3D12Resource.Get(),
@@ -281,22 +281,22 @@ internal sealed class SwapChainApplication : Win32Application
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON);
// Transition the resources back to COMMON and UNORDERED_ACCESS respectively
- d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
+ this.d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
- d3D12GraphicsCommandList.Get()->Close();
+ _ = this.d3D12GraphicsCommandList.Get()->Close();
// Execute the command list to perform the copy
- this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)d3D12GraphicsCommandList.GetAddressOf());
- this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
+ this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)this.d3D12GraphicsCommandList.GetAddressOf());
+ _ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
// Present the new frame
- this.dxgiSwapChain1.Get()->Present(0, 0);
+ _ = this.dxgiSwapChain1.Get()->Present(0, 0);
if (this.nextD3D12FenceValue > this.d3D12Fence.Get()->GetCompletedValue())
{
- this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
+ _ = this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
}
this.nextD3D12FenceValue++;
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32Application.cs b/samples/ComputeSharp.SwapChain/Backend/Win32Application.cs
index a097a84b..fbb03e37 100644
--- a/samples/ComputeSharp.SwapChain/Backend/Win32Application.cs
+++ b/samples/ComputeSharp.SwapChain/Backend/Win32Application.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using TerraFX.Interop.Windows;
namespace ComputeSharp.SwapChain.Backend;
@@ -24,4 +24,4 @@ internal abstract class Win32Application
///
/// The current time since the start of the application.
public abstract void OnUpdate(TimeSpan time);
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs
index 475a2210..6856b27f 100644
--- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs
+++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
@@ -11,7 +11,7 @@ namespace ComputeSharp.SwapChain.Backend;
///
/// A helper class to manage the creation and execution of Win32 applications.
///
-internal unsafe static class Win32ApplicationRunner
+internal static unsafe class Win32ApplicationRunner
{
///
/// Whether or not a resize operation is in progress.
@@ -185,6 +185,7 @@ internal unsafe static class Win32ApplicationRunner
{
isPaused = false;
}
+
return 0;
}
@@ -196,11 +197,11 @@ internal unsafe static class Win32ApplicationRunner
if (isPaused)
{
- Windows.SetCapture(hwnd);
+ _ = Windows.SetCapture(hwnd);
}
else
{
- Windows.ReleaseCapture();
+ _ = Windows.ReleaseCapture();
}
isPaused = !isPaused;
@@ -229,7 +230,7 @@ internal unsafe static class Win32ApplicationRunner
// Size update
case WM.WM_SIZE:
{
- if (!isResizing && wParam != (byte)Windows.SIZE_MINIMIZED)
+ if (!isResizing && wParam != Windows.SIZE_MINIMIZED)
{
application.OnResize();
}
@@ -252,36 +253,68 @@ internal unsafe static class Win32ApplicationRunner
_ = Windows.GetCursorPos(&point);
_ = Windows.GetWindowRect(hwnd, &rect);
- bool isAtTop = Math.Abs(point.y - rect.top) < 12;
- bool isAtRight = Math.Abs(point.x - rect.right) < 12;
- bool isAtBottom = Math.Abs(point.y - rect.bottom) < 12;
- bool isAtLeft = Math.Abs(point.x - rect.left) < 12;
+ bool isAtTop = Math.Abs(point.y - rect.top) < 12;
+ bool isAtRight = Math.Abs(point.x - rect.right) < 12;
+ bool isAtBottom = Math.Abs(point.y - rect.bottom) < 12;
+ bool isAtLeft = Math.Abs(point.x - rect.left) < 12;
if (isAtTop)
{
- if (isAtRight) return Windows.HTTOPRIGHT;
- if (isAtLeft) return Windows.HTTOPLEFT;
+ if (isAtRight)
+ {
+ return Windows.HTTOPRIGHT;
+ }
+
+ if (isAtLeft)
+ {
+ return Windows.HTTOPLEFT;
+ }
+
return Windows.HTTOP;
}
if (isAtRight)
{
- if (isAtTop) return Windows.HTTOPRIGHT;
- if (isAtBottom) return Windows.HTBOTTOMRIGHT;
+ if (isAtTop)
+ {
+ return Windows.HTTOPRIGHT;
+ }
+
+ if (isAtBottom)
+ {
+ return Windows.HTBOTTOMRIGHT;
+ }
+
return Windows.HTRIGHT;
}
if (isAtBottom)
{
- if (isAtRight) return Windows.HTBOTTOMRIGHT;
- if (isAtLeft) return Windows.HTBOTTOMLEFT;
+ if (isAtRight)
+ {
+ return Windows.HTBOTTOMRIGHT;
+ }
+
+ if (isAtLeft)
+ {
+ return Windows.HTBOTTOMLEFT;
+ }
+
return Windows.HTBOTTOM;
}
if (isAtLeft)
{
- if (isAtTop) return Windows.HTTOPLEFT;
- if (isAtBottom) return Windows.HTBOTTOMLEFT;
+ if (isAtTop)
+ {
+ return Windows.HTTOPLEFT;
+ }
+
+ if (isAtBottom)
+ {
+ return Windows.HTBOTTOMLEFT;
+ }
+
return Windows.HTLEFT;
}
@@ -312,4 +345,4 @@ internal unsafe static class Win32ApplicationRunner
return Windows.DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
-}
+}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs
index 29381a57..d1606b2a 100644
--- a/samples/ComputeSharp.SwapChain/Program.cs
+++ b/samples/ComputeSharp.SwapChain/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Runtime.CompilerServices;
using ComputeSharp.SwapChain.Backend;
@@ -48,7 +48,7 @@ class Program
}
Console.WriteLine($"{Samples.Length}+: Exit (Use Escape, 'Q', or Alt + F4 to exit a sample once chosen)");
- Console.WriteLine();
+ Console.WriteLine();
do
{
@@ -61,7 +61,7 @@ class Program
Console.WriteLine();
Console.WriteLine($"Starting {Samples[index].ShaderName}...");
- Win32ApplicationRunner.Run(Samples[index].Application);
+ _ = Win32ApplicationRunner.Run(Samples[index].Application);
}
}
while (index >= 0 && index < Samples.Length);
@@ -78,4 +78,4 @@ class Program
return GraphicsDevice.GetDefault().LoadReadOnlyTexture2D(filename);
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs
index 7fe883be..74ec0772 100644
--- a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs
+++ b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs
@@ -1,4 +1,4 @@
-namespace System.Runtime.CompilerServices;
+namespace System.Runtime.CompilerServices;
///
/// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
@@ -11,14 +11,20 @@ public sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
///
/// The name of the argument that should be passed to the handler.
/// may be used as the name of the receiver in an instance method.
- public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new string[] { argument };
+ public InterpolatedStringHandlerArgumentAttribute(string argument)
+ {
+ Arguments = new string[] { argument };
+ }
///
/// Initializes a new instance of the class.
///
/// The names of the arguments that should be passed to the handler.
/// may be used as the name of the receiver in an instance method.
- public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) => Arguments = arguments;
+ public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
+ {
+ Arguments = arguments;
+ }
///
/// Gets the names of the arguments that should be passed to the handler.
diff --git a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerAttribute.cs b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerAttribute.cs
index 75904a51..0ef12b61 100644
--- a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerAttribute.cs
+++ b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/InterpolatedStringHandlerAttribute.cs
@@ -1,4 +1,4 @@
-namespace System.Runtime.CompilerServices;
+namespace System.Runtime.CompilerServices;
///
/// Indicates the attributed type is to be used as an interpolated string handler.
diff --git a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/IsExternalInit.cs b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/IsExternalInit.cs
index 775f605a..c02e30d6 100644
--- a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/IsExternalInit.cs
+++ b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/IsExternalInit.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
@@ -12,4 +12,4 @@ namespace System.Runtime.CompilerServices;
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit
{
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs
index 9d2046fc..2676343b 100644
--- a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs
+++ b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.InteropServices;
namespace ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices;
@@ -14,5 +14,8 @@ internal static class RuntimeHelpers
/// The type to associate the memory to.
/// The size in byte of the memory to allocate.
/// A pointer to the allocated memory.
- public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size);
+ public static IntPtr AllocateTypeAssociatedMemory(Type type, int size)
+ {
+ return Marshal.AllocHGlobal(size);
+ }
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/SkipLocalsInitAttribute.cs b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/SkipLocalsInitAttribute.cs
index 1339a5ae..6d63a804 100644
--- a/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/SkipLocalsInitAttribute.cs
+++ b/src/ComputeSharp.Core.NetStandard/System/Runtime.CompilerServices/SkipLocalsInitAttribute.cs
@@ -1,4 +1,4 @@
-namespace System.Runtime.CompilerServices;
+namespace System.Runtime.CompilerServices;
///
/// Used to indicate to the compiler that the .locals init
diff --git a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
index 9d573fd3..288d6eae 100644
--- a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
+++ b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using System.Text;
using ComputeSharp.Core.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
@@ -145,4 +145,4 @@ public sealed class AutoConstructorGenerator : IIncrementalGenerator
return hierarchyInfo.GetSyntax(constructorDeclaration.AddAttributeLists(attributes));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs
index 8afd2642..1892174c 100644
--- a/src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs
+++ b/src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System.IO;
using System.Reflection;
using Microsoft.CodeAnalysis;
@@ -25,4 +25,4 @@ public sealed class GlobalUsingDirectivesGenerator : IIncrementalGenerator
context.AddSource("GlobalUsingDirectives.g.cs", globalUsingDirectives);
});
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.SourceGenerators/Models/ConstructorInfo.cs b/src/ComputeSharp.Core.SourceGenerators/Models/ConstructorInfo.cs
index 93075030..73f981cd 100644
--- a/src/ComputeSharp.Core.SourceGenerators/Models/ConstructorInfo.cs
+++ b/src/ComputeSharp.Core.SourceGenerators/Models/ConstructorInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
@@ -14,10 +14,16 @@ namespace ComputeSharp.Core.SourceGenerators.Models;
internal sealed record ConstructorInfo(ImmutableArray Parameters, ImmutableArray DefaultedFields)
{
///
- public bool Equals(ConstructorInfo? obj) => Comparer.Default.Equals(this, obj);
+ public bool Equals(ConstructorInfo? obj)
+ {
+ return Comparer.Default.Equals(this, obj);
+ }
///
- public override int GetHashCode() => Comparer.Default.GetHashCode(this);
+ public override int GetHashCode()
+ {
+ return Comparer.Default.GetHashCode(this);
+ }
///
/// An implementation for .
diff --git a/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs b/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs
index ff276e79..3f45388a 100644
--- a/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs
+++ b/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs
@@ -1,8 +1,8 @@
-namespace ComputeSharp.Core.SourceGenerators.Models;
+namespace ComputeSharp.Core.SourceGenerators.Models;
///
/// A model describing info on a constructor parameter.
///
/// The fully qualified type name.
/// The parameter name.
-internal sealed record ParameterInfo(string Type, string Name);
+internal sealed record ParameterInfo(string Type, string Name);
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs b/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
index 048876af..20737a4c 100644
--- a/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace ComputeSharp;
@@ -8,4 +8,4 @@ namespace ComputeSharp;
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class AutoConstructorAttribute : Attribute
{
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehavior.cs b/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehavior.cs
index 0690f9f7..465bc2b7 100644
--- a/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehavior.cs
+++ b/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehavior.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp;
+namespace ComputeSharp;
///
/// Indicates the behavior of fields annotated with .
@@ -9,4 +9,4 @@ internal enum AutoConstructorBehavior
/// Causes to ignore fields and set their values to .
///
IgnoreAndSetToDefault
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehaviorAttribute.cs b/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehaviorAttribute.cs
index f25456c6..b9dbbb8a 100644
--- a/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehaviorAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/Internals/AutoConstructorBehaviorAttribute.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace ComputeSharp;
diff --git a/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs b/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs
index 274cad30..b8661343 100644
--- a/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs
+++ b/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace ComputeSharp.Exceptions;
@@ -15,4 +15,4 @@ public sealed class InvalidExecutionContextException : InvalidOperationException
: base($"The API {name} can only be used from within an HLSL shader.")
{
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs b/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs
index de7c0dcf..1edcaf7e 100644
--- a/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs
+++ b/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Buffers;
@@ -61,10 +61,10 @@ internal ref struct FormatInterpolatedStringHandler
{
this.format = format;
this.formatProvider = formatProvider;
- characters = initialBuffer;
- arrayToReturnToPool = null;
- position = 0;
- hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider);
+ this.characters = initialBuffer;
+ this.arrayToReturnToPool = null;
+ this.position = 0;
+ this.hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider);
}
///
@@ -96,11 +96,11 @@ internal ref struct FormatInterpolatedStringHandler
public string ToStringAndClear()
{
#if NET6_0_OR_GREATER
- string result = new(characters.Slice(0, position));
+ string result = new(this.characters.Slice(0, this.position));
#else
- string result = characters.Slice(0, position).ToString();
+ string result = this.characters.Slice(0, this.position).ToString();
#endif
- char[]? toReturn = arrayToReturnToPool;
+ char[]? toReturn = this.arrayToReturnToPool;
this = default;
@@ -121,26 +121,27 @@ internal ref struct FormatInterpolatedStringHandler
{
if (value.Length == 1)
{
- Span chars = characters;
- int pos = position;
+ Span chars = this.characters;
+ int pos = this.position;
if ((uint)pos < (uint)chars.Length)
{
chars[pos] = value[0];
- position = pos + 1;
+ this.position = pos + 1;
}
else
{
GrowThenCopyString(value);
}
+
return;
}
if (value.Length == 2)
{
- Span chars = characters;
- int pos = position;
+ Span chars = this.characters;
+ int pos = this.position;
if ((uint)pos < chars.Length - 1)
{
@@ -152,12 +153,13 @@ internal ref struct FormatInterpolatedStringHandler
Unsafe.ReadUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(value.AsSpan()))));
#endif
- position = pos + 2;
+ this.position = pos + 2;
}
else
{
GrowThenCopyString(value);
}
+
return;
}
@@ -171,12 +173,12 @@ internal ref struct FormatInterpolatedStringHandler
private void AppendStringDirect(string value)
{
#if NET6_0_OR_GREATER
- if (value.TryCopyTo(characters.Slice(position)))
+ if (value.TryCopyTo(this.characters.Slice(this.position)))
#else
- if (value.AsSpan().TryCopyTo(characters.Slice(position)))
+ if (value.AsSpan().TryCopyTo(this.characters.Slice(this.position)))
#endif
{
- position += value.Length;
+ this.position += value.Length;
}
else
{
@@ -204,23 +206,23 @@ internal ref struct FormatInterpolatedStringHandler
where T : IFormattable
#endif
{
- if (hasCustomFormatter)
+ if (this.hasCustomFormatter)
{
- AppendCustomFormatter(value, format);
+ AppendCustomFormatter(value, this.format);
return;
}
#if NET6_0_OR_GREATER
int charsWritten;
- while (!value.TryFormat(characters.Slice(position), out charsWritten, format, formatProvider))
+ while (!value.TryFormat(this.characters.Slice(this.position), out charsWritten, this.format, this.formatProvider))
{
Grow();
}
- position += charsWritten;
+ this.position += charsWritten;
#else
- AppendStringDirect(value.ToString(format, formatProvider));
+ AppendStringDirect(value.ToString(this.format, this.formatProvider));
#endif
}
@@ -243,9 +245,9 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private void AppendCustomFormatter(T value, string? format)
{
- ICustomFormatter? formatter = (ICustomFormatter?)formatProvider?.GetFormat(typeof(ICustomFormatter));
+ ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
- if (formatter is not null && formatter.Format(format, value, formatProvider) is string customFormatted)
+ if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
{
AppendStringDirect(customFormatted);
}
@@ -261,12 +263,12 @@ internal ref struct FormatInterpolatedStringHandler
Grow(value.Length);
#if NET6_0_OR_GREATER
- value.CopyTo(characters.Slice(position));
+ value.CopyTo(this.characters.Slice(this.position));
#else
- value.AsSpan().CopyTo(characters.Slice(position));
+ value.AsSpan().CopyTo(this.characters.Slice(this.position));
#endif
- position += value.Length;
+ this.position += value.Length;
}
///
@@ -275,17 +277,19 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow(int additionalChars)
{
- GrowCore((uint)position + (uint)additionalChars);
+ GrowCore((uint)this.position + (uint)additionalChars);
}
+#if NET6_0_OR_GREATER
///
/// Grows the size of .
///
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow()
{
- GrowCore((uint)characters.Length + 1);
+ GrowCore((uint)this.characters.Length + 1);
}
+#endif
///
/// Grow the size of to at least the specified .
@@ -293,7 +297,7 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void GrowCore(uint requiredMinCapacity)
{
- uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)characters.Length * 2, 0x3FFFFFDF));
+ uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)this.characters.Length * 2, 0x3FFFFFDF));
#if NET6_0_OR_GREATER
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
#else
@@ -301,11 +305,11 @@ internal ref struct FormatInterpolatedStringHandler
#endif
char[] newArray = ArrayPool.Shared.Rent(arraySize);
- characters.Slice(0, position).CopyTo(newArray);
+ this.characters.Slice(0, this.position).CopyTo(newArray);
- char[]? toReturn = arrayToReturnToPool;
+ char[]? toReturn = this.arrayToReturnToPool;
- characters = arrayToReturnToPool = newArray;
+ this.characters = this.arrayToReturnToPool = newArray;
if (toReturn is not null)
{
diff --git a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs b/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs
index bfb0ffe0..0aec4d5b 100644
--- a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs
+++ b/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
@@ -34,12 +34,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
///
/// The number of characters written to .
///
- internal int position;
+ private int position;
///
/// Indicates whether all formatting operations have succeeded.
///
- internal bool success;
+ private bool success;
///
/// Whether provides an .
@@ -62,9 +62,9 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
this.format = format;
this.formatAsString = null;
this.formatProvider = formatProvider;
- position = 0;
- success = shouldAppend = destination.Length >= literalLength;
- hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider);
+ this.position = 0;
+ this.success = shouldAppend = destination.Length >= literalLength;
+ this.hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider);
}
///
@@ -106,13 +106,13 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
if (value.Length == 1)
{
Span destination = this.destination;
- int pos = position;
+ int pos = this.position;
if ((uint)pos < (uint)destination.Length)
{
destination[pos] = value[0];
- position = pos + 1;
+ this.position = pos + 1;
return true;
}
@@ -123,7 +123,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
if (value.Length == 2)
{
Span destination = this.destination;
- int pos = position;
+ int pos = this.position;
if ((uint)pos < destination.Length - 1)
{
@@ -135,7 +135,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
Unsafe.ReadUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(value.AsSpan()))));
#endif
- position = pos + 2;
+ this.position = pos + 2;
return true;
}
@@ -154,12 +154,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
private bool AppendStringDirect(string value)
{
#if NET6_0_OR_GREATER
- if (value.TryCopyTo(destination.Slice(position)))
+ if (value.TryCopyTo(this.destination.Slice(this.position)))
#else
- if (value.AsSpan().TryCopyTo(destination.Slice(position)))
+ if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
#endif
{
- position += value.Length;
+ this.position += value.Length;
return true;
}
@@ -177,24 +177,22 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
where T : IFormattable
#endif
{
- if (hasCustomFormatter)
+ if (this.hasCustomFormatter)
{
- return AppendCustomFormatter(value, formatAsString ??= format.ToString());
+ return AppendCustomFormatter(value, this.formatAsString ??= this.format.ToString());
}
#if NET6_0_OR_GREATER
- int charsWritten;
-
- if (value.TryFormat(destination.Slice(position), out charsWritten, format, formatProvider))
+ if (value.TryFormat(this.destination.Slice(this.position), out int charsWritten, this.format, this.formatProvider))
{
- position += charsWritten;
+ this.position += charsWritten;
return true;
}
return Fail();
#else
- return AppendStringDirect(value.ToString(formatAsString ??= format.ToString(), formatProvider));
+ return AppendStringDirect(value.ToString(this.formatAsString ??= this.format.ToString(), this.formatProvider));
#endif
}
@@ -204,7 +202,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
/// The value to write.
public bool AppendFormatted(string? value)
{
- if (hasCustomFormatter)
+ if (this.hasCustomFormatter)
{
return AppendCustomFormatter(value, format: null);
}
@@ -215,12 +213,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
}
#if NET6_0_OR_GREATER
- if (value.TryCopyTo(destination.Slice(position)))
+ if (value.TryCopyTo(this.destination.Slice(this.position)))
#else
- if (value.AsSpan().TryCopyTo(destination.Slice(position)))
+ if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
#endif
{
- position += value.Length;
+ this.position += value.Length;
return true;
}
@@ -236,9 +234,9 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private bool AppendCustomFormatter(T value, string? format)
{
- ICustomFormatter? formatter = (ICustomFormatter?)formatProvider?.GetFormat(typeof(ICustomFormatter));
+ ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
- if (formatter is not null && formatter.Format(format, value, formatProvider) is string customFormatted)
+ if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
{
return AppendStringDirect(customFormatted);
}
@@ -251,7 +249,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
///
private bool Fail()
{
- success = false;
+ this.success = false;
return false;
}
diff --git a/src/ComputeSharp.Core/Intrinsics/Attributes/HlslIntrinsicNameAttribute.cs b/src/ComputeSharp.Core/Intrinsics/Attributes/HlslIntrinsicNameAttribute.cs
index 5a5b0df5..ffc2fdad 100644
--- a/src/ComputeSharp.Core/Intrinsics/Attributes/HlslIntrinsicNameAttribute.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Attributes/HlslIntrinsicNameAttribute.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
namespace ComputeSharp.Core.Intrinsics.Attributes;
@@ -28,4 +28,4 @@ internal sealed class HlslIntrinsicNameAttribute : Attribute
/// Gets whether or not matching parameters is also required to extract the name of this intrinsic.
///
public bool RequiresParametersMatching { get; init; }
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.g.cs
index 937ed920..42845080 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.g.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.g.cs
@@ -1,5 +1,7 @@
using ComputeSharp.Core.Intrinsics.Attributes;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.tt b/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.tt
index eeb80f9f..51a0a0e8 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.tt
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Casts.tt
@@ -4,6 +4,8 @@
<#@ output extension=".g.cs"#>
using ComputeSharp.Core.Intrinsics.Attributes;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs
index d72e9827..98ba9e5a 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs
@@ -1,6 +1,8 @@
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt
index 1536a67a..fccd4923 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt
@@ -2,6 +2,8 @@
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs
index 03fb5bb7..57e56054 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs
@@ -1,6 +1,8 @@
-using ComputeSharp.Core.Intrinsics.Attributes;
+using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
@@ -88,4 +90,4 @@ public static partial class Hlsl
///
[HlslIntrinsicName("lit")]
public static float Lit(float nDotL, float nDotH, float m) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
index b59a334d..2ebe9659 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
@@ -1,6 +1,8 @@
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.tt b/src/ComputeSharp.Core/Intrinsics/Hlsl.tt
index da74c73d..60fc7d8d 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.tt
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.tt
@@ -2,6 +2,8 @@
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
+#pragma warning disable IDE0022
+
namespace ComputeSharp;
///
diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs
index 774676c6..d2d0490f 100644
--- a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs
+++ b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.InteropServices;
namespace ComputeSharp;
@@ -13,7 +13,7 @@ public readonly struct Bool
/// The wrapped value for the current instance.
///
[FieldOffset(0)]
- private readonly int Value;
+ private readonly int value;
///
/// Creates a new instance for a given value.
@@ -21,19 +21,19 @@ public readonly struct Bool
/// .
private Bool(bool value)
{
- Value = value ? 1 : 0;
+ this.value = value ? 1 : 0;
}
///
public override bool Equals(object? obj)
{
- return obj is Bool x && Value == x.Value;
+ return obj is Bool x && this.value == x.value;
}
///
public override int GetHashCode()
{
- return Value.GetHashCode();
+ return this.value.GetHashCode();
}
///
@@ -94,24 +94,24 @@ public readonly struct Bool
///
/// The left instance.
/// The right instance.
- public static bool operator ==(Bool left, Bool right) => left.Value == right.Value;
+ public static bool operator ==(Bool left, Bool right) => left.value == right.value;
///
/// Checks whether or not two instances represent a different value.
///
/// The left instance.
/// The right instance.
- public static bool operator !=(Bool left, Bool right) => left.Value != right.Value;
+ public static bool operator !=(Bool left, Bool right) => left.value != right.value;
///
/// Converts a given instance to its corresponding value.
///
/// The input instance.
- public static implicit operator bool(Bool x) => x.Value != 0;
+ public static implicit operator bool(Bool x) => x.value != 0;
///
/// Converts a value to a corresponding instance.
///
/// The input value.
public static implicit operator Bool(bool x) => new(x);
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs
index 2257036a..5ae6f9dd 100644
--- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs
+++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -23,4 +23,4 @@ public partial struct Bool2
///
/// The value to use for the components of the new instance.
public static implicit operator Bool2(bool x) => new(x, x);
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs
index 35eee2fa..1e1b3c5d 100644
--- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs
+++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -49,4 +49,4 @@ public partial struct Bool3
///
/// The value to use for the components of the new instance.
public static implicit operator Bool3(bool x) => new(x, x, x);
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs
index 3694225d..fbcc45d4 100644
--- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs
+++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -94,4 +94,4 @@ public partial struct Bool4
///
/// The value to use for the components of the new instance.
public static implicit operator Bool4(bool x) => new(x, x, x, x);
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.cs
index 15bec764..4df36386 100644
--- a/src/ComputeSharp.Core/Primitives/Double/Double2.cs
+++ b/src/ComputeSharp.Core/Primitives/Double/Double2.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -44,4 +44,4 @@ public partial struct Double2
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator Float2(Double2 xy) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.cs
index aadd36e5..7a913297 100644
--- a/src/ComputeSharp.Core/Primitives/Double/Double3.cs
+++ b/src/ComputeSharp.Core/Primitives/Double/Double3.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -70,4 +70,4 @@ public partial struct Double3
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator Float3(Double3 xyz) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.cs
index 345e51a9..e17e3fce 100644
--- a/src/ComputeSharp.Core/Primitives/Double/Double4.cs
+++ b/src/ComputeSharp.Core/Primitives/Double/Double4.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -115,4 +115,4 @@ public partial struct Double4
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator Float4(Double4 xyzw) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.cs
index aa9a566f..bae3c788 100644
--- a/src/ComputeSharp.Core/Primitives/Float/Float2.cs
+++ b/src/ComputeSharp.Core/Primitives/Float/Float2.cs
@@ -1,4 +1,4 @@
-using System.Numerics;
+using System.Numerics;
#pragma warning disable CS0660, CS0661
@@ -58,4 +58,4 @@ public partial struct Float2
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator UInt2(Float2 xy) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.cs
index b934c43b..538a6000 100644
--- a/src/ComputeSharp.Core/Primitives/Float/Float3.cs
+++ b/src/ComputeSharp.Core/Primitives/Float/Float3.cs
@@ -1,4 +1,4 @@
-using System.Numerics;
+using System.Numerics;
#pragma warning disable CS0660, CS0661
@@ -84,4 +84,4 @@ public partial struct Float3
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator UInt3(Float3 xyz) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.cs
index 8796eda4..3cbe2622 100644
--- a/src/ComputeSharp.Core/Primitives/Float/Float4.cs
+++ b/src/ComputeSharp.Core/Primitives/Float/Float4.cs
@@ -1,4 +1,4 @@
-using System.Numerics;
+using System.Numerics;
#pragma warning disable CS0660, CS0661
@@ -129,4 +129,4 @@ public partial struct Float4
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static explicit operator UInt4(Float4 xyzw) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.cs
index 2093f902..b9ce5e58 100644
--- a/src/ComputeSharp.Core/Primitives/Int/Int2.cs
+++ b/src/ComputeSharp.Core/Primitives/Int/Int2.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -44,4 +44,4 @@ public partial struct Int2
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double2(Int2 xy) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.cs
index cdfd9641..90c1b94c 100644
--- a/src/ComputeSharp.Core/Primitives/Int/Int3.cs
+++ b/src/ComputeSharp.Core/Primitives/Int/Int3.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -70,4 +70,4 @@ public partial struct Int3
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double3(Int3 xyz) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.cs
index d5f44c49..41e6fb60 100644
--- a/src/ComputeSharp.Core/Primitives/Int/Int4.cs
+++ b/src/ComputeSharp.Core/Primitives/Int/Int4.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -115,4 +115,4 @@ public partial struct Int4
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double4(Int4 xyzw) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/MatrixIndex.cs b/src/ComputeSharp.Core/Primitives/MatrixIndex.cs
index d5044d3c..2b2bfd1c 100644
--- a/src/ComputeSharp.Core/Primitives/MatrixIndex.cs
+++ b/src/ComputeSharp.Core/Primitives/MatrixIndex.cs
@@ -1,4 +1,4 @@
-namespace ComputeSharp;
+namespace ComputeSharp;
///
/// A type indicating a base-1 index into a matrix type. This can be used to extract references to swizzled vectors within a given matrix value.
@@ -93,4 +93,4 @@ public enum MatrixIndex
/// The fourth item in the fourth row.
///
M44
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs
index 782624e7..48ef484e 100644
--- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs
+++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -44,4 +44,4 @@ public partial struct UInt2
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double2(UInt2 xy) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs
index 88fab923..65c4f468 100644
--- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs
+++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -70,4 +70,4 @@ public partial struct UInt3
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double3(UInt3 xyz) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs
index 3be7d78d..a7b776b1 100644
--- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs
+++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS0660, CS0661
+#pragma warning disable CS0660, CS0661
namespace ComputeSharp;
@@ -115,4 +115,4 @@ public partial struct UInt4
/// The input value to cast.
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static implicit operator Double4(UInt4 xyzw) => default;
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Properties/Polyfills/UnscopedRefAttribute.cs b/src/ComputeSharp.Core/Properties/Polyfills/UnscopedRefAttribute.cs
index c57a296a..f6f5776c 100644
--- a/src/ComputeSharp.Core/Properties/Polyfills/UnscopedRefAttribute.cs
+++ b/src/ComputeSharp.Core/Properties/Polyfills/UnscopedRefAttribute.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Diagnostics.CodeAnalysis;
diff --git a/src/ComputeSharp.D2D1.NetStandard/System/Buffers/BitOperations.cs b/src/ComputeSharp.D2D1.NetStandard/System/Buffers/BitOperations.cs
index a8f36d90..fa177274 100644
--- a/src/ComputeSharp.D2D1.NetStandard/System/Buffers/BitOperations.cs
+++ b/src/ComputeSharp.D2D1.NetStandard/System/Buffers/BitOperations.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
namespace ComputeSharp.D2D1.NetStandard.System.Buffers;
diff --git a/src/ComputeSharp.D2D1.NetStandard/System/Diagnostics.CodeAnalysis/DoesNotReturnAttribute.cs b/src/ComputeSharp.D2D1.NetStandard/System/Diagnostics.CodeAnalysis/DoesNotReturnAttribute.cs
index 1c6a222e..1c661961 100644
--- a/src/ComputeSharp.D2D1.NetStandard/System/Diagnostics.CodeAnalysis/DoesNotReturnAttribute.cs
+++ b/src/ComputeSharp.D2D1.NetStandard/System/Diagnostics.CodeAnalysis/DoesNotReturnAttribute.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
diff --git a/src/ComputeSharp.D2D1.NetStandard/System/Math.cs b/src/ComputeSharp.D2D1.NetStandard/System/Math.cs
index 7885d997..8d011f9a 100644
--- a/src/ComputeSharp.D2D1.NetStandard/System/Math.cs
+++ b/src/ComputeSharp.D2D1.NetStandard/System/Math.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
namespace ComputeSharp.D2D1.NetStandard.System;
@@ -21,7 +21,7 @@ internal static class Math
{
return min;
}
-
+
if (value > max)
{
return max;
diff --git a/src/ComputeSharp.D2D1.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/ComputeSharp.D2D1.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
index b7a2c4ee..38812bf3 100644
--- a/src/ComputeSharp.D2D1.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
+++ b/src/ComputeSharp.D2D1.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.InteropServices;
namespace ComputeSharp.D2D1.NetStandard.System.Runtime.CompilerServices;
@@ -14,5 +14,8 @@ internal static class RuntimeHelpers
/// The type to associate the memory to.
/// The size in byte of the memory to allocate.
/// A pointer to the allocated memory.
- public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size);
+ public static IntPtr AllocateTypeAssociatedMemory(Type type, int size)
+ {
+ return Marshal.AllocHGlobal(size);
+ }
}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.NetStandard/System/Text/EncodingExtensions.cs b/src/ComputeSharp.D2D1.NetStandard/System/Text/EncodingExtensions.cs
index 4f9f5f47..9be7852d 100644
--- a/src/ComputeSharp.D2D1.NetStandard/System/Text/EncodingExtensions.cs
+++ b/src/ComputeSharp.D2D1.NetStandard/System/Text/EncodingExtensions.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.InteropServices;
using System.Text;
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.Syntax.cs
index 93ef05c5..ac2bead8 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.Syntax.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Text;
using ComputeSharp.D2D1.SourceGenerators.Models;
@@ -101,4 +101,4 @@ partial class D2DPixelShaderSourceGenerator
.WithBody(methodBlock);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs
index b346673b..65a2f074 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Runtime.CompilerServices;
@@ -188,4 +188,4 @@ partial class D2DPixelShaderSourceGenerator
return bytecode;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs
index 0d96cb7e..0e653800 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -119,4 +119,4 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
context.AddSource($"{item.Hierarchy.FilenameHint}.{item.BytecodeInfo.MethodName}.g.cs", text);
});
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs
index 50d4843b..a0cf5ce7 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs
@@ -45,4 +45,4 @@ public sealed class InvalidAssemblyLevelCompileOptionsAnalyzer : DiagnosticAnaly
}
});
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs
index 1b599546..55caff9d 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs
@@ -45,4 +45,4 @@ public sealed class InvalidD2DResourceTextureIndexUseAnalyzer : DiagnosticAnalyz
}
}, SymbolKind.Field);
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
index 4dceab78..48bd1fd5 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
@@ -1,4 +1,4 @@
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis;
namespace ComputeSharp.SourceGeneration.Diagnostics;
@@ -856,4 +856,4 @@ partial class DiagnosticDescriptors
isEnabledByDefault: true,
description: "A D2D1 shader must be annotated with the [D2DInputCount] attribute.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/SuppressionDescriptors.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/SuppressionDescriptors.cs
index b9b3864b..1b4fe29e 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/SuppressionDescriptors.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/SuppressionDescriptors.cs
@@ -1,4 +1,4 @@
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators.Diagnostics;
@@ -14,4 +14,4 @@ internal static class SuppressionDescriptors
id: "CMPSD2DSPR0001",
suppressedDiagnosticId: "CS0649",
justification: "Fields of type D2D1ResourceTexture1D, D2D1ResourceTexture2D and D2D1ResourceTexture3D are implicitly mapped to resource texture objects into the resulting D2D1 pixel shader for their containing type, and don't need to be initialized");
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs
index 6a34ff49..d7c3ba60 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Mappings;
using Microsoft.CodeAnalysis;
@@ -68,4 +68,4 @@ public sealed class D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor :
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs
index 3ba67836..9cfecca8 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.D2D1.__Internals;
+using ComputeSharp.D2D1.__Internals;
using ComputeSharp.SourceGeneration.Helpers;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -49,4 +49,4 @@ partial class ID2D1ShaderGenerator
LiteralExpression(SyntaxKind.StringLiteralExpression, hlslSourceLiteralExpression)))));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
index f9687982..8faf1d54 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -64,13 +64,13 @@ partial class ID2D1ShaderGenerator
out ImmutableArray<(string Name, string HlslType, int Index)> resourceTextureFields);
// Explore the syntax tree and extract the processed info
- var semanticModelProvider = new SemanticModelProvider(compilation);
- var (entryPoint, processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition);
- var staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition);
+ SemanticModelProvider semanticModelProvider = new(compilation);
+ (string entryPoint, ImmutableArray<(string Signature, string Definition)> processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition);
+ ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition);
// Process the discovered types and constants
- var declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods);
- var definedConstants = GetDefinedConstants(constantDefinitions);
+ ImmutableArray<(string Name, string Definition)> declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods);
+ ImmutableArray<(string Name, string Value)> definedConstants = GetDefinedConstants(constantDefinitions);
// Check whether the scene position is required
bool requiresScenePosition = GetD2DRequiresScenePositionInfo(structDeclarationSymbol);
@@ -111,7 +111,7 @@ partial class ID2D1ShaderGenerator
using ImmutableArrayBuilder<(string, string)> values = ImmutableArrayBuilder<(string, string)>.Rent();
using ImmutableArrayBuilder<(string, string, int)> resourceTextures = ImmutableArrayBuilder<(string, string, int)>.Rent();
- foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType())
+ foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType())
{
if (fieldSymbol.IsStatic)
{
@@ -205,9 +205,9 @@ partial class ID2D1ShaderGenerator
needsD2D1RequiresScenePosition = false;
- foreach (var fieldDeclaration in structDeclaration.Members.OfType())
+ foreach (FieldDeclarationSyntax fieldDeclaration in structDeclaration.Members.OfType())
{
- foreach (var variableDeclarator in fieldDeclaration.Declaration.Variables)
+ foreach (VariableDeclaratorSyntax variableDeclarator in fieldDeclaration.Declaration.Variables)
{
IFieldSymbol fieldSymbol = (IFieldSymbol)semanticModel.For(variableDeclarator).GetDeclaredSymbol(variableDeclarator)!;
@@ -319,7 +319,7 @@ partial class ID2D1ShaderGenerator
needsD2D1RequiresScenePosition |= shaderSourceRewriter.NeedsD2DRequiresScenePositionAttribute;
// Emit the extracted local functions first
- foreach (var localFunction in shaderSourceRewriter.LocalFunctions)
+ foreach (KeyValuePair localFunction in shaderSourceRewriter.LocalFunctions)
{
methods.Add((
localFunction.Value.AsDefinition().NormalizeWhitespace(eol: "\n").ToFullString(),
@@ -362,10 +362,10 @@ partial class ID2D1ShaderGenerator
{
using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent();
- foreach (var constant in constantDefinitions)
+ foreach (KeyValuePair constant in constantDefinitions)
{
- var ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
- var constantName = $"__{ownerTypeName}__{constant.Key.Name}";
+ string ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
+ string constantName = $"__{ownerTypeName}__{constant.Key.Name}";
builder.Add((constantName, constant.Value));
}
@@ -389,18 +389,21 @@ partial class ID2D1ShaderGenerator
{
using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent();
- IReadOnlyCollection invalidTypes;
+ IReadOnlyCollection invalidTypes;
// Process the discovered types
- foreach (var type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes))
+ foreach (INamedTypeSymbol type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes))
{
- var structType = type.GetFullMetadataName().ToHlslIdentifierName();
- var structDeclaration = StructDeclaration(structType);
+ string structType = type.GetFullMetadataName().ToHlslIdentifierName();
+ StructDeclarationSyntax structDeclaration = StructDeclaration(structType);
// Declare the fields of the current type
- foreach (var field in type.GetMembers().OfType())
+ foreach (IFieldSymbol field in type.GetMembers().OfType())
{
- if (field.IsStatic) continue;
+ if (field.IsStatic)
+ {
+ continue;
+ }
INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type;
@@ -423,7 +426,7 @@ partial class ID2D1ShaderGenerator
}
// Declare the methods of the current type
- foreach (var method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type)))
+ foreach (KeyValuePair method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type)))
{
structDeclaration = structDeclaration.AddMembers(method.Value);
}
@@ -453,7 +456,7 @@ partial class ID2D1ShaderGenerator
/// The input instance to process.
private static void DetectAndReportInvalidPropertyDeclarations(ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol)
{
- foreach (var memberSymbol in structDeclarationSymbol.GetMembers())
+ foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
{
// Detect properties that are not explicit interface implementations
if (memberSymbol is IPropertySymbol { ExplicitInterfaceImplementations.IsEmpty: true })
@@ -530,13 +533,13 @@ partial class ID2D1ShaderGenerator
void AppendLF()
{
- hlslBuilder.Append('\n');
+ _ = hlslBuilder.Append('\n');
}
void AppendLineAndLF(string text)
{
- hlslBuilder.Append(text);
- hlslBuilder.Append('\n');
+ _ = hlslBuilder.Append(text);
+ _ = hlslBuilder.Append('\n');
}
// Header
@@ -574,7 +577,7 @@ partial class ID2D1ShaderGenerator
{
AppendLF();
- foreach (var (name, value) in definedConstants)
+ foreach ((string name, string value) in definedConstants)
{
AppendLineAndLF($"#define {name} {value}");
}
@@ -585,7 +588,7 @@ partial class ID2D1ShaderGenerator
{
AppendLF();
- foreach (var field in staticFields)
+ foreach ((string Name, string TypeDeclaration, string? Assignment) field in staticFields)
{
if (field.Assignment is string assignment)
{
@@ -599,7 +602,7 @@ partial class ID2D1ShaderGenerator
}
// Declared types
- foreach (var (_, typeDefinition) in declaredTypes)
+ foreach ((string _, string typeDefinition) in declaredTypes)
{
AppendLF();
AppendLineAndLF(typeDefinition);
@@ -610,14 +613,14 @@ partial class ID2D1ShaderGenerator
{
AppendLF();
- foreach (var (fieldName, fieldType) in valueFields)
+ foreach ((string fieldName, string fieldType) in valueFields)
{
AppendLineAndLF($"{fieldType} {fieldName};");
}
}
// Resource textures
- foreach (var (fieldName, fieldType, index) in resourceTextureFields)
+ foreach ((string fieldName, string fieldType, int index) in resourceTextureFields)
{
AppendLF();
@@ -626,14 +629,14 @@ partial class ID2D1ShaderGenerator
}
// Forward declarations
- foreach (var (forwardDeclaration, _) in processedMethods)
+ foreach ((string forwardDeclaration, string _) in processedMethods)
{
AppendLF();
AppendLineAndLF(forwardDeclaration);
}
// Captured methods
- foreach (var (_, method) in processedMethods)
+ foreach ((string _, string method) in processedMethods)
{
AppendLF();
AppendLineAndLF(method);
@@ -646,4 +649,4 @@ partial class ID2D1ShaderGenerator
return hlslBuilder.ToString();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputCountMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputCountMethod.Syntax.cs
index 80028804..92326c75 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputCountMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputCountMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.D2D1.__Internals;
+using ComputeSharp.D2D1.__Internals;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
@@ -35,4 +35,4 @@ partial class ID2D1ShaderGenerator
.WithBody(Block(ReturnStatement(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(inputCount)))));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs
index fcf9c5cc..6bb75339 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.D2D1.__Internals;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -78,4 +78,4 @@ partial class ID2D1ShaderGenerator
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs
index b6e85408..c6e23620 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
@@ -169,4 +169,4 @@ partial class ID2D1ShaderGenerator
combinedInputTypes = combinedBuilder.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.Syntax.cs
index 427d89b7..02b0cd88 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.D2D1.__Internals;
+using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.SourceGenerators.Models;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -48,4 +48,4 @@ partial class ID2D1ShaderGenerator
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)info.ChannelDepth))))));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs
index f0af8afe..3c746fb1 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.SourceGeneration.Extensions;
+using ComputeSharp.SourceGeneration.Extensions;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -59,4 +59,4 @@ partial class ID2D1ShaderGenerator
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.Syntax.cs
index b583ae38..e5d9b082 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.D2D1.__Internals;
+using ComputeSharp.D2D1.__Internals;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
@@ -33,4 +33,4 @@ partial class ID2D1ShaderGenerator
.WithBody(Block(ReturnStatement(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)pixelOptions)))));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs
index d1f52c2c..18102a14 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs
@@ -1,4 +1,4 @@
-using ComputeSharp.SourceGeneration.Extensions;
+using ComputeSharp.SourceGeneration.Extensions;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -28,4 +28,4 @@ partial class ID2D1ShaderGenerator
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
index fc8709d8..0c1a3598 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Helpers;
@@ -124,6 +124,7 @@ partial class ID2D1ShaderGenerator
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"),
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"))));
}
+
break;
}
}
@@ -131,4 +132,4 @@ partial class ID2D1ShaderGenerator
return statements.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
index fea4c8b3..ab8d460b 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Globalization;
using System.Linq;
using System.Text;
@@ -189,7 +189,7 @@ partial class ID2D1ShaderGenerator
///
/// A mapping of precomputed literals for all values.
///
- private static readonly string[] formattedBytes =
+ private static readonly string[] FormattedBytes =
{
"0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x0A", "0x0B", "0x0C", "0x0D", "0x0E", "0x0F",
"0x10", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1A", "0x1B", "0x1C", "0x1D", "0x1E", "0x1F",
@@ -218,15 +218,15 @@ partial class ID2D1ShaderGenerator
{
using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent();
- builder.AddRange(formattedBytes[bytecode[0]].AsSpan());
+ builder.AddRange(FormattedBytes[bytecode[0]].AsSpan());
foreach (byte b in bytecode.Slice(1))
{
builder.AddRange(", ".AsSpan());
- builder.AddRange(formattedBytes[b].AsSpan());
+ builder.AddRange(FormattedBytes[b].AsSpan());
}
return builder.ToString();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
index 624f9b69..8c684364 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Linq;
@@ -191,4 +191,4 @@ partial class ID2D1ShaderGenerator
return message.NormalizeToSingleLine();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
index aaace9de..381e0b6d 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Helpers;
@@ -149,6 +149,7 @@ partial class ID2D1ShaderGenerator
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"),
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"))));
}
+
break;
}
}
@@ -166,4 +167,4 @@ partial class ID2D1ShaderGenerator
return statements.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs
index fa90409d..e3f23d17 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -72,7 +72,7 @@ partial class ID2D1ShaderGenerator
else if (fieldSymbol.Type.IsUnmanagedType)
{
// Custom struct type defined by the user
- foreach (var fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), rawDataOffset))
+ foreach (FieldInfo fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), rawDataOffset))
{
yield return fieldInfo;
}
@@ -117,7 +117,7 @@ partial class ID2D1ShaderGenerator
{
// For scalar, vector and linear matrix types, serialize the value normally.
// Only the initial alignment needs to be considered, while data is packed.
- var (fieldSize, fieldPack) = HlslKnownSizes.GetTypeInfo(typeName);
+ (int fieldSize, int fieldPack) = HlslKnownSizes.GetTypeInfo(typeName);
// Check if the current type is a matrix type with more than one row. In this
// case, each row is aligned as if it was a separate array, so the start of
@@ -132,7 +132,7 @@ partial class ID2D1ShaderGenerator
builder.Add(startingRawDataOffset);
- rawDataOffset = startingRawDataOffset + fieldPack * columns;
+ rawDataOffset = startingRawDataOffset + (fieldPack * columns);
}
return new FieldInfo.NonLinearMatrix(
@@ -160,4 +160,4 @@ partial class ID2D1ShaderGenerator
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.Syntax.cs
index 952fb95a..b2413cfe 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Helpers;
@@ -146,4 +146,4 @@ partial class ID2D1ShaderGenerator
return statements.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs
index 7813b71e..55821ef0 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Immutable;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
@@ -49,6 +49,7 @@ partial class ID2D1ShaderGenerator
inputDescriptionsBuilder.Add(new InputDescription((uint)index, filter, levelOfDetailCount));
}
+
break;
default:
break;
@@ -96,4 +97,4 @@ partial class ID2D1ShaderGenerator
inputDescriptions = inputDescriptionsBuilder.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.Syntax.cs
index 6ebafc2c..805f7726 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.Syntax.cs
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Helpers;
@@ -137,4 +137,4 @@ partial class ID2D1ShaderGenerator
return statements.ToImmutable();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs
index f1bf3151..4c6944b0 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Immutable;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
@@ -33,7 +33,7 @@ partial class ID2D1ShaderGenerator
{
using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = ImmutableArrayBuilder<(int? Index, int Rank)>.Rent();
- foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType())
+ foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType())
{
// Only look for fields of a named type symbol (diagnostics is emitted by the HLSL rewriter if it's not the case).
// We're only looking for instance fields of unmanaged types in this case (as resource textures are structs).
@@ -133,4 +133,4 @@ partial class ID2D1ShaderGenerator
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs
index 6d1c78fc..e0a8ca76 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using ComputeSharp.SourceGeneration.Models;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -73,4 +73,4 @@ partial class ID2D1ShaderGenerator
return hierarchyInfo.GetSyntax(methodDeclaration.AddAttributeLists(attributes.ToArray()));
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
index 6dbd90ca..01ee8226 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -301,7 +301,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
});
// Get the LoadInputDescriptions() info (hierarchy and input descriptions)
- IncrementalValuesProvider<((HierarchyInfo Hierarchy, InputDescriptionsInfo InputDescriptions) Info, bool CanUseSkipLocalsInit) > inputDescriptionsInfo =
+ IncrementalValuesProvider<((HierarchyInfo Hierarchy, InputDescriptionsInfo InputDescriptions) Info, bool CanUseSkipLocalsInit)> inputDescriptionsInfo =
shaderInfoWithErrors
.Select(static (item, _) => (item.Hierarchy, item.InputDescriptions))
.Combine(canUseSkipLocalsInit);
@@ -329,4 +329,4 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetPixelOptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs
index 78098a82..00885bbe 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Reflection;
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.D2D1;
@@ -12,11 +12,11 @@ partial class HlslKnownKeywords
static partial void AddKnownKeywords(ICollection knownKeywords)
{
// D2D1 intrinsics method names
- foreach (var method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static))
+ foreach (MethodInfo? method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static))
{
string name = method.GetCustomAttribute()?.Name ?? method.Name;
knownKeywords.Add(name);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs
index c99d7315..24ae776a 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs
@@ -26,7 +26,7 @@ partial class HlslKnownMethods
static partial void AddKnownMethods(IDictionary knownMethods)
{
// Programmatically load mappings from the D2D1 class as well
- foreach (var method in
+ foreach (MethodInfo? method in
from method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static)
group method by method.Name
into groups
@@ -50,4 +50,4 @@ partial class HlslKnownMethods
[$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Sample({typeof(Float3).FullName})"] = null
};
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs
index 578bf8a5..af7c3fb6 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace ComputeSharp.SourceGeneration.Mappings;
@@ -28,4 +28,4 @@ partial class HlslKnownProperties
["ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Depth"] = (3, 2)
};
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs
index 5569583a..1ebec150 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using ComputeSharp.SourceGeneration.Extensions;
using Microsoft.CodeAnalysis;
@@ -54,4 +54,4 @@ partial class HlslKnownTypes
// The captured field is of a custom struct type
return typeName.ToHlslIdentifierName();
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1PixelShaderSourceInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1PixelShaderSourceInfo.cs
index 2a3e64dc..20a81557 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1PixelShaderSourceInfo.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1PixelShaderSourceInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
@@ -19,10 +19,16 @@ internal sealed record D2D1PixelShaderSourceInfo(
ImmutableArray Diagnostcs)
{
///
- public bool Equals(D2D1PixelShaderSourceInfo? obj) => Comparer.Default.Equals(this, obj);
+ public bool Equals(D2D1PixelShaderSourceInfo? obj)
+ {
+ return Comparer.Default.Equals(this, obj);
+ }
///
- public override int GetHashCode() => Comparer.Default.GetHashCode(this);
+ public override int GetHashCode()
+ {
+ return Comparer.Default.GetHashCode(this);
+ }
///
/// An implementation for .
@@ -46,4 +52,4 @@ internal sealed record D2D1PixelShaderSourceInfo(
x.Diagnostcs.SequenceEqual(y.Diagnostcs);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
index 643889ba..f79ebb90 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
@@ -31,10 +31,16 @@ internal sealed record D2D1ShaderInfo(
ImmutableArray Diagnostcs)
{
///
- public bool Equals(D2D1ShaderInfo? obj) => Comparer.Default.Equals(this, obj);
+ public bool Equals(D2D1ShaderInfo? obj)
+ {
+ return Comparer.Default.Equals(this, obj);
+ }
///
- public override int GetHashCode() => Comparer.Default.GetHashCode(this);
+ public override int GetHashCode()
+ {
+ return Comparer.Default.GetHashCode(this);
+ }
///
/// An implementation for .
@@ -70,4 +76,4 @@ internal sealed record D2D1ShaderInfo(
x.Diagnostcs.SequenceEqual(y.Diagnostcs);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/DispatchDataInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/DispatchDataInfo.cs
index e99830bb..c8aa95ed 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Models/DispatchDataInfo.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/DispatchDataInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
@@ -14,10 +14,16 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
internal sealed record DispatchDataInfo(ImmutableArray FieldInfos, int ConstantBufferSizeInBytes)
{
///
- public bool Equals(DispatchDataInfo? obj) => Comparer.Default.Equals(this, obj);
+ public bool Equals(DispatchDataInfo? obj)
+ {
+ return Comparer.Default.Equals(this, obj);
+ }
///
- public override int GetHashCode() => Comparer.Default.GetHashCode(this);
+ public override int GetHashCode()
+ {
+ return Comparer.Default.GetHashCode(this);
+ }
///
/// An implementation for .
@@ -39,4 +45,4 @@ internal sealed record DispatchDataInfo(ImmutableArray FieldInfos, in
x.ConstantBufferSizeInBytes == y.ConstantBufferSizeInBytes;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/EmbeddedBytecodeInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/EmbeddedBytecodeInfo.cs
index 2a901c51..1d65fbc8 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Models/EmbeddedBytecodeInfo.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/EmbeddedBytecodeInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
@@ -16,10 +16,16 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, D2D1CompileOptions? CompileOptions, ImmutableArray Bytecode)
{
///
- public bool Equals(EmbeddedBytecodeInfo? obj) => Comparer.Default.Equals(this, obj);
+ public bool Equals(EmbeddedBytecodeInfo? obj)
+ {
+ return Comparer.Default.Equals(this, obj);
+ }
///
- public override int GetHashCode() => Comparer.Default.GetHashCode(this);
+ public override int GetHashCode()
+ {
+ return Comparer.Default.GetHashCode(this);
+ }
///
/// An