diff options
author | Chad Versace <[email protected]> | 2015-12-09 16:59:02 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2015-12-14 10:46:27 -0800 |
commit | ee57062e1ec5d1d4666239c5a9c426982861f375 (patch) | |
tree | 414c27925118fb115dd524e2b8c03644ee88730e | |
parent | f0d11d5a814b792eb5f5161e9332123aaaf689fb (diff) |
anv: Remove anv_image::surface_type
When building RENDER_SURFACE_STATE, the driver set
SurfaceType = anv_image::surface_type, which was calculated during
anv_image_init(). This was bad because the value of
anv_image::surface_type was taken from a gen-specific header,
gen8_pack.h, even though the anv_image structure is used for all gens.
Replace anv_image::surface_type with a gen-specific lookup function,
anv_surftype(), defined in gen${x}_state.c.
The lookup function contains some useful asserts that caught some nasty
bugs in anv meta, which were fixed in the previous commit.
-rw-r--r-- | src/vulkan/anv_image.c | 11 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 2 | ||||
-rw-r--r-- | src/vulkan/gen7_state.c | 26 | ||||
-rw-r--r-- | src/vulkan/gen8_state.c | 26 |
4 files changed, 50 insertions, 15 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index ffc7ae8cae6..3b3751ad1e1 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -34,12 +34,6 @@ */ #include "gen8_pack.h" -static const uint8_t anv_surf_type_from_image_type[] = { - [VK_IMAGE_TYPE_1D] = SURFTYPE_1D, - [VK_IMAGE_TYPE_2D] = SURFTYPE_2D, - [VK_IMAGE_TYPE_3D] = SURFTYPE_3D, -}; - /** * The \a format argument is required and overrides any format found in struct * anv_image_create_info. Exactly one bit must be set in \a aspect. @@ -203,10 +197,6 @@ anv_image_create(VkDevice _device, anv_assert(pCreateInfo->extent.height > 0); anv_assert(pCreateInfo->extent.depth > 0); - /* TODO(chadv): How should we validate inputs? */ - const uint8_t surf_type = - anv_surf_type_from_image_type[pCreateInfo->imageType]; - image = anv_alloc2(&device->alloc, alloc, sizeof(*image), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!image) @@ -219,7 +209,6 @@ anv_image_create(VkDevice _device, image->levels = pCreateInfo->mipLevels; image->array_size = pCreateInfo->arrayLayers; image->usage = anv_image_get_full_usage(pCreateInfo); - image->surface_type = surf_type; if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT) { image->needs_nonrt_surface_state = true; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 3b5a4be8355..07854d3e357 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1429,8 +1429,6 @@ struct anv_image { struct anv_bo *bo; VkDeviceSize offset; - uint8_t surface_type; /**< RENDER_SURFACE_STATE.SurfaceType */ - bool needs_nonrt_surface_state:1; bool needs_color_rt_surface_state:1; bool needs_storage_surface_state:1; diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index 3206f77b831..321dc3f0f5d 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -32,6 +32,30 @@ #include "gen7_pack.h" #include "gen75_pack.h" +static const uint8_t +anv_surftype(const struct anv_image *image, VkImageViewType view_type) +{ + switch (view_type) { + default: + unreachable("bad VkImageViewType"); + case VK_IMAGE_VIEW_TYPE_1D: + case VK_IMAGE_VIEW_TYPE_1D_ARRAY: + assert(image->type == VK_IMAGE_TYPE_1D); + return SURFTYPE_1D; + case VK_IMAGE_VIEW_TYPE_CUBE: + case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY: + anv_finishme("%s:%s: cube images", __FILE__, __func__); + /* fallthrough */ + case VK_IMAGE_VIEW_TYPE_2D: + case VK_IMAGE_VIEW_TYPE_2D_ARRAY: + assert(image->type == VK_IMAGE_TYPE_2D); + return SURFTYPE_2D; + case VK_IMAGE_VIEW_TYPE_3D: + assert(image->type == VK_IMAGE_TYPE_3D); + return SURFTYPE_3D; + } +} + GENX_FUNC(GEN7, GEN75) void genX(fill_buffer_surface_state)(void *state, const struct anv_format *format, uint32_t offset, uint32_t range, @@ -242,7 +266,7 @@ genX(image_view_init)(struct anv_image_view *iview, isl_surf_get_image_alignment_sa(&surface->isl); struct GENX(RENDER_SURFACE_STATE) surface_state = { - .SurfaceType = image->surface_type, + .SurfaceType = anv_surftype(image, pCreateInfo->viewType), .SurfaceArray = image->array_size > 1, .SurfaceFormat = format->surface_format, .SurfaceVerticalAlignment = anv_valign[image_align_sa.height], diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index ac1f17f48f9..0937677e8e4 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -32,6 +32,30 @@ #include "gen8_pack.h" #include "gen9_pack.h" +static const uint8_t +anv_surftype(const struct anv_image *image, VkImageViewType view_type) +{ + switch (view_type) { + default: + unreachable("bad VkImageViewType"); + case VK_IMAGE_VIEW_TYPE_1D: + case VK_IMAGE_VIEW_TYPE_1D_ARRAY: + assert(image->type == VK_IMAGE_TYPE_1D); + return SURFTYPE_1D; + case VK_IMAGE_VIEW_TYPE_CUBE: + case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY: + anv_finishme("%s:%s: cube images", __FILE__, __func__); + /* fallthrough */ + case VK_IMAGE_VIEW_TYPE_2D: + case VK_IMAGE_VIEW_TYPE_2D_ARRAY: + assert(image->type == VK_IMAGE_TYPE_2D); + return SURFTYPE_2D; + case VK_IMAGE_VIEW_TYPE_3D: + assert(image->type == VK_IMAGE_TYPE_3D); + return SURFTYPE_3D; + } +} + void genX(fill_buffer_surface_state)(void *state, const struct anv_format *format, uint32_t offset, uint32_t range, uint32_t stride) @@ -222,7 +246,7 @@ genX(image_view_init)(struct anv_image_view *iview, get_halign_valign(&surface->isl, &halign, &valign); struct GENX(RENDER_SURFACE_STATE) surface_state = { - .SurfaceType = image->surface_type, + .SurfaceType = anv_surftype(image, pCreateInfo->viewType), .SurfaceArray = image->array_size > 1, .SurfaceFormat = format_info->surface_format, .SurfaceVerticalAlignment = valign, |