On Fri Apr 14 00:45:48 2023 +0000, Zebediah Figura wrote:
Thought: what if we tracked this per component instead? The current usage is close enough to RA / backend logic that I don't think it matters much from a design perspective, but I do suspect that in general this would make things a bit simpler, if only because it's a single array instead of several. In fact, we could potentially expand this in the future to store other per-component logic. One particularly salient thing that comes to mind is tracking whether we need to use a bool / int variable for sm1 uniforms—which itself determines the size of each register set. I think the downside is that request_object_registers_for_allocation() has to do a bit more work, but at least it's very clear and straightforward work. (Also, style nitpick: imbalanced braces.)
I don't like the idea very much. We often would want (in this MR patches and later) to iterate over the elements in a specific regset. These cases are easier now:
```c unsigned int i, count = var->data_type->reg_size[regset];
for (i = 0; i < count; ++i) { /* Directly use var->objects_usage[regset][i] */ } ```
than they would be if objects_usage is arranged per-component:
```c unsigned int k, i, count = hlsl_type_component_count(var->data_type);
i = 0; for (k = 0; k < count; ++k) { hlsl_type *component_type = hlsl_type_get_component_type(ctx, var->data_type, k);
if (regset != hlsl_type_get_regset(ctx, component_type)) continue
/* Use var->objects_usage[k], knowing that its offset in the regset is i. */
++i; } ```
In fact, we could potentially expand this in the future to store other per-component logic. One particularly salient thing that comes to mind is tracking whether we need to use a bool / int variable for sm1 uniforms—which itself determines the size of each register set.
I think that in this case we would rather store this information variable-wise. Since we only need the maximum register index used, and no information for every component, as we do for samplers (sampler_dim), and textures in SM 5 (we need to write a resource entry for every used component).