2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 anv_surftype(const struct anv_image
*image
, VkImageViewType view_type
,
30 unreachable("bad VkImageViewType");
31 case VK_IMAGE_VIEW_TYPE_1D
:
32 case VK_IMAGE_VIEW_TYPE_1D_ARRAY
:
33 assert(image
->type
== VK_IMAGE_TYPE_1D
);
35 case VK_IMAGE_VIEW_TYPE_CUBE
:
36 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
:
37 assert(image
->type
== VK_IMAGE_TYPE_2D
);
38 return storage
? SURFTYPE_2D
: SURFTYPE_CUBE
;
39 case VK_IMAGE_VIEW_TYPE_2D
:
40 case VK_IMAGE_VIEW_TYPE_2D_ARRAY
:
41 assert(image
->type
== VK_IMAGE_TYPE_2D
);
43 case VK_IMAGE_VIEW_TYPE_3D
:
44 assert(image
->type
== VK_IMAGE_TYPE_3D
);
49 #if ANV_GEN > 7 || ANV_IS_HASWELL
50 static const uint32_t vk_to_gen_swizzle_map
[] = {
51 [VK_COMPONENT_SWIZZLE_ZERO
] = SCS_ZERO
,
52 [VK_COMPONENT_SWIZZLE_ONE
] = SCS_ONE
,
53 [VK_COMPONENT_SWIZZLE_R
] = SCS_RED
,
54 [VK_COMPONENT_SWIZZLE_G
] = SCS_GREEN
,
55 [VK_COMPONENT_SWIZZLE_B
] = SCS_BLUE
,
56 [VK_COMPONENT_SWIZZLE_A
] = SCS_ALPHA
59 static inline uint32_t
60 vk_to_gen_swizzle(VkComponentSwizzle swizzle
, VkComponentSwizzle component
)
62 if (swizzle
== VK_COMPONENT_SWIZZLE_IDENTITY
)
63 return vk_to_gen_swizzle_map
[component
];
65 return vk_to_gen_swizzle_map
[swizzle
];
69 static const uint32_t vk_to_gen_tex_filter
[] = {
70 [VK_FILTER_NEAREST
] = MAPFILTER_NEAREST
,
71 [VK_FILTER_LINEAR
] = MAPFILTER_LINEAR
74 static const uint32_t vk_to_gen_mipmap_mode
[] = {
75 [VK_SAMPLER_MIPMAP_MODE_BASE
] = MIPFILTER_NONE
,
76 [VK_SAMPLER_MIPMAP_MODE_NEAREST
] = MIPFILTER_NEAREST
,
77 [VK_SAMPLER_MIPMAP_MODE_LINEAR
] = MIPFILTER_LINEAR
80 static const uint32_t vk_to_gen_tex_address
[] = {
81 [VK_SAMPLER_ADDRESS_MODE_REPEAT
] = TCM_WRAP
,
82 [VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT
] = TCM_MIRROR
,
83 [VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
] = TCM_CLAMP
,
84 [VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE
] = TCM_MIRROR_ONCE
,
85 [VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
] = TCM_CLAMP_BORDER
,
88 static const uint32_t vk_to_gen_compare_op
[] = {
89 [VK_COMPARE_OP_NEVER
] = PREFILTEROPNEVER
,
90 [VK_COMPARE_OP_LESS
] = PREFILTEROPLESS
,
91 [VK_COMPARE_OP_EQUAL
] = PREFILTEROPEQUAL
,
92 [VK_COMPARE_OP_LESS_OR_EQUAL
] = PREFILTEROPLEQUAL
,
93 [VK_COMPARE_OP_GREATER
] = PREFILTEROPGREATER
,
94 [VK_COMPARE_OP_NOT_EQUAL
] = PREFILTEROPNOTEQUAL
,
95 [VK_COMPARE_OP_GREATER_OR_EQUAL
] = PREFILTEROPGEQUAL
,
96 [VK_COMPARE_OP_ALWAYS
] = PREFILTEROPALWAYS
,