Change viewport matrix storage from AOS to SOA to support viewport arrays.
Signed-off-by: Tim Rowley <timothy.o.rowley@intel.com>
HANDLE hContext,
uint32_t numViewports,
const SWR_VIEWPORT* pViewports,
- const SWR_VIEWPORT_MATRIX* pMatrices)
+ const SWR_VIEWPORT_MATRICES* pMatrices)
{
SWR_ASSERT(numViewports <= KNOB_NUM_VIEWPORTS_SCISSORS,
"Invalid number of viewports.");
if (pMatrices != nullptr)
{
- memcpy(&pState->vpMatrix[0], pMatrices, sizeof(SWR_VIEWPORT_MATRIX) * numViewports);
+ //memcpy(&pState->vpMatrix[0], pMatrices, sizeof(SWR_VIEWPORT_MATRIX) * numViewports);
+ // @todo Faster to copy portions of the SOA or just copy all of it?
+ memcpy(&pState->vpMatrices, pMatrices, sizeof(SWR_VIEWPORT_MATRICES));
}
else
{
{
if (pContext->driverType == DX)
{
- pState->vpMatrix[i].m00 = pState->vp[i].width / 2.0f;
- pState->vpMatrix[i].m11 = -pState->vp[i].height / 2.0f;
- pState->vpMatrix[i].m22 = pState->vp[i].maxZ - pState->vp[i].minZ;
- pState->vpMatrix[i].m30 = pState->vp[i].x + pState->vpMatrix[i].m00;
- pState->vpMatrix[i].m31 = pState->vp[i].y - pState->vpMatrix[i].m11;
- pState->vpMatrix[i].m32 = pState->vp[i].minZ;
+ pState->vpMatrices.m00[i] = pState->vp[i].width / 2.0f;
+ pState->vpMatrices.m11[i] = -pState->vp[i].height / 2.0f;
+ pState->vpMatrices.m22[i] = pState->vp[i].maxZ - pState->vp[i].minZ;
+ pState->vpMatrices.m30[i] = pState->vp[i].x + pState->vpMatrices.m00[i];
+ pState->vpMatrices.m31[i] = pState->vp[i].y - pState->vpMatrices.m11[i];
+ pState->vpMatrices.m32[i] = pState->vp[i].minZ;
}
else
{
// Standard, with the exception that Y is inverted.
- pState->vpMatrix[i].m00 = (pState->vp[i].width - pState->vp[i].x) / 2.0f;
- pState->vpMatrix[i].m11 = (pState->vp[i].y - pState->vp[i].height) / 2.0f;
- pState->vpMatrix[i].m22 = (pState->vp[i].maxZ - pState->vp[i].minZ) / 2.0f;
- pState->vpMatrix[i].m30 = pState->vp[i].x + pState->vpMatrix[i].m00;
- pState->vpMatrix[i].m31 = pState->vp[i].height + pState->vpMatrix[i].m11;
- pState->vpMatrix[i].m32 = pState->vp[i].minZ + pState->vpMatrix[i].m22;
+ pState->vpMatrices.m00[i] = (pState->vp[i].width - pState->vp[i].x) / 2.0f;
+ pState->vpMatrices.m11[i] = (pState->vp[i].y - pState->vp[i].height) / 2.0f;
+ pState->vpMatrices.m22[i] = (pState->vp[i].maxZ - pState->vp[i].minZ) / 2.0f;
+ pState->vpMatrices.m30[i] = pState->vp[i].x + pState->vpMatrices.m00[i];
+ pState->vpMatrices.m31[i] = pState->vp[i].height + pState->vpMatrices.m11[i];
+ pState->vpMatrices.m32[i] = pState->vp[i].minZ + pState->vpMatrices.m22[i];
// Now that the matrix is calculated, clip the view coords to screen size.
// OpenGL allows for -ve x,y in the viewport.
HANDLE hContext,
uint32_t numViewports,
const SWR_VIEWPORT* pViewports,
- const SWR_VIEWPORT_MATRIX* pMatrices);
+ const SWR_VIEWPORT_MATRICES* pMatrices);
//////////////////////////////////////////////////////////////////////////
/// @brief SwrSetScissorRects
GUARDBAND gbState;
SWR_VIEWPORT vp[KNOB_NUM_VIEWPORTS_SCISSORS];
- SWR_VIEWPORT_MATRIX vpMatrix[KNOB_NUM_VIEWPORTS_SCISSORS];
+ SWR_VIEWPORT_MATRICES vpMatrices;
BBOX scissorRects[KNOB_NUM_VIEWPORTS_SCISSORS];
BBOX scissorInFixedPoint;
tri[2].v[2] = _simd_mul_ps(tri[2].v[2], vRecipW2);
// viewport transform to screen coords
- viewportTransform<3>(tri, state.vpMatrix[0]);
+ viewportTransform<3>(tri, state.vpMatrices);
}
// adjust for pixel center location
primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0);
// viewport transform to screen coords
- viewportTransform<1>(&primVerts, state.vpMatrix[0]);
+ viewportTransform<1>(&primVerts, state.vpMatrices);
}
// adjust for pixel center location
prim[1].v[2] = _simd_mul_ps(prim[1].v[2], vRecipW1);
// viewport transform to screen coords
- viewportTransform<2>(prim, state.vpMatrix[0]);
+ viewportTransform<2>(prim, state.vpMatrices);
}
// adjust for pixel center location
template<uint32_t NumVerts>
INLINE
-void viewportTransform(simdvector *v, const SWR_VIEWPORT_MATRIX & vpMatrix)
+void viewportTransform(simdvector *v, const SWR_VIEWPORT_MATRICES & vpMatrices)
{
- simdscalar m00 = _simd_load1_ps(&vpMatrix.m00);
- simdscalar m30 = _simd_load1_ps(&vpMatrix.m30);
- simdscalar m11 = _simd_load1_ps(&vpMatrix.m11);
- simdscalar m31 = _simd_load1_ps(&vpMatrix.m31);
- simdscalar m22 = _simd_load1_ps(&vpMatrix.m22);
- simdscalar m32 = _simd_load1_ps(&vpMatrix.m32);
+ simdscalar m00 = _simd_load1_ps(&vpMatrices.m00[0]);
+ simdscalar m30 = _simd_load1_ps(&vpMatrices.m30[0]);
+ simdscalar m11 = _simd_load1_ps(&vpMatrices.m11[0]);
+ simdscalar m31 = _simd_load1_ps(&vpMatrices.m31[0]);
+ simdscalar m22 = _simd_load1_ps(&vpMatrices.m22[0]);
+ simdscalar m32 = _simd_load1_ps(&vpMatrices.m32[0]);
for (uint32_t i = 0; i < NumVerts; ++i)
{
float m32;
};
+//////////////////////////////////////////////////////////////////////////
+/// VIEWPORT_MATRIXES
+/////////////////////////////////////////////////////////////////////////
+struct SWR_VIEWPORT_MATRICES
+{
+ float m00[KNOB_NUM_VIEWPORTS_SCISSORS];
+ float m11[KNOB_NUM_VIEWPORTS_SCISSORS];
+ float m22[KNOB_NUM_VIEWPORTS_SCISSORS];
+ float m30[KNOB_NUM_VIEWPORTS_SCISSORS];
+ float m31[KNOB_NUM_VIEWPORTS_SCISSORS];
+ float m32[KNOB_NUM_VIEWPORTS_SCISSORS];
+};
+
//////////////////////////////////////////////////////////////////////////
/// SWR_VIEWPORT
/////////////////////////////////////////////////////////////////////////
pipe_rasterizer_state *rasterizer = ctx->rasterizer;
SWR_VIEWPORT *vp = &ctx->derived.vp;
- SWR_VIEWPORT_MATRIX *vpm = &ctx->derived.vpm;
+ SWR_VIEWPORT_MATRICES *vpm = &ctx->derived.vpm;
vp->x = state->translate[0] - state->scale[0];
vp->width = state->translate[0] + state->scale[0];
vp->maxZ = state->translate[2] + state->scale[2];
}
- vpm->m00 = state->scale[0];
- vpm->m11 = state->scale[1];
- vpm->m22 = state->scale[2];
- vpm->m30 = state->translate[0];
- vpm->m31 = state->translate[1];
- vpm->m32 = state->translate[2];
+ vpm->m00[0] = state->scale[0];
+ vpm->m11[0] = state->scale[1];
+ vpm->m22[0] = state->scale[2];
+ vpm->m30[0] = state->translate[0];
+ vpm->m31[0] = state->translate[1];
+ vpm->m32[0] = state->translate[2];
/* Now that the matrix is calculated, clip the view coords to screen
* size. OpenGL allows for -ve x,y in the viewport. */
struct swr_derived_state {
SWR_RASTSTATE rastState;
SWR_VIEWPORT vp;
- SWR_VIEWPORT_MATRIX vpm;
+ SWR_VIEWPORT_MATRICES vpm;
};
void swr_update_derived(struct pipe_context *,