1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * @brief Definition of the blend jitter
29 ******************************************************************************/
32 #include "common/formats.h"
33 #include "core/state.h"
35 struct RENDER_TARGET_BLEND_COMPILE_STATE
39 SWR_BLEND_FACTOR sourceAlphaBlendFactor
;
40 SWR_BLEND_FACTOR destAlphaBlendFactor
;
41 SWR_BLEND_FACTOR sourceBlendFactor
;
42 SWR_BLEND_FACTOR destBlendFactor
;
43 SWR_BLEND_OP colorBlendFunc
;
44 SWR_BLEND_OP alphaBlendFunc
;
45 SWR_LOGIC_OP logicOpFunc
;
48 enum ALPHA_TEST_FORMAT
54 //////////////////////////////////////////////////////////////////////////
56 //////////////////////////////////////////////////////////////////////////
63 uint32_t alphaTestEnable
: 1;
64 uint32_t independentAlphaBlendEnable
: 1;
65 uint32_t alphaToCoverageEnable
: 1;
66 uint32_t oMaskEnable
:1;
67 uint32_t inputCoverageEnable
:1;
68 uint32_t sampleMaskEnable
:1;
69 uint32_t numSamples
:5;
70 uint32_t _reserved
: 21;
75 #define BLEND_ENABLE_MASK 0x3D // a2c | oMaskEnable | inputCoverageEnable | sampleMaskEnable
76 //////////////////////////////////////////////////////////////////////////
77 /// State required for blend jit
78 //////////////////////////////////////////////////////////////////////////
79 struct BLEND_COMPILE_STATE
81 SWR_FORMAT format
; // format of render target being blended
82 RENDER_TARGET_BLEND_COMPILE_STATE blendState
;
85 SWR_ZFUNCTION alphaTestFunction
;
86 ALPHA_TEST_FORMAT alphaTestFormat
;
88 bool operator==(const BLEND_COMPILE_STATE
& other
) const
90 return memcmp(this, &other
, sizeof(BLEND_COMPILE_STATE
)) == 0;
93 // Canonicalize state to reduce unnecessary JIT compiles
96 if (!desc
.alphaTestEnable
)
98 alphaTestFormat
= (ALPHA_TEST_FORMAT
)0;
99 alphaTestFunction
= (SWR_ZFUNCTION
)0;
102 if (!blendState
.blendEnable
)
104 blendState
.sourceAlphaBlendFactor
= (SWR_BLEND_FACTOR
)0;
105 blendState
.destAlphaBlendFactor
= (SWR_BLEND_FACTOR
)0;
106 blendState
.sourceBlendFactor
= (SWR_BLEND_FACTOR
)0;
107 blendState
.destBlendFactor
= (SWR_BLEND_FACTOR
)0;
108 blendState
.colorBlendFunc
= (SWR_BLEND_OP
)0;
109 blendState
.alphaBlendFunc
= (SWR_BLEND_OP
)0;
112 if (!blendState
.logicOpEnable
)
114 blendState
.logicOpFunc
= (SWR_LOGIC_OP
)0;
117 if (!blendState
.blendEnable
&& !blendState
.logicOpEnable
)
119 format
= (SWR_FORMAT
)0;
122 if (!desc
.independentAlphaBlendEnable
)
124 blendState
.sourceAlphaBlendFactor
= (SWR_BLEND_FACTOR
)0;
125 blendState
.destAlphaBlendFactor
= (SWR_BLEND_FACTOR
)0;
126 blendState
.alphaBlendFunc
= (SWR_BLEND_OP
)0;