WIP Inlining KRPipelineManager::selectPipeline wrapper function.
This commit is contained in:
@@ -140,8 +140,8 @@ void KRAmbientZone::render(RenderInfo& ri)
|
|||||||
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
||||||
|
|
||||||
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline *pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
pPipeline->bind(*ri.camera, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
if(getContext().getPipelineManager()->selectPipeline(*ri.surface, *ri.camera, pPipeline, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, 0, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
||||||
@@ -150,7 +150,6 @@ void KRAmbientZone::render(RenderInfo& ri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float KRAmbientZone::getGradientDistance()
|
float KRAmbientZone::getGradientDistance()
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ void KRAudioSource::render(RenderInfo& ri)
|
|||||||
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
||||||
|
|
||||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
pShader->bind(*ri.camera, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
if(getContext().getPipelineManager()->selectPipeline(*ri.surface, *ri.camera, pShader, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, 0, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
||||||
@@ -217,7 +217,6 @@ void KRAudioSource::render(RenderInfo& ri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void KRAudioSource::setGain(float gain)
|
void KRAudioSource::setGain(float gain)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,16 +91,14 @@ void KRBone::render(RenderInfo& ri)
|
|||||||
info.rasterMode = PipelineInfo::RasterMode::kAdditiveNoTest;
|
info.rasterMode = PipelineInfo::RasterMode::kAdditiveNoTest;
|
||||||
|
|
||||||
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
pShader->bind(*ri.camera, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
if(getContext().getPipelineManager()->selectPipeline(*ri.surface, *ri.camera, pShader, ri.viewport, sphereModelMatrix, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, 0, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
||||||
sphereModels[0]->renderSubmesh(ri.commandBuffer, i, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
sphereModels[0]->renderSubmesh(ri.commandBuffer, i, ri.renderPass, getName(), "visualize_overlay", 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
||||||
|
|
||||||
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(compositeSurface, info);
|
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(compositeSurface, info);
|
||||||
getContext().getPipelineManager()->selectPipeline(compositeSurface, *this, pPipeline, m_viewport, Matrix4(), nullptr, nullptr, nullptr, 0, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero());
|
pPipeline->bind(*this, m_viewport, Matrix4(), nullptr, nullptr, nullptr, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
||||||
|
|
||||||
@@ -352,11 +352,10 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
Matrix4 matModel = Matrix4();
|
Matrix4 matModel = Matrix4();
|
||||||
matModel.scale((*itr).first.size() * 0.5f);
|
matModel.scale((*itr).first.size() * 0.5f);
|
||||||
matModel.translate((*itr).first.center());
|
matModel.translate((*itr).first.center());
|
||||||
if(getContext().getPipelineManager()->selectPipeline(compositeSurface, *this, pVisShader, m_viewport, matModel, nullptr, nullptr, nullptr, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
pVisShader->bind(*this, m_viewport, matModel, nullptr, nullptr, nullptr, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
|
|
||||||
// fprintf(stderr, "VBO Mem: %i Kbyte Texture Mem: %i/%i Kbyte (active/total) Shader Handles: %i Visible Bounds: %i Max Texture LOD: %i\n", (int)m_pContext->getMeshManager()->getMemUsed() / 1024, (int)m_pContext->getTextureManager()->getActiveMemUsed() / 1024, (int)m_pContext->getTextureManager()->getMemUsed() / 1024, (int)m_pContext->getPipelineManager()->getShaderHandlesUsed(), (int)m_visibleBounds.size(), m_pContext->getTextureManager()->getLODDimCap());
|
// fprintf(stderr, "VBO Mem: %i Kbyte Texture Mem: %i/%i Kbyte (active/total) Shader Handles: %i Visible Bounds: %i Max Texture LOD: %i\n", (int)m_pContext->getMeshManager()->getMemUsed() / 1024, (int)m_pContext->getTextureManager()->getActiveMemUsed() / 1024, (int)m_pContext->getTextureManager()->getMemUsed() / 1024, (int)m_pContext->getPipelineManager()->getShaderHandlesUsed(), (int)m_visibleBounds.size(), m_pContext->getTextureManager()->getLODDimCap());
|
||||||
|
|||||||
@@ -266,10 +266,11 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
info.renderPass = ri.renderPass;
|
info.renderPass = ri.renderPass;
|
||||||
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
||||||
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
||||||
|
info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
||||||
|
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
|
||||||
if(getContext().getPipelineManager()->selectPipeline(*ri.surface, *ri.camera, pParticleShader, ri.viewport, particleModelMatrix, &this_point_light, &this_directional_light, &this_spot_light, 0, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
pParticleShader->bind(*ri.camera, ri.viewport, particleModelMatrix, &this_point_light, &this_directional_light, &this_spot_light, ri.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
||||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_PARTICLE_ORIGIN, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
|
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_PARTICLE_ORIGIN, Matrix4::DotWDiv(Matrix4::Invert(particleModelMatrix), Vector3::Zero()));
|
||||||
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, m_dust_particle_size);
|
pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, m_dust_particle_size);
|
||||||
@@ -281,7 +282,7 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||||
}
|
vkCmdDraw(ri.commandBuffer, particle_count * 3, 1, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,8 +361,10 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
info.renderPass = ri.renderPass;
|
info.renderPass = ri.renderPass;
|
||||||
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
info.rasterMode = PipelineInfo::RasterMode::kAdditive;
|
||||||
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
info.cullMode = PipelineInfo::CullMode::kCullNone;
|
||||||
|
// TODO: set info.vertexAttributes and info.modelFormat
|
||||||
|
|
||||||
if(getContext().getPipelineManager()->selectPipeline(*ri.surface, info, ri.viewport, occlusion_test_sphere_matrix, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info);
|
||||||
|
pPipeline->bind(*info.pCamera, ri.viewport, occlusion_test_sphere_matrix, info.point_lights, info.directional_lights, info.spot_lights, info.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero());
|
||||||
|
|
||||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||||
#if TARGET_OS_IPHONE || defined(ANDROID)
|
#if TARGET_OS_IPHONE || defined(ANDROID)
|
||||||
@@ -385,7 +388,6 @@ void KRLight::render(RenderInfo& ri) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(ri.renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
if(ri.renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||||
if(m_flareTexture.size() && m_flareSize > 0.0f) {
|
if(m_flareTexture.size() && m_flareSize > 0.0f) {
|
||||||
|
|||||||
@@ -294,12 +294,6 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool KRPipelineManager::selectPipeline(KRSurface& surface, const PipelineInfo& info, const KRViewport& viewport, const Matrix4& matModel, const Vector3& rim_color, float rim_power, const Vector4& fade_color)
|
|
||||||
{
|
|
||||||
KRPipeline* pPipeline = getPipeline(surface, info);
|
|
||||||
return selectPipeline(surface, *info.pCamera, pPipeline, viewport, matModel, info.point_lights, info.directional_lights, info.spot_lights, info.bone_count, info.renderPass, rim_color, rim_power, fade_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KRPipelineManager::selectPipeline(KRSurface& surface, KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> *point_lights, const std::vector<KRDirectionalLight *> *directional_lights, const std::vector<KRSpotLight *> *spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)
|
bool KRPipelineManager::selectPipeline(KRSurface& surface, KRCamera &camera, KRPipeline *pPipeline, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> *point_lights, const std::vector<KRDirectionalLight *> *directional_lights, const std::vector<KRSpotLight *> *spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)
|
||||||
{
|
{
|
||||||
if(pPipeline) {
|
if(pPipeline) {
|
||||||
|
|||||||
Reference in New Issue
Block a user