Jon Leech 348990517c Change log for September 30, 2016 Vulkan 1.0.29 spec update:
* Bump API patch number and header version number to 29 for this update.

Github Issues:

  * Remove redundant constraint on
    slink:VkCommandBufferInheritanceInfo::pname:queryFlags (public issue
    224).
  * Fix typo and remove link in Note in the
    <<extended-functionality-instance-extensions-and-devices, Instance
    Extensions and Device Extensions>> section (public issue 359).
  * Fix erroneous validation statement for the pname:layout member of
    slink:VkComputePipelineCreateInfo (public issue 362).

Internal Issues:

  * Restore long figure captions using asciidoc sidebar blocks, due to
    restrictions of asciidoc syntax (internal issue 101).
  * Replace most latexmath equations with comparable markup in straight
    asciidoc, which significantly improves time required to fully load and
    process the HTML forms of the Specification. There are known minor font
    and alignment inconsistencies with MathJax and PDF rendering of
    latexmath equations. Please do not file github issues about these. We
    are aware of the inconsistencies and will make refinements over time,
    while the performance improvements are compelling in at least some major
    browsers (internal issue 313).
  * Move handcoded validity statements from +vk.xml+ into the Specification
    body, easing work in the single-branch model. Specify the distinction
    between these explicit statements, and the implicit validity statements
    inferred from vk.xml. Validity statements now appear in two blocks for
    each command and structure - handcoded "Valid Usage" and the implicit
    "Valid Usage (Implicit)" (internal issue 392).
  * Add the +returnedonly="false"+ attribute to WSI output structures,
    removing incorrectly generated implicit validity statements for
    slink:VkDisplayPropertiesKHR, slink:VkDisplayPlanePropertiesKHR,
    slink:VkDisplayModePropertiesKHR, slink:VkDisplayPlaneCapabilitiesKHR,
    slink:VkSurfaceCapabilitiesKHR, and slink:VkSurfaceFormatKHR structures
    (internal issue 486).
  * Update slink:VkImageLayout to require the
    ename:VK_IMAGE_USAGE_SAMPLED_BIT be set for sampled depth/stencil images
    (internal issue 487).
  * Use an explicit format specifier string for the date command invocation
    in the +Makefile+ instead of the shorthand -R option, which doesn't work
    on BSD and MaxOS X date commands (internal issue 500).

Other Issues:

  * Use the terms ``allocation scope'' and ``extension scope'' instead of
    just ``scope'', and add them to the glossary.
2016-09-30 21:13:37 -07:00

259 lines
11 KiB
Plaintext

// Copyright (c) 2015-2016 The Khronos Group Inc.
// Copyright notice at https://www.khronos.org/registry/speccopyright.html
[[samplers]]
= Samplers
// refBegin VkSampler Opaque handle to a sampler object
sname:VkSampler objects represent the state of an image sampler which is
used by the implementation to read image data and apply filtering and other
transformations for the shader.
Samplers are represented by sname:VkSampler handles:
include::../api/handles/VkSampler.txt[]
// refEnd VkSampler
// refBegin vkCreateSampler Create a new sampler object
To create a sampler object, call:
include::../api/protos/vkCreateSampler.txt[]
* pname:device is the logical device that creates the sampler.
* pname:pCreateInfo is a pointer to an instance of the
slink:VkSamplerCreateInfo structure specifying the state of the sampler
object.
* pname:pAllocator controls host memory allocation as described in the
<<memory-allocation, Memory Allocation>> chapter.
* pname:pSampler points to a sname:VkSampler handle in which the resulting
sampler object is returned.
include::../validity/protos/vkCreateSampler.txt[]
// refBegin VkSamplerCreateInfo Structure specifying parameters of a newly created sampler
The sname:VkSamplerCreateInfo structure is defined as:
include::../api/structs/VkSamplerCreateInfo.txt[]
* pname:sType is the type of this structure.
* pname:pNext is `NULL` or a pointer to an extension-specific structure.
* pname:flags is reserved for future use.
* pname:magFilter is the magnification filter to apply to lookups, and is
of type:
+
--
// refBegin VkFilter Specify filters used for texture lookups
include::../api/enums/VkFilter.txt[]
--
+
* pname:minFilter is the minification filter to apply to lookups, and is
of type elink:VkFilter.
* pname:mipmapMode is the mipmap filter to apply to lookups as described
in the <<textures-texel-filtering, Texel Filtering>> section, and is of
type:
+
--
// refBegin VkSamplerMipmapMode Specify mipmap mode used for texture lookups
include::../api/enums/VkSamplerMipmapMode.txt[]
--
+
* pname:addressModeU is the addressing mode for outside [0..1] range for U
coordinate.
See elink:VkSamplerAddressMode.
* pname:addressModeV is the addressing mode for outside [0..1] range for V
coordinate.
See elink:VkSamplerAddressMode.
* pname:addressModeW is the addressing mode for outside [0..1] range for W
coordinate.
See elink:VkSamplerAddressMode.
* [[samplers-mipLodBias]] pname:mipLodBias is the bias to be added to
mipmap LOD calculation and bias provided by image sampling functions in
SPIR-V, as described in the <<textures-level-of-detail-operation,
Level-of-Detail Operation>> section.
* [[samplers-maxAnisotropy]] pname:anisotropyEnable is ename:VK_TRUE to
enable anisotropic filtering, as described in the
<<textures-texel-anisotropic-filtering, Texel Anisotropic Filtering>>
section, or ename:VK_FALSE otherwise.
* pname:maxAnisotropy is the anisotropy value clamp.
* pname:compareEnable is ename:VK_TRUE to enable comparison against a
reference value during lookups, or ename:VK_FALSE otherwise.
** Note: Some implementations will default to shader state if this member
does not match.
* pname:compareOp is the comparison function to apply to fetched data
before filtering as described in the <<textures-depth-compare-operation,
Depth Compare Operation>> section.
See elink:VkCompareOp.
* pname:minLod and pname:maxLod are the values used to clamp the computed
level-of-detail value, as described in the
<<textures-level-of-detail-operation, Level-of-Detail Operation>>
section.
pname:maxLod must: be greater than or equal to pname:minLod.
* pname:borderColor is the predefined border color to use, as described in
the <<textures-texel-replacement, Texel Replacement>> section, and is of
type:
+
--
// refBegin VkBorderColor Specify border color used for texture lookups
include::../api/enums/VkBorderColor.txt[]
--
+
* [[samplers-unnormalizedCoordinates]] pname:unnormalizedCoordinates
controls whether to use unnormalized or normalized texel coordinates to
address texels of the image.
When set to ename:VK_TRUE, the range of the image coordinates used to
lookup the texel is in the range of zero to the image dimensions for x,
y and z.
When set to ename:VK_FALSE the range of image coordinates is zero to
one.
When pname:unnormalizedCoordinates is ename:VK_TRUE, samplers have the
following requirements:
** pname:minFilter and pname:magFilter must: be equal.
** pname:mipmapMode must: be ename:VK_SAMPLER_MIPMAP_MODE_NEAREST.
** pname:minLod and pname:maxLod must: be zero.
** pname:addressModeU and pname:addressModeV must: each be either
ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or
ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.
** pname:anisotropyEnable must: be ename:VK_FALSE.
** pname:compareEnable must: be ename:VK_FALSE.
* When pname:unnormalizedCoordinates is ename:VK_TRUE, images the sampler
is used with in the shader have the following requirements:
** The pname:viewType must: be either ename:VK_IMAGE_VIEW_TYPE_1D or
ename:VK_IMAGE_VIEW_TYPE_2D.
** The image view must: have a single layer and a single mip level.
* When pname:unnormalizedCoordinates is ename:VK_TRUE, image built-in
functions in the shader that use the sampler have the following
requirements:
** The functions must: not use projection.
** The functions must: not use offsets.
[NOTE]
.Mapping of OpenGL to Vulkan filter modes
==================
pname:magFilter values of ename:VK_FILTER_NEAREST and ename:VK_FILTER_LINEAR
directly correspond to code:GL_NEAREST and code:GL_LINEAR magnification
filters.
pname:minFilter and pname:mipmapMode combine to correspond to the similarly
named OpenGL minification filter of code:GL_minFilter_MIPMAP_mipmapMode
(e.g. pname:minFilter of ename:VK_FILTER_LINEAR and pname:mipmapMode of
ename:VK_SAMPLER_MIPMAP_MODE_NEAREST correspond to
code:GL_LINEAR_MIPMAP_NEAREST).
There are no Vulkan filter modes that directly correspond to OpenGL
minification filters of code:GL_LINEAR or code:GL_NEAREST, but they can: be
emulated using ename:VK_SAMPLER_MIPMAP_MODE_NEAREST, pname:minLod = 0, and
pname:maxLod = 0.25, and using pname:minFilter = ename:VK_FILTER_LINEAR or
pname:minFilter = ename:VK_FILTER_NEAREST, respectively.
Note that using a pname:maxLod of zero would cause
<<textures-texel-filtering,magnification>> to always be performed, and the
pname:magFilter to always be used.
This is valid, just not an exact match for OpenGL behavior.
Clamping the maximum LOD to 0.25 allows the [eq]#{lambda}# value to be
non-zero and minification to be performed, while still always rounding down
to the base level.
If the pname:minFilter and pname:magFilter are equal, then using a
pname:maxLod of zero also works.
==================
pname:addressModeU, pname:addressModeV, and pname:addressModeW must: each
have one of the following values:
// refBegin VkSamplerAddressMode Specify behavior of sampling with texture coordinates outside an image
include::../api/enums/VkSamplerAddressMode.txt[]
These values control the behavior of sampling with coordinates outside the
range [eq]#[0,1]# for the respective u, v, or w coordinate as defined in the
<<textures-wrapping-operation, Wrapping Operation>> section.
* ename:VK_SAMPLER_ADDRESS_MODE_REPEAT indicates that the repeat wrap mode
will be used.
* ename:VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT indicates that the
mirrored repeat wrap mode will be used.
* ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE indicates that the clamp to
edge wrap mode will be used.
* ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER indicates that the clamp
to border wrap mode will be used.
* ename:VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE indicates that the
mirror clamp to edge wrap mode will be used.
This is only valid if the +VK_KHR_mirror_clamp_to_edge+ extension is
enabled.
The maximum number of sampler objects which can: be simultaneously created
on a device is implementation-dependent and specified by the
<<features-limits-maxSamplerAllocationCount,pname:maxSamplerAllocationCount>>
member of the sname:VkPhysicalDeviceLimits structure.
If pname:maxSamplerAllocationCount is exceeded, fname:vkCreateSampler will
return ename:VK_ERROR_TOO_MANY_OBJECTS.
Since sname:VkSampler is a non-dispatchable handle type, implementations
may: return the same handle for sampler state vectors that are identical.
In such cases, all such objects would only count once against the
pname:maxSamplerAllocationCount limit.
.Valid Usage
****
* The absolute value of pname:mipLodBias must: be less than or equal to
sname:VkPhysicalDeviceLimits::pname:maxSamplerLodBias
* If the <<features-features-samplerAnisotropy,anisotropic sampling>>
feature is not enabled, pname:anisotropyEnable must: be ename:VK_FALSE
* If pname:anisotropyEnable is ename:VK_TRUE, pname:maxAnisotropy must: be
between `1.0` and
sname:VkPhysicalDeviceLimits::pname:maxSamplerAnisotropy, inclusive
* If pname:unnormalizedCoordinates is ename:VK_TRUE, pname:minFilter and
pname:magFilter must: be equal
* If pname:unnormalizedCoordinates is ename:VK_TRUE, pname:mipmapMode
must: be ename:VK_SAMPLER_MIPMAP_MODE_NEAREST
* If pname:unnormalizedCoordinates is ename:VK_TRUE, pname:minLod and
pname:maxLod must: be zero
* If pname:unnormalizedCoordinates is ename:VK_TRUE, pname:addressModeU
and pname:addressModeV must: each be either
ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or
ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
* If pname:unnormalizedCoordinates is ename:VK_TRUE,
pname:anisotropyEnable must: be ename:VK_FALSE
* If pname:unnormalizedCoordinates is ename:VK_TRUE, pname:compareEnable
must: be ename:VK_FALSE
* If any of pname:addressModeU, pname:addressModeV or pname:addressModeW
are ename:VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, pname:borderColor
must: be a valid elink:VkBorderColor value
* If the +VK_KHR_sampler_mirror_clamp_to_edge+ extension is not enabled,
pname:addressModeU, pname:addressModeV and pname:addressModeW must: not
be ename:VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE
* If pname:compareEnable is ename:VK_TRUE, pname:compareOp must: be a
valid elink:VkCompareOp value
ifdef::VK_IMG_filter_cubic[]
* If either pname:magFilter or pname:minFilter is
ename:VK_FILTER_CUBIC_IMG, pname:anisotropyEnable must: be
ename:VK_FALSE
endif::VK_IMG_filter_cubic[]
****
include::../validity/structs/VkSamplerCreateInfo.txt[]
// refBegin vkDestroySampler Destroy a sampler object
To destroy a sampler, call:
include::../api/protos/vkDestroySampler.txt[]
* pname:device is the logical device that destroys the sampler.
* pname:sampler is the sampler to destroy.
* pname:pAllocator controls host memory allocation as described in the
<<memory-allocation, Memory Allocation>> chapter.
.Valid Usage
****
* All submitted commands that refer to pname:sampler must: have completed
execution
* If sname:VkAllocationCallbacks were provided when pname:sampler was
created, a compatible set of callbacks must: be provided here
* If no sname:VkAllocationCallbacks were provided when pname:sampler was
created, pname:pAllocator must: be `NULL`
****
include::../validity/protos/vkDestroySampler.txt[]