- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在调用 CreateGraphicsPipelineState()
时遇到了一个奇怪的错误。该函数返回 E_INVALIDARG
,即使描述已全部设置。
之前的描述有效,我尝试将 indexbuffers
添加到我的管道中,我什至没有接触任何 PSO 或着色器的代码,现在 PSO 的创建都一团糟。
问题是在启用调试层时,我没有从驱动程序收到任何 DX 错误消息。我只知道这个
"Microsoft C++ exception: _com_error at memory location
当我单步执行函数时。
感觉是指针错误之类的,但我想不通是什么错误。也许你们中的任何人都能看出我犯了一个明显的错误?
这是我的代码:
CGraphicsPSO* pso = new CGraphicsPSO();
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
// Input Layout
std::vector<D3D12_INPUT_ELEMENT_DESC> elements;
if (aPSODesc.inputLayout != nullptr)
{
auto& ilData = aPSODesc.inputLayout->desc;
for (auto& element : ilData)
{
// All Data here is correct when breaking
D3D12_INPUT_ELEMENT_DESC elementDesc;
elementDesc.SemanticName = element.mySemanticName;
elementDesc.SemanticIndex = element.mySemanticIndex;
elementDesc.InputSlot = element.myInputSlot;
elementDesc.AlignedByteOffset = element.myAlignedByteOffset;
elementDesc.InputSlotClass = _ConvertInputClassificationDX12(element.myInputSlotClass);
elementDesc.Format = _ConvertFormatDX12(element.myFormat);
elementDesc.InstanceDataStepRate = element.myInstanceDataStepRate;
elements.push_back(elementDesc);
}
D3D12_INPUT_LAYOUT_DESC inputLayout = {};
inputLayout.NumElements = (UINT)elements.size();
inputLayout.pInputElementDescs = elements.data();
psoDesc.InputLayout = inputLayout;
}
// TOPOLOGY
switch (aPSODesc.topology)
{
default:
case EPrimitiveTopology::TriangleList:
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; // <--- Always this option
break;
case EPrimitiveTopology::PointList:
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
break;
case EPrimitiveTopology::LineList:
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
break;
//case EPrimitiveTopology::Patch:
// psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH;
// break;
}
// Shaders
if (aPSODesc.vs != nullptr)
{
D3D12_SHADER_BYTECODE vertexShaderBytecode = {};
vertexShaderBytecode.BytecodeLength = aPSODesc.vs->myByteCodeSize;
vertexShaderBytecode.pShaderBytecode = aPSODesc.vs->myByteCode;
psoDesc.VS = vertexShaderBytecode;
}
if (aPSODesc.ps != nullptr)
{
D3D12_SHADER_BYTECODE pixelShaderBytecode = {};
pixelShaderBytecode.BytecodeLength = aPSODesc.ps->myByteCodeSize;
pixelShaderBytecode.pShaderBytecode = aPSODesc.ps->myByteCode;
psoDesc.PS = pixelShaderBytecode;
}
psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; // format of the render target
DXGI_SAMPLE_DESC sampleDesc = {};
sampleDesc.Count = 1;
sampleDesc.Quality = 0;
psoDesc.DepthStencilState.DepthEnable = FALSE;
psoDesc.DepthStencilState.StencilEnable = FALSE;
psoDesc.SampleDesc = sampleDesc; // must be the same sample description as the swapchain and depth/stencil buffer
psoDesc.SampleMask = UINT_MAX; // sample mask has to do with multi-sampling. 0xffffffff means point sampling is done
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT); // a default rasterizer state.
psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT); // a default blent state.
psoDesc.NumRenderTargets = 1; // we are only binding one render target
psoDesc.pRootSignature = myGraphicsRootSignature;
psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
ID3D12PipelineState* pipelineState;
HRESULT hr = myDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipelineState));
pso->myPipelineState = pipelineState;
if (FAILED(hr))
{
delete pso;
return nullptr;
}
return pso;
最佳答案
所以我刚刚发现了错误。似乎我为我的输入布局解析语义的方式给了我一个无效的指针。因此地址处的内存是无效的并且给 DX12 设备不正确的描述。
所以我所做的是将语义名称本地存储在我的 CreatePSO 函数中,直到创建 PSO,现在一切正常。
关于c++ - E_INVALIDARG 调用 CreateGraphicsPipelineState 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51559227/
我正在调查一个 E_INVALIDARG 异常,当我尝试创建第二个常量缓冲区来存储我的灯光信息时抛出该异常: // create matrix stack early CD3D11_B
在 Directx 12 中创建管道状态对象失败并显示 E_INVALIDARG 并且调试层输出一堆废话说 D3D12_GRAPHICS_PIPELINE_STATE_DESC 实例中的数据无效: D
我在这里尝试做的只是创建一个接口(interface)的实例。真的应该这么简单。一直在关注任何在线资料,阅读我能找到但终生无法解决这个问题的资料。 它归结为从 CoCreateInstance 返回的
我将 DirectInput 与 Direct3D 11 一起使用,并针对 x64 进行编译,我从这一行得到一个 E_INVALIDARG: HRESULT hr = DirectInput8Crea
我有一个 ATL COM 组件,它引发一些由托管(C# 和 VB.NET)代码处理的事件。该组件当前由 VS2005 VB.NET 项目(作为 ActiveX 控件)使用,并且引发了所有事件并且一切正
我试图弄清楚为什么我在运行代码时总是收到 E_INVALIDARG 错误。 ID3D11Buffer * cbPerObjectBuffer; cbPerObject cbPerObj; cb
我正在使用 DirectX11 用 C++ 编写程序。现在我想从着色器开始,为此我还需要 ID3D11InputLayout //in main shader.Bind(DeviceContext);
我有以下代码: struct shaderData { char *shaderCode; UINT size; }; struct shaderData *CubeApp::GetS
我正在使用 MediaFoundation使用 SharpDX 对来自 desktop duplication frames 的视频文件进行编码. 我正在创建纹理并捕获屏幕。然后将此纹理传递给 MFC
创建 d3d11 设备和交换链的代码无法在某些计算机上运行并返回 E_INVALIDARG 错误。对于具有相同版本 DirectX 的计算机,这也有所不同。我似乎找不到不同行为的原因。 DXGI_MO
我在调用 CreateGraphicsPipelineState() 时遇到了一个奇怪的错误。该函数返回 E_INVALIDARG,即使描述已全部设置。 之前的描述有效,我尝试将 indexbuffe
我正在尝试用 C++ 初始化 Direct3D11。在安装了 Visual Studio 的机器上(所有这些都在 Windows 10 上运行),它运行良好。在其他计算机(未安装 Visual Stu
好吧,我已经迷路了几个小时了...... IXSLTemplate::putref_stylesheet 不记录除 E_FAIL 之外的任何错误。 但是在我的例子中 putref_stylesheet
问题 我正在尝试调用 ProcessOutput 以从我的解码器获取解码数据并出现以下错误: E_INVALIDARG One or more arguments are invalid. 我尝试过的
COM 接口(interface)方法可以返回各种 HRESULT 值来表示传递的参数值无效。我什么时候返回 E_POINTER 什么时候返回 E_INVALIDARG? 据我所知,如果一个方法在封装
我有以下调用,无论我尝试什么,hresult 总是 E_INVALIDARG: LogMessage(L"Creating swap chain. Emulation: " + std::to_wst
我有一个 WPF 应用程序。在构建它时出现以下错误: Could not load file or assembly or one of its dependencies. The parameter
运行带有函数 DCompositionCreateDevice2 的 Win32C++ 源代码时出现异常问题,这是用 VS 2015 编译的。 源代码编译没有任何错误,但显示上述运行时错误。用VS 2
我有一个 d3dDevice: ComPtrd3dDevice; 我在这里将它用于 dxgiDevice: ComPtr dxgiDevice2; HRESULT hr; hr
我正在尝试在 GPU 内存中创建缓冲区以从 CPU 上传数据。 GPU 访问将是只读的。数据将用作计算着色器的输入缓冲区。 CreateBuffer() 失败并出现错误 0x80070057 (E_I
我是一名优秀的程序员,十分优秀!