@@ -1638,6 +1638,16 @@ class DXDevice : public offloadtest::Device {
16381638 if (auto Err = CreateBuffer (Resource, IS .RootResources ))
16391639 return Err;
16401640 }
1641+
1642+ if (P.isTraditionalRaster () && P.Bindings .VertexBufferPtr ) {
1643+ auto VBOrErr = offloadtest::createVertexBufferFromCPUBuffer (
1644+ *this , *P.Bindings .VertexBufferPtr );
1645+ if (!VBOrErr)
1646+ return VBOrErr.takeError ();
1647+ IS .VB = std::move (*VBOrErr);
1648+ llvm::outs () << " Vertex buffer created.\n " ;
1649+ }
1650+
16411651 return llvm::Error::success ();
16421652 }
16431653
@@ -1911,39 +1921,11 @@ class DXDevice : public offloadtest::Device {
19111921 return llvm::Error::success ();
19121922 }
19131923
1914- llvm::Error createVertexBuffer (Pipeline &P, InvocationState &IS ) {
1915- if (!P.Bindings .VertexBufferPtr )
1916- return llvm::createStringError (
1917- std::errc::invalid_argument,
1918- " No vertex buffer bound for graphics pipeline." );
1919-
1920- auto VBOrErr = offloadtest::createVertexBufferFromCPUBuffer (
1921- *this , *P.Bindings .VertexBufferPtr );
1922- if (!VBOrErr)
1923- return VBOrErr.takeError ();
1924- IS .VB = std::move (*VBOrErr);
1925-
1926- auto &VBBuf = llvm::cast<DXBuffer>(*IS .VB );
1927- D3D12_VERTEX_BUFFER_VIEW VBView = {};
1928- VBView.BufferLocation = VBBuf.Buffer ->GetGPUVirtualAddress ();
1929- VBView.SizeInBytes = static_cast <UINT >(IS .VB ->getSizeInBytes ());
1930- VBView.StrideInBytes = P.Bindings .getVertexStride ();
1931-
1932- IS .CB ->CmdList ->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
1933- IS .CB ->CmdList ->IASetVertexBuffers (0 , 1 , &VBView);
1934-
1935- return llvm::Error::success ();
1936- }
1937-
19381924 llvm::Error createGraphicsCommands (Pipeline &P, InvocationState &IS ) {
19391925 auto &RT = llvm::cast<DXTexture>(*IS .RT );
19401926 auto &DS = llvm::cast<DXTexture>(*IS .DS );
19411927 auto &RTReadback = llvm::cast<DXBuffer>(*IS .RTReadback );
19421928
1943- if (!IS .VB )
1944- return llvm::createStringError (std::errc::invalid_argument,
1945- " Vertex buffer not initialized." );
1946-
19471929 const DXPipelineState &DXPipeline =
19481930 llvm::cast<DXPipelineState>(*IS .Pipeline .get ());
19491931 IS .CB ->CmdList ->SetGraphicsRootSignature (DXPipeline.RootSig .Get ());
@@ -1981,6 +1963,17 @@ class DXDevice : public offloadtest::Device {
19811963 static_cast <LONG >(VP .Height )};
19821964 IS .CB ->CmdList ->RSSetScissorRects (1 , &Scissor);
19831965
1966+ if (IS .VB ) {
1967+ auto &VBBuf = llvm::cast<DXBuffer>(*IS .VB );
1968+ D3D12_VERTEX_BUFFER_VIEW VBView = {};
1969+ VBView.BufferLocation = VBBuf.Buffer ->GetGPUVirtualAddress ();
1970+ VBView.SizeInBytes = static_cast <UINT >(IS .VB ->getSizeInBytes ());
1971+ VBView.StrideInBytes = P.Bindings .getVertexStride ();
1972+ IS .CB ->CmdList ->IASetVertexBuffers (0 , 1 , &VBView);
1973+ }
1974+
1975+ IS .CB ->CmdList ->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
1976+
19841977 IS .CB ->CmdList ->DrawInstanced (P.getVertexCount (), 1 , 0 , 0 );
19851978
19861979 // Transition the render target to copy source and copy to the readback
@@ -2108,9 +2101,6 @@ class DXDevice : public offloadtest::Device {
21082101 if (auto Err = createDepthStencil (P, State))
21092102 return Err;
21102103 llvm::outs () << " Depth stencil created.\n " ;
2111- if (auto Err = createVertexBuffer (P, State))
2112- return Err;
2113- llvm::outs () << " Vertex buffer created.\n " ;
21142104
21152105 ShaderContainer VS = {};
21162106 ShaderContainer PS = {};
0 commit comments