Skip to content

Commit

Permalink
Vulkan: shave off 60 bytes from AttachmentOpsArray
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ShabbyX authored and Commit Bot committed Mar 6, 2019
1 parent a8300e5 commit e397949
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/libANGLE/renderer/vulkan/vk_cache_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using RefCountedPipelineLayout = RefCounted<PipelineLayout>;

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

struct alignas(8) PackedAttachmentOpsDesc final
struct PackedAttachmentOpsDesc final
{
uint8_t loadOp;
uint8_t storeOp;
uint8_t stencilLoadOp;
uint8_t stencilStoreOp;
// VkAttachmentLoadOp is in range [0, 2], and VkAttachmentStoreOp is in range [0, 1].
uint16_t loadOp : 2;
uint16_t storeOp : 1;
uint16_t stencilLoadOp : 2;
uint16_t stencilStoreOp : 1;

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

static_assert(sizeof(PackedAttachmentOpsDesc) == 8, "Size check failed");
static_assert(sizeof(PackedAttachmentOpsDesc) == 2, "Size check failed");

class AttachmentOpsArray final
{
Expand All @@ -122,7 +124,7 @@ class AttachmentOpsArray final

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

static_assert(sizeof(AttachmentOpsArray) == 80, "Size check failed");
static_assert(sizeof(AttachmentOpsArray) == 20, "Size check failed");

struct PackedAttribDesc final
{
Expand Down

0 comments on commit e397949

Please sign in to comment.