Beispiel #1
0
 void ModelShader::BindParameters()
 {
     BindParameter(WORLD_MATRIX, SP_MATRIX4, "world_matrix");
     BindParameter(VIEW_MATRIX, SP_MATRIX4, "view_matrix");
     BindParameter(PROJ_MATRIX, SP_MATRIX4, "projection_matrix");
     BindTexture(TEXTURE, 0, "texture0");
 }
Beispiel #2
0
void SQLiteCommand::prepareBindContext() {
	if (myBindContext.size() > 0) {
		return;
	}

	size_t number = 0;

	for (size_t i = 0; i < myStatements.size(); ++i) {
		sqlite3_stmt *statement = myStatements[i];
		const int count = sqlite3_bind_parameter_count(statement);
		for (int j = 1; j <= count; ++j) {
			++number;
			const char *name = sqlite3_bind_parameter_name(statement, j);
			if (name == 0) {
				myBindContext.push_back(BindParameter(number));
			} else {
				const std::string namestr(name);
				if (std::find_if(myBindContext.begin(), myBindContext.end(), BindParameterComparator(namestr)) == myBindContext.end()) {
					myBindContext.push_back(BindParameter(number, namestr));
				}
			}
		}
	}
}
Beispiel #3
0
void Blend::Setup(SetupContext& context) {
	auto& target = this->GetInput<0>().Get();
	gxapi::RtvTexture2DArray rtvDesc;
	rtvDesc.activeArraySize = 1;
	rtvDesc.firstArrayElement = 0;
	rtvDesc.firstMipLevel = 0;
	rtvDesc.planeIndex = 0;
	m_blendDest = context.CreateRtv(target, target.GetFormat(), rtvDesc);

	auto blendSrc = this->GetInput<1>().Get();
	gxapi::SrvTexture2DArray srvDesc;
	srvDesc.activeArraySize = 1;
	srvDesc.firstArrayElement = 0;
	srvDesc.mipLevelClamping = 0;
	srvDesc.mostDetailedMip = 0;
	srvDesc.numMipLevels = 1;
	srvDesc.planeIndex = 0;
	m_blendSrc = context.CreateSrv(blendSrc, blendSrc.GetFormat(), srvDesc);

	gxapi::RenderTargetBlendState currBlendMode = this->GetInput<2>().Get();

	this->GetOutput<0>().Set(target);


	if (!m_binder) {
		BindParameterDesc tex0ParamDesc;
		m_tex0Param = BindParameter(eBindParameterType::TEXTURE, 0);
		tex0ParamDesc.parameter = m_tex0Param;
		tex0ParamDesc.constantSize = 0;
		tex0ParamDesc.relativeAccessFrequency = 0;
		tex0ParamDesc.relativeChangeFrequency = 0;
		tex0ParamDesc.shaderVisibility = gxapi::eShaderVisiblity::PIXEL;

		BindParameterDesc sampBindParamDesc;
		sampBindParamDesc.parameter = BindParameter(eBindParameterType::SAMPLER, 0);
		sampBindParamDesc.constantSize = 0;
		sampBindParamDesc.relativeAccessFrequency = 0;
		sampBindParamDesc.relativeChangeFrequency = 0;
		sampBindParamDesc.shaderVisibility = gxapi::eShaderVisiblity::PIXEL;

		gxapi::StaticSamplerDesc samplerDesc;
		samplerDesc.shaderRegister = 0;
		samplerDesc.filter = gxapi::eTextureFilterMode::MIN_MAG_LINEAR_MIP_POINT;
		samplerDesc.addressU = gxapi::eTextureAddressMode::CLAMP;
		samplerDesc.addressV = gxapi::eTextureAddressMode::CLAMP;
		samplerDesc.addressW = gxapi::eTextureAddressMode::CLAMP;
		samplerDesc.mipLevelBias = 0.f;
		samplerDesc.registerSpace = 0;
		samplerDesc.shaderVisibility = gxapi::eShaderVisiblity::PIXEL;

		m_binder = context.CreateBinder({ tex0ParamDesc, sampBindParamDesc }, { samplerDesc });
	}


	if (!m_shader.vs || m_shader.ps) {
		ShaderParts shaderParts;
		shaderParts.vs = true;
		shaderParts.ps = true;

		m_shader = context.CreateShader("Blend", shaderParts, "");
	}

	if (m_renderTargetFormat != target.GetFormat() || m_blendMode != currBlendMode) {
		m_renderTargetFormat = target.GetFormat();
		m_blendMode = currBlendMode;

		std::vector<gxapi::InputElementDesc> inputElementDesc = {
			gxapi::InputElementDesc("POSITION", 0, gxapi::eFormat::R32G32_FLOAT, 0, 0)
		};

		gxapi::GraphicsPipelineStateDesc psoDesc;
		psoDesc.inputLayout.elements = inputElementDesc.data();
		psoDesc.inputLayout.numElements = (unsigned)inputElementDesc.size();
		psoDesc.rootSignature = m_binder.GetRootSignature();
		psoDesc.vs = m_shader.vs;
		psoDesc.ps = m_shader.ps;
		psoDesc.rasterization = gxapi::RasterizerState(gxapi::eFillMode::SOLID, gxapi::eCullMode::DRAW_ALL);
		psoDesc.primitiveTopologyType = gxapi::ePrimitiveTopologyType::TRIANGLE;
		psoDesc.blending.alphaToCoverage = false;
		psoDesc.blending.independentBlending = false;
		psoDesc.blending.singleTarget = m_blendMode;
		
		psoDesc.numRenderTargets = 1;
		psoDesc.renderTargetFormats[0] = m_renderTargetFormat;

		m_PSO.reset(context.CreatePSO(psoDesc));
	}
	
}
Beispiel #4
0
		// http://msdn.microsoft.com/en-us/library/windows/desktop/ms711786(v=vs.85).aspx
		void BindColumn(unsigned short index, ParameterType parameterType, const Column& column)
		{
			const HANAColumnType hct = column.GetColumnType();
			switch (hct.sqlDataType)
			{
			case SqlDataType::SVARCHAR:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, hct.size, 0, (SQLPOINTER*)column.GetDataPtr(), hct.dataSize, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SNVARCHAR:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, hct.size, 0, (SQLPOINTER*)column.GetDataPtr(), hct.dataSize, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SDECIMAL:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, hct.size, 0, (SQLPOINTER*)column.GetDataPtr(), hct.dataSize, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SINTEGER:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 10, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SSMALLINT:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 5, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::STINYINT:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 3, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SFLOATN:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, hct.size, 0, (SQLPOINTER*)column.GetDataPtr(), hct.dataSize, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SDOUBLE:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 15, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SBIGINT:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 19, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SDATE:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 10, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::STIME:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 8, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::STIMESTAMP:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 20, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			case SqlDataType::SSECONDDATE:
				BindParameter(index, parameterType, hct.cDataType, hct.sqlDataType, 19, 0, (SQLPOINTER*)column.GetDataPtr(), 0, (SQLLEN*)column.GetDataLenPtr());
				break;
			default:throw HANAException("Unkown column type"); break;
			}
		}
