Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 3 | * |
| 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 Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef STATE_H |
| 29 | #define STATE_H |
| 30 | |
| 31 | #include "intel.h" |
| 32 | #include "obj.h" |
| 33 | |
Chia-I Wu | aabb360 | 2014-08-19 14:18:23 +0800 | [diff] [blame] | 34 | /* Should we add intel_state back, as the base class for dynamic states? */ |
| 35 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 36 | struct intel_dynamic_viewport { |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 37 | struct intel_obj obj; |
| 38 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 39 | uint32_t viewport_count; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 40 | /* SF_CLIP_VIEWPORTs, CC_VIEWPORTs, and SCISSOR_RECTs */ |
| 41 | uint32_t *cmd; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 42 | 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 Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 46 | }; |
| 47 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 48 | struct intel_dynamic_line_width { |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 49 | struct intel_obj obj; |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 50 | VkDynamicLineWidthStateCreateInfo line_width_info; |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 51 | }; |
| 52 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 53 | struct intel_dynamic_depth_bias { |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 54 | struct intel_obj obj; |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 55 | VkDynamicDepthBiasStateCreateInfo depth_bias_info; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 56 | }; |
| 57 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 58 | struct intel_dynamic_blend { |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 59 | struct intel_obj obj; |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 60 | VkDynamicBlendStateCreateInfo blend_info; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 61 | }; |
| 62 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 63 | struct intel_dynamic_depth_bounds { |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 64 | struct intel_obj obj; |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 65 | VkDynamicDepthBoundsStateCreateInfo depth_bounds_info; |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct 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 Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 73 | }; |
| 74 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 75 | static inline struct intel_dynamic_viewport *intel_dynamic_viewport(VkDynamicViewportState state) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 76 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 77 | return *(struct intel_dynamic_viewport **) &state; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 78 | } |
| 79 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 80 | static inline struct intel_dynamic_viewport *intel_viewport_state_from_obj(struct intel_obj *obj) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 81 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 82 | return (struct intel_dynamic_viewport *) obj; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 83 | } |
| 84 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 85 | static inline struct intel_dynamic_line_width *intel_dynamic_line_width(VkDynamicLineWidthState state) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 86 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 87 | return *(struct intel_dynamic_line_width **) &state; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 88 | } |
| 89 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 90 | static inline struct intel_dynamic_line_width *intel_line_width_state_from_obj(struct intel_obj *obj) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 91 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 92 | return (struct intel_dynamic_line_width *) obj; |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 93 | } |
| 94 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 95 | static inline struct intel_dynamic_depth_bias *intel_dynamic_depth_bias(VkDynamicDepthBiasState state) |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 96 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 97 | return *(struct intel_dynamic_depth_bias **) &state; |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 98 | } |
| 99 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 100 | static inline struct intel_dynamic_depth_bias *intel_depth_bias_state_from_obj(struct intel_obj *obj) |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 101 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 102 | return (struct intel_dynamic_depth_bias *) obj; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 103 | } |
| 104 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 105 | static inline struct intel_dynamic_blend *intel_dynamic_blend(VkDynamicBlendState state) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 106 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 107 | return *(struct intel_dynamic_blend **) &state; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 108 | } |
| 109 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 110 | static inline struct intel_dynamic_blend *intel_blend_state_from_obj(struct intel_obj *obj) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 111 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 112 | return (struct intel_dynamic_blend *) obj; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 113 | } |
| 114 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 115 | static inline struct intel_dynamic_depth_bounds *intel_dynamic_depth_bounds(VkDynamicDepthBoundsState state) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 116 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 117 | return *(struct intel_dynamic_depth_bounds **) &state; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 118 | } |
| 119 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 120 | static inline struct intel_dynamic_depth_bounds *intel_depth_bounds_state_from_obj(struct intel_obj *obj) |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 121 | { |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 122 | return (struct intel_dynamic_depth_bounds *) obj; |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | static inline struct intel_dynamic_stencil *intel_dynamic_stencil(VkDynamicStencilState state) |
| 126 | { |
| 127 | return *(struct intel_dynamic_stencil **) &state; |
| 128 | } |
| 129 | |
| 130 | static inline struct intel_dynamic_stencil *intel_stencil_state_from_obj(struct intel_obj *obj) |
| 131 | { |
| 132 | return (struct intel_dynamic_stencil *) obj; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 133 | } |
| 134 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 135 | VkResult intel_viewport_state_create(struct intel_dev *dev, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 136 | const VkDynamicViewportStateCreateInfo *info, |
| 137 | struct intel_dynamic_viewport **state_ret); |
| 138 | void intel_viewport_state_destroy(struct intel_dynamic_viewport *state); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 139 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 140 | VkResult intel_line_width_state_create(struct intel_dev *dev, |
| 141 | const VkDynamicLineWidthStateCreateInfo *info, |
| 142 | struct intel_dynamic_line_width **state_ret); |
| 143 | void intel_line_width_state_destroy(struct intel_dynamic_line_width *state); |
| 144 | VkResult intel_depth_bias_state_create(struct intel_dev *dev, |
| 145 | const VkDynamicDepthBiasStateCreateInfo *info, |
| 146 | struct intel_dynamic_depth_bias **state_ret); |
| 147 | void intel_depth_bias_state_destroy(struct intel_dynamic_depth_bias *state); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 148 | VkResult intel_blend_state_create(struct intel_dev *dev, |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 149 | const VkDynamicBlendStateCreateInfo *info, |
| 150 | struct intel_dynamic_blend **state_ret); |
| 151 | void intel_blend_state_destroy(struct intel_dynamic_blend *state); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 152 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame^] | 153 | VkResult intel_depth_bounds_state_create(struct intel_dev *dev, |
| 154 | const VkDynamicDepthBoundsStateCreateInfo *info, |
| 155 | struct intel_dynamic_depth_bounds **state_ret); |
| 156 | void intel_depth_bounds_state_destroy(struct intel_dynamic_depth_bounds *state); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 157 | |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 158 | VkResult 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); |
| 162 | void intel_stencil_state_destroy(struct intel_dynamic_stencil *state); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 163 | #endif /* STATE_H */ |