Path: blob/21.2-virgl/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h
4574 views
/****************************************************************************1* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22* @file fetch_jit.h23*24* @brief Definition of the fetch jitter25*26* Notes:27*28******************************************************************************/29#pragma once3031#include "common/formats.h"32#include "core/state.h"3334//////////////////////////////////////////////////////////////////////////35/// INPUT_ELEMENT_DESC36//////////////////////////////////////////////////////////////////////////37struct INPUT_ELEMENT_DESC38{39union40{41struct42{43uint32_t AlignedByteOffset : 12;44uint32_t Format : 10;45uint32_t StreamIndex : 6;46uint32_t InstanceEnable : 1;47uint32_t InstanceStrideEnable : 1;48uint32_t ComponentControl0 : 4;49uint32_t ComponentControl1 : 4;50uint32_t ComponentControl2 : 4;51uint32_t ComponentControl3 : 4;52uint32_t ComponentPacking : 4;53uint32_t _reserved : 14;54};55uint64_t bits;56};57uint32_t InstanceAdvancementState;58};5960// used to set ComponentPacking61enum ComponentEnable62{63NONE = 0x0,64X = 0x1,65Y = 0x2,66XY = 0x3,67Z = 0x4,68XZ = 0x5,69YZ = 0x6,70XYZ = 0x7,71W = 0x8,72XW = 0x9,73YW = 0xA,74XYW = 0xB,75ZW = 0xC,76XZW = 0xD,77YZW = 0xE,78XYZW = 0xF,79};8081enum ComponentControl82{83NoStore = 0,84StoreSrc = 1,85Store0 = 2,86Store1Fp = 3,87Store1Int = 4,88StoreVertexId = 5,89StoreInstanceId = 6,90};9192//////////////////////////////////////////////////////////////////////////93/// State required for fetch shader jit compile.94//////////////////////////////////////////////////////////////////////////95struct FETCH_COMPILE_STATE96{97uint32_t numAttribs{0};98INPUT_ELEMENT_DESC layout[SWR_VTX_NUM_SLOTS];99SWR_FORMAT indexType;100uint32_t cutIndex{0xffffffff};101102// Options that effect the JIT'd code103bool bDisableIndexOOBCheck; // If enabled, FetchJit will exclude index OOB check104bool bEnableCutIndex{false}; // Compares indices with the cut index and returns a cut mask105bool bVertexIDOffsetEnable{false}; // Offset vertexID by StartVertex for non-indexed draws or106// BaseVertex for indexed draws107bool bPartialVertexBuffer{108false}; // for indexed draws, map illegal indices to a known resident vertex109110bool bForceSequentialAccessEnable{false};111bool bInstanceIDOffsetEnable{false};112113FETCH_COMPILE_STATE(bool disableIndexOOBCheck = false) :114bDisableIndexOOBCheck(disableIndexOOBCheck){};115116bool operator==(const FETCH_COMPILE_STATE& other) const117{118if (numAttribs != other.numAttribs)119return false;120if (indexType != other.indexType)121return false;122if (bDisableIndexOOBCheck != other.bDisableIndexOOBCheck)123return false;124if (bEnableCutIndex != other.bEnableCutIndex)125return false;126if (cutIndex != other.cutIndex)127return false;128if (bVertexIDOffsetEnable != other.bVertexIDOffsetEnable)129return false;130if (bPartialVertexBuffer != other.bPartialVertexBuffer)131return false;132if (bForceSequentialAccessEnable != other.bForceSequentialAccessEnable)133return false;134if (bInstanceIDOffsetEnable != other.bInstanceIDOffsetEnable)135return false;136137for (uint32_t i = 0; i < numAttribs; ++i)138{139if ((layout[i].bits != other.layout[i].bits) ||140(((layout[i].InstanceEnable == 1) || (layout[i].InstanceStrideEnable == 1)) &&141(layout[i].InstanceAdvancementState != other.layout[i].InstanceAdvancementState)))142{143return false;144}145}146147return true;148}149};150151152