blob: e41f9dd2f472de1756e0979357b30509ea5b1296 [file] [log] [blame]
Chia-I Wua5714e82014-08-11 15:33:42 +08001/*
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 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 Barbourfa6cac72015-01-16 14:27:35 -070036struct intel_dynamic_vp {
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;
Tony Barbourfa6cac72015-01-16 14:27:35 -070040 bool has_scissor_rects;
Chia-I Wua5714e82014-08-11 15:33:42 +080041 /* SF_CLIP_VIEWPORTs, CC_VIEWPORTs, and SCISSOR_RECTs */
42 uint32_t *cmd;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060043 uint32_t cmd_len;
44 uint32_t cmd_clip_pos;
45 uint32_t cmd_cc_pos;
46 uint32_t cmd_scissor_rect_pos;
Chia-I Wua5714e82014-08-11 15:33:42 +080047};
48
Tony Barbourfa6cac72015-01-16 14:27:35 -070049struct intel_dynamic_rs {
Chia-I Wua5714e82014-08-11 15:33:42 +080050 struct intel_obj obj;
Tony Barbourfa6cac72015-01-16 14:27:35 -070051 XGL_DYNAMIC_RS_STATE_CREATE_INFO rs_info;
Chia-I Wua5714e82014-08-11 15:33:42 +080052};
53
Tony Barbourfa6cac72015-01-16 14:27:35 -070054struct intel_dynamic_cb {
Chia-I Wua5714e82014-08-11 15:33:42 +080055 struct intel_obj obj;
Tony Barbourfa6cac72015-01-16 14:27:35 -070056 XGL_DYNAMIC_CB_STATE_CREATE_INFO cb_info;
Chia-I Wua5714e82014-08-11 15:33:42 +080057};
58
Tony Barbourfa6cac72015-01-16 14:27:35 -070059struct intel_dynamic_ds {
Chia-I Wua5714e82014-08-11 15:33:42 +080060 struct intel_obj obj;
Tony Barbourfa6cac72015-01-16 14:27:35 -070061 XGL_DYNAMIC_DS_STATE_CREATE_INFO ds_info;
Chia-I Wua5714e82014-08-11 15:33:42 +080062};
63
Tony Barbourfa6cac72015-01-16 14:27:35 -070064static inline struct intel_dynamic_vp *intel_dynamic_vp(XGL_DYNAMIC_VP_STATE_OBJECT state)
Chia-I Wua5714e82014-08-11 15:33:42 +080065{
Tony Barbourfa6cac72015-01-16 14:27:35 -070066 return (struct intel_dynamic_vp *) state;
Chia-I Wua5714e82014-08-11 15:33:42 +080067}
68
Tony Barbourfa6cac72015-01-16 14:27:35 -070069static inline struct intel_dynamic_vp *intel_viewport_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +080070{
Tony Barbourfa6cac72015-01-16 14:27:35 -070071 return (struct intel_dynamic_vp *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +080072}
73
Tony Barbourfa6cac72015-01-16 14:27:35 -070074static inline struct intel_dynamic_rs *intel_dynamic_rs(XGL_DYNAMIC_RS_STATE_OBJECT state)
Chia-I Wua5714e82014-08-11 15:33:42 +080075{
Tony Barbourfa6cac72015-01-16 14:27:35 -070076 return (struct intel_dynamic_rs *) state;
Chia-I Wua5714e82014-08-11 15:33:42 +080077}
78
Tony Barbourfa6cac72015-01-16 14:27:35 -070079static inline struct intel_dynamic_rs *intel_raster_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +080080{
Tony Barbourfa6cac72015-01-16 14:27:35 -070081 return (struct intel_dynamic_rs *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +080082}
83
Tony Barbourfa6cac72015-01-16 14:27:35 -070084static inline struct intel_dynamic_cb *intel_dynamic_cb(XGL_DYNAMIC_CB_STATE_OBJECT state)
Chia-I Wua5714e82014-08-11 15:33:42 +080085{
Tony Barbourfa6cac72015-01-16 14:27:35 -070086 return (struct intel_dynamic_cb *) state;
Chia-I Wua5714e82014-08-11 15:33:42 +080087}
88
Tony Barbourfa6cac72015-01-16 14:27:35 -070089static inline struct intel_dynamic_cb *intel_blend_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +080090{
Tony Barbourfa6cac72015-01-16 14:27:35 -070091 return (struct intel_dynamic_cb *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +080092}
93
Tony Barbourfa6cac72015-01-16 14:27:35 -070094static inline struct intel_dynamic_ds *intel_dynamic_ds(XGL_DYNAMIC_DS_STATE_OBJECT state)
Chia-I Wua5714e82014-08-11 15:33:42 +080095{
Tony Barbourfa6cac72015-01-16 14:27:35 -070096 return (struct intel_dynamic_ds *) state;
Chia-I Wua5714e82014-08-11 15:33:42 +080097}
98
Tony Barbourfa6cac72015-01-16 14:27:35 -070099static inline struct intel_dynamic_ds *intel_ds_state_from_obj(struct intel_obj *obj)
Chia-I Wua5714e82014-08-11 15:33:42 +0800100{
Tony Barbourfa6cac72015-01-16 14:27:35 -0700101 return (struct intel_dynamic_ds *) obj;
Chia-I Wua5714e82014-08-11 15:33:42 +0800102}
103
104XGL_RESULT intel_viewport_state_create(struct intel_dev *dev,
Tony Barbourfa6cac72015-01-16 14:27:35 -0700105 const XGL_DYNAMIC_VP_STATE_CREATE_INFO *info,
106 struct intel_dynamic_vp **state_ret);
107void intel_viewport_state_destroy(struct intel_dynamic_vp *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800108
109XGL_RESULT intel_raster_state_create(struct intel_dev *dev,
Tony Barbourfa6cac72015-01-16 14:27:35 -0700110 const XGL_DYNAMIC_RS_STATE_CREATE_INFO *info,
111 struct intel_dynamic_rs **state_ret);
112void intel_raster_state_destroy(struct intel_dynamic_rs *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800113
114XGL_RESULT intel_blend_state_create(struct intel_dev *dev,
Tony Barbourfa6cac72015-01-16 14:27:35 -0700115 const XGL_DYNAMIC_CB_STATE_CREATE_INFO *info,
116 struct intel_dynamic_cb **state_ret);
117void intel_blend_state_destroy(struct intel_dynamic_cb *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800118
119XGL_RESULT intel_ds_state_create(struct intel_dev *dev,
Tony Barbourfa6cac72015-01-16 14:27:35 -0700120 const XGL_DYNAMIC_DS_STATE_CREATE_INFO *info,
121 struct intel_dynamic_ds **state_ret);
122void intel_ds_state_destroy(struct intel_dynamic_ds *state);
Chia-I Wua5714e82014-08-11 15:33:42 +0800123
Chia-I Wua5714e82014-08-11 15:33:42 +0800124#endif /* STATE_H */