swr/rast: Handle instanceID offset / Instance Stride enable

Supported in JitGatherVertices(); FetchJit::JitLoadVertices() may require
similar changes, will need address this if it is determined that this
path is still in use.

Handle Force Sequential Access in FetchJit::Create.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
Tim Rowley 2017-09-20 11:50:32 -05:00
parent 68d8dd1fb5
commit 5a2bca5db5
1 changed files with 39 additions and 7 deletions

View File

@ -222,6 +222,18 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& fetchState)
default: SWR_INVALID("Unsupported index type"); vIndices = nullptr; break;
}
if(fetchState.bForceSequentialAccessEnable)
{
Value* pOffsets = C({ 0, 1, 2, 3, 4, 5, 6, 7 });
// VertexData buffers are accessed sequentially, the index is equal to the vertex number
vIndices = VBROADCAST(LOAD(mpFetchInfo, { 0, SWR_FETCH_CONTEXT_StartVertex }));
vIndices = ADD(vIndices, pOffsets);
#if USE_SIMD16_SHADERS
vIndices2 = ADD(vIndices, VIMMED1(8));
#endif
}
Value* vVertexId = vIndices;
#if USE_SIMD16_SHADERS
Value* vVertexId2 = vIndices2;
@ -275,12 +287,6 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& fetchState)
: JitGatherVertices(fetchState, streams, vIndices, pVtxOut);
#endif
if (fetchState.bInstanceIDOffsetEnable)
{
// TODO:
SWR_ASSERT((0), "Add support for handling InstanceID Offset Enable.");
}
RET_VOID();
JitManager::DumpToFile(fetch, "src");
@ -362,6 +368,11 @@ void FetchJit::JitLoadVertices(const FETCH_COMPILE_STATE &fetchState, Value* str
vectors.clear();
if (fetchState.bInstanceIDOffsetEnable)
{
SWR_ASSERT((0), "TODO: Fill out more once driver sends this down");
}
Value *vCurIndices;
Value *startOffset;
if(ied.InstanceEnable)
@ -831,8 +842,16 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE &fetchState,
minVertex = LOAD(minVertex);
}
if (fetchState.bInstanceIDOffsetEnable)
{
// the InstanceID (curInstance) value is offset by StartInstanceLocation
curInstance = ADD(curInstance, startInstance);
}
Value *vCurIndices;
Value *startOffset;
Value *vInstanceStride = VIMMED1(0);
if(ied.InstanceEnable)
{
Value* stepRate = C(ied.InstanceAdvancementState);
@ -853,11 +872,19 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE &fetchState,
}
else if (ied.InstanceStrideEnable)
{
// grab the instance advancement state, determines stride in bytes from one instance to the next
Value* stepRate = C(ied.InstanceAdvancementState);
vInstanceStride = VBROADCAST(MUL(curInstance, stepRate));
// offset indices by baseVertex
vCurIndices = ADD(vIndices, vBaseVertex);
startOffset = startVertex;
SWR_ASSERT((0), "TODO: Fill out more once driver sends this down.");
}
else
{
// offset indices by baseVertex
// offset indices by baseVertex
vCurIndices = ADD(vIndices, vBaseVertex);
startOffset = startVertex;
@ -925,6 +952,11 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE &fetchState,
Value* vOffsets = MUL(vCurIndices, vStride);
vOffsets = ADD(vOffsets, vAlignmentOffsets);
// if instance stride enable is:
// true - add product of the instanceID and advancement state to the offst into the VB
// false - value of vInstanceStride has been initialialized to zero
vOffsets = ADD(vOffsets, vInstanceStride);
// Packing and component control
ComponentEnable compMask = (ComponentEnable)ied.ComponentPacking;
const ComponentControl compCtrl[4] { (ComponentControl)ied.ComponentControl0, (ComponentControl)ied.ComponentControl1,