Started splitting geometry_passes in smaller files

This commit is contained in:
Elderme 2015-10-18 15:52:52 +02:00
parent c1e709b320
commit 73c0b010ff
8 changed files with 347 additions and 210 deletions

View File

@ -96,12 +96,12 @@ namespace
template<typename T>
static void FillInstances_impl( DrawCalls::InstanceList instance_list,
T * InstanceBuffer,
DrawElementsIndirectCommand *CommandBuffer,
size_t &InstanceBufferOffset,
size_t &CommandBufferOffset,
size_t &PolyCount)
void FillInstances_impl(DrawCalls::InstanceList instance_list,
T * InstanceBuffer,
DrawElementsIndirectCommand *CommandBuffer,
size_t &InstanceBufferOffset,
size_t &CommandBufferOffset,
size_t &PolyCount)
{
// Should never be empty
GLMesh *mesh = instance_list.front().first;
@ -126,13 +126,13 @@ namespace
}
template<typename T>
static void FillInstances( const DrawCalls::MeshMap &GatheredGLMesh,
std::vector<GLMesh *> &InstancedList,
T *InstanceBuffer,
DrawElementsIndirectCommand *CommandBuffer,
size_t &InstanceBufferOffset,
size_t &CommandBufferOffset,
size_t &Polycount)
void FillInstances( const DrawCalls::MeshMap &GatheredGLMesh,
std::vector<GLMesh *> &InstancedList,
T *InstanceBuffer,
DrawElementsIndirectCommand *CommandBuffer,
size_t &InstanceBufferOffset,
size_t &CommandBufferOffset,
size_t &Polycount)
{
auto It = GatheredGLMesh.begin(), E = GatheredGLMesh.end();
for (; It != E; ++It)
@ -658,11 +658,40 @@ void DrawCalls::prepareDrawCalls( ShadowMatrices& shadow_matrices, scene::ICamer
CmdBuffer = (DrawElementsIndirectCommand*)glMapBufferRange(GL_DRAW_INDIRECT_BUFFER, 0, 10000 * sizeof(DrawElementsIndirectCommand), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
}
//TODO: replace duplicated code with a loop
/*
Material::ShaderType dual_tex_materials[5] = {Material::SHADERTYPE_SOLID,
Material::SHADERTYPE_ALPHA_TEST,
Material::SHADERTYPE_SOLID_UNLIT,
Material::SHADERTYPE_SPHERE_MAP,
Material::SHADERTYPE_VEGETATION};
for(int i=0;i<1;i++)
{
SolidPassCmd::getInstance()->Offset[dual_tex_materials[i]] = current_cmd;
FillInstances(m_solid_pass_mesh[dual_tex_materials[i]],
ListInstancedMatDefault::getInstance()->SolidPass, //we need to change this line to something more generic
InstanceBufferDualTex,
CmdBuffer,
offset,
current_cmd,
SolidPoly);
SolidPassCmd::getInstance()->Size[dual_tex_materials[i]] = current_cmd - SolidPassCmd::getInstance()->Offset[dual_tex_materials[i]];
}*/
// Default Material
SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID] = current_cmd;
FillInstances(m_solid_pass_mesh[Material::SHADERTYPE_SOLID], ListInstancedMatDefault::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly);
FillInstances(m_solid_pass_mesh[Material::SHADERTYPE_SOLID],
ListInstancedMatDefault::getInstance()->SolidPass,
InstanceBufferDualTex,
CmdBuffer,
offset,
current_cmd,
SolidPoly);
SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_SOLID] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_SOLID];
// Alpha Ref
SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_ALPHA_TEST] = current_cmd;
FillInstances(m_solid_pass_mesh[Material::SHADERTYPE_ALPHA_TEST], ListInstancedMatAlphaRef::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly);

230
src/graphics/draw_tools.hpp Normal file
View File

