From 63e298795deb4af678ff509e325e5c350274ffee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 21 Dec 2018 18:02:39 -0800 Subject: [PATCH] Cleanup. --- examples/14-shadowvolumes/shadowvolumes.cpp | 30 ++++++++++----------- examples/16-shadowmaps/shadowmaps.cpp | 10 +++---- examples/27-terrain/terrain.cpp | 2 +- examples/30-picking/picking.cpp | 2 +- examples/31-rsm/reflectiveshadowmap.cpp | 2 +- examples/32-particles/particles.cpp | 2 +- examples/common/bgfx_utils.cpp | 6 ++--- examples/common/camera.cpp | 2 +- examples/common/debugdraw/debugdraw.cpp | 24 ++++++++--------- src/topology.cpp | 6 ++--- tools/geometryc/geometryc.cpp | 8 +++--- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 05e633690..ba0d95093 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -160,16 +160,16 @@ void planeNormal(float* __restrict _result , const float* __restrict _v2 ) { - const bx::Vec3 v0 = bx::load(_v0); - const bx::Vec3 v1 = bx::load(_v1); - const bx::Vec3 v2 = bx::load(_v2); + const bx::Vec3 v0 = bx::load(_v0); + const bx::Vec3 v1 = bx::load(_v1); + const bx::Vec3 v2 = bx::load(_v2); const bx::Vec3 vec0 = bx::sub(v1, v0); const bx::Vec3 vec1 = bx::sub(v2, v1); const bx::Vec3 cross = bx::cross(vec0, vec1); bx::store(_result, bx::normalize(cross) ); - _result[3] = -bx::dot(bx::load(_result), bx::load(_v0) ); + _result[3] = -bx::dot(bx::load(_result), bx::load(_v0) ); } struct Uniforms @@ -1381,7 +1381,7 @@ void shadowVolumeCreate(ShadowVolume& _shadowVolume const Face& face = *iter; bool frontFacing = false; - const float f = bx::dot(bx::load(face.m_plane), bx::load(_light) ) + face.m_plane[3]; + const float f = bx::dot(bx::load(face.m_plane), bx::load(_light) ) + face.m_plane[3]; if (f > 0.0f) { frontFacing = true; @@ -1569,8 +1569,8 @@ void shadowVolumeCreate(ShadowVolume& _shadowVolume const Edge& edge = edges[ii]; const Plane* edgePlane = &edgePlanes[ii*2]; - int16_t s0 = ( (bx::dot(bx::load(edgePlane[0].m_plane), bx::load(_light) ) + edgePlane[0].m_plane[3]) > 0.0f) ^ edge.m_faceReverseOrder[0]; - int16_t s1 = ( (bx::dot(bx::load(edgePlane[1].m_plane), bx::load(_light) ) + edgePlane[1].m_plane[3]) > 0.0f) ^ edge.m_faceReverseOrder[1]; + int16_t s0 = ( (bx::dot(bx::load(edgePlane[0].m_plane), bx::load(_light) ) + edgePlane[0].m_plane[3]) > 0.0f) ^ edge.m_faceReverseOrder[0]; + int16_t s1 = ( (bx::dot(bx::load(edgePlane[1].m_plane), bx::load(_light) ) + edgePlane[1].m_plane[3]) > 0.0f) ^ edge.m_faceReverseOrder[1]; int16_t kk = ( (s0 + s1) << 1) - 2; if (kk != 0) @@ -1607,7 +1607,7 @@ void shadowVolumeCreate(ShadowVolume& _shadowVolume { const Face& face = *iter; - const float f = bx::dot(bx::load(face.m_plane), bx::load(_light) ) + face.m_plane[3]; + const float f = bx::dot(bx::load(face.m_plane), bx::load(_light) ) + face.m_plane[3]; bool frontFacing = (f > 0.0f); for (uint8_t ii = 0, num = 1 + uint8_t(!_textureAsStencil); ii < num; ++ii) @@ -1700,7 +1700,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f const float delta = 0.1f; const float nearNormal[4] = { 0.0f, 0.0f, 1.0f, _near }; - const float d = bx::dot(bx::load(lightPosV), bx::load(nearNormal) ) + lightPosV[3] * nearNormal[3]; + const float d = bx::dot(bx::load(lightPosV), bx::load(nearNormal) ) + lightPosV[3] * nearNormal[3]; // Light is: // 1.0f - in front of near plane @@ -1733,9 +1733,9 @@ void createNearClipVolume(float* __restrict _outPlanes24f float* outNormal = planeNormals[ii]; float* outPlane = volumePlanes[ii]; - const bx::Vec3 c0 = bx::load(corners[ii]); - const bx::Vec3 planeVec = bx::sub(c0, bx::load(corners[(ii-1)&3]) ); - const bx::Vec3 light = bx::sub(bx::load(_lightPos), bx::mul(c0, _lightPos[3]) ); + const bx::Vec3 c0 = bx::load(corners[ii]); + const bx::Vec3 planeVec = bx::sub(c0, bx::load(corners[(ii-1)&3]) ); + const bx::Vec3 light = bx::sub(bx::load(_lightPos), bx::mul(c0, _lightPos[3]) ); const bx::Vec3 normal = bx::mul(bx::cross(planeVec, light), lightSide); const float invLen = 1.0f / bx::sqrt(bx::dot(normal, normal) ); @@ -1755,14 +1755,14 @@ void createNearClipVolume(float* __restrict _outPlanes24f bx::vec4MulMtx(volumePlanes[4], nearPlaneV, mtxViewTrans); float* lightPlane = volumePlanes[5]; - const bx::Vec3 lightPlaneNormal = bx::sub(bx::mul({ 0.0f, 0.0f, -_near * lightSide }, mtxViewInv), bx::load(_lightPos) ); + const bx::Vec3 lightPlaneNormal = bx::sub(bx::mul({ 0.0f, 0.0f, -_near * lightSide }, mtxViewInv), bx::load(_lightPos) ); float lenInv = 1.0f / bx::sqrt(bx::dot(lightPlaneNormal, lightPlaneNormal) ); lightPlane[0] = lightPlaneNormal.x * lenInv; lightPlane[1] = lightPlaneNormal.y * lenInv; lightPlane[2] = lightPlaneNormal.z * lenInv; - lightPlane[3] = -bx::dot(lightPlaneNormal, bx::load(_lightPos) ) * lenInv; + lightPlane[3] = -bx::dot(lightPlaneNormal, bx::load(_lightPos) ) * lenInv; } bool clipTest(const float* _planes, uint8_t _planeNum, const Mesh& _mesh, const float* _scale, const float* _translate) @@ -1786,7 +1786,7 @@ bool clipTest(const float* _planes, uint8_t _planeNum, const Mesh& _mesh, const { const float* plane = volumePlanes[ii]; - float positiveSide = bx::dot(bx::load(plane), bx::load(sphere.m_center) ) + plane[3] + sphere.m_radius; + float positiveSide = bx::dot(bx::load(plane), bx::load(sphere.m_center) ) + plane[3] + sphere.m_radius; if (positiveSide < 0.0f) { diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 391e8a5b0..6d208921f 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -2333,8 +2333,8 @@ public: lightProj[ProjType::Horizontal][14] /= currentSmSettings->m_far; } - const bx::Vec3 at = bx::add(bx::load(m_pointLight.m_position.m_v), bx::load(m_pointLight.m_spotDirectionInner.m_v) ); - bx::mtxLookAt(lightView[TetrahedronFaces::Green], bx::load(m_pointLight.m_position.m_v), at); + const bx::Vec3 at = bx::add(bx::load(m_pointLight.m_position.m_v), bx::load(m_pointLight.m_spotDirectionInner.m_v) ); + bx::mtxLookAt(lightView[TetrahedronFaces::Green], bx::load(m_pointLight.m_position.m_v), at); } else if (LightType::PointLight == m_settings.m_lightType) { @@ -2403,9 +2403,9 @@ public: float tmp[3] = { - -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[0]) ), - -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[4]) ), - -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[8]) ), + -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[0]) ), + -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[4]) ), + -bx::dot(bx::load(m_pointLight.m_position.m_v), bx::load(&mtxTmp[8]) ), }; bx::mtxTranspose(mtxYpr[ii], mtxTmp); diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index 25e4161a7..d33c98414 100644 --- a/examples/27-terrain/terrain.cpp +++ b/examples/27-terrain/terrain.cpp @@ -357,7 +357,7 @@ public: float ray_world[4]; bx::vec4MulMtx(ray_world, ray_eye, invViewMtx); - const bx::Vec3 rayDir = bx::mul(bx::normalize(bx::load(ray_world) ), -1.0f); + const bx::Vec3 rayDir = bx::mul(bx::normalize(bx::load(ray_world) ), -1.0f); bx::Vec3 pos; cameraGetPosition(&pos.x); diff --git a/examples/30-picking/picking.cpp b/examples/30-picking/picking.cpp index 7847e1ba4..b362ad08f 100644 --- a/examples/30-picking/picking.cpp +++ b/examples/30-picking/picking.cpp @@ -278,7 +278,7 @@ public: // Look at our unprojected point float pickView[16]; - bx::mtxLookAt(pickView, bx::load(pickEye), bx::load(pickAt) ); + bx::mtxLookAt(pickView, bx::load(pickEye), bx::load(pickAt) ); // Tight FOV is best for picking float pickProj[16]; diff --git a/examples/31-rsm/reflectiveshadowmap.cpp b/examples/31-rsm/reflectiveshadowmap.cpp index 807ec757b..ec17afd9f 100644 --- a/examples/31-rsm/reflectiveshadowmap.cpp +++ b/examples/31-rsm/reflectiveshadowmap.cpp @@ -476,7 +476,7 @@ public: lightAt[1] = 0.0f; lightAt[2] = 0.0f; - bx::mtxLookAt(smView, bx::load(lightEye), bx::load(lightAt) ); + bx::mtxLookAt(smView, bx::load(lightEye), bx::load(lightAt) ); const float area = 10.0f; const bgfx::Caps* caps = bgfx::getCaps(); bx::mtxOrtho(smProj, -area, area, -area, area, -100.0f, 100.0f, 0.0f, caps->homogeneousDepth); diff --git a/examples/32-particles/particles.cpp b/examples/32-particles/particles.cpp index 4736a5da0..5790e7af2 100644 --- a/examples/32-particles/particles.cpp +++ b/examples/32-particles/particles.cpp @@ -416,7 +416,7 @@ public: m_emitter[currentEmitter].update(); psUpdate(deltaTime * timeScale); - psRender(0, view, bx::load(eye) ); + psRender(0, view, bx::load(eye) ); if (showBounds) { diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index f1fdf2254..e259d10a5 100644 --- a/examples/common/bgfx_utils.cpp +++ b/examples/common/bgfx_utils.cpp @@ -333,13 +333,13 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl for (uint32_t ii = 0; ii < _numVertices; ++ii) { - const bx::Vec3 tanu = bx::load(&tangents[ii*6]); - const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); + const bx::Vec3 tanu = bx::load(&tangents[ii*6]); + const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); float nxyzw[4]; bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _decl, _vertices, ii); - const bx::Vec3 normal = bx::load(nxyzw); + const bx::Vec3 normal = bx::load(nxyzw); const float ndt = bx::dot(normal, tanu); const bx::Vec3 nxt = bx::cross(normal, tanu); const bx::Vec3 tmp = bx::sub(tanu, bx::mul(normal, ndt) ); diff --git a/examples/common/camera.cpp b/examples/common/camera.cpp index 3e48e57d4..5dc140297 100644 --- a/examples/common/camera.cpp +++ b/examples/common/camera.cpp @@ -240,7 +240,7 @@ struct Camera void getViewMtx(float* _viewMtx) { - bx::mtxLookAt(_viewMtx, bx::load(&m_eye.x), bx::load(&m_at.x), bx::load(&m_up.x) ); + bx::mtxLookAt(_viewMtx, bx::load(&m_eye.x), bx::load(&m_at.x), bx::load(&m_up.x) ); } void setPosition(const float* _pos) diff --git a/examples/common/debugdraw/debugdraw.cpp b/examples/common/debugdraw/debugdraw.cpp index 891d3f42d..3d492e0d3 100644 --- a/examples/common/debugdraw/debugdraw.cpp +++ b/examples/common/debugdraw/debugdraw.cpp @@ -1380,7 +1380,7 @@ struct DebugDrawEncoderImpl vertex.m_abgr = attrib.m_abgr; vertex.m_len = attrib.m_offset; - float len = bx::length(bx::sub(bx::load(&vertex.m_x), bx::load(&m_cache[prev].m_x) ) ) * attrib.m_scale; + float len = bx::length(bx::sub(bx::load(&vertex.m_x), bx::load(&m_cache[prev].m_x) ) ) * attrib.m_scale; vertex.m_len = m_cache[prev].m_len + len; m_indices[m_indexPos++] = prev; @@ -1556,7 +1556,7 @@ struct DebugDrawEncoderImpl }, }; - bx::store(params[0], bx::normalize(bx::load(params[0]) ) ); + bx::store(params[0], bx::normalize(bx::load(params[0]) ) ); m_encoder->setUniform(s_dds.u_params, params, 4); m_encoder->setState(0 @@ -1751,14 +1751,14 @@ struct DebugDrawEncoderImpl bx::Vec3 udir; bx::Vec3 vdir; - bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); + bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); float xy0[2]; float xy1[2]; circle(xy0, 0.0f); squircle(xy1, 0.0f); - const bx::Vec3 center = bx::load(_center); + const bx::Vec3 center = bx::load(_center); bx::Vec3 pos = bx::mul(udir, bx::lerp(xy0[0], xy1[0], _weight)*_radius); bx::Vec3 tmp0 = bx::mul(vdir, bx::lerp(xy0[1], xy1[1], _weight)*_radius); @@ -1829,7 +1829,7 @@ struct DebugDrawEncoderImpl if (attrib.m_wireframe) { bx::Vec3 udir, vdir; - bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); + bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); const float halfExtent = _size*0.5f; @@ -1837,7 +1837,7 @@ struct DebugDrawEncoderImpl const bx::Vec3 umax = bx::mul(udir, halfExtent); const bx::Vec3 vmin = bx::mul(vdir, -halfExtent); const bx::Vec3 vmax = bx::mul(vdir, halfExtent); - const bx::Vec3 center = bx::load(_center); + const bx::Vec3 center = bx::load(_center); moveTo(bx::add(center, bx::add(umin, vmin) ) ); lineTo(bx::add(center, bx::add(umax, vmin) ) ); @@ -1870,7 +1870,7 @@ struct DebugDrawEncoderImpl const Attrib& attrib = m_attrib[m_stack]; bx::Vec3 udir, vdir; - bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); + bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); const Pack2D& pack = s_dds.m_sprite.get(_handle); const float invTextureSize = 1.0f/SPRITE_TEXTURE_SIZE; @@ -1887,7 +1887,7 @@ struct DebugDrawEncoderImpl const bx::Vec3 umax = bx::mul(udir, halfExtentU); const bx::Vec3 vmin = bx::mul(vdir, -halfExtentV); const bx::Vec3 vmax = bx::mul(vdir, halfExtentV); - const bx::Vec3 center = bx::load(_center); + const bx::Vec3 center = bx::load(_center); DebugUvVertex* vertex = &m_cacheQuad[m_posQuad]; m_posQuad += 4; @@ -1927,7 +1927,7 @@ struct DebugDrawEncoderImpl const Attrib& attrib = m_attrib[m_stack]; float normal[3]; - bx::store(normal, bx::normalize(bx::sub(bx::load(_from), bx::load(_to) ) ) ); + bx::store(normal, bx::normalize(bx::sub(bx::load(_from), bx::load(_to) ) ) ); float mtx[2][16]; bx::mtxFromNormal(mtx[0], normal, _radius, _from, attrib.m_spin); @@ -1954,7 +1954,7 @@ struct DebugDrawEncoderImpl const Attrib& attrib = m_attrib[m_stack]; float normal[3]; - bx::store(normal, bx::normalize(bx::sub(bx::load(_from), bx::load(_to) ) ) ); + bx::store(normal, bx::normalize(bx::sub(bx::load(_from), bx::load(_to) ) ) ); float mtx[2][16]; bx::mtxFromNormal(mtx[0], normal, _radius, _from, attrib.m_spin); @@ -2063,7 +2063,7 @@ struct DebugDrawEncoderImpl bx::Vec3 udir; bx::Vec3 vdir; - bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); + bx::calcTangentFrame(udir, vdir, bx::load(_normal), attrib.m_spin); udir = bx::mul(udir, _step); vdir = bx::mul(vdir, _step); @@ -2075,7 +2075,7 @@ struct DebugDrawEncoderImpl const bx::Vec3 umax = bx::mul(udir, halfExtent); const bx::Vec3 vmin = bx::mul(vdir, -halfExtent); const bx::Vec3 vmax = bx::mul(vdir, halfExtent); - const bx::Vec3 center = bx::load(_center); + const bx::Vec3 center = bx::load(_center); bx::Vec3 xs = bx::add(center, bx::add(umin, vmin) ); bx::Vec3 xe = bx::add(center, bx::add(umax, vmin) ); diff --git a/src/topology.cpp b/src/topology.cpp index 02221800e..48fd98fc6 100644 --- a/src/topology.cpp +++ b/src/topology.cpp @@ -280,17 +280,17 @@ namespace bgfx const bx::Vec3 vertexPos(const void* _vertices, uint32_t _stride, uint32_t _index) { const uint8_t* vertices = (const uint8_t*)_vertices; - return bx::load(&vertices[_index*_stride]); + return bx::load(&vertices[_index*_stride]); } inline float distanceDir(const float* __restrict _dir, const void* __restrict _vertices, uint32_t _stride, uint32_t _index) { - return bx::dot(vertexPos(_vertices, _stride, _index), bx::load(_dir) ); + return bx::dot(vertexPos(_vertices, _stride, _index), bx::load(_dir) ); } inline float distancePos(const float* __restrict _pos, const void* __restrict _vertices, uint32_t _stride, uint32_t _index) { - const bx::Vec3 tmp = bx::sub(bx::load(_pos), vertexPos(_vertices, _stride, _index) ); + const bx::Vec3 tmp = bx::sub(bx::load(_pos), vertexPos(_vertices, _stride, _index) ); return bx::sqrt(bx::dot(tmp, tmp) ); } diff --git a/tools/geometryc/geometryc.cpp b/tools/geometryc/geometryc.cpp index 1174b30f7..185bb7c2f 100644 --- a/tools/geometryc/geometryc.cpp +++ b/tools/geometryc/geometryc.cpp @@ -236,13 +236,13 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl for (uint32_t ii = 0; ii < _numVertices; ++ii) { - const bx::Vec3 tanu = bx::load(&tangents[ii*6]); - const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); + const bx::Vec3 tanu = bx::load(&tangents[ii*6]); + const bx::Vec3 tanv = bx::load(&tangents[ii*6 + 3]); float nxyzw[4]; bgfx::vertexUnpack(nxyzw, bgfx::Attrib::Normal, _decl, _vertices, ii); - const bx::Vec3 normal = bx::load(nxyzw); + const bx::Vec3 normal = bx::load(nxyzw); const float ndt = bx::dot(normal, tanu); const bx::Vec3 nxt = bx::cross(normal, tanu); const bx::Vec3 tmp = bx::sub(tanu, bx::mul(normal, ndt) ); @@ -998,7 +998,7 @@ int main(int _argc, const char* _argv[]) if (hasNormal) { float normal[4]; - bx::store(normal, bx::normalize(bx::load(&normals[index.m_normal]) ) ); + bx::store(normal, bx::normalize(bx::load(&normals[index.m_normal]) ) ); bgfx::vertexPack(normal, true, bgfx::Attrib::Normal, decl, vertices); }