diff options
Diffstat (limited to 'src/platform/vulkan/vulkan_common.h')
| -rw-r--r-- | src/platform/vulkan/vulkan_common.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/platform/vulkan/vulkan_common.h b/src/platform/vulkan/vulkan_common.h index 22d389c..ead4d1f 100644 --- a/src/platform/vulkan/vulkan_common.h +++ b/src/platform/vulkan/vulkan_common.h @@ -187,6 +187,9 @@ namespace Donut::RHI auto bind_pipeline(Pipeline* p) -> void override { m_pipe = static_cast<VkPipelineR*>(p); + // a pipeline whose shaders never loaded has no vk object; binding a null + // handle is driver roulette, so skip it and let draw() skip too + if (!m_pipe || m_pipe->m_pipeline == VK_NULL_HANDLE) { m_pipe = nullptr; return; } vkCmdBindPipeline(m_cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipe->m_pipeline); } auto set_viewport(int x, int y, int w, int h, bool flip_y) -> void override @@ -216,9 +219,9 @@ namespace Donut::RHI auto bind_index_buffer(Buffer* ib) -> void override { vkCmdBindIndexBuffer(m_cmd, static_cast<VkBufferR*>(ib)->m_buf, 0, VK_INDEX_TYPE_UINT32); } auto draw(uint32_t vertex_count) -> void override - { flush_descriptors(); vkCmdDraw(m_cmd, vertex_count, 1, 0, 0); } + { if (!m_pipe) return; flush_descriptors(); vkCmdDraw(m_cmd, vertex_count, 1, 0, 0); } auto draw_indexed(uint32_t index_count) -> void override - { flush_descriptors(); vkCmdDrawIndexed(m_cmd, index_count, 1, 0, 0, 0); } + { if (!m_pipe) return; flush_descriptors(); vkCmdDrawIndexed(m_cmd, index_count, 1, 0, 0, 0); } // allocate + write + bind a descriptor set for the current pipeline's // declared resources, using whatever was bound since bind_pipeline. |
