mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-22 22:25:37 +01:00
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
|
//--------------------------------------------------------------------------------------
|
||
|
// File: DirectXHelpers.cpp
|
||
|
//
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
// Licensed under the MIT License.
|
||
|
//
|
||
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||
|
//--------------------------------------------------------------------------------------
|
||
|
|
||
|
#include "pch.h"
|
||
|
#include "DirectXHelpers.h"
|
||
|
#include "Effects.h"
|
||
|
#include "PlatformHelpers.h"
|
||
|
|
||
|
|
||
|
using namespace DirectX;
|
||
|
|
||
|
_Use_decl_annotations_
|
||
|
HRESULT DirectX::CreateInputLayoutFromEffect(
|
||
|
ID3D11Device* device,
|
||
|
IEffect* effect,
|
||
|
const D3D11_INPUT_ELEMENT_DESC* desc,
|
||
|
size_t count,
|
||
|
ID3D11InputLayout** pInputLayout) noexcept
|
||
|
{
|
||
|
if (!pInputLayout)
|
||
|
return E_INVALIDARG;
|
||
|
|
||
|
*pInputLayout = nullptr;
|
||
|
|
||
|
if (!device || !effect || !desc || !count)
|
||
|
return E_INVALIDARG;
|
||
|
|
||
|
void const* shaderByteCode;
|
||
|
size_t byteCodeLength;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
||
|
}
|
||
|
catch (com_exception e)
|
||
|
{
|
||
|
return e.get_result();
|
||
|
}
|
||
|
catch (...)
|
||
|
{
|
||
|
return E_FAIL;
|
||
|
}
|
||
|
|
||
|
return device->CreateInputLayout(
|
||
|
desc, static_cast<UINT>(count),
|
||
|
shaderByteCode, byteCodeLength,
|
||
|
pInputLayout);
|
||
|
}
|