Пример #1
0
	AEResult BuildCBFPRLights(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_FPR_LightCulling
		//
		//		cbuffer _AE_CB_FPR_Lights : register(b0)
		//		{
		//			float3	_AE_CameraPos			: packoffset(c0);
		//			uint	_AE_WindowWidth			: packoffset(c0.w);
		//		};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_HalfPixel
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHTS_NAME);

		/**************************************
		*Add Var 1: _AE_CameraPos
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_CAMERA_POS_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 3;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::vec3);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::vec3);
		scv->m_ShaderVariableClass = ShaderVariableClass::Vector;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_WindowWidth
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WINDOW_WIDTH_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 1;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(uint32_t);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(uint32_t);
		scv->m_ShaderVariableClass = ShaderVariableClass::Scalar;
		scv->m_ShaderVariableType = ShaderVariableType::UInt;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
Пример #2
0
	AEResult BuildCBFPRLightCulling(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_FPR_LightCulling
		//
		//		cbuffer _AE_CB_FPR_LightCulling : register(b0)
		//		{
		//			matrix	_AE_View				: packoffset(c0);
		//			matrix	_AE_InvProjection		: packoffset(c4);
		//		
		//			uint	_AE_WindowHeight		: packoffset(c8.x);
		//			uint	_AE_WindowWidth			: packoffset(c8.y);
		//			uint	_AE_NumLights			: packoffset(c8.z);
		//		};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_FPR_LightCulling
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHT_CULLING_NAME);

		/**************************************
		*Add Var 1: _AE_View
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_VIEW_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_InvProjection
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_INV_PROJECTION_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 3: _AE_WindowHeight
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WINDOW_HEIGHT_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 1;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(uint32_t);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(uint32_t);
		scv->m_ShaderVariableClass = ShaderVariableClass::Scalar;
		scv->m_ShaderVariableType = ShaderVariableType::UInt;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 4: _AE_WindowWidth
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WINDOW_WIDTH_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 1;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(uint32_t);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(uint32_t);
		scv->m_ShaderVariableClass = ShaderVariableClass::Scalar;
		scv->m_ShaderVariableType = ShaderVariableType::UInt;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 5: _AE_NumLights
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_NUM_LIGHTS_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 1;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(uint32_t);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(uint32_t);
		scv->m_ShaderVariableClass = ShaderVariableClass::Scalar;
		scv->m_ShaderVariableType = ShaderVariableType::UInt;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
Пример #3
0
	AEResult BuildCBWVP(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_World_View_Proj
		//
		//	cbuffer _AE_CB_World_View_Proj : register(b0)
		//	{
		//		matrix _AE_World		: packoffset(c0);
		//		matrix _AE_View			: packoffset(c4);
		//		matrix _AE_PROJection	: packoffset(c8);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_World_View_Proj
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_WORLD_VIEW_PROJ_NAME);

		/**************************************
		*Add Var 1: _AE_World
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WORLD_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_View
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_VIEW_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 3: _AE_PROJection
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_PROJECTION_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
Пример #4
0
	AEResult BuildCBHalfPixel(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_HalfPixel
		//
		//	cbuffer _AE_CB_HalfPixel : register(b0)
		//	{
		//		float2 _AE_HalfPixel	: packoffset(c0);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_HalfPixel
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_HALF_PIXEL_NAME);

		/**************************************
		*Add Var 1: _AE_HalfPixel
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_HALF_PIXEL_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 2;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::vec2);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::vec2);
		scv->m_ShaderVariableClass = ShaderVariableClass::Vector;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
Пример #5
0
	AEResult BuildCBBones(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_Bones
		//
		//	cbuffer _AE_CB_Bones : register(b1)
		//	{
		//		matrix _AE_BoneTransforms[MAX_BONES] : packoffset(c0);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_Bones
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 1, AE_CB_BONES_NAME);

		/**************************************
		*Add Var 1: _AE_World
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_BONE_TRANSFORMS_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = AE_MAX_BONES;
		scv->m_IsArray = true;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4) * AE_MAX_BONES;
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}