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