Zig Version
0.17.0-dev.957+53c670f46
Steps to Reproduce, Observed Behavior, and Expected Behavior
I expected this test to pass:
constSampler=@SpirvType(.sampler);constSampler2=@SpirvType(.sampler);comptimeassert(Sampler==Sampler2);However, SPIRV types are currently considered to be unique. This issue is partially resolved by #35914, but that fix isn't enough to get the test case passing.
I believe that this is because each type is given a unique name in zirReifySpirvType:
constname=tryip.getOrPutStringFmt(gpa,io,pt.tid,"{f}__SpirvType_{d}",.{block.type_name_ctx.fmt(ip),@intFromEnum(inst)},.no_embedded_nulls,);If you log the types with @compileLog, you can see the unique names:
@as(type,spirv.Sampler__SpirvType_12)@as(type,spirv.Sampler2__SpirvType_17)I decided not to PR a fix since it's possible I'm misunderstanding the situation and this is intentional, I haven't dug into the SPIRV backend much yet.
Assuming this isn't desirable, I think we should rework zirReifySpirvType to look more like zirVectorType--ie it should only store its input parameters on the resulting type--and then add some coverage for type equality to test/behavior/spirv.zig.
CC @alichraghi