作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 DirectX11 用 C++ 编写程序。现在我想从着色器开始,为此我还需要 ID3D11InputLayout
//in main
shader.Bind(DeviceContext);
ID3D11InputLayout *pLayout;
D3D11_INPUT_ELEMENT_DESC ied[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
HRESULT hh = Device->CreateInputLayout(ied, 2, shader.GetVSBlob()->GetBufferPointer(), shader.GetVSBlob()->GetBufferSize(), &pLayout);
DeviceContext->IASetInputLayout(pLayout);
//Vertex Shader
struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
VOut main(float4 position : POSITION, float4 color : COLOR)
{
VOut output;
output.position = position;
output.color = color;
return output;
}
//pixel shader
struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
float4 main(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
return color;
}
Device->CreateInputLayout() 返回 E_INVALIDARG。
最佳答案
启用 Direct3D Debug Device并查找调试输出。
D3D11 ERROR: ID3D11Device::CreateInputLayout: The provided input signature expects
to read an element with SemanticName/Index: 'SV_Position'/0, but the declaration
doesn't provide a matching name.
[ STATE_CREATION ERROR #163: CREATEINPUTLAYOUT_MISSINGELEMENT]
在这种情况下,您会看到您在布局中使用了遗留的“POSITION”语义,但在着色器中使用了“SV_Position”。它们需要保持一致。
关于c++ - CreateInputLayout 返回 E_INVALIDARG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58117319/
我正在使用 DirectX11 用 C++ 编写程序。现在我想从着色器开始,为此我还需要 ID3D11InputLayout //in main shader.Bind(DeviceContext);
最近我一直在关注 rasertek 的 DirectX 编程,但在我的代码中,createinputlayout() 函数不起作用。我想我得到了与源代码相同的代码,但是 createinputlayo
我是一名优秀的程序员,十分优秀!