[PATCH vkd3d 3/5] vkd3d-shader/spirv: Send descriptor offsets via a shader parameter.

Conor McCarthy cmccarthy at codeweavers.com
Mon Nov 29 06:58:45 CST 2021


November 27, 2021 10:02 PM, "Henri Verbeet" <hverbeet at gmail.com> wrote:

> Something along those lines. I think
> vkd3d_dxbc_compiler_get_constant_uint() should work fine for arrays,
> the caller can just pass something like
> "parameter->u.immediate_constant.u.u32_array[index]". We'd want an
> indexed variant of vkd3d_dxbc_compiler_emit_uint_shader_parameter()
> though, which we could then use in
> vkd3d_dxbc_compiler_get_descriptor_index().
> 
>> I don't see a need to support specialisation constant arrays. We can just emit a compiler error if
>> the UINT32_ARRAY data type is specified for a specialisation constant.
> 
> We could, but it's weird in terms of API consistency. From the point
> of view of a user of the API, there doesn't seem to be a good reason
> specialisation constant arrays wouldn't/shouldn't/couldn't be
> supported. It doesn't seem terribly hard to add either.


I think the only reasonable way to use the array is similar to what I've already done, i.e. find the u32 array and store it in the compiler object, because the indexed value needs to be subtracted from the base register index in vkd3d_dxbc_compiler_get_descriptor_binding(). To load an offset value in vkd3d_dxbc_compiler_get_descriptor_index() as a variable id means adding extra SPIR-V for the subtraction, plus the overhead of finding the parameter each time a descriptor is accessed. It's a performance cost for no advantage.

We can't support specialisation constants for the offsets without the extra SPIR-V, but nothing is gained by supporting them. As a descriptor offset array would be the only possible specialisation constant array, any support for them without that would be dead code.

If what you've described is the only acceptable way to send descriptor offsets via shader parameters, then parameters aren't an efficient way to send the offsets.



More information about the wine-devel mailing list