summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2015-08-17 14:03:52 -0700
committerChad Versace <[email protected]>2015-08-17 14:08:55 -0700
commit6ff95bba8abd50b47117f733d3e46fb90333210f (patch)
treecfe146ab77cf559097c5beb767aa6fee9fae6e9e
parent5a6b2e6df0ac63e20856dfcd1fc9f0ff73ae67e2 (diff)
vk: Add anv_format reference to anv_render_pass_attachment
Change type of anv_render_pass_attachment::format from VkFormat to const struct anv_format*. This elimiates the repetitive lookups into the VkFormat -> anv_format table when looping over attachments during anv_cmd_buffer_clear_attachments().
-rw-r--r--src/vulkan/anv_device.c3
-rw-r--r--src/vulkan/anv_formats.c13
-rw-r--r--src/vulkan/anv_image.c5
-rw-r--r--src/vulkan/anv_meta.c4
-rw-r--r--src/vulkan/anv_private.h9
5 files changed, 15 insertions, 19 deletions
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c
index 0f06f3e5a91..145d16f485e 100644
--- a/src/vulkan/anv_device.c
+++ b/src/vulkan/anv_device.c
@@ -2229,7 +2229,8 @@ VkResult anv_CreateRenderPass(
pass->attachments = anv_device_alloc(device, size, 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
- pass->attachments[i].format = pCreateInfo->pAttachments[i].format;
+ pass->attachments[i].format =
+ anv_format_for_vk_format(pCreateInfo->pAttachments[i].format);
pass->attachments[i].samples = pCreateInfo->pAttachments[i].samples;
pass->attachments[i].load_op = pCreateInfo->pAttachments[i].loadOp;
pass->attachments[i].stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
diff --git a/src/vulkan/anv_formats.c b/src/vulkan/anv_formats.c
index 9b971a18ac2..f5d00a0f8ff 100644
--- a/src/vulkan/anv_formats.c
+++ b/src/vulkan/anv_formats.c
@@ -218,19 +218,6 @@ anv_format_for_vk_format(VkFormat format)
return &anv_formats[format];
}
-bool
-anv_is_vk_format_depth_or_stencil(VkFormat format)
-{
- const struct anv_format *format_info =
- anv_format_for_vk_format(format);
-
- if (format_info->depth_format != UNSUPPORTED &&
- format_info->depth_format != 0)
- return true;
-
- return format_info->has_stencil;
-}
-
// Format capabilities
struct surface_format_info {
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c
index 3b706c68443..0152fef9ffb 100644
--- a/src/vulkan/anv_image.c
+++ b/src/vulkan/anv_image.c
@@ -689,7 +689,10 @@ anv_CreateAttachmentView(VkDevice _device,
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
- if (anv_is_vk_format_depth_or_stencil(pCreateInfo->format)) {
+ const struct anv_format *format =
+ anv_format_for_vk_format(pCreateInfo->format);
+
+ if (anv_format_is_depth_or_stencil(format)) {
struct anv_depth_stencil_view *view =
anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c
index d3dbd6bafc7..8808d312db4 100644
--- a/src/vulkan/anv_meta.c
+++ b/src/vulkan/anv_meta.c
@@ -269,7 +269,7 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
int num_clear_layers = 0;
for (uint32_t i = 0; i < pass->attachment_count; i++) {
if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
- if (anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
+ if (anv_format_is_depth_or_stencil(pass->attachments[i].format)) {
anv_finishme("Can't clear depth-stencil yet");
continue;
}
@@ -286,7 +286,7 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
int layer = 0;
for (uint32_t i = 0; i < pass->attachment_count; i++) {
if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR &&
- !anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
+ !anv_format_is_depth_or_stencil(pass->attachments[i].format)) {
instance_data[layer] = (struct clear_instance_data) {
.vue_header = {
.RTAIndex = i,
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index ee2700254cd..1b2cfc6fa0c 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -888,7 +888,12 @@ extern const struct anv_format *const anv_format_s8_uint;
const struct anv_format *
anv_format_for_vk_format(VkFormat format);
-bool anv_is_vk_format_depth_or_stencil(VkFormat format);
+
+static inline bool
+anv_format_is_depth_or_stencil(const struct anv_format *format)
+{
+ return format->depth_format || format->has_stencil;
+}
/**
* A proxy for the color surfaces, depth surfaces, and stencil surfaces.
@@ -1042,7 +1047,7 @@ struct anv_subpass {
};
struct anv_render_pass_attachment {
- VkFormat format;
+ const struct anv_format *format;
uint32_t samples;
VkAttachmentLoadOp load_op;
VkAttachmentLoadOp stencil_load_op;