void DepthPrepass::Setup(SetupContext & context) {
	Texture2D& depthStencil = this->GetInput<0>().Get();
	depthStencil.SetName("Depth prepass DS");// Debug

	const gxapi::eFormat currDepthStencilFormat = FormatAnyToDepthStencil(depthStencil.GetFormat());

	gxapi::DsvTexture2DArray desc;
	desc.activeArraySize = 1;
	desc.firstArrayElement = 0;
	desc.firstMipLevel = 0;

	m_targetDsv = context.CreateDsv(depthStencil, currDepthStencilFormat, desc);
	
	
	m_entities = this->GetInput<1>().Get();

	m_camera = this->GetInput<2>().Get();

	this->GetOutput<0>().Set(depthStencil);

	if (!m_binder.has_value()) {
		BindParameterDesc transformBindParamDesc;
		m_transformBindParam = BindParameter(eBindParameterType::CONSTANT, 0);
		transformBindParamDesc.parameter = m_transformBindParam;
		transformBindParamDesc.constantSize = sizeof(float) * 4 * 4;
		transformBindParamDesc.relativeAccessFrequency = 0;
		transformBindParamDesc.relativeChangeFrequency = 0;
		transformBindParamDesc.shaderVisibility = gxapi::eShaderVisiblity::VERTEX;

		BindParameterDesc sampBindParamDesc;
		sampBindParamDesc.parameter = BindParameter(eBindParameterType::SAMPLER, 0);
		sampBindParamDesc.constantSize = 0;
		sampBindParamDesc.relativeAccessFrequency = 0;
		sampBindParamDesc.relativeChangeFrequency = 0;
		sampBindParamDesc.shaderVisibility = gxapi::eShaderVisiblity::PIXEL;

		gxapi::StaticSamplerDesc samplerDesc;
		samplerDesc.shaderRegister = 0;
		samplerDesc.filter = gxapi::eTextureFilterMode::MIN_MAG_MIP_LINEAR;
		samplerDesc.addressU = gxapi::eTextureAddressMode::WRAP;
		samplerDesc.addressV = gxapi::eTextureAddressMode::WRAP;
		samplerDesc.addressW = gxapi::eTextureAddressMode::WRAP;
		samplerDesc.mipLevelBias = 0.f;
		samplerDesc.registerSpace = 0;
		samplerDesc.shaderVisibility = gxapi::eShaderVisiblity::PIXEL;

		m_binder = context.CreateBinder({ transformBindParamDesc, sampBindParamDesc },{ samplerDesc });
	}

	if (!m_shader.vs || !m_shader.ps) {
		ShaderParts shaderParts;
		shaderParts.vs = true;
		shaderParts.ps = true;

		m_shader = context.CreateShader("DepthPrepass", shaderParts, "");
	}

	if (m_PSO == nullptr || m_depthStencilFormat != currDepthStencilFormat) {
		m_depthStencilFormat = currDepthStencilFormat;

		std::vector<gxapi::InputElementDesc> inputElementDesc = {
			gxapi::InputElementDesc("POSITION", 0, gxapi::eFormat::R32G32B32_FLOAT, 0, 0),
			gxapi::InputElementDesc("NORMAL", 0, gxapi::eFormat::R32G32B32_FLOAT, 0, 12),
			gxapi::InputElementDesc("TEX_COORD", 0, gxapi::eFormat::R32G32_FLOAT, 0, 24),
		};

		gxapi::GraphicsPipelineStateDesc psoDesc;
		psoDesc.inputLayout.elements = inputElementDesc.data();
		psoDesc.inputLayout.numElements = (unsigned)inputElementDesc.size();
		psoDesc.rootSignature = m_binder->GetRootSignature();
		psoDesc.vs = m_shader.vs;
		psoDesc.ps = m_shader.ps;
		psoDesc.rasterization = gxapi::RasterizerState(gxapi::eFillMode::SOLID, gxapi::eCullMode::DRAW_CCW);
		psoDesc.primitiveTopologyType = gxapi::ePrimitiveTopologyType::TRIANGLE;

		psoDesc.depthStencilState = gxapi::DepthStencilState(true, true);
		psoDesc.depthStencilFormat = m_depthStencilFormat;

		psoDesc.numRenderTargets = 0;

		m_PSO.reset(context.CreatePSO(psoDesc));
	}
}