Minor tweaks to the HLSL shader output
このコミットが含まれているのは:
1 親
fad335642b
コミット
c2bc4e7850
7ファイル変更
+37
-62
検索条件に一致するファイルはありません
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains info on a shader buffer field.
|
||||
@@ -10,12 +8,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslBufferInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="fieldCsharpType">The type of the current field in the C# source.</param>
|
||||
/// <param name="fieldHlslType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldName">The name of the current field.</param>
|
||||
/// <param name="bufferIndex">The index of the current buffer field.</param>
|
||||
protected HlslBufferInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldCsharpType, fieldHlslType, fieldName)
|
||||
protected HlslBufferInfo(string fieldType, string fieldName, int bufferIndex)
|
||||
: base(fieldType, fieldName)
|
||||
{
|
||||
BufferIndex = bufferIndex;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains info on a shader field.
|
||||
@@ -11,25 +8,18 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CapturedFieldInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="fieldCsharpType">The type of the current field in the C# source.</param>
|
||||
/// <param name="fieldHlslType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldName">The name to use for the current field.</param>
|
||||
public CapturedFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName)
|
||||
public CapturedFieldInfo(string fieldType, string fieldName)
|
||||
{
|
||||
FieldCsharpType = fieldCsharpType.ToFriendlyString();
|
||||
FieldHlslType = fieldHlslType;
|
||||
FieldType = fieldType;
|
||||
FieldName = fieldName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the current field in the C# source.
|
||||
/// </summary>
|
||||
public string FieldCsharpType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the current field in the HLSL shader.
|
||||
/// </summary>
|
||||
public string FieldHlslType { get; }
|
||||
public string FieldType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for the current field.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
{
|
||||
@@ -11,12 +10,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ConstantBufferFieldInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="fieldCsharpType">The type of the current field in the C# source.</param>
|
||||
/// <param name="fieldHlslType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldName">The name of the current field.</param>
|
||||
/// <param name="bufferIndex">The index of the current constant buffer field.</param>
|
||||
public ConstantBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex)
|
||||
public ConstantBufferFieldInfo(string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldHlslType, fieldName, bufferIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
{
|
||||
@@ -11,12 +10,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadOnlyBufferFieldInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="fieldCsharpType">The type of the current field in the C# source.</param>
|
||||
/// <param name="fieldHlslType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldName">The name of the current field.</param>
|
||||
/// <param name="bufferIndex">The index of the current readonly buffer field.</param>
|
||||
public ReadOnlyBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex)
|
||||
public ReadOnlyBufferFieldInfo(string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldHlslType, fieldName, bufferIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
|
||||
|
||||
namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
{
|
||||
@@ -11,12 +10,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadWriteBufferFieldInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="fieldCsharpType">The type of the current field in the C# source.</param>
|
||||
/// <param name="fieldHlslType">The type of the current field in the HLSL shader.</param>
|
||||
/// <param name="fieldName">The name of the current field.</param>
|
||||
/// <param name="bufferIndex">The index of the current read write buffer field.</param>
|
||||
public ReadWriteBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex)
|
||||
public ReadWriteBufferFieldInfo(string fieldHlslType, string fieldName, int bufferIndex)
|
||||
: base(fieldHlslType, fieldName, bufferIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +1,37 @@
|
||||
/* ===============
|
||||
* AUTO GENERATED
|
||||
* ===============
|
||||
* This shader was created by ComputeSharp.
|
||||
* For info or issues: https://github.com/Sergio0694/ComputeSharp */
|
||||
// ================================================
|
||||
// AUTO GENERATED
|
||||
// ================================================
|
||||
// This shader was created by ComputeSharp.
|
||||
// See: https://github.com/Sergio0694/ComputeSharp.
|
||||
|
||||
{{!Captured variables buffer}}
|
||||
// Scalar/vector variables
|
||||
cbuffer _ : register(b0)
|
||||
{
|
||||
uint __x__; // Target X iterations
|
||||
uint __y__; // Target Y iterations
|
||||
uint __z__; // Target Z iterations
|
||||
uint __x;
|
||||
uint __y;
|
||||
uint __z;
|
||||
{{#FieldsList}}
|
||||
{{&FieldHlslType}} {{FieldName}};
|
||||
{{&FieldType}} {{FieldName}};
|
||||
{{/FieldsList}}
|
||||
}
|
||||
{{#BuffersList}}
|
||||
{{#IsConstantBuffer}}
|
||||
|
||||
{{!Constant buffer}}
|
||||
// {{&FieldCsharpType}} buffer "{{FieldName}}"
|
||||
cbuffer _{{FieldName}} : register(b{{BufferIndex}})
|
||||
{
|
||||
{{&FieldHlslType}} {{FieldName}}[2];
|
||||
{{&FieldType}} {{FieldName}}[2];
|
||||
}
|
||||
{{/IsConstantBuffer}}
|
||||
{{#IsReadOnlyBuffer}}
|
||||
|
||||
{{!Readonly buffer}}
|
||||
// {{&FieldCsharpType}} buffer "{{FieldName}}"
|
||||
{{&FieldHlslType}} {{FieldName}} : register(t{{BufferIndex}});
|
||||
{{&FieldType}} {{FieldName}} : register(t{{BufferIndex}});
|
||||
{{/IsReadOnlyBuffer}}
|
||||
{{#IsReadWriteBuffer}}
|
||||
|
||||
{{!Read write buffer}}
|
||||
// {{&FieldCsharpType}} buffer "{{FieldName}}"
|
||||
{{&FieldHlslType}} {{FieldName}} : register(u{{BufferIndex}});
|
||||
{{&FieldType}} {{FieldName}} : register(u{{BufferIndex}});
|
||||
{{/IsReadWriteBuffer}}
|
||||
{{/BuffersList}}
|
||||
{{#FunctionsList}}
|
||||
@@ -53,13 +49,11 @@ cbuffer _{{FieldName}} : register(b{{BufferIndex}})
|
||||
{{/LocalFunctionsList}}
|
||||
|
||||
{{!Shader entry point}}
|
||||
// Shader body
|
||||
[Shader("compute")]
|
||||
[NumThreads({{NumThreadsX}}, {{NumThreadsY}}, {{NumThreadsZ}})]
|
||||
void CSMain(uint3 {{ThreadsIdsVariableName}} : SV_DispatchThreadId)
|
||||
{
|
||||
if ({{ThreadsIdsVariableName}}.x < __x__ &&
|
||||
{{ThreadsIdsVariableName}}.y < __y__ &&
|
||||
{{ThreadsIdsVariableName}}.z < __z__) // Automatic bounds check
|
||||
if ({{ThreadsIdsVariableName}}.x < __x &&
|
||||
{{ThreadsIdsVariableName}}.y < __y &&
|
||||
{{ThreadsIdsVariableName}}.z < __z)
|
||||
{{&ShaderBody}}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType.GenericTypeArguments[0]);
|
||||
|
||||
this.hlslBuffersInfo.Add(new ConstantBufferFieldInfo(fieldType, typeName, fieldName, (int)this.constantBuffersCount++));
|
||||
this.hlslBuffersInfo.Add(new ConstantBufferFieldInfo(typeName, fieldName, (int)this.constantBuffersCount++));
|
||||
}
|
||||
else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType))
|
||||
{
|
||||
@@ -197,7 +197,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType);
|
||||
|
||||
this.hlslBuffersInfo.Add(new ReadOnlyBufferFieldInfo(fieldType, typeName, fieldName, (int)this.readOnlyBuffersCount++));
|
||||
this.hlslBuffersInfo.Add(new ReadOnlyBufferFieldInfo(typeName, fieldName, (int)this.readOnlyBuffersCount++));
|
||||
}
|
||||
else if (HlslKnownTypes.IsReadWriteBufferType(fieldType))
|
||||
{
|
||||
@@ -210,7 +210,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType);
|
||||
|
||||
this.hlslBuffersInfo.Add(new ReadWriteBufferFieldInfo(fieldType, typeName, fieldName, (int)this.readWriteBuffersCount++));
|
||||
this.hlslBuffersInfo.Add(new ReadWriteBufferFieldInfo(typeName, fieldName, (int)this.readWriteBuffersCount++));
|
||||
}
|
||||
else if (HlslKnownTypes.IsKnownScalarType(fieldType) || HlslKnownTypes.IsKnownVectorType(fieldType))
|
||||
{
|
||||
@@ -218,7 +218,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType);
|
||||
|
||||
this.fieldsInfo.Add(new CapturedFieldInfo(fieldType, typeName, fieldName));
|
||||
this.fieldsInfo.Add(new CapturedFieldInfo(typeName, fieldName));
|
||||
}
|
||||
else if (fieldType.IsDelegate() &&
|
||||
memberInfo.GetValue(shader) is Delegate func &&
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする