/*
- * 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.
*/
#include "test-graphics-reflection.h"
+#include "test-graphics-controller.h"
#include "test-graphics-shader.h"
#include <dali/public-api/object/property-map.h>
{
static const std::vector<UniformData> UNIFORMS =
{
+ UniformData("uColor", Property::Type::VECTOR4),
UniformData("uRendererColor", Property::Type::FLOAT),
UniformData("uCustom", Property::Type::INTEGER),
UniformData("uCustom3", Property::Type::VECTOR3),
UniformData("sTexture", Property::Type::FLOAT),
UniformData("sTextureRect", Property::Type::FLOAT),
UniformData("sGloss", Property::Type::FLOAT),
- UniformData("uColor", Property::Type::VECTOR4),
UniformData("uActorColor", Property::Type::VECTOR4),
UniformData("uModelMatrix", Property::Type::MATRIX),
UniformData("uModelView", Property::Type::MATRIX),
UniformData("uMvpMatrix", Property::Type::MATRIX),
UniformData("uNormalMatrix", Property::Type::MATRIX3),
UniformData("uProjection", Property::Type::MATRIX),
+ UniformData("uScale", Property::Type::VECTOR3),
UniformData("uSize", Property::Type::VECTOR3),
UniformData("uViewMatrix", Property::Type::MATRIX),
UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX),
} // namespace
-TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, uint32_t programId, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms, std::vector<TestGraphicsReflection::TestUniformBlockInfo>& customUniformBlocks)
-: mGl(gl),
+TestGraphicsReflection::TestGraphicsReflection(TestGraphicsController& controller, TestGlAbstraction& gl, uint32_t programId, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms, std::vector<TestGraphicsReflection::TestUniformBlockInfo>& customUniformBlocks)
+: mController(controller),
+ mGl(gl),
mCustomUniforms(customUniforms)
{
for(Property::Array::SizeType i = 0; i < vfs.Count(); ++i)
mDefaultUniformBlock.members.clear();
int offset = 0;
- for(const auto& data : UNIFORMS)
- {
- mDefaultUniformBlock.members.emplace_back();
- auto& item = mDefaultUniformBlock.members.back();
- item.name = data.name;
- item.binding = 0;
- item.offsets.push_back(offset);
- item.locations.push_back(gl.GetUniformLocation(programId, data.name.c_str()));
- item.bufferIndex = 0;
- item.uniformClass = Graphics::UniformClass::UNIFORM;
- item.type = data.type;
- offset += GetSizeForType(data.type);
- }
for(const auto& data : mCustomUniforms)
{
offset += GetSizeForType(data.type);
}
}
+
+ for(const auto& data : UNIFORMS)
+ {
+ mDefaultUniformBlock.members.emplace_back();
+ auto& item = mDefaultUniformBlock.members.back();
+ item.name = data.name;
+ item.binding = 0;
+ item.offsets.push_back(offset);
+ item.locations.push_back(gl.GetUniformLocation(programId, data.name.c_str()));
+ item.bufferIndex = 0;
+ item.uniformClass = Graphics::UniformClass::UNIFORM;
+ item.type = data.type;
+ offset += GetSizeForType(data.type);
+ }
+
mDefaultUniformBlock.size = offset;
mUniformBlocks.push_back(mDefaultUniformBlock);
uint32_t TestGraphicsReflection::GetVertexAttributeLocation(const std::string& name) const
{
- // Automatically assign locations to named attributes when requested
auto iter = std::find(mAttributes.begin(), mAttributes.end(), name);
if(iter != mAttributes.end())
{
return iter - mAttributes.begin();
}
- else
+ else if(mController.AutoAttrCreation())
{
uint32_t location = mAttributes.size();
mAttributes.push_back(name);
return location;
}
- return 0u;
+
+ return -1;
}
Dali::Graphics::VertexInputAttributeFormat TestGraphicsReflection::GetVertexAttributeFormat(uint32_t location) const
out.members[i].uniformClass = Graphics::UniformClass::UNIFORM;
out.members[i].offset = memberUniform.offsets[0];
out.members[i].location = memberUniform.locations[0];
+ out.members[i].elementCount = memberUniform.numElements;
}
return true;