Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e397949

Browse files
ShabbyXCommit Bot
authored andcommitted
Vulkan: shave off 60 bytes from AttachmentOpsArray
Bug: angleproject:2361 Change-Id: I39eb34b3c415fa165fa7803b2bc09338833f6773 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1496039 Reviewed-by: Jamie Madill <jmadill@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 parent a8300e5 commit e397949

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/libANGLE/renderer/vulkan/vk_cache_utils.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using RefCountedPipelineLayout = RefCounted<PipelineLayout>;
3030

3131
// Packed Vk resource descriptions.
3232
// Most Vk types use many more bits than required to represent the underlying data.
33-
// Since ANGLE wants cache things like RenderPasses and Pipeline State Objects using
33+
// Since ANGLE wants to cache things like RenderPasses and Pipeline State Objects using
3434
// hashing (and also needs to check equality) we can optimize these operations by
3535
// using fewer bits. Hence the packed types.
3636
//
@@ -86,19 +86,21 @@ bool operator==(const RenderPassDesc &lhs, const RenderPassDesc &rhs);
8686
constexpr size_t kRenderPassDescSize = sizeof(RenderPassDesc);
8787
static_assert(kRenderPassDescSize == 12, "Size check failed");
8888

89-
struct alignas(8) PackedAttachmentOpsDesc final
89+
struct PackedAttachmentOpsDesc final
9090
{
91-
uint8_t loadOp;
92-
uint8_t storeOp;
93-
uint8_t stencilLoadOp;
94-
uint8_t stencilStoreOp;
91+
// VkAttachmentLoadOp is in range [0, 2], and VkAttachmentStoreOp is in range [0, 1].
92+
uint16_t loadOp : 2;
93+
uint16_t storeOp : 1;
94+
uint16_t stencilLoadOp : 2;
95+
uint16_t stencilStoreOp : 1;
9596

96-
// 16-bits to force pad the structure to exactly 8 bytes.
97-
uint16_t initialLayout;
98-
uint16_t finalLayout;
97+
// 5-bits to force pad the structure to exactly 2 bytes. Note that we currently don't support
98+
// any of the extension layouts, whose values start at 1'000'000'000.
99+
uint16_t initialLayout : 5;
100+
uint16_t finalLayout : 5;
99101
};
100102

101-
static_assert(sizeof(PackedAttachmentOpsDesc) == 8, "Size check failed");
103+
static_assert(sizeof(PackedAttachmentOpsDesc) == 2, "Size check failed");
102104

103105
class AttachmentOpsArray final
104106
{
@@ -122,7 +124,7 @@ class AttachmentOpsArray final
122124

123125
bool operator==(const AttachmentOpsArray &lhs, const AttachmentOpsArray &rhs);
124126

125-
static_assert(sizeof(AttachmentOpsArray) == 80, "Size check failed");
127+
static_assert(sizeof(AttachmentOpsArray) == 20, "Size check failed");
126128

127129
struct PackedAttribDesc final
128130
{

0 commit comments

Comments
 (0)