/*
Copyright (C) 2010, Heikki Salo
All rights reserved.
Distributed under the BSD license:
http://www.opensource.org/licenses/bsd-license.php
*/
#include "stdafx.h"
#include "DPEffect.hpp"
#include "DPDevice.hpp"
#include "DPLayout.hpp"
#include "DPUtils.hpp"
DPInputLayout::DPInputLayout(python::object& desc, DPEffect& effect, UINT techIndex, UINT passIndex)
{
layout = 0;
DPDevice* device = getDPDevice();
ID3DX11EffectTechnique* technique = effect.getEffect()->GetTechniqueByIndex(techIndex);
if (!technique->IsValid()) {
DPThrow("Invalid technique");
}
ID3DX11EffectPass* effectPass = technique->GetPassByIndex(passIndex);
if (!effectPass->IsValid())
DPThrow("Invalid pass");
std::vector<D3D11_INPUT_ELEMENT_DESC> resultDesc;
ConvertLayoutDesc(desc, &resultDesc);
D3DX11_PASS_DESC passDesc;
effectPass->GetDesc(&passDesc);
HRESULT hr = device->getDevice()->CreateInputLayout(&resultDesc[0], resultDesc.size(),
passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &layout);
if (FAILED(hr)) {
DPThrow(hr);
}
DPBase::init(device->getDevice());
}
void ExportDPInputLayout()
{
using namespace boost::python;
class_<DPInputLayout, boost::noncopyable>("InputLayout", init<object&, DPEffect&, UINT, UINT>())
.def("release", &DPInputLayout::release)
;
}