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>
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',
'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(
'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')
--- /dev/null
+---
+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
+...
]
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]],
%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:
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
out_funcs.pfnSwrEnableStatsBE = SwrEnableStatsBE;
out_funcs.pfnSwrEndFrame = SwrEndFrame;
out_funcs.pfnSwrInit = SwrInit;
- out_funcs.pfnSwrLoadHotTile = SwrLoadHotTile;
- out_funcs.pfnSwrStoreHotTileToSurface = SwrStoreHotTileToSurface;
- out_funcs.pfnSwrStoreHotTileClear = SwrStoreHotTileClear;
}
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.
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.
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;
PFNSwrEnableStatsBE pfnSwrEnableStatsBE;
PFNSwrEndFrame pfnSwrEndFrame;
PFNSwrInit pfnSwrInit;
- PFNSwrLoadHotTile pfnSwrLoadHotTile;
- PFNSwrStoreHotTileToSurface pfnSwrStoreHotTileToSurface;
- PFNSwrStoreHotTileClear pfnSwrStoreHotTileClear;
};
extern "C" {
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
- psContext.alternateOffset = useAlternateOffset ? 1 : 0;
simdscalar activeLanes;
if (!(work.anyCoveredSamples & MASK))
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
- psContext.alternateOffset = useAlternateOffset ? 1 : 0;
if (T::InputCoverage != SWR_INPUT_COVERAGE_NONE)
{
{
const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0);
- psContext.alternateOffset = useAlternateOffset ? 1 : 0;
simdmask coverageMask = work.coverageMask[0] & MASK;
// 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;
}
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);
}
}
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);
}
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.
};
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
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)
{
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)
{
// 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)
{
{
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
fixed = ASHR(vFixed, vExtraBits, name);
}
-
+#endif
return fixed;
}
{
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...
{
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;
}
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)
{
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)
{
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);
* @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();
InitSimStoreTilesTable();
InitSimClearTilesTable();
}
+
+
+void SwrGetTileIterface(SWR_TILE_INTERFACE &out_funcs)
+{
+ out_funcs.pfnSwrLoadHotTile = SwrLoadHotTile;
+ out_funcs.pfnSwrStoreHotTileToSurface = SwrStoreHotTileToSurface;
+}
\ No newline at end of file
* @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);
}
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);
\ No newline at end of file
#include "memory/TilingFunctions.h"
#include "memory/Convert.h"
+#include "memory/SurfaceState.h"
#include "core/multisample.h"
#include <array>
{
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);
\ No newline at end of file
--- /dev/null
+/****************************************************************************
+* 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
+};
\ No newline at end of file
#include "core/state.h"
#include "core/format_traits.h"
#include "memory/tilingtraits.h"
+#include "memory/SurfaceState.h"
#include <algorithm>
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>;
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;
#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>
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 */
unsigned dirty; /**< Mask of SWR_NEW_x flags */
SWR_INTERFACE api;
+ SWR_TILE_INTERFACE tileApi;
uint32_t max_draws_in_flight;
};
#ifdef HAVE_SWR_BUILTIN
screen->pLibrary = NULL;
screen->pfnSwrGetInterface = SwrGetInterface;
+ screen->pfnSwrGetInterface = SwrGetTileInterface;
InitTilesTable();
fprintf(stderr, "(using: builtin).\n");
#else
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;
}
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);
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
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
#ifndef SWR_RESOURCE_H
#define SWR_RESOURCE_H
+#include "memory/SurfaceState.h"
#include "pipe/p_state.h"
#include "api.h"
#include "api.h"
#include "memory/TilingFunctions.h"
+#include "memory/InitMemory.h"
struct sw_winsys;
/* Dynamic backend implementations */
util_dl_library *pLibrary;
PFNSwrGetInterface pfnSwrGetInterface;
+ PFNSwrGetTileInterface pfnSwrGetTileInterface;
/* Do we run on Xeon Phi? */
bool is_knl;
#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"
#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"
#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;