Cogs.Core
RenderMaterialInstance.h
1#pragma once
2
3#include "RenderMaterial.h"
4#include "RenderResourceBase.h"
5#include "../Resources/MaterialInstance.h"
6#include "../Resources/MeshStreamsLayout.h"
7#include "../Systems/Core/CameraSystem.h"
8
9namespace Cogs
10{
11 class IGraphicsDevice;
12
13 namespace Core
14 {
15 struct EnginePermutation;
16 struct MeshStreamsLayout;
17 struct RenderPassOptions;
18 enum struct ClipShapeType : uint32_t;
19
20 struct COGSCORE_DLL_API RenderMaterialInstance : RenderResourceBase<MaterialInstance>
21 {
22 ActivationResult update(MaterialInstance * materialInstance, IGraphicsDevice * device, class RenderResources * resources, RenderStates * renderStates);
23
24 void release(class Renderer * renderer);
25
31 const EffectBinding* checkReady(const MeshStreamsLayout& streamsLayout,
32 const EnginePermutation* permutation,
33 const RenderPassOptions& passOptions,
34 ClipShapeType clipShape);
35
37 const EffectBinding* getBindings(const MeshStreamsLayout& streamsLayout,
38 const EnginePermutation* permutation,
39 const RenderPassOptions& passOptions,
40 ClipShapeType clipShape) const;
41
43 {
44 BufferHandle handle;
45 size_t generation = 0;
46 bool bound = false;
47 };
48 std::vector<UpdateBuffer> buffers;
49 std::vector<BufferHandle> ownedBuffers;
50
51 std::vector<SamplerStateHandle> samplerStates;
52
54 {
55 size_t permutationCode;
56 MeshStreamsLayout streamsLayout;
57 const EnginePermutation* enginePermutation;
58 RenderPassOptions passOptions;
59 ClipShapeType clipShape;
60 EffectBinding* binding;
61 size_t variantGeneration;
62 };
63 std::vector<RenderEffectBinding> loadedBindings;
64 std::vector<RenderEffectBinding> pendingBindings;
65 ShaderVariantSelectors variantSelectors;
66
67 Context* context = nullptr;
68 RenderMaterial* renderMaterial = nullptr;
69
70 size_t variantGeneration = 0;
71 size_t permutationIndex = 0;
72
73 // Keep track of which generation of shaders/bindings the instance was last
74 // synchronized with.
75 uint16_t buffersGeneration = 0;
76 };
77 }
78}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Contains render resources used by the renderer.
Core renderer system.
Definition: Renderer.h:28
Represents a graphics device used to manage graphics resources and issue drawing commands.
ClipShapeType
Specifices what kind of shape a clip shape has.
ActivationResult
Defines results for resource activation.
Definition: ResourceBase.h:14
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Material instances represent a specialized Material combined with state for all its buffers and prope...
Render resources represent Engine resources like Mesh, Effect or MaterialInstance,...