@@ -17,10 +17,32 @@ namespace cage
1717{
1818 class GraphicsDevice ;
1919 class Texture ;
20+ class GpuBuffer ;
2021 class Shader ;
2122 class Model ;
2223
23- struct CAGE_ENGINE_API PassConfig
24+ struct CAGE_ENGINE_API BindingsConfig
25+ {
26+ struct TextureConfig
27+ {
28+ Texture *texture = nullptr ;
29+ uint32 shaderSet = m;
30+ uint32 shaderBinding = m;
31+ };
32+ std::vector<TextureConfig> textures;
33+
34+ struct BufferConfig
35+ {
36+ GpuBuffer *buffer = nullptr ;
37+ uint32 shaderSet = m;
38+ uint32 shaderBinding = m;
39+ uint32 offset = 0 ;
40+ uint32 size = m;
41+ };
42+ std::vector<BufferConfig> buffers;
43+ };
44+
45+ struct CAGE_ENGINE_API PassConfig : public BindingsConfig
2446 {
2547 struct ColorTargetConfig
2648 {
@@ -41,25 +63,28 @@ namespace cage
4163 const char *label = nullptr ;
4264 };
4365
44- struct CAGE_ENGINE_API DrawConfig
66+ struct CAGE_ENGINE_API DrawConfig : public BindingsConfig
4567 {
46- std::array<Texture *, MaxTexturesCountPerMaterial> materialTextures = {};
47- std::vector<Texture *> extraTextures;
4868 Shader *shader = nullptr ;
4969 Model *model = nullptr ;
70+
71+ uint32 instances = 1 ;
5072 };
5173
74+ // fills in all textures and material buffer from the model, using shader set = 1, and also fills in the shader
75+ CAGE_ENGINE_API DrawConfig prepareDrawConfig (const AssetsManager *assets, Model *model, uint32 shaderKeywords = 0 );
76+
5277 class CAGE_ENGINE_API GraphicsEncoder : private Immovable
5378 {
5479 public:
5580 void nextPass (const PassConfig &config);
5681 void draw (const DrawConfig &config);
5782 void submit ();
5883
59- PassConfig getCurrentPass () const ;
84+ const PassConfig & getCurrentPass () const ;
6085
61- wgpu::CommandEncoder nativeCommandEncoder ();
62- wgpu::RenderPassEncoder nativeDrawEncoder ();
86+ const wgpu::CommandEncoder & nativeCommandEncoder ();
87+ const wgpu::RenderPassEncoder & nativeDrawEncoder ();
6388 };
6489
6590 CAGE_ENGINE_API Holder<GraphicsEncoder> newGraphicsEncoder (GraphicsDevice *device);
0 commit comments