Avoid draw calls when any push constants are not set.
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -134,9 +134,9 @@ void KRAmbientZone::render(RenderInfo& ri)
|
|||||||
info.vertexAttributes = sphereModel->getVertexAttributes();
|
info.vertexAttributes = sphereModel->getVertexAttributes();
|
||||||
|
|
||||||
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pPipeline->bind(ri, sphereModelMatrix);
|
if (pPipeline->bind(ri, sphereModelMatrix)) {
|
||||||
|
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
}
|
||||||
} // sphereModel
|
} // sphereModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ void KRAudioSource::render(RenderInfo& ri)
|
|||||||
info.vertexAttributes = sphereModel->getVertexAttributes();
|
info.vertexAttributes = sphereModel->getVertexAttributes();
|
||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->bind(ri, sphereModelMatrix);
|
if (pShader->bind(ri, sphereModelMatrix)) {
|
||||||
|
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
}
|
||||||
} // sphereModels.size()
|
} // sphereModels.size()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ void KRBone::render(RenderInfo& ri)
|
|||||||
info.vertexAttributes = sphereModel->getVertexAttributes();
|
info.vertexAttributes = sphereModel->getVertexAttributes();
|
||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->bind(ri, sphereModelMatrix);
|
if (pShader->bind(ri, sphereModelMatrix)) {
|
||||||
|
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
}
|
||||||
} // sphereModel
|
} // sphereModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,11 +167,12 @@ void KRCamera::render(KRNode::RenderInfo& ri)
|
|||||||
|
|
||||||
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pPipeline->setImageBinding("diffuseTexture", m_skyBox.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
pPipeline->setImageBinding("diffuseTexture", m_skyBox.val.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
||||||
pPipeline->bind(ri, Matrix4());
|
if (pPipeline->bind(ri, Matrix4())) {
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
||||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
@@ -631,11 +632,12 @@ void KRCamera::renderDebug(RenderInfo& ri)
|
|||||||
KRPipeline* fontShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* fontShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
fontShader->setImageBinding("fontTexture", fontTexture, getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
fontShader->setImageBinding("fontTexture", fontTexture, getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
||||||
fontShader->bind(ri, Matrix4());
|
if (fontShader->bind(ri, Matrix4())) {
|
||||||
|
|
||||||
m_debug_text_vbo_data.bind(ri.commandBuffer);
|
m_debug_text_vbo_data.bind(ri.commandBuffer);
|
||||||
|
|
||||||
vkCmdDraw(ri.commandBuffer, vertex_count, 1, 0, 0);
|
vkCmdDraw(ri.commandBuffer, vertex_count, 1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
m_debug_text_vertices.unlock();
|
m_debug_text_vertices.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,9 +222,9 @@ void KRCollider::render(RenderInfo& ri)
|
|||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
pShader->bind(ri, getModelMatrix());
|
if (pShader->bind(ri, getModelMatrix())) {
|
||||||
|
m_model.val.get()->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
m_model.val.get()->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
}
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,11 +160,11 @@ void KRDirectionalLight::render(RenderInfo& ri)
|
|||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->setPushConstant(ShaderValue::light_direction_view_space, light_direction_view_space);
|
pShader->setPushConstant(ShaderValue::light_direction_view_space, light_direction_view_space);
|
||||||
pShader->bind(ri, getModelMatrix()); // TODO: Need to pass in the light index to the shader
|
if (pShader->bind(ri, getModelMatrix())) { // TODO: Need to pass in the light index to the shader
|
||||||
|
// Render a full screen quad
|
||||||
// Render a full screen quad
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ri.reflectedObjects.pop_back();
|
ri.reflectedObjects.pop_back();
|
||||||
|
|||||||
@@ -185,18 +185,18 @@ void KRLight::render(RenderInfo& ri)
|
|||||||
if (m_cShadowBuffers >= 1 && shadowValid[0] && m_dust_particle_density > 0.0f && m_dust_particle_size > 0.0f && m_dust_particle_intensity > 0.0f) {
|
if (m_cShadowBuffers >= 1 && shadowValid[0] && m_dust_particle_density > 0.0f && m_dust_particle_size > 0.0f && m_dust_particle_intensity > 0.0f) {
|
||||||
|
|
||||||
if (ri.viewport->visible(getBounds()) || true) { // FINDME, HACK need to remove "|| true"?
|
if (ri.viewport->visible(getBounds()) || true) { // FINDME, HACK need to remove "|| true"?
|
||||||
|
|
||||||
float particle_range = 600.0f;
|
float particle_range = 600.0f;
|
||||||
|
|
||||||
int particle_count = (int)(m_dust_particle_density * pow(particle_range, 3));
|
int particle_count = (int)(m_dust_particle_density * pow(particle_range, 3));
|
||||||
if (particle_count > KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES) {
|
if (particle_count > KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES) {
|
||||||
particle_count = KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES;
|
particle_count = KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4 particleModelMatrix;
|
Matrix4 particleModelMatrix;
|
||||||
particleModelMatrix.scale(particle_range); // Scale the box symetrically to ensure that we don't have an uneven distribution of particles for different angles of the view frustrum
|
particleModelMatrix.scale(particle_range); // Scale the box symetrically to ensure that we don't have an uneven distribution of particles for different angles of the view frustrum
|
||||||
particleModelMatrix.translate(ri.viewport->getCameraPosition());
|
particleModelMatrix.translate(ri.viewport->getCameraPosition());
|
||||||
|
|
||||||
std::vector<KRDirectionalLight*> this_directional_light;
|
std::vector<KRDirectionalLight*> this_directional_light;
|
||||||
std::vector<KRSpotLight*> this_spot_light;
|
std::vector<KRSpotLight*> this_spot_light;
|
||||||
std::vector<KRPointLight*> this_point_light;
|
std::vector<KRPointLight*> this_point_light;
|
||||||
@@ -212,7 +212,7 @@ void KRLight::render(RenderInfo& ri)
|
|||||||
if (point_light) {
|
if (point_light) {
|
||||||
this_point_light.push_back(point_light);
|
this_point_light.push_back(point_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineInfo info{};
|
PipelineInfo info{};
|
||||||
std::string shader_name("dust_particle");
|
std::string shader_name("dust_particle");
|
||||||
info.shader_name = &shader_name;
|
info.shader_name = &shader_name;
|
||||||
@@ -226,14 +226,15 @@ void KRLight::render(RenderInfo& ri)
|
|||||||
info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
||||||
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
pParticleShader->setPushConstant(ShaderValue::dust_particle_color, m_color.val * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
pParticleShader->setPushConstant(ShaderValue::dust_particle_color, m_color.val * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
||||||
pParticleShader->setPushConstant(ShaderValue::particle_origin, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
|
pParticleShader->setPushConstant(ShaderValue::particle_origin, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
|
||||||
pParticleShader->bind(ri, particleModelMatrix); // TODO: Pass light index to shader
|
if (pParticleShader->bind(ri, particleModelMatrix)) { // TODO: Pass light index to shader
|
||||||
|
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
||||||
|
|
||||||
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);
|
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,9 +475,9 @@ void KRLight::renderShadowBuffers(RenderInfo& ri)
|
|||||||
KRPipeline* shadowShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* shadowShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
ri.viewport = &m_shadowViewports[iShadow];
|
ri.viewport = &m_shadowViewports[iShadow];
|
||||||
shadowShader->bind(ri, Matrix4());
|
if (shadowShader->bind(ri, Matrix4())) {
|
||||||
|
getScene().render(ri);
|
||||||
getScene().render(ri);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ri.viewport = prevViewport;
|
ri.viewport = prevViewport;
|
||||||
|
|||||||
@@ -102,11 +102,11 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri)
|
|||||||
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
|
|
||||||
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pParticleShader->bind(ri, getModelMatrix());
|
if (pParticleShader->bind(ri, getModelMatrix())) {
|
||||||
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_RANDOM_PARTICLES, 1.0f);
|
|
||||||
|
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);
|
||||||
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,19 +116,20 @@ void KRPointLight::render(RenderInfo& ri)
|
|||||||
info.modelFormat = bInsideLight ? ModelFormat::KRENGINE_MODEL_FORMAT_STRIP : ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
info.modelFormat = bInsideLight ? ModelFormat::KRENGINE_MODEL_FORMAT_STRIP : ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->bind(ri, sphereModelMatrix); // TODO: Pass light index to shader
|
if (pShader->bind(ri, sphereModelMatrix)) { // TODO: Pass light index to shader
|
||||||
|
|
||||||
if (bInsideLight) {
|
if (bInsideLight) {
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
||||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
// Render sphere of light's influence
|
// Render sphere of light's influence
|
||||||
generateMesh();
|
generateMesh();
|
||||||
|
|
||||||
GLDEBUG(glVertexAttribPointer(KRMesh::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, m_sphereVertices));
|
GLDEBUG(glVertexAttribPointer(KRMesh::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, m_sphereVertices));
|
||||||
|
|
||||||
vkCmdDraw(ri.commandBuffer, m_cVertices, 1, 0, 0);
|
vkCmdDraw(ri.commandBuffer, m_cVertices, 1, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,10 +131,9 @@ void KRReverbZone::render(RenderInfo& ri)
|
|||||||
info.vertexAttributes = sphereModel->getVertexAttributes();
|
info.vertexAttributes = sphereModel->getVertexAttributes();
|
||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
if (pShader->bind(ri, sphereModelMatrix)) {
|
||||||
pShader->bind(ri, sphereModelMatrix);
|
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
|
}
|
||||||
sphereModel->renderNoMaterials(ri.commandBuffer, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
|
||||||
} // sphereModel
|
} // sphereModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,10 +137,10 @@ void KRSprite::render(RenderInfo& ri)
|
|||||||
|
|
||||||
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline* pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
pShader->setImageBinding("diffuseTexture", m_spriteTexture.val.get(), m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
pShader->setImageBinding("diffuseTexture", m_spriteTexture.val.get(), m_pContext->getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
||||||
pShader->bind(ri, getModelMatrix());
|
if (pShader->bind(ri, getModelMatrix())) {
|
||||||
|
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
||||||
m_pContext->getMeshManager()->bindVBO(ri.commandBuffer, &vertices, 1.0f);
|
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
||||||
vkCmdDraw(ri.commandBuffer, 4, 1, 0, 0);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user