Vulkan Image Operations are operations performed by those SPIR-V Image Instructions which take an OpTypeImage (representing a VkImageView) or OpTypeSampledImage (representing a (VkImageView, VkSampler) pair). Read, write, and atomic operations also take texel coordinates as operands, and return a value based on a neighborhood of texture elements (texels) within the image. Query operations return properties of the bound image or of the lookup itself. The “Depth” operand of OpTypeImage is ignored.
Texel Coordinate Systems
OpImageFetch, OpImageSparseFetch, OpImageRead, OpImageSparseRead, and OpImageWrite instructions use integer texel coordinates. Other image instructions can use either normalized or unnormalized texel coordinates (selected by the unnormalizedCoordinates state of the sampler used in the instruction), but there are limitations on what operations, image state, and sampler state is supported. Normalized coordinates are logically converted to unnormalized as part of image operations, and certain steps are only performed on normalized coordinates. The array layer coordinate is always treated as unnormalized even when other coordinates are normalized.
Normalized texel coordinates are referred to as (s,t,r,q,a), with the coordinates having the following meanings:
Unnormalized texel coordinates are referred to as (u,v,w,a), with the coordinates having the following meanings:
Integer texel coordinates are referred to as (i,j,k,l,n), with the coordinates having the following meanings:
For all coordinate types, unused coordinates are assigned a value of zero.
The Texel Coordinate Systems - For the example shown of an 8×4 texel two dimensional image.
Normalized texel coordinates:◦ The s coordinate goes from 0.0 to 1.0. ◦ The t coordinate goes from 0.0 to 1.0.
Unnormalized texel coordinates: ◦ The u coordinate within the range 0.0 to 8.0 is within the image, otherwise it is outside the image. ◦ The v coordinate within the range 0.0 to 4.0 is within the image, otherwise it is outside the image.
Integer texel coordinates: ◦ The i coordinate within the range 0 to 7 addresses texels within the image, otherwise it is outside the image. ◦ The j coordinate within the range 0 to 3 addresses texels within the image, otherwise it is outside the image.
Also shown for linear filtering: ◦ Given the unnormalized coordinates (u,v), the four texels selected are i0j0, i1j0, i0j1, and i1j1. ◦ The fractions α and β. ◦ Given the offset Δi and Δj, the four texels selected by the offset are i0j'0, i1j'0, i0j'1, and i1j'1.
For formats with reduced-resolution components, Δi and Δj are relative to the resolution of the highest-resolution component, and therefore may be divided by two relative to the unnormalized coordinate space of the lower-resolution components.
The Texel Coordinate Systems - For the example shown of an 8×4 texel two dimensional image. • Texel coordinates as above. Also shown for nearest filtering: ◦ Given the unnormalized coordinates (u,v), the texel selected is ij. ◦ Given the offset Δi and Δj, the texel selected by the offset is ij'.Conversion Formulas Texel Input Operations
Texel Input Validation Operations
Depth Compare Operation
Conversion to RGBA
Sampler Y′CBCR ConversionTexel Output Operations
Texel Output Validation Operations
Integer Texel Coordinate Validation
Sparse Texel Operation
Texel Output Format ConversionNormalized Texel Coordinate Operations
Derivative Image Operations
Cube Map Face Selection and Transformations
Cube Map Face Selection
Cube Map Coordinate Transformation
Cube Map Derivative Transformation
Scale Factor Operation, Level-of-Detail Operation and Image Level(s) Selection
(s,t,r,q,a) to (u,v,w,a) TransformationUnnormalized Texel Coordinate Operations
(u,v,w,a) to (i,j,k,l,n) Transformation And Array Layer SelectionInteger Texel Coordinate Operations Image Sample Operations
Texel FilteringImage Operation Steps
Each step described in this chapter is performed by a subset of the image instructions:
Image Property Queries
OpImageQuerySize, OpImageQuerySizeLod, OpImageQueryLevels, and OpImageQuerySamples query properties of the image descriptor that would be accessed by a shader image operation.
OpImageQuerySizeLod returns the size of the image level identified by the Level of Detail operand. If that level does not exist in the image, then the value returned is undefined.
OpImageQueryLod returns the Lod parameters that would be used in an image operation with the given image and coordinates. The steps described in this chapter are performed as if for OpImageSampleImplicitLod, up to Scale Factor Operation, Level-of-Detail Operation and Image Level(s) Selection. The return value is the vector (λ', dl). These values may be subject to implementation-specific maxima and minima for very large, out-of-range values.
原创技术文章，撰写不易，转载请注明出处：电子设备中的画家|王烁 于 2021 年 5 月 10 日发表，原文链接(http://geekfaner.com/shineengine/blog20_Vulkanv1.2_6.html)