• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef API_3D_RENDER_IRENDER_DATA_STORE_DEFAULT_MATERIAL_H
17 #define API_3D_RENDER_IRENDER_DATA_STORE_DEFAULT_MATERIAL_H
18 
19 #include <cstdint>
20 
21 #include <3d/ecs/components/material_component.h>
22 #include <3d/render/render_data_defines_3d.h>
23 #include <base/containers/array_view.h>
24 #include <base/math/matrix.h>
25 #include <base/math/vector.h>
26 #include <core/namespace.h>
27 #include <render/datastore/intf_render_data_store.h>
28 #include <render/device/intf_shader_manager.h>
29 #include <render/resource_handle.h>
30 
31 CORE3D_BEGIN_NAMESPACE()
32 /** @ingroup group_render_irenderdatastoredefaultmaterial */
33 /** RenderDataDefaultMaterial.
34  */
35 struct RenderDataDefaultMaterial {
36     /** min supported roughness value. clamped to this - 1.0.
37     Avoids division with zero in shader BRDF calculations and prevents "zero" size speculars. */
38     static constexpr float MIN_ROUGHNESS { 0.089f };
39     /** max supported skin matrix count */
40     static constexpr uint32_t MAX_SKIN_MATRIX_COUNT { 128u };
41 
42     /** Count of uvec4 variables for material uniforms (must match 3d_dm_structure_common.h)
43      * Aligned for 256 bytes with indices.
44      */
45     static constexpr uint32_t MATERIAL_FACTOR_UNIFORM_VEC4_COUNT { 15u };
46     static constexpr uint32_t MATERIAL_PACKED_UNIFORM_UVEC4_COUNT { 15u };
47 
48     /** Count of uvec4 variables for material uniforms (must match 3d_dm_structure_common.h) */
49     static constexpr uint32_t MATERIAL_TEXTURE_COUNT { 11u };
50 
51     /** max default material custom resources */
52     static constexpr uint32_t MAX_MATERIAL_CUSTOM_RESOURCE_COUNT { 8u };
53 
54     /** max default material custom resources */
55     static constexpr uint32_t MAX_MESH_USER_VEC4_COUNT { 8u };
56 
57     /** max default material custom resources */
58     static constexpr uint32_t MAX_MATERIAL_CUSTOM_PROPERTY_BYTE_SIZE { 256u };
59 
60     /** default depth rendering related important flags for render material flags */
61     static constexpr uint32_t RENDER_MATERIAL_DEPTH_FLAGS {
62         RenderMaterialFlagBits::RENDER_MATERIAL_GPU_INSTANCING_BIT
63     };
64     /** default depth rendering related important flags for submesh flags */
65     static constexpr uint32_t RENDER_SUBMESH_DEPTH_FLAGS { RenderSubmeshFlagBits::RENDER_SUBMESH_SKIN_BIT };
66 
67     /** Input material uniforms
68      * There's no conversion happening to these, so pre-multiplications etc needs to happen prior
69      */
70     struct InputMaterialUniforms {
71         // the factor values are not the same default values as in MaterialComponent
72         struct TextureData {
73             BASE_NS::Math::Vec4 factor { 0.0f, 0.0f, 0.0f, 0.0f };
74             BASE_NS::Math::Vec2 translation { 0.0f, 0.0f };
75             float rotation { 0.0f };
76             BASE_NS::Math::Vec2 scale { 1.0f, 1.0f };
77         };
78         TextureData textureData[MATERIAL_TEXTURE_COUNT];
79         // separate values which is pushed to shader alpha cutoff
80         float alphaCutoff { 1.0f };
81         // texcoord set bits, selection for uv0 or uv1
82         uint32_t texCoordSetBits { 0u };
83         // texcoord transform set bits
84         uint32_t texTransformSetBits { 0u };
85         /** material id */
86         uint64_t id { 0 };
87     };
88 
89     /** Material uniforms (NOTE: rotScaleTrans could be packed more)
90      */
91     struct MaterialUniforms {
92         // Factors as half4
93         // 0: baseColor
94         // 1: normal
95         // 2: material
96         // 3: emissive
97         // 4: ao
98         // 5: clearcoat
99         // 6: clearcoat roughness
100         // 7: clearcoat normal
101         // 8: sheen
102         // 9: transmission
103         // 10: specular
104         // 11: alpha cutoff
105 
106         BASE_NS::Math::Vec4 factors[MATERIAL_FACTOR_UNIFORM_VEC4_COUNT];
107 
108         // unpacked, .xy material id,
109         BASE_NS::Math::UVec4 indices { 0u, 0u, 0u, 0u };
110     };
111 
112     struct MaterialPackedUniforms {
113         // Texture transforms as half4 ({2x2 mat}, {2d offset, unused})
114         // 0: rotScaleTrans baseColor
115         // 1: rotScaleTrans normal
116         // 2: rotScaleTrans material
117         // 3: rotScaleTrans emissive
118         // 4: rotScaleTrans ao
119         // 5: rotScaleTrans clearcoat
120         // 6: rotScaleTrans clearcoat roughness
121         // 7: rotScaleTrans clearcoat normal
122         // 8: rotScaleTrans sheen
123         // 9: rotScaleTrans transmission
124         // 10: rotScaleTrans specular
125 
126         //
127         // 12: alphaCutoff, unused, useTexcoord | hasTransform
128         BASE_NS::Math::UVec4 packed[MATERIAL_PACKED_UNIFORM_UVEC4_COUNT];
129 
130         // unpacked, .xy material id,
131         BASE_NS::Math::UVec4 indices { 0u, 0u, 0u, 0u };
132     };
133 
134     /*
135      * Combined uniforms for factors and packed transforms
136      **/
137     struct AllMaterialUniforms {
138         /** Material factor uniforms */
139         MaterialUniforms factors;
140         /** Material packed transforms */
141         MaterialPackedUniforms transforms;
142     };
143 
144     /** Material handles with handle reference (used as inputs)
145      */
146     struct MaterialHandlesWithHandleReference {
147         /** Source images for different texture types */
148         RENDER_NS::RenderHandleReference images[MATERIAL_TEXTURE_COUNT];
149         /** Samplers for different texture types */
150         RENDER_NS::RenderHandleReference samplers[MATERIAL_TEXTURE_COUNT];
151     };
152     /** Material handles with raw handles
153      */
154     struct MaterialHandles {
155         /** Source images for different texture types */
156         RENDER_NS::RenderHandle images[MATERIAL_TEXTURE_COUNT];
157         /** Samplers for different texture types */
158         RENDER_NS::RenderHandle samplers[MATERIAL_TEXTURE_COUNT];
159     };
160 
161     /** Material shader with handle references (used as inputs)
162      */
163     struct MaterialShaderWithHandleReference {
164         /** Shader to be used. (If invalid, a default is chosen by the default material renderer) */
165         RENDER_NS::RenderHandleReference shader;
166         /** Shader graphics state to be used. (If invalid, a default is chosen by the default material renderer) */
167         RENDER_NS::RenderHandleReference graphicsState;
168     };
169 
170     /** Material data
171      */
172     struct MaterialData {
173         /** Material shader */
174         MaterialShaderWithHandleReference materialShader;
175         /** Depth shader */
176         MaterialShaderWithHandleReference depthShader;
177         /** Render extra rendering flags */
178         RenderExtraRenderingFlags extraMaterialRenderingFlags { 0u };
179         /** Render material flags, same as MaterialComponent */
180         RenderMaterialFlags renderMaterialFlags { RENDER_MATERIAL_SHADOW_RECEIVER_BIT |
181                                                   RENDER_MATERIAL_SHADOW_CASTER_BIT |
182                                                   RENDER_MATERIAL_PUNCTUAL_LIGHT_RECEIVER_BIT |
183                                                   RENDER_MATERIAL_INDIRECT_LIGHT_RECEIVER_BIT };
184 
185         /** Custom render slot id */
186         uint32_t customRenderSlotId { ~0u };
187 
188         /** Optional camera id (significant bits) for camera based material
189          * Will render only with a given camera id if set.
190          */
191         uint32_t customCameraId { RenderSceneDataConstants::INVALID_INDEX };
192 
193         /** Render material type */
194         RenderMaterialType materialType { RenderMaterialType::METALLIC_ROUGHNESS };
195 
196         /** Render sort layer id. Valid values are 0 - 63 */
197         uint8_t renderSortLayer { RenderSceneDataConstants::DEFAULT_RENDER_SORT_LAYER_ID };
198         /** Render sort layer id. Valid values are 0 - 255 */
199         uint8_t renderSortLayerOrder { 0 };
200     };
201 
202     /** Submesh material flags
203      */
204     struct SubmeshMaterialFlags {
205         /** Material type */
206         RenderMaterialType materialType { RenderMaterialType::METALLIC_ROUGHNESS };
207         /* Render submesh's submesh flags, dublicated here for convenience */
208         RenderSubmeshFlags submeshFlags { 0u };
209         /** Extra material rendering flags */
210         RenderExtraRenderingFlags extraMaterialRenderingFlags { 0u };
211 
212         /** Render material flags */
213         RenderMaterialFlags renderMaterialFlags { 0u };
214 
215         /** 32 bit hash based on the variables above */
216         uint32_t renderHash { 0u };
217         /** 32 bit hash based on the variables above targeted for default depth rendering hashing */
218         uint32_t renderDepthHash { 0u };
219     };
220 
221     struct SlotMaterialData {
222         /** Custom shader handle or invalid handle */
223         RENDER_NS::RenderHandle shader;
224         /** Custom graphics state handle or invalid handle */
225         RENDER_NS::RenderHandle gfxState;
226         /** Render material flags */
227         RenderMaterialFlags renderMaterialFlags { 0u };
228         /** Render camera id for camera effect (uses only 32 significant id bits) */
229         uint32_t cameraId { 0u };
230         /** Combined of render materials flags hash, material idx, shader id */
231         uint32_t renderSortHash { 0u };
232         /** Combined sort layer from render submesh */
233         uint16_t combinedRenderSortLayer { 0u };
234     };
235 
236     /** Object counts for rendering.
237      */
238     struct ObjectCounts {
239         /** Mesh count, NOTE: is currently global */
240         uint32_t meshCount { 0u };
241         /** Submesh count */
242         uint32_t submeshCount { 0u };
243         /** Skin count */
244         uint32_t skinCount { 0u };
245         /** Material count (frame material count) */
246         uint32_t materialCount { 0u };
247         /** Unique material count */
248         uint32_t uniqueMaterialCount { 0u };
249     };
250 
251     /** Per mesh skin joint matrices.
252      */
253     struct JointMatrixData {
254         /** Matrices */
255         BASE_NS::Math::Mat4X4* data { nullptr };
256         /** Matrix count */
257         uint32_t count { 0 };
258     };
259 
260     /** Material custom resources.
261      */
262     struct CustomResourceData {
263         /** invalid handle if custom material shader not given.
264          * With default material build-in render nodes must have compatible pipeline layout.
265          * With custom render slots and custom render nodes can be anything.
266          */
267         RENDER_NS::RenderHandle shaderHandle;
268 
269         /** handle count */
270         uint32_t resourceHandleCount { 0u };
271         /** invalid handles if not given */
272         RENDER_NS::RenderHandle resourceHandles[MAX_MATERIAL_CUSTOM_RESOURCE_COUNT];
273     };
274 
275     /** Material slot types. Where
276      */
277     enum class MaterialSlotType : uint32_t {
278         /** Basic opaque slot */
279         SLOT_TYPE_OPAQUE = 0,
280         /** Basic translucent slot */
281         SLOT_TYPE_TRANSLUCENT = 1,
282         /** Basic depth slot for shadows and depth pre-pass */
283         SLOT_TYPE_DEPTH = 2,
284     };
285 };
286 
287 /** @ingroup group_render_irenderdatastoredefaultmaterial */
288 /** RenderDataStoreDefaultMaterial interface.
289  * Not internally syncronized.
290  * Default material can be fetched with material id
291  * 0xFFFFffff and 0xFFFFFFFFffffffff
292  */
293 class IRenderDataStoreDefaultMaterial : public RENDER_NS::IRenderDataStore {
294 public:
295     static constexpr BASE_NS::Uid UID { "fdd9f86b-f5fc-45da-8832-41cbd649ed49" };
296 
297     ~IRenderDataStoreDefaultMaterial() override = default;
298 
299     /** [[DEPRECATED]] Add mesh data.
300      * @param meshData All mesh data.
301      * @return Mesh index for submesh to use.
302      */
303     virtual uint32_t AddMeshData(const RenderMeshData& meshData) = 0;
304 
305     /** Add frame render mesh data.
306      * @param id Mesh id. In typical ECS usage mesh entity id.
307      * @param meshAabbData render mesh aabb data.
308      * @param meshSkinData render mesh skin data.
309      */
310     virtual void AddFrameRenderMeshData(const RenderMeshData& meshData, const RenderMeshAabbData& meshAabbData,
311         const RenderMeshSkinData& meshSkinData) = 0;
312 
313     /** Add frame render mesh data with batching.
314      * @param id Mesh id. In typical ECS usage mesh entity id.
315      * @param meshAabbData array view render mesh aabb data.
316      * @param meshSkinData render mesh skin data.
317      * @param meshBatchData render mesh batch data.
318      */
319     virtual void AddFrameRenderMeshData(BASE_NS::array_view<const RenderMeshData> meshData,
320         const RenderMeshAabbData& meshAabbData, const RenderMeshSkinData& meshSkinData,
321         const RenderMeshBatchData& meshBatchData) = 0;
322 
323     /** Update (or create) rendering mesh data.
324      * Automatic hashing with id. (E.g. mesh entity id)
325      * Final rendering flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
326      * @param id Mesh id. In typical ECS usage mesh entity id.
327      * @param meshData Mesh data.
328      */
329     virtual void UpdateMeshData(uint64_t id, const MeshDataWithHandleReference& meshData) = 0;
330 
331     /** Destroy mesh rendering data explicitly.
332      * NOTE: The references for the resources might be zero already at this point.
333      * In typical cases should be automatically called by some ECS system when mesh is destroyed
334      * @param id Mesh id. In typical ECS usage mesh entity id.
335      */
336     virtual void DestroyMeshData(uint64_t id) = 0;
337 
338     /** Update (or create) rendering material data.
339      * Automatic hashing with id. (E.g. material entity id)
340      * Final rendering material flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
341      * @param id Material id. In typical ECS usage material entity id.
342      * @param materialUniforms input material uniforms.
343      * @param materialHandles raw GPU resource handles.
344      * @param materialData Material data.
345      * @return Returns material index.
346      */
347     virtual uint32_t UpdateMaterialData(const uint64_t id,
348         const RenderDataDefaultMaterial::InputMaterialUniforms& materialUniforms,
349         const RenderDataDefaultMaterial::MaterialHandlesWithHandleReference& materialHandles,
350         const RenderDataDefaultMaterial::MaterialData& materialData) = 0;
351 
352     /** Update (or create) rendering material data.
353      * Automatic hashing with id. (E.g. material entity id)
354      * Final rendering material flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
355      * @param id Material component id. In typical ECS usage material entity id.
356      * @param materialUniforms input material uniforms.
357      * @param materialHandles raw GPU resource handles.
358      * @param materialData Material data.
359      * @param customPropertyData Custom property data per material.
360      * @return Returns material index.
361      */
362     virtual uint32_t UpdateMaterialData(const uint64_t id,
363         const RenderDataDefaultMaterial::InputMaterialUniforms& materialUniforms,
364         const RenderDataDefaultMaterial::MaterialHandlesWithHandleReference& materialHandles,
365         const RenderDataDefaultMaterial::MaterialData& materialData,
366         const BASE_NS::array_view<const uint8_t> customPropertyData) = 0;
367 
368     /** Update (or create) rendering material data.
369      * Automatic hashing with id. (E.g. material entity id)
370      * Final rendering material flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
371      * @param id Material component id. In typical ECS usage material entity id.
372      * @param materialUniforms input material uniforms.
373      * @param materialHandles raw GPU resource handles.
374      * @param materialData Material data.
375      * @param customPropertyData Custom property data per material.
376      * @param customBindings Custom bindings data per material.
377      * @return Returns material index.
378      */
379     virtual uint32_t UpdateMaterialData(const uint64_t id,
380         const RenderDataDefaultMaterial::InputMaterialUniforms& materialUniforms,
381         const RenderDataDefaultMaterial::MaterialHandlesWithHandleReference& materialHandles,
382         const RenderDataDefaultMaterial::MaterialData& materialData,
383         const BASE_NS::array_view<const uint8_t> customPropertyData,
384         const BASE_NS::array_view<const RENDER_NS::RenderHandleReference> customBindings) = 0;
385 
386     /** Destroy material rendering data explicitly.
387      * NOTE: The references for the resources might be zero already at this point.
388      * In typical cases should be automatically called by some ECS system when material is destroyed
389      * @param id Material component id. In typical ECS usage material entity id.
390      */
391     virtual void DestroyMaterialData(const uint64_t id) = 0;
392 
393     /** Destroy material rendering data explicitly.
394      * NOTE: The references for the resources might be zero already at this point.
395      * In typical cases should be automatically called by some ECS system when material is destroyed
396      * @param ids Array view of material component ids. In typical ECS usage material entity id.
397      */
398     virtual void DestroyMaterialData(const BASE_NS::array_view<uint64_t> ids) = 0;
399 
400     /** Add material and get material index and frame offset
401      * @param id Material component id. In typical ECS usage material entity id.
402      * @return RenderFrameMaterialIndices material index and frame offset
403      */
404     virtual RenderFrameMaterialIndices AddFrameMaterialData(uint64_t id) = 0;
405 
406     /** Add material and get material index and frame offset
407      * @param id Material component id. In typical ECS usage material entity id.
408      * @param instanceCount Instance count of the same material.
409      * @return RenderFrameMaterialIndices material index and frame offset
410      */
411     virtual RenderFrameMaterialIndices AddFrameMaterialData(uint64_t id, uint32_t instanceCount) = 0;
412 
413     /** Add material and get material index and frame offset
414      * Automatic hashing with id. (E.g. material entity id)
415      * Final rendering material flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
416      * @param id Material component id. In typical ECS usage material entity id.
417      * @return RenderFrameMaterialIndices material index and frame offset
418      */
419     virtual RenderFrameMaterialIndices AddFrameMaterialData(BASE_NS::array_view<const uint64_t> ids) = 0;
420 
421     /** Add material without an id to be rendered this frame.
422      * Prefer using id based material updates.
423      * The data is automatically cleared after the rendering has been processed.
424      * @param materialUniforms input material uniforms.
425      * @param materialHandles raw GPU resource handles.
426      * @param materialData Material data.
427      * @param customPropertyData Custom property data per material.
428      * @param customBindings Custom bindings data per material.
429      */
430     virtual RenderFrameMaterialIndices AddFrameMaterialData(
431         const RenderDataDefaultMaterial::InputMaterialUniforms& materialUniforms,
432         const RenderDataDefaultMaterial::MaterialHandlesWithHandleReference& materialHandles,
433         const RenderDataDefaultMaterial::MaterialData& materialData,
434         const BASE_NS::array_view<const uint8_t> customPropertyData,
435         const BASE_NS::array_view<const RENDER_NS::RenderHandleReference> customBindings) = 0;
436 
437     /** Add material instance data and get material index and frame offset
438      * Final rendering material flags are per submesh (RenderDataDefaultMaterial::SubmeshMaterialFlags)
439      * @param materialIndex Material index (from get material index or update).
440      * @param frameOffset Frame offset for the base instance material.
441      * @param instanceIndex Offset to base frame offset for this instance.
442      * @return Material frame offset index for submesh to use.
443      */
444     virtual RenderFrameMaterialIndices AddFrameMaterialInstanceData(
445         uint32_t materialIndex, uint32_t frameOffset, uint32_t instanceIndex) = 0;
446 
447     /** Get material index.
448      * Default material can be fetched with material id
449      * 0xFFFFffff and 0xFFFFFFFFffffffff
450      * @param id Material component id. In typical ECS usage material entity id.
451      * @return Material index to material array.
452      */
453     virtual uint32_t GetMaterialIndex(uint64_t id) const = 0;
454 
455     /** Get material frame indices for material arrays.
456      * Returns all the material offsets which have been added.
457      * Same material index might be in these offset multiple times due to instancing.
458      * @return Material indices to material arrays.
459      */
460     virtual BASE_NS::array_view<const uint32_t> GetMaterialFrameIndices() const = 0;
461 
462     /** [[DEPRECATED]] Add submeshes safely with default material to rendering. Render slots are evaluated
463      * automatically.
464      * @param submesh Submesh.
465      */
466     virtual void AddSubmesh(const RenderSubmeshWithHandleReference& submesh) = 0;
467 
468     /** [[DEPRECATED]] Add submeshes safely with default material to rendering.
469      * @param submesh Submesh.
470      * @param renderSlotAndShaders All the render slots where the submesh is handled.
471      */
472     virtual void AddSubmesh(const RenderSubmeshWithHandleReference& submesh,
473         const BASE_NS::array_view<const RENDER_NS::IShaderManager::RenderSlotData> renderSlotAndShaders) = 0;
474 
475     /** Set render slots for material types.
476      * @param materialSlotType Material slot type.
477      * @param renderSlotIds All render slot ids.
478      */
479     virtual void SetRenderSlots(const RenderDataDefaultMaterial::MaterialSlotType materialSlotType,
480         const BASE_NS::array_view<const uint32_t> renderSlotIds) = 0;
481 
482     /** Get render slot mask for material type.
483      * @param materialSlotType Material slot type.
484      * @return Mask of render slot ids.
485      */
486     virtual uint64_t GetRenderSlotMask(const RenderDataDefaultMaterial::MaterialSlotType materialSlotType) const = 0;
487 
488     /** Get all object count which were send to rendering
489      * @return ObjectCounts
490      */
491     virtual RenderDataDefaultMaterial::ObjectCounts GetObjectCounts() const = 0;
492 
493     /** Get list of mesh data
494      */
495     virtual BASE_NS::array_view<const RenderMeshData> GetMeshData() const = 0;
496 
497     /** Get list of mesh skin joint matrices
498      */
499     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::JointMatrixData> GetMeshJointMatrices() const = 0;
500 
501     /** Get slot submesh indices
502      * @param renderSlotId Index
503      */
504     virtual BASE_NS::array_view<const uint32_t> GetSlotSubmeshIndices(const uint32_t renderSlotId) const = 0;
505 
506     /** Get slot submesh shader handles
507      * @param renderSlotId Index
508      */
509     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::SlotMaterialData> GetSlotSubmeshMaterialData(
510         const uint32_t renderSlotId) const = 0;
511 
512     /** Get object counts per render slot
513      * @param renderSlotId Index
514      */
515     virtual RenderDataDefaultMaterial::ObjectCounts GetSlotObjectCounts(const uint32_t renderSlotId) const = 0;
516 
517     /** Get list of render submeshes
518      */
519     virtual BASE_NS::array_view<const RenderSubmesh> GetSubmeshes() const = 0;
520 
521     /** Get submesh joint matrix data
522      * @param skinJointIndex Skin joint index from RenderSubmesh got from AddSkinJointMatrices().
523      */
524     virtual BASE_NS::array_view<const BASE_NS::Math::Mat4X4> GetSubmeshJointMatrixData(
525         const uint32_t skinJointIndex) const = 0;
526 
527     /** Get material uniforms (per material) */
528     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::AllMaterialUniforms> GetMaterialUniforms() const = 0;
529     /** Get material handles (per material) */
530     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::MaterialHandles> GetMaterialHandles() const = 0;
531     /** Get material custom property data with material index.
532      * @param materialIndex Index of material from RenderSubmesh and an index if going through e.g. material unforms
533      */
534     virtual BASE_NS::array_view<const uint8_t> GetMaterialCustomPropertyData(const uint32_t materialIndex) const = 0;
535     /** Get submesh material flags (per submesh) */
536     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::SubmeshMaterialFlags>
537     GetSubmeshMaterialFlags() const = 0;
538 
539     /** Get custom resource handles */
540     virtual BASE_NS::array_view<const RenderDataDefaultMaterial::CustomResourceData>
541     GetCustomResourceHandles() const = 0;
542 
543     /** Get information about added render mesh objects.
544      * @return Render frame object info.
545      */
546     virtual RenderFrameObjectInfo GetRenderFrameObjectInfo() const = 0;
547 
548     /** Generate render hash (32 bits as RenderDataDefaultMaterial::SubmeshMaterialFlags::renderHash) */
549     virtual uint32_t GenerateRenderHash(const RenderDataDefaultMaterial::SubmeshMaterialFlags& flags) const = 0;
550 
551     /** Add debug materials for all slot submeshes to be rendered this frame.
552      * The data is automatically cleared after the rendering has been processed.
553      * This should mainly be used for debugging purposes.
554      * @param toSlotId the (debug) render slot which we add a single material for e.g. debugging.
555      * @param fromSlotIds the common render slots with submeshes which we are rendering with additional materials.
556      * @param materialUniforms input material uniforms.
557      * @param materialHandles raw GPU resource handles.
558      * @param materialData Material data.
559      * @param customPropertyData Custom property data per material.
560      * @param customBindings Custom bindings data per material.
561      */
562     virtual RenderFrameMaterialIndices AddRenderSlotSubmeshesFrameMaterialData(const uint32_t toSlotId,
563         BASE_NS::array_view<const uint32_t> fromSlotIds,
564         const RenderDataDefaultMaterial::InputMaterialUniforms& materialUniforms,
565         const RenderDataDefaultMaterial::MaterialHandlesWithHandleReference& materialHandles,
566         const RenderDataDefaultMaterial::MaterialData& materialData,
567         const BASE_NS::array_view<const uint8_t> customPropertyData,
568         const BASE_NS::array_view<const RENDER_NS::RenderHandleReference> customBindings) = 0;
569 
570 protected:
571     IRenderDataStoreDefaultMaterial() = default;
572 };
573 CORE3D_END_NAMESPACE()
574 
575 #endif // API_3D_RENDER_IRENDER_DATA_STORE_DEFAULT_MATERIAL_H
576