Sfoglia il codice sorgente

Some refactoring and renaming

Panagiotis Christopoulos Charitos 4 anni fa
parent
commit
9bd086e5d8

+ 0 - 9
AnKi/Gr/Vulkan/GrManagerImpl.cpp

@@ -67,10 +67,6 @@ GrManagerImpl::~GrManagerImpl()
 
 
 	if(m_debugCallback)
 	if(m_debugCallback)
 	{
 	{
-		PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT =
-			reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(
-				vkGetInstanceProcAddr(m_instance, "vkDestroyDebugReportCallbackEXT"));
-
 		vkDestroyDebugReportCallbackEXT(m_instance, m_debugCallback, nullptr);
 		vkDestroyDebugReportCallbackEXT(m_instance, m_debugCallback, nullptr);
 	}
 	}
 
 
@@ -393,11 +389,6 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 
 
 		ci.pUserData = this;
 		ci.pUserData = this;
 
 
-		PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT =
-			reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(
-				vkGetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT"));
-		ANKI_ASSERT(vkCreateDebugReportCallbackEXT);
-
 		vkCreateDebugReportCallbackEXT(m_instance, &ci, nullptr, &m_debugCallback);
 		vkCreateDebugReportCallbackEXT(m_instance, &ci, nullptr, &m_debugCallback);
 	}
 	}
 
 

+ 7 - 7
AnKi/Importer/GltfImporterMesh.cpp

