swr/rast: Refactor memory API between rasterizer core and swr

This commit cleans up API between the core of the rasterizer and swr.
Some formatting changes are also done.

Reviewed-by: Alok Hota <alok.hota@intel.com>
This commit is contained in:
Jan Zielinski 2019-07-17 17:22:16 +02:00
parent 4627a0c4eb
commit 6f7306c029
30 changed files with 370 additions and 185 deletions

View file

@ -102,6 +102,16 @@ env.CodeGenerate(
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp')
env.CodeGenerate(
target = './gen_surf_state_llvm.h',
script = swrroot + 'rasterizer/codegen/gen_llvm_types.py',
source = 'rasterizer/memory/SurfaceState.h',
command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp')
env.CodeGenerate(
script = swrroot + 'rasterizer/codegen/gen_archrast.py',
target = ['rasterizer/archrast/gen_ar_event.hpp',

View file

@ -83,6 +83,7 @@ files_swr_mesa = files(
'rasterizer/jitter/streamout_jit.h',
'rasterizer/jitter/shader_lib/DebugOutput.cpp',
'rasterizer/jitter/functionpasses/lower_x86.cpp',
'rasterizer/memory/SurfaceState.h'
)
files_swr_arch = files(
@ -153,10 +154,12 @@ files_swr_arch = files(
'rasterizer/memory/tilingtraits.h',
'rasterizer/memory/InitMemory.h',
'rasterizer/memory/InitMemory.cpp',
'rasterizer/memory/SurfaceState.h'
)
swr_context_files = files('swr_context.h')
swr_state_files = files('rasterizer/core/state.h')
swr_surf_state_files = files('rasterizer/memory/SurfaceState.h')
swr_event_proto_files = files('rasterizer/archrast/events.proto')
swr_event_pproto_files = files('rasterizer/archrast/events_private.proto')
swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp')

View file

@ -0,0 +1,114 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
#AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
#IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
#IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
#RawStringFormats:
# - Delimiter: pb
# Language: TextProto
# BasedOnStyle: google
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

View file

@ -48,7 +48,8 @@ files_swr_common += [
]
foreach x : [[swr_context_files, 'gen_swr_context_llvm.h'],
[swr_state_files, 'gen_state_llvm.h']]
[swr_state_files, 'gen_state_llvm.h'],
[swr_surf_state_files, 'gen_surf_state_llvm.h']]
files_swr_common += custom_target(
x[1],
input : ['gen_llvm_types.py', x[0]],

View file

@ -50,11 +50,7 @@ ${func['decl']}
%else:
FunctionType* pFuncTy = FunctionType::get(${ func['returnType'] }, {}, false);
%endif:
#if LLVM_VERSION_MAJOR >= 9
Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("meta.intrinsic.${func['name']}", pFuncTy).getCallee());
#else
Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("meta.intrinsic.${func['name']}", pFuncTy));
#endif
return CALL(pFunc, std::initializer_list<Value*>{${argList}}, name);
%elif isIntrin:
%if len(func['types']) != 0:

View file

@ -193,15 +193,14 @@ HANDLE SwrCreateContext(SWR_CREATECONTEXT_INFO* pCreateInfo)
pContext->pHotTileMgr = new HotTileMgr();
// initialize callback functions
pContext->pfnLoadTile = pCreateInfo->pfnLoadTile;
pContext->pfnStoreTile = pCreateInfo->pfnStoreTile;
pContext->pfnClearTile = pCreateInfo->pfnClearTile;
pContext->pfnTranslateGfxptrForRead = pCreateInfo->pfnTranslateGfxptrForRead;
pContext->pfnTranslateGfxptrForWrite = pCreateInfo->pfnTranslateGfxptrForWrite;
pContext->pfnMakeGfxPtr = pCreateInfo->pfnMakeGfxPtr;
pContext->pfnUpdateSoWriteOffset = pCreateInfo->pfnUpdateSoWriteOffset;
pContext->pfnUpdateStats = pCreateInfo->pfnUpdateStats;
pContext->pfnUpdateStatsFE = pCreateInfo->pfnUpdateStatsFE;
pContext->pfnLoadTile = pCreateInfo->pfnLoadTile;
pContext->pfnStoreTile = pCreateInfo->pfnStoreTile;
pContext->pfnTranslateGfxptrForRead = pCreateInfo->pfnTranslateGfxptrForRead;
pContext->pfnTranslateGfxptrForWrite = pCreateInfo->pfnTranslateGfxptrForWrite;
pContext->pfnMakeGfxPtr = pCreateInfo->pfnMakeGfxPtr;
pContext->pfnUpdateSoWriteOffset = pCreateInfo->pfnUpdateSoWriteOffset;
pContext->pfnUpdateStats = pCreateInfo->pfnUpdateStats;
pContext->pfnUpdateStatsFE = pCreateInfo->pfnUpdateStatsFE;
// pass pointer to bucket manager back to caller
@ -1769,7 +1768,4 @@ void SwrGetInterface(SWR_INTERFACE& out_funcs)
out_funcs.pfnSwrEnableStatsBE = SwrEnableStatsBE;
out_funcs.pfnSwrEndFrame = SwrEndFrame;
out_funcs.pfnSwrInit = SwrInit;
out_funcs.pfnSwrLoadHotTile = SwrLoadHotTile;
out_funcs.pfnSwrStoreHotTileToSurface = SwrStoreHotTileToSurface;
out_funcs.pfnSwrStoreHotTileClear = SwrStoreHotTileClear;
}

View file

@ -145,17 +145,15 @@ typedef void(SWR_API* PFN_CLEAR_TILE)(HANDLE hPrivateContex
uint32_t renderTargetArrayIndex,
const float* pClearColor);
typedef void*(SWR_API* PFN_TRANSLATE_GFXPTR_FOR_READ)(HANDLE hPrivateContext,
gfxptr_t xpAddr,
bool* pbNullTileAccessed);
typedef void* (SWR_API* PFN_TRANSLATE_GFXPTR_FOR_READ)(HANDLE hPrivateContext,
gfxptr_t xpAddr,
bool* pbNullTileAccessed);
typedef void*(SWR_API* PFN_TRANSLATE_GFXPTR_FOR_WRITE)(HANDLE hPrivateContext,
gfxptr_t xpAddr,
bool* pbNullTileAccessed);
typedef void* (SWR_API* PFN_TRANSLATE_GFXPTR_FOR_WRITE)(HANDLE hPrivateContext,
gfxptr_t xpAddr,
bool* pbNullTileAccessed);
typedef gfxptr_t(SWR_API* PFN_MAKE_GFXPTR)(HANDLE hPrivateContext,
void* sysAddr);
typedef gfxptr_t(SWR_API* PFN_MAKE_GFXPTR)(HANDLE hPrivateContext, void* sysAddr);
//////////////////////////////////////////////////////////////////////////
/// @brief Callback to allow driver to update their copy of streamout write offset.
@ -250,15 +248,14 @@ struct SWR_CREATECONTEXT_INFO
SWR_WORKER_PRIVATE_STATE* pWorkerPrivateState;
// Callback functions
PFN_LOAD_TILE pfnLoadTile;
PFN_STORE_TILE pfnStoreTile;
PFN_CLEAR_TILE pfnClearTile;
PFN_TRANSLATE_GFXPTR_FOR_READ pfnTranslateGfxptrForRead;
PFN_TRANSLATE_GFXPTR_FOR_WRITE pfnTranslateGfxptrForWrite;
PFN_MAKE_GFXPTR pfnMakeGfxPtr;
PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset;
PFN_UPDATE_STATS pfnUpdateStats;
PFN_UPDATE_STATS_FE pfnUpdateStatsFE;
PFN_LOAD_TILE pfnLoadTile;
PFN_STORE_TILE pfnStoreTile;
PFN_TRANSLATE_GFXPTR_FOR_READ pfnTranslateGfxptrForRead;
PFN_TRANSLATE_GFXPTR_FOR_WRITE pfnTranslateGfxptrForWrite;
PFN_MAKE_GFXPTR pfnMakeGfxPtr;
PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset;
PFN_UPDATE_STATS pfnUpdateStats;
PFN_UPDATE_STATS_FE pfnUpdateStatsFE;
// Pointer to rdtsc buckets mgr returned to the caller.
@ -687,58 +684,6 @@ SWR_FUNC(void, SwrEndFrame, HANDLE hContext);
SWR_FUNC(void, SwrInit);
//////////////////////////////////////////////////////////////////////////
/// @brief Loads a full hottile from a render surface
/// @param hPrivateContext - Handle to private DC
/// @param dstFormat - Format for hot tile.
/// @param renderTargetIndex - Index to src render target
/// @param x, y - Coordinates to raster tile.
/// @param pDstHotTile - Pointer to Hot Tile
SWR_FUNC(void,
SwrLoadHotTile,
HANDLE hWorkerPrivateData,
const SWR_SURFACE_STATE* pSrcSurface,
SWR_FORMAT dstFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x,
uint32_t y,
uint32_t renderTargetArrayIndex,
uint8_t* pDstHotTile);
//////////////////////////////////////////////////////////////////////////
/// @brief Deswizzles and stores a full hottile to a render surface
/// @param hPrivateContext - Handle to private DC
/// @param srcFormat - Format for hot tile.
/// @param renderTargetIndex - Index to destination render target
/// @param x, y - Coordinates to raster tile.
/// @param pSrcHotTile - Pointer to Hot Tile
SWR_FUNC(void,
SwrStoreHotTileToSurface,
HANDLE hWorkerPrivateData,
SWR_SURFACE_STATE* pDstSurface,
SWR_FORMAT srcFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x,
uint32_t y,
uint32_t renderTargetArrayIndex,
uint8_t* pSrcHotTile);
//////////////////////////////////////////////////////////////////////////
/// @brief Writes clear color to every pixel of a render surface
/// @param hPrivateContext - Handle to private DC
/// @param renderTargetIndex - Index to destination render target
/// @param x, y - Coordinates to raster tile.
/// @param pClearColor - Pointer to clear color
SWR_FUNC(void,
SwrStoreHotTileClear,
HANDLE hWorkerPrivateData,
SWR_SURFACE_STATE* pDstSurface,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x,
uint32_t y,
uint32_t renderTargetArrayIndex,
const float* pClearColor);
struct SWR_INTERFACE
{
PFNSwrCreateContext pfnSwrCreateContext;
@ -788,9 +733,6 @@ struct SWR_INTERFACE
PFNSwrEnableStatsBE pfnSwrEnableStatsBE;
PFNSwrEndFrame pfnSwrEndFrame;
PFNSwrInit pfnSwrInit;
PFNSwrLoadHotTile pfnSwrLoadHotTile;
PFNSwrStoreHotTileToSurface pfnSwrStoreHotTileToSurface;
PFNSwrStoreHotTileClear pfnSwrStoreHotTileClear;
};
extern "C" {

View file

@ -1056,7 +1056,6 @@ void BackendPixelRate(DRAW_CONTEXT* pDC,
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
psContext.alternateOffset = useAlternateOffset ? 1 : 0;
simdscalar activeLanes;
if (!(work.anyCoveredSamples & MASK))

View file

@ -83,7 +83,6 @@ void BackendSampleRate(DRAW_CONTEXT* pDC,
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
psContext.alternateOffset = useAlternateOffset ? 1 : 0;
if (T::InputCoverage != SWR_INPUT_COVERAGE_NONE)
{

View file

@ -84,7 +84,6 @@ void BackendSingleSample(DRAW_CONTEXT* pDC,
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
psContext.alternateOffset = useAlternateOffset ? 1 : 0;
simdmask coverageMask = work.coverageMask[0] & MASK;

View file

@ -525,7 +525,6 @@ struct SWR_CONTEXT
// Callback functions, passed in at create context time
PFN_LOAD_TILE pfnLoadTile;
PFN_STORE_TILE pfnStoreTile;
PFN_CLEAR_TILE pfnClearTile;
PFN_TRANSLATE_GFXPTR_FOR_READ pfnTranslateGfxptrForRead;
PFN_TRANSLATE_GFXPTR_FOR_WRITE pfnTranslateGfxptrForWrite;
PFN_MAKE_GFXPTR pfnMakeGfxPtr;

View file

@ -139,7 +139,7 @@ INLINE Float<SIMD_T> SIMDCALL Clamp(Float<SIMD_T> const& v, uint32_t Component)
}
template <SWR_FORMAT Format>
INLINE simdscalar SIMDCALL Clamp(simdscalar const& v, uint32_t Component)
INLINE simd16scalar SIMDCALL Clamp(simdscalar const& v, uint32_t Component)
{
return Clamp<SIMD256, Format>(v, Component);
}
@ -168,7 +168,7 @@ INLINE Float<SIMD_T> SIMDCALL Normalize(Float<SIMD_T> const& vComp, uint32_t Com
}
template <SWR_FORMAT Format>
INLINE simdscalar SIMDCALL Normalize(simdscalar const& vComp, uint32_t Component)
INLINE simd16scalar SIMDCALL Normalize(simdscalar const& vComp, uint32_t Component)
{
return Normalize<SIMD256, Format>(vComp, Component);
}

View file

@ -380,8 +380,6 @@ struct SWR_PS_CONTEXT
uint8_t* pColorBuffer[SWR_NUM_RENDERTARGETS]; // IN: Pointers to render target hottiles
uint32_t alternateOffset; // IN: for 8x2 tile backend, which 4x2 do we need to read from
SWR_SHADER_STATS stats; // OUT: shader statistics used for archrast.
};
@ -538,47 +536,6 @@ enum SWR_AUX_MODE
AUX_MODE_DEPTH,
};
struct SWR_LOD_OFFSETS
{
uint32_t offsets[2][15];
};
//////////////////////////////////////////////////////////////////////////
/// SWR_SURFACE_STATE
//////////////////////////////////////////////////////////////////////////
struct SWR_SURFACE_STATE
{
gfxptr_t xpBaseAddress;
SWR_SURFACE_TYPE type; // @llvm_enum
SWR_FORMAT format; // @llvm_enum
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t numSamples;
uint32_t samplePattern;
uint32_t pitch;
uint32_t qpitch;
uint32_t minLod; // for sampled surfaces, the most detailed LOD that can be accessed by sampler
uint32_t maxLod; // for sampled surfaces, the max LOD that can be accessed
float resourceMinLod; // for sampled surfaces, the most detailed fractional mip that can be
// accessed by sampler
uint32_t lod; // for render targets, the lod being rendered to
uint32_t arrayIndex; // for render targets, the array index being rendered to for arrayed surfaces
SWR_TILE_MODE tileMode; // @llvm_enum
uint32_t halign;
uint32_t valign;
uint32_t xOffset;
uint32_t yOffset;
uint32_t lodOffsets[2][15]; // lod offsets for sampled surfaces
gfxptr_t xpAuxBaseAddress; // Used for compression, append/consume counter, etc.
SWR_AUX_MODE auxMode; // @llvm_enum
bool bInterleavedSamples; // are MSAA samples stored interleaved or planar
};
// vertex fetch state
// WARNING- any changes to this struct need to be reflected
// in the fetch shader jit

View file

@ -445,11 +445,7 @@ namespace SwrJit
args.push_back(PointerType::get(mInt8Ty, 0));
FunctionType* callPrintTy = FunctionType::get(Type::getVoidTy(JM()->mContext), args, true);
Function* callPrintFn =
#if LLVM_VERSION_MAJOR >= 9
cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("CallPrint", callPrintTy).getCallee());
#else
cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("CallPrint", callPrintTy));
#endif
// if we haven't yet added the symbol to the symbol table
if ((sys::DynamicLibrary::SearchForAddressOfSymbol("CallPrint")) == nullptr)
@ -618,11 +614,7 @@ namespace SwrJit
{
FunctionType* pFuncTy = FunctionType::get(mFP32Ty, mInt16Ty);
Function* pCvtPh2Ps = cast<Function>(
#if LLVM_VERSION_MAJOR >= 9
JM()->mpCurrentModule->getOrInsertFunction("ConvertFloat16ToFloat32", pFuncTy).getCallee());
#else
JM()->mpCurrentModule->getOrInsertFunction("ConvertFloat16ToFloat32", pFuncTy));
#endif
if (sys::DynamicLibrary::SearchForAddressOfSymbol("ConvertFloat16ToFloat32") == nullptr)
{
@ -658,11 +650,7 @@ namespace SwrJit
// call scalar C function for now
FunctionType* pFuncTy = FunctionType::get(mInt16Ty, mFP32Ty);
Function* pCvtPs2Ph = cast<Function>(
#if LLVM_VERSION_MAJOR >= 9
JM()->mpCurrentModule->getOrInsertFunction("ConvertFloat32ToFloat16", pFuncTy).getCallee());
#else
JM()->mpCurrentModule->getOrInsertFunction("ConvertFloat32ToFloat16", pFuncTy));
#endif
if (sys::DynamicLibrary::SearchForAddressOfSymbol("ConvertFloat32ToFloat16") == nullptr)
{
@ -786,6 +774,14 @@ namespace SwrJit
{
SWR_ASSERT((numIntBits + numFracBits) <= 32, "Can only handle 32-bit fixed-point values");
Value* fixed = nullptr;
#if 0
// This doesn't work for negative numbers!!
{
fixed = FP_TO_SI(VROUND(FMUL(vFloat, VIMMED1(float(1 << numFracBits))),
C(_MM_FROUND_TO_NEAREST_INT)),
mSimdInt32Ty);
}
#else
{
// Do round to nearest int on fractional bits first
// Not entirely perfect for negative numbers, but close enough
@ -808,7 +804,7 @@ namespace SwrJit
fixed = ASHR(vFixed, vExtraBits, name);
}
#endif
return fixed;
}
@ -849,6 +845,7 @@ namespace SwrJit
{
SWR_ASSERT((numIntBits + numFracBits) <= 32, "Can only handle 32-bit fixed-point values");
Value* fixed = nullptr;
#if 1
// KNOB_SIM_FAST_MATH? Below works correctly from a precision
// standpoint...
{
@ -856,6 +853,28 @@ namespace SwrJit
C(_MM_FROUND_TO_NEAREST_INT)),
mSimdInt32Ty);
}
#else
{
// Do round to nearest int on fractional bits first
vFloat = VROUND(FMUL(vFloat, VIMMED1(float(1 << numFracBits))),
C(_MM_FROUND_TO_NEAREST_INT));
vFloat = FMUL(vFloat, VIMMED1(1.0f / float(1 << numFracBits)));
// TODO: Handle INF, NAN, overflow / underflow, etc.
Value* vSgn = FCMP_OLT(vFloat, VIMMED1(0.0f));
Value* vFloatInt = BITCAST(vFloat, mSimdInt32Ty);
Value* vFixed = AND(vFloatInt, VIMMED1((1 << 23) - 1));
vFixed = OR(vFixed, VIMMED1(1 << 23));
Value* vExp = LSHR(SHL(vFloatInt, VIMMED1(1)), VIMMED1(24));
vExp = SUB(vExp, VIMMED1(127));
Value* vExtraBits = SUB(VIMMED1(23 - numFracBits), vExp);
fixed = LSHR(vFixed, vExtraBits, name);
}
#endif
return fixed;
}
@ -940,11 +959,7 @@ namespace SwrJit
FunctionType* pFuncTy = FunctionType::get(Type::getVoidTy(JM()->mContext), args, false);
Function* pFunc = cast<Function>(
#if LLVM_VERSION_MAJOR >= 9
JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StartBucket", pFuncTy).getCallee());
#else
JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StartBucket", pFuncTy));
#endif
if (sys::DynamicLibrary::SearchForAddressOfSymbol("BucketManager_StartBucket") ==
nullptr)
{
@ -969,11 +984,7 @@ namespace SwrJit
FunctionType* pFuncTy = FunctionType::get(Type::getVoidTy(JM()->mContext), args, false);
Function* pFunc = cast<Function>(
#if LLVM_VERSION_MAJOR >=9
JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StopBucket", pFuncTy).getCallee());
#else
JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StopBucket", pFuncTy));
#endif
if (sys::DynamicLibrary::SearchForAddressOfSymbol("BucketManager_StopBucket") ==
nullptr)
{

View file

@ -263,15 +263,12 @@ struct StreamOutJit : public BuilderGfxMem
std::ios_base::in | std::ios_base::out | std::ios_base::ate);
fnName << ComputeCRC(0, &state, sizeof(state));
// SO function signature
// typedef void(__cdecl *PFN_SO_FUNC)(SimDrawContext, SWR_STREAMOUT_CONTEXT*)
Type* typeParam0;
typeParam0 = mInt8PtrTy;
std::vector<Type*> args{
typeParam0,
PointerType::get(Gen_SWR_STREAMOUT_CONTEXT(JM()), 0), // SWR_STREAMOUT_CONTEXT*
typeParam0,
PointerType::get(Gen_SWR_STREAMOUT_CONTEXT(JM()), 0), // SWR_STREAMOUT_CONTEXT*
};
FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false);

View file

@ -25,7 +25,11 @@
* @brief Provide access to tiles table initialization functions
*
******************************************************************************/
#include "memory/InitMemory.h"
#include "memory/LoadTile.h"
#include "memory/StoreTile.h"
#include "InitMemory.h"
void InitSimLoadTilesTable();
void InitSimStoreTilesTable();
@ -37,3 +41,10 @@ void InitTilesTable()
InitSimStoreTilesTable();
InitSimClearTilesTable();
}
void SwrGetTileIterface(SWR_TILE_INTERFACE &out_funcs)
{
out_funcs.pfnSwrLoadHotTile = SwrLoadHotTile;
out_funcs.pfnSwrStoreHotTileToSurface = SwrStoreHotTileToSurface;
}

View file

@ -25,9 +25,57 @@
* @brief Provide access to tiles table initialization functions
*
******************************************************************************/
#pragma once
#include "common/os.h"
#include "memory/SurfaceState.h"
//////////////////////////////////////////////////////////////////////////
/// @brief Loads a full hottile from a render surface
/// @param hPrivateContext - Handle to private DC
/// @param dstFormat - Format for hot tile.
/// @param renderTargetIndex - Index to src render target
/// @param x, y - Coordinates to raster tile.
/// @param pDstHotTile - Pointer to Hot Tile
SWR_FUNC(void,
SwrLoadHotTile,
HANDLE hWorkerPrivateData,
const SWR_SURFACE_STATE* pSrcSurface,
SWR_FORMAT dstFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x,
uint32_t y,
uint32_t renderTargetArrayIndex,
uint8_t* pDstHotTile);
//////////////////////////////////////////////////////////////////////////
/// @brief Deswizzles and stores a full hottile to a render surface
/// @param hPrivateContext - Handle to private DC
/// @param srcFormat - Format for hot tile.
/// @param renderTargetIndex - Index to destination render target
/// @param x, y - Coordinates to raster tile.
/// @param pSrcHotTile - Pointer to Hot Tile
SWR_FUNC(void,
SwrStoreHotTileToSurface,
HANDLE hWorkerPrivateData,
SWR_SURFACE_STATE* pDstSurface,
SWR_FORMAT srcFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x,
uint32_t y,
uint32_t renderTargetArrayIndex,
uint8_t* pSrcHotTile);
struct SWR_TILE_INTERFACE {
PFNSwrLoadHotTile pfnSwrLoadHotTile;
PFNSwrStoreHotTileToSurface pfnSwrStoreHotTileToSurface;
};
extern "C"
{
SWR_VISIBLE void SWR_API InitTilesTable();
typedef void(SWR_API* PFNSwrGetTileInterface)(SWR_TILE_INTERFACE& out_funcs);
SWR_VISIBLE void SWR_API SwrGetTileIterface(SWR_TILE_INTERFACE &out_funcs);
}

View file

@ -336,3 +336,18 @@ static INLINE void InitLoadTileDepthTable(PFN_LOAD_TILES(&table)[NUM_SWR_FORMATS
table[R16_UNORM] = LoadMacroTile<TilingTraits<TTileMode, 16>, R16_UNORM, R32_FLOAT>::Load;
}
//////////////////////////////////////////////////////////////////////////
/// @brief Loads a full hottile from a render surface
/// @param hPrivateContext - Handle to private DC
/// @param dstFormat - Format for hot tile.
/// @param renderTargetIndex - Index to src render target
/// @param x, y - Coordinates to raster tile.
/// @param pDstHotTile - Pointer to Hot Tile
void SwrLoadHotTile(
HANDLE hWorkerPrivateData,
const SWR_SURFACE_STATE *pSrcSurface,
SWR_FORMAT dstFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
uint8_t *pDstHotTile);

View file

@ -35,6 +35,7 @@
#include "memory/TilingFunctions.h"
#include "memory/Convert.h"
#include "memory/SurfaceState.h"
#include "core/multisample.h"
#include <array>
@ -2031,3 +2032,19 @@ void InitStoreTilesTableStencil(
{
table[TTileMode][R8_UINT] = StoreMacroTile<TilingTraits<TTileMode, 8>, R8_UINT, R8_UINT>::Store;
}
//////////////////////////////////////////////////////////////////////////
/// @brief Deswizzles and stores a full hottile to a render surface
/// @param hPrivateContext - Handle to private DC
/// @param srcFormat - Format for hot tile.
/// @param renderTargetIndex - Index to destination render target
/// @param x, y - Coordinates to raster tile.
/// @param pSrcHotTile - Pointer to Hot Tile
void SwrStoreHotTileToSurface(
HANDLE hWorkerPrivateData,
SWR_SURFACE_STATE *pDstSurface,
SWR_FORMAT srcFormat,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
uint8_t *pSrcHotTile);

View file

@ -0,0 +1,66 @@
/****************************************************************************
* Copyright (C) 2014-2019 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 SurfaceState.h
*
* @brief Common definitions for surface state
*
******************************************************************************/
#pragma once
#include "core/state.h"
//////////////////////////////////////////////////////////////////////////
/// SWR_SURFACE_STATE
//////////////////////////////////////////////////////////////////////////
struct SWR_SURFACE_STATE
{
gfxptr_t xpBaseAddress;
SWR_SURFACE_TYPE type; // @llvm_enum
SWR_FORMAT format; // @llvm_enum
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t numSamples;
uint32_t samplePattern;
uint32_t pitch;
uint32_t qpitch;
uint32_t minLod; // for sampled surfaces, the most detailed LOD that can be accessed by sampler
uint32_t maxLod; // for sampled surfaces, the max LOD that can be accessed
float resourceMinLod; // for sampled surfaces, the most detailed fractional mip that can be
// accessed by sampler
uint32_t lod; // for render targets, the lod being rendered to
uint32_t arrayIndex; // for render targets, the array index being rendered to for arrayed surfaces
SWR_TILE_MODE tileMode; // @llvm_enum
uint32_t halign;
uint32_t valign;
uint32_t xOffset;
uint32_t yOffset;
uint32_t lodOffsets[2][15]; // lod offsets for sampled surfaces
gfxptr_t xpAuxBaseAddress; // Used for compression, append/consume counter, etc.
SWR_AUX_MODE auxMode; // @llvm_enum
bool bInterleavedSamples; // are MSAA samples stored interleaved or planar
};

View file

@ -30,6 +30,7 @@
#include "core/state.h"
#include "core/format_traits.h"
#include "memory/tilingtraits.h"
#include "memory/SurfaceState.h"
#include <algorithm>

View file

@ -480,7 +480,9 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
memset(ctx, 0, sizeof(struct swr_context));
swr_screen(p_screen)->pfnSwrGetInterface(ctx->api);
swr_screen(p_screen)->pfnSwrGetTileInterface(ctx->tileApi);
ctx->swrDC.pAPI = &ctx->api;
ctx->swrDC.pTileAPI = &ctx->tileApi;
ctx->blendJIT =
new std::unordered_map<BLEND_COMPILE_STATE, PFN_BLEND_JIT_FUNC>;
@ -492,7 +494,6 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
createInfo.privateStateSize = sizeof(swr_draw_context);
createInfo.pfnLoadTile = swr_LoadHotTile;
createInfo.pfnStoreTile = swr_StoreHotTile;
createInfo.pfnClearTile = swr_StoreHotTileClear;
createInfo.pfnUpdateStats = swr_UpdateStats;
createInfo.pfnUpdateStatsFE = swr_UpdateStatsFE;
createInfo.pfnMakeGfxPtr = swr_MakeGfxPtr;

View file

@ -29,6 +29,8 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_blitter.h"
#include "rasterizer/memory/SurfaceState.h"
#include "rasterizer/memory/InitMemory.h"
#include "jit_api.h"
#include "swr_state.h"
#include <unordered_map>
@ -104,6 +106,7 @@ struct swr_draw_context {
SWR_SURFACE_STATE renderTargets[SWR_NUM_ATTACHMENTS];
struct swr_query_result *pStats; // @llvm_struct
SWR_INTERFACE *pAPI; // @llvm_struct - Needed for the swr_memory callbacks
SWR_TILE_INTERFACE *pTileAPI; // @llvm_struct - Needed for the swr_memory callbacks
};
/* gen_llvm_types FINI */
@ -173,6 +176,7 @@ struct swr_context {
unsigned dirty; /**< Mask of SWR_NEW_x flags */
SWR_INTERFACE api;
SWR_TILE_INTERFACE tileApi;
uint32_t max_draws_in_flight;
};

View file

@ -36,6 +36,7 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
#ifdef HAVE_SWR_BUILTIN
screen->pLibrary = NULL;
screen->pfnSwrGetInterface = SwrGetInterface;
screen->pfnSwrGetInterface = SwrGetTileInterface;
InitTilesTable();
fprintf(stderr, "(using: builtin).\n");
#else
@ -50,9 +51,11 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
util_dl_proc pApiProc = util_dl_get_proc_address(screen->pLibrary,
"SwrGetInterface");
util_dl_proc pTileApiProc = util_dl_get_proc_address(screen->pLibrary,
"SwrGetTileIterface");
util_dl_proc pInitFunc = util_dl_get_proc_address(screen->pLibrary,
"InitTilesTable");
if (!pApiProc || !pInitFunc) {
if (!pApiProc || !pInitFunc || !pTileApiProc) {
fprintf(stderr, "(skipping: %s).\n", util_dl_error());
util_dl_close(screen->pLibrary);
screen->pLibrary = NULL;
@ -60,6 +63,12 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
}
screen->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
screen->pfnSwrGetTileInterface = (PFNSwrGetTileInterface)pTileApiProc;
SWR_ASSERT(screen->pfnSwrGetInterface != nullptr);
SWR_ASSERT(screen->pfnSwrGetTileInterface != nullptr);
SWR_ASSERT(pInitFunc != nullptr);
pInitFunc();
fprintf(stderr, "(using: %s).\n", filename);

View file

@ -35,7 +35,7 @@ swr_LoadHotTile(HANDLE hPrivateContext,
swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
SWR_SURFACE_STATE *pSrcSurface = &pDC->renderTargets[renderTargetIndex];
pDC->pAPI->pfnSwrLoadHotTile(hWorkerPrivateData, pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile);
pDC->pTileAPI->pfnSwrLoadHotTile(hWorkerPrivateData, pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile);
}
INLINE void
@ -50,23 +50,7 @@ swr_StoreHotTile(HANDLE hPrivateContext,
swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex];
pDC->pAPI->pfnSwrStoreHotTileToSurface(hWorkerPrivateData, pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile);
}
INLINE void
swr_StoreHotTileClear(HANDLE hPrivateContext,
HANDLE hWorkerPrivateData,
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
UINT x,
UINT y,
uint32_t renderTargetArrayIndex,
const float* pClearColor)
{
// Grab destination surface state from private context
swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex];
pDC->pAPI->pfnSwrStoreHotTileClear(hWorkerPrivateData, pDstSurface, renderTargetIndex, x, y, renderTargetArrayIndex, pClearColor);
pDC->pTileAPI->pfnSwrStoreHotTileToSurface(hWorkerPrivateData, pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile);
}
INLINE gfxptr_t

View file

@ -24,6 +24,7 @@
#ifndef SWR_RESOURCE_H
#define SWR_RESOURCE_H
#include "memory/SurfaceState.h"
#include "pipe/p_state.h"
#include "api.h"

View file

@ -33,6 +33,7 @@
#include "api.h"
#include "memory/TilingFunctions.h"
#include "memory/InitMemory.h"
struct sw_winsys;
@ -54,6 +55,7 @@ struct swr_screen {
/* Dynamic backend implementations */
util_dl_library *pLibrary;
PFNSwrGetInterface pfnSwrGetInterface;
PFNSwrGetTileInterface pfnSwrGetTileInterface;
/* Do we run on Xeon Phi? */
bool is_knl;

View file

@ -44,6 +44,7 @@
#include "gallivm/lp_bld_tgsi.h"
#include "swr_context.h"
#include "gen_surf_state_llvm.h"
#include "gen_swr_context_llvm.h"
#include "swr_resource.h"
#include "swr_state.h"

View file

@ -45,6 +45,7 @@
#include "swr_state.h"
#include "swr_context.h"
#include "gen_surf_state_llvm.h"
#include "gen_swr_context_llvm.h"
#include "swr_screen.h"
#include "swr_resource.h"

View file

@ -58,6 +58,7 @@
#include "util/u_memory.h"
#include "swr_tex_sample.h"
#include "gen_surf_state_llvm.h"
#include "gen_swr_context_llvm.h"
using namespace SwrJit;