Branimir Karadžić 7 年之前
父節點
當前提交
63e298795d

+ 15 - 15
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<bx::Vec3>(_v0);
+	const bx::Vec3 v1    = bx::load<bx::Vec3>(_v1);
+	const bx::Vec3 v2    = bx::load<bx::Vec3>(_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<bx::Vec3>(_result), bx::load<bx::Vec3>(_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<bx::Vec3>(face.m_plane), bx::load<bx::Vec3>(_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<bx::Vec3>(edgePlane[0].m_plane), bx::load<bx::Vec3>(_light) ) + edgePlane[0].m_plane[3]) > 0.0f) ^ edge.m_faceReverseOrder[0];
+				int16_t s1 = ( (bx::dot(bx::load<bx::Vec3>(edgePlane[1].m_plane), bx::load<bx::Vec3>(_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<bx::Vec3>(face.m_plane), bx::load<bx::Vec3>(_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<bx::Vec3>(lightPosV), bx::load<bx::Vec3>(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<bx::Vec3>(corners[ii]);
+		const bx::Vec3 planeVec = bx::sub(c0, bx::load<bx::Vec3>(corners[(ii-1)&3]) );
+		const bx::Vec3 light    = bx::sub(bx::load<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(plane), bx::load<bx::Vec3>(sphere.m_center) ) + plane[3] + sphere.m_radius;
 
 			if (positiveSide < 0.0f)
 			{

+ 5 - 5
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<bx::Vec3>(m_pointLight.m_position.m_v), bx::load<bx::Vec3>(m_pointLight.m_spotDirectionInner.m_v) );
+				bx::mtxLookAt(lightView[TetrahedronFaces::Green], bx::load<bx::Vec3>(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<bx::Vec3>(m_pointLight.m_position.m_v), bx::load<bx::Vec3>(&mtxTmp[0]) ),
+						-bx::dot(bx::load<bx::Vec3>(m_pointLight.m_position.m_v), bx::load<bx::Vec3>(&mtxTmp[4]) ),
+						-bx::dot(bx::load<bx::Vec3>(m_pointLight.m_position.m_v), bx::load<bx::Vec3>(&mtxTmp[8]) ),
 					};
 
 					bx::mtxTranspose(mtxYpr[ii], mtxTmp);

+ 1 - 1
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<bx::Vec3>(ray_world) ), -1.0f);
 
 		bx::Vec3 pos;
 		cameraGetPosition(&pos.x);

+ 1 - 1
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<bx::Vec3>(pickEye), bx::load<bx::Vec3>(pickAt) );
 
 				// Tight FOV is best for picking
 				float pickProj[16];

+ 1 - 1
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<bx::Vec3>(lightEye), bx::load<bx::Vec3>(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);

+ 1 - 1
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<bx::Vec3>(eye) );
 
 			if (showBounds)
 			{

+ 3 - 3
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<bx::Vec3>(&tangents[ii*6]);
+		const bx::Vec3 tanv = bx::load<bx::Vec3>(&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<bx::Vec3>(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) );

+ 1 - 1
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<bx::Vec3>(&m_eye.x), bx::load<bx::Vec3>(&m_at.x), bx::load<bx::Vec3>(&m_up.x) );
 	}
 
 	void setPosition(const float* _pos)

+ 12 - 12
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<bx::Vec3>(&vertex.m_x), bx::load<bx::Vec3>(&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<bx::Vec3>(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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_from), bx::load<bx::Vec3>(_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<bx::Vec3>(_from), bx::load<bx::Vec3>(_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<bx::Vec3>(_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<bx::Vec3>(_center);
 
 		bx::Vec3 xs = bx::add(center, bx::add(umin, vmin) );
 		bx::Vec3 xe = bx::add(center, bx::add(umax, vmin) );

+ 3 - 3
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<bx::Vec3>(&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<bx::Vec3>(_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<bx::Vec3>(_pos), vertexPos(_vertices, _stride, _index) );
 		return bx::sqrt(bx::dot(tmp, tmp) );
 	}
 

+ 4 - 4
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<bx::Vec3>(&tangents[ii*6]);
+		const bx::Vec3 tanv = bx::load<bx::Vec3>(&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<bx::Vec3>(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<bx::Vec3>(&normals[index.m_normal]) ) );
 						bgfx::vertexPack(normal, true, bgfx::Attrib::Normal, decl, vertices);
 					}