xref: /aosp_15_r20/external/swiftshader/src/Device/Context.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker // Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2*03ce13f7SAndroid Build Coastguard Worker //
3*03ce13f7SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*03ce13f7SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*03ce13f7SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*03ce13f7SAndroid Build Coastguard Worker //
7*03ce13f7SAndroid Build Coastguard Worker //    http://www.apache.org/licenses/LICENSE-2.0
8*03ce13f7SAndroid Build Coastguard Worker //
9*03ce13f7SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*03ce13f7SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*03ce13f7SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*03ce13f7SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*03ce13f7SAndroid Build Coastguard Worker // limitations under the License.
14*03ce13f7SAndroid Build Coastguard Worker 
15*03ce13f7SAndroid Build Coastguard Worker #ifndef vk_Context_hpp
16*03ce13f7SAndroid Build Coastguard Worker #define vk_Context_hpp
17*03ce13f7SAndroid Build Coastguard Worker 
18*03ce13f7SAndroid Build Coastguard Worker #include "Config.hpp"
19*03ce13f7SAndroid Build Coastguard Worker #include "Memset.hpp"
20*03ce13f7SAndroid Build Coastguard Worker #include "Stream.hpp"
21*03ce13f7SAndroid Build Coastguard Worker #include "System/Types.hpp"
22*03ce13f7SAndroid Build Coastguard Worker #include "Vulkan/VkDescriptorSet.hpp"
23*03ce13f7SAndroid Build Coastguard Worker #include "Vulkan/VkFormat.hpp"
24*03ce13f7SAndroid Build Coastguard Worker 
25*03ce13f7SAndroid Build Coastguard Worker #include <vector>
26*03ce13f7SAndroid Build Coastguard Worker 
27*03ce13f7SAndroid Build Coastguard Worker namespace vk {
28*03ce13f7SAndroid Build Coastguard Worker 
29*03ce13f7SAndroid Build Coastguard Worker class Buffer;
30*03ce13f7SAndroid Build Coastguard Worker class Device;
31*03ce13f7SAndroid Build Coastguard Worker class ImageView;
32*03ce13f7SAndroid Build Coastguard Worker class PipelineLayout;
33*03ce13f7SAndroid Build Coastguard Worker class RenderPass;
34*03ce13f7SAndroid Build Coastguard Worker 
35*03ce13f7SAndroid Build Coastguard Worker struct InputsDynamicStateFlags
36*03ce13f7SAndroid Build Coastguard Worker {
37*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicVertexInputBindingStride : 1;
38*03ce13f7SAndroid Build Coastguard Worker         bool dynamicVertexInput : 1;
39*03ce13f7SAndroid Build Coastguard Worker };
40*03ce13f7SAndroid Build Coastguard Worker 
41*03ce13f7SAndroid Build Coastguard Worker // Note: The split between Inputs and VertexInputInterfaceState is mostly superficial.  The state
42*03ce13f7SAndroid Build Coastguard Worker // (be it dynamic or static) in Inputs should have been mostly a part of VertexInputInterfaceState.
43*03ce13f7SAndroid Build Coastguard Worker // Changing that requires some surgery.
44*03ce13f7SAndroid Build Coastguard Worker struct VertexInputInterfaceDynamicStateFlags
45*03ce13f7SAndroid Build Coastguard Worker {
46*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicPrimitiveRestartEnable : 1;
47*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicPrimitiveTopology : 1;
48*03ce13f7SAndroid Build Coastguard Worker };
49*03ce13f7SAndroid Build Coastguard Worker 
50*03ce13f7SAndroid Build Coastguard Worker struct PreRasterizationDynamicStateFlags
51*03ce13f7SAndroid Build Coastguard Worker {
52*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicLineWidth : 1;
53*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthBias : 1;
54*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthBiasEnable : 1;
55*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicCullMode : 1;
56*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicFrontFace : 1;
57*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicViewport : 1;
58*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicScissor : 1;
59*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicViewportWithCount : 1;
60*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicScissorWithCount : 1;
61*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicRasterizerDiscardEnable : 1;
62*03ce13f7SAndroid Build Coastguard Worker };
63*03ce13f7SAndroid Build Coastguard Worker 
64*03ce13f7SAndroid Build Coastguard Worker struct FragmentDynamicStateFlags
65*03ce13f7SAndroid Build Coastguard Worker {
66*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthTestEnable : 1;
67*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthWriteEnable : 1;
68*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthBoundsTestEnable : 1;
69*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthBounds : 1;
70*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicDepthCompareOp : 1;
71*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicStencilTestEnable : 1;
72*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicStencilOp : 1;
73*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicStencilCompareMask : 1;
74*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicStencilWriteMask : 1;
75*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicStencilReference : 1;
76*03ce13f7SAndroid Build Coastguard Worker };
77*03ce13f7SAndroid Build Coastguard Worker 
78*03ce13f7SAndroid Build Coastguard Worker struct FragmentOutputInterfaceDynamicStateFlags
79*03ce13f7SAndroid Build Coastguard Worker {
80*03ce13f7SAndroid Build Coastguard Worker 	bool dynamicBlendConstants : 1;
81*03ce13f7SAndroid Build Coastguard Worker };
82*03ce13f7SAndroid Build Coastguard Worker 
83*03ce13f7SAndroid Build Coastguard Worker struct DynamicStateFlags
84*03ce13f7SAndroid Build Coastguard Worker {
85*03ce13f7SAndroid Build Coastguard Worker     // Note: InputsDynamicStateFlags is kept local to Inputs
86*03ce13f7SAndroid Build Coastguard Worker 	VertexInputInterfaceDynamicStateFlags vertexInputInterface;
87*03ce13f7SAndroid Build Coastguard Worker 	PreRasterizationDynamicStateFlags preRasterization;
88*03ce13f7SAndroid Build Coastguard Worker 	FragmentDynamicStateFlags fragment;
89*03ce13f7SAndroid Build Coastguard Worker 	FragmentOutputInterfaceDynamicStateFlags fragmentOutputInterface;
90*03ce13f7SAndroid Build Coastguard Worker };
91*03ce13f7SAndroid Build Coastguard Worker 
92*03ce13f7SAndroid Build Coastguard Worker struct VertexInputBinding
93*03ce13f7SAndroid Build Coastguard Worker {
94*03ce13f7SAndroid Build Coastguard Worker 	Buffer *buffer = nullptr;
95*03ce13f7SAndroid Build Coastguard Worker 	VkDeviceSize offset = 0;
96*03ce13f7SAndroid Build Coastguard Worker 	VkDeviceSize size = 0;
97*03ce13f7SAndroid Build Coastguard Worker };
98*03ce13f7SAndroid Build Coastguard Worker 
99*03ce13f7SAndroid Build Coastguard Worker struct IndexBuffer
100*03ce13f7SAndroid Build Coastguard Worker {
getIndexTypevk::IndexBuffer101*03ce13f7SAndroid Build Coastguard Worker 	inline VkIndexType getIndexType() const { return indexType; }
102*03ce13f7SAndroid Build Coastguard Worker 	void setIndexBufferBinding(const VertexInputBinding &indexBufferBinding, VkIndexType type);
103*03ce13f7SAndroid Build Coastguard Worker 	void getIndexBuffers(VkPrimitiveTopology topology, uint32_t count, uint32_t first, bool indexed, bool hasPrimitiveRestartEnable, std::vector<std::pair<uint32_t, void *>> *indexBuffers) const;
104*03ce13f7SAndroid Build Coastguard Worker 
105*03ce13f7SAndroid Build Coastguard Worker private:
106*03ce13f7SAndroid Build Coastguard Worker 	uint32_t bytesPerIndex() const;
107*03ce13f7SAndroid Build Coastguard Worker 
108*03ce13f7SAndroid Build Coastguard Worker 	VertexInputBinding binding;
109*03ce13f7SAndroid Build Coastguard Worker 	VkIndexType indexType;
110*03ce13f7SAndroid Build Coastguard Worker };
111*03ce13f7SAndroid Build Coastguard Worker 
112*03ce13f7SAndroid Build Coastguard Worker struct Attachments
113*03ce13f7SAndroid Build Coastguard Worker {
114*03ce13f7SAndroid Build Coastguard Worker 	ImageView *colorBuffer[sw::MAX_COLOR_BUFFERS] = {};
115*03ce13f7SAndroid Build Coastguard Worker 	ImageView *depthBuffer = nullptr;
116*03ce13f7SAndroid Build Coastguard Worker 	ImageView *stencilBuffer = nullptr;
117*03ce13f7SAndroid Build Coastguard Worker 
118*03ce13f7SAndroid Build Coastguard Worker 	// VK_KHR_dynamic_rendering_local_read allows color locations to be mapped to the render
119*03ce13f7SAndroid Build Coastguard Worker 	// pass attachments, but blend and other state is not affected by this map.  The image views
120*03ce13f7SAndroid Build Coastguard Worker 	// placed in colorBuffer are indexed by "location" (i.e the decoration in the shader), and
121*03ce13f7SAndroid Build Coastguard Worker 	// the following maps facilitate the association between the attachment-specific state and
122*03ce13f7SAndroid Build Coastguard Worker 	// the location-indexed color buffers.
123*03ce13f7SAndroid Build Coastguard Worker 	uint32_t indexToLocation[sw::MAX_COLOR_BUFFERS] = {};
124*03ce13f7SAndroid Build Coastguard Worker 	uint32_t locationToIndex[sw::MAX_COLOR_BUFFERS] = {};
125*03ce13f7SAndroid Build Coastguard Worker 
126*03ce13f7SAndroid Build Coastguard Worker 	VkFormat colorFormat(int location) const;
127*03ce13f7SAndroid Build Coastguard Worker 	VkFormat depthFormat() const;
128*03ce13f7SAndroid Build Coastguard Worker 	VkFormat depthStencilFormat() const;
129*03ce13f7SAndroid Build Coastguard Worker };
130*03ce13f7SAndroid Build Coastguard Worker 
131*03ce13f7SAndroid Build Coastguard Worker struct DynamicState;
132*03ce13f7SAndroid Build Coastguard Worker struct Inputs
133*03ce13f7SAndroid Build Coastguard Worker {
134*03ce13f7SAndroid Build Coastguard Worker 	void initialize(const VkPipelineVertexInputStateCreateInfo *vertexInputState, const VkPipelineDynamicStateCreateInfo *dynamicStateCreateInfo);
135*03ce13f7SAndroid Build Coastguard Worker 
136*03ce13f7SAndroid Build Coastguard Worker 	void updateDescriptorSets(const DescriptorSet::Array &dso,
137*03ce13f7SAndroid Build Coastguard Worker 	                          const DescriptorSet::Bindings &ds,
138*03ce13f7SAndroid Build Coastguard Worker 	                          const DescriptorSet::DynamicOffsets &ddo);
getDescriptorSetObjectsvk::Inputs139*03ce13f7SAndroid Build Coastguard Worker 	inline const DescriptorSet::Array &getDescriptorSetObjects() const { return descriptorSetObjects; }
getDescriptorSetsvk::Inputs140*03ce13f7SAndroid Build Coastguard Worker 	inline const DescriptorSet::Bindings &getDescriptorSets() const { return descriptorSets; }
getDescriptorDynamicOffsetsvk::Inputs141*03ce13f7SAndroid Build Coastguard Worker 	inline const DescriptorSet::DynamicOffsets &getDescriptorDynamicOffsets() const { return descriptorDynamicOffsets; }
getStreamvk::Inputs142*03ce13f7SAndroid Build Coastguard Worker 	inline const sw::Stream &getStream(uint32_t i) const { return stream[i]; }
143*03ce13f7SAndroid Build Coastguard Worker 
144*03ce13f7SAndroid Build Coastguard Worker 	void bindVertexInputs(int firstInstance);
145*03ce13f7SAndroid Build Coastguard Worker 	void setVertexInputBinding(const VertexInputBinding vertexInputBindings[], const DynamicState &dynamicState);
146*03ce13f7SAndroid Build Coastguard Worker 	void advanceInstanceAttributes();
147*03ce13f7SAndroid Build Coastguard Worker 	VkDeviceSize getVertexStride(uint32_t i) const;
148*03ce13f7SAndroid Build Coastguard Worker 	VkDeviceSize getInstanceStride(uint32_t i) const;
149*03ce13f7SAndroid Build Coastguard Worker 
150*03ce13f7SAndroid Build Coastguard Worker private:
151*03ce13f7SAndroid Build Coastguard Worker 	InputsDynamicStateFlags dynamicStateFlags = {};
152*03ce13f7SAndroid Build Coastguard Worker 	VertexInputBinding vertexInputBindings[MAX_VERTEX_INPUT_BINDINGS] = {};
153*03ce13f7SAndroid Build Coastguard Worker 	DescriptorSet::Array descriptorSetObjects = {};
154*03ce13f7SAndroid Build Coastguard Worker 	DescriptorSet::Bindings descriptorSets = {};
155*03ce13f7SAndroid Build Coastguard Worker 	DescriptorSet::DynamicOffsets descriptorDynamicOffsets = {};
156*03ce13f7SAndroid Build Coastguard Worker 	sw::Stream stream[sw::MAX_INTERFACE_COMPONENTS / 4];
157*03ce13f7SAndroid Build Coastguard Worker };
158*03ce13f7SAndroid Build Coastguard Worker 
159*03ce13f7SAndroid Build Coastguard Worker struct MultisampleState
160*03ce13f7SAndroid Build Coastguard Worker {
161*03ce13f7SAndroid Build Coastguard Worker 	bool sampleShadingEnable = false;
162*03ce13f7SAndroid Build Coastguard Worker 	bool alphaToCoverage = false;
163*03ce13f7SAndroid Build Coastguard Worker 
164*03ce13f7SAndroid Build Coastguard Worker 	int sampleCount = 0;
165*03ce13f7SAndroid Build Coastguard Worker 	unsigned int multiSampleMask = 0;
166*03ce13f7SAndroid Build Coastguard Worker 	float minSampleShading = 0.0f;
167*03ce13f7SAndroid Build Coastguard Worker 
168*03ce13f7SAndroid Build Coastguard Worker 	void set(const VkPipelineMultisampleStateCreateInfo *multisampleState);
169*03ce13f7SAndroid Build Coastguard Worker };
170*03ce13f7SAndroid Build Coastguard Worker 
171*03ce13f7SAndroid Build Coastguard Worker struct BlendState : sw::Memset<BlendState>
172*03ce13f7SAndroid Build Coastguard Worker {
BlendStatevk::BlendState173*03ce13f7SAndroid Build Coastguard Worker 	BlendState()
174*03ce13f7SAndroid Build Coastguard Worker 	    : Memset(this, 0)
175*03ce13f7SAndroid Build Coastguard Worker 	{}
176*03ce13f7SAndroid Build Coastguard Worker 
BlendStatevk::BlendState177*03ce13f7SAndroid Build Coastguard Worker 	BlendState(bool alphaBlendEnable,
178*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendFactor sourceBlendFactor,
179*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendFactor destBlendFactor,
180*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendOp blendOperation,
181*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendFactor sourceBlendFactorAlpha,
182*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendFactor destBlendFactorAlpha,
183*03ce13f7SAndroid Build Coastguard Worker 	           VkBlendOp blendOperationAlpha)
184*03ce13f7SAndroid Build Coastguard Worker 	    : Memset(this, 0)
185*03ce13f7SAndroid Build Coastguard Worker 	    , alphaBlendEnable(alphaBlendEnable)
186*03ce13f7SAndroid Build Coastguard Worker 	    , sourceBlendFactor(sourceBlendFactor)
187*03ce13f7SAndroid Build Coastguard Worker 	    , destBlendFactor(destBlendFactor)
188*03ce13f7SAndroid Build Coastguard Worker 	    , blendOperation(blendOperation)
189*03ce13f7SAndroid Build Coastguard Worker 	    , sourceBlendFactorAlpha(sourceBlendFactorAlpha)
190*03ce13f7SAndroid Build Coastguard Worker 	    , destBlendFactorAlpha(destBlendFactorAlpha)
191*03ce13f7SAndroid Build Coastguard Worker 	    , blendOperationAlpha(blendOperationAlpha)
192*03ce13f7SAndroid Build Coastguard Worker 	{}
193*03ce13f7SAndroid Build Coastguard Worker 
194*03ce13f7SAndroid Build Coastguard Worker 	bool alphaBlendEnable;
195*03ce13f7SAndroid Build Coastguard Worker 	VkBlendFactor sourceBlendFactor;
196*03ce13f7SAndroid Build Coastguard Worker 	VkBlendFactor destBlendFactor;
197*03ce13f7SAndroid Build Coastguard Worker 	VkBlendOp blendOperation;
198*03ce13f7SAndroid Build Coastguard Worker 	VkBlendFactor sourceBlendFactorAlpha;
199*03ce13f7SAndroid Build Coastguard Worker 	VkBlendFactor destBlendFactorAlpha;
200*03ce13f7SAndroid Build Coastguard Worker 	VkBlendOp blendOperationAlpha;
201*03ce13f7SAndroid Build Coastguard Worker };
202*03ce13f7SAndroid Build Coastguard Worker 
203*03ce13f7SAndroid Build Coastguard Worker struct DynamicVertexInputBindingState
204*03ce13f7SAndroid Build Coastguard Worker {
205*03ce13f7SAndroid Build Coastguard Worker 	VkVertexInputRate inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
206*03ce13f7SAndroid Build Coastguard Worker 	VkDeviceSize stride = 0;
207*03ce13f7SAndroid Build Coastguard Worker 	unsigned int divisor = 0;
208*03ce13f7SAndroid Build Coastguard Worker };
209*03ce13f7SAndroid Build Coastguard Worker 
210*03ce13f7SAndroid Build Coastguard Worker struct DynamicVertexInputAttributeState
211*03ce13f7SAndroid Build Coastguard Worker {
212*03ce13f7SAndroid Build Coastguard Worker 	VkFormat format = VK_FORMAT_UNDEFINED;
213*03ce13f7SAndroid Build Coastguard Worker 	unsigned int offset = 0;
214*03ce13f7SAndroid Build Coastguard Worker 	unsigned int binding = 0;
215*03ce13f7SAndroid Build Coastguard Worker };
216*03ce13f7SAndroid Build Coastguard Worker 
217*03ce13f7SAndroid Build Coastguard Worker struct DynamicState
218*03ce13f7SAndroid Build Coastguard Worker {
219*03ce13f7SAndroid Build Coastguard Worker 	VkViewport viewport = {};
220*03ce13f7SAndroid Build Coastguard Worker 	VkRect2D scissor = {};
221*03ce13f7SAndroid Build Coastguard Worker 	sw::float4 blendConstants = {};
222*03ce13f7SAndroid Build Coastguard Worker 	float depthBiasConstantFactor = 0.0f;
223*03ce13f7SAndroid Build Coastguard Worker 	float depthBiasClamp = 0.0f;
224*03ce13f7SAndroid Build Coastguard Worker 	float depthBiasSlopeFactor = 0.0f;
225*03ce13f7SAndroid Build Coastguard Worker 	float minDepthBounds = 0.0f;
226*03ce13f7SAndroid Build Coastguard Worker 	float maxDepthBounds = 0.0f;
227*03ce13f7SAndroid Build Coastguard Worker 	float lineWidth = 0.0f;
228*03ce13f7SAndroid Build Coastguard Worker 
229*03ce13f7SAndroid Build Coastguard Worker 	VkCullModeFlags cullMode = VK_CULL_MODE_NONE;
230*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 depthBoundsTestEnable = VK_FALSE;
231*03ce13f7SAndroid Build Coastguard Worker 	VkCompareOp depthCompareOp = VK_COMPARE_OP_NEVER;
232*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 depthTestEnable = VK_FALSE;
233*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 depthWriteEnable = VK_FALSE;
234*03ce13f7SAndroid Build Coastguard Worker 	VkFrontFace frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
235*03ce13f7SAndroid Build Coastguard Worker 	VkPrimitiveTopology primitiveTopology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
236*03ce13f7SAndroid Build Coastguard Worker 	uint32_t scissorCount = 0;
237*03ce13f7SAndroid Build Coastguard Worker 	VkRect2D scissors[vk::MAX_VIEWPORTS] = {};
238*03ce13f7SAndroid Build Coastguard Worker 	VkStencilFaceFlags faceMask = (VkStencilFaceFlags)0;
239*03ce13f7SAndroid Build Coastguard Worker 	VkStencilOpState frontStencil = {};
240*03ce13f7SAndroid Build Coastguard Worker 	VkStencilOpState backStencil = {};
241*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 stencilTestEnable = VK_FALSE;
242*03ce13f7SAndroid Build Coastguard Worker 	uint32_t viewportCount = 0;
243*03ce13f7SAndroid Build Coastguard Worker 	VkViewport viewports[vk::MAX_VIEWPORTS] = {};
244*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 rasterizerDiscardEnable = VK_FALSE;
245*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 depthBiasEnable = VK_FALSE;
246*03ce13f7SAndroid Build Coastguard Worker 	VkBool32 primitiveRestartEnable = VK_FALSE;
247*03ce13f7SAndroid Build Coastguard Worker 	DynamicVertexInputBindingState vertexInputBindings[MAX_VERTEX_INPUT_BINDINGS];
248*03ce13f7SAndroid Build Coastguard Worker 	DynamicVertexInputAttributeState vertexInputAttributes[sw::MAX_INTERFACE_COMPONENTS / 4];
249*03ce13f7SAndroid Build Coastguard Worker };
250*03ce13f7SAndroid Build Coastguard Worker 
251*03ce13f7SAndroid Build Coastguard Worker struct VertexInputInterfaceState
252*03ce13f7SAndroid Build Coastguard Worker {
253*03ce13f7SAndroid Build Coastguard Worker 	void initialize(const VkPipelineVertexInputStateCreateInfo *vertexInputState,
254*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineInputAssemblyStateCreateInfo *inputAssemblyState,
255*03ce13f7SAndroid Build Coastguard Worker 	                const DynamicStateFlags &allDynamicStateFlags);
256*03ce13f7SAndroid Build Coastguard Worker 
257*03ce13f7SAndroid Build Coastguard Worker 	void applyState(const DynamicState &dynamicState);
258*03ce13f7SAndroid Build Coastguard Worker 
getTopologyvk::VertexInputInterfaceState259*03ce13f7SAndroid Build Coastguard Worker 	inline VkPrimitiveTopology getTopology() const { return topology; }
hasPrimitiveRestartEnablevk::VertexInputInterfaceState260*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasPrimitiveRestartEnable() const { return primitiveRestartEnable; }
261*03ce13f7SAndroid Build Coastguard Worker 
hasDynamicTopologyvk::VertexInputInterfaceState262*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasDynamicTopology() const { return dynamicStateFlags.dynamicPrimitiveTopology; }
hasDynamicPrimitiveRestartEnablevk::VertexInputInterfaceState263*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasDynamicPrimitiveRestartEnable() const { return dynamicStateFlags.dynamicPrimitiveRestartEnable; }
264*03ce13f7SAndroid Build Coastguard Worker 
265*03ce13f7SAndroid Build Coastguard Worker 	bool isDrawPoint(bool polygonModeAware, VkPolygonMode polygonMode) const;
266*03ce13f7SAndroid Build Coastguard Worker 	bool isDrawLine(bool polygonModeAware, VkPolygonMode polygonMode) const;
267*03ce13f7SAndroid Build Coastguard Worker 	bool isDrawTriangle(bool polygonModeAware, VkPolygonMode polygonMode) const;
268*03ce13f7SAndroid Build Coastguard Worker 
269*03ce13f7SAndroid Build Coastguard Worker private:
270*03ce13f7SAndroid Build Coastguard Worker 	VertexInputInterfaceDynamicStateFlags dynamicStateFlags = {};
271*03ce13f7SAndroid Build Coastguard Worker 
272*03ce13f7SAndroid Build Coastguard Worker 	bool primitiveRestartEnable = false;
273*03ce13f7SAndroid Build Coastguard Worker 
274*03ce13f7SAndroid Build Coastguard Worker 	VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
275*03ce13f7SAndroid Build Coastguard Worker };
276*03ce13f7SAndroid Build Coastguard Worker 
277*03ce13f7SAndroid Build Coastguard Worker struct PreRasterizationState
278*03ce13f7SAndroid Build Coastguard Worker {
279*03ce13f7SAndroid Build Coastguard Worker 	void initialize(const vk::Device *device,
280*03ce13f7SAndroid Build Coastguard Worker 	                const PipelineLayout *layout,
281*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineViewportStateCreateInfo *viewportState,
282*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineRasterizationStateCreateInfo *rasterizationState,
283*03ce13f7SAndroid Build Coastguard Worker 	                const vk::RenderPass *renderPass, uint32_t subpassIndex,
284*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineRenderingCreateInfo *rendering,
285*03ce13f7SAndroid Build Coastguard Worker 	                const DynamicStateFlags &allDynamicStateFlags);
286*03ce13f7SAndroid Build Coastguard Worker 
getPipelineLayoutvk::PreRasterizationState287*03ce13f7SAndroid Build Coastguard Worker 	inline const PipelineLayout *getPipelineLayout() const { return pipelineLayout; }
overridePipelineLayoutvk::PreRasterizationState288*03ce13f7SAndroid Build Coastguard Worker 	inline void overridePipelineLayout(const PipelineLayout *linkedLayout) { pipelineLayout = linkedLayout; }
289*03ce13f7SAndroid Build Coastguard Worker 
290*03ce13f7SAndroid Build Coastguard Worker 	void applyState(const DynamicState &dynamicState);
291*03ce13f7SAndroid Build Coastguard Worker 
getCullModevk::PreRasterizationState292*03ce13f7SAndroid Build Coastguard Worker 	inline VkCullModeFlags getCullMode() const { return cullMode; }
getFrontFacevk::PreRasterizationState293*03ce13f7SAndroid Build Coastguard Worker 	inline VkFrontFace getFrontFace() const { return frontFace; }
getPolygonModevk::PreRasterizationState294*03ce13f7SAndroid Build Coastguard Worker 	inline VkPolygonMode getPolygonMode() const { return polygonMode; }
getProvokingVertexModevk::PreRasterizationState295*03ce13f7SAndroid Build Coastguard Worker 	inline VkProvokingVertexModeEXT getProvokingVertexMode() const { return provokingVertexMode; }
getLineRasterizationModevk::PreRasterizationState296*03ce13f7SAndroid Build Coastguard Worker 	inline VkLineRasterizationModeEXT getLineRasterizationMode() const { return lineRasterizationMode; }
297*03ce13f7SAndroid Build Coastguard Worker 
hasRasterizerDiscardvk::PreRasterizationState298*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasRasterizerDiscard() const { return rasterizerDiscard; }
299*03ce13f7SAndroid Build Coastguard Worker 
getConstantDepthBiasvk::PreRasterizationState300*03ce13f7SAndroid Build Coastguard Worker 	inline float getConstantDepthBias() const { return depthBiasEnable ? constantDepthBias : 0; }
getSlopeDepthBiasvk::PreRasterizationState301*03ce13f7SAndroid Build Coastguard Worker 	inline float getSlopeDepthBias() const { return depthBiasEnable ? slopeDepthBias : 0; }
getDepthBiasClampvk::PreRasterizationState302*03ce13f7SAndroid Build Coastguard Worker 	inline float getDepthBiasClamp() const { return depthBiasEnable ? depthBiasClamp : 0; }
303*03ce13f7SAndroid Build Coastguard Worker 
hasDepthRangeUnrestrictedvk::PreRasterizationState304*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasDepthRangeUnrestricted() const { return depthRangeUnrestricted; }
getDepthClampEnablevk::PreRasterizationState305*03ce13f7SAndroid Build Coastguard Worker 	inline bool getDepthClampEnable() const { return depthClampEnable; }
getDepthClipEnablevk::PreRasterizationState306*03ce13f7SAndroid Build Coastguard Worker 	inline bool getDepthClipEnable() const { return depthClipEnable; }
getDepthClipNegativeOneToOnevk::PreRasterizationState307*03ce13f7SAndroid Build Coastguard Worker 	inline bool getDepthClipNegativeOneToOne() const { return depthClipNegativeOneToOne; }
308*03ce13f7SAndroid Build Coastguard Worker 
getLineWidthvk::PreRasterizationState309*03ce13f7SAndroid Build Coastguard Worker 	inline float getLineWidth() const { return lineWidth; }
310*03ce13f7SAndroid Build Coastguard Worker 
getScissorvk::PreRasterizationState311*03ce13f7SAndroid Build Coastguard Worker 	inline const VkRect2D &getScissor() const { return scissor; }
getViewportvk::PreRasterizationState312*03ce13f7SAndroid Build Coastguard Worker 	inline const VkViewport &getViewport() const { return viewport; }
313*03ce13f7SAndroid Build Coastguard Worker 
314*03ce13f7SAndroid Build Coastguard Worker private:
315*03ce13f7SAndroid Build Coastguard Worker 	const PipelineLayout *pipelineLayout = nullptr;
316*03ce13f7SAndroid Build Coastguard Worker 
317*03ce13f7SAndroid Build Coastguard Worker 	PreRasterizationDynamicStateFlags dynamicStateFlags = {};
318*03ce13f7SAndroid Build Coastguard Worker 
319*03ce13f7SAndroid Build Coastguard Worker 	bool rasterizerDiscard = false;
320*03ce13f7SAndroid Build Coastguard Worker 	bool depthClampEnable = false;
321*03ce13f7SAndroid Build Coastguard Worker 	bool depthClipEnable = false;
322*03ce13f7SAndroid Build Coastguard Worker 	bool depthClipNegativeOneToOne = false;
323*03ce13f7SAndroid Build Coastguard Worker 	bool depthBiasEnable = false;
324*03ce13f7SAndroid Build Coastguard Worker 	bool depthRangeUnrestricted = false;
325*03ce13f7SAndroid Build Coastguard Worker 
326*03ce13f7SAndroid Build Coastguard Worker 	VkCullModeFlags cullMode = 0;
327*03ce13f7SAndroid Build Coastguard Worker 	VkFrontFace frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
328*03ce13f7SAndroid Build Coastguard Worker 	VkPolygonMode polygonMode = VK_POLYGON_MODE_FILL;
329*03ce13f7SAndroid Build Coastguard Worker 	VkProvokingVertexModeEXT provokingVertexMode = VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT;
330*03ce13f7SAndroid Build Coastguard Worker 	VkLineRasterizationModeEXT lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
331*03ce13f7SAndroid Build Coastguard Worker 
332*03ce13f7SAndroid Build Coastguard Worker 	float depthBiasClamp = 0.0f;
333*03ce13f7SAndroid Build Coastguard Worker 	float constantDepthBias = 0.0f;
334*03ce13f7SAndroid Build Coastguard Worker 	float slopeDepthBias = 0.0f;
335*03ce13f7SAndroid Build Coastguard Worker 
336*03ce13f7SAndroid Build Coastguard Worker 	float lineWidth = 0.0f;
337*03ce13f7SAndroid Build Coastguard Worker 
338*03ce13f7SAndroid Build Coastguard Worker 	VkRect2D scissor = {};
339*03ce13f7SAndroid Build Coastguard Worker 	VkViewport viewport = {};
340*03ce13f7SAndroid Build Coastguard Worker };
341*03ce13f7SAndroid Build Coastguard Worker 
342*03ce13f7SAndroid Build Coastguard Worker struct FragmentState
343*03ce13f7SAndroid Build Coastguard Worker {
344*03ce13f7SAndroid Build Coastguard Worker 	void initialize(const PipelineLayout *layout,
345*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineDepthStencilStateCreateInfo *depthStencilState,
346*03ce13f7SAndroid Build Coastguard Worker 	                const vk::RenderPass *renderPass, uint32_t subpassIndex,
347*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineRenderingCreateInfo *rendering,
348*03ce13f7SAndroid Build Coastguard Worker 	                const DynamicStateFlags &allDynamicStateFlags);
349*03ce13f7SAndroid Build Coastguard Worker 
getPipelineLayoutvk::FragmentState350*03ce13f7SAndroid Build Coastguard Worker 	inline const PipelineLayout *getPipelineLayout() const { return pipelineLayout; }
overridePipelineLayoutvk::FragmentState351*03ce13f7SAndroid Build Coastguard Worker 	inline void overridePipelineLayout(const PipelineLayout *linkedLayout) { pipelineLayout = linkedLayout; }
352*03ce13f7SAndroid Build Coastguard Worker 
353*03ce13f7SAndroid Build Coastguard Worker 	void applyState(const DynamicState &dynamicState);
354*03ce13f7SAndroid Build Coastguard Worker 
getFrontStencilvk::FragmentState355*03ce13f7SAndroid Build Coastguard Worker 	inline VkStencilOpState getFrontStencil() const { return frontStencil; }
getBackStencilvk::FragmentState356*03ce13f7SAndroid Build Coastguard Worker 	inline VkStencilOpState getBackStencil() const { return backStencil; }
357*03ce13f7SAndroid Build Coastguard Worker 
getMinDepthBoundsvk::FragmentState358*03ce13f7SAndroid Build Coastguard Worker 	inline float getMinDepthBounds() const { return minDepthBounds; }
getMaxDepthBoundsvk::FragmentState359*03ce13f7SAndroid Build Coastguard Worker 	inline float getMaxDepthBounds() const { return maxDepthBounds; }
360*03ce13f7SAndroid Build Coastguard Worker 
getDepthCompareModevk::FragmentState361*03ce13f7SAndroid Build Coastguard Worker 	inline VkCompareOp getDepthCompareMode() const { return depthCompareMode; }
362*03ce13f7SAndroid Build Coastguard Worker 
363*03ce13f7SAndroid Build Coastguard Worker 	bool depthWriteActive(const Attachments &attachments) const;
364*03ce13f7SAndroid Build Coastguard Worker 	bool depthTestActive(const Attachments &attachments) const;
365*03ce13f7SAndroid Build Coastguard Worker 	bool stencilActive(const Attachments &attachments) const;
366*03ce13f7SAndroid Build Coastguard Worker 	bool depthBoundsTestActive(const Attachments &attachments) const;
367*03ce13f7SAndroid Build Coastguard Worker 
368*03ce13f7SAndroid Build Coastguard Worker private:
369*03ce13f7SAndroid Build Coastguard Worker 	void setDepthStencilState(const VkPipelineDepthStencilStateCreateInfo *depthStencilState);
370*03ce13f7SAndroid Build Coastguard Worker 
371*03ce13f7SAndroid Build Coastguard Worker 	const PipelineLayout *pipelineLayout = nullptr;
372*03ce13f7SAndroid Build Coastguard Worker 
373*03ce13f7SAndroid Build Coastguard Worker 	FragmentDynamicStateFlags dynamicStateFlags = {};
374*03ce13f7SAndroid Build Coastguard Worker 
375*03ce13f7SAndroid Build Coastguard Worker 	bool depthTestEnable = false;
376*03ce13f7SAndroid Build Coastguard Worker 	bool depthWriteEnable = false;
377*03ce13f7SAndroid Build Coastguard Worker 	bool depthBoundsTestEnable = false;
378*03ce13f7SAndroid Build Coastguard Worker 	bool stencilEnable = false;
379*03ce13f7SAndroid Build Coastguard Worker 
380*03ce13f7SAndroid Build Coastguard Worker 	float minDepthBounds = 0.0f;
381*03ce13f7SAndroid Build Coastguard Worker 	float maxDepthBounds = 0.0f;
382*03ce13f7SAndroid Build Coastguard Worker 
383*03ce13f7SAndroid Build Coastguard Worker 	VkCompareOp depthCompareMode = VK_COMPARE_OP_NEVER;
384*03ce13f7SAndroid Build Coastguard Worker 
385*03ce13f7SAndroid Build Coastguard Worker 	VkStencilOpState frontStencil = {};
386*03ce13f7SAndroid Build Coastguard Worker 	VkStencilOpState backStencil = {};
387*03ce13f7SAndroid Build Coastguard Worker 
388*03ce13f7SAndroid Build Coastguard Worker 	// Note: if a pipeline library is created with the fragment state only, and sample shading
389*03ce13f7SAndroid Build Coastguard Worker 	// is enabled or a render pass is provided, VkPipelineMultisampleStateCreateInfo must be
390*03ce13f7SAndroid Build Coastguard Worker 	// provided.  This must identically match with the one provided for the fragment output
391*03ce13f7SAndroid Build Coastguard Worker 	// interface library.
392*03ce13f7SAndroid Build Coastguard Worker 	//
393*03ce13f7SAndroid Build Coastguard Worker 	// Currently, SwiftShader can always use the copy provided and stored in
394*03ce13f7SAndroid Build Coastguard Worker 	// FragmentOutputInterfaceState.  If a future optimization requires access to this state in
395*03ce13f7SAndroid Build Coastguard Worker 	// a pipeline library without fragment output interface, a copy of MultisampleState can be
396*03ce13f7SAndroid Build Coastguard Worker 	// placed here and initialized under the above condition.
397*03ce13f7SAndroid Build Coastguard Worker 	//
398*03ce13f7SAndroid Build Coastguard Worker 	// Ref: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap10.html#pipeline-graphics-subsets
399*03ce13f7SAndroid Build Coastguard Worker };
400*03ce13f7SAndroid Build Coastguard Worker 
401*03ce13f7SAndroid Build Coastguard Worker struct FragmentOutputInterfaceState
402*03ce13f7SAndroid Build Coastguard Worker {
403*03ce13f7SAndroid Build Coastguard Worker 	void initialize(const VkPipelineColorBlendStateCreateInfo *colorBlendState,
404*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineMultisampleStateCreateInfo *multisampleState,
405*03ce13f7SAndroid Build Coastguard Worker 	                const vk::RenderPass *renderPass, uint32_t subpassIndex,
406*03ce13f7SAndroid Build Coastguard Worker 	                const VkPipelineRenderingCreateInfo *rendering,
407*03ce13f7SAndroid Build Coastguard Worker 	                const DynamicStateFlags &allDynamicStateFlags);
408*03ce13f7SAndroid Build Coastguard Worker 
409*03ce13f7SAndroid Build Coastguard Worker 	void applyState(const DynamicState &dynamicState);
410*03ce13f7SAndroid Build Coastguard Worker 
getMultiSampleMaskvk::FragmentOutputInterfaceState411*03ce13f7SAndroid Build Coastguard Worker 	inline unsigned int getMultiSampleMask() const { return multisample.multiSampleMask; }
getSampleCountvk::FragmentOutputInterfaceState412*03ce13f7SAndroid Build Coastguard Worker 	inline int getSampleCount() const { return multisample.sampleCount; }
hasSampleShadingEnabledvk::FragmentOutputInterfaceState413*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasSampleShadingEnabled() const { return multisample.sampleShadingEnable; }
getMinSampleShadingvk::FragmentOutputInterfaceState414*03ce13f7SAndroid Build Coastguard Worker 	inline float getMinSampleShading() const { return multisample.minSampleShading; }
hasAlphaToCoveragevk::FragmentOutputInterfaceState415*03ce13f7SAndroid Build Coastguard Worker 	inline bool hasAlphaToCoverage() const { return multisample.alphaToCoverage; }
416*03ce13f7SAndroid Build Coastguard Worker 
getBlendConstantsvk::FragmentOutputInterfaceState417*03ce13f7SAndroid Build Coastguard Worker 	inline const sw::float4 &getBlendConstants() const { return blendConstants; }
418*03ce13f7SAndroid Build Coastguard Worker 
419*03ce13f7SAndroid Build Coastguard Worker 	// The following take the attachment "location", which may not be the same as the index in
420*03ce13f7SAndroid Build Coastguard Worker 	// the attachment list with VK_KHR_dynamic_rendering_local_read.
421*03ce13f7SAndroid Build Coastguard Worker 	BlendState getBlendState(int location, const Attachments &attachments, bool fragmentContainsKill) const;
422*03ce13f7SAndroid Build Coastguard Worker 	int colorWriteActive(int location, const Attachments &attachments) const;
423*03ce13f7SAndroid Build Coastguard Worker 
424*03ce13f7SAndroid Build Coastguard Worker private:
425*03ce13f7SAndroid Build Coastguard Worker 	void setColorBlendState(const VkPipelineColorBlendStateCreateInfo *colorBlendState);
426*03ce13f7SAndroid Build Coastguard Worker 
427*03ce13f7SAndroid Build Coastguard Worker 	VkBlendFactor blendFactor(VkBlendOp blendOperation, VkBlendFactor blendFactor) const;
428*03ce13f7SAndroid Build Coastguard Worker 	VkBlendOp blendOperation(VkBlendOp blendOperation, VkBlendFactor sourceBlendFactor, VkBlendFactor destBlendFactor, vk::Format format) const;
429*03ce13f7SAndroid Build Coastguard Worker 
430*03ce13f7SAndroid Build Coastguard Worker 	bool alphaBlendActive(int location, const Attachments &attachments, bool fragmentContainsKill) const;
431*03ce13f7SAndroid Build Coastguard Worker 	bool colorWriteActive(const Attachments &attachments) const;
432*03ce13f7SAndroid Build Coastguard Worker 
433*03ce13f7SAndroid Build Coastguard Worker 	int colorWriteMask[sw::MAX_COLOR_BUFFERS] = {};  // RGBA
434*03ce13f7SAndroid Build Coastguard Worker 
435*03ce13f7SAndroid Build Coastguard Worker 	FragmentOutputInterfaceDynamicStateFlags dynamicStateFlags = {};
436*03ce13f7SAndroid Build Coastguard Worker 
437*03ce13f7SAndroid Build Coastguard Worker 	sw::float4 blendConstants = {};
438*03ce13f7SAndroid Build Coastguard Worker 	BlendState blendState[sw::MAX_COLOR_BUFFERS] = {};
439*03ce13f7SAndroid Build Coastguard Worker 
440*03ce13f7SAndroid Build Coastguard Worker 	MultisampleState multisample;
441*03ce13f7SAndroid Build Coastguard Worker };
442*03ce13f7SAndroid Build Coastguard Worker 
443*03ce13f7SAndroid Build Coastguard Worker struct GraphicsState
444*03ce13f7SAndroid Build Coastguard Worker {
445*03ce13f7SAndroid Build Coastguard Worker 	GraphicsState(const Device *device, const VkGraphicsPipelineCreateInfo *pCreateInfo, const PipelineLayout *layout);
446*03ce13f7SAndroid Build Coastguard Worker 
447*03ce13f7SAndroid Build Coastguard Worker 	GraphicsState combineStates(const DynamicState &dynamicState) const;
448*03ce13f7SAndroid Build Coastguard Worker 
hasVertexInputInterfaceStatevk::GraphicsState449*03ce13f7SAndroid Build Coastguard Worker 	bool hasVertexInputInterfaceState() const
450*03ce13f7SAndroid Build Coastguard Worker 	{
451*03ce13f7SAndroid Build Coastguard Worker 		return (validSubset & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT) != 0;
452*03ce13f7SAndroid Build Coastguard Worker 	}
hasPreRasterizationStatevk::GraphicsState453*03ce13f7SAndroid Build Coastguard Worker 	bool hasPreRasterizationState() const
454*03ce13f7SAndroid Build Coastguard Worker 	{
455*03ce13f7SAndroid Build Coastguard Worker 		return (validSubset & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT) != 0;
456*03ce13f7SAndroid Build Coastguard Worker 	}
hasFragmentStatevk::GraphicsState457*03ce13f7SAndroid Build Coastguard Worker 	bool hasFragmentState() const
458*03ce13f7SAndroid Build Coastguard Worker 	{
459*03ce13f7SAndroid Build Coastguard Worker 		return (validSubset & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT) != 0;
460*03ce13f7SAndroid Build Coastguard Worker 	}
hasFragmentOutputInterfaceStatevk::GraphicsState461*03ce13f7SAndroid Build Coastguard Worker 	bool hasFragmentOutputInterfaceState() const
462*03ce13f7SAndroid Build Coastguard Worker 	{
463*03ce13f7SAndroid Build Coastguard Worker 		return (validSubset & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0;
464*03ce13f7SAndroid Build Coastguard Worker 	}
465*03ce13f7SAndroid Build Coastguard Worker 
getVertexInputInterfaceStatevk::GraphicsState466*03ce13f7SAndroid Build Coastguard Worker 	const VertexInputInterfaceState &getVertexInputInterfaceState() const
467*03ce13f7SAndroid Build Coastguard Worker 	{
468*03ce13f7SAndroid Build Coastguard Worker 		ASSERT(hasVertexInputInterfaceState());
469*03ce13f7SAndroid Build Coastguard Worker 		return vertexInputInterfaceState;
470*03ce13f7SAndroid Build Coastguard Worker 	}
getPreRasterizationStatevk::GraphicsState471*03ce13f7SAndroid Build Coastguard Worker 	const PreRasterizationState &getPreRasterizationState() const
472*03ce13f7SAndroid Build Coastguard Worker 	{
473*03ce13f7SAndroid Build Coastguard Worker 		ASSERT(hasPreRasterizationState());
474*03ce13f7SAndroid Build Coastguard Worker 		return preRasterizationState;
475*03ce13f7SAndroid Build Coastguard Worker 	}
getFragmentStatevk::GraphicsState476*03ce13f7SAndroid Build Coastguard Worker 	const FragmentState &getFragmentState() const
477*03ce13f7SAndroid Build Coastguard Worker 	{
478*03ce13f7SAndroid Build Coastguard Worker 		ASSERT(hasFragmentState());
479*03ce13f7SAndroid Build Coastguard Worker 		return fragmentState;
480*03ce13f7SAndroid Build Coastguard Worker 	}
getFragmentOutputInterfaceStatevk::GraphicsState481*03ce13f7SAndroid Build Coastguard Worker 	const FragmentOutputInterfaceState &getFragmentOutputInterfaceState() const
482*03ce13f7SAndroid Build Coastguard Worker 	{
483*03ce13f7SAndroid Build Coastguard Worker 		ASSERT(hasFragmentOutputInterfaceState());
484*03ce13f7SAndroid Build Coastguard Worker 		return fragmentOutputInterfaceState;
485*03ce13f7SAndroid Build Coastguard Worker 	}
486*03ce13f7SAndroid Build Coastguard Worker 
487*03ce13f7SAndroid Build Coastguard Worker private:
488*03ce13f7SAndroid Build Coastguard Worker 	// The four subsets of a graphics pipeline as described in the spec.  With
489*03ce13f7SAndroid Build Coastguard Worker 	// VK_EXT_graphics_pipeline_library, a number of these may be valid.
490*03ce13f7SAndroid Build Coastguard Worker 	VertexInputInterfaceState vertexInputInterfaceState;
491*03ce13f7SAndroid Build Coastguard Worker 	PreRasterizationState preRasterizationState;
492*03ce13f7SAndroid Build Coastguard Worker 	FragmentState fragmentState;
493*03ce13f7SAndroid Build Coastguard Worker 	FragmentOutputInterfaceState fragmentOutputInterfaceState;
494*03ce13f7SAndroid Build Coastguard Worker 
495*03ce13f7SAndroid Build Coastguard Worker 	VkGraphicsPipelineLibraryFlagsEXT validSubset = 0;
496*03ce13f7SAndroid Build Coastguard Worker };
497*03ce13f7SAndroid Build Coastguard Worker 
498*03ce13f7SAndroid Build Coastguard Worker }  // namespace vk
499*03ce13f7SAndroid Build Coastguard Worker 
500*03ce13f7SAndroid Build Coastguard Worker #endif  // vk_Context_hpp
501