};
static uint32_t
-anv_image_choose_tile_mode(const VkImageCreateInfo *vk_info,
- const struct anv_image_create_info *anv_info)
+anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
{
- if (anv_info)
+ if (anv_info->force_tile_mode)
return anv_info->tile_mode;
- switch (vk_info->tiling) {
+ switch (anv_info->vk_info->tiling) {
case VK_IMAGE_TILING_LINEAR:
return LINEAR;
case VK_IMAGE_TILING_OPTIMAL:
VkResult anv_image_create(
VkDevice _device,
- const VkImageCreateInfo* pCreateInfo,
- const struct anv_image_create_info * extra,
+ const struct anv_image_create_info * create_info,
VkImage* pImage)
{
struct anv_device *device = (struct anv_device *) _device;
+ const VkImageCreateInfo *pCreateInfo = create_info->vk_info;
const VkExtent3D *restrict extent = &pCreateInfo->extent;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
anv_assert(pCreateInfo->extent.height > 0);
anv_assert(pCreateInfo->extent.depth == 1);
- const uint32_t tile_mode =
- anv_image_choose_tile_mode(pCreateInfo, extra);
+ const uint32_t tile_mode = anv_image_choose_tile_mode(create_info);
/* TODO(chadv): How should we validate inputs? */
const uint8_t surf_type =
const VkImageCreateInfo* pCreateInfo,
VkImage* pImage)
{
- return anv_image_create(device, pCreateInfo, NULL, pImage);
+ return anv_image_create(device,
+ &(struct anv_image_create_info) {
+ .vk_info = pCreateInfo,
+ },
+ pImage);
}
VkResult anv_GetImageSubresourceInfo(
};
struct anv_image_create_info {
- uint32_t tile_mode;
+ const VkImageCreateInfo *vk_info;
+ bool force_tile_mode;
+ uint8_t tile_mode;
};
VkResult anv_image_create(VkDevice _device,
- const VkImageCreateInfo *pCreateInfo,
- const struct anv_image_create_info *extra,
+ const struct anv_image_create_info *info,
VkImage *pImage);
void anv_image_view_init(struct anv_surface_view *view,
struct anv_device_memory *memory;
anv_image_create((VkDevice) device,
- &(VkImageCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
- .imageType = VK_IMAGE_TYPE_2D,
- .format = pCreateInfo->imageFormat,
- .extent = {
- .width = pCreateInfo->imageExtent.width,
- .height = pCreateInfo->imageExtent.height,
- .depth = 1
- },
- .mipLevels = 1,
- .arraySize = 1,
- .samples = 1,
- /* FIXME: Need a way to use X tiling to allow scanout */
- .tiling = VK_IMAGE_TILING_OPTIMAL,
- .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
- .flags = 0,
- },
- &(struct anv_image_create_info) {
- .tile_mode = XMAJOR
- },
- (VkImage *) &image);
+ &(struct anv_image_create_info) {
+ .force_tile_mode = true,
+ .tile_mode = XMAJOR,
+ .vk_info =
+ &(VkImageCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
+ .imageType = VK_IMAGE_TYPE_2D,
+ .format = pCreateInfo->imageFormat,
+ .extent = {
+ .width = pCreateInfo->imageExtent.width,
+ .height = pCreateInfo->imageExtent.height,
+ .depth = 1
+ },
+ .mipLevels = 1,
+ .arraySize = 1,
+ .samples = 1,
+ /* FIXME: Need a way to use X tiling to allow scanout */
+ .tiling = VK_IMAGE_TILING_OPTIMAL,
+ .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ .flags = 0,
+ }},
+ (VkImage *) &image);
anv_AllocMemory((VkDevice) device,
&(VkMemoryAllocInfo) {