blob: f6bf19af4f62b541401a64903a9ff012cf9191f9 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
2* Copyright 2015 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef GrVkStencil_DEFINED
9#define GrVkStencil_DEFINED
10
11#include "GrStencilAttachment.h"
12#include "GrVkImage.h"
jvanverthe50f3e72016-03-28 07:03:06 -070013#include "vk/GrVkDefines.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050014
15class GrVkImageView;
16class GrVkGpu;
17
egdaniele015c262016-02-26 13:12:00 -080018class GrVkStencilAttachment : public GrStencilAttachment, public GrVkImage {
Greg Daniel164a9f02016-02-22 09:56:40 -050019public:
20 struct Format {
21 VkFormat fInternalFormat;
22 int fStencilBits;
23 int fTotalBits;
24 bool fPacked;
25 };
26
kkinnunen2e6055b2016-04-22 01:48:29 -070027 static GrVkStencilAttachment* Create(GrVkGpu* gpu, int width, int height,
Greg Daniel164a9f02016-02-22 09:56:40 -050028 int sampleCnt, const Format& format);
29
30 ~GrVkStencilAttachment() override;
31
egdanielb2df0c22016-05-13 11:30:37 -070032 const GrVkResource* imageResource() const { return this->resource(); }
Greg Daniel164a9f02016-02-22 09:56:40 -050033 const GrVkImageView* stencilView() const { return fStencilView; }
34
35 VkFormat vkFormat() const { return fFormat.fInternalFormat; }
36
37protected:
38 void onRelease() override;
39 void onAbandon() override;
40
41private:
42 size_t onGpuMemorySize() const override;
43
44 GrVkStencilAttachment(GrVkGpu* gpu,
Greg Daniel164a9f02016-02-22 09:56:40 -050045 const Format& format,
46 const GrVkImage::ImageDesc&,
egdanielb2df0c22016-05-13 11:30:37 -070047 const GrVkImageInfo&,
Greg Daniel164a9f02016-02-22 09:56:40 -050048 const GrVkImageView* stencilView);
49
50 GrVkGpu* getVkGpu() const;
51
52 Format fFormat;
53
Greg Daniel164a9f02016-02-22 09:56:40 -050054 const GrVkImageView* fStencilView;
Greg Daniel164a9f02016-02-22 09:56:40 -050055};
56
57#endif