blob: 85dc748df320bb02063fe8518876b0787a07b03d [file] [log] [blame]
Chia-I Wua5714e82014-08-11 15:33:42 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wua5714e82014-08-11 15:33:42 +08003 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wua5714e82014-08-11 15:33:42 +080026 */
27
28#ifndef STATE_H
29#define STATE_H
30
31#include "intel.h"
32#include "obj.h"
33
Chia-I Wuaabb3602014-08-19 14:18:23 +080034/* Should we add intel_state back, as the base class for dynamic states? */
35
Tony Barbourde4124d2015-07-03 10:33:54 -060036struct intel_dynamic_viewport {
Chia-I Wua5714e82014-08-11 15:33:42 +080037 struct intel_obj obj;
38
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060039 uint32_t viewport_count;
Chia-I Wua5714e82014-08-11 15:33:42 +080040 /* SF_CLIP_VIEWPORTs, CC_VIEWPORTs, and SCISSOR_RECTs */
41 uint32_t *cmd;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060042 uint32_t cmd_len;
43 uint32_t cmd_clip_pos;
44 uint32_t cmd_cc_pos;
45 uint32_t cmd_scissor_rect_pos;
Chia-I Wua5714e82014-08-11 15:33:42 +080046};
47
Cody Northrope4bc6942015-08-26 10:01:32 -060048struct intel_dynamic_line_width {
Chia-I Wua5714e82014-08-11 15:33:42 +080049 struct intel_obj obj;
Cody Northrope4bc6942015-08-26 10:01:32 -060050 VkDynamicLineWidthStateCreateInfo line_width_info;
Cody Northropf5bd2252015-08-17 11:10:49 -060051};
52
Cody Northrope4bc6942015-08-26 10:01:32 -060053struct intel_dynamic_depth_bias {
Cody Northropf5bd2252015-08-17 11:10:49 -060054 struct intel_obj obj;
Cody Northrope4bc6942015-08-26 10:01:32 -060055 VkDynamicDepthBiasStateCreateInfo depth_bias_info;
Chia-I Wua5714e82014-08-11 15:33:42 +080056};
57
Cody Northrope4bc6942015-08-26 10:01:32 -060058struct intel_dynamic_blend {
Chia-I Wua5714e82014-08-11 15:33:42 +080059 struct intel_obj obj;
Cody Northrope4bc6942015-08-26 10:01:32 -060060 VkDynamicBlendStateCreateInfo blend_info;
Chia-I Wua5714e82014-08-11 15:33:42 +080061};
62
Cody Northrope4bc6942015-08-26 10:01:32 -060063struct intel_dynamic_depth_bounds {
Chia-I Wua5714e82014-08-11 15:33:42 +080064 struct intel_obj obj;
Cody Northrope4bc6942015-08-26 10:01:32 -060065 VkDynamicDepthBoundsStateCreateInfo depth_bounds_info;
Cody Northrop2605cb02015-08-18 15:21:16 -060066};
67
68struct intel_dynamic_stencil {
69 struct intel_obj obj;
70 VkDynamicStencilStateCreateInfo stencil_info_front;
71 /* TODO: enable back facing stencil state */
72 /*VkDynamicStencilStateCreateInfo stencil_info_back;*/
Chia-I Wua5714e82014-08-11 15:33:42 +080073};
74
Tony Barbourde4124d2015-07-03 10:33:54 -060075static inline struct intel_dynamic_viewport *intel_dynamic_viewport(VkDynamicViewportState state)
Chia-I Wua5714e82014-08-11 15:33:42 +080076{
Tony Barbourde4124d2015-07-03 10:33:54 -060077 return *(struct intel_dynamic_viewport **) &state;
Chia-I Wua5714e82014-08-11 15:33:42 +080078}
79
Tony Barbourde4124d2015-07-03 10:33:54 -060080static inline struct intel_dynamic_viewport *intel_viewport_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +080081{
Tony Barbourde4124d2015-07-03 10:33:54 -060082 return (struct intel_dynamic_viewport *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +080083}
84
Cody Northrope4bc6942015-08-26 10:01:32 -060085static inline struct intel_dynamic_line_width *intel_dynamic_line_width(VkDynamicLineWidthState state)
Chia-I Wua5714e82014-08-11 15:33:42 +080086{
Cody Northrope4bc6942015-08-26 10:01:32 -060087 return *(struct intel_dynamic_line_width **) &state;
Chia-I Wua5714e82014-08-11 15:33:42 +080088}
89
Cody Northrope4bc6942015-08-26 10:01:32 -060090static inline struct intel_dynamic_line_width *intel_line_width_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +080091{
Cody Northrope4bc6942015-08-26 10:01:32 -060092 return (struct intel_dynamic_line_width *) obj;
Cody Northropf5bd2252015-08-17 11:10:49 -060093}
94
Cody Northrope4bc6942015-08-26 10:01:32 -060095static inline struct intel_dynamic_depth_bias *intel_dynamic_depth_bias(VkDynamicDepthBiasState state)
Cody Northropf5bd2252015-08-17 11:10:49 -060096{
Cody Northrope4bc6942015-08-26 10:01:32 -060097 return *(struct intel_dynamic_depth_bias **) &state;
Cody Northropf5bd2252015-08-17 11:10:49 -060098}
99
Cody Northrope4bc6942015-08-26 10:01:32 -0600100static inline struct intel_dynamic_depth_bias *intel_depth_bias_state_from_obj(struct intel_obj *obj)
Cody Northropf5bd2252015-08-17 11:10:49 -0600101{
Cody Northrope4bc6942015-08-26 10:01:32 -0600102 return (struct intel_dynamic_depth_bias *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +0800103}
104
Cody Northrope4bc6942015-08-26 10:01:32 -0600105static inline struct intel_dynamic_blend *intel_dynamic_blend(VkDynamicBlendState state)
Chia-I Wua5714e82014-08-11 15:33:42 +0800106{
Cody Northrope4bc6942015-08-26 10:01:32 -0600107 return *(struct intel_dynamic_blend **) &state;
Chia-I Wua5714e82014-08-11 15:33:42 +0800108}
109
Cody Northrope4bc6942015-08-26 10:01:32 -0600110static inline struct intel_dynamic_blend *intel_blend_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +0800111{
Cody Northrope4bc6942015-08-26 10:01:32 -0600112 return (struct intel_dynamic_blend *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +0800113}
114
Cody Northrope4bc6942015-08-26 10:01:32 -0600115static inline struct intel_dynamic_depth_bounds *intel_dynamic_depth_bounds(VkDynamicDepthBoundsState state)
Chia-I Wua5714e82014-08-11 15:33:42 +0800116{
Cody Northrope4bc6942015-08-26 10:01:32 -0600117 return *(struct intel_dynamic_depth_bounds **) &state;
Chia-I Wua5714e82014-08-11 15:33:42 +0800118}
119
Cody Northrope4bc6942015-08-26 10:01:32 -0600120static inline struct intel_dynamic_depth_bounds *intel_depth_bounds_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +0800121{
Cody Northrope4bc6942015-08-26 10:01:32 -0600122 return (struct intel_dynamic_depth_bounds *) obj;
Cody Northrop2605cb02015-08-18 15:21:16 -0600123}
124
125static inline struct intel_dynamic_stencil *intel_dynamic_stencil(VkDynamicStencilState state)
126{
127 return *(struct intel_dynamic_stencil **) &state;
128}
129
130static inline struct intel_dynamic_stencil *intel_stencil_state_from_obj(struct intel_obj *obj)
131{
132 return (struct intel_dynamic_stencil *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +0800133}
134
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600135VkResult intel_viewport_state_create(struct intel_dev *dev,
Tony Barbourde4124d2015-07-03 10:33:54 -0600136 const VkDynamicViewportStateCreateInfo *info,
137 struct intel_dynamic_viewport **state_ret);
138void intel_viewport_state_destroy(struct intel_dynamic_viewport *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800139
Cody Northrope4bc6942015-08-26 10:01:32 -0600140VkResult intel_line_width_state_create(struct intel_dev *dev,
141 const VkDynamicLineWidthStateCreateInfo *info,
142 struct intel_dynamic_line_width **state_ret);
143void intel_line_width_state_destroy(struct intel_dynamic_line_width *state);
144VkResult intel_depth_bias_state_create(struct intel_dev *dev,
145 const VkDynamicDepthBiasStateCreateInfo *info,
146 struct intel_dynamic_depth_bias **state_ret);
147void intel_depth_bias_state_destroy(struct intel_dynamic_depth_bias *state);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600148VkResult intel_blend_state_create(struct intel_dev *dev,
Cody Northrope4bc6942015-08-26 10:01:32 -0600149 const VkDynamicBlendStateCreateInfo *info,
150 struct intel_dynamic_blend **state_ret);
151void intel_blend_state_destroy(struct intel_dynamic_blend *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800152
Cody Northrope4bc6942015-08-26 10:01:32 -0600153VkResult intel_depth_bounds_state_create(struct intel_dev *dev,
154 const VkDynamicDepthBoundsStateCreateInfo *info,
155 struct intel_dynamic_depth_bounds **state_ret);
156void intel_depth_bounds_state_destroy(struct intel_dynamic_depth_bounds *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800157
Cody Northrop2605cb02015-08-18 15:21:16 -0600158VkResult intel_stencil_state_create(struct intel_dev *dev,
159 const VkDynamicStencilStateCreateInfo *info_front,
160 const VkDynamicStencilStateCreateInfo *info_back,
161 struct intel_dynamic_stencil **state_ret);
162void intel_stencil_state_destroy(struct intel_dynamic_stencil *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800163#endif /* STATE_H */