Example #1
0
    void Effect::ExtractPassData(D3DX11_EFFECT_DESC& effectDesc) {
        for(U32 g = 0; g < effectDesc.Groups; ++g) {
            ID3DX11EffectGroup* group = dx11Effect->GetGroupByIndex(g);
            D3DX11_GROUP_DESC groupDesc;
            DXCall(group->GetDesc(&groupDesc));

            for(U32 t = 0; t < groupDesc.Techniques; ++t) {
                ID3DX11EffectTechnique* pTechnique = group->GetTechniqueByIndex(t);
                D3DX11_TECHNIQUE_DESC techniqueDesc;
                DXCall(pTechnique->GetDesc(&techniqueDesc));

                for(U32 p = 0; p < techniqueDesc.Passes; ++p) {
                    ID3DX11EffectPass* pass = pTechnique->GetPassByIndex(p);
                    D3DX11_PASS_DESC passDesc;
                    DXCall(pass->GetDesc(&passDesc));

                    D3DX11_PASS_SHADER_DESC passShaderDesc;
                    DXCall(pass->GetVertexShaderDesc(&passShaderDesc));
                    D3DX11_EFFECT_SHADER_DESC shaderDesc;
                    DXCall(passShaderDesc.pShaderVariable->GetShaderDesc(passShaderDesc.ShaderIndex, &shaderDesc));

                    for(U32 i = 0; i < shaderDesc.NumInputSignatureEntries; ++i) {
                        D3D11_SIGNATURE_PARAMETER_DESC signatureDesc;
                        DXCall(passShaderDesc.pShaderVariable->GetInputSignatureElementDesc(passShaderDesc.ShaderIndex, i, &signatureDesc));
                    }

                    groups[groupDesc.Name].techniques[techniqueDesc.Name].passes[passDesc.Name].data.pass = pass;
                    groups[groupDesc.Name].techniques[techniqueDesc.Name].passes[passDesc.Name].data.inputSignature = passDesc.pIAInputSignature;
                    groups[groupDesc.Name].techniques[techniqueDesc.Name].passes[passDesc.Name].data.inputSignatureSize = passDesc.IAInputSignatureSize;

                }
            }
        }
    }
Example #2
0
	bool D3D11EffectMaterial::SetVertexFormat(const VertexFormat& format)
	{
		if(m_pIL != NULL)
		{
			m_pIL->Release();
		}

		int nElem = format.GetElementCount();
		D3D11_INPUT_ELEMENT_DESC* layout = new D3D11_INPUT_ELEMENT_DESC[nElem];

		for(int i = 0; i < nElem; ++i)
		{
			const VertexElement& e = format.GetElement(i);

			switch(e.semantic)
			{
			case VertexElement::POSITION:
				layout[i].SemanticName							= "POSITION";
				break;

			case VertexElement::NORMAL:
				layout[i].SemanticName							= "NORMAL";
				break;

			case VertexElement::COLOR:
				layout[i].SemanticName							= "COLOR";
				break;

			case VertexElement::POSITION_T:
				layout[i].SemanticName							= "POSITIONT";
				break;

			case VertexElement::TEXCOORD:
				layout[i].SemanticName							= "TEXCOORD";
				break;

			default:
				break;

			}

			layout[i].Format								= D3D11Format::Convert(e.type);
			layout[i].SemanticIndex							= e.element_slot;

			layout[i].InputSlot								= 0;
			layout[i].AlignedByteOffset						= D3D11_APPEND_ALIGNED_ELEMENT ;
			layout[i].InputSlotClass						= D3D11_INPUT_PER_VERTEX_DATA;
			layout[i].InstanceDataStepRate					= 0;
		}

		ID3DX11EffectTechnique* pTech = m_pEffect->GetTechniqueByIndex(0);

		ID3DX11EffectPass* pPass = pTech->GetPassByIndex(0);
		D3DX11_PASS_DESC pass;
		ZeroMemory(&pass, sizeof(pass));
		HRESULT hr = pPass->GetDesc(&pass);

		hr = m_pDevice->CreateInputLayout( layout, 
			nElem, 
			pass.pIAInputSignature,
			pass.IAInputSignatureSize,
			&m_pIL ); 

		if(FAILED(hr))
		{
			delete[] layout;
			return false;
		}
		delete[] layout;
		return true;
	}