Module: Mesa Branch: master Commit: 8c4426f519c95f27c4842afea08571b82aace999 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c4426f519c95f27c4842afea08571b82aace999
Author: Jonathan Marek <[email protected]> Date: Tue Sep 29 22:02:00 2020 -0400 turnip: remove unnecessary/redundant tu_image fields Signed-off-by: Jonathan Marek <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6940> --- src/freedreno/vulkan/tu_clear_blit.c | 38 ++++++++----------- src/freedreno/vulkan/tu_image.c | 72 ++++++++++++++++-------------------- src/freedreno/vulkan/tu_private.h | 9 +---- src/freedreno/vulkan/tu_util.h | 2 +- 4 files changed, 50 insertions(+), 71 deletions(-) diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c index f003988e0a9..ff3f42edb91 100644 --- a/src/freedreno/vulkan/tu_clear_blit.c +++ b/src/freedreno/vulkan/tu_clear_blit.c @@ -181,8 +181,6 @@ r2d_src_buffer(struct tu_cmd_buffer *cmd, static void r2d_dst(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) { - assert(iview->image->samples == 1); - tu_cs_emit_pkt4(cs, REG_A6XX_RB_2D_DST_INFO, 4); tu_cs_emit(cs, iview->RB_2D_DST_INFO); tu_cs_image_ref_2d(cs, iview, layer, false); @@ -194,8 +192,6 @@ r2d_dst(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) static void r2d_dst_stencil(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) { - assert(iview->image->samples == 1); - tu_cs_emit_pkt4(cs, REG_A6XX_RB_2D_DST_INFO, 4); tu_cs_emit(cs, tu_image_view_stencil(iview, RB_2D_DST_INFO) & ~A6XX_RB_2D_DST_INFO_FLAGS); tu_cs_emit_qw(cs, iview->stencil_base_addr + iview->stencil_layer_size * layer); @@ -665,7 +661,7 @@ r3d_src_buffer(struct tu_cmd_buffer *cmd, static void r3d_dst(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) { - tu6_emit_msaa(cs, iview->image->samples); /* TODO: move to setup */ + tu6_emit_msaa(cs, iview->image->layout[0].nr_samples); /* TODO: move to setup */ tu_cs_emit_pkt4(cs, REG_A6XX_RB_MRT_BUF_INFO(0), 6); tu_cs_emit(cs, iview->RB_MRT_BUF_INFO); @@ -681,7 +677,7 @@ r3d_dst(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) static void r3d_dst_stencil(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer) { - tu6_emit_msaa(cs, iview->image->samples); /* TODO: move to setup */ + tu6_emit_msaa(cs, iview->image->layout[0].nr_samples); /* TODO: move to setup */ tu_cs_emit_pkt4(cs, REG_A6XX_RB_MRT_BUF_INFO(0), 6); tu_cs_emit(cs, tu_image_view_stencil(iview, RB_MRT_BUF_INFO)); @@ -1040,7 +1036,7 @@ tu6_blit_image(struct tu_cmd_buffer *cmd, * the 2d path. */ - if (dst_image->samples > 1 || + if (dst_image->layout[0].nr_samples > 1 || src_image->vk_format == VK_FORMAT_BC1_RGB_UNORM_BLOCK || src_image->vk_format == VK_FORMAT_BC1_RGB_SRGB_BLOCK || filter == VK_FILTER_CUBIC_EXT) @@ -1344,7 +1340,7 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, const struct blit_ops *ops = &r2d_ops; struct tu_cs *cs = &cmd->cs; - if (dst_image->samples > 1) + if (dst_image->layout[0].nr_samples > 1) ops = &r3d_ops; VkFormat format = VK_FORMAT_UNDEFINED; @@ -1418,12 +1414,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, struct tu_image staging_image = { .vk_format = src_format, - .type = src_image->type, - .tiling = VK_IMAGE_TILING_LINEAR, - .extent = extent, .level_count = 1, .layer_count = info->srcSubresource.layerCount, - .samples = src_image->samples, .bo_offset = 0, }; @@ -1441,13 +1433,13 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, fdl6_layout(&staging_image.layout[0], vk_format_to_pipe_format(staging_image.vk_format), - staging_image.samples, - staging_image.extent.width, - staging_image.extent.height, - staging_image.extent.depth, + src_image->layout[0].nr_samples, + extent.width, + extent.height, + extent.depth, staging_image.level_count, staging_image.layer_count, - staging_image.type == VK_IMAGE_TYPE_3D, + extent.depth > 1, NULL); VkResult result = tu_get_scratch_bo(cmd->device, @@ -1719,12 +1711,12 @@ clear_image(struct tu_cmd_buffer *cmd, if (format == VK_FORMAT_D32_SFLOAT_S8_UINT || format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) format = copy_format(format, aspect_mask, false); - if (image->type == VK_IMAGE_TYPE_3D) { + if (image->layout[0].depth0 > 1) { assert(layer_count == 1); assert(range->baseArrayLayer == 0); } - const struct blit_ops *ops = image->samples > 1 ? &r3d_ops : &r2d_ops; + const struct blit_ops *ops = image->layout[0].nr_samples > 1 ? &r3d_ops : &r2d_ops; ops->setup(cmd, cs, format, aspect_mask, ROTATE_0, true, image->layout[0].ubwc); if (image->vk_format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) @@ -1733,12 +1725,12 @@ clear_image(struct tu_cmd_buffer *cmd, ops->clear_value(cs, format, clear_value); for (unsigned j = 0; j < level_count; j++) { - if (image->type == VK_IMAGE_TYPE_3D) - layer_count = u_minify(image->extent.depth, range->baseMipLevel + j); + if (image->layout[0].depth0 > 1) + layer_count = u_minify(image->layout[0].depth0, range->baseMipLevel + j); ops->coords(cs, &(VkOffset2D){}, NULL, &(VkExtent2D) { - u_minify(image->extent.width, range->baseMipLevel + j), - u_minify(image->extent.height, range->baseMipLevel + j) + u_minify(image->layout[0].width0, range->baseMipLevel + j), + u_minify(image->layout[0].height0, range->baseMipLevel + j) }); struct tu_image_view dst; diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index 189559313db..80cf4b3b04b 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -216,7 +216,7 @@ tu_image_view_init(struct tu_image_view *iview, uint32_t height = u_minify(layout->height0, range->baseMipLevel); uint32_t storage_depth = tu_get_layerCount(image, range); if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { - storage_depth = u_minify(image->extent.depth, range->baseMipLevel); + storage_depth = u_minify(image->layout[0].depth0, range->baseMipLevel); } uint32_t depth = storage_depth; @@ -268,7 +268,7 @@ tu_image_view_init(struct tu_image_view *iview, A6XX_TEX_CONST_0_TILE_MODE(fmt.tile_mode) | COND(vk_format_is_srgb(format), A6XX_TEX_CONST_0_SRGB) | A6XX_TEX_CONST_0_FMT(fmt_tex) | - A6XX_TEX_CONST_0_SAMPLES(tu_msaa_samples(image->samples)) | + A6XX_TEX_CONST_0_SAMPLES(tu_msaa_samples(layout->nr_samples)) | A6XX_TEX_CONST_0_SWAP(fmt.swap) | tu6_texswiz(&pCreateInfo->components, conversion, format, aspect_mask, limited_z24s8) | A6XX_TEX_CONST_0_MIPLVLS(tu_get_levelCount(image, range) - 1); @@ -322,7 +322,6 @@ tu_image_view_init(struct tu_image_view *iview, iview->descriptor[10] = base_addr[2] >> 32; assert(pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_3D); - assert(!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT)); return; } @@ -351,8 +350,8 @@ tu_image_view_init(struct tu_image_view *iview, .color_swap = fmt.swap, .flags = ubwc_enabled, .srgb = vk_format_is_srgb(format), - .samples = tu_msaa_samples(image->samples), - .samples_average = image->samples > 1 && + .samples = tu_msaa_samples(layout->nr_samples), + .samples_average = layout->nr_samples > 1 && !vk_format_is_int(format) && !vk_format_is_depth_or_stencil(format), .unk20 = 1, @@ -382,31 +381,29 @@ tu_image_view_init(struct tu_image_view *iview, if (is_d24s8 && ubwc_enabled) cfmt.fmt = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8; - if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) { - memset(iview->storage_descriptor, 0, sizeof(iview->storage_descriptor)); + memset(iview->storage_descriptor, 0, sizeof(iview->storage_descriptor)); - iview->storage_descriptor[0] = - A6XX_IBO_0_FMT(fmt.fmt) | - A6XX_IBO_0_TILE_MODE(fmt.tile_mode); - iview->storage_descriptor[1] = - A6XX_IBO_1_WIDTH(width) | - A6XX_IBO_1_HEIGHT(height); - iview->storage_descriptor[2] = - A6XX_IBO_2_PITCH(pitch) | - A6XX_IBO_2_TYPE(tu6_tex_type(pCreateInfo->viewType, true)); - iview->storage_descriptor[3] = A6XX_IBO_3_ARRAY_PITCH(layer_size); + iview->storage_descriptor[0] = + A6XX_IBO_0_FMT(fmt.fmt) | + A6XX_IBO_0_TILE_MODE(fmt.tile_mode); + iview->storage_descriptor[1] = + A6XX_IBO_1_WIDTH(width) | + A6XX_IBO_1_HEIGHT(height); + iview->storage_descriptor[2] = + A6XX_IBO_2_PITCH(pitch) | + A6XX_IBO_2_TYPE(tu6_tex_type(pCreateInfo->viewType, true)); + iview->storage_descriptor[3] = A6XX_IBO_3_ARRAY_PITCH(layer_size); - iview->storage_descriptor[4] = base_addr; - iview->storage_descriptor[5] = (base_addr >> 32) | A6XX_IBO_5_DEPTH(storage_depth); + iview->storage_descriptor[4] = base_addr; + iview->storage_descriptor[5] = (base_addr >> 32) | A6XX_IBO_5_DEPTH(storage_depth); - if (ubwc_enabled) { - iview->storage_descriptor[3] |= A6XX_IBO_3_FLAG | A6XX_IBO_3_UNK27; - iview->storage_descriptor[7] |= ubwc_addr; - iview->storage_descriptor[8] |= ubwc_addr >> 32; - iview->storage_descriptor[9] = A6XX_IBO_9_FLAG_BUFFER_ARRAY_PITCH(layout->ubwc_layer_size >> 2); - iview->storage_descriptor[10] = - A6XX_IBO_10_FLAG_BUFFER_PITCH(ubwc_pitch); - } + if (ubwc_enabled) { + iview->storage_descriptor[3] |= A6XX_IBO_3_FLAG | A6XX_IBO_3_UNK27; + iview->storage_descriptor[7] |= ubwc_addr; + iview->storage_descriptor[8] |= ubwc_addr >> 32; + iview->storage_descriptor[9] = A6XX_IBO_9_FLAG_BUFFER_ARRAY_PITCH(layout->ubwc_layer_size >> 2); + iview->storage_descriptor[10] = + A6XX_IBO_10_FLAG_BUFFER_PITCH(ubwc_pitch); } iview->extent.width = width; @@ -435,7 +432,7 @@ tu_image_view_init(struct tu_image_view *iview, iview->RB_BLIT_DST_INFO = A6XX_RB_BLIT_DST_INFO( .tile_mode = cfmt.tile_mode, - .samples = tu_msaa_samples(iview->image->samples), + .samples = tu_msaa_samples(layout->nr_samples), .color_format = cfmt.fmt, .color_swap = cfmt.swap, .flags = ubwc_enabled).value; @@ -505,16 +502,9 @@ tu_CreateImage(VkDevice _device, if (!image) return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); - image->type = pCreateInfo->imageType; - image->vk_format = pCreateInfo->format; - image->tiling = pCreateInfo->tiling; - image->usage = pCreateInfo->usage; - image->flags = pCreateInfo->flags; - image->extent = pCreateInfo->extent; image->level_count = pCreateInfo->mipLevels; image->layer_count = pCreateInfo->arrayLayers; - image->samples = pCreateInfo->samples; enum a6xx_tile_mode tile_mode = TILE6_3; bool ubwc_enabled = @@ -567,7 +557,7 @@ tu_CreateImage(VkDevice _device, if (image->vk_format == VK_FORMAT_S8_UINT) ubwc_enabled = false; - if (image->extent.depth > 1) { + if (pCreateInfo->extent.depth > 1) { tu_finishme("UBWC with 3D textures"); ubwc_enabled = false; } @@ -581,7 +571,7 @@ tu_CreateImage(VkDevice _device, * UBWC-enabled mipmaps in freedreno currently. Just match the closed GL * behavior of no UBWC. */ - if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) + if (pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) ubwc_enabled = false; /* Disable UBWC for D24S8 on A630 in some cases @@ -597,7 +587,7 @@ tu_CreateImage(VkDevice _device, */ if (device->physical_device->limited_z24s8 && image->vk_format == VK_FORMAT_D24_UNORM_S8_UINT && - (image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))) { + (pCreateInfo->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))) { ubwc_enabled = false; } @@ -633,7 +623,7 @@ tu_CreateImage(VkDevice _device, /* only expect simple 2D images for now */ if (pCreateInfo->mipLevels != 1 || pCreateInfo->arrayLayers != 1 || - image->extent.depth != 1) + pCreateInfo->extent.depth != 1) goto invalid_layout; plane_layout.offset = plane_layouts[i].offset; @@ -645,7 +635,7 @@ tu_CreateImage(VkDevice _device, layout->ubwc = ubwc_enabled; if (!fdl6_layout(layout, vk_format_to_pipe_format(format), - image->samples, + pCreateInfo->samples, width0, height0, pCreateInfo->extent.depth, pCreateInfo->mipLevels, @@ -725,8 +715,10 @@ tu_DestroyImage(VkDevice _device, if (!image) return; +#ifdef ANDROID if (image->owned_memory != VK_NULL_HANDLE) tu_FreeMemory(_device, image->owned_memory, pAllocator); +#endif vk_object_free(&device->vk, pAllocator, image); } diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 614094135df..12e317337dd 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1244,25 +1244,20 @@ struct tu_image { struct vk_object_base base; - VkImageType type; /* The original VkFormat provided by the client. This may not match any * of the actual surface formats. */ VkFormat vk_format; - VkImageAspectFlags aspects; - VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */ - VkImageTiling tiling; /** VkImageCreateInfo::tiling */ - VkImageCreateFlags flags; /** VkImageCreateInfo::flags */ - VkExtent3D extent; uint32_t level_count; uint32_t layer_count; - VkSampleCountFlagBits samples; struct fdl_layout layout[3]; uint32_t total_size; +#ifdef ANDROID /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */ VkDeviceMemory owned_memory; +#endif /* Set when bound */ struct tu_bo *bo; diff --git a/src/freedreno/vulkan/tu_util.h b/src/freedreno/vulkan/tu_util.h index eefb09a1d12..8f629a7ba59 100644 --- a/src/freedreno/vulkan/tu_util.h +++ b/src/freedreno/vulkan/tu_util.h @@ -45,7 +45,7 @@ mesa_to_vk_shader_stage(gl_shader_stage mesa_stage) stage = __builtin_ffs(__tmp) - 1, __tmp; __tmp &= ~(1 << (stage))) static inline enum a3xx_msaa_samples -tu_msaa_samples(VkSampleCountFlagBits samples) +tu_msaa_samples(uint32_t samples) { assert(__builtin_popcount(samples) == 1); return util_logbase2(samples); _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