@ -0,0 +1,230 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_DRAW_TOOLS_HPP
#define HEADER_DRAW_TOOLS_HPP
#include "graphics/shader.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_mesh.hpp"
// ----------------------------------------------------------------------------
/** Draw a mesh using specified shader (require OpenGL 3.2)
* \param mesh The mesh to draw
* \param args The shader uniforms values
*/
template<typename S, typename...Uniforms>
void draw(const GLMesh *mesh, Uniforms... args)
{
irr_driver->IncreaseObjectCount(); //TODO: move somewhere else
S::getInstance()->setUniforms(args...);
glDrawElementsBaseVertex(mesh->PrimitiveType,
(int)mesh->IndexCount,
mesh->IndexType,
(GLvoid *)mesh->vaoOffset,
(int)mesh->vaoBaseVertex);
} // draw
// ----------------------------------------------------------------------------
/** Variadic template to draw a mesh (using OpenGL 3.2 function)
* with per mesh custom uniforms.*/
template<int...list>
struct CustomUnrollArgs;
// ----------------------------------------------------------------------------
template<int n, int...list>
struct CustomUnrollArgs<n, list...>
{
/** Draw a mesh using specified shader (require OpenGL 3.2)
* \param cascade The cascade shadow map index
* \param t First tuple element is the mesh to draw, next elements are uniforms values
* \param args The shader uniforms values
*/
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawMesh(const STK::Tuple<TupleTypes...> &t,
Args... args)
{
CustomUnrollArgs<list...>::template drawMesh<S>(t, STK::tuple_get<n>(t), args...);
} // drawMesh
// ----------------------------------------------------------------------------
/** Draw shadow mesh using specified shader (require OpenGL 3.2)
* \param t First tuple element is the mesh to draw, next elements are uniforms values
* \param args The shader uniforms values
*/
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawShadow(unsigned cascade,
const STK::Tuple<TupleTypes...> &t,
Args... args)
{
CustomUnrollArgs<list...>::template drawShadow<S>(cascade, t, STK::tuple_get<n>(t), args...);
} // drawShadow
// ----------------------------------------------------------------------------
/** Draw mesh reflective shadow map using specified shader (require OpenGL 3.2)
* \param rsm_matrix The reflective shadow map matrix
* \param t First tuple element is the mesh to draw, next elements are uniforms values
* \param args The shader uniforms values
*/
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawReflectiveShadowMap(const irr::core::matrix4 &rsm_matrix,
const STK::Tuple<TupleTypes...> &t,
Args... args)
{
CustomUnrollArgs<list...>::template drawReflectiveShadowMap<S>(rsm_matrix, t, STK::tuple_get<n>(t), args...);
} // drawReflectiveShadowMap
}; // CustomUnrollArgs
// ----------------------------------------------------------------------------
/** Partial specialisation of CustomUnrollArgs to end the recursion */
template<>
struct CustomUnrollArgs<>
{
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawMesh(const STK::Tuple<TupleTypes...> &t,
Args... args)
{
draw<S>(STK::tuple_get<0>(t), args...);
} // drawMesh
// ----------------------------------------------------------------------------
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawShadow(unsigned cascade,
const STK::Tuple<TupleTypes...> &t,
Args... args)
{
draw<S>(STK::tuple_get<0>(t), cascade, args...);
} // drawShadow
// ----------------------------------------------------------------------------
template<typename S,
typename ...TupleTypes,
typename ...Args>
static void drawReflectiveShadowMap(const irr::core::matrix4 &rsm_matrix,
const STK::Tuple<TupleTypes...> &t,
Args... args)
{
draw<S>(STK::tuple_get<0>(t), rsm_matrix, args...);
} // drawReflectiveShadowMap
}; // CustomUnrollArgs
// ----------------------------------------------------------------------------
/** Variadic template to apply textures parameters.*/
template<typename T, int N>
struct TexExpander_impl
{
template<typename...TupleArgs,
typename... Args>
static void ExpandTex(const GLMesh &mesh,
const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs) - N>(TexSwizzle);
TexExpander_impl<T, N - 1>::template
ExpandTex(mesh, TexSwizzle,
args..., getTextureGLuint(mesh.textures[idx]));
} // ExpandTex
}; // TexExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct TexExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(const GLMesh &mesh,
const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
T::getInstance()->setTextureUnits(args...);
} // ExpandTex
}; // TexExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct TexExpander
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(const GLMesh &mesh,
const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
TexExpander_impl<T, sizeof...(TupleArgs)>::ExpandTex(mesh, TexSwizzle,
args...);
} // ExpandTex
}; // TexExpander
// ----------------------------------------------------------------------------
template<typename T, int N>
struct HandleExpander_impl
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles,
const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs)-N>(TexSwizzle);
HandleExpander_impl<T, N - 1>::template
Expand(TextureHandles, TexSwizzle, args..., TextureHandles[idx]);
} // Expand
}; // HandleExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct HandleExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles,
const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
T::getInstance()->setTextureHandles(args...);
} // Expand
}; // HandleExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct HandleExpander
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
HandleExpander_impl<T, sizeof...(TupleArgs)>::Expand(TextureHandles, TexSwizzle, args...);
} // Expand
}; // HandleExpander
#endif //HEADER_DRAW_TOOLS_HPP

