X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Frenderer.h;h=99c8c5002b242da1d18c694d77996ff8ded0607c;hb=274b6fb1b02692cc422bad9040d1abe5d545505a;hp=51989f7711f8b84bd8a43a1eb8d872cb2a3cf7d2;hpb=50492d9a5106b3dd76e3d6fa5ac88d9f97ba3c47;p=libs%2Fgl.git diff --git a/source/render/renderer.h b/source/render/renderer.h index 51989f77..99c8c500 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -83,6 +83,7 @@ private: struct State { + std::uintptr_t pipeline_key = 0; const Camera *camera = 0; Matrix model_matrix; const Framebuffer *framebuffer = 0; @@ -102,7 +103,9 @@ private: enum ChangeMask { + PIPELINE_KEY = 1, MATRIX = 2, + CAMERA = 4, SHADER_DATA = 16 }; @@ -114,8 +117,12 @@ private: std::vector shdata_stack; std::vector texture_stack; const Texture &placeholder_texture; + PipelineState *last_pipeline = 0; Commands commands; + static const Tag world_obj_matrix_tag; + static const Tag world_obj_normal_matrix_tag; + public: Renderer(); @@ -140,6 +147,16 @@ private: State &get_state() const; public: + void set_pipeline_key(std::uintptr_t); + void set_pipeline_key(const void *p) { set_pipeline_key(reinterpret_cast(p)); } + + template + void set_pipeline_key(std::uintptr_t k, T d) + { set_pipeline_key(k^(static_cast(d)<<((sizeof(std::uintptr_t)-sizeof(T))*std::numeric_limits::digits))); } + + template + void set_pipeline_key(const void *p, T d) { set_pipeline_key(reinterpret_cast(p), d); } + /** Sets the camera to render from. The model matrix is reset to identity. */ void set_camera(const Camera &); @@ -204,6 +221,7 @@ public: void end_query(const QueryPool &, unsigned); private: + PipelineState &get_pipeline_state(); void apply_framebuffer(); void apply_state(); };