Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › spirv › imageSampleImplicitLod Public Function imageSampleImplicitLod Doc Source 151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 pub fn imageSampleImplicitLod (
sampled_image : anytype ,
coordinate : ImageCoordinate (std .meta .Child (@TypeOf (sampled_image )), f32 ),
) @Vector (4 , ImageSampledType (std .meta .Child (@TypeOf (sampled_image )))) {
const SampledImage = switch (@typeInfo (@TypeOf (sampled_image ))) {
.pointer => |pointer | pointer .child ,
else => @compileError ("Expected a pointer to SPIR-V sampled image type, found '" ++ @typeName (@TypeOf (sampled_image )) ++ "'" ),
};
const Result = @Vector (4 , ImageSampledType (SampledImage ));
const image_info = switch (@typeInfo (SampledImage )) {
.spirv => |spirv | switch (spirv ) {
.sampled_image => |sampled_image_info | @typeInfo (sampled_image_info ).spirv .image ,
else => @compileError ("Expected SPIR-V sampled image type, found '" ++ @typeName (SampledImage ) ++ "'" ),
},
else => @compileError ("Expected SPIR-V sampled image type, found '" ++ @typeName (SampledImage ) ++ "'" ),
};
if (image_info .multisampled )
@compileError ("Can not implicitly sample a sampled image that was multisampled" );
// TOOD: If buffer dim is added, throw a compile error if the dimension is a buffer.
return asm volatile (
\\%loaded_sampler = OpLoad %SampledImage %sampled_image
\\%ret = OpImageSampleImplicitLod %Result %loaded_sampler %coordinate
: [ret ] "" (-> Result ),
: [SampledImage ] "t" (SampledImage ),
[sampled_image ] "" (sampled_image ),
[Result ] "t" (Result ),
[coordinate ] "" (coordinate ),
);
}
The type of
sampled_imagemust be a pointer to a SPIR-V sampled image.