コード例 #1
0
ファイル: Material.cpp プロジェクト: swq0553/anki-3d-engine
//==============================================================================
ProgramResourcePointer& Material::getProgram(
	const RenderingKey key, ShaderType type)
{
	ProgramResourcePointer& out = m_progs[getShaderIndex(key, type)];

	if(out.isLoaded())
	{
		ANKI_ASSERT(
			computeShaderTypeIndex(out->getGlProgram().getType()) == type);
	}

	return out;
}
コード例 #2
0
ファイル: Material.cpp プロジェクト: ezhangle/anki-3d-engine
//==============================================================================
ProgramResourcePointer& Material::getProgram(
	const RenderingKey key, U32 shaderId)
{
	ANKI_ASSERT((U)key.m_pass < m_passesCount);
	ANKI_ASSERT(key.m_lod < m_lodsCount);

	if(key.m_tessellation)
	{
		ANKI_ASSERT(m_tessellation);
	}

	// Calc the count that are before this shader
	U tessCount = m_tessellation ? 2 : 1;
	U count = 0;
	switch(shaderId)
	{
	case 4:
		// Count of geom
		count += 0;
	case 3:
		// Count of tess
		if(m_tessellation)
		{
			count += m_passesCount * m_lodsCount;
		}
	case 2:
		// Count of tess
		if(m_tessellation)
		{
			count += m_passesCount * m_lodsCount;
		}
	case 1:
		// Count of vert
		count += m_passesCount * m_lodsCount * tessCount;
	case 0:
		break;
	default:
		ANKI_ASSERT(0);
	}

	// Calc the idx
	U idx = 0;
	switch(shaderId)
	{
	case 0:
		idx = (U)key.m_pass * m_lodsCount * tessCount + key.m_lod * tessCount 
			+ (key.m_tessellation ? 1 : 0);
		break;
	case 1:
	case 2:
	case 4:
		idx = (U)key.m_pass * m_lodsCount + key.m_lod;
		break;
	default:
		ANKI_ASSERT(0);
	}

	idx += count;
	ANKI_ASSERT(idx < m_progs.size());
	ProgramResourcePointer& out = m_progs[idx];

	if(out.isLoaded())
	{
		ANKI_ASSERT(
			computeShaderTypeIndex(out->getGlProgram().getType()) == shaderId);
	}

	return out;
}