Say I have the following:
Texture2D texture : register(t0);
SamplerState sampler : register(s0);
export float4 Sample(float2 uv) { return texture.Sample(sampler, uv); }
export float4 Multiply(float4 lhs, float4 rhs) { return lhs * rhs; }
Can I use such a shader library and shader linking to implement Multiply(Sample_0(uv), Sample_1(uv))
, where Sample_n
is an instance of the Sample
method remapped to use texture and sampler register n
(so each call samples its own texture)?
The issue is that the API exposes resource remapping on ID3D11ModuleInstance
, but the ID3D11FunctionLinkingGraph::CallFunction
function takes a ID3D11Module
as a parameter, so I don't see how two different calls could be associated with two different module instances of the same module but with different remappings.
Yes you can.
CallFunction
takes ID3D11Module
just for the function signature (validation purposes), but it also takes an optional pModuleInstanceNamespace
, which allows you to specify the specific module instance namespace you will link to.
The FLG interface doesn't actually link to a specific module instance until you call Link. At that point it links to the module instances that have been added to the linker.
That way, one FLG may link to different module instances in different scenarios.
Also the module instances need not be created and set up in advance of graph construction.