namespace Dali
{
-
struct UniformData
{
- std::string name;
- Property::Type type;
- UniformData( const std::string& name, Property::Type type = Property::Type::NONE)
- : name(name), type(type)
- {}
+ std::string name;
+ Property::Type type;
+ UniformData(const std::string& name, Property::Type type = Property::Type::NONE)
+ : name(name),
+ type(type)
+ {
+ }
};
class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction
GetUniformLocation(program, "uLightCameraProjectionMatrix");
GetUniformLocation(program, "uLightCameraViewMatrix");
- for( const auto& uniform : mCustomUniformData )
+ for(const auto& uniform : mCustomUniformData)
{
GetUniformLocation(program, uniform.name.c_str());
}
out << std::hex << target << ", " << pname << ", " << param;
std::string params = out.str();
- out.str("");
- out << std::hex << target;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] << out.str();
- out.str("");
- out << std::hex << pname;
- namedParams["pname"] << out.str();
- out.str("");
- out << std::hex << param;
- namedParams["param"] << out.str();
+ namedParams["target"] << std::hex << target;
+ namedParams["pname"] << std::hex << pname;
+ namedParams["param"] << param;
mTexParameterTrace.PushCall("TexParameteri", params, namedParams);
}
typedef std::map<GLuint, UniformIDMap> ProgramUniformMap;
ProgramUniformMap mUniforms;
- std::vector<UniformData> mCustomUniformData{};
+ std::vector<UniformData> mCustomUniformData{};
template<typename T>
struct ProgramUniformValue : public std::map<GLuint, std::map<GLint, T> >
*/
#include "test-graphics-buffer.h"
-#include "test-graphics-program.h"
-#include "test-graphics-reflection.h"
#include <sstream>
#include "dali-test-suite-utils.h"
+#include "test-graphics-program.h"
+#include "test-graphics-reflection.h"
namespace Dali
{
return target;
}
-void TestGraphicsBuffer::BindAsUniformBuffer( const TestGraphicsProgram* program ) const
+void TestGraphicsBuffer::BindAsUniformBuffer(const TestGraphicsProgram* program) const
{
auto* reflection = static_cast<const TestGraphicsReflection*>(&program->GetReflection());
auto* data = memory.data();
- for( const auto& member : uboInfo.members )
+ for(const auto& member : uboInfo.members)
{
- auto type = reflection->GetMemberType( 0, member.location );
+ auto type = reflection->GetMemberType(0, member.location);
switch(type)
{
case Property::VECTOR4:
{
- auto value = *reinterpret_cast<const Dali::Vector4*>(data+member.offset);
- mGl.Uniform4f( member.location, value.x, value.y, value.z, value.w );
+ auto value = *reinterpret_cast<const Dali::Vector4*>(data + member.offset);
+ mGl.Uniform4f(member.location, value.x, value.y, value.z, value.w);
break;
}
case Property::VECTOR3:
{
- auto value = *reinterpret_cast<const Dali::Vector3*>(data+member.offset);
- mGl.Uniform3f( member.location, value.x, value.y, value.z );
+ auto value = *reinterpret_cast<const Dali::Vector3*>(data + member.offset);
+ mGl.Uniform3f(member.location, value.x, value.y, value.z);
break;
}
case Property::VECTOR2:
{
- auto value = *reinterpret_cast<const Dali::Vector2*>(data+member.offset);
- mGl.Uniform2f( member.location, value.x, value.y );
+ auto value = *reinterpret_cast<const Dali::Vector2*>(data + member.offset);
+ mGl.Uniform2f(member.location, value.x, value.y);
break;
}
case Property::FLOAT:
{
- auto value = *reinterpret_cast<const float*>(data+member.offset);
- fprintf(stderr, "BindAsUniformBuffer: %s, value: %f\n", member.name.c_str(), value);
- mGl.Uniform1f( member.location, value );
+ auto value = *reinterpret_cast<const float*>(data + member.offset);
+ mGl.Uniform1f(member.location, value);
break;
}
case Property::INTEGER:
{
- auto ptr = reinterpret_cast<const GLint*>(data+member.offset);
+ auto ptr = reinterpret_cast<const GLint*>(data + member.offset);
auto value = *ptr;
- mGl.Uniform1i( member.location, value );
+ mGl.Uniform1i(member.location, value);
break;
}
case Property::MATRIX:
{
- auto value = reinterpret_cast<const float*>(data+member.offset);
- mGl.UniformMatrix4fv( member.location, 1, GL_FALSE, value );
+ auto value = reinterpret_cast<const float*>(data + member.offset);
+ mGl.UniformMatrix4fv(member.location, 1, GL_FALSE, value);
break;
}
case Property::MATRIX3:
{
- auto value = reinterpret_cast<const float*>(data+member.offset);
- mGl.UniformMatrix3fv( member.location, 1, GL_FALSE, value );
+ auto value = reinterpret_cast<const float*>(data + member.offset);
+ mGl.UniformMatrix3fv(member.location, 1, GL_FALSE, value);
break;
}
default:
}
}
}
-
-
}
} // namespace Dali
return true;
}
- void BindAsUniformBuffer( const TestGraphicsProgram* program ) const;
+ void BindAsUniformBuffer(const TestGraphicsProgram* program) const;
TraceCallStack& mCallStack;
TestGlAbstraction& mGl;
int TestGraphicsCommandBuffer::GetDrawCallsCount()
{
int count = 0;
- for( auto& cmd : mCommands )
+ for(auto& cmd : mCommands)
{
- if( cmd.type == CommandType::DRAW ||
- cmd.type == CommandType::DRAW_INDEXED ||
- cmd.type == CommandType::DRAW_INDEXED_INDIRECT )
+ if(cmd.type == CommandType::DRAW ||
+ cmd.type == CommandType::DRAW_INDEXED ||
+ cmd.type == CommandType::DRAW_INDEXED_INDIRECT)
{
++count;
}
return count;
}
-void TestGraphicsCommandBuffer::GetStateForDrawCall( int drawCallIndex )
+void TestGraphicsCommandBuffer::GetStateForDrawCall(int drawCallIndex)
{
- int index = 0;
+ int index = 0;
std::vector<Command> mCommandStack{};
- for( auto& cmd : mCommands )
+ for(auto& cmd : mCommands)
{
mCommandStack.push_back(cmd);
- if( cmd.type == CommandType::DRAW ||
- cmd.type == CommandType::DRAW_INDEXED ||
- cmd.type == CommandType::DRAW_INDEXED_INDIRECT )
+ if(cmd.type == CommandType::DRAW ||
+ cmd.type == CommandType::DRAW_INDEXED ||
+ cmd.type == CommandType::DRAW_INDEXED_INDIRECT)
{
- if( index == drawCallIndex )
+ if(index == drawCallIndex)
{
break;
}
}
}
-std::vector<Command*> TestGraphicsCommandBuffer::GetCommandsByType( CommandTypeMask mask )
+std::vector<Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask)
{
std::vector<Command*> mCommandStack{};
- for( auto& cmd : mCommands )
+ for(auto& cmd : mCommands)
{
- if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)) )
+ if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)))
{
- mCommandStack.emplace_back( &cmd );
+ mCommandStack.emplace_back(&cmd);
}
}
return mCommandStack;
#include <cstdint>
#include <vector>
#include "test-gl-abstraction.h"
-#include "test-graphics-pipeline.h"
#include "test-graphics-buffer.h"
+#include "test-graphics-pipeline.h"
#include "test-trace-call-stack.h"
namespace Dali
enum class CommandType
{
- FLUSH = 1 << 0,
- BIND_TEXTURES = 1 << 1,
- BIND_SAMPLERS = 1 << 2,
- BIND_VERTEX_BUFFERS = 1 << 3,
- BIND_INDEX_BUFFER = 1 << 4,
- BIND_UNIFORM_BUFFER = 1 << 5,
- BIND_PIPELINE = 1 << 6,
- DRAW = 1 << 7,
- DRAW_INDEXED = 1 << 8,
- DRAW_INDEXED_INDIRECT = 1 << 9
+ FLUSH = 1 << 0,
+ BIND_TEXTURES = 1 << 1,
+ BIND_SAMPLERS = 1 << 2,
+ BIND_VERTEX_BUFFERS = 1 << 3,
+ BIND_INDEX_BUFFER = 1 << 4,
+ BIND_UNIFORM_BUFFER = 1 << 5,
+ BIND_PIPELINE = 1 << 6,
+ DRAW = 1 << 7,
+ DRAW_INDEXED = 1 << 8,
+ DRAW_INDEXED_INDIRECT = 1 << 9,
+ SET_SCISSOR = 1 << 10,
+ SET_SCISSOR_TEST = 1 << 11,
+ SET_VIEWPORT = 1 << 12,
+ SET_VIEWPORT_TEST = 1 << 13
};
using CommandTypeMask = uint32_t;
struct VertexBufferBindingDescriptor
{
const TestGraphicsBuffer* buffer{nullptr};
- uint32_t offset{0u};
+ uint32_t offset{0u};
};
/**
struct IndexBufferBindingDescriptor
{
const TestGraphicsBuffer* buffer{nullptr};
- uint32_t offset{};
- Graphics::Format format{};
+ uint32_t offset{};
+ Graphics::Format format{};
};
/**
struct UniformBufferBindingDescriptor
{
const TestGraphicsBuffer* buffer{nullptr};
- uint32_t binding{0u};
- uint32_t offset{0u};
- bool emulated; ///<true if UBO is emulated for old gfx API
+ uint32_t binding{0u};
+ uint32_t offset{0u};
+ bool emulated; ///<true if UBO is emulated for old gfx API
};
/**
struct
{
const TestGraphicsBuffer* buffer;
- uint32_t offset;
- uint32_t drawCount;
- uint32_t stride;
+ uint32_t offset;
+ uint32_t drawCount;
+ uint32_t stride;
} drawIndexedIndirect;
};
};
// Nothing to do
break;
}
+ case CommandType::SET_SCISSOR:
+ {
+ scissor.region = rhs.scissor.region;
+ break;
+ }
+ case CommandType::SET_SCISSOR_TEST:
+ {
+ scissorTest.enable = rhs.scissorTest.enable;
+ break;
+ }
+ case CommandType::SET_VIEWPORT:
+ {
+ viewport.region = rhs.viewport.region;
+ break;
+ }
+ case CommandType::SET_VIEWPORT_TEST:
+ {
+ viewportTest.enable = rhs.viewportTest.enable;
+ break;
+ }
}
type = rhs.type;
}
/**
- * @brief Copy constructor
+ * @brief move constructor
* @param[in] rhs Command
*/
Command(Command&& rhs) noexcept
// Nothing to do
break;
}
+ case CommandType::SET_SCISSOR:
+ {
+ scissor.region = rhs.scissor.region;
+ break;
+ }
+ case CommandType::SET_SCISSOR_TEST:
+ {
+ scissorTest.enable = rhs.scissorTest.enable;
+ break;
+ }
+ case CommandType::SET_VIEWPORT:
+ {
+ viewport.region = rhs.viewport.region;
+ break;
+ }
+ case CommandType::SET_VIEWPORT_TEST:
+ {
+ viewportTest.enable = rhs.viewportTest.enable;
+ break;
+ }
}
type = rhs.type;
}
struct : public DrawCallDescriptor
{
} draw;
+
+ struct
+ {
+ Graphics::Rect2D region;
+ } scissor;
+ struct
+ {
+ bool enable;
+ } scissorTest;
+ struct
+ {
+ Graphics::Viewport region;
+ } viewport;
+ struct
+ {
+ bool enable;
+ } viewportTest;
};
};
-
class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
{
public:
TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
~TestGraphicsCommandBuffer()
{
-
}
void BindVertexBuffers(uint32_t firstBinding,
void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings) override
{
- printf("BindUniformBuffers: bindings.size(): %lu\n", bindings.size());
-
mCommands.emplace_back();
auto& cmd = mCommands.back();
cmd.type = CommandType::BIND_UNIFORM_BUFFER;
void BindIndexBuffer(const Graphics::Buffer& buffer,
uint32_t offset,
- Graphics::Format format) override
+ Graphics::Format format) override
{
mCommands.emplace_back();
mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
}
void BeginRenderPass(
- Graphics::RenderPass& renderPass,
- Graphics::RenderTarget& renderTarget,
+ Graphics::RenderPass& renderPass,
+ Graphics::RenderTarget& renderTarget,
Graphics::Extent2D renderArea,
std::vector<Graphics::ClearValue> clearValues) override
{
mCallStack.PushCall("Reset", "");
}
- void SetScissor(Graphics::Extent2D value) override
+ void SetScissor(Graphics::Rect2D value) override
{
- mCallStack.PushCall("SetScissor", "");
+ TraceCallStack::NamedParams params;
+ params["x"] << value.x;
+ params["y"] << value.y;
+ params["width"] << value.width;
+ params["height"] << value.height;
+ mCallStack.PushCall("SetScissor", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_SCISSOR;
+ mCommands.back().scissor.region = value;
}
void SetScissorTestEnable(bool value) override
{
- mCallStack.PushCall("SetScissorTestEnable", "");
+ TraceCallStack::NamedParams params;
+ params["value"] << (value ? "T" : "F");
+ mCallStack.PushCall("SetScissorTestEnable", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_SCISSOR_TEST;
+ mCommands.back().scissorTest.enable = value;
}
void SetViewport(Graphics::Viewport value) override
{
- mCallStack.PushCall("SetViewport", "");
+ TraceCallStack::NamedParams params;
+ params["x"] << value.x;
+ params["y"] << value.y;
+ params["width"] << value.width;
+ params["height"] << value.height;
+ params["minDepth"] << value.minDepth;
+ params["maxDepth"] << value.maxDepth;
+ mCallStack.PushCall("SetViewport", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_VIEWPORT;
+ mCommands.back().viewport.region = value;
}
void SetViewportEnable(bool value) override
{
- mCallStack.PushCall("SetViewportEnable", "");
+ TraceCallStack::NamedParams params;
+ params["value"] << (value ? "T" : "F");
+ mCallStack.PushCall("SetViewportEnable", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_VIEWPORT_TEST;
+ mCommands.back().viewportTest.enable = value;
}
[[nodiscard]] const std::vector<Command>& GetCommands() const
* Retrieves state resolve for selected draw call
* @param drawCommandIndex
*/
- void GetStateForDrawCall( int drawCallIndex );
+ void GetStateForDrawCall(int drawCallIndex);
/**
* Retrieves commands of specified type
*/
- std::vector<Command*> GetCommandsByType( CommandTypeMask mask );
-
+ std::vector<Command*> GetCommandsByType(CommandTypeMask mask);
private:
- TraceCallStack& mCallStack;
- TestGlAbstraction& mGlAbstraction;
+ TraceCallStack& mCallStack;
+ TestGlAbstraction& mGlAbstraction;
+
std::vector<Command> mCommands;
};
if(!value.empty())
{
// must be fixed
- for (auto &binding : value[0]->bindTextures.textureBindings)
+ for(auto& binding : value[0]->bindTextures.textureBindings)
{
- if (binding.texture)
+ if(binding.texture)
{
auto texture = Uncast<TestGraphicsTexture>(binding.texture);
texture->Bind(binding.binding);
- if (binding.sampler)
+ if(binding.sampler)
{
auto sampler = Uncast<TestGraphicsSampler>(binding.sampler);
- if (sampler)
+ if(sampler)
{
sampler->Apply(texture->GetTarget());
}
// IndexBuffer binding,
auto bindIndexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_INDEX_BUFFER);
- if (!bindIndexBufferCmds.empty())
+ if(!bindIndexBufferCmds.empty())
{
- auto &indexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer;
- if (indexBufferBinding.buffer)
+ auto& indexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer;
+ if(indexBufferBinding.buffer)
{
auto buffer = Uncast<TestGraphicsBuffer>(indexBufferBinding.buffer);
buffer->Bind();
// VertexBuffer binding,
auto bindVertexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_VERTEX_BUFFERS);
- if (!bindVertexBufferCmds.empty())
+ if(!bindVertexBufferCmds.empty())
{
- for (auto &binding : bindVertexBufferCmds[0]->bindVertexBuffers.vertexBufferBindings)
+ for(auto& binding : bindVertexBufferCmds[0]->bindVertexBuffers.vertexBufferBindings)
{
auto graphicsBuffer = binding.buffer;
auto vertexBuffer = Uncast<TestGraphicsBuffer>(graphicsBuffer);
vertexBuffer->Bind();
}
}
+
+ bool scissorEnabled = false;
+
+ auto scissorTestList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR_TEST);
+ if(!scissorTestList.empty())
+ {
+ if(scissorTestList[0]->scissorTest.enable)
+ {
+ mGl.Enable(GL_SCISSOR_TEST);
+ scissorEnabled = true;
+ }
+ else
+ {
+ mGl.Disable(GL_SCISSOR_TEST);
+ }
+ }
+
+ auto scissorList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR);
+ if(!scissorList.empty() && scissorEnabled)
+ {
+ auto& rect = scissorList[0]->scissor.region;
+ mGl.Scissor(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ auto viewportList = commandBuffer->GetCommandsByType(0 | CommandType::SET_VIEWPORT);
+ if(!viewportList.empty())
+ {
+ mGl.Viewport(viewportList[0]->viewport.region.x, viewportList[0]->viewport.region.y, viewportList[0]->viewport.region.width, viewportList[0]->viewport.region.height);
+ }
+
+ // ignore viewport enable
+
// Pipeline attribute setup
- auto bindPipelineCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_PIPELINE);
- if (!bindPipelineCmds.empty())
+ auto bindPipelineCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_PIPELINE);
+ if(!bindPipelineCmds.empty())
{
- auto pipeline = bindPipelineCmds[0]->bindPipeline.pipeline;
- auto &vi = pipeline->vertexInputState;
- for (auto &attribute : vi.attributes)
+ auto pipeline = bindPipelineCmds[0]->bindPipeline.pipeline;
+ auto& vi = pipeline->vertexInputState;
+ for(auto& attribute : vi.attributes)
{
mGl.EnableVertexAttribArray(attribute.location);
uint32_t attributeOffset = attribute.offset;
GetGlType(attribute.format),
GL_FALSE, // Not normalized
stride,
- reinterpret_cast<void *>(attributeOffset));
+ reinterpret_cast<void*>(attributeOffset));
}
+
// Cull face setup
- auto &rasterizationState = pipeline->rasterizationState;
- if (rasterizationState.cullMode == Graphics::CullMode::NONE)
+ auto& rasterizationState = pipeline->rasterizationState;
+ if(rasterizationState.cullMode == Graphics::CullMode::NONE)
{
mGl.Disable(GL_CULL_FACE);
}
// so it isn't present in the API (and won't have any tests!)
// Blending setup
- auto &colorBlendState = pipeline->colorBlendState;
- if (colorBlendState.blendEnable)
+ auto& colorBlendState = pipeline->colorBlendState;
+ if(colorBlendState.blendEnable)
{
mGl.Enable(GL_BLEND);
GetBlendFactor(colorBlendState.dstColorBlendFactor),
GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
- if (colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
+ if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
{
mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
}
// UniformBuffer binding (once we know pipeline)
auto bindUniformBuffersCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_UNIFORM_BUFFER);
- if (!bindUniformBuffersCmds.empty())
+ if(!bindUniformBuffersCmds.empty())
{
auto buffer = bindUniformBuffersCmds[0]->bindUniformBuffers.standaloneUniformsBufferBinding;
// based on reflection, issue gl calls
- buffer.buffer->BindAsUniformBuffer( static_cast<const TestGraphicsProgram*>(pipeline->programState.program) );
+ buffer.buffer->BindAsUniformBuffer(static_cast<const TestGraphicsProgram*>(pipeline->programState.program));
}
- auto drawCmds = commandBuffer->GetCommandsByType( 0 |
- CommandType::DRAW |
- CommandType::DRAW_INDEXED_INDIRECT |
- CommandType::DRAW_INDEXED );
+ auto drawCmds = commandBuffer->GetCommandsByType(0 |
+ CommandType::DRAW |
+ CommandType::DRAW_INDEXED_INDIRECT |
+ CommandType::DRAW_INDEXED);
if(!drawCmds.empty())
{
- if (drawCmds[0]->draw.type == DrawCallDescriptor::Type::DRAW_INDEXED )
+ if(drawCmds[0]->draw.type == DrawCallDescriptor::Type::DRAW_INDEXED)
{
mGl.DrawElements(GetTopology(topology),
static_cast<GLsizei>(drawCmds[0]->draw.drawIndexed.indexCount),
GL_UNSIGNED_SHORT,
- reinterpret_cast<void *>(drawCmds[0]->draw.drawIndexed.firstIndex));
+ reinterpret_cast<void*>(drawCmds[0]->draw.drawIndexed.firstIndex));
}
else
{
}
}
// attribute clear
- for (auto &attribute : vi.attributes)
+ for(auto& attribute : vi.attributes)
{
mGl.DisableVertexAttribArray(attribute.location);
}
bool found = true;
for(auto& shader : *(programCreateInfo.shaderState))
{
- auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
+ auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
std::vector<uint8_t> source;
source.resize(graphicsShader->mCreateInfo.sourceSize);
memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms);
for(auto& shader : *(programCreateInfo.shaderState))
{
- auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
- mProgramCache.back().shaders[shader.pipelineStage].resize( graphicsShader->mCreateInfo.sourceSize );
+ auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
+ mProgramCache.back().shaders[shader.pipelineStage].resize(graphicsShader->mCreateInfo.sourceSize);
memcpy(&mProgramCache.back().shaders[shader.pipelineStage][0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
}
return Graphics::MakeUnique<TestGraphicsProgram>(mProgramCache.back().programImpl);
struct ProgramCache
{
std::map<Graphics::PipelineStage, std::vector<uint8_t>> shaders;
- TestGraphicsProgramImpl* programImpl;
+ TestGraphicsProgramImpl* programImpl;
};
std::vector<ProgramCache> mProgramCache;
#include "test-graphics-shader.h"
#include <dali/public-api/object/property-map.h>
-#include <vector>
#include <string>
+#include <vector>
namespace Dali
{
namespace
{
static const std::vector<UniformData> UNIFORMS =
-{
- UniformData("uRendererColor",Property::Type::FLOAT),
- UniformData("uCustom", Property::Type::INTEGER),
- UniformData("uCustom3", Property::Type::VECTOR3),
- UniformData("uFadeColor", Property::Type::VECTOR4),
- UniformData("uUniform1", Property::Type::VECTOR4),
- UniformData("uUniform2", Property::Type::VECTOR4),
- UniformData("uUniform3", Property::Type::VECTOR4),
- UniformData("uFadeProgress", Property::Type::FLOAT),
- UniformData("uANormalMatrix", Property::Type::MATRIX3),
- UniformData("sEffect", Property::Type::FLOAT),
- UniformData("sTexture", Property::Type::FLOAT),
- UniformData("sTextureRect", Property::Type::FLOAT),
- UniformData("sGloss", Property::Type::FLOAT),
- UniformData("uColor", 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("uSize", Property::Type::VECTOR3),
- UniformData("uViewMatrix", Property::Type::MATRIX),
- UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX),
- UniformData("uLightCameraViewMatrix", Property::Type::MATRIX),
+ {
+ UniformData("uRendererColor", Property::Type::FLOAT),
+ UniformData("uCustom", Property::Type::INTEGER),
+ UniformData("uCustom3", Property::Type::VECTOR3),
+ UniformData("uFadeColor", Property::Type::VECTOR4),
+ UniformData("uUniform1", Property::Type::VECTOR4),
+ UniformData("uUniform2", Property::Type::VECTOR4),
+ UniformData("uUniform3", Property::Type::VECTOR4),
+ UniformData("uFadeProgress", Property::Type::FLOAT),
+ UniformData("uANormalMatrix", Property::Type::MATRIX3),
+ UniformData("sEffect", Property::Type::FLOAT),
+ UniformData("sTexture", Property::Type::FLOAT),
+ UniformData("sTextureRect", Property::Type::FLOAT),
+ UniformData("sGloss", Property::Type::FLOAT),
+ UniformData("uColor", 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("uSize", Property::Type::VECTOR3),
+ UniformData("uViewMatrix", Property::Type::MATRIX),
+ UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX),
+ UniformData("uLightCameraViewMatrix", Property::Type::MATRIX),
};
}
TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms)
- : mGl(gl),
- mCustomUniforms(customUniforms)
+: mGl(gl),
+ mCustomUniforms(customUniforms)
{
for(Property::Array::SizeType i = 0; i < vfs.Count(); ++i)
{
}
}
- mDefaultUniformBlock.name = "";
- mDefaultUniformBlock.members = {};
- mDefaultUniformBlock.binding = 0;
- mDefaultUniformBlock.size = 64 * (UNIFORMS.size() + mCustomUniforms.size());
+ mDefaultUniformBlock.name = "";
+ mDefaultUniformBlock.members = {};
+ mDefaultUniformBlock.binding = 0;
+ mDefaultUniformBlock.size = 64 * (UNIFORMS.size() + mCustomUniforms.size());
mDefaultUniformBlock.descriptorSet = 0;
mDefaultUniformBlock.members.clear();
int loc = 0;
- for( const auto& data : UNIFORMS )
+ for(const auto& data : UNIFORMS)
{
mDefaultUniformBlock.members.emplace_back();
- auto& item = mDefaultUniformBlock.members.back();
- item.name = data.name;
- item.binding = 0;
- item.offset = loc*64;
- item.location = loc++;
- item.bufferIndex = 0;
+ auto& item = mDefaultUniformBlock.members.back();
+ item.name = data.name;
+ item.binding = 0;
+ item.offset = loc * 64;
+ item.location = loc++;
+ item.bufferIndex = 0;
item.uniformClass = Graphics::UniformClass::UNIFORM;
}
- for( const auto& data : mCustomUniforms )
+ for(const auto& data : mCustomUniforms)
{
fprintf(stderr, "\ncustom uniforms: %s\n", data.name.c_str());
mDefaultUniformBlock.members.emplace_back();
- auto& item = mDefaultUniformBlock.members.back();
- item.name = data.name;
- item.binding = 0;
- item.offset = loc*64;
- item.location = loc++;
- item.bufferIndex = 0;
+ auto& item = mDefaultUniformBlock.members.back();
+ item.name = data.name;
+ item.binding = 0;
+ item.offset = loc * 64;
+ item.location = loc++;
+ item.bufferIndex = 0;
item.uniformClass = Graphics::UniformClass::UNIFORM;
}
return Graphics::ShaderLanguage::GLSL_3_1;
}
-Dali::Property::Type TestGraphicsReflection::GetMemberType( int blockIndex, int location) const
+Dali::Property::Type TestGraphicsReflection::GetMemberType(int blockIndex, int location) const
{
return location < static_cast<int>(UNIFORMS.size()) ? UNIFORMS[location].type : mCustomUniforms[location - UNIFORMS.size()].type;
}
* limitations under the License.
*/
-#include <dali/graphics-api/graphics-reflection.h>
#include <dali/graphics-api/graphics-program-create-info.h>
+#include <dali/graphics-api/graphics-reflection.h>
#include "test-gl-abstraction.h"
namespace Dali
{
-
class TestGraphicsReflection : public Graphics::Reflection
{
public:
}
}
- Dali::Property::Type GetMemberType( int blockIndex, int location) const;
+ Dali::Property::Type GetMemberType(int blockIndex, int location) const;
TestGlAbstraction& mGl;
mutable std::vector<std::string> mAttributes;
std::vector<UniformData> mCustomUniforms;
- Graphics::UniformBlockInfo mDefaultUniformBlock{}; ///< The emulated UBO containing all the standalone uniforms
- std::vector<Graphics::UniformBlockInfo> mUniformBlocks{}; ///< List of uniform blocks
+ Graphics::UniformBlockInfo mDefaultUniformBlock{}; ///< The emulated UBO containing all the standalone uniforms
+ std::vector<Graphics::UniformBlockInfo> mUniformBlocks{}; ///< List of uniform blocks
};
} // namespace Dali