i32 CShaderManager::Init()
	{
		//Create default shaders
		IInputLayout* pIL = m_pRenderSystem->GetInputLayout( ILE::POSITION );
		xst_assert2( pIL != xst_null );
		xst_assert2( pIL->GetVertexShader() != xst_null );
		
		/*IVertexShader* pVS = m_pRenderSystem->CreateDefaultVertexShader( pIL, this, 0, strVSName, XST::ResourceType::SHADER, XST::ResourceStates::CREATED, xst_null );
		if( pVS == xst_null )
		{
			return XST_FAIL;
		}*/

		xst_castring strPSName( "xse_default_ps" );
		Resources::IPixelShader* pPS = m_pRenderSystem->CreateDefaultPixelShader( xst_null, this, 0, strPSName, XST::ResourceType::SHADER, XST::ResourceStates::CREATED, xst_null );
		if( pPS == xst_null )
		{
			return XST_FAIL;
		}

		m_pDefaultPS = PixelShaderPtr( pPS );
		m_pDefaultVS = VertexShaderPtr( pIL->GetVertexShader() );

		return XST_OK;
	}
	VertexShaderPtr CShaderManager::GetDefaultVertexShader(const IInputLayout* pIL)
	{
		xst_assert( pIL->GetVertexShader() != xst_null, "(CShaderManager::GetdefaultVertexShader) Vertex shader for input layout must be created!" );
		//Try to get this shader
		VShaderMap::iterator Itr;
		if( XST::MapUtils::FindPlace( m_mDefaultVShaders, pIL, &Itr ) )
		{
			XST::MapUtils::InsertOnPlace( m_mDefaultVShaders, pIL, VertexShaderPtr( pIL->GetVertexShader() ), Itr );
		}

		//If found return it
		return Itr->second;
	}
Beispiel #3
0
	VertexShaderPtr UGraphicsDevice::LoadVertexShader(const void* inVertexBytes, size_t inVertexBytesLength)
	{
		assert(inVertexBytes);

		ID3D11VertexShader* vertexShader = nullptr;
		HRESULT hr = mD3dDevice->CreateVertexShader(inVertexBytes, inVertexBytesLength, nullptr, &vertexShader);
		if (FAILED(hr))
		{
			LOG(LogGraphicsDevice, Error, "LoadVertexShader() Failed to load vertex shader\n");
			return nullptr;
		}

		return VertexShaderPtr(vertexShader, AutoReleaseD3D);
	}