-
Notifications
You must be signed in to change notification settings - Fork 252
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
Access Interface through pointer #5677
Comments
The following two codes are not same,
In order to be same, it should be either one of the followings.
or
The first case, however, is not supported. |
Ok I see. I guess this example was wrong then. My goal is to be able to access an Interface just via an address. struct MyData {
ITest* ptr;
};
StructuredBuffer<MyData> data; or [[vk::push_constant]] ITest* pc; |
I think what you want to do is "Link-time type" described in the Slang User's document. The reason why I said it is that |
I don't think so, the main point is really to allow to access a buffer that contains interface implementations through a pointer. struct Mesh {
// some data
IMaterial* material;
};
StructuredBuffer<Mesh> meshes; In this example this would allow to bundle the material with the mesh data // like so
meshes[0].material.foo()
// instead of
StructuredBuffer<IMaterial> materials;
materials[meshes[0].material_idx].foo() |
doing something like this crashes the compiler without any warnings or errors. struct Input {
Ptr<uint8_t> sensors;
}
[[vk::push_constant]] Input pc;
[shader("vertex")]
float4 vertexMain(uint vid : SV_VertexID, uint iid : SV_InstanceID) : SV_Position
{
let sensor = Ptr<ISensor>(pc.sensors);
return sensor.splat(float4(1.0))
} |
It is possible to access an Interface through a StructuredBuffer, though it is not possible to do this through a pointer.
There should not really be a big difference between these usecases, so I hope this can be allowed soon.
The text was updated successfully, but these errors were encountered: