[D3D12] What's wrong with this app design?

Started by
6 comments, last by ngub05 8 years, 1 month ago

Here's the brief design of my d3d12 app which loads an image an displays it on screen.

After InitializeWindow(), I initialize D3D (InitD3D), then Render() and receive widow messages in a loop.

InitD3D()

debug layer
device create
create CQ
create SwapChain
RTv desc heap
point RTV to swap chainback buffers
create CA
creata and close CL
create fence per frame
create one fence event

Render()
wait for gpu to finish
reset CA
reset cL
UploadTexturedataFromFile()
resource barrier: present to RT
record CL = {get RTVhandle, OMsetrendertarget(), clearRTV}
resource barrier: RT to present
CL close()
CQ execute CL
CQ signal
swapchain->Present()
UploadTexturedataFromFile()
-loads an image using WIC
-copy pixels data
-created upload an default heaps.
-commandlist-copytexturearea from upload to default.

As you can see I haven't set up a root signature and pso. It's because I'm not calling DrawInstanced() in my render. My understanding is that if I point RTV to swap chainback buffers and call OMsetrendertarget(), I only need to call Present() to display my image.

Is this wrong? If yes, Is it necessary that I should set up a basic root signature and pso and call DrawInstanced() ?

PS: I started graphics programming recently with dx12.

Advertisement

Now you only clear the screen. To see the image you need to draw it to the screen. Uploading the texture to the GPU only makes it available for the GPU to render with, it does not show it to the screen.

On the other hand, i just started with Dx12 myself so i do not know that much myself :). Check out my Dx12 notes at http://www.gamedevpensieve.com/graphics/graphic-api/directx12.

@spinningcubes | Blog: Spinningcubes.com | Gamedev notes: GameDev Pensieve | Spinningcubes on Youtube

Can someone expain, what exactly will be happening when i call DrawInstanced(). Should it be called before ExecuteCommandLists()? Why? I'm missing some very important concepts here..

you use the command list to create commands, which get stored in a list, called a command list. drawinstanced is a command, so when you call that, a draw command is put into the command list. you call executecommandlists to actually execute the commands in that list. So yes, you need to call drawinstanced before you call executecommandlists

ok, i just read your first post, it looks like your doing something you definitely do not want to do. you are loading a texture from a file every frame, then uploading it to the gpu? thats a no no. You need to load the texture once when you need it, either at initialization time if you need it right away, or later when you come across it in your world. once its loaded from the file, you upload it once, and keep it on the gpu until you are finished with it.


I haven't set up a root signature and pso. It's because

You need a root signature/pso to draw things with a shader. If you're just copyresourceing a texture onto the swap chain I suppose you don't... but at that point you're just making an image compositor.

i didn't even see that part. Yeah, if you want to use the pipeline, you need at least a pso and pso's need a root signature, even if its a default empty root signature. If you want to draw something onto a render target, you need at least a vertex and pixel shader in your pso. if you are only using the pipeline up to the stream output stage, you only need a vertex shader.

basically the only thing you can do without a pso is clear the render target, or manage and move around resources on the gpu, since thats not actually part of the graphics pipeline. If you want to use any part of the graphics pipeline though (input assembler to output merger stage (or to stream output stage)), you do need a pso (which again needs a root signature).

Thanks for your time and patience. Cleared my doubts :)

This topic is closed to new replies.

Advertisement