2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 18:27:42 +00:00

SIMD refactor

This commit is contained in:
Jack Andersen
2018-12-07 15:49:15 -10:00
parent e1fa938127
commit 7c7da6671a
201 changed files with 2475 additions and 1906 deletions

View File

@@ -39,45 +39,45 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb)
{
zeus::CVector3f vboData[] =
{
{aabb.max.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.min.z},
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
};
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);

View File

@@ -64,10 +64,10 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect)
{
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y * 2.f;
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y * 2.f - 1.f;
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
@@ -85,7 +85,7 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t)
delta /= float(g_Viewport.xc_height);
zeus::CRectangle rect(0.f, 0.f, 1.f, delta);
m_bottom.draw(color, rect);
rect.position.y = 1.f - delta;
rect.position.y() = 1.f - delta;
m_top.draw(color, rect);
}
}

View File

@@ -26,7 +26,7 @@ void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& c
auto iBufInfo = grid.m_instBuf.getBufferInfo();
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {uBufInfo.first.get(),
fxMgr.m_fogUniformBuf.get()};
size_t ubufOffsets[] = {uBufInfo.second, 0};
size_t ubufOffsets[] = {size_t(uBufInfo.second), 0};
size_t ubufSizes[] = {sizeof(CEnvFxShaders::Uniform), sizeof(CGraphics::g_Fog)};
boo::PipelineStage uniformStages[] = {boo::PipelineStage::Vertex, boo::PipelineStage::Fragment};
boo::ObjToken<boo::ITexture> textures[] = {fxMgr.xb74_txtrSnowFlake->GetBooTexture(),

View File

@@ -264,23 +264,23 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info,
continue;
}
zeus::CVector3f localPos = ripple.GetCenter() - waterCenter;
rOut.center.x = localPos.x;
rOut.center.y = localPos.y;
rOut.center.z = ripple.GetTime() * ripple.GetOOTimeFalloff();
rOut.center.w = ripple.GetOODistanceFalloff();
rOut.params.x = ripple.GetAmplitude();
rOut.params.y = ripple.GetPhase();
rOut.params.z = (1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() *
ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
rOut.center.x() = float(localPos.x());
rOut.center.y() = float(localPos.y());
rOut.center.z() = ripple.GetTime() * ripple.GetOOTimeFalloff();
rOut.center.w() = ripple.GetOODistanceFalloff();
rOut.params.x() = ripple.GetAmplitude();
rOut.params.y() = ripple.GetPhase();
rOut.params.z() = (1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() *
ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
}
uni.m_colorMul = colorMul;
uni.m_pad[0].x = rippleNormResolution;
uni.m_pad[0].x() = rippleNormResolution;
uni.m_lighting.ActivateLights(info.lights);
for (i=0 ; i<3 ; ++i)
uni.m_lighting.colorRegs[i] = info.kColors[i];
uni.m_lighting.mulColor = info.kColors[3];
uni.m_lighting.fog = CGraphics::g_Fog;
uni.m_pad2.x = info.indScale;
uni.m_pad2.x() = info.indScale;
m_uniBuf->unmap();
}

View File

@@ -35,8 +35,8 @@ void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& c
vec.normalize();
vec *= zeus::CVector2f(std::sqrt(mag));
}
data[y][x][0] = zeus::clamp(0, int((((vec.x / 2.f + 0.5f) - x / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
data[y][x][1] = zeus::clamp(0, int((((vec.y / 2.f + 0.5f) - y / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
data[y][x][0] = zeus::clamp(0, int((((vec.x() / 2.f + 0.5f) - x / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
data[y][x][1] = zeus::clamp(0, int((((vec.y() / 2.f + 0.5f) - y / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
}
}
m_warpTex = ctx.newStaticTexture(WARP_RAMP_RES+1, WARP_RAMP_RES+1, 1,
@@ -132,14 +132,14 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
/* Transform UV coordinates of rectangle within viewport and sampled scene texels (clamped to viewport bounds) */
zeus::CVector2f vp{float(CGraphics::g_CroppedViewport.xc_width), float(CGraphics::g_CroppedViewport.x10_height)};
m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x;
m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y;
m_uniform.m_matrix[3][0] = pt.x + (1.f / vp.x);
m_uniform.m_matrix[3][1] = pt.y + (1.f / vp.y);
m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x();
m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y();
m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x());
m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y());
if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL)
m_uniform.m_matrix[3][2] = pt.z * 2.f - 1.f;
m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f;
else
m_uniform.m_matrix[3][2] = pt.z;
m_uniform.m_matrix[3][2] = pt.z();
if (clipRect.x4_left)
{
@@ -161,9 +161,9 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top;
CGraphics::ResolveSpareTexture(clipRect);
m_uniform.m_strength.x = m_uniform.m_matrix[0][0] * m_strength * 0.5f *
(clipRect.x10_height / float(clipRect.xc_width));
m_uniform.m_strength.y = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
m_uniform.m_strength.x() = m_uniform.m_matrix[0][0] * m_strength * 0.5f *
(clipRect.x10_height / float(clipRect.xc_width));
m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
CGraphics::SetShaderDataBinding(m_dataBind);

View File

@@ -66,22 +66,22 @@ void CTextSupportShader::ImageInstance::SetMetrics(const CFontImageDef& imgDef,
if (imgDef.x4_texs.size())
{
const CTexture& tex = *imgDef.x4_texs[0].GetObj();
imgSize.assign(tex.GetWidth() * imgDef.x14_cropFactor.x,
tex.GetHeight() * imgDef.x14_cropFactor.y);
imgSize.assign(tex.GetWidth() * imgDef.x14_cropFactor.x(),
tex.GetHeight() * imgDef.x14_cropFactor.y());
}
zeus::CVector2f cropPad = imgDef.x14_cropFactor * 0.5f;
m_pos[0].assign(offset.x, 0.f, offset.y);
m_uv[0].assign(0.5f - cropPad.x, 0.5f + cropPad.y);
m_uv[0].assign(0.5f - cropPad.x(), 0.5f + cropPad.y());
m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y);
m_uv[1].assign(0.5f + cropPad.x, 0.5f + cropPad.y);
m_pos[1].assign(offset.x + imgSize.x(), 0.f, offset.y);
m_uv[1].assign(0.5f + cropPad.x(), 0.5f + cropPad.y());
m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y);
m_uv[2].assign(0.5f - cropPad.x, 0.5f - cropPad.y);
m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y());
m_uv[2].assign(0.5f - cropPad.x(), 0.5f - cropPad.y());
m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y);
m_uv[3].assign(0.5f + cropPad.x, 0.5f - cropPad.y);
m_pos[3].assign(offset.x + imgSize.x(), 0.f, offset.y + imgSize.y());
m_uv[3].assign(0.5f + cropPad.x(), 0.5f - cropPad.y());
}
}

View File

@@ -231,17 +231,17 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
if (!m_flipRect)
{
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y * 2.f;
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y * 2.f - 1.f;
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
}
else
{
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y * -2.f;
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y * -2.f + 1.f;
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y() * -2.f;
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y() * -2.f + 1.f;
}
m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(m_uniform));