aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h
blob: d3181cd29eceaf0b3106bc96db59b79e554e00f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/****************************************************************************
* Copyright (C) 2014-2015 Intel Corporation.   All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @file fetch_jit.h
*
* @brief Definition of the fetch jitter
*
* Notes:
*
******************************************************************************/
#pragma once

#include "common/formats.h"
#include "core/state.h"

//////////////////////////////////////////////////////////////////////////
/// INPUT_ELEMENT_DESC
//////////////////////////////////////////////////////////////////////////
struct INPUT_ELEMENT_DESC
{
    union
    {
        struct
        {
            uint32_t            AlignedByteOffset : 12;
            uint32_t            Format : 10;
            uint32_t            StreamIndex : 6;
            uint32_t            InstanceEnable : 1;
            uint32_t            ComponentControl0 : 3;
            uint32_t            ComponentControl1 : 3;
            uint32_t            ComponentControl2 : 3;
            uint32_t            ComponentControl3 : 3;
            uint32_t            ComponentPacking : 4;
            uint32_t            _reserved : 19;
        };
        uint64_t bits;
    };
    uint32_t InstanceDataStepRate;
};

// used to set ComponentPacking
enum ComponentEnable
{
    NONE = 0x0,
    X    = 0x1,
    Y    = 0x2,
    XY   = 0x3,
    Z    = 0x4,
    XZ   = 0x5,
    YZ   = 0x6,
    XYZ  = 0x7,
    W    = 0x8,
    XW   = 0x9,
    YW   = 0xA,
    XYW  = 0xB,
    ZW   = 0xC,
    XZW  = 0xD,
    YZW  = 0xE,
    XYZW = 0xF,
};

enum ComponentControl
{
    NoStore         = 0,
    StoreSrc        = 1,
    Store0          = 2,
    Store1Fp        = 3,
    Store1Int       = 4,
    StoreVertexId   = 5,
    StoreInstanceId = 6
};

//////////////////////////////////////////////////////////////////////////
/// State required for fetch shader jit compile.
//////////////////////////////////////////////////////////////////////////
struct FETCH_COMPILE_STATE
{
    uint32_t numAttribs;
    INPUT_ELEMENT_DESC layout[KNOB_NUM_ATTRIBUTES];
    SWR_FORMAT indexType;
    uint32_t cutIndex{ 0xffffffff };

    // Options that effect the JIT'd code
    bool bDisableVGATHER;           // if enabled, FetchJit will generate loads/shuffles instead of VGATHERs
    bool bDisableIndexOOBCheck;     // if enabled, FetchJit will exclude index OOB check
    bool bEnableCutIndex{ false };  // compares indices with the cut index and returns a cut mask

    FETCH_COMPILE_STATE(bool disableVGATHER = false, bool diableIndexOOBCheck = false):
        bDisableVGATHER(disableVGATHER), bDisableIndexOOBCheck(diableIndexOOBCheck){ };

    bool operator==(const FETCH_COMPILE_STATE &other) const
    {
        if (numAttribs != other.numAttribs) return false;
        if (indexType != other.indexType) return false;
        if (bDisableVGATHER != other.bDisableVGATHER) return false;
        if (bDisableIndexOOBCheck != other.bDisableIndexOOBCheck) return false;
        if (bEnableCutIndex != other.bEnableCutIndex) return false;
        if (cutIndex != other.cutIndex) return false;

        for(uint32_t i = 0; i < numAttribs; ++i)
        {
            if((layout[i].bits != other.layout[i].bits) ||
               ((layout[i].InstanceEnable == 1) &&
                (layout[i].InstanceDataStepRate != other.layout[i].InstanceDataStepRate))){
                return false;
            }
        }

        return true;
    }
};