anv/image: Move common code to anv_image.c
This commit is contained in:
+70
-15
@@ -400,6 +400,48 @@ anv_validate_CreateImageView(VkDevice _device,
|
||||
return anv_CreateImageView(_device, pCreateInfo, pAllocator, pView);
|
||||
}
|
||||
|
||||
void
|
||||
anv_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage)
|
||||
{
|
||||
switch (device->info.gen) {
|
||||
case 7:
|
||||
if (device->info.is_haswell)
|
||||
gen75_fill_image_surface_state(device, state_map, iview,
|
||||
pCreateInfo, usage);
|
||||
else
|
||||
gen7_fill_image_surface_state(device, state_map, iview,
|
||||
pCreateInfo, usage);
|
||||
break;
|
||||
case 8:
|
||||
gen8_fill_image_surface_state(device, state_map, iview,
|
||||
pCreateInfo, usage);
|
||||
break;
|
||||
case 9:
|
||||
gen9_fill_image_surface_state(device, state_map, iview,
|
||||
pCreateInfo, usage);
|
||||
break;
|
||||
default:
|
||||
unreachable("unsupported gen\n");
|
||||
}
|
||||
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->nonrt_surface_state);
|
||||
}
|
||||
|
||||
static struct anv_state
|
||||
alloc_surface_state(struct anv_device *device,
|
||||
struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
if (cmd_buffer) {
|
||||
return anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
||||
} else {
|
||||
return anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
anv_image_view_init(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
@@ -447,21 +489,34 @@ anv_image_view_init(struct anv_image_view *iview,
|
||||
.depth = anv_minify(image->extent.depth, range->baseMipLevel),
|
||||
};
|
||||
|
||||
switch (device->info.gen) {
|
||||
case 7:
|
||||
if (device->info.is_haswell)
|
||||
gen75_image_view_init(iview, device, pCreateInfo, cmd_buffer);
|
||||
else
|
||||
gen7_image_view_init(iview, device, pCreateInfo, cmd_buffer);
|
||||
break;
|
||||
case 8:
|
||||
gen8_image_view_init(iview, device, pCreateInfo, cmd_buffer);
|
||||
break;
|
||||
case 9:
|
||||
gen9_image_view_init(iview, device, pCreateInfo, cmd_buffer);
|
||||
break;
|
||||
default:
|
||||
unreachable("unsupported gen\n");
|
||||
if (image->needs_nonrt_surface_state) {
|
||||
iview->nonrt_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
anv_fill_image_surface_state(device, iview->nonrt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||
} else {
|
||||
iview->nonrt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_color_rt_surface_state) {
|
||||
iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
anv_fill_image_surface_state(device, iview->color_rt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
||||
} else {
|
||||
iview->color_rt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_storage_surface_state) {
|
||||
iview->storage_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
anv_fill_image_surface_state(device, iview->storage_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT);
|
||||
} else {
|
||||
iview->storage_surface_state.alloc_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-19
@@ -1599,28 +1599,30 @@ void anv_image_view_init(struct anv_image_view *view,
|
||||
struct anv_cmd_buffer *cmd_buffer);
|
||||
|
||||
void
|
||||
gen7_image_view_init(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer);
|
||||
|
||||
anv_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage);
|
||||
void
|
||||
gen75_image_view_init(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer);
|
||||
|
||||
gen7_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage);
|
||||
void
|
||||
gen8_image_view_init(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer);
|
||||
|
||||
gen75_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage);
|
||||
void
|
||||
gen9_image_view_init(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer);
|
||||
gen8_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage);
|
||||
void
|
||||
gen9_fill_image_surface_state(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage);
|
||||
|
||||
struct anv_buffer_view {
|
||||
enum isl_format format; /**< VkBufferViewCreateInfo::format */
|
||||
|
||||
+4
-57
@@ -65,17 +65,6 @@ genX(fill_buffer_surface_state)(void *state, enum isl_format format,
|
||||
GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &surface_state);
|
||||
}
|
||||
|
||||
static struct anv_state
|
||||
alloc_surface_state(struct anv_device *device,
|
||||
struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
if (cmd_buffer) {
|
||||
return anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
||||
} else {
|
||||
return anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult genX(CreateSampler)(
|
||||
VkDevice _device,
|
||||
const VkSamplerCreateInfo* pCreateInfo,
|
||||
@@ -148,12 +137,15 @@ static const uint8_t anv_valign[] = {
|
||||
[4] = VALIGN_4,
|
||||
};
|
||||
|
||||
static void
|
||||
void
|
||||
genX(fill_image_surface_state)(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
VkImageUsageFlagBits usage)
|
||||
{
|
||||
if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
|
||||
anv_finishme("non-2D image views");
|
||||
|
||||
assert(usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_STORAGE_BIT |
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT));
|
||||
@@ -249,49 +241,4 @@ genX(fill_image_surface_state)(struct anv_device *device, void *state_map,
|
||||
}
|
||||
|
||||
GENX(RENDER_SURFACE_STATE_pack)(NULL, state_map, &template);
|
||||
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->nonrt_surface_state);
|
||||
}
|
||||
|
||||
GENX_FUNC(GEN7, GEN75) void
|
||||
genX(image_view_init)(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
|
||||
|
||||
if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
|
||||
anv_finishme("non-2D image views");
|
||||
|
||||
if (image->needs_nonrt_surface_state) {
|
||||
iview->nonrt_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->nonrt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||
} else {
|
||||
iview->nonrt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_color_rt_surface_state) {
|
||||
iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->color_rt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
||||
} else {
|
||||
iview->color_rt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_storage_surface_state) {
|
||||
iview->storage_surface_state = alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->storage_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT);
|
||||
} else {
|
||||
iview->storage_surface_state.alloc_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-57
@@ -78,17 +78,6 @@ static const uint8_t anv_valign[] = {
|
||||
[16] = VALIGN16,
|
||||
};
|
||||
|
||||
static struct anv_state
|
||||
alloc_surface_state(struct anv_device *device,
|
||||
struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
if (cmd_buffer) {
|
||||
return anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
||||
} else {
|
||||
return anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the values to pack into RENDER_SUFFACE_STATE.SurfaceHorizontalAlignment
|
||||
* and SurfaceVerticalAlignment.
|
||||
@@ -162,7 +151,7 @@ get_qpitch(const struct isl_surf *surf)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
genX(fill_image_surface_state)(struct anv_device *device, void *state_map,
|
||||
struct anv_image_view *iview,
|
||||
const VkImageViewCreateInfo *pCreateInfo,
|
||||
@@ -320,51 +309,6 @@ genX(fill_image_surface_state)(struct anv_device *device, void *state_map,
|
||||
}
|
||||
|
||||
GENX(RENDER_SURFACE_STATE_pack)(NULL, state_map, &template);
|
||||
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->nonrt_surface_state);
|
||||
}
|
||||
|
||||
void
|
||||
genX(image_view_init)(struct anv_image_view *iview,
|
||||
struct anv_device *device,
|
||||
const VkImageViewCreateInfo* pCreateInfo,
|
||||
struct anv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
|
||||
|
||||
if (image->needs_nonrt_surface_state) {
|
||||
iview->nonrt_surface_state =
|
||||
alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->nonrt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||
} else {
|
||||
iview->nonrt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_color_rt_surface_state) {
|
||||
iview->color_rt_surface_state =
|
||||
alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->color_rt_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
||||
} else {
|
||||
iview->color_rt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_storage_surface_state) {
|
||||
iview->storage_surface_state =
|
||||
alloc_surface_state(device, cmd_buffer);
|
||||
|
||||
genX(fill_image_surface_state)(device, iview->storage_surface_state.map,
|
||||
iview, pCreateInfo,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT);
|
||||
} else {
|
||||
iview->storage_surface_state.alloc_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VkResult genX(CreateSampler)(
|
||||
|
||||
Reference in New Issue
Block a user