@@ -624,28 +624,28 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 	memset(&header, 0, sizeof(header));
 	memset(&header, 0, sizeof(header));
 	{
 	{
 		// Positions
 		// Positions
-		MeshBinaryVertexAttribute& posa = header.m_vertexAttributes[VertexAttributeLocation::POSITION];
+		MeshBinaryVertexAttribute& posa = header.m_vertexAttributes[VertexAttributeId::POSITION];
 		posa.m_bufferBinding = 0;
 		posa.m_bufferBinding = 0;
 		posa.m_format = Format::R32G32B32_SFLOAT;
 		posa.m_format = Format::R32G32B32_SFLOAT;
 		posa.m_relativeOffset = 0;
 		posa.m_relativeOffset = 0;
 		posa.m_scale = 1.0f;
 		posa.m_scale = 1.0f;
 
 
 		// Normals
 		// Normals
-		MeshBinaryVertexAttribute& na = header.m_vertexAttributes[VertexAttributeLocation::NORMAL];
+		MeshBinaryVertexAttribute& na = header.m_vertexAttributes[VertexAttributeId::NORMAL];
 		na.m_bufferBinding = 1;
 		na.m_bufferBinding = 1;
 		na.m_format = Format::A2B10G10R10_SNORM_PACK32;
 		na.m_format = Format::A2B10G10R10_SNORM_PACK32;
 		na.m_relativeOffset = 0;
 		na.m_relativeOffset = 0;
 		na.m_scale = 1.0f;
 		na.m_scale = 1.0f;
 
 
 		// Tangents
 		// Tangents
-		MeshBinaryVertexAttribute& ta = header.m_vertexAttributes[VertexAttributeLocation::TANGENT];
+		MeshBinaryVertexAttribute& ta = header.m_vertexAttributes[VertexAttributeId::TANGENT];
 		ta.m_bufferBinding = 1;
 		ta.m_bufferBinding = 1;
 		ta.m_format = Format::A2B10G10R10_SNORM_PACK32;
 		ta.m_format = Format::A2B10G10R10_SNORM_PACK32;
 		ta.m_relativeOffset = sizeof(U32);
 		ta.m_relativeOffset = sizeof(U32);
 		ta.m_scale = 1.0f;
 		ta.m_scale = 1.0f;
 
 
 		// UVs
 		// UVs
-		MeshBinaryVertexAttribute& uva = header.m_vertexAttributes[VertexAttributeLocation::UV];
+		MeshBinaryVertexAttribute& uva = header.m_vertexAttributes[VertexAttributeId::UV0];
 		uva.m_bufferBinding = 1;
 		uva.m_bufferBinding = 1;
 		uva.m_format = Format::R32G32_SFLOAT;
 		uva.m_format = Format::R32G32_SFLOAT;
 		uva.m_relativeOffset = sizeof(U32) * 2;
 		uva.m_relativeOffset = sizeof(U32) * 2;
@@ -654,13 +654,13 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 		// Bone weight
 		// Bone weight
 		if(hasBoneWeights)
 		if(hasBoneWeights)
 		{
 		{
-			MeshBinaryVertexAttribute& bidxa = header.m_vertexAttributes[VertexAttributeLocation::BONE_INDICES];
+			MeshBinaryVertexAttribute& bidxa = header.m_vertexAttributes[VertexAttributeId::BONE_INDICES];
 			bidxa.m_bufferBinding = 2;
 			bidxa.m_bufferBinding = 2;
 			bidxa.m_format = Format::R8G8B8A8_UINT;
 			bidxa.m_format = Format::R8G8B8A8_UINT;
 			bidxa.m_relativeOffset = 0;
 			bidxa.m_relativeOffset = 0;
 			bidxa.m_scale = 1.0f;
 			bidxa.m_scale = 1.0f;
 
 
-			MeshBinaryVertexAttribute& wa = header.m_vertexAttributes[VertexAttributeLocation::BONE_WEIGHTS];
+			MeshBinaryVertexAttribute& wa = header.m_vertexAttributes[VertexAttributeId::BONE_WEIGHTS];
 			wa.m_bufferBinding = 2;
 			wa.m_bufferBinding = 2;
 			wa.m_format = Format::R8G8B8A8_UNORM;
 			wa.m_format = Format::R8G8B8A8_UNORM;
 			wa.m_relativeOffset = sizeof(U8Vec4);
 			wa.m_relativeOffset = sizeof(U8Vec4);
@@ -773,7 +773,7 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 
 
 			verts[i].m_normal = packColorToR10G10B10A2SNorm(normal.x(), normal.y(), normal.z(), 0.0f);
 			verts[i].m_normal = packColorToR10G10B10A2SNorm(normal.x(), normal.y(), normal.z(), 0.0f);
 			verts[i].m_tangent = packColorToR10G10B10A2SNorm(tangent.x(), tangent.y(), tangent.z(), tangent.w());
 			verts[i].m_tangent = packColorToR10G10B10A2SNorm(tangent.x(), tangent.y(), tangent.z(), tangent.w());
-			verts[i].m_uvs[UV_CHANNEL_0] = uv;
+			verts[i].m_uv0 = uv;
 		}
 		}
 
 
 		ANKI_CHECK(file.write(&verts[0], verts.getSizeInBytes()));
 		ANKI_CHECK(file.write(&verts[0], verts.getSizeInBytes()));

+ 1 - 1
AnKi/Renderer/TraditionalDeferredShading.cpp

@@ -61,7 +61,7 @@ void TraditionalDeferredLightShading::bindVertexIndexBuffers(MeshResourcePtr& me
 	U32 bufferBinding;
 	U32 bufferBinding;
 	Format fmt;
 	Format fmt;
 	U32 relativeOffset;
 	U32 relativeOffset;
-	mesh->getVertexAttributeInfo(VertexAttributeLocation::POSITION, bufferBinding, fmt, relativeOffset);
+	mesh->getVertexAttributeInfo(VertexAttributeId::POSITION, bufferBinding, fmt, relativeOffset);
 
 
 	cmdb->setVertexAttribute(0, 0, fmt, relativeOffset);
 	cmdb->setVertexAttribute(0, 0, fmt, relativeOffset);
 
 

+ 1 - 18
AnKi/Resource/Common.h

@@ -10,7 +10,7 @@
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Gr/Enums.h>
 #include <AnKi/Gr/Enums.h>
-#include <AnKi/Shaders/Include/Common.h>
+#include <AnKi/Shaders/Include/ModelTypes.h>
 
 
 namespace anki
 namespace anki
 {
 {
@@ -34,23 +34,6 @@ class TransferGpuAllocatorHandle;
 /// @name Constants
 /// @name Constants
 /// @{
 /// @{
 
 
-/// Standard attribute locations. Should be the same as in Common.glsl.
-enum class VertexAttributeLocation : U8
-{
-	POSITION,
-	UV,
-	UV2,
-	NORMAL,
-	TANGENT,
-	COLOR,
-	BONE_WEIGHTS,
-	BONE_INDICES,
-
-	COUNT,
-	FIRST = POSITION,
-};
-ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VertexAttributeLocation)
-
 enum class RayType : U8
 enum class RayType : U8
 {
 {
 	SHADOWS,
 	SHADOWS,

+ 11 - 11
AnKi/Resource/MaterialResource.cpp

@@ -126,18 +126,18 @@ class GpuMaterialTexture
 {
 {
 public:
 public:
 	const char* m_name;
 	const char* m_name;
-	U32 m_textureSlot;
+	TextureChannelId m_textureSlot;
 };
 };
 
 
-static const Array<GpuMaterialTexture, TEXTURE_CHANNEL_COUNT> GPU_MATERIAL_TEXTURES = {
-	{{"TEXTURE_CHANNEL_DIFFUSE", TEXTURE_CHANNEL_DIFFUSE},
-	 {"TEXTURE_CHANNEL_NORMAL", TEXTURE_CHANNEL_NORMAL},
-	 {"TEXTURE_CHANNEL_ROUGHNESS_METALNESS", TEXTURE_CHANNEL_ROUGHNESS_METALNESS},
-	 {"TEXTURE_CHANNEL_EMISSION", TEXTURE_CHANNEL_EMISSION},
-	 {"TEXTURE_CHANNEL_HEIGHT", TEXTURE_CHANNEL_HEIGHT},
-	 {"TEXTURE_CHANNEL_AUX_0", TEXTURE_CHANNEL_AUX_0},
-	 {"TEXTURE_CHANNEL_AUX_1", TEXTURE_CHANNEL_AUX_1},
-	 {"TEXTURE_CHANNEL_AUX_2", TEXTURE_CHANNEL_AUX_2}}};
+static const Array<GpuMaterialTexture, U(TextureChannelId::COUNT)> GPU_MATERIAL_TEXTURES = {
+	{{"TEXTURE_CHANNEL_DIFFUSE", TextureChannelId::DIFFUSE},
+	 {"TEXTURE_CHANNEL_NORMAL", TextureChannelId::NORMAL},
+	 {"TEXTURE_CHANNEL_ROUGHNESS_METALNESS", TextureChannelId::ROUGHNESS_METALNESS},
+	 {"TEXTURE_CHANNEL_EMISSION", TextureChannelId::EMISSION},
+	 {"TEXTURE_CHANNEL_HEIGHT", TextureChannelId::HEIGHT},
+	 {"TEXTURE_CHANNEL_AUX_0", TextureChannelId::AUX_0},
+	 {"TEXTURE_CHANNEL_AUX_1", TextureChannelId::AUX_1},
+	 {"TEXTURE_CHANNEL_AUX_2", TextureChannelId::AUX_2}}};
 
 
 class GpuMaterialFloats
 class GpuMaterialFloats
 {
 {
@@ -1234,7 +1234,7 @@ Error MaterialResource::parseRtMaterial(XmlElement rtMaterialEl)
 					CString fname;
 					CString fname;
 					ANKI_CHECK(inputEl.getAttributeText("value", fname));
 					ANKI_CHECK(inputEl.getAttributeText("value", fname));
 
 
-					const U32 textureIdx = GPU_MATERIAL_TEXTURES[i].m_textureSlot;
+					const TextureChannelId textureIdx = GPU_MATERIAL_TEXTURES[i].m_textureSlot;
 					ANKI_CHECK(getManager().loadResource(fname, m_textureResources[textureIdx], false));
 					ANKI_CHECK(getManager().loadResource(fname, m_textureResources[textureIdx], false));
 
 
 					m_textureViews[m_textureViewCount] = m_textureResources[textureIdx]->getGrTextureView();
 					m_textureViews[m_textureViewCount] = m_textureResources[textureIdx]->getGrTextureView();

+ 2 - 2
AnKi/Resource/MaterialResource.h

@@ -439,8 +439,8 @@ private:
 
 
 	MaterialGpuDescriptor m_materialGpuDescriptor;
 	MaterialGpuDescriptor m_materialGpuDescriptor;
 
 
-	Array<TextureResourcePtr, TEXTURE_CHANNEL_COUNT> m_textureResources; ///< Keep the resources alive.
-	Array<TextureViewPtr, TEXTURE_CHANNEL_COUNT> m_textureViews; ///< Cache the GPU objects.
+	Array<TextureResourcePtr, U(TextureChannelId::COUNT)> m_textureResources; ///< Keep the resources alive.
+	Array<TextureViewPtr, U(TextureChannelId::COUNT)> m_textureViews; ///< Cache the GPU objects.
 	U8 m_textureViewCount = 0;
 	U8 m_textureViewCount = 0;
 
 
 	RayTypeBit m_rayTypes = RayTypeBit::NONE;
 	RayTypeBit m_rayTypes = RayTypeBit::NONE;

+ 2 - 2
AnKi/Resource/MeshBinary.h

@@ -125,9 +125,9 @@ class MeshBinaryHeader
 public:
 public:
 	Array<U8, 8> m_magic;
 	Array<U8, 8> m_magic;
 	MeshBinaryFlag m_flags;
 	MeshBinaryFlag m_flags;
-	Array<MeshBinaryVertexBuffer, U32(VertexAttributeLocation::COUNT)> m_vertexBuffers;
+	Array<MeshBinaryVertexBuffer, U32(VertexAttributeId::COUNT)> m_vertexBuffers;
 	U32 m_vertexBufferCount;
 	U32 m_vertexBufferCount;
-	Array<MeshBinaryVertexAttribute, U32(VertexAttributeLocation::COUNT)> m_vertexAttributes;
+	Array<MeshBinaryVertexAttribute, U32(VertexAttributeId::COUNT)> m_vertexAttributes;
 	IndexType m_indexType;
 	IndexType m_indexType;
 	Array<U8, 3> m_padding;
 	Array<U8, 3> m_padding;
 	U32 m_totalIndexCount;
 	U32 m_totalIndexCount;

+ 2 - 2
AnKi/Resource/MeshBinary.xml

@@ -51,9 +51,9 @@ ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(MeshBinaryFlag)
 			<members>
 			<members>
 				<member name="m_magic" type="U8" array_size="8"/>
 				<member name="m_magic" type="U8" array_size="8"/>
 				<member name="m_flags" type="MeshBinaryFlag"/>
 				<member name="m_flags" type="MeshBinaryFlag"/>
-				<member name="m_vertexBuffers" type="MeshBinaryVertexBuffer" array_size="U32(VertexAttributeLocation::COUNT)"/>
+				<member name="m_vertexBuffers" type="MeshBinaryVertexBuffer" array_size="U32(VertexAttributeId::COUNT)"/>
 				<member name="m_vertexBufferCount" type="U32"/>
 				<member name="m_vertexBufferCount" type="U32"/>
-				<member name="m_vertexAttributes" type="MeshBinaryVertexAttribute" array_size="U32(VertexAttributeLocation::COUNT)"/>
+				<member name="m_vertexAttributes" type="MeshBinaryVertexAttribute" array_size="U32(VertexAttributeId::COUNT)"/>
 				<member name="m_indexType" type="IndexType"/>
 				<member name="m_indexType" type="IndexType"/>
 				<member name="m_padding" type="U8" array_size="3"/>
 				<member name="m_padding" type="U8" array_size="3"/>
 				<member name="m_totalIndexCount" type="U32"/>
 				<member name="m_totalIndexCount" type="U32"/>

+ 9 - 11
AnKi/Resource/MeshBinaryLoader.cpp

@@ -67,7 +67,7 @@ Error MeshBinaryLoader::load(const ResourceFilename& filename)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-Error MeshBinaryLoader::checkFormat(VertexAttributeLocation type, ConstWeakArray<Format> supportedFormats,
+Error MeshBinaryLoader::checkFormat(VertexAttributeId type, ConstWeakArray<Format> supportedFormats,
 									U32 vertexBufferIdx, U32 relativeOffset) const
 									U32 vertexBufferIdx, U32 relativeOffset) const
 {
 {
 	const MeshBinaryVertexAttribute& attrib = m_header.m_vertexAttributes[type];
 	const MeshBinaryVertexAttribute& attrib = m_header.m_vertexAttributes[type];
@@ -138,17 +138,15 @@ Error MeshBinaryLoader::checkHeader() const
 	}
 	}
 
 
 	// Attributes
 	// Attributes
-	ANKI_CHECK(checkFormat(VertexAttributeLocation::POSITION, Array<Format, 1>{{Format::R32G32B32_SFLOAT}}, 0, 0));
+	ANKI_CHECK(checkFormat(VertexAttributeId::POSITION, Array<Format, 1>{{Format::R32G32B32_SFLOAT}}, 0, 0));
+	ANKI_CHECK(checkFormat(VertexAttributeId::NORMAL, Array<Format, 1>{{Format::A2B10G10R10_SNORM_PACK32}}, 1, 0));
+	ANKI_CHECK(checkFormat(VertexAttributeId::TANGENT, Array<Format, 1>{{Format::A2B10G10R10_SNORM_PACK32}}, 1, 4));
+	ANKI_CHECK(checkFormat(VertexAttributeId::UV0, Array<Format, 1>{{Format::R32G32_SFLOAT}}, 1, 8));
+	ANKI_CHECK(checkFormat(VertexAttributeId::UV1, Array<Format, 1>{{Format::NONE}}, 1, 0));
 	ANKI_CHECK(
 	ANKI_CHECK(
-		checkFormat(VertexAttributeLocation::NORMAL, Array<Format, 1>{{Format::A2B10G10R10_SNORM_PACK32}}, 1, 0));
+		checkFormat(VertexAttributeId::BONE_INDICES, Array<Format, 2>{{Format::NONE, Format::R8G8B8A8_UINT}}, 2, 0));
 	ANKI_CHECK(
 	ANKI_CHECK(
-		checkFormat(VertexAttributeLocation::TANGENT, Array<Format, 1>{{Format::A2B10G10R10_SNORM_PACK32}}, 1, 4));
-	ANKI_CHECK(checkFormat(VertexAttributeLocation::UV, Array<Format, 1>{{Format::R32G32_SFLOAT}}, 1, 8));
-	ANKI_CHECK(checkFormat(VertexAttributeLocation::UV2, Array<Format, 1>{{Format::NONE}}, 1, 0));
-	ANKI_CHECK(checkFormat(VertexAttributeLocation::BONE_INDICES,
-						   Array<Format, 2>{{Format::NONE, Format::R8G8B8A8_UINT}}, 2, 0));
-	ANKI_CHECK(checkFormat(VertexAttributeLocation::BONE_WEIGHTS,
-						   Array<Format, 2>{{Format::NONE, Format::R8G8B8A8_UNORM}}, 2, 4));
+		checkFormat(VertexAttributeId::BONE_WEIGHTS, Array<Format, 2>{{Format::NONE, Format::R8G8B8A8_UNORM}}, 2, 4));
 
 
 	// Vertex buffers
 	// Vertex buffers
 	if(m_header.m_vertexBufferCount != 2 + U32(hasBoneInfo()))
 	if(m_header.m_vertexBufferCount != 2 + U32(hasBoneInfo()))
@@ -279,7 +277,7 @@ Error MeshBinaryLoader::storeIndicesAndPosition(DynamicArrayAuto<U32>& indices,
 	// Store positions
 	// Store positions
 	{
 	{
 		positions.resize(m_header.m_totalVertexCount);
 		positions.resize(m_header.m_totalVertexCount);
-		const MeshBinaryVertexAttribute& attrib = m_header.m_vertexAttributes[VertexAttributeLocation::POSITION];
+		const MeshBinaryVertexAttribute& attrib = m_header.m_vertexAttributes[VertexAttributeId::POSITION];
 		ANKI_ASSERT(attrib.m_format == Format::R32G32B32_SFLOAT);
 		ANKI_ASSERT(attrib.m_format == Format::R32G32B32_SFLOAT);
 		ANKI_CHECK(storeVertexBuffer(attrib.m_bufferBinding, &positions[0], positions.getSizeInBytes()));
 		ANKI_CHECK(storeVertexBuffer(attrib.m_bufferBinding, &positions[0], positions.getSizeInBytes()));
 	}
 	}

+ 2 - 2
AnKi/Resource/MeshBinaryLoader.h

@@ -48,7 +48,7 @@ public:
 	Bool hasBoneInfo() const
 	Bool hasBoneInfo() const
 	{
 	{
 		ANKI_ASSERT(isLoaded());
 		ANKI_ASSERT(isLoaded());
-		return m_header.m_vertexAttributes[VertexAttributeLocation::BONE_INDICES].m_format != Format::NONE;
+		return m_header.m_vertexAttributes[VertexAttributeId::BONE_INDICES].m_format != Format::NONE;
 	}
 	}
 
 
 	ConstWeakArray<MeshBinarySubMesh> getSubMeshes() const
 	ConstWeakArray<MeshBinarySubMesh> getSubMeshes() const
@@ -97,7 +97,7 @@ private:
 	}
 	}
 
 
 	ANKI_USE_RESULT Error checkHeader() const;
 	ANKI_USE_RESULT Error checkHeader() const;
-	ANKI_USE_RESULT Error checkFormat(VertexAttributeLocation type, ConstWeakArray<Format> supportedFormats,
+	ANKI_USE_RESULT Error checkFormat(VertexAttributeId type, ConstWeakArray<Format> supportedFormats,
 									  U32 vertexBufferIdx, U32 relativeOffset) const;
 									  U32 vertexBufferIdx, U32 relativeOffset) const;
 };
 };
 /// @}
 /// @}

+ 8 - 9
AnKi/Resource/MeshResource.cpp

@@ -142,8 +142,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		BufferInitInfo(totalVertexBuffSize, vertexBufferUsage, BufferMapAccessBit::NONE,
 		BufferInitInfo(totalVertexBuffSize, vertexBufferUsage, BufferMapAccessBit::NONE,
 					   StringAuto(getTempAllocator()).sprintf("%s_%s", "Vert", basename.cstr())));
 					   StringAuto(getTempAllocator()).sprintf("%s_%s", "Vert", basename.cstr())));
 
 
-	for(VertexAttributeLocation attrib = VertexAttributeLocation::FIRST; attrib < VertexAttributeLocation::COUNT;
-		++attrib)
+	for(VertexAttributeId attrib = VertexAttributeId::FIRST; attrib < VertexAttributeId::COUNT; ++attrib)
 	{
 	{
 		AttribInfo& out = m_attributes[attrib];
 		AttribInfo& out = m_attributes[attrib];
 		const MeshBinaryVertexAttribute& in = header.m_vertexAttributes[attrib];
 		const MeshBinaryVertexAttribute& in = header.m_vertexAttributes[attrib];
@@ -193,7 +192,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		U32 bufferIdx;
 		U32 bufferIdx;
 		Format format;
 		Format format;
 		U32 relativeOffset;
 		U32 relativeOffset;
-		getVertexAttributeInfo(VertexAttributeLocation::POSITION, bufferIdx, format, relativeOffset);
+		getVertexAttributeInfo(VertexAttributeId::POSITION, bufferIdx, format, relativeOffset);
 
 
 		BufferPtr buffer;
 		BufferPtr buffer;
 		PtrSize offset;
 		PtrSize offset;
@@ -215,23 +214,23 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		U32 bufferIdx;
 		U32 bufferIdx;
 		Format format;
 		Format format;
 		U32 relativeOffset;
 		U32 relativeOffset;
-		getVertexAttributeInfo(VertexAttributeLocation::POSITION, bufferIdx, format, relativeOffset);
+		getVertexAttributeInfo(VertexAttributeId::POSITION, bufferIdx, format, relativeOffset);
 		BufferPtr buffer;
 		BufferPtr buffer;
 		PtrSize offset;
 		PtrSize offset;
 		PtrSize stride;
 		PtrSize stride;
 		getVertexBufferInfo(bufferIdx, buffer, offset, stride);
 		getVertexBufferInfo(bufferIdx, buffer, offset, stride);
 		m_meshGpuDescriptor.m_indexBufferPtr = m_indexBuffer->getGpuAddress();
 		m_meshGpuDescriptor.m_indexBufferPtr = m_indexBuffer->getGpuAddress();
-		m_meshGpuDescriptor.m_positionBufferPtr = buffer->getGpuAddress();
+		m_meshGpuDescriptor.m_vertexBufferPtrs[VertexAttributeBufferId::POSITION] = buffer->getGpuAddress();
 
 
-		getVertexAttributeInfo(VertexAttributeLocation::NORMAL, bufferIdx, format, relativeOffset);
+		getVertexAttributeInfo(VertexAttributeId::NORMAL, bufferIdx, format, relativeOffset);
 		getVertexBufferInfo(bufferIdx, buffer, offset, stride);
 		getVertexBufferInfo(bufferIdx, buffer, offset, stride);
-		m_meshGpuDescriptor.m_mainVertexBufferPtr = buffer->getGpuAddress();
+		m_meshGpuDescriptor.m_vertexBufferPtrs[VertexAttributeBufferId::NORMAL_TANGENT_UV0] = buffer->getGpuAddress();
 
 
 		if(hasBoneWeights())
 		if(hasBoneWeights())
 		{
 		{
-			getVertexAttributeInfo(VertexAttributeLocation::BONE_WEIGHTS, bufferIdx, format, relativeOffset);
+			getVertexAttributeInfo(VertexAttributeId::BONE_WEIGHTS, bufferIdx, format, relativeOffset);
 			getVertexBufferInfo(bufferIdx, buffer, offset, stride);
 			getVertexBufferInfo(bufferIdx, buffer, offset, stride);
-			m_meshGpuDescriptor.m_boneInfoVertexBufferPtr = buffer->getGpuAddress();
+			m_meshGpuDescriptor.m_vertexBufferPtrs[VertexAttributeBufferId::BONE] = buffer->getGpuAddress();
 		}
 		}
 
 
 		m_meshGpuDescriptor.m_indexCount = m_indexCount;
 		m_meshGpuDescriptor.m_indexCount = m_indexCount;

+ 4 - 4
AnKi/Resource/MeshResource.h

@@ -79,7 +79,7 @@ public:
 	}
 	}
 
 
 	/// Get attribute info. You need to check if the attribute is preset first (isVertexAttributePresent)
 	/// Get attribute info. You need to check if the attribute is preset first (isVertexAttributePresent)
-	void getVertexAttributeInfo(const VertexAttributeLocation attrib, U32& bufferIdx, Format& format,
+	void getVertexAttributeInfo(const VertexAttributeId attrib, U32& bufferIdx, Format& format,
 								U32& relativeOffset) const
 								U32& relativeOffset) const
 	{
 	{
 		ANKI_ASSERT(isVertexAttributePresent(attrib));
 		ANKI_ASSERT(isVertexAttributePresent(attrib));
@@ -89,7 +89,7 @@ public:
 	}
 	}
 
 
 	/// Check if a vertex attribute is present.
 	/// Check if a vertex attribute is present.
-	Bool isVertexAttributePresent(const VertexAttributeLocation attrib) const
+	Bool isVertexAttributePresent(const VertexAttributeId attrib) const
 	{
 	{
 		return !!m_attributes[attrib].m_format;
 		return !!m_attributes[attrib].m_format;
 	}
 	}
@@ -97,7 +97,7 @@ public:
 	/// Return true if it has bone weights.
 	/// Return true if it has bone weights.
 	Bool hasBoneWeights() const
 	Bool hasBoneWeights() const
 	{
 	{
-		return isVertexAttributePresent(VertexAttributeLocation::BONE_WEIGHTS);
+		return isVertexAttributePresent(VertexAttributeId::BONE_WEIGHTS);
 	}
 	}
 
 
 	AccelerationStructurePtr getBottomLevelAccelerationStructure() const
 	AccelerationStructurePtr getBottomLevelAccelerationStructure() const
@@ -152,7 +152,7 @@ private:
 
 
 	DynamicArray<SubMesh> m_subMeshes;
 	DynamicArray<SubMesh> m_subMeshes;
 	DynamicArray<VertBuffInfo> m_vertexBufferInfos;
 	DynamicArray<VertBuffInfo> m_vertexBufferInfos;
-	Array<AttribInfo, U(VertexAttributeLocation::COUNT)> m_attributes;
+	Array<AttribInfo, U(VertexAttributeId::COUNT)> m_attributes;
 
 
 	BufferPtr m_indexBuffer;
 	BufferPtr m_indexBuffer;
 	BufferPtr m_vertexBuffer;
 	BufferPtr m_vertexBuffer;

+ 5 - 5
AnKi/Resource/ModelResource.cpp

@@ -12,7 +12,7 @@
 namespace anki
 namespace anki
 {
 {
 
 
-static Bool attributeIsRequired(VertexAttributeLocation loc, Pass pass, Bool hasSkin)
+static Bool attributeIsRequired(VertexAttributeId loc, Pass pass, Bool hasSkin)
 {
 {
 	if(pass == Pass::GB || pass == Pass::FS)
 	if(pass == Pass::GB || pass == Pass::FS)
 	{
 	{
@@ -20,12 +20,12 @@ static Bool attributeIsRequired(VertexAttributeLocation loc, Pass pass, Bool has
 	}
 	}
 	else if(!hasSkin)
 	else if(!hasSkin)
 	{
 	{
-		return loc == VertexAttributeLocation::POSITION;
+		return loc == VertexAttributeId::POSITION;
 	}
 	}
 	else
 	else
 	{
 	{
-		return loc == VertexAttributeLocation::POSITION || loc == VertexAttributeLocation::BONE_INDICES
-			   || loc == VertexAttributeLocation::BONE_WEIGHTS;
+		return loc == VertexAttributeId::POSITION || loc == VertexAttributeId::BONE_INDICES
+			   || loc == VertexAttributeId::BONE_WEIGHTS;
 	}
 	}
 }
 }
 
 
@@ -44,7 +44,7 @@ void ModelPatch::getRenderingInfo(const RenderingKey& key, ModelRenderingInfo& i
 		inf.m_vertexAttributeCount = 0;
 		inf.m_vertexAttributeCount = 0;
 		inf.m_vertexBufferBindingCount = 0;
 		inf.m_vertexBufferBindingCount = 0;
 
 
-		for(VertexAttributeLocation loc = VertexAttributeLocation::FIRST; loc < VertexAttributeLocation::COUNT; ++loc)
+		for(VertexAttributeId loc = VertexAttributeId::FIRST; loc < VertexAttributeId::COUNT; ++loc)
 		{
 		{
 			if(!mesh.isVertexAttributePresent(loc) || !attributeIsRequired(loc, key.getPass(), key.isSkinned()))
 			if(!mesh.isVertexAttributePresent(loc) || !attributeIsRequired(loc, key.getPass(), key.isSkinned()))
 			{
 			{

+ 3 - 3
AnKi/Resource/ModelResource.h

@@ -41,7 +41,7 @@ public:
 class ModelVertexAttribute
 class ModelVertexAttribute
 {
 {
 public:
 public:
-	VertexAttributeLocation m_location;
+	VertexAttributeId m_location;
 	Format m_format;
 	Format m_format;
 	U32 m_bufferBinding;
 	U32 m_bufferBinding;
 	U32 m_relativeOffset;
 	U32 m_relativeOffset;
@@ -89,7 +89,7 @@ public:
 	Array<U32, U(RayType::COUNT)> m_shaderGroupHandleIndices;
 	Array<U32, U(RayType::COUNT)> m_shaderGroupHandleIndices;
 
 
 	/// Get some pointers that the m_descriptor is pointing to. Use these pointers for life tracking.
 	/// Get some pointers that the m_descriptor is pointing to. Use these pointers for life tracking.
-	Array<GrObjectPtr, TEXTURE_CHANNEL_COUNT + 2> m_grObjectReferences;
+	Array<GrObjectPtr, U(TextureChannelId::COUNT) + 2> m_grObjectReferences;
 	U32 m_grObjectReferenceCount;
 	U32 m_grObjectReferenceCount;
 };
 };
 
 
@@ -126,7 +126,7 @@ public:
 	}
 	}
 
 
 private:
 private:
-	ModelResource* m_model ANKI_DEBUG_CODE(= nullptr);
+	ModelResource* m_model = nullptr;
 
 
 	MaterialResourcePtr m_mtl;
 	MaterialResourcePtr m_mtl;
 
 

+ 3 - 3
AnKi/Scene/Components/ParticleEmitterComponent.cpp

@@ -404,9 +404,9 @@ void ParticleEmitterComponent::draw(RenderQueueDrawContext& ctx) const
 		cmdb->bindShaderProgram(prog);
 		cmdb->bindShaderProgram(prog);
 
 
 		// Vertex attribs
 		// Vertex attribs
-		cmdb->setVertexAttribute(0, 0, Format::R32G32B32_SFLOAT, 0);
-		cmdb->setVertexAttribute(1, 0, Format::R32_SFLOAT, sizeof(Vec3));
-		cmdb->setVertexAttribute(2, 0, Format::R32_SFLOAT, sizeof(Vec3) + sizeof(F32));
+		cmdb->setVertexAttribute(U32(VertexAttributeId::POSITION), 0, Format::R32G32B32_SFLOAT, 0);
+		cmdb->setVertexAttribute(U32(VertexAttributeId::SCALE), 0, Format::R32_SFLOAT, sizeof(Vec3));
+		cmdb->setVertexAttribute(U32(VertexAttributeId::ALPHA), 0, Format::R32_SFLOAT, sizeof(Vec3) + sizeof(F32));
 
 
 		// Vertex buff
 		// Vertex buff
 		cmdb->bindVertexBuffer(0, token.m_buffer, token.m_offset, VERTEX_SIZE, VertexStepRate::INSTANCE);
 		cmdb->bindVertexBuffer(0, token.m_buffer, token.m_offset, VERTEX_SIZE, VertexStepRate::INSTANCE);

+ 6 - 0
AnKi/ShaderCompiler/ShaderProgramParser.cpp

@@ -673,6 +673,12 @@ Error ShaderProgramParser::parseInclude(const StringAuto* begin, const StringAut
 		StringAuto fname2(m_alloc);
 		StringAuto fname2(m_alloc);
 		fname2.create(path.begin() + 1, path.begin() + path.getLength() - 1);
 		fname2.create(path.begin() + 1, path.begin() + path.getLength() - 1);
 
 
+		if(fname2.find("AnKi/Shaders/") == String::NPOS)
+		{
+			// The shaders can't include C++ files. Ignore the include
+			return Error::NONE;
+		}
+
 		if(parseFile(fname2, depth + 1))
 		if(parseFile(fname2, depth + 1))
 		{
 		{
 			ANKI_PP_ERROR_MALFORMED_MSG("Error parsing include. See previous errors");
 			ANKI_PP_ERROR_MALFORMED_MSG("Error parsing include. See previous errors");

+ 0 - 13
AnKi/Shaders/Common.glsl

@@ -25,19 +25,6 @@ const U32 MAX_SHARED_MEMORY = 32u * 1024u;
 #define saturate(x_) clamp((x_), 0.0, 1.0)
 #define saturate(x_) clamp((x_), 0.0, 1.0)
 #define mad(a_, b_, c_) fma((a_), (b_), (c_))
 #define mad(a_, b_, c_) fma((a_), (b_), (c_))
 
 
-// Common locations
-#define POSITION_LOCATION 0
-#define TEXTURE_COORDINATE_LOCATION 1
-#define TEXTURE_COORDINATE_LOCATION_2 2
-#define NORMAL_LOCATION 3
-#define TANGENT_LOCATION 4
-#define COLOR_LOCATION 5
-#define BONE_WEIGHTS_LOCATION 6
-#define BONE_INDICES_LOCATION 7
-
-#define SCALE_LOCATION 1
-#define ALPHA_LOCATION 2
-
 // Passes
 // Passes
 #define PASS_GB 0
 #define PASS_GB 0
 #define PASS_FS 1
 #define PASS_FS 1

+ 1 - 0
AnKi/Shaders/ForwardShadingCommonFrag.glsl

@@ -8,6 +8,7 @@
 // Common code for all fragment shaders of FS
 // Common code for all fragment shaders of FS
 #include <AnKi/Shaders/Common.glsl>
 #include <AnKi/Shaders/Common.glsl>
 #include <AnKi/Shaders/Functions.glsl>
 #include <AnKi/Shaders/Functions.glsl>
+#include <AnKi/Shaders/Include/ModelTypes.h>
 
 
 // Global resources
 // Global resources
 layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
 layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;

+ 2 - 1
AnKi/Shaders/ForwardShadingCommonVert.glsl

@@ -7,9 +7,10 @@
 
 
 // Common code for all vertex shaders of FS
 // Common code for all vertex shaders of FS
 #include <AnKi/Shaders/Common.glsl>
 #include <AnKi/Shaders/Common.glsl>
+#include <AnKi/Shaders/Include/ModelTypes.h>
 
 
 // In/out
 // In/out
-layout(location = POSITION_LOCATION) in Vec3 in_position;
+layout(location = VERTEX_ATTRIBUTE_ID_POSITION) in Vec3 in_position;
 
 
 out gl_PerVertex
 out gl_PerVertex
 {
 {

+ 2 - 2
AnKi/Shaders/ForwardShadingParticles.ankiprog

@@ -33,8 +33,8 @@ layout(set = 1, binding = 2) uniform texture2DArray u_diffuseMapArr;
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/ForwardShadingCommonVert.glsl>
 #include <AnKi/Shaders/ForwardShadingCommonVert.glsl>
 
 
-layout(location = SCALE_LOCATION) in F32 in_scale;
-layout(location = ALPHA_LOCATION) in F32 in_alpha;
+layout(location = VERTEX_ATTRIBUTE_ID_SCALE) in F32 in_scale;
+layout(location = VERTEX_ATTRIBUTE_ID_ALPHA) in F32 in_alpha;
 
 
 layout(location = 0) flat out F32 out_alpha;
 layout(location = 0) flat out F32 out_alpha;
 layout(location = 1) out Vec2 out_uv;
 layout(location = 1) out Vec2 out_uv;

+ 7 - 6
AnKi/Shaders/GBufferCommon.glsl

@@ -8,21 +8,22 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Shaders/Pack.glsl>
 #include <AnKi/Shaders/Pack.glsl>
+#include <AnKi/Shaders/Include/ModelTypes.h>
 
 
 //
 //
 // Vert input
 // Vert input
 //
 //
 #if defined(ANKI_VERTEX_SHADER)
 #if defined(ANKI_VERTEX_SHADER)
-layout(location = POSITION_LOCATION) in Vec3 in_position;
+layout(location = VERTEX_ATTRIBUTE_ID_POSITION) in Vec3 in_position;
 #	if ANKI_PASS == PASS_GB
 #	if ANKI_PASS == PASS_GB
-layout(location = TEXTURE_COORDINATE_LOCATION) in Vec2 in_uv;
-layout(location = NORMAL_LOCATION) in Vec3 in_normal;
-layout(location = TANGENT_LOCATION) in Vec4 in_tangent;
+layout(location = VERTEX_ATTRIBUTE_ID_UV0) in Vec2 in_uv;
+layout(location = VERTEX_ATTRIBUTE_ID_NORMAL) in Vec3 in_normal;
+layout(location = VERTEX_ATTRIBUTE_ID_TANGENT) in Vec4 in_tangent;
 #	endif
 #	endif
 
 
 #	if ANKI_BONES
 #	if ANKI_BONES
-layout(location = BONE_WEIGHTS_LOCATION) in Vec4 in_boneWeights;
-layout(location = BONE_INDICES_LOCATION) in UVec4 in_boneIndices;
+layout(location = VERTEX_ATTRIBUTE_ID_BONE_WEIGHTS) in Vec4 in_boneWeights;
+layout(location = VERTEX_ATTRIBUTE_ID_BONE_INDICES) in UVec4 in_boneIndices;
 #	endif
 #	endif
 #endif
 #endif
 
 

+ 3 - 0
AnKi/Shaders/Include/Common.h

@@ -9,6 +9,9 @@
 // Macros & functions C++
 // Macros & functions C++
 //
 //
 #if defined(__cplusplus)
 #if defined(__cplusplus)
+
+#	include <AnKi/Math.h>
+
 #	define ANKI_BEGIN_NAMESPACE \
 #	define ANKI_BEGIN_NAMESPACE \
 		namespace anki \
 		namespace anki \
 		{
 		{

+ 91 - 20
AnKi/Shaders/Include/ModelTypes.h

@@ -9,15 +9,65 @@
 
 
 ANKI_BEGIN_NAMESPACE
 ANKI_BEGIN_NAMESPACE
 
 
-const U32 UV_CHANNEL_0 = 0u;
-const U32 UV_CHANNEL_COUNT = 1u;
+// Vertex attribute locations. Not all are used
+#if defined(__cplusplus)
+enum class VertexAttributeId : U8
+{
+	POSITION,
+	UV0,
+	UV1,
+	NORMAL,
+	TANGENT,
+	COLOR,
+	BONE_WEIGHTS,
+	BONE_INDICES,
+
+	COUNT,
+	FIRST = POSITION,
+
+	SCALE = UV0, ///< Only for particles.
+	ALPHA = UV1, ///< Only for particles.
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VertexAttributeId)
+#else
+const U32 VERTEX_ATTRIBUTE_ID_POSITION = 0u;
+const U32 VERTEX_ATTRIBUTE_ID_UV0 = 1u;
+const U32 VERTEX_ATTRIBUTE_ID_UV1 = 2u;
+const U32 VERTEX_ATTRIBUTE_ID_NORMAL = 3u;
+const U32 VERTEX_ATTRIBUTE_ID_TANGENT = 4u;
+const U32 VERTEX_ATTRIBUTE_ID_COLOR = 5u;
+const U32 VERTEX_ATTRIBUTE_ID_BONE_WEIGHTS = 6u;
+const U32 VERTEX_ATTRIBUTE_ID_BONE_INDICES = 7u;
+const U32 VERTEX_ATTRIBUTE_ID_COUNT = 8u;
+
+const U32 VERTEX_ATTRIBUTE_ID_SCALE = VERTEX_ATTRIBUTE_ID_UV0; ///< Only for particles.
+const U32 VERTEX_ATTRIBUTE_ID_ALPHA = VERTEX_ATTRIBUTE_ID_UV1; ///< Only for particles.
+#endif
+
+// Vertex buffers
+#if defined(__cplusplus)
+enum class VertexAttributeBufferId : U8
+{
+	POSITION,
+	NORMAL_TANGENT_UV0,
+	BONE,
+
+	COUNT
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VertexAttributeBufferId)
+#else
+const U32 VERTEX_ATTRIBUTE_BUFFER_ID_POSITION = 0u;
+const U32 VERTEX_ATTRIBUTE_BUFFER_ID_NORMAL_TANGENT_UV0 = 1u;
+const U32 VERTEX_ATTRIBUTE_BUFFER_ID_BONE = 2u;
+const U32 VERTEX_ATTRIBUTE_BUFFER_ID_COUNT = 3u;
+#endif
 
 
-/// The main vertex that contains normals, tangents and UVs
+/// The main vertex that contains normals, tangents and UVs.
 struct MainVertex
 struct MainVertex
 {
 {
 	U32 m_normal; ///< Packed in a custom R11G11B10_SNorm
 	U32 m_normal; ///< Packed in a custom R11G11B10_SNorm
 	U32 m_tangent; ///< Packed in a custom R10G10B11A1_SNorm format
 	U32 m_tangent; ///< Packed in a custom R10G10B11A1_SNorm format
-	Vec2 m_uvs[UV_CHANNEL_COUNT];
+	Vec2 m_uv0;
 };
 };
 
 
 const U32 _ANKI_SIZEOF_MainVertex = 4u * 4u;
 const U32 _ANKI_SIZEOF_MainVertex = 4u * 4u;
@@ -39,9 +89,11 @@ ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_BoneInfoVertex == sizeof(BoneInfoVertex))
 struct MeshGpuDescriptor
 struct MeshGpuDescriptor
 {
 {
 	U64 m_indexBufferPtr; ///< Points to a buffer of U16 indices.
 	U64 m_indexBufferPtr; ///< Points to a buffer of U16 indices.
-	U64 m_positionBufferPtr; ///< Points to a buffer of Vec3 positions.
-	U64 m_mainVertexBufferPtr; ///< Points to a buffer of MainVertex.
-	U64 m_boneInfoVertexBufferPtr; ///< Points to a buffer of BoneInfoVertex.
+#if defined(__cplusplus)
+	Array<U64, U(VertexAttributeBufferId::COUNT)> m_vertexBufferPtrs;
+#else
+	U64 m_vertexBufferPtrs[VERTEX_ATTRIBUTE_BUFFER_ID_COUNT];
+#endif
 	U32 m_indexCount;
 	U32 m_indexCount;
 	U32 m_vertexCount;
 	U32 m_vertexCount;
 	Vec3 m_aabbMin;
 	Vec3 m_aabbMin;
@@ -52,20 +104,40 @@ const U32 _ANKI_SIZEOF_MeshGpuDescriptor = 4u * ANKI_SIZEOF(U64) + 8u * ANKI_SIZ
 const U32 _ANKI_ALIGNOF_MeshGpuDescriptor = 8u;
 const U32 _ANKI_ALIGNOF_MeshGpuDescriptor = 8u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MeshGpuDescriptor == sizeof(MeshGpuDescriptor));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MeshGpuDescriptor == sizeof(MeshGpuDescriptor));
 
 
-const U32 TEXTURE_CHANNEL_DIFFUSE = 0u;
-const U32 TEXTURE_CHANNEL_NORMAL = 1u;
-const U32 TEXTURE_CHANNEL_ROUGHNESS_METALNESS = 2u;
-const U32 TEXTURE_CHANNEL_EMISSION = 3u;
-const U32 TEXTURE_CHANNEL_HEIGHT = 4u;
-const U32 TEXTURE_CHANNEL_AUX_0 = 5u;
-const U32 TEXTURE_CHANNEL_AUX_1 = 6u;
-const U32 TEXTURE_CHANNEL_AUX_2 = 7u;
-
-const U32 TEXTURE_CHANNEL_COUNT = 8u;
+#if defined(__cplusplus)
+enum class TextureChannelId : U8
+{
+	DIFFUSE,
+	NORMAL,
+	ROUGHNESS_METALNESS,
+	EMISSION,
+	HEIGHT,
+	AUX_0,
+	AUX_1,
+	AUX_2,
+
+	COUNT
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(TextureChannelId)
+#else
+const U32 TEXTURE_CHANNEL_ID_DIFFUSE = 0u;
+const U32 TEXTURE_CHANNEL_ID_NORMAL = 1u;
+const U32 TEXTURE_CHANNEL_ID_ROUGHNESS_METALNESS = 2u;
+const U32 TEXTURE_CHANNEL_ID_EMISSION = 3u;
+const U32 TEXTURE_CHANNEL_ID_HEIGHT = 4u;
+const U32 TEXTURE_CHANNEL_ID_AUX_0 = 5u;
+const U32 TEXTURE_CHANNEL_ID_AUX_1 = 6u;
+const U32 TEXTURE_CHANNEL_ID_AUX_2 = 7u;
+const U32 TEXTURE_CHANNEL_ID_COUNT = 8u;
+#endif
 
 
 struct MaterialGpuDescriptor
 struct MaterialGpuDescriptor
 {
 {
-	U16 m_bindlessTextureIndices[TEXTURE_CHANNEL_COUNT];
+#if defined(__cplusplus)
+	Array<U16, U(TextureChannelId::COUNT)> m_bindlessTextureIndices;
+#else
+	U16 m_bindlessTextureIndices[TEXTURE_CHANNEL_ID_COUNT];
+#endif
 	Vec3 m_diffuseColor;
 	Vec3 m_diffuseColor;
 	Vec3 m_specularColor;
 	Vec3 m_specularColor;
 	Vec3 m_emissiveColor;
 	Vec3 m_emissiveColor;
@@ -73,8 +145,7 @@ struct MaterialGpuDescriptor
 	F32 m_metalness;
 	F32 m_metalness;
 };
 };
 
 
-const U32 _ANKI_SIZEOF_MaterialGpuDescriptor =
-	TEXTURE_CHANNEL_COUNT * ANKI_SIZEOF(U16) + 3u * ANKI_SIZEOF(Vec3) + 2u * ANKI_SIZEOF(F32);
+const U32 _ANKI_SIZEOF_MaterialGpuDescriptor = 8u * ANKI_SIZEOF(U16) + 3u * ANKI_SIZEOF(Vec3) + 2u * ANKI_SIZEOF(F32);
 const U32 _ANKI_ALIGNOF_MaterialGpuDescriptor = 4u;
 const U32 _ANKI_ALIGNOF_MaterialGpuDescriptor = 4u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MaterialGpuDescriptor == sizeof(MaterialGpuDescriptor));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MaterialGpuDescriptor == sizeof(MaterialGpuDescriptor));
 
 

+ 6 - 9
AnKi/Shaders/RtShadowsHit.ankiprog

@@ -39,20 +39,17 @@ void main()
 
 
 	const U32 offset = U32(gl_PrimitiveID) * ANKI_SIZEOF(U16Vec3);
 	const U32 offset = U32(gl_PrimitiveID) * ANKI_SIZEOF(U16Vec3);
 	const UVec3 indices = UVec3(U16Vec3Ref(mesh.m_indexBufferPtr + U64(offset)).m_value);
 	const UVec3 indices = UVec3(U16Vec3Ref(mesh.m_indexBufferPtr + U64(offset)).m_value);
+	const U64 vertBufferPtr = mesh.m_vertexBufferPtrs[VERTEX_ATTRIBUTE_BUFFER_ID_NORMAL_TANGENT_UV0];
 
 
-	const MainVertex vert0 =
-		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[0] * ANKI_SIZEOF(MainVertex))).m_value;
-	const MainVertex vert1 =
-		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[1] * ANKI_SIZEOF(MainVertex))).m_value;
-	const MainVertex vert2 =
-		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[2] * ANKI_SIZEOF(MainVertex))).m_value;
+	const MainVertex vert0 = MainVertexRef(vertBufferPtr + U64(indices[0] * ANKI_SIZEOF(MainVertex))).m_value;
+	const MainVertex vert1 = MainVertexRef(vertBufferPtr + U64(indices[1] * ANKI_SIZEOF(MainVertex))).m_value;
+	const MainVertex vert2 = MainVertexRef(vertBufferPtr + U64(indices[2] * ANKI_SIZEOF(MainVertex))).m_value;
 
 
 	const Vec3 barycentrics = Vec3(1.0f - g_attribs.x - g_attribs.y, g_attribs.x, g_attribs.y);
 	const Vec3 barycentrics = Vec3(1.0f - g_attribs.x - g_attribs.y, g_attribs.x, g_attribs.y);
 
 
-	const Vec2 uv = vert0.m_uvs[UV_CHANNEL_0] * barycentrics.x + vert1.m_uvs[UV_CHANNEL_0] * barycentrics.y
-					+ vert2.m_uvs[UV_CHANNEL_0] * barycentrics.z;
+	const Vec2 uv = vert0.m_uv0 * barycentrics.x + vert1.m_uv0 * barycentrics.y + vert2.m_uv0 * barycentrics.z;
 
 
-	const U32 texIdx = U32(model.m_material.m_bindlessTextureIndices[TEXTURE_CHANNEL_DIFFUSE]);
+	const U32 texIdx = U32(model.m_material.m_bindlessTextureIndices[TEXTURE_CHANNEL_ID_DIFFUSE]);
 	const F32 alpha = textureLod(u_bindlessTextures2dF32[nonuniformEXT(texIdx)], u_sampler, uv, 3.0).a;
 	const F32 alpha = textureLod(u_bindlessTextures2dF32[nonuniformEXT(texIdx)], u_sampler, uv, 3.0).a;
 
 
 	g_payload += alpha;
 	g_payload += alpha;