From 7d1be415c6fd83468ede3641ffc07cfc06a6e9f9 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 16 Oct 2018 17:26:07 -1000 Subject: [PATCH] Fix tessellation pipeline setup --- lib/graphicsdev/D3D11.cpp | 3 +++ lib/graphicsdev/GL.cpp | 35 ++++++++++++++++++++--------------- lib/graphicsdev/Vulkan.cpp | 5 ++++- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index cc16275..6cf56bd 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -588,6 +588,9 @@ class D3D11ShaderPipeline : public GraphicsDataNode if (auto* s = evaluation.cast()) s->shader(m_dShader); + if (control && evaluation) + m_topology = D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + info.patchSize - 1; + D3D11_CULL_MODE cullMode; switch (info.culling) { diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 5777b95..367b7f3 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -839,7 +839,11 @@ protected: CullMode m_culling; uint32_t m_patchSize = 0; mutable GLint m_uniLocs[BOO_GLSL_MAX_UNIFORM_COUNT]; - GLShaderPipeline(const ObjToken& parent, const AdditionalPipelineInfo& info) + GLShaderPipeline(const ObjToken& parent, + ObjToken vertex, ObjToken fragment, + ObjToken geometry, ObjToken control, + ObjToken evaluation, const VertexFormatInfo& vtxFmt, + const AdditionalPipelineInfo& info) : GraphicsDataNode(parent) { std::fill(std::begin(m_uniLocs), std::end(m_uniLocs), -1); @@ -865,6 +869,19 @@ protected: m_culling = info.culling; m_drawPrim = PRIMITIVE_TABLE[int(info.prim)]; m_patchSize = info.patchSize; + + m_vertex = vertex; + m_fragment = fragment; + m_geometry = geometry; + m_control = control; + m_evaluation = evaluation; + + if (control && evaluation) + m_drawPrim = GL_PATCHES; + + m_elements.reserve(vtxFmt.elementCount); + for (size_t i=0 ; i vertex, ObjToke int(factory.m_maxPatchSize), int(additionalInfo.patchSize)); } - ObjToken retval(new GLShaderPipeline(m_data, additionalInfo)); - GLShaderPipeline& shader = *retval.cast(); - - shader.m_vertex = vertex; - shader.m_fragment = fragment; - shader.m_geometry = geometry; - shader.m_control = control; - shader.m_evaluation = evaluation; - - shader.m_elements.reserve(vtxFmt.elementCount); - for (size_t i=0 ; i diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index c914aab..6e46c3a 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -2230,7 +2230,10 @@ protected: m_colorWrite(info.colorWrite), m_alphaWrite(info.alphaWrite), m_overwriteAlpha(info.overwriteAlpha), m_culling(info.culling), m_patchSize(info.patchSize) - {} + { + if (control && evaluation) + m_prim = Primitive::Patches; + } public: ~VulkanShaderPipeline() {