Added Vulkan versions of KRVBOData::bind and KRPipeline::bind

This commit is contained in:
2022-02-28 01:07:32 -08:00
parent a26ee33e4c
commit 6a56c9ebfe
5 changed files with 18 additions and 7 deletions

View File

@@ -809,6 +809,13 @@ void KRMeshManager::KRVBOData::bind()
#endif
}
void KRMeshManager::KRVBOData::bind(VkCommandBuffer& commandBuffer)
{
VkBuffer vertexBuffers[] = { getVertexBuffer() };
VkDeviceSize offsets[] = { 0 };
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
}
void KRMeshManager::KRVBOData::resetPoolExpiry(float lodCoverage)
{
long current_frame = m_manager->getContext().getCurrentFrame();

View File

@@ -96,6 +96,7 @@ public:
void load();
void unload();
void bind();
void bind(VkCommandBuffer& commandBuffer);
// Disable copy constructors
KRVBOData(const KRVBOData& o) = delete;

View File

@@ -548,6 +548,11 @@ void KRPipeline::setUniform(int location, const Matrix4 &value)
}
}
void KRPipeline::bind(VkCommandBuffer& commandBuffer)
{
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline);
}
bool KRPipeline::bind(KRCamera &camera, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color) {
if(m_iProgram == 0) {
return false;

View File

@@ -51,6 +51,7 @@ public:
const char *getKey() const;
bool bind(KRCamera &camera, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
void bind(VkCommandBuffer& commandBuffer);
enum {
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,

View File

@@ -168,11 +168,8 @@ void KRPresentationThread::renderFrame()
if (haveMesh) {
KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(surface, "vulkan_test", testVertices.getVertexAttributes());
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, testPipeline->getPipeline());
VkBuffer vertexBuffers[] = { testVertices.getVertexBuffer() };
VkDeviceSize offsets[] = { 0 };
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
testPipeline->bind(commandBuffer);
testVertices.bind(commandBuffer);
vkCmdDraw(commandBuffer, 3, 1, 0, 0);
}