Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.h
4574 views
1
/****************************************************************************
2
* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
3
*
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:
10
*
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
13
* Software.
14
*
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
21
* IN THE SOFTWARE.
22
*
23
* @file blend_jit.h
24
*
25
* @brief Definition of the blend jitter
26
*
27
* Notes:
28
*
29
******************************************************************************/
30
#pragma once
31
32
#include "common/formats.h"
33
#include "core/state.h"
34
35
struct RENDER_TARGET_BLEND_COMPILE_STATE
36
{
37
bool blendEnable;
38
bool logicOpEnable;
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;
46
};
47
48
enum ALPHA_TEST_FORMAT
49
{
50
ALPHA_TEST_UNORM8,
51
ALPHA_TEST_FLOAT32
52
};
53
54
//////////////////////////////////////////////////////////////////////////
55
/// BLEND_DESC
56
//////////////////////////////////////////////////////////////////////////
57
struct BLEND_DESC
58
{
59
union
60
{
61
struct
62
{
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;
71
};
72
uint32_t bits;
73
};
74
};
75
#define BLEND_ENABLE_MASK 0x3D // a2c | oMaskEnable | inputCoverageEnable | sampleMaskEnable
76
//////////////////////////////////////////////////////////////////////////
77
/// State required for blend jit
78
//////////////////////////////////////////////////////////////////////////
79
struct BLEND_COMPILE_STATE
80
{
81
SWR_FORMAT format; // format of render target being blended
82
RENDER_TARGET_BLEND_COMPILE_STATE blendState;
83
BLEND_DESC desc;
84
85
SWR_ZFUNCTION alphaTestFunction;
86
ALPHA_TEST_FORMAT alphaTestFormat;
87
88
bool operator==(const BLEND_COMPILE_STATE& other) const
89
{
90
return memcmp(this, &other, sizeof(BLEND_COMPILE_STATE)) == 0;
91
}
92
93
// Canonicalize state to reduce unnecessary JIT compiles
94
void Canonicalize()
95
{
96
if (!desc.alphaTestEnable)
97
{
98
alphaTestFormat = (ALPHA_TEST_FORMAT)0;
99
alphaTestFunction = (SWR_ZFUNCTION)0;
100
}
101
102
if (!blendState.blendEnable)
103
{
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;
110
}
111
112
if (!blendState.logicOpEnable)
113
{
114
blendState.logicOpFunc = (SWR_LOGIC_OP)0;
115
}
116
117
if (!blendState.blendEnable && !blendState.logicOpEnable)
118
{
119
format = (SWR_FORMAT)0;
120
}
121
122
if (!desc.independentAlphaBlendEnable)
123
{
124
blendState.sourceAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
125
blendState.destAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
126
blendState.alphaBlendFunc = (SWR_BLEND_OP)0;
127
}
128
}
129
};
130
131