Add 16bit indices support for Raycast + add alignment
This commit is contained in:
@@ -185,12 +185,30 @@ public:
|
|||||||
|
|
||||||
// spu_printf("processNode with triangleIndex %d\n",triangleIndex);
|
// spu_printf("processNode with triangleIndex %d\n",triangleIndex);
|
||||||
|
|
||||||
|
// ugly solution to support both 16bit and 32bit indices
|
||||||
|
if (m_lsMemPtr->bvhShapeData.gIndexMesh.m_indexType == PHY_SHORT)
|
||||||
|
{
|
||||||
|
short int* indexBasePtr = (short int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
||||||
|
ATTRIBUTE_ALIGNED16(short int tmpIndices[3]);
|
||||||
|
|
||||||
|
small_cache_read_triple(&tmpIndices[0],(ppu_address_t)&indexBasePtr[0],
|
||||||
|
&tmpIndices[1],(ppu_address_t)&indexBasePtr[1],
|
||||||
|
&tmpIndices[2],(ppu_address_t)&indexBasePtr[2],
|
||||||
|
sizeof(short int));
|
||||||
|
|
||||||
|
m_lsMemPtr->spuIndices[0] = int(tmpIndices[0]);
|
||||||
|
m_lsMemPtr->spuIndices[1] = int(tmpIndices[1]);
|
||||||
|
m_lsMemPtr->spuIndices[2] = int(tmpIndices[2]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
int* indexBasePtr = (int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
int* indexBasePtr = (int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride);
|
||||||
|
|
||||||
small_cache_read_triple(&m_lsMemPtr->spuIndices[0],(ppu_address_t)&indexBasePtr[0],
|
small_cache_read_triple(&m_lsMemPtr->spuIndices[0],(ppu_address_t)&indexBasePtr[0],
|
||||||
&m_lsMemPtr->spuIndices[1],(ppu_address_t)&indexBasePtr[1],
|
&m_lsMemPtr->spuIndices[1],(ppu_address_t)&indexBasePtr[1],
|
||||||
&m_lsMemPtr->spuIndices[2],(ppu_address_t)&indexBasePtr[2],
|
&m_lsMemPtr->spuIndices[2],(ppu_address_t)&indexBasePtr[2],
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
//printf("%d %d %d\n", m_lsMemPtr->spuIndices[0], m_lsMemPtr->spuIndices[1], m_lsMemPtr->spuIndices[2]);
|
//printf("%d %d %d\n", m_lsMemPtr->spuIndices[0], m_lsMemPtr->spuIndices[1], m_lsMemPtr->spuIndices[2]);
|
||||||
// spu_printf("SPU index0=%d ,",spuIndices[0]);
|
// spu_printf("SPU index0=%d ,",spuIndices[0]);
|
||||||
// spu_printf("SPU index1=%d ,",spuIndices[1]);
|
// spu_printf("SPU index1=%d ,",spuIndices[1]);
|
||||||
@@ -379,6 +397,7 @@ void performRaycastAgainstConcave (RaycastGatheredObjectData* gatheredObjectData
|
|||||||
|
|
||||||
// spu_printf("nextBatch = %d\n",nextBatch);
|
// spu_printf("nextBatch = %d\n",nextBatch);
|
||||||
|
|
||||||
|
|
||||||
for (int j=0;j<nextBatch;j++)
|
for (int j=0;j<nextBatch;j++)
|
||||||
{
|
{
|
||||||
const btBvhSubtreeInfo& subtree = lsMemPtr->bvhShapeData.gSubtreeHeaders[j];
|
const btBvhSubtreeInfo& subtree = lsMemPtr->bvhShapeData.gSubtreeHeaders[j];
|
||||||
@@ -394,11 +413,14 @@ void performRaycastAgainstConcave (RaycastGatheredObjectData* gatheredObjectData
|
|||||||
cellDmaWaitTagStatusAll(DMA_MASK(2));
|
cellDmaWaitTagStatusAll(DMA_MASK(2));
|
||||||
|
|
||||||
/* Walk this subtree */
|
/* Walk this subtree */
|
||||||
|
|
||||||
|
{
|
||||||
spuWalkStacklessQuantizedTreeAgainstRay(lsMemPtr, &nodeCallback,rayFromInTriangleSpace, rayToInTriangleSpace, quantizedQueryAabbMin,quantizedQueryAabbMax,
|
spuWalkStacklessQuantizedTreeAgainstRay(lsMemPtr, &nodeCallback,rayFromInTriangleSpace, rayToInTriangleSpace, quantizedQueryAabbMin,quantizedQueryAabbMax,
|
||||||
&lsMemPtr->bvhShapeData.gSubtreeNodes[0],
|
&lsMemPtr->bvhShapeData.gSubtreeNodes[0],
|
||||||
0,
|
0,
|
||||||
subtree.m_subtreeSize);
|
subtree.m_subtreeSize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// spu_printf("subtreeSize = %d\n",gSubtreeHeaders[j].m_subtreeSize);
|
// spu_printf("subtreeSize = %d\n",gSubtreeHeaders[j].m_subtreeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,10 +506,12 @@ void processRaycastTask(void* userPtr, void* lsMemory)
|
|||||||
SpuRaycastTaskWorkUnitOut tWorkUnitOut;
|
SpuRaycastTaskWorkUnitOut tWorkUnitOut;
|
||||||
tWorkUnitOut.hitFraction = 1.0;
|
tWorkUnitOut.hitFraction = 1.0;
|
||||||
|
|
||||||
|
|
||||||
if (btBroadphaseProxy::isConvex (gatheredObjectData.m_shapeType))
|
if (btBroadphaseProxy::isConvex (gatheredObjectData.m_shapeType))
|
||||||
{
|
{
|
||||||
performRaycastAgainstConvex (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
performRaycastAgainstConvex (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
||||||
} else if (btBroadphaseProxy::isCompound (gatheredObjectData.m_shapeType)) {
|
}
|
||||||
|
else if (btBroadphaseProxy::isCompound (gatheredObjectData.m_shapeType)) {
|
||||||
performRaycastAgainstCompound (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
performRaycastAgainstCompound (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
||||||
} else if (btBroadphaseProxy::isConcave (gatheredObjectData.m_shapeType)) {
|
} else if (btBroadphaseProxy::isConcave (gatheredObjectData.m_shapeType)) {
|
||||||
performRaycastAgainstConcave (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
performRaycastAgainstConcave (&gatheredObjectData, workUnit, &tWorkUnitOut, localMemory);
|
||||||
@@ -503,6 +527,8 @@ void processRaycastTask(void* userPtr, void* lsMemory)
|
|||||||
/* write ray cast data back */
|
/* write ray cast data back */
|
||||||
dmaStoreRayOutput ((ppu_address_t)workUnit.output, &workUnitOut, 1);
|
dmaStoreRayOutput ((ppu_address_t)workUnit.output, &workUnitOut, 1);
|
||||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
#include "../PlatformDefinitions.h"
|
#include "../PlatformDefinitions.h"
|
||||||
|
|
||||||
struct RaycastGatheredObjectData
|
ATTRIBUTE_ALIGNED16(struct) RaycastGatheredObjectData
|
||||||
{
|
{
|
||||||
ppu_address_t m_collisionShape;
|
ppu_address_t m_collisionShape;
|
||||||
void* m_spuCollisionShape;
|
void* m_spuCollisionShape;
|
||||||
@@ -33,7 +33,7 @@ ATTRIBUTE_ALIGNED16(struct) SpuRaycastTaskWorkUnit
|
|||||||
|
|
||||||
#define SPU_RAYCAST_WORK_UNITS_PER_TASK 4
|
#define SPU_RAYCAST_WORK_UNITS_PER_TASK 4
|
||||||
|
|
||||||
struct SpuRaycastTaskDesc
|
ATTRIBUTE_ALIGNED128(struct) SpuRaycastTaskDesc
|
||||||
{
|
{
|
||||||
SpuRaycastTaskWorkUnit workUnits[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
SpuRaycastTaskWorkUnit workUnits[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||||
int numWorkUnits;
|
int numWorkUnits;
|
||||||
|
|||||||
Reference in New Issue
Block a user