aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp
diff options
context:
space:
mode:
authorAlok Hota <[email protected]>2018-06-05 13:59:53 -0500
committerTim Rowley <[email protected]>2018-06-18 13:57:38 -0500
commita678f40e467bbf72719c60928de26a91f21ac699 (patch)
tree1583ecaf97c287ad3976e4bf77b65a9349b291bc /src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp
parentd85fef1e34657fc082b9a763de9499d324fbeebf (diff)
swr/rast: Clang-Format most rasterizer source code
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp')
-rw-r--r--src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp152
1 files changed, 79 insertions, 73 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp
index cb2e3aed61a..8f86af2a4b4 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp
@@ -1,32 +1,32 @@
/****************************************************************************
-* 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 streamout_jit.cpp
-*
-* @brief Implementation of the streamout jitter
-*
-* Notes:
-*
-******************************************************************************/
+ * 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 streamout_jit.cpp
+ *
+ * @brief Implementation of the streamout jitter
+ *
+ * Notes:
+ *
+ ******************************************************************************/
#include "jit_pch.hpp"
#include "builder.h"
#include "jit_api.h"
@@ -44,13 +44,12 @@ struct StreamOutJit : public Builder
{
StreamOutJit(JitManager* pJitMgr) : Builder(pJitMgr){};
- // returns pointer to SWR_STREAMOUT_BUFFER
+ // returns pointer to SWR_STREAMOUT_BUFFER
Value* getSOBuffer(Value* pSoCtx, uint32_t buffer)
{
- return LOAD(pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_pBuffer, buffer });
+ return LOAD(pSoCtx, {0, SWR_STREAMOUT_CONTEXT_pBuffer, buffer});
}
-
//////////////////////////////////////////////////////////////////////////
// @brief checks if streamout buffer is oob
// @return <i1> true/false
@@ -62,28 +61,27 @@ struct StreamOutJit : public Builder
// load enable
// @todo bool data types should generate <i1> llvm type
- Value* enabled = TRUNC(LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_enable }), IRB()->getInt1Ty());
+ Value* enabled = TRUNC(LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_enable}), IRB()->getInt1Ty());
// load buffer size
- Value* bufferSize = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_bufferSize });
-
+ Value* bufferSize = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_bufferSize});
+
// load current streamOffset
- Value* streamOffset = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_streamOffset });
+ Value* streamOffset = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_streamOffset});
// load buffer pitch
- Value* pitch = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_pitch });
+ Value* pitch = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_pitch});
// buffer is considered oob if in use in a decl but not enabled
returnMask = OR(returnMask, NOT(enabled));
// buffer is oob if cannot fit a prims worth of verts
Value* newOffset = ADD(streamOffset, MUL(pitch, C(state.numVertsPerPrim)));
- returnMask = OR(returnMask, ICMP_SGT(newOffset, bufferSize));
+ returnMask = OR(returnMask, ICMP_SGT(newOffset, bufferSize));
return returnMask;
}
-
//////////////////////////////////////////////////////////////////////////
// @brief converts scalar bitmask to <4 x i32> suitable for shuffle vector,
// packing the active mask bits
@@ -93,8 +91,8 @@ struct StreamOutJit : public Builder
Value* PackMask(uint32_t bitmask)
{
std::vector<Constant*> indices(4, C(0));
- DWORD index;
- uint32_t elem = 0;
+ DWORD index;
+ uint32_t elem = 0;
while (_BitScanForward(&index, bitmask))
{
indices[elem++] = C((int)index);
@@ -133,17 +131,17 @@ struct StreamOutJit : public Builder
void buildDecl(Value* pStream, Value* pOutBuffers[4], const STREAMOUT_DECL& decl)
{
uint32_t numComponents = _mm_popcnt_u32(decl.componentMask);
- uint32_t packedMask = (1 << numComponents) - 1;
+ uint32_t packedMask = (1 << numComponents) - 1;
if (!decl.hole)
{
// increment stream pointer to correct slot
Value* pAttrib = GEP(pStream, C(4 * decl.attribSlot));
// load 4 components from stream
- Type* simd4Ty = VectorType::get(IRB()->getFloatTy(), 4);
+ Type* simd4Ty = VectorType::get(IRB()->getFloatTy(), 4);
Type* simd4PtrTy = PointerType::get(simd4Ty, 0);
- pAttrib = BITCAST(pAttrib, simd4PtrTy);
- Value *vattrib = LOAD(pAttrib);
+ pAttrib = BITCAST(pAttrib, simd4PtrTy);
+ Value* vattrib = LOAD(pAttrib);
// shuffle/pack enabled components
Value* vpackedAttrib = VSHUFFLE(vattrib, vattrib, PackMask(decl.componentMask));
@@ -178,7 +176,11 @@ struct StreamOutJit : public Builder
}
}
- void buildStream(const STREAMOUT_COMPILE_STATE& state, const STREAMOUT_STREAM& streamState, Value* pSoCtx, BasicBlock* returnBB, Function* soFunc)
+ void buildStream(const STREAMOUT_COMPILE_STATE& state,
+ const STREAMOUT_STREAM& streamState,
+ Value* pSoCtx,
+ BasicBlock* returnBB,
+ Function* soFunc)
{
// get list of active SO buffers
std::unordered_set<uint32_t> activeSOBuffers;
@@ -189,9 +191,9 @@ struct StreamOutJit : public Builder
}
// always increment numPrimStorageNeeded
- Value *numPrimStorageNeeded = LOAD(pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_numPrimStorageNeeded });
- numPrimStorageNeeded = ADD(numPrimStorageNeeded, C(1));
- STORE(numPrimStorageNeeded, pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_numPrimStorageNeeded });
+ Value* numPrimStorageNeeded = LOAD(pSoCtx, {0, SWR_STREAMOUT_CONTEXT_numPrimStorageNeeded});
+ numPrimStorageNeeded = ADD(numPrimStorageNeeded, C(1));
+ STORE(numPrimStorageNeeded, pSoCtx, {0, SWR_STREAMOUT_CONTEXT_numPrimStorageNeeded});
// check OOB on active SO buffers. If any buffer is out of bound, don't write
// the primitive to any buffer
@@ -208,27 +210,27 @@ struct StreamOutJit : public Builder
IRB()->SetInsertPoint(validBB);
- Value* numPrimsWritten = LOAD(pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_numPrimsWritten });
- numPrimsWritten = ADD(numPrimsWritten, C(1));
- STORE(numPrimsWritten, pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_numPrimsWritten });
+ Value* numPrimsWritten = LOAD(pSoCtx, {0, SWR_STREAMOUT_CONTEXT_numPrimsWritten});
+ numPrimsWritten = ADD(numPrimsWritten, C(1));
+ STORE(numPrimsWritten, pSoCtx, {0, SWR_STREAMOUT_CONTEXT_numPrimsWritten});
// compute start pointer for each output buffer
Value* pOutBuffer[4];
Value* pOutBufferStartVertex[4];
Value* outBufferPitch[4];
- for (uint32_t b: activeSOBuffers)
+ for (uint32_t b : activeSOBuffers)
{
- Value* pBuf = getSOBuffer(pSoCtx, b);
- Value* pData = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_pBuffer });
- Value* streamOffset = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_streamOffset });
- pOutBuffer[b] = GEP(pData, streamOffset);
+ Value* pBuf = getSOBuffer(pSoCtx, b);
+ Value* pData = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_pBuffer});
+ Value* streamOffset = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_streamOffset});
+ pOutBuffer[b] = GEP(pData, streamOffset);
pOutBufferStartVertex[b] = pOutBuffer[b];
- outBufferPitch[b] = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_pitch });
+ outBufferPitch[b] = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_pitch});
}
// loop over the vertices of the prim
- Value* pStreamData = LOAD(pSoCtx, { 0, SWR_STREAMOUT_CONTEXT_pPrimData });
+ Value* pStreamData = LOAD(pSoCtx, {0, SWR_STREAMOUT_CONTEXT_pPrimData});
for (uint32_t v = 0; v < state.numVertsPerPrim; ++v)
{
buildVertex(streamState, pStreamData, pOutBuffer);
@@ -241,23 +243,24 @@ struct StreamOutJit : public Builder
for (uint32_t b : activeSOBuffers)
{
pOutBufferStartVertex[b] = GEP(pOutBufferStartVertex[b], outBufferPitch[b]);
- pOutBuffer[b] = pOutBufferStartVertex[b];
+ pOutBuffer[b] = pOutBufferStartVertex[b];
}
}
// update each active buffer's streamOffset
for (uint32_t b : activeSOBuffers)
{
- Value* pBuf = getSOBuffer(pSoCtx, b);
- Value* streamOffset = LOAD(pBuf, { 0, SWR_STREAMOUT_BUFFER_streamOffset });
+ Value* pBuf = getSOBuffer(pSoCtx, b);
+ Value* streamOffset = LOAD(pBuf, {0, SWR_STREAMOUT_BUFFER_streamOffset});
streamOffset = ADD(streamOffset, MUL(C(state.numVertsPerPrim), outBufferPitch[b]));
- STORE(streamOffset, pBuf, { 0, SWR_STREAMOUT_BUFFER_streamOffset });
+ STORE(streamOffset, pBuf, {0, SWR_STREAMOUT_BUFFER_streamOffset});
}
}
Function* Create(const STREAMOUT_COMPILE_STATE& state)
{
- std::stringstream fnName("SO_", std::ios_base::in | std::ios_base::out | std::ios_base::ate);
+ std::stringstream fnName("SO_",
+ std::ios_base::in | std::ios_base::out | std::ios_base::ate);
fnName << ComputeCRC(0, &state, sizeof(state));
// SO function signature
@@ -267,19 +270,20 @@ struct StreamOutJit : public Builder
PointerType::get(Gen_SWR_STREAMOUT_CONTEXT(JM()), 0), // SWR_STREAMOUT_CONTEXT*
};
- FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false);
- Function* soFunc = Function::Create(fTy, GlobalValue::ExternalLinkage, fnName.str(), JM()->mpCurrentModule);
+ FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false);
+ Function* soFunc = Function::Create(
+ fTy, GlobalValue::ExternalLinkage, fnName.str(), JM()->mpCurrentModule);
soFunc->getParent()->setModuleIdentifier(soFunc->getName());
// create return basic block
- BasicBlock* entry = BasicBlock::Create(JM()->mContext, "entry", soFunc);
+ BasicBlock* entry = BasicBlock::Create(JM()->mContext, "entry", soFunc);
BasicBlock* returnBB = BasicBlock::Create(JM()->mContext, "return", soFunc);
IRB()->SetInsertPoint(entry);
// arguments
- auto argitr = soFunc->arg_begin();
+ auto argitr = soFunc->arg_begin();
Value* pSoCtx = &*argitr++;
pSoCtx->setName("pSoCtx");
@@ -325,11 +329,12 @@ struct StreamOutJit : public Builder
/// @return PFN_SO_FUNC - pointer to SOS function
PFN_SO_FUNC JitStreamoutFunc(HANDLE hJitMgr, const HANDLE hFunc)
{
- llvm::Function *func = (llvm::Function*)hFunc;
- JitManager* pJitMgr = reinterpret_cast<JitManager*>(hJitMgr);
- PFN_SO_FUNC pfnStreamOut;
+ llvm::Function* func = (llvm::Function*)hFunc;
+ JitManager* pJitMgr = reinterpret_cast<JitManager*>(hJitMgr);
+ PFN_SO_FUNC pfnStreamOut;
pfnStreamOut = (PFN_SO_FUNC)(pJitMgr->mpExec->getFunctionAddress(func->getName().str()));
- // MCJIT finalizes modules the first time you JIT code from them. After finalized, you cannot add new IR to the module
+ // MCJIT finalizes modules the first time you JIT code from them. After finalized, you cannot
+ // add new IR to the module
pJitMgr->mIsModuleFinalized = true;
pJitMgr->DumpAsm(func, "SoFunc_optimized");
@@ -342,7 +347,8 @@ PFN_SO_FUNC JitStreamoutFunc(HANDLE hJitMgr, const HANDLE hFunc)
/// @brief JIT compiles streamout shader
/// @param hJitMgr - JitManager handle
/// @param state - SO state to build function from
-extern "C" PFN_SO_FUNC JITCALL JitCompileStreamout(HANDLE hJitMgr, const STREAMOUT_COMPILE_STATE& state)
+extern "C" PFN_SO_FUNC JITCALL JitCompileStreamout(HANDLE hJitMgr,
+ const STREAMOUT_COMPILE_STATE& state)
{
JitManager* pJitMgr = reinterpret_cast<JitManager*>(hJitMgr);
@@ -358,7 +364,7 @@ extern "C" PFN_SO_FUNC JITCALL JitCompileStreamout(HANDLE hJitMgr, const STREAMO
pJitMgr->SetupNewModule();
StreamOutJit theJit(pJitMgr);
- HANDLE hFunc = theJit.Create(soState);
+ HANDLE hFunc = theJit.Create(soState);
return JitStreamoutFunc(hJitMgr, hFunc);
}