Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 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. |
| 23 | */ |
| 24 | |
| 25 | #ifndef STATE_H |
| 26 | #define STATE_H |
| 27 | |
| 28 | #include "intel.h" |
| 29 | #include "obj.h" |
| 30 | |
Chia-I Wu | aabb360 | 2014-08-19 14:18:23 +0800 | [diff] [blame^] | 31 | /* Should we add intel_state back, as the base class for dynamic states? */ |
| 32 | |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 33 | struct intel_viewport_state { |
| 34 | struct intel_obj obj; |
| 35 | |
Chia-I Wu | 97702a6 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 36 | bool scissor_enable; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 37 | /* SF_CLIP_VIEWPORTs, CC_VIEWPORTs, and SCISSOR_RECTs */ |
| 38 | uint32_t *cmd; |
| 39 | XGL_SIZE size; |
| 40 | }; |
| 41 | |
| 42 | struct intel_raster_state { |
| 43 | struct intel_obj obj; |
| 44 | |
Chia-I Wu | 97702a6 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 45 | uint32_t cmd_clip_cull; |
| 46 | uint32_t cmd_sf_fill; |
| 47 | uint32_t cmd_sf_cull; |
| 48 | uint32_t cmd_depth_offset_const; |
| 49 | uint32_t cmd_depth_offset_scale; |
| 50 | uint32_t cmd_depth_offset_clamp; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct intel_msaa_state { |
| 54 | struct intel_obj obj; |
| 55 | |
| 56 | /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */ |
| 57 | uint32_t cmd[6]; |
| 58 | }; |
| 59 | |
| 60 | struct intel_blend_state { |
| 61 | struct intel_obj obj; |
| 62 | |
| 63 | /* BLEND_STATE */ |
| 64 | uint32_t cmd[XGL_MAX_COLOR_ATTACHMENTS * 2]; |
Chia-I Wu | 97702a6 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 65 | /* a part of COLOR_CALC_STATE */ |
| 66 | uint32_t cmd_blend_color[4]; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | struct intel_ds_state { |
| 70 | struct intel_obj obj; |
| 71 | |
| 72 | /* DEPTH_STENCIL_STATE */ |
Chia-I Wu | 97702a6 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 73 | uint32_t cmd[3]; |
| 74 | /* a part of COLOR_CALC_STATE */ |
| 75 | uint32_t cmd_stencil_ref; |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static inline struct intel_viewport_state *intel_viewport_state(XGL_VIEWPORT_STATE_OBJECT state) |
| 79 | { |
| 80 | return (struct intel_viewport_state *) state; |
| 81 | } |
| 82 | |
| 83 | static inline struct intel_viewport_state *intel_viewport_state_from_obj(struct intel_obj *obj) |
| 84 | { |
| 85 | return (struct intel_viewport_state *) obj; |
| 86 | } |
| 87 | |
| 88 | static inline struct intel_raster_state *intel_raster_state(XGL_RASTER_STATE_OBJECT state) |
| 89 | { |
| 90 | return (struct intel_raster_state *) state; |
| 91 | } |
| 92 | |
| 93 | static inline struct intel_raster_state *intel_raster_state_from_obj(struct intel_obj *obj) |
| 94 | { |
| 95 | return (struct intel_raster_state *) obj; |
| 96 | } |
| 97 | |
| 98 | static inline struct intel_msaa_state *intel_msaa_state(XGL_VIEWPORT_STATE_OBJECT state) |
| 99 | { |
| 100 | return (struct intel_msaa_state *) state; |
| 101 | } |
| 102 | |
| 103 | static inline struct intel_msaa_state *intel_msaa_state_from_obj(struct intel_obj *obj) |
| 104 | { |
| 105 | return (struct intel_msaa_state *) obj; |
| 106 | } |
| 107 | |
| 108 | static inline struct intel_blend_state *intel_blend_state(XGL_VIEWPORT_STATE_OBJECT state) |
| 109 | { |
| 110 | return (struct intel_blend_state *) state; |
| 111 | } |
| 112 | |
| 113 | static inline struct intel_blend_state *intel_blend_state_from_obj(struct intel_obj *obj) |
| 114 | { |
| 115 | return (struct intel_blend_state *) obj; |
| 116 | } |
| 117 | |
| 118 | static inline struct intel_ds_state *intel_ds_state(XGL_VIEWPORT_STATE_OBJECT state) |
| 119 | { |
| 120 | return (struct intel_ds_state *) state; |
| 121 | } |
| 122 | |
| 123 | static inline struct intel_ds_state *intel_ds_state_from_obj(struct intel_obj *obj) |
| 124 | { |
| 125 | return (struct intel_ds_state *) obj; |
| 126 | } |
| 127 | |
| 128 | XGL_RESULT intel_viewport_state_create(struct intel_dev *dev, |
| 129 | const XGL_VIEWPORT_STATE_CREATE_INFO *info, |
| 130 | struct intel_viewport_state **state_ret); |
| 131 | void intel_viewport_state_destroy(struct intel_viewport_state *state); |
| 132 | |
| 133 | XGL_RESULT intel_raster_state_create(struct intel_dev *dev, |
| 134 | const XGL_RASTER_STATE_CREATE_INFO *info, |
| 135 | struct intel_raster_state **state_ret); |
| 136 | void intel_raster_state_destroy(struct intel_raster_state *state); |
| 137 | |
| 138 | XGL_RESULT intel_msaa_state_create(struct intel_dev *dev, |
| 139 | const XGL_MSAA_STATE_CREATE_INFO *info, |
| 140 | struct intel_msaa_state **state_ret); |
| 141 | void intel_msaa_state_destroy(struct intel_msaa_state *state); |
| 142 | |
| 143 | XGL_RESULT intel_blend_state_create(struct intel_dev *dev, |
| 144 | const XGL_COLOR_BLEND_STATE_CREATE_INFO *info, |
| 145 | struct intel_blend_state **state_ret); |
| 146 | void intel_blend_state_destroy(struct intel_blend_state *state); |
| 147 | |
| 148 | XGL_RESULT intel_ds_state_create(struct intel_dev *dev, |
| 149 | const XGL_DEPTH_STENCIL_STATE_CREATE_INFO *info, |
| 150 | struct intel_ds_state **state_ret); |
| 151 | void intel_ds_state_destroy(struct intel_ds_state *state); |
| 152 | |
| 153 | XGL_RESULT XGLAPI intelCreateViewportState( |
| 154 | XGL_DEVICE device, |
| 155 | const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo, |
| 156 | XGL_VIEWPORT_STATE_OBJECT* pState); |
| 157 | |
| 158 | XGL_RESULT XGLAPI intelCreateRasterState( |
| 159 | XGL_DEVICE device, |
| 160 | const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo, |
| 161 | XGL_RASTER_STATE_OBJECT* pState); |
| 162 | |
| 163 | XGL_RESULT XGLAPI intelCreateMsaaState( |
| 164 | XGL_DEVICE device, |
| 165 | const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo, |
| 166 | XGL_MSAA_STATE_OBJECT* pState); |
| 167 | |
| 168 | XGL_RESULT XGLAPI intelCreateColorBlendState( |
| 169 | XGL_DEVICE device, |
| 170 | const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo, |
| 171 | XGL_COLOR_BLEND_STATE_OBJECT* pState); |
| 172 | |
| 173 | XGL_RESULT XGLAPI intelCreateDepthStencilState( |
| 174 | XGL_DEVICE device, |
| 175 | const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo, |
| 176 | XGL_DEPTH_STENCIL_STATE_OBJECT* pState); |
| 177 | |
| 178 | #endif /* STATE_H */ |