- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 DirectX 12 的新手,正在尝试在 DX 上渲染网格。到目前为止,我成功地从 obj 和 fbx 文件中检索顶点和索引,并使用模板通用窗口项目在 DX 12 上渲染所有顶点。但是,我遇到了索引缓冲区的一些问题,因为三角形列表的渲染结果完全不正确,尤其是当输入网格很大(数十万个顶点)时。基本上,索引数据被写成一个指针数组,看起来是正确的。使用线列表基元拓扑,渲染结果如下图所示。 Line list primitive topology rendering result
我想知道是否有人可以给出任何代码中可能出错的建议。对于 IBV 设置,我使用的是模板项目中的确切代码。提前感谢您的帮助。
更新:数据为使用FBX SDK获取的obj文件数据。我确认了 obj 网格信息和检索到的数据,它们是精确匹配的。所以我认为数据文件是正确的。此外,对于IBV设置传入的数据,如缓冲区字节大小,也是正确的。对于代码,它来自 VS DX 12 模板通用 windows 项目,如下所示。非常感谢您的帮助。
// Create the index buffer resource in the GPU's default heap and copy index data into it using the upload heap.
// The upload resource must not be released until after the GPU has finished using it.
Microsoft::WRL::ComPtr<ID3D12Resource> indexBufferUpload;
//CD3DX12_RESOURCE_DESC indexBufferDesc = CD3DX12_RESOURCE_DESC::Buffer(indexBufferSize);
DX::ThrowIfFailed(d3dDevice->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(defaultHeapProperties),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(indexBufferSize),
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr,
IID_PPV_ARGS(&m_indexBuffer)));
DX::ThrowIfFailed(d3dDevice->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(indexBufferSize),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&indexBufferUpload)));
m_indexBuffer->SetName(L"Index Buffer Resource");
indexBufferUpload->SetName(L"Index Buffer Upload Resource");
// Upload the index buffer to the GPU.
{
D3D12_SUBRESOURCE_DATA indexData = {0};
//indexData.pData = cubeIndices;
indexData.pData = reinterpret_cast<BYTE*>(cubeIndices);
indexData.RowPitch = indexBufferSize;
indexData.SlicePitch = indexData.RowPitch;
UpdateSubresources(m_commandList.Get(), m_indexBuffer.Get(), indexBufferUpload.Get(), 0, 0, 1, &indexData);
CD3DX12_RESOURCE_BARRIER indexBufferResourceBarrier =
CD3DX12_RESOURCE_BARRIER::Transition(m_indexBuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_INDEX_BUFFER);
//CD3DX12_RESOURCE_BARRIER indexBufferResourceBarrier =
// CD3DX12_RESOURCE_BARRIER::Transition(m_indexBuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
m_commandList->ResourceBarrier(1, &indexBufferResourceBarrier);
}
// Create a descriptor heap for the constant buffers.
{
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.NumDescriptors = DX::c_frameCount;
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
// This flag indicates that this descriptor heap can be bound to the pipeline and that descriptors contained in it can be referenced by a root table.
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
DX::ThrowIfFailed(d3dDevice->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&m_cbvHeap)));
m_cbvHeap->SetName(L"Constant Buffer View Descriptor Heap");
}
CD3DX12_RESOURCE_DESC constantBufferDesc = CD3DX12_RESOURCE_DESC::Buffer(DX::c_frameCount * c_alignedConstantBufferSize);
DX::ThrowIfFailed(d3dDevice->CreateCommittedResource(
&uploadHeapProperties,
D3D12_HEAP_FLAG_NONE,
&constantBufferDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&m_constantBuffer)));
m_constantBuffer->SetName(L"Constant Buffer");
// Create constant buffer views to access the upload buffer.
D3D12_GPU_VIRTUAL_ADDRESS cbvGpuAddress = m_constantBuffer->GetGPUVirtualAddress();
CD3DX12_CPU_DESCRIPTOR_HANDLE cbvCpuHandle(m_cbvHeap->GetCPUDescriptorHandleForHeapStart());
m_cbvDescriptorSize = d3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
for (int n = 0; n < DX::c_frameCount; n++)
{
D3D12_CONSTANT_BUFFER_VIEW_DESC desc;
desc.BufferLocation = cbvGpuAddress;
desc.SizeInBytes = c_alignedConstantBufferSize;
d3dDevice->CreateConstantBufferView(&desc, cbvCpuHandle);
cbvGpuAddress += desc.SizeInBytes;
cbvCpuHandle.Offset(m_cbvDescriptorSize);
}
// Map the constant buffers.
DX::ThrowIfFailed(m_constantBuffer->Map(0, nullptr, reinterpret_cast<void**>(&m_mappedConstantBuffer)));
ZeroMemory(m_mappedConstantBuffer, DX::c_frameCount * c_alignedConstantBufferSize);
// We don't unmap this until the app closes. Keeping things mapped for the lifetime of the resource is okay.
// Close the command list and execute it to begin the vertex/index buffer copy into the GPU's default heap.
DX::ThrowIfFailed(m_commandList->Close());
ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() };
m_deviceResources->GetCommandQueue()->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);
// Create vertex/index buffer views.
m_vertexBufferView.BufferLocation = m_vertexBuffer->GetGPUVirtualAddress();
m_vertexBufferView.StrideInBytes = sizeof(VertexPositionColorTexture);
m_vertexBufferView.SizeInBytes = sizeof(*cubeVertices) * m_VertexNumber;
m_indexBufferView.BufferLocation = m_indexBuffer->GetGPUVirtualAddress();
m_indexBufferView.SizeInBytes = sizeof(*cubeIndices) * m_VertxIndicesNumber;
m_indexBufferView.Format = DXGI_FORMAT_R16_UINT;
// Wait for the command list to finish executing; the vertex/index buffers need to be uploaded to the GPU before the upload resources go out of scope.
m_deviceResources->WaitForGpu();
最佳答案
我实际上和 Michael 一起工作,所以我知道这个问题的答案:)。我会把它张贴在这里,供偶然发现这篇文章的人使用。
当有超过 140000 个索引时,问题确实是使用 16 位(unsigned short)索引。最大 unsigned short 为 65535。解决方案是使用格式为 DXGI_FORMAT_R32_UINT 的 32 位索引(unsigned int)。
关于indices - DirectX 12 索引缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34024007/
我有一个 TableView,每个单元格的附件都设置为“披露指示器”,它工作正常。 然后,我决定在使用外部来源的数据更新每个单元格时添加一个事件指示器。为此,我设置了: cell.accessoryV
我正在尝试遵循来自 here 的公认解决方案在 Xcode 6.3.2 上,但指示器拒绝显示,或者由于某种原因我在 iPhone 6 plus 上看不到它。没有错误消息、带有标题的警告等显示,并且空白
我的 JavaFX 应用程序计算另一个文件夹下一层的每个文件夹的大小。我的问题是,当我点击“应用”按钮(该按钮在另一个类中开始计算)时,我想要一个不确定的进度指示器来向用户显示该应用程序正在运行并且尚
One of the biggest causes of instability in Elasticsearch is fielddata: field values have to be load
我在实验宇宙学中做一些模拟,在使用 numpy 数组时遇到了这个问题。我是 numpy 的新手,所以我不确定我是否做错了或者这是一个错误。我跑: Enthought Python Distributi
我有一个结构数组,这些结构基本上是形成一条边的两个点。由于性能,我使用结构。 现在我有对象 A 保存边缘和这个对象中的一个方法来告诉另一个对象 B 关于这个边缘数组中的连续边缘列表。 边缘: e0 e
我正在使用 Elasticsearch ( Official PHP client) 开发一个 PHP 网站。 我正在编写需要确定新插入文档的测试在继续之前准备好搜索。 为此,在索引新文档后,我调用:
我是 DirectX 12 的新手,正在尝试在 DX 上渲染网格。到目前为止,我成功地从 obj 和 fbx 文件中检索顶点和索引,并使用模板通用窗口项目在 DX 12 上渲染所有顶点。但是,我遇到了
我是 DirectX 12 的新手,正在尝试在 DX 上渲染网格。到目前为止,我成功地从 obj 和 fbx 文件中检索顶点和索引,并使用模板通用窗口项目在 DX 12 上渲染所有顶点。但是,我遇到了
我正在使用 StratifiedKFold 创建用于拆分数据的索引。它给了我索引超出范围的错误。 Xdev的索引从0到47503。 cv_index 变量的 min 和 max 索引分别为 0 和 1
我想绘制以下 UIPageControl 指示器: 我目前有以下代码,结果是: if (isHighlighted) { UIBezierPath *ovalPath = [UIBezierP
我们在以下用例中使用 elasticsearch。 Elasticsearch 版本:5.1.1 注意:我们使用的是 AWS 托管的 ElasticSearch 我们有一个 Multi-Tenancy
我正在尝试使用 scikit-learn 中的算法根据大量输入来预测输出。我似乎收到错误“索引过多”,但无法弄清楚原因。 CSV 文件训练: 1.1 0.2 0.1 0 0.12 0
在this page的底部从 Python 2.3 文档中它说: slice objects now have a method indices(length) which, given the le
我在主线程上做一些繁重的计算,这些计算不能在单独的线程上运行。 我想在这些计算运行时在应用程序 UI 上显示一个“忙碌指示器”(即旋转小部件)。因此,我无法在主线程上显示繁忙指示器,因为在这些计算运行
我有一个名为 memory_region 的类,有点像未类型化的 gsl::span (即它本质上是一个 void* 和一个 size_t ),我也将其用于类型删除。因此它有一个 as_span()方
我一直在寻找如何将 Tablayout 中的指示器更改为圆形,就像这样 但我不知道该怎么做,任何帮助! 最佳答案 来自source code ,标签指示器定义为: @dimen/de
我在哪里可以找到可绘制的 Android“向上”按钮以便我可以对其进行自定义?或者它的文件名是什么,以便我可以快速搜索以在 sdk 目录中找到它? 最佳答案 正如您在 default style 中看
我遇到了 ViewPager 的另一个问题,我现在无法用我目前的知识解决它。 我有带 ViewPager 的 TabPageIndicator,在每个选项卡上,我都显示文本。这是简单的 TextVie
我将如何制作一个自定义指示器,该指示器将使用可绘制对象和用于 SwipeRefreshLayout 的自定义动画? 我查看了 SwipeRefreshLayout 的源代码,发现 CircleImag
我是一名优秀的程序员,十分优秀!