/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
namespace
{
-
enum class LoadDataType
{
UNSIGNED_BYTE = 0,
bool ReadBlob(const MeshDefinition::Blob& descriptor, std::istream& source, uint8_t* target)
{
source.clear();
- if(!source.seekg(descriptor.mOffset, std::istream::beg))
+ if(!source.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(descriptor.mOffset)), std::istream::beg))
{
return false;
}
{
readSize += descriptor.mStride;
target += descriptor.mElementSizeHint;
- source.seekg(diff, std::istream::cur);
+ source.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(diff)), std::istream::cur);
}
return readSize == totalSize;
}
bool LoadNormals(LoadAccessorInputs normalsInput, bool isTriangles, uint32_t positionBufferSize)
{
- auto hasNormals = normalsInput.accessor.IsDefined();
+ auto hasNormals = normalsInput.accessor.IsDefined();
if(hasNormals)
{
const auto bufferSize = normalsInput.accessor.mBlob.GetBufferSize();
{
auto& texCoords = textureCoordinatesInput.accessors[0];
const auto bufferSize = texCoords.mBlob.GetBufferSize();
- uint32_t uvCount;
+ uint32_t uvCount;
if(MaskMatch(textureCoordinatesInput.flags, MeshDefinition::Flags::S8_TEXCOORD) || MaskMatch(textureCoordinatesInput.flags, MeshDefinition::Flags::U8_TEXCOORD))
{
}
}
+constexpr uint32_t MINIMUM_SHADER_VERSION_SUPPORT_VERTEX_ID = 300;
+
} // namespace
MeshDefinition::SparseBlob::SparseBlob(const Blob& indices, const Blob& values, uint32_t count)
}
LoadBlendShapes(raw, mBlendShapes, mBlendShapeHeader, mBlendShapeVersion, numberOfVertices, fileStream, buffers);
-
return raw;
}
}
}
+ if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_VERTEX_ID && !raw.mAttribs.empty()))
+ {
+ auto numElements = raw.mAttribs[0].mNumElements;
+
+ // gl_VertexID not support. We should add buffer hard.
+ Property::Map attribMap;
+ attribMap["aVertexID"] = Property::FLOAT;
+
+ VertexBuffer attribBuffer = VertexBuffer::New(attribMap);
+
+ std::vector<uint8_t> buffer(numElements * sizeof(float));
+ auto ids = reinterpret_cast<float*>(buffer.data());
+
+ for(uint32_t i = 0; i < numElements; i++)
+ {
+ ids[i] = static_cast<float>(i);
+ }
+
+ attribBuffer.SetData(buffer.data(), numElements);
+
+ meshGeometry.geometry.AddVertexBuffer(attribBuffer);
+ }
+
for(auto& a : raw.mAttribs)
{
a.AttachBuffer(meshGeometry.geometry);