-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer and textures nodes review #355
Comments
Some notes on top of my head:
|
For reference, these were the things we used in Xenko/Ocean of air. the CopeResource, CopyCounter, ... (should be renderers) and two different indirect args buffers one for DrawIndirect and one for DispatchIndirect: I think that the Usage should stay as an enum and have defaults... also additional flags should be possible (Vertex/Index for compute buffers). interesting articles: |
|
I guess DynamicTexture nodes are also missing. |
@tebjan suggests to first introduce one Based on the usage of it we can post pone the introduction of more easy to use nodes. |
Low-level nodes:
Texture/Buffer (Advanced)
Texture2D
High-level nodes:
DataPointer/Box
|
SetTextureData, SetData, BufferData, InitialData, TextureIntitalData shall all use the same data type. We want to focus on a databox-like construct that doesn't treat the 1d case as special. We want to have a pinnable DataBox.
|
We now got:
Not yet:
these would need some investigation into use cases (cube textures, append/consume/counter buffer, auto draw with copy counter) and make the nodes according to them. |
Our buffer nodes need a review to be able to work with them easily.
Current state
DynamicBuffer
takingIHasMemory<T>
DynamicArrayBuffer
takingMutableArray<T>
StructuredBuffer
taking size/count, unordered access and outputs the command list?!Buffer.GetData
andBuffer.SetData
overloads, where only the ones withMutableArray<T>
are somehow usable but still hard as they require the command listCritic
We lack some needed ones
ArgumentBuffer
AppendBuffer
taking element size / countCounterBuffer
- not sure?Data access is inconsistent
IHasMemory<T>
(implemented bySpread<T>
andSpreadBuilder<T>
) - an idea taken from Consider adding {ReadOnly}SpanMemoryStream types dotnet/runtime#22838 where it is still calledIHasBuffer<T>
asBuffer<T>
was renamed toMemory<T>
later I think. One however can't connect other common types like arrays - I guess therefor the need forDynamicArrayBuffer
.GetData
andSetData
nodes useMutableArray<T>
,ref T
(makes no sense in VL) andDataPointer
- a tuple ofIntPtr
and length as well as the unhandy command list input an end-user has no clue about.Inconsistent in- and outputs
DynamicBuffer
has options forIsVertexBuffer
andIsIndexBuffer
while all the others don`t have thatProposal
IndexBuffer
,VertexBuffer
,StructuredBuffer
,AppendBuffer
,ArgumentBuffer
andCounterBuffer
Default
(read-write),Immutable
(read-only),Dynamic
(gpu: read-only, cpu: write-only) andStaging
(copy from gpu to cpu) - as long as they make sense and are supported, need to check API documentationStaging
have a data input of typeReadOnlyMemory<T>
and we provide an adaptive nodeAsReadOnlyMemory
takingIReadOnlyList<T>
with implementions forSpread<T>
,SpreadBuilder<T>
,MutableArray<T>
andImmutableArray<T>
Memory<Byte>
) and interpret the data in the shader. Feeding that to the buffer constructors usually results in a not supported exception as the graphics APIs require an element size of at least 4 bytes. This could be tackled by re-interpreting theMemory<Byte>
asMemory<Int>
- see https://stackoverflow.com/questions/54511330/how-can-i-cast-memoryt-to-another for an implementation. This raises the question why not useSpan<T>
? See discussion below.Buffer<T>
As long as VL doesn't support implict type conversions on links, a
AsReadOnlyMemory
node would need to be placed upstream. But this reliefs the node set to get blown up completely by all type combinations. The performance impact should be neglectable asReadOnlyMemory<T>
is a struct and therefor causes no allocation.Based on the above ideas we'd end up with the following node set:
Default
)Immutable
)Dynamic
)Staging
)IndexBuffer
ReadOnlyMemory<int>
VertexBuffer
StructuredBuffer
Unordered Access
inputArgumentBuffer
AppendBuffer
CounterBuffer
Staging
) would never have data input but only element count. Element size would gets infered fromT
.Dynamic
) hasApply
pin to write incoming dataStructuredBuffer (Default)
will haveUnorderAccess
set. If one wants read-only use 'Immutable' or 'Dynamic' versions.And further we'd provide
GetData
andSetData
process nodes (dealing with the command list internally) again withReadOnlyMemory<T>
as data type.Discussion
ReadOnlySpan<T>
as input - but we would first need to sort out the compiler exception in VL - because aref read-only struct
is not allowed to be used as a type argument. The tracing mechanism would need to filter them out - how costly would that be? Backend would need to check every hub it traces.The text was updated successfully, but these errors were encountered: