diff options
author | Nanley Chery <[email protected]> | 2016-03-22 10:53:37 -0700 |
---|---|---|
committer | Nanley Chery <[email protected]> | 2016-03-24 16:15:00 -0700 |
commit | a5dc3c0f02aa523d1d3d123b62b9a187821079fe (patch) | |
tree | 36c486b5d659ebdbbaa96694ecabecf21770ff8c /src/intel/vulkan/anv_private.h | |
parent | 20417b2cb05ff0f710eb6b6fbd9299ba915f8fc1 (diff) |
anv: Sanitize Image extents and offsets
Prepare Image extents and offsets for internal consumption by assigning
the default values implicitly defned by the spec. Fixes textures on
several Vulkan demos in which the VkImageCopy depth is set to zero when
copying a 2D image.
v2 (Jason Ekstrand):
Replace "prep" with "sanitize"
Make function static inline
Pass structs instead of pointers
Reviewed-by: Jason Ekstrand <[email protected]>
Signed-off-by: Nanley Chery <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_private.h')
-rw-r--r-- | src/intel/vulkan/anv_private.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 03e87670165..94a13d7d331 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1670,6 +1670,39 @@ struct anv_buffer_view { const struct anv_format * anv_format_for_descriptor_type(VkDescriptorType type); +static inline struct VkExtent3D +anv_sanitize_image_extent(const VkImageType imageType, + const struct VkExtent3D imageExtent) +{ + switch (imageType) { + case VK_IMAGE_TYPE_1D: + return (VkExtent3D) { imageExtent.width, 1, 1 }; + case VK_IMAGE_TYPE_2D: + return (VkExtent3D) { imageExtent.width, imageExtent.height, 1 }; + case VK_IMAGE_TYPE_3D: + return imageExtent; + default: + unreachable("invalid image type"); + } +} + +static inline struct VkOffset3D +anv_sanitize_image_offset(const VkImageType imageType, + const struct VkOffset3D imageOffset) +{ + switch (imageType) { + case VK_IMAGE_TYPE_1D: + return (VkOffset3D) { imageOffset.x, 0, 0 }; + case VK_IMAGE_TYPE_2D: + return (VkOffset3D) { imageOffset.x, imageOffset.y, 0 }; + case VK_IMAGE_TYPE_3D: + return imageOffset; + default: + unreachable("invalid image type"); + } +} + + void anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state, enum isl_format format, |