View File

@ -0,0 +1,18 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/geometry_first_pass.hpp"

View File

@ -0,0 +1,22 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_GEOMETRY_PASSES_HPP
#define HEADER_GEOMETRY_PASSES_HPP
#endif //HEADER_GEOMETRY_PASSES_HPP

View File

@ -17,6 +17,7 @@
#include "graphics/geometry_passes.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/draw_tools.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/post_processing.hpp"
#include "graphics/rtts.hpp"
@ -976,123 +977,7 @@ namespace RenderGeometry
using namespace RenderGeometry;
// ----------------------------------------------------------------------------
template<typename T, typename...uniforms>
void draw(const T *Shader, const GLMesh *mesh, uniforms... Args)
{
irr_driver->IncreaseObjectCount();
GLenum ptype = mesh->PrimitiveType;
GLenum itype = mesh->IndexType;
size_t count = mesh->IndexCount;
Shader->setUniforms(Args...);
glDrawElementsBaseVertex(ptype, (int)count, itype,
(GLvoid *)mesh->vaoOffset,
(int)mesh->vaoBaseVertex);
} // draw
// ----------------------------------------------------------------------------
template<int...List>
struct custom_unroll_args;
template<>
struct custom_unroll_args<>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
{
draw<T>(Shader, STK::tuple_get<0>(t), args...);
} // exec
}; // custom_unroll_args
// ----------------------------------------------------------------------------
template<int N, int...List>
struct custom_unroll_args<N, List...>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
{
custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
} // exec
}; // custom_unroll_args
// ----------------------------------------------------------------------------
template<typename T, int N>
struct TexExpander_impl
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs) - N>(TexSwizzle);
TexExpander_impl<T, N - 1>::template
ExpandTex(mesh, TexSwizzle,
args..., getTextureGLuint(mesh.textures[idx]));
} // ExpandTex
}; // TexExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct TexExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
T::getInstance()->setTextureUnits(args...);
} // ExpandTex
}; // TexExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct TexExpander
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle,
Args... args)
{
TexExpander_impl<T, sizeof...(TupleArgs)>::ExpandTex(mesh, TexSwizzle,
args...);
} // ExpandTex
}; // TexExpander
// ----------------------------------------------------------------------------
template<typename T, int N>
struct HandleExpander_impl
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles,
const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs)-N>(TexSwizzle);
HandleExpander_impl<T, N - 1>::template
Expand(TextureHandles, TexSwizzle, args..., TextureHandles[idx]);
} // Expand
}; // HandleExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct HandleExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles,
const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
T::getInstance()->setTextureHandles(args...);
} // Expand
}; // HandleExpander_impl
// ----------------------------------------------------------------------------
template<typename T>
struct HandleExpander
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
HandleExpander_impl<T, sizeof...(TupleArgs)>::Expand(TextureHandles, TexSwizzle, args...);
} // Expand
}; // HandleExpander
// ----------------------------------------------------------------------------
template<typename T, int ...List>
@ -1121,7 +1006,7 @@ void renderMeshes1stPass()
HandleExpander<typename T::FirstPassShader>::template Expand(mesh.TextureHandles, T::FirstPassTextures);
else
TexExpander<typename T::FirstPassShader>::template ExpandTex(mesh, T::FirstPassTextures);
custom_unroll_args<List...>::template exec(T::FirstPassShader::getInstance(), meshes.at(i));
CustomUnrollArgs<List...>::template drawMesh<typename T::FirstPassShader>(meshes.at(i));
}
} // renderMeshes1stPass
@ -1188,6 +1073,7 @@ void GeometryPasses::renderSolidFirstPass()
for (unsigned i = 0; i < ImmediateDrawList::getInstance()->size(); i++)
ImmediateDrawList::getInstance()->at(i)->render();
//TODO: is it useful if AZDO enabled?
renderMeshes1stPass<DefaultMaterial, 2, 1>();
renderMeshes1stPass<SplattingMat, 2, 1>();
renderMeshes1stPass<UnlitMat, 3, 2, 1>();
@ -1256,8 +1142,7 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
TexExpander<typename T::SecondPassShader>::template
ExpandTex(mesh, T::SecondPassTextures, Prefilled_Tex[0],
Prefilled_Tex[1], Prefilled_Tex[2]);
custom_unroll_args<List...>::template
exec(T::SecondPassShader::getInstance(), meshes.at(i));
CustomUnrollArgs<List...>::template drawMesh<typename T::SecondPassShader>(meshes.at(i));
}
} // renderMeshes2ndPass
@ -1356,6 +1241,7 @@ void GeometryPasses::renderSolidSecondPass( unsigned render_target_diffuse,
render_target_specular,
render_target_half_red);
//TODO: is it useful when AZDO enabled?
renderMeshes2ndPass<DefaultMaterial, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<AlphaRef, 3, 1 >(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<UnlitMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
@ -1510,7 +1396,7 @@ void renderTransparenPass(const std::vector<RenderGeometry::TexUnit> &TexUnits,
Shader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
else
Shader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0]));
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
CustomUnrollArgs<List...>::template drawMesh<Shader>(meshes->at(i));
}
} // renderTransparenPass
@ -1652,45 +1538,6 @@ void GeometryPasses::renderTransparent(unsigned render_target)
} // renderTransparent
// ----------------------------------------------------------------------------
template<typename T, typename...uniforms>
void drawShadow(const T *Shader, unsigned cascade, const GLMesh *mesh, uniforms... Args)
{
irr_driver->IncreaseObjectCount();
GLenum ptype = mesh->PrimitiveType;
GLenum itype = mesh->IndexType;
size_t count = mesh->IndexCount;
Shader->setUniforms(cascade, Args...);
glDrawElementsBaseVertex(ptype, (int)count, itype,
(GLvoid *)mesh->vaoOffset, (int)mesh->vaoBaseVertex);
} // drawShadow
// ----------------------------------------------------------------------------
template<int...List>
struct shadow_custom_unroll_args;
template<>
struct shadow_custom_unroll_args<>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, unsigned cascade, const STK::Tuple<TupleTypes...> &t, Args... args)
{
drawShadow<T>(Shader, cascade, STK::tuple_get<0>(t), args...);
} // exec
}; // shadow_custom_unroll_args
// ----------------------------------------------------------------------------
template<int N, int...List>
struct shadow_custom_unroll_args<N, List...>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const T *Shader, unsigned cascade, const STK::Tuple<TupleTypes...> &t, Args... args)
{
shadow_custom_unroll_args<List...>::template exec<T>(Shader, cascade, t, STK::tuple_get<N>(t), args...);
} // exec
}; // shadow_custom_unroll_args
// ----------------------------------------------------------------------------
template<typename T, int...List>
void renderShadow(unsigned cascade)
@ -1708,7 +1555,7 @@ void renderShadow(unsigned cascade)
HandleExpander<typename T::ShadowPassShader>::template Expand(mesh->TextureHandles, T::ShadowTextures);
else
TexExpander<typename T::ShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures);
shadow_custom_unroll_args<List...>::template exec<typename T::ShadowPassShader>(T::ShadowPassShader::getInstance(), cascade, t.at(i));
CustomUnrollArgs<List...>::template drawShadow<typename T::ShadowPassShader>(cascade, t.at(i));
} // for i
} // renderShadow
@ -1838,34 +1685,6 @@ void GeometryPasses::renderShadows(const ShadowMatrices& shadow_matrices,
} // renderShadows
// ----------------------------------------------------------------------------
template<int...List>
struct rsm_custom_unroll_args;
template<>
struct rsm_custom_unroll_args<>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const core::matrix4 &rsm_matrix,
const STK::Tuple<TupleTypes...> &t, Args... args)
{
draw<T>(T::getInstance(), STK::tuple_get<0>(t), rsm_matrix, args...);
}
}; // rsm_custom_unroll_args
// ----------------------------------------------------------------------------
template<int N, int...List>
struct rsm_custom_unroll_args<N, List...>
{
template<typename T, typename ...TupleTypes, typename ...Args>
static void exec(const core::matrix4 &rsm_matrix,
const STK::Tuple<TupleTypes...> &t, Args... args)
{
rsm_custom_unroll_args<List...>::template
exec<T>(rsm_matrix, t, STK::tuple_get<N>(t), args...);
}
}; // rsm_custom_unroll_args
// ----------------------------------------------------------------------------
template<typename T, int... Selector>
void drawRSM(const core::matrix4 & rsm_matrix)
@ -1884,7 +1703,7 @@ void drawRSM(const core::matrix4 & rsm_matrix)
HandleExpander<typename T::RSMShader>::template Expand(mesh->TextureHandles, T::RSMTextures);
else
TexExpander<typename T::RSMShader>::template ExpandTex(*mesh, T::RSMTextures);
rsm_custom_unroll_args<Selector...>::template exec<typename T::RSMShader>(rsm_matrix, t.at(i));
CustomUnrollArgs<Selector...>::template drawReflectiveShadowMap<typename T::RSMShader>(rsm_matrix, t.at(i));
}
} // drawRSM

View File

@ -46,7 +46,7 @@ class Material : public NoCopy
public:
enum ShaderType
{
SHADERTYPE_SOLID,
SHADERTYPE_SOLID = 0,
SHADERTYPE_ALPHA_TEST,
SHADERTYPE_ALPHA_BLEND,
SHADERTYPE_ADDITIVE,

View File

@ -87,6 +87,16 @@ public:
virtual bool isImmediateDraw() const { return false; }
}; // STKMeshCommon
/*
// ----------------------------------------------------------------------------
//TODO: template function in order to avoid duplicate code (clear method)
template<typename T>
clearMeshList()
{
}
*/
// ----------------------------------------------------------------------------
template<typename T, typename... Args>
class MeshList : public Singleton<T>

View File

@ -29,12 +29,16 @@
#include "graphics/stk_mesh.hpp"
#include "utils/singleton.hpp"
template<typename T>
template<typename T, int nb_cascades, int nb_materials>
class CommandBuffer : public Singleton<T>
{
public:
GLuint drawindirectcmd;
DrawElementsIndirectCommand *Ptr;
//size_t Offset[nb_cascades][nb_materials];
//size_t Size[nb_cascades][nb_materials];
CommandBuffer()
{
glGenBuffers(1, &drawindirectcmd);
@ -49,6 +53,11 @@ public:
glBufferData(GL_DRAW_INDIRECT_BUFFER, 10000 * sizeof(DrawElementsIndirectCommand), 0, GL_STREAM_DRAW);
}
}
void bind()
{
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, drawindirectcmd);
}
};
class ImmediateDrawList : public Singleton<ImmediateDrawList>, public std::vector<scene::ISceneNode *>
@ -61,25 +70,25 @@ class ParticlesList : public Singleton<ParticlesList>, public std::vector<Partic
{};
class SolidPassCmd : public CommandBuffer<SolidPassCmd>
class SolidPassCmd : public CommandBuffer<SolidPassCmd, 1, static_cast<int>(Material::SHADERTYPE_COUNT)>
{
public:
size_t Offset[Material::SHADERTYPE_COUNT], Size[Material::SHADERTYPE_COUNT];
};
class ShadowPassCmd : public CommandBuffer<ShadowPassCmd>
class ShadowPassCmd : public CommandBuffer<ShadowPassCmd, 4, static_cast<int>(Material::SHADERTYPE_COUNT)>
{
public:
size_t Offset[4][Material::SHADERTYPE_COUNT], Size[4][Material::SHADERTYPE_COUNT];
};
class RSMPassCmd : public CommandBuffer<RSMPassCmd>
class RSMPassCmd : public CommandBuffer<RSMPassCmd, 1, static_cast<int>(Material::SHADERTYPE_COUNT)>
{
public:
size_t Offset[Material::SHADERTYPE_COUNT], Size[Material::SHADERTYPE_COUNT];
};
class GlowPassCmd : public CommandBuffer<GlowPassCmd>
class GlowPassCmd : public CommandBuffer<GlowPassCmd, 1, 1>
{
public:
size_t Offset, Size;