Is it possible to pass one custom struct to another?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- computer-graphics
Research direction
The issue names no repository file, test, or entry point. Start by tracing the ReadWriteBuffer constraint and shader struct handling; done means establishing whether nested structs with Runner references are supported and documenting a confirmed workaround or limitation.
Written by the indexing model from the issue text.
Description
I'm trying to port some C# code to work on the GPU with the hope of coming up with solutions to all the porting problems I'll encounter when I tackle the code I want to run on the GPU.
Some issues I've overcome easily, i.e. Enums (still, it would be awesome if it wasn't necessary to convert to ints). Others are a little harder, i.e. a way to handle strings (I have a plan in mind using an ArrayPool approach and storing the values in a unit array, wish shaders supported byte arrays).
The one I'm stuck on though is passing a struct to another, i.e.
[AutoConstructor]
public partial struct Runner
{
private ReadWriteBuffer<SecondaryStruct> secondaryBuffer;
}
public struct SecondaryStruct
{
private Runner runner;
public void Init(Runner runner)
{
this.runner = runner;
}
}
I get a warning:
CS8377 The type 'SecondaryStruct' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'ReadWriteBuffer<T>' ComputeShaderTest
Is there a way to work around this issue? i.e. somehow make Runner a global variable that I can access within SecondaryStruct?
By the way, an amazing library you and everyone who has contributed have put together here. Thanks for all the hard effort that you've put into it.
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 148
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Sergio0694/ComputeSharp
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Sergio0694/ComputeSharp#936 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Sergio0694/ComputeSharp#931 ·
-
D2D1: D2D.SampleInputAtOffset with a compound offset expression silently samples wrong coordinates Openbug :bug: untriaged :toolbox:
Difficulty 3/5 1-2 days Newbie friendliness 75/100
Sergio0694/ComputeSharp#929 ·
-
PIX integration Openquestion :question: untriaged :toolbox:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Sergio0694/ComputeSharp#926 ·
-
CopyToAsync Openproposal :bulb: untriaged :toolbox:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Sergio0694/ComputeSharp#925 ·
All issues in Sergio0694/ComputeSharp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100