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 | #include "dev.h" |
| 26 | #include "state.h" |
| 27 | |
| 28 | static void viewport_state_destroy(struct intel_obj *obj) |
| 29 | { |
| 30 | struct intel_viewport_state *state = intel_viewport_state_from_obj(obj); |
| 31 | |
| 32 | intel_viewport_state_destroy(state); |
| 33 | } |
| 34 | |
| 35 | XGL_RESULT intel_viewport_state_create(struct intel_dev *dev, |
| 36 | const XGL_VIEWPORT_STATE_CREATE_INFO *info, |
| 37 | struct intel_viewport_state **state_ret) |
| 38 | { |
| 39 | struct intel_viewport_state *state; |
| 40 | |
| 41 | state = (struct intel_viewport_state *) intel_base_create(dev, |
| 42 | sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_VIEWPORT_STATE, |
| 43 | info, 0); |
| 44 | if (!state) |
| 45 | return XGL_ERROR_OUT_OF_MEMORY; |
| 46 | |
| 47 | state->obj.destroy = viewport_state_destroy; |
| 48 | |
| 49 | //emit_viewport_state(dev->gpu, info, state->cmd); |
| 50 | |
| 51 | *state_ret = state; |
| 52 | |
| 53 | return XGL_SUCCESS; |
| 54 | } |
| 55 | |
| 56 | void intel_viewport_state_destroy(struct intel_viewport_state *state) |
| 57 | { |
| 58 | intel_base_destroy(&state->obj.base); |
| 59 | } |
| 60 | |
| 61 | static void raster_state_destroy(struct intel_obj *obj) |
| 62 | { |
| 63 | struct intel_raster_state *state = intel_raster_state_from_obj(obj); |
| 64 | |
| 65 | intel_raster_state_destroy(state); |
| 66 | } |
| 67 | |
| 68 | XGL_RESULT intel_raster_state_create(struct intel_dev *dev, |
| 69 | const XGL_RASTER_STATE_CREATE_INFO *info, |
| 70 | struct intel_raster_state **state_ret) |
| 71 | { |
| 72 | struct intel_raster_state *state; |
| 73 | |
| 74 | state = (struct intel_raster_state *) intel_base_create(dev, |
| 75 | sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_RASTER_STATE, |
| 76 | info, 0); |
| 77 | if (!state) |
| 78 | return XGL_ERROR_OUT_OF_MEMORY; |
| 79 | |
| 80 | state->obj.destroy = raster_state_destroy; |
| 81 | |
| 82 | //emit_raster_state(dev->gpu, info, state->cmd); |
| 83 | |
| 84 | *state_ret = state; |
| 85 | |
| 86 | return XGL_SUCCESS; |
| 87 | } |
| 88 | |
| 89 | void intel_raster_state_destroy(struct intel_raster_state *state) |
| 90 | { |
| 91 | intel_base_destroy(&state->obj.base); |
| 92 | } |
| 93 | |
| 94 | static void msaa_state_destroy(struct intel_obj *obj) |
| 95 | { |
| 96 | struct intel_msaa_state *state = intel_msaa_state_from_obj(obj); |
| 97 | |
| 98 | intel_msaa_state_destroy(state); |
| 99 | } |
| 100 | |
| 101 | XGL_RESULT intel_msaa_state_create(struct intel_dev *dev, |
| 102 | const XGL_MSAA_STATE_CREATE_INFO *info, |
| 103 | struct intel_msaa_state **state_ret) |
| 104 | { |
| 105 | struct intel_msaa_state *state; |
| 106 | |
| 107 | state = (struct intel_msaa_state *) intel_base_create(dev, |
| 108 | sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_MSAA_STATE, |
| 109 | info, 0); |
| 110 | if (!state) |
| 111 | return XGL_ERROR_OUT_OF_MEMORY; |
| 112 | |
| 113 | state->obj.destroy = msaa_state_destroy; |
| 114 | |
| 115 | //emit_msaa_state(dev->gpu, info, state->cmd); |
| 116 | |
| 117 | *state_ret = state; |
| 118 | |
| 119 | return XGL_SUCCESS; |
| 120 | } |
| 121 | |
| 122 | void intel_msaa_state_destroy(struct intel_msaa_state *state) |
| 123 | { |
| 124 | intel_base_destroy(&state->obj.base); |
| 125 | } |
| 126 | |
| 127 | static void blend_state_destroy(struct intel_obj *obj) |
| 128 | { |
| 129 | struct intel_blend_state *state = intel_blend_state_from_obj(obj); |
| 130 | |
| 131 | intel_blend_state_destroy(state); |
| 132 | } |
| 133 | |
| 134 | XGL_RESULT intel_blend_state_create(struct intel_dev *dev, |
| 135 | const XGL_COLOR_BLEND_STATE_CREATE_INFO *info, |
| 136 | struct intel_blend_state **state_ret) |
| 137 | { |
| 138 | struct intel_blend_state *state; |
| 139 | |
| 140 | state = (struct intel_blend_state *) intel_base_create(dev, |
| 141 | sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_MSAA_STATE, |
| 142 | info, 0); |
| 143 | if (!state) |
| 144 | return XGL_ERROR_OUT_OF_MEMORY; |
| 145 | |
| 146 | state->obj.destroy = blend_state_destroy; |
| 147 | |
| 148 | //emit_blend_state(dev->gpu, info, state->cmd); |
| 149 | |
| 150 | *state_ret = state; |
| 151 | |
| 152 | return XGL_SUCCESS; |
| 153 | } |
| 154 | |
| 155 | void intel_blend_state_destroy(struct intel_blend_state *state) |
| 156 | { |
| 157 | intel_base_destroy(&state->obj.base); |
| 158 | } |
| 159 | |
| 160 | static void ds_state_destroy(struct intel_obj *obj) |
| 161 | { |
| 162 | struct intel_ds_state *state = intel_ds_state_from_obj(obj); |
| 163 | |
| 164 | intel_ds_state_destroy(state); |
| 165 | } |
| 166 | |
| 167 | XGL_RESULT intel_ds_state_create(struct intel_dev *dev, |
| 168 | const XGL_DEPTH_STENCIL_STATE_CREATE_INFO *info, |
| 169 | struct intel_ds_state **state_ret) |
| 170 | { |
| 171 | struct intel_ds_state *state; |
| 172 | |
| 173 | state = (struct intel_ds_state *) intel_base_create(dev, |
| 174 | sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_MSAA_STATE, |
| 175 | info, 0); |
| 176 | if (!state) |
| 177 | return XGL_ERROR_OUT_OF_MEMORY; |
| 178 | |
| 179 | state->obj.destroy = ds_state_destroy; |
| 180 | |
| 181 | //emit_ds_state(dev->gpu, info, state->cmd); |
| 182 | |
| 183 | *state_ret = state; |
| 184 | |
| 185 | return XGL_SUCCESS; |
| 186 | } |
| 187 | |
| 188 | void intel_ds_state_destroy(struct intel_ds_state *state) |
| 189 | { |
| 190 | intel_base_destroy(&state->obj.base); |
| 191 | } |
| 192 | |
| 193 | XGL_RESULT XGLAPI intelCreateViewportState( |
| 194 | XGL_DEVICE device, |
| 195 | const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo, |
| 196 | XGL_VIEWPORT_STATE_OBJECT* pState) |
| 197 | { |
| 198 | struct intel_dev *dev = intel_dev(device); |
| 199 | |
| 200 | return intel_viewport_state_create(dev, pCreateInfo, |
| 201 | (struct intel_viewport_state **) pState); |
| 202 | } |
| 203 | |
| 204 | XGL_RESULT XGLAPI intelCreateRasterState( |
| 205 | XGL_DEVICE device, |
| 206 | const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo, |
| 207 | XGL_RASTER_STATE_OBJECT* pState) |
| 208 | { |
| 209 | struct intel_dev *dev = intel_dev(device); |
| 210 | |
| 211 | return intel_raster_state_create(dev, pCreateInfo, |
| 212 | (struct intel_raster_state **) pState); |
| 213 | } |
| 214 | |
| 215 | XGL_RESULT XGLAPI intelCreateMsaaState( |
| 216 | XGL_DEVICE device, |
| 217 | const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo, |
| 218 | XGL_MSAA_STATE_OBJECT* pState) |
| 219 | { |
| 220 | struct intel_dev *dev = intel_dev(device); |
| 221 | |
| 222 | return intel_msaa_state_create(dev, pCreateInfo, |
| 223 | (struct intel_msaa_state **) pState); |
| 224 | } |
| 225 | |
| 226 | XGL_RESULT XGLAPI intelCreateColorBlendState( |
| 227 | XGL_DEVICE device, |
| 228 | const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo, |
| 229 | XGL_COLOR_BLEND_STATE_OBJECT* pState) |
| 230 | { |
| 231 | struct intel_dev *dev = intel_dev(device); |
| 232 | |
| 233 | return intel_blend_state_create(dev, pCreateInfo, |
| 234 | (struct intel_blend_state **) pState); |
| 235 | } |
| 236 | |
| 237 | XGL_RESULT XGLAPI intelCreateDepthStencilState( |
| 238 | XGL_DEVICE device, |
| 239 | const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo, |
| 240 | XGL_DEPTH_STENCIL_STATE_OBJECT* pState) |
| 241 | { |
| 242 | struct intel_dev *dev = intel_dev(device); |
| 243 | |
| 244 | return intel_ds_state_create(dev, pCreateInfo, |
| 245 | (struct intel_ds_state **) pState); |
| 246 | } |