First, I want to thank iedoc and Juliean
That was my ridiculous mistake when quickly copy and paste
Actuallly, I was working on a bigger project, porting that project from D3D11 to D3D12 and met such an issue. Do not know why it could not render anything to screen. Because resource is huge, I can not upload it all here.
I am sure that I set m_viewport and m_scissorRect already on that project
. Here is my work:
- On init: (using commandlist 1, commandAllocator1)
+Create Vertex buffer (default heap and upload heap)
+Execute commandlist
+Sleep(1000): maybe do not need but just to make sure init command was finished on GPU before render.
- On Render: (using commandlist 2, commandAllocator 2, same commandQueue)
+Transition Vertex buffer from COPY_DEST to VERTEX_BUFFER
+Transition backbuffer to PRESENT to RENDER_TARGET
+OMSetRenderTargets
+ClearRendertarget
+SetViewport and scissor (sure it has value)
+SetGraphicsRootSignature and PipelineState (using same root and pipeline as above example because I just want to draw triangle, VertexShader use position as float3 and inputlayout is float3 also)
+IASetVertexBuffers
+IASetPrimitiveTopology
+DrawInstanced
+Transition backbuffer to RENDER_TARGET to PRESENT
+Execute commandlist
+Present()
+Update frame index
- I can see clear color, if I set clear color different each frame and set break point at present(), i can see it changed color each times but no triangles. Could you guys please show me if i miss any step.
Note: Sometimes, I can see that triangles blink at first launch and disappear.