Jump to content
  • Advertisement
Sign in to follow this  
Koen

DX11 geometry shaders and input patches

Recommended Posts

Has anyone ever tried to draw with one of the D3D11_PRIMITIVE_TOPOLOGY_XX_CONTROL_POINT_PATCHLIST primitive topologies, when only a vertex, geometry and pixel shader are active? Practical Rendering and Computation with Direct3D 11microsoft's documentation for the InputPatch hlsl type and this (old) blog post seem to suggest it should be possible. But when I try, an error occurs when drawing:

D3D11 ERROR: ID3D11DeviceContext::Draw: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not D3D11_SO_NO_RASTERIZED_STREAM) but the input topology is Patch Control Points.  You need either a Hull Shader and Domain Shader, or a Geometry Shader. [ EXECUTION ERROR #349: DEVICE_DRAW_INPUTLAYOUT_NOT_SET]
D3D11: **BREAK** enabled for the previous message, which was: [ ERROR EXECUTION #349: DEVICE_DRAW_INPUTLAYOUT_NOT_SET ]

I'm sure I did bind a geometry shader (and renderdoc agrees with me 😉).

The OpenGL and Vulkan documentation seem to explicitly *not* allow this, though, so maybe it's simply not possible 🙂 If you've ever managed to do this, were there some special details to take into account to get it working? Thanks!

 

PS: for completeness, here's my test shader code, although I don't think it does anything special:

//
// vertex shader
//

struct VertexShaderInputData {
  float4 pos : position;
};
struct VertexShaderOutputData {
  float4 pos : position;
};
VertexShaderOutputData vs_main(VertexShaderInputData inputData) {
  VertexShaderOutputData outputData;
  outputData.pos = inputData.pos; 
  return outputData;
}

//
// geometry shader
//

struct GeometryShaderInputData {
  float4 pos : position;
};
struct GeometryShaderOutputData {
  float4 pos : SV_Position;
};
[maxvertexcount(8)]
void gs_main(in InputPatch<GeometryShaderInputData, 8> inputData,
             uint input_patch_id : SV_PrimitiveID,
             uint gs_instance_id : SV_GSInstanceID,
             inout TriangleStream<GeometryShaderOutputData> output_stream) {
  GeometryShaderOutputData output_vertex;

  output_vertex.pos = inputData[0].pos;
  output_stream.Append(output_vertex);
  ...and so on...
}

//
// pixel shader
//

struct PixelShaderOutputData {
  float4 color : SV_Target0;
};
PixelShaderOutputData main() {
  PixelShaderOutputData outputData;
  outputData.color = float4(1.0,1.0,1.0,1.0); 
  return outputData;
}

 

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!