On Thu Mar 7 06:43:09 2024 +0000, Francisco Casas wrote:
I am not fond of passing `dxbc_desc` as a parameter and use it far later to initialize the signatures in `sm6->p.program`. It may be hard to see from outside the function that `dxcb_desc` will be lending its signatures to `sm6->p.program` and be memset to 0. Also, any error before `dxbc_desc` lends the signatures to `sm6->p.program` leaks these signatures. How about creating `dxbc_desc` inside `sm6_parser_init()` right before lending the signatures? This would require passing the whole `compile_info` as a parameter and also move the 32-bit alignment there.
I would call that "transferring ownership" rather than "lending", and I don't think it's a problem in itself. You're right that I wasn't doing that properly, though, so hopefully now it is fixed. Now ownership of `dxbc_desc` remains with `vkd3d_shader_sm6_parser_create()`, which merely lends a reference to it to `sm6_parser_init()`, which in turn will decide whether to move ownership of the signatures to the program or not (but in both cases exactly one entity remains the owner of the signatures). Is that better for you?