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/fetch_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 fetch_jit.h
24
*
25
* @brief Definition of the fetch jitter
26
*
27
* Notes:
28
*
29
******************************************************************************/
30
#pragma once
31
32
#include "common/formats.h"
33
#include "core/state.h"
34
35
//////////////////////////////////////////////////////////////////////////
36
/// INPUT_ELEMENT_DESC
37
//////////////////////////////////////////////////////////////////////////
38
struct INPUT_ELEMENT_DESC
39
{
40
union
41
{
42
struct
43
{
44
uint32_t AlignedByteOffset : 12;
45
uint32_t Format : 10;
46
uint32_t StreamIndex : 6;
47
uint32_t InstanceEnable : 1;
48
uint32_t InstanceStrideEnable : 1;
49
uint32_t ComponentControl0 : 4;
50
uint32_t ComponentControl1 : 4;
51
uint32_t ComponentControl2 : 4;
52
uint32_t ComponentControl3 : 4;
53
uint32_t ComponentPacking : 4;
54
uint32_t _reserved : 14;
55
};
56
uint64_t bits;
57
};
58
uint32_t InstanceAdvancementState;
59
};
60
61
// used to set ComponentPacking
62
enum ComponentEnable
63
{
64
NONE = 0x0,
65
X = 0x1,
66
Y = 0x2,
67
XY = 0x3,
68
Z = 0x4,
69
XZ = 0x5,
70
YZ = 0x6,
71
XYZ = 0x7,
72
W = 0x8,
73
XW = 0x9,
74
YW = 0xA,
75
XYW = 0xB,
76
ZW = 0xC,
77
XZW = 0xD,
78
YZW = 0xE,
79
XYZW = 0xF,
80
};
81
82
enum ComponentControl
83
{
84
NoStore = 0,
85
StoreSrc = 1,
86
Store0 = 2,
87
Store1Fp = 3,
88
Store1Int = 4,
89
StoreVertexId = 5,
90
StoreInstanceId = 6,
91
};
92
93
//////////////////////////////////////////////////////////////////////////
94
/// State required for fetch shader jit compile.
95
//////////////////////////////////////////////////////////////////////////
96
struct FETCH_COMPILE_STATE
97
{
98
uint32_t numAttribs{0};
99
INPUT_ELEMENT_DESC layout[SWR_VTX_NUM_SLOTS];
100
SWR_FORMAT indexType;
101
uint32_t cutIndex{0xffffffff};
102
103
// Options that effect the JIT'd code
104
bool bDisableIndexOOBCheck; // If enabled, FetchJit will exclude index OOB check
105
bool bEnableCutIndex{false}; // Compares indices with the cut index and returns a cut mask
106
bool bVertexIDOffsetEnable{false}; // Offset vertexID by StartVertex for non-indexed draws or
107
// BaseVertex for indexed draws
108
bool bPartialVertexBuffer{
109
false}; // for indexed draws, map illegal indices to a known resident vertex
110
111
bool bForceSequentialAccessEnable{false};
112
bool bInstanceIDOffsetEnable{false};
113
114
FETCH_COMPILE_STATE(bool disableIndexOOBCheck = false) :
115
bDisableIndexOOBCheck(disableIndexOOBCheck){};
116
117
bool operator==(const FETCH_COMPILE_STATE& other) const
118
{
119
if (numAttribs != other.numAttribs)
120
return false;
121
if (indexType != other.indexType)
122
return false;
123
if (bDisableIndexOOBCheck != other.bDisableIndexOOBCheck)
124
return false;
125
if (bEnableCutIndex != other.bEnableCutIndex)
126
return false;
127
if (cutIndex != other.cutIndex)
128
return false;
129
if (bVertexIDOffsetEnable != other.bVertexIDOffsetEnable)
130
return false;
131
if (bPartialVertexBuffer != other.bPartialVertexBuffer)
132
return false;
133
if (bForceSequentialAccessEnable != other.bForceSequentialAccessEnable)
134
return false;
135
if (bInstanceIDOffsetEnable != other.bInstanceIDOffsetEnable)
136
return false;
137
138
for (uint32_t i = 0; i < numAttribs; ++i)
139
{
140
if ((layout[i].bits != other.layout[i].bits) ||
141
(((layout[i].InstanceEnable == 1) || (layout[i].InstanceStrideEnable == 1)) &&
142
(layout[i].InstanceAdvancementState != other.layout[i].InstanceAdvancementState)))
143
{
144
return false;
145
}
146
}
147
148
return true;
149
}
150
};
151
152