X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Frenderer.h;h=31ad65ea1a373bf8c6c5478d4bf878d571ffce4f;hb=7b1a814276741e1aff68c6e9066537374c19c283;hp=51989f7711f8b84bd8a43a1eb8d872cb2a3cf7d2;hpb=50492d9a5106b3dd76e3d6fa5ac88d9f97ba3c47;p=libs%2Fgl.git diff --git a/source/render/renderer.h b/source/render/renderer.h index 51989f77..31ad65ea 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,6 +117,7 @@ private: std::vector shdata_stack; std::vector texture_stack; const Texture &placeholder_texture; + PipelineState *last_pipeline = 0; Commands commands; public: @@ -140,6 +144,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 +218,7 @@ public: void end_query(const QueryPool &, unsigned); private: + PipelineState &get_pipeline_state(); void apply_framebuffer(); void apply_state(); };