• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By lubbe75
      As far as I understand there is no real random or noise function in HLSL. 
      I have a big water polygon, and I'd like to fake water wave normals in my pixel shader. I know it's not efficient and the standard way is really to use a pre-calculated noise texture, but anyway...
      Does anyone have any quick and dirty HLSL shader code that fakes water normals, and that doesn't look too repetitious? 
    • By turanszkij
      Hi,
      I finally managed to get the DX11 emulating Vulkan device working but everything is flipped vertically now because Vulkan has a different clipping space. What are the best practices out there to keep these implementation consistent? I tried using a vertically flipped viewport, and while it works on Nvidia 1050, the Vulkan debug layer is throwing error messages that this is not supported in the spec so it might not work on others. There is also the possibility to flip the clip scpace position Y coordinate before writing out with vertex shader, but that requires changing and recompiling every shader. I could also bake it into the camera projection matrices, though I want to avoid that because then I need to track down for the whole engine where I upload matrices... Any chance of an easy extension or something? If not, I will probably go with changing the vertex shaders.
    • By NikiTo
      Some people say "discard" has not a positive effect on optimization. Other people say it will at least spare the fetches of textures.
       
      if (color.A < 0.1f) { //discard; clip(-1); } // tons of reads of textures following here // and loops too
      Some people say that "discard" will only mask out the output of the pixel shader, while still evaluates all the statements after the "discard" instruction.

      MSN>
      discard: Do not output the result of the current pixel.
      clip: Discards the current pixel..
      <MSN

      As usual it is unclear, but it suggests that "clip" could discard the whole pixel(maybe stopping execution too)

      I think, that at least, because of termal and energy consuming reasons, GPU should not evaluate the statements after "discard", but some people on internet say that GPU computes the statements anyways. What I am more worried about, are the texture fetches after discard/clip.

      (what if after discard, I have an expensive branch decision that makes the approved cheap branch neighbor pixels stall for nothing? this is crazy)
    • By NikiTo
      I have a problem. My shaders are huge, in the meaning that they have lot of code inside. Many of my pixels should be completely discarded. I could use in the very beginning of the shader a comparison and discard, But as far as I understand, discard statement does not save workload at all, as it has to stale until the long huge neighbor shaders complete.
      Initially I wanted to use stencil to discard pixels before the execution flow enters the shader. Even before the GPU distributes/allocates resources for this shader, avoiding stale of pixel shaders execution flow, because initially I assumed that Depth/Stencil discards pixels before the pixel shader, but I see now that it happens inside the very last Output Merger state. It seems extremely inefficient to render that way a little mirror in a scene with big viewport. Why they've put the stencil test in the output merger anyway? Handling of Stencil is so limited compared to other resources. Does people use Stencil functionality at all for games, or they prefer discard/clip?

      Will GPU stale the pixel if I issue a discard in the very beginning of the pixel shader, or GPU will already start using the freed up resources to render another pixel?!?!



       
    • By Axiverse
      I'm wondering when upload buffers are copied into the GPU. Basically I want to pool buffers and want to know when I can reuse and write new data into the buffers.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX12 [D3D12] Root Signature Reflection

This topic is 553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get a shader's root signature via reflection so that I can validate what I'm setting.

 

First of all, this page for D3D12CreateRootSignatureDeserializer says that the function has been superceded by D3D12CreateVersionedRootSignatureDeserializer, but I apparently don't have that function in my DirectX 12 header/lib?

 

Regardless, I tried calling D3D12CreateRootSignatureDeserializer as follows:

.

ComPtr<ID3D12RootSignatureDeserializer> deserializer;
D3D12CreateRootSignatureDeserializer(blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&deserializer));
D3D12_ROOT_SIGNATURE_DESC *desc = (D3D12_ROOT_SIGNATURE_DESC *)deserializer->GetRootSignatureDesc();

.

But this crashes, because the ID3D12RootSignatureDeserializer pointer returned is null.  "blob" in that code is a ComPtr<ID3DBlob> returned by D3DCompileFromFile, and that part is working fine (I can compile and render using the shader, I just can't get the root signature via reflection).  I'm not sure if the blob is the correct thing to pass, as the documentation only says "If an application has a serialized root signature already or has a compiled shader that contains a root signature and wants to determine the layout definition, it can call D3D12CreateRootSignatureDeserializer to generate a ID3D12RootSignatureDeserializer interface."

 

Anyone have any experience with either of these two issues?

Share this post


Link to post
Share on other sites
Advertisement

D3D12CreateRootSignatureDeserializer returns an HRESULT. What's the result of calling the function? If you're getting back a null pointer, it's probably not success.

 

Are you sure that the blob you're passing in is/contains a root signature? It should either be a blob retrieved from D3D12SerializeRootSignature or the result of compiling a shader whose entrypoint is marked with the [RootSignature] attribute.

Share this post


Link to post
Share on other sites

The function returns E_INVALIDARG.  I'm trying to call this with a compiled shader (ie the resulting blob from D3DCompileFromFile).  I'm not specifying the RootSignature in the HLSL directly, I'm creating it in the C++ code and passing it to the pipeline state.

 

Seeing as misaligning the root signature on purpose causes an error telling me I'm binding the wrong descriptor table type (for example), it seems like the implicit root signature in the compiled shader is known.  How do I get it via reflection?

Share this post


Link to post
Share on other sites

Seeing as misaligning the root signature on purpose causes an error telling me I'm binding the wrong descriptor table type (for example), it seems like the implicit root signature in the compiled shader is known.  How do I get it via reflection?

 

As far as I'm aware you won't be able to retrieve a root signature from your bytecode if you don't explicitly define it in your shader code.

One type of validation you could do is to get information of SRV/CBV/UAV/Sampler bindings using shader reflection. You can cross-reference this data against your root signature to see whether the root signature has the appropriate descriptors, descriptor tables, constants or static samplers to support your shader.

 

Other than doing that I don't think you can actually extract explicit root signature information out of a shader without defining it in your HLSL code.

Share this post


Link to post
Share on other sites

It's not a root signature in the shader.

 

The shader declares registers. The root signature declares root parameters, and a mapping from those parameters to shader registers. The runtime does validation that the root signature declares exactly one root parameter which covers every shader register that the shader uses.

 

To reflect shader registers, you use ID3D12ShaderReflection.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement