Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2015 Intel Corporation |
| 3 | * |
| 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: |
| 10 | * |
| 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 |
| 13 | * Software. |
| 14 | * |
| 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <assert.h> |
| 25 | #include <stdbool.h> |
| 26 | #include <string.h> |
| 27 | #include <unistd.h> |
| 28 | #include <fcntl.h> |
| 29 | |
| 30 | #include "anv_private.h" |
| 31 | |
Jason Ekstrand | de54b4b | 2015-11-16 12:29:07 -0800 | [diff] [blame] | 32 | #include "gen7_pack.h" |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 33 | #include "gen75_pack.h" |
Jason Ekstrand | de54b4b | 2015-11-16 12:29:07 -0800 | [diff] [blame] | 34 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 35 | GENX_FUNC(GEN7, GEN75) void |
| 36 | genX(fill_buffer_surface_state)(void *state, const struct anv_format *format, |
| 37 | uint32_t offset, uint32_t range, |
| 38 | uint32_t stride) |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 39 | { |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 40 | uint32_t num_elements = range / stride; |
| 41 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 42 | struct GENX(RENDER_SURFACE_STATE) surface_state = { |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 43 | .SurfaceType = SURFTYPE_BUFFER, |
| 44 | .SurfaceFormat = format->surface_format, |
| 45 | .SurfaceVerticalAlignment = VALIGN_4, |
| 46 | .SurfaceHorizontalAlignment = HALIGN_4, |
| 47 | .TiledSurface = false, |
Kristian Høgsberg Kristensen | 647a602 | 2015-08-25 15:58:21 -0700 | [diff] [blame] | 48 | .RenderCacheReadWriteMode = false, |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 49 | .SurfaceObjectControlState = GENX(MOCS), |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 50 | .Height = (num_elements >> 7) & 0x3fff, |
| 51 | .Width = num_elements & 0x7f, |
| 52 | .Depth = (num_elements >> 21) & 0x3f, |
| 53 | .SurfacePitch = stride - 1, |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 54 | # if (ANV_IS_HASWELL) |
| 55 | .ShaderChannelSelectR = SCS_RED, |
| 56 | .ShaderChannelSelectG = SCS_GREEN, |
| 57 | .ShaderChannelSelectB = SCS_BLUE, |
| 58 | .ShaderChannelSelectA = SCS_ALPHA, |
| 59 | # endif |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 60 | .SurfaceBaseAddress = { NULL, offset }, |
| 61 | }; |
| 62 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 63 | GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &surface_state); |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 66 | static const uint32_t vk_to_gen_tex_filter[] = { |
Jason Ekstrand | e8f2294 | 2015-11-30 16:21:38 -0800 | [diff] [blame] | 67 | [VK_FILTER_NEAREST] = MAPFILTER_NEAREST, |
| 68 | [VK_FILTER_LINEAR] = MAPFILTER_LINEAR |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | static const uint32_t vk_to_gen_mipmap_mode[] = { |
Jason Ekstrand | e8f2294 | 2015-11-30 16:21:38 -0800 | [diff] [blame] | 72 | [VK_SAMPLER_MIPMAP_MODE_BASE] = MIPFILTER_NONE, |
| 73 | [VK_SAMPLER_MIPMAP_MODE_NEAREST] = MIPFILTER_NEAREST, |
| 74 | [VK_SAMPLER_MIPMAP_MODE_LINEAR] = MIPFILTER_LINEAR |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static const uint32_t vk_to_gen_tex_address[] = { |
Jason Ekstrand | e8f2294 | 2015-11-30 16:21:38 -0800 | [diff] [blame] | 78 | [VK_SAMPLER_ADDRESS_MODE_REPEAT] = TCM_WRAP, |
| 79 | [VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT] = TCM_MIRROR, |
| 80 | [VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE] = TCM_CLAMP, |
| 81 | [VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE] = TCM_MIRROR_ONCE, |
| 82 | [VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER] = TCM_CLAMP_BORDER, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | static const uint32_t vk_to_gen_compare_op[] = { |
| 86 | [VK_COMPARE_OP_NEVER] = PREFILTEROPNEVER, |
| 87 | [VK_COMPARE_OP_LESS] = PREFILTEROPLESS, |
| 88 | [VK_COMPARE_OP_EQUAL] = PREFILTEROPEQUAL, |
Jason Ekstrand | 73ef7d4 | 2015-11-30 13:49:28 -0800 | [diff] [blame] | 89 | [VK_COMPARE_OP_LESS_OR_EQUAL] = PREFILTEROPLEQUAL, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 90 | [VK_COMPARE_OP_GREATER] = PREFILTEROPGREATER, |
| 91 | [VK_COMPARE_OP_NOT_EQUAL] = PREFILTEROPNOTEQUAL, |
Jason Ekstrand | 73ef7d4 | 2015-11-30 13:49:28 -0800 | [diff] [blame] | 92 | [VK_COMPARE_OP_GREATER_OR_EQUAL] = PREFILTEROPGEQUAL, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 93 | [VK_COMPARE_OP_ALWAYS] = PREFILTEROPALWAYS, |
| 94 | }; |
| 95 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 96 | static struct anv_state |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 97 | alloc_surface_state(struct anv_device *device, |
| 98 | struct anv_cmd_buffer *cmd_buffer) |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 99 | { |
| 100 | if (cmd_buffer) { |
Jason Ekstrand | 6dc4cad | 2015-10-15 13:45:07 -0700 | [diff] [blame] | 101 | return anv_cmd_buffer_alloc_surface_state(cmd_buffer); |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 102 | } else { |
| 103 | return anv_state_pool_alloc(&device->surface_state_pool, 64, 64); |
| 104 | } |
| 105 | } |
| 106 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 107 | VkResult genX(CreateSampler)( |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 108 | VkDevice _device, |
| 109 | const VkSamplerCreateInfo* pCreateInfo, |
| 110 | VkSampler* pSampler) |
| 111 | { |
| 112 | ANV_FROM_HANDLE(anv_device, device, _device); |
| 113 | struct anv_sampler *sampler; |
| 114 | uint32_t mag_filter, min_filter, max_anisotropy; |
| 115 | |
| 116 | assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); |
| 117 | |
| 118 | sampler = anv_device_alloc(device, sizeof(*sampler), 8, |
| 119 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
| 120 | if (!sampler) |
| 121 | return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 122 | |
| 123 | if (pCreateInfo->maxAnisotropy > 1) { |
| 124 | mag_filter = MAPFILTER_ANISOTROPIC; |
| 125 | min_filter = MAPFILTER_ANISOTROPIC; |
| 126 | max_anisotropy = (pCreateInfo->maxAnisotropy - 2) / 2; |
| 127 | } else { |
| 128 | mag_filter = vk_to_gen_tex_filter[pCreateInfo->magFilter]; |
| 129 | min_filter = vk_to_gen_tex_filter[pCreateInfo->minFilter]; |
| 130 | max_anisotropy = RATIO21; |
| 131 | } |
| 132 | |
| 133 | struct GEN7_SAMPLER_STATE sampler_state = { |
| 134 | .SamplerDisable = false, |
| 135 | .TextureBorderColorMode = DX10OGL, |
| 136 | .BaseMipLevel = 0.0, |
Jason Ekstrand | e8f2294 | 2015-11-30 16:21:38 -0800 | [diff] [blame] | 137 | .MipModeFilter = vk_to_gen_mipmap_mode[pCreateInfo->mipmapMode], |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 138 | .MagModeFilter = mag_filter, |
| 139 | .MinModeFilter = min_filter, |
| 140 | .TextureLODBias = pCreateInfo->mipLodBias * 256, |
| 141 | .AnisotropicAlgorithm = EWAApproximation, |
| 142 | .MinLOD = pCreateInfo->minLod, |
| 143 | .MaxLOD = pCreateInfo->maxLod, |
| 144 | .ChromaKeyEnable = 0, |
| 145 | .ChromaKeyIndex = 0, |
| 146 | .ChromaKeyMode = 0, |
| 147 | .ShadowFunction = vk_to_gen_compare_op[pCreateInfo->compareOp], |
| 148 | .CubeSurfaceControlMode = 0, |
| 149 | |
| 150 | .BorderColorPointer = |
| 151 | device->border_colors.offset + |
| 152 | pCreateInfo->borderColor * sizeof(float) * 4, |
| 153 | |
| 154 | .MaximumAnisotropy = max_anisotropy, |
| 155 | .RAddressMinFilterRoundingEnable = 0, |
| 156 | .RAddressMagFilterRoundingEnable = 0, |
| 157 | .VAddressMinFilterRoundingEnable = 0, |
| 158 | .VAddressMagFilterRoundingEnable = 0, |
| 159 | .UAddressMinFilterRoundingEnable = 0, |
| 160 | .UAddressMagFilterRoundingEnable = 0, |
| 161 | .TrilinearFilterQuality = 0, |
Jason Ekstrand | 57f5003 | 2015-10-05 20:17:24 -0700 | [diff] [blame] | 162 | .NonnormalizedCoordinateEnable = pCreateInfo->unnormalizedCoordinates, |
Jason Ekstrand | f7c3519 | 2015-10-05 20:15:06 -0700 | [diff] [blame] | 163 | .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeU], |
| 164 | .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeV], |
| 165 | .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeW], |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | GEN7_SAMPLER_STATE_pack(NULL, sampler->state, &sampler_state); |
| 169 | |
| 170 | *pSampler = anv_sampler_to_handle(sampler); |
| 171 | |
| 172 | return VK_SUCCESS; |
| 173 | } |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 174 | |
| 175 | static const uint8_t anv_halign[] = { |
| 176 | [4] = HALIGN_4, |
| 177 | [8] = HALIGN_8, |
| 178 | }; |
| 179 | |
| 180 | static const uint8_t anv_valign[] = { |
| 181 | [2] = VALIGN_2, |
| 182 | [4] = VALIGN_4, |
| 183 | }; |
| 184 | |
Jason Ekstrand | a53f23d | 2015-11-30 13:06:12 -0800 | [diff] [blame] | 185 | static const uint32_t vk_to_gen_swizzle_map[] = { |
| 186 | [VK_COMPONENT_SWIZZLE_ZERO] = SCS_ZERO, |
| 187 | [VK_COMPONENT_SWIZZLE_ONE] = SCS_ONE, |
| 188 | [VK_COMPONENT_SWIZZLE_R] = SCS_RED, |
| 189 | [VK_COMPONENT_SWIZZLE_G] = SCS_GREEN, |
| 190 | [VK_COMPONENT_SWIZZLE_B] = SCS_BLUE, |
| 191 | [VK_COMPONENT_SWIZZLE_A] = SCS_ALPHA |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
Jason Ekstrand | 2c77b0c | 2015-11-30 13:29:49 -0800 | [diff] [blame] | 194 | static inline uint32_t |
Jason Ekstrand | a53f23d | 2015-11-30 13:06:12 -0800 | [diff] [blame] | 195 | vk_to_gen_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component) |
| 196 | { |
| 197 | if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY) |
| 198 | return vk_to_gen_swizzle_map[component]; |
| 199 | else |
| 200 | return vk_to_gen_swizzle_map[swizzle]; |
| 201 | } |
| 202 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 203 | GENX_FUNC(GEN7, GEN75) void |
| 204 | genX(image_view_init)(struct anv_image_view *iview, |
| 205 | struct anv_device *device, |
| 206 | const VkImageViewCreateInfo* pCreateInfo, |
| 207 | struct anv_cmd_buffer *cmd_buffer) |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 208 | { |
| 209 | ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); |
| 210 | |
| 211 | const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 212 | |
Chad Versace | 941b48e | 2015-08-28 07:08:58 -0700 | [diff] [blame] | 213 | struct anv_surface *surface = |
Chad Versace | 7a089bd | 2015-10-05 06:48:14 -0700 | [diff] [blame] | 214 | anv_image_get_surface_for_aspect_mask(image, range->aspectMask); |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 215 | |
| 216 | const struct anv_format *format = |
| 217 | anv_format_for_vk_format(pCreateInfo->format); |
| 218 | |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 219 | if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D) |
| 220 | anv_finishme("non-2D image views"); |
| 221 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 222 | iview->image = image; |
Chad Versace | f0f4dfa | 2015-10-05 16:24:53 -0700 | [diff] [blame] | 223 | iview->bo = image->bo; |
| 224 | iview->offset = image->offset + surface->offset; |
| 225 | iview->format = anv_format_for_vk_format(pCreateInfo->format); |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 226 | |
| 227 | iview->extent = (VkExtent3D) { |
| 228 | .width = anv_minify(image->extent.width, range->baseMipLevel), |
| 229 | .height = anv_minify(image->extent.height, range->baseMipLevel), |
| 230 | .depth = anv_minify(image->extent.depth, range->baseMipLevel), |
| 231 | }; |
| 232 | |
| 233 | uint32_t depth = 1; |
Jason Ekstrand | 299f8f1 | 2015-12-01 12:52:56 -0800 | [diff] [blame] | 234 | if (range->layerCount > 1) { |
| 235 | depth = range->layerCount; |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 236 | } else if (image->extent.depth > 1) { |
| 237 | depth = image->extent.depth; |
| 238 | } |
| 239 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 240 | struct GENX(RENDER_SURFACE_STATE) surface_state = { |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 241 | .SurfaceType = image->surface_type, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 242 | .SurfaceArray = image->array_size > 1, |
| 243 | .SurfaceFormat = format->surface_format, |
| 244 | .SurfaceVerticalAlignment = anv_valign[surface->v_align], |
| 245 | .SurfaceHorizontalAlignment = anv_halign[surface->h_align], |
Kristian Høgsberg Kristensen | 6a1098b | 2015-08-25 10:48:43 -0700 | [diff] [blame] | 246 | |
| 247 | /* From bspec (DevSNB, DevIVB): "Set Tile Walk to TILEWALK_XMAJOR if |
| 248 | * Tiled Surface is False." |
| 249 | */ |
Chad Versace | ba46746 | 2015-11-13 10:24:57 -0800 | [diff] [blame] | 250 | .TiledSurface = surface->tiling != ISL_TILING_LINEAR, |
| 251 | .TileWalk = surface->tiling == ISL_TILING_Y ? |
| 252 | TILEWALK_YMAJOR : TILEWALK_XMAJOR, |
Kristian Høgsberg Kristensen | 6a1098b | 2015-08-25 10:48:43 -0700 | [diff] [blame] | 253 | |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 254 | .VerticalLineStride = 0, |
| 255 | .VerticalLineStrideOffset = 0, |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 256 | |
| 257 | .RenderCacheReadWriteMode = 0, /* TEMPLATE */ |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 258 | |
| 259 | .Height = image->extent.height - 1, |
| 260 | .Width = image->extent.width - 1, |
| 261 | .Depth = depth - 1, |
| 262 | .SurfacePitch = surface->stride - 1, |
Jason Ekstrand | 1e4263b | 2015-10-06 10:27:50 -0700 | [diff] [blame] | 263 | .MinimumArrayElement = range->baseArrayLayer, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 264 | .NumberofMultisamples = MULTISAMPLECOUNT_1, |
| 265 | .XOffset = 0, |
| 266 | .YOffset = 0, |
| 267 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 268 | .SurfaceObjectControlState = GENX(MOCS), |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 269 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 270 | .MIPCountLOD = 0, /* TEMPLATE */ |
| 271 | .SurfaceMinLOD = 0, /* TEMPLATE */ |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 272 | |
| 273 | .MCSEnable = false, |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 274 | # if (ANV_IS_HASWELL) |
Jason Ekstrand | a53f23d | 2015-11-30 13:06:12 -0800 | [diff] [blame] | 275 | .ShaderChannelSelectR = vk_to_gen_swizzle(pCreateInfo->components.r, |
| 276 | VK_COMPONENT_SWIZZLE_R), |
| 277 | .ShaderChannelSelectG = vk_to_gen_swizzle(pCreateInfo->components.g, |
| 278 | VK_COMPONENT_SWIZZLE_G), |
| 279 | .ShaderChannelSelectB = vk_to_gen_swizzle(pCreateInfo->components.b, |
| 280 | VK_COMPONENT_SWIZZLE_B), |
| 281 | .ShaderChannelSelectA = vk_to_gen_swizzle(pCreateInfo->components.a, |
| 282 | VK_COMPONENT_SWIZZLE_A), |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 283 | # else /* XXX: Seriously? */ |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 284 | .RedClearColor = 0, |
| 285 | .GreenClearColor = 0, |
| 286 | .BlueClearColor = 0, |
| 287 | .AlphaClearColor = 0, |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 288 | # endif |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 289 | .ResourceMinLOD = 0.0, |
Chad Versace | f0f4dfa | 2015-10-05 16:24:53 -0700 | [diff] [blame] | 290 | .SurfaceBaseAddress = { NULL, iview->offset }, |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 291 | }; |
| 292 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 293 | if (image->needs_nonrt_surface_state) { |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 294 | iview->nonrt_surface_state = alloc_surface_state(device, cmd_buffer); |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 295 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 296 | surface_state.RenderCacheReadWriteMode = false; |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 297 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 298 | /* For non render target surfaces, the hardware interprets field |
| 299 | * MIPCount/LOD as MIPCount. The range of levels accessible by the |
| 300 | * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. |
Kristian Høgsberg Kristensen | 6a1098b | 2015-08-25 10:48:43 -0700 | [diff] [blame] | 301 | */ |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 302 | surface_state.SurfaceMinLOD = range->baseMipLevel; |
Jason Ekstrand | 299f8f1 | 2015-12-01 12:52:56 -0800 | [diff] [blame] | 303 | surface_state.MIPCountLOD = range->levelCount - 1; |
Kristian Høgsberg Kristensen | 6a1098b | 2015-08-25 10:48:43 -0700 | [diff] [blame] | 304 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 305 | GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->nonrt_surface_state.map, |
| 306 | &surface_state); |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 307 | } |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 308 | |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 309 | if (image->needs_color_rt_surface_state) { |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 310 | iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer); |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 311 | |
Jason Ekstrand | de54b4b | 2015-11-16 12:29:07 -0800 | [diff] [blame] | 312 | surface_state.RenderCacheReadWriteMode = 0; /* Write only */ |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 313 | |
| 314 | /* For render target surfaces, the hardware interprets field MIPCount/LOD as |
| 315 | * LOD. The Broadwell PRM says: |
| 316 | * |
| 317 | * MIPCountLOD defines the LOD that will be rendered into. |
| 318 | * SurfaceMinLOD is ignored. |
| 319 | */ |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 320 | surface_state.MIPCountLOD = range->baseMipLevel; |
| 321 | surface_state.SurfaceMinLOD = 0; |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 322 | |
Jason Ekstrand | f0390bc | 2015-11-17 07:07:02 -0800 | [diff] [blame] | 323 | GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->color_rt_surface_state.map, |
| 324 | &surface_state); |
Chad Versace | 24de3d4 | 2015-10-06 19:11:58 -0700 | [diff] [blame] | 325 | } |
Kristian Høgsberg Kristensen | f1455ff | 2015-08-20 22:59:19 -0700 | [diff] [blame] | 326 | } |