<commit_before>﻿#include "GEK\Utility\String.h"
#include "GEK\Utility\FileSystem.h"
#include "GEK\Utility\XML.h"
#include "GEK\Context\ContextUser.h"
#include "GEK\Context\ObservableMixin.h"
#include "GEK\Engine\Engine.h"
#include "GEK\Engine\Render.h"
#include "GEK\Engine\Resources.h"
#include "GEK\Engine\Plugin.h"
#include "GEK\Engine\Shader.h"
#include "GEK\Engine\Material.h"
#include "GEK\Engine\Population.h"
#include "GEK\Engine\Entity.h"
#include "GEK\Engine\Component.h"
#include "GEK\Components\Transform.h"
#include "GEK\Shapes\Sphere.h"
#include <set>
#include <ppl.h>
#include <concurrent_vector.h>

namespace Gek
{
    class RenderPipelineImplementation
        : public RenderPipeline
    {
    private:
        VideoPipeline *videoPipeline;

    public:
        RenderPipelineImplementation(VideoPipeline *videoPipeline)
            : videoPipeline(videoPipeline)
        {
        }

        // RenderPipeline
        void setProgram(VideoObject *program)
        {
            videoPipeline->setProgram(program);
        }

        void setConstantBuffer(VideoBuffer *constantBuffer, uint32_t stage)
        {
            videoPipeline->setConstantBuffer(constantBuffer, stage);
        }

        void setSamplerState(VideoObject *samplerState, uint32_t stage)
        {
            videoPipeline->setSamplerState(samplerState, stage);
        }

        void setResource(VideoObject *resource, uint32_t stage)
        {
            videoPipeline->setResource(resource, stage);
        }

        void setUnorderedAccess(VideoObject *unorderedAccess, uint32_t stage)
        {
            videoPipeline->setUnorderedAccess(unorderedAccess, stage);<commit_msg>Trying to automate caching for render context<commit_after>﻿#include "GEK\Utility\String.h"
#include "GEK\Utility\FileSystem.h"
#include "GEK\Utility\XML.h"
#include "GEK\Context\ContextUser.h"
#include "GEK\Context\ObservableMixin.h"
#include "GEK\Engine\Engine.h"
#include "GEK\Engine\Render.h"
#include "GEK\Engine\Resources.h"
#include "GEK\Engine\Plugin.h"
#include "GEK\Engine\Shader.h"
#include "GEK\Engine\Material.h"
#include "GEK\Engine\Population.h"
#include "GEK\Engine\Entity.h"
#include "GEK\Engine\Component.h"
#include "GEK\Components\Transform.h"
#include "GEK\Shapes\Sphere.h"
#include <set>
#include <ppl.h>
#include <concurrent_vector.h>

namespace Gek
{
    template <typename... ARGUMENTS, typename CLASS>
    void checkCache(std::tuple<ARGUMENTS...> &cache, CLASS *classObject, void (CLASS::*function)(ARGUMENTS...), ARGUMENTS... arguments)
    {
        auto tuple = std::tie(arguments...);
        if (tuple != cache)
        {
            cache = std::move(tuple);
            (classObject->*function)(arguments...);
        }
    }

    template <typename CLASS, typename RETURN, typename... ARGUMENTS>
    struct FunctionTraits<RETURN(CLASS::*)(ARGUMENTS...) const>
    {
        typedef std::tuple<decltype(ARGUMENTS...)> arguments;
    };

    class RenderPipelineImplementation
        : public RenderPipeline
    {
    private:
        VideoPipeline *videoPipeline;

    public:
        RenderPipelineImplementation(VideoPipeline *videoPipeline)
            : videoPipeline(videoPipeline)
        {
        }

        // RenderPipeline
        FunctionTraits<RenderPipelineImplementation::setProgram>::arguments setProgramCache;
        void setProgram(VideoObject *program)
        {
            checkCache(setProgramCache, videoPipeline, &VideoPipeline::setProgram, program);
        }

        std::tuple<VideoBuffer *, uint32_t> setConstantBufferCache;
        void setConstantBuffer(VideoBuffer *constantBuffer, uint32_t stage)
        {
            checkCache(setConstantBufferCache, videoPipeline, &VideoPipeline::setConstantBuffer, constantBuffer, stage);
        }

        std::tuple<VideoObject *, uint32_t> setSamplerStateCache;
        void setSamplerState(VideoObject *samplerState, uint32_t stage)
        {
            checkCache(setSamplerStateCache, videoPipeline, &VideoPipeline::setSamplerState, samplerState, stage);
        }

        std::tuple<VideoObject *, uint32_t> setResourceCache;
        void setResource(VideoObject *resource, uint32_t stage)
        {
            checkCache(setResourceCache, videoPipeline, &VideoPipeline::setResource, resource, stage);
        }

        std::tuple<VideoObject *, uint32_t> setUnorderedAccessCache;
        void setUnorderedAccess(VideoObject *unorderedAccess, uint32_t stage)
        {
            checkCache(setUnorderedAccessCache, videoPipeline, &VideoPipeline::setUnorderedAccess, unorderedAccess, stage);
{'fraction_non_alphanumeric': 0.11413635373556959, 'fraction_numerical': 0.005227619255064256, 'mean_word_length': 3.299625468164794, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '87809', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1354, 'n_words': 238}