On 8/11/22 15:26, Francisco Casas wrote:
+static bool check_for_non_static_object_references(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
void *context)
Just a suggestion, I think "validate" would be a good word to use here.
+{
- unsigned int start, count;
- bool invalid = false;
- if (instr->type == HLSL_IR_RESOURCE_LOAD)
- {
struct hlsl_ir_resource_load *load = hlsl_ir_resource_load(instr);
invalid |= !hlsl_component_index_range_from_deref(ctx, &load->resource, &start, &count);
if (load->sampler.var)
invalid |= !hlsl_component_index_range_from_deref(ctx, &load->sampler, &start, &count);
- }
- else if (instr->type == HLSL_IR_LOAD && instr->data_type->type == HLSL_CLASS_OBJECT)
- {
struct hlsl_ir_load *load = hlsl_ir_load(instr);
invalid |= !hlsl_component_index_range_from_deref(ctx, &load->src, &start, &count);
Do we need this "else if" branch at all? In fact, won't this result in multiple messages if a dynamic dereference is used?
- }
- if (invalid)
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
"All object references must be determinable at compile time.");
I think it'd be helpful to name the specific expression that can't be resolved (and, along the same lines, to report resources and samplers separately).
- return invalid;
Shouldn't this always return false? We don't have any more work to do.
+}