Could we perhaps do something like this? ``` .section ISGN dcl_param SV_Position, v0.xyz, float, POS dcl_param SV_IsFrontFace.x, v1.x, uint, FFACE dcl_param texcoord_2.xy, v2.xy dcl_param texcoord_3.xy, v3.xy, uint .section OSGN dcl_param SV_Target_0.xyzw, o0.xyzw, float, TARGET dcl_param SV_Target_1.xyzw, o1.xyzw, float, TARGET .section SHEX ... ```
I suppose the copy was done to avoid returning an oversized buffer, but I'd expect that the returned buffer won't be kept around for long, and the copy operation can be expensive. The caller can still decide to trim the buffer themselves, if so they wish.
Actually, a good chunk of the reason was simply avoiding the complication of transferring ownership of the underlying allocation from the string buffer to the vkd3d_shader_code structure. (I.e., vkd3d_shader_code_from_string_buffer(), essentially.)
Subject: [PATCH 2/3] vkd3d-shader/d3d-asm: Pass a string buffer to vkd3d_dxbc_binary_to_text().
Do we really need that? I guess this is mostly a consequence of the way vkd3d_dxbc_signature_to_text() works, but I'd prefer to keep that function internal to d3d_asm.c and call it from vkd3d_dxbc_binary_to_text().
While we're touching this, I'd suggest introducing a structure like this: ```c struct vsir_program { struct vkd3d_shader_desc shader_desc; struct vkd3d_shader_version shader_version; struct vkd3d_shader_instruction_array instructions; }; ``` and possibly getting rid of struct vkd3d_shader_instruction_array in the long run: ```c struct vsir_program { struct vkd3d_shader_desc shader_desc; struct vkd3d_shader_version shader_version;
struct vkd3d_shader_instruction *elements; size_t capacity; size_t count;
struct vkd3d_shader_param_allocator src_params; struct vkd3d_shader_param_allocator dst_params; struct vkd3d_shader_immediate_constant_buffer **icbs; size_t icb_capacity; size_t icb_count; }; ```