namespace Dali
{
-static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
-static const char* mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
- {
- "aPosition", // ATTRIB_POSITION
- "aNormal", // ATTRIB_NORMAL
- "aTexCoord", // ATTRIB_TEXCOORD
- "aColor", // ATTRIB_COLOR
- "aBoneWeights", // ATTRIB_BONE_WEIGHTS
- "aBoneIndices" // ATTRIB_BONE_INDICES
-};
-
class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction
{
public:
+ static const int MAX_ATTRIBUTE_CACHE_SIZE{64};
+
TestGlAbstraction();
~TestGlAbstraction() override;
void Initialize();
out << program << ", " << shader;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] = ToString(program);
- namedParams["shader"] = ToString(shader);
+ namedParams["program"] << program;
+ namedParams["shader"] << shader;
mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
}
std::ostringstream o;
o << std::hex << target << ", " << buffer;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = target;
- namedParams["buffer"] = buffer;
+ namedParams["target"] << target;
+ namedParams["buffer"] << buffer;
mBufferTrace.PushCall("BindBuffer", o.str(), namedParams);
}
out << target << ", " << texture;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["texture"] = ToString(texture);
+ namedParams["target"] << target;
+ namedParams["texture"] << texture;
mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
}
std::ostringstream o;
o << std::hex << target << ", " << size << ", " << data << ", " << usage;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = target;
- namedParams["size"] = size;
- namedParams["usage"] = usage;
+ namedParams["target"] << std::hex << target;
+ namedParams["size"] << size;
+ namedParams["usage"] << usage;
mBufferTrace.PushCall("BufferData", o.str(), namedParams);
std::ostringstream o;
o << std::hex << target << ", " << offset << ", " << size << ", " << data;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = target;
- namedParams["offset"] = offset;
- namedParams["size"] = size;
+ namedParams["target"] << std::hex << target;
+ namedParams["offset"] << offset;
+ namedParams["size"] << size;
mBufferTrace.PushCall("BufferSubData", o.str());
mBufferSubDataCalls.push_back(size);
out << s;
TraceCallStack::NamedParams namedParams;
- namedParams["s"] = ToString(s);
+ namedParams["s"] << s;
mStencilFunctionTrace.PushCall("ClearStencil", out.str(), namedParams);
}
std::stringstream out;
out << shader;
TraceCallStack::NamedParams namedParams;
- namedParams["shader"] = ToString(shader);
+ namedParams["shader"] << shader;
mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
}
out << target << ", " << level << ", " << width << ", " << height;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["level"] = ToString(level);
- namedParams["internalformat"] = ToString(internalformat);
- namedParams["width"] = ToString(width);
- namedParams["height"] = ToString(height);
- namedParams["border"] = ToString(border);
- namedParams["size"] = ToString(imageSize);
+ namedParams["target"] << std::hex << target;
+ namedParams["level"] << level;
+ namedParams["internalformat"] << internalformat;
+ namedParams["width"] << width;
+ namedParams["height"] << height;
+ namedParams["border"] << border;
+ namedParams["size"] << imageSize;
mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
}
out << target << ", " << level << ", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["level"] = ToString(level);
- namedParams["xoffset"] = ToString(xoffset);
- namedParams["yoffset"] = ToString(yoffset);
- namedParams["width"] = ToString(width);
- namedParams["height"] = ToString(height);
+ namedParams["target"] << std::hex << target;
+ namedParams["level"] << level;
+ namedParams["xoffset"] << xoffset;
+ namedParams["yoffset"] << yoffset;
+ namedParams["width"] << width;
+ namedParams["height"] << height;
mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
}
out << type;
TraceCallStack::NamedParams namedParams;
- namedParams["type"] = ToString(type);
+ namedParams["type"] << std::hex << type;
mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
return ++mLastShaderIdUsed;
out << mode;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] = ToString(mode);
+ namedParams["program"] << mode;
mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
}
out << program;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] = ToString(program);
+ namedParams["program"] << program;
mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
}
out << shader;
TraceCallStack::NamedParams namedParams;
- namedParams["shader"] = ToString(shader);
+ namedParams["shader"] << shader;
mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
}
out << (i > 0 ? ", " : "") << textures[i];
std::stringstream paramName;
paramName << "texture[" << i << "]";
- namedParams[paramName.str()] = ToString(textures[i]);
+ namedParams[paramName.str()] << textures[i];
mDeletedTextureIds.push_back(textures[i]);
mNumGeneratedTextures--;
}
out << func;
TraceCallStack::NamedParams namedParams;
- namedParams["func"] = ToString(func);
+ namedParams["func"] << std::hex << func;
mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
}
std::stringstream out;
out << program << ", " << shader;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] = ToString(program);
- namedParams["shader"] = ToString(shader);
+ namedParams["program"] << program;
+ namedParams["shader"] << shader;
mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
}
std::stringstream out;
out << cap;
TraceCallStack::NamedParams namedParams;
- namedParams["cap"] = ToString(cap);
+ namedParams["cap"] << std::hex << cap;
mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
}
inline void DisableVertexAttribArray(GLuint index) override
{
+ std::stringstream out;
+ out << index;
+ TraceCallStack::NamedParams namedParams;
+ namedParams["index"] << index;
+ mBufferTrace.PushCall("DisableVertexAttribArray", out.str(), namedParams);
SetVertexAttribArray(index, false);
}
std::stringstream out;
out << mode << ", " << first << ", " << count;
TraceCallStack::NamedParams namedParams;
- namedParams["mode"] = ToString(mode);
- namedParams["first"] = ToString(first);
- namedParams["count"] = ToString(count);
+ namedParams["mode"] << std::hex << mode;
+ namedParams["first"] << first;
+ namedParams["count"] << count;
mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
}
out << mode << ", " << count << ", " << type << ", indices";
TraceCallStack::NamedParams namedParams;
- namedParams["mode"] = ToString(mode);
- namedParams["count"] = ToString(count);
- namedParams["type"] = ToString(type);
+ namedParams["mode"] << std::hex << mode;
+ namedParams["count"] << count;
+ namedParams["type"] << type;
// Skip void pointers - are they of any use?
mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
}
std::stringstream out;
out << cap;
TraceCallStack::NamedParams namedParams;
- namedParams["cap"] = ToString(cap);
+ namedParams["cap"] << std::hex << cap;
mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
}
inline void EnableVertexAttribArray(GLuint index) override
{
+ std::stringstream out;
+ out << index;
+ TraceCallStack::NamedParams namedParams;
+ namedParams["index"] << index;
+ mBufferTrace.PushCall("EnableVertexAttribArray", out.str(), namedParams);
SetVertexAttribArray(index, true);
}
std::ostringstream o;
o << n;
TraceCallStack::NamedParams namedParams;
- namedParams["n"] = o.str();
+ namedParams["n"] << o.str();
mBufferTrace.PushCall("GenBuffers", o.str(), namedParams);
}
std::stringstream out;
out << target;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
+ namedParams["target"] << std::hex << target;
mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
}
}
TraceCallStack::NamedParams namedParams;
- namedParams["count"] = ToString(count);
+ namedParams["count"] << count;
std::stringstream out;
for(int i = 0; i < count; i++)
}
std::ostringstream oss;
oss << "indices[" << i << "]";
- namedParams[oss.str()] = ToString(textures[i]);
+ namedParams[oss.str()] << textures[i];
}
mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
inline int GetAttribLocation(GLuint program, const char* name) override
{
- std::string attribName(name);
-
- for(unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i)
- {
- if(mStdAttribs[i] == attribName)
- {
- return i;
- }
- }
-
- // 0 is a valid location
- return 0;
+ std::string check(name);
+ auto iter = std::find(mAttribLocs.begin(), mAttribLocs.end(), check);
+ if(iter == mAttribLocs.end())
+ return -1;
+ return iter - mAttribLocs.begin();
}
inline void GetBooleanv(GLenum pname, GLboolean* params) override
out << program;
TraceCallStack::NamedParams namedParams;
- namedParams["program"] = ToString(program);
+ namedParams["program"] << program;
mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
mNumberOfActiveUniforms = 3;
std::stringstream out;
out << x << ", " << y << ", " << width << ", " << height;
TraceCallStack::NamedParams namedParams;
- namedParams["x"] = ToString(x);
- namedParams["y"] = ToString(y);
- namedParams["width"] = ToString(width);
- namedParams["height"] = ToString(height);
+ namedParams["x"] << x;
+ namedParams["y"] << y;
+ namedParams["width"] << width;
+ namedParams["height"] << height;
mScissorTrace.PushCall("Scissor", out.str(), namedParams);
}
out << func << ", " << ref << ", " << mask;
TraceCallStack::NamedParams namedParams;
- namedParams["func"] = ToString(func);
- namedParams["ref"] = ToString(ref);
- namedParams["mask"] = ToString(mask);
+ namedParams["func"] << std::hex << func;
+ namedParams["ref"] << ref;
+ namedParams["mask"] << mask;
mStencilFunctionTrace.PushCall("StencilFunc", out.str(), namedParams);
}
out << face << ", " << func << ", " << ref << ", " << mask;
TraceCallStack::NamedParams namedParams;
- namedParams["face"] = ToString(face);
- namedParams["func"] = ToString(func);
- namedParams["ref"] = ToString(ref);
- namedParams["mask"] = ToString(mask);
+ namedParams["face"] << std::hex << face;
+ namedParams["func"] << std::hex << func;
+ namedParams["ref"] << ref;
+ namedParams["mask"] << mask;
mStencilFunctionTrace.PushCall("StencilFuncSeparate", out.str(), namedParams);
}
out << mask;
TraceCallStack::NamedParams namedParams;
- namedParams["mask"] = ToString(mask);
+ namedParams["mask"] << mask;
mStencilFunctionTrace.PushCall("StencilMask", out.str(), namedParams);
}
out << face << ", " << mask;
TraceCallStack::NamedParams namedParams;
- namedParams["face"] = ToString(face);
- namedParams["mask"] = ToString(mask);
+ namedParams["face"] << std::hex << face;
+ namedParams["mask"] << mask;
mStencilFunctionTrace.PushCall("StencilMaskSeparate", out.str(), namedParams);
}
out << fail << ", " << zfail << ", " << zpass;
TraceCallStack::NamedParams namedParams;
- namedParams["fail"] = ToString(fail);
- namedParams["zfail"] = ToString(zfail);
- namedParams["zpass"] = ToString(zpass);
+ namedParams["fail"] << std::hex << fail;
+ namedParams["zfail"] << std::hex << zfail;
+ namedParams["zpass"] << std::hex << zpass;
mStencilFunctionTrace.PushCall("StencilOp", out.str(), namedParams);
}
out << face << ", " << fail << ", " << zfail << "," << zpass;
TraceCallStack::NamedParams namedParams;
- namedParams["face"] = ToString(face);
- namedParams["fail"] = ToString(fail);
- namedParams["zfail"] = ToString(zfail);
- namedParams["zpass"] = ToString(zpass);
+ namedParams["face"] << std::hex << face;
+ namedParams["fail"] << std::hex << fail;
+ namedParams["zfail"] << std::hex << zfail;
+ namedParams["zpass"] << std::hex << zpass;
mStencilFunctionTrace.PushCall("StencilOpSeparate", out.str(), namedParams);
}
out << target << ", " << level << ", " << width << ", " << height;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["level"] = ToString(level);
- namedParams["internalformat"] = ToString(internalformat);
- namedParams["width"] = ToString(width);
- namedParams["height"] = ToString(height);
- namedParams["border"] = ToString(border);
- namedParams["format"] = ToString(format);
- namedParams["type"] = ToString(type);
+ namedParams["target"] << std::hex << target;
+ namedParams["level"] << level;
+ namedParams["internalformat"] << internalformat;
+ namedParams["width"] << width;
+ namedParams["height"] << height;
+ namedParams["border"] << border;
+ namedParams["format"] << std::hex << format;
+ namedParams["type"] << std::hex << type;
mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
}
out << target << ", " << pname << ", " << param;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["pname"] = ToString(pname);
- namedParams["param"] = ToString(param);
+ namedParams["target"] << std::hex << target;
+ namedParams["pname"] << std::hex << pname;
+ namedParams["param"] << param;
- mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
+ mTexParameterTrace.PushCall("TexParameterf", out.str(), namedParams);
}
inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override
out << target << ", " << pname << ", " << params[0];
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["pname"] = ToString(pname);
- namedParams["params[0]"] = ToString(params[0]);
+ namedParams["target"] << std::hex << target;
+ namedParams["pname"] << std::hex << pname;
+ namedParams["params[0]"] << params[0];
- mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
+ mTexParameterTrace.PushCall("TexParameterfv", out.str(), namedParams);
}
inline void TexParameteri(GLenum target, GLenum pname, GLint param) override
out.str("");
out << std::hex << target;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = out.str();
+ namedParams["target"] << out.str();
out.str("");
out << std::hex << pname;
- namedParams["pname"] = out.str();
+ namedParams["pname"] << out.str();
out.str("");
out << std::hex << param;
- namedParams["param"] = out.str();
- mTexParamaterTrace.PushCall("TexParameteri", params, namedParams);
+ namedParams["param"] << out.str();
+ mTexParameterTrace.PushCall("TexParameteri", params, namedParams);
}
inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override
std::stringstream out;
out << target << ", " << pname << ", " << params[0];
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["pname"] = ToString(pname);
- namedParams["params[0]"] = ToString(params[0]);
- mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
+ namedParams["target"] << std::hex << target;
+ namedParams["pname"] << std::hex << pname;
+ namedParams["params[0]"] << params[0];
+ mTexParameterTrace.PushCall("TexParameteriv", out.str(), namedParams);
}
inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override
out << target << ", " << level << ", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] = ToString(target);
- namedParams["level"] = ToString(level);
- namedParams["xoffset"] = ToString(xoffset);
- namedParams["yoffset"] = ToString(yoffset);
- namedParams["width"] = ToString(width);
- namedParams["height"] = ToString(height);
+ namedParams["target"] << std::hex << target;
+ namedParams["level"] << level;
+ namedParams["xoffset"] << xoffset;
+ namedParams["yoffset"] << yoffset;
+ namedParams["width"] << width;
+ namedParams["height"] << height;
mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
}
inline void Uniform1f(GLint location, GLfloat value) override
{
- std::string params = ToString(value);
+ std::string params = std::to_string(value);
AddUniformCallToTraceStack(location, params);
if(!mProgramUniforms1f.SetUniformValue(mCurrentProgram, location, value))
std::string params;
for(int i = 0; i < count; ++i)
{
- params = params + ToString(v[i]) + ",";
+ params = params + std::to_string(v[i]) + ",";
}
AddUniformCallToTraceStack(location, params);
inline void Uniform1i(GLint location, GLint x) override
{
- std::string params = ToString(x);
+ std::string params = std::to_string(x);
AddUniformCallToTraceStack(location, params);
inline void Uniform1iv(GLint location, GLsizei count, const GLint* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
inline void Uniform2f(GLint location, GLfloat x, GLfloat y) override
{
- std::string params = ToString(x) + "," + ToString(y);
+ std::string params = std::to_string(x) + "," + std::to_string(y);
AddUniformCallToTraceStack(location, params);
if(!mProgramUniforms2f.SetUniformValue(mCurrentProgram,
inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
inline void Uniform2i(GLint location, GLint x, GLint y) override
{
- std::string params = ToString(x) + "," + ToString(y);
+ std::string params = std::to_string(x) + "," + std::to_string(y);
AddUniformCallToTraceStack(location, params);
}
inline void Uniform2iv(GLint location, GLsizei count, const GLint* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
}
inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override
{
- std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z);
+ std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z);
AddUniformCallToTraceStack(location, params);
if(!mProgramUniforms3f.SetUniformValue(mCurrentProgram,
inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
inline void Uniform3i(GLint location, GLint x, GLint y, GLint z) override
{
- std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z);
+ std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z);
AddUniformCallToTraceStack(location, params);
}
inline void Uniform3iv(GLint location, GLsizei count, const GLint* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
}
inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
{
- std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z) + "," + ToString(w);
+ std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + "," + std::to_string(w);
AddUniformCallToTraceStack(location, params);
if(!mProgramUniforms4f.SetUniformValue(mCurrentProgram,
inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override
{
- std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z) + "," + ToString(w);
+ std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + "," + std::to_string(w);
AddUniformCallToTraceStack(location, params);
}
inline void Uniform4iv(GLint location, GLsizei count, const GLint* v) override
{
- std::string params = ToString(v);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i];
+ AddUniformCallToTraceStack(location, out.str());
}
inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- std::string params = ToString(value);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i];
+ AddUniformCallToTraceStack(location, out.str());
}
inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- std::string params = ToString(value);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- std::string params = ToString(value);
- AddUniformCallToTraceStack(location, params);
+ std::ostringstream out;
+ for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i];
+ AddUniformCallToTraceStack(location, out.str());
for(int i = 0; i < count; ++i)
{
{
}
- inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
+ inline void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
{
+ TraceCallStack::NamedParams namedParams;
+ namedParams["index"] << index;
+ namedParams["size"] << size;
+ namedParams["type"] << std::hex << type;
+ namedParams["normalized"] << (normalized ? "T" : "F");
+ namedParams["stride"] << stride;
+ namedParams["offset"] << std::to_string(reinterpret_cast<unsigned long>(ptr));
+
+ mBufferTrace.PushCall("VertexAttribPointer", namedParams.str(), namedParams);
}
inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
}
private:
- inline void AddUniformCallToTraceStack(GLint location, std::string& value)
+ inline void AddUniformCallToTraceStack(GLint location, const std::string& value)
{
std::string name = "<not found>";
bool matched = false;
{
mLinkStatus = value;
}
- inline void SetGetAttribLocationResult(int result)
+ inline void SetAttribLocations(std::vector<std::string> locs)
{
- mGetAttribLocationResult = result;
+ mAttribLocs = locs;
}
inline void SetGetErrorResult(GLenum result)
{
//Methods for Texture verification
inline void EnableTexParameterCallTrace(bool enable)
{
- mTexParamaterTrace.Enable(enable);
+ mTexParameterTrace.Enable(enable);
}
inline void ResetTexParameterCallStack()
{
- mTexParamaterTrace.Reset();
+ mTexParameterTrace.Reset();
}
inline TraceCallStack& GetTexParameterTrace()
{
- return mTexParamaterTrace;
+ return mTexParameterTrace;
}
//Methods for Draw verification
BufferSubDataCalls mBufferSubDataCalls;
GLuint mLinkStatus;
GLint mNumberOfActiveUniforms;
- GLint mGetAttribLocationResult;
GLenum mGetErrorResult;
GLubyte* mGetStringResult;
GLboolean mIsBufferResult;
bool mGetProgramBinaryCalled;
typedef std::map<GLuint, std::string> ShaderSourceMap;
ShaderSourceMap mShaderSources;
+ std::vector<std::string> mAttribLocs; // should be bound to shader
GLuint mLastShaderCompiled;
GLbitfield mLastClearBitMask;
Vector4 mLastClearColor;
ActiveTextureType mActiveTextures[MIN_TEXTURE_UNIT_LIMIT];
- TraceCallStack mBufferTrace{"gl"};
+ TraceCallStack mBufferTrace;
TraceCallStack mCullFaceTrace;
TraceCallStack mEnableDisableTrace;
TraceCallStack mShaderTrace;
- TraceCallStack mTextureTrace{"gl"};
- TraceCallStack mTexParamaterTrace;
+ TraceCallStack mTextureTrace;
+ TraceCallStack mTexParameterTrace;
TraceCallStack mDrawTrace;
TraceCallStack mDepthFunctionTrace;
TraceCallStack mStencilFunctionTrace;
#include "test-graphics-controller.h"
-#include "dali-test-suite-utils.h"
#include "test-graphics-buffer.h"
#include "test-graphics-command-buffer.h"
#include "test-graphics-sampler.h"
#include "test-graphics-texture.h"
#include <dali/integration-api/gl-defines.h>
+#include <cstdio>
#include <iostream>
#include <sstream>
namespace Dali
{
+template<typename T>
+T* Uncast(const Graphics::CommandBuffer* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Texture* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Sampler* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Buffer* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo)
{
return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size;
if(offset > mMappedOffset + mMappedSize ||
size + offset > mMappedOffset + mMappedSize)
{
- tet_infoline("TestGraphics.Memory::LockRegion() Out of bounds");
+ fprintf(stderr, "TestGraphics.Memory::LockRegion() Out of bounds");
mBuffer.memory.resize(mMappedOffset + offset + size); // Grow to prevent memcpy from crashing
}
mLockedOffset = offset;
};
TestGraphicsController::TestGraphicsController()
+: mCallStack(true, "TestGraphicsController."),
+ mCommandBufferCallStack(true, "TestCommandBuffer.")
{
mCallStack.Enable(true);
- mCallStack.EnableLogging(true);
mCommandBufferCallStack.Enable(true);
- mCommandBufferCallStack.EnableLogging(true);
- auto& trace = mGlAbstraction.GetTextureTrace();
+ auto& trace = mGl.GetTextureTrace();
trace.Enable(true);
trace.EnableLogging(true);
}
+int GetNumComponents(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::INTEGER:
+ return 1;
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ return 2;
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ return 3;
+ case Graphics::VertexInputFormat::FVECTOR4:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return 4;
+ }
+ return 1;
+}
+
+GLint GetSize(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ return 1u;
+ case Graphics::VertexInputFormat::INTEGER:
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return 2u;
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR4:
+ return 4u;
+ }
+ return 1u;
+}
+
+GLint GetGlType(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ return GL_BYTE;
+ case Graphics::VertexInputFormat::INTEGER:
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return GL_SHORT;
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR4:
+ return GL_FLOAT;
+ }
+ return GL_BYTE;
+}
+
+GLenum GetTopology(Graphics::PrimitiveTopology topology)
+{
+ switch(topology)
+ {
+ case Graphics::PrimitiveTopology::POINT_LIST:
+ return GL_POINTS;
+
+ case Graphics::PrimitiveTopology::LINE_LIST:
+ return GL_LINES;
+
+ case Graphics::PrimitiveTopology::LINE_LOOP:
+ return GL_LINE_LOOP;
+
+ case Graphics::PrimitiveTopology::LINE_STRIP:
+ return GL_LINE_STRIP;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_LIST:
+ return GL_TRIANGLES;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
+ return GL_TRIANGLE_STRIP;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_FAN:
+ return GL_TRIANGLE_FAN;
+ }
+ return GL_TRIANGLES;
+}
+
void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
{
- std::ostringstream out;
TraceCallStack::NamedParams namedParams;
- out << "cmdBuffer[" << submitInfo.cmdBuffer.size() << "], flags:" << std::hex << submitInfo.flags;
- namedParams["submitInfo"] = out.str();
+ namedParams["submitInfo"] << "cmdBuffer[" << submitInfo.cmdBuffer.size()
+ << "], flags:" << std::hex << submitInfo.flags;
mCallStack.PushCall("Controller::SubmitCommandBuffers", "", namedParams);
- for(auto& commandBuffer : submitInfo.cmdBuffer)
+ for(auto& graphicsCommandBuffer : submitInfo.cmdBuffer)
{
- for(auto& binding : (static_cast<TestGraphicsCommandBuffer*>(commandBuffer))->mTextureBindings)
+ auto commandBuffer = Uncast<TestGraphicsCommandBuffer>(graphicsCommandBuffer);
+ for(auto& binding : commandBuffer->mTextureBindings)
{
if(binding.texture)
{
- auto texture = const_cast<TestGraphicsTexture*>(static_cast<const TestGraphicsTexture*>(binding.texture));
+ auto texture = Uncast<TestGraphicsTexture>(binding.texture);
texture->Bind(binding.binding);
if(binding.sampler)
{
- auto sampler = const_cast<TestGraphicsSampler*>(static_cast<const TestGraphicsSampler*>(binding.sampler));
+ auto sampler = Uncast<TestGraphicsSampler>(binding.sampler);
if(sampler)
{
sampler->Apply(texture->GetTarget());
texture->Prepare(); // Ensure native texture is ready
}
}
+
+ // IndexBuffer binding,
+ auto& indexBufferBinding = commandBuffer->mIndexBufferBinding;
+ if(indexBufferBinding.buffer)
+ {
+ auto buffer = Uncast<TestGraphicsBuffer>(indexBufferBinding.buffer);
+ buffer->Bind();
+ }
+
+ // VertexBuffer binding,
+ for(auto graphicsBuffer : commandBuffer->mVertexBufferBindings.buffers)
+ {
+ auto vertexBuffer = Uncast<TestGraphicsBuffer>(graphicsBuffer);
+ vertexBuffer->Bind();
+ }
+
+ // Pipeline attribute setup
+ auto& vi = commandBuffer->mPipeline->vertexInputState;
+ for(auto& attribute : vi.attributes)
+ {
+ mGl.EnableVertexAttribArray(attribute.location);
+ uint32_t attributeOffset = attribute.offset;
+ GLsizei stride = vi.bufferBindings[attribute.binding].stride;
+
+ mGl.VertexAttribPointer(attribute.location,
+ GetNumComponents(attribute.format),
+ GetGlType(attribute.format),
+ GL_FALSE, // Not normalized
+ stride,
+ reinterpret_cast<void*>(attributeOffset));
+ }
+
+ // draw call
+ auto topology = commandBuffer->mPipeline->inputAssemblyState.topology;
+
+ if(commandBuffer->drawCommand.drawType == TestGraphicsCommandBuffer::Draw::DrawType::Indexed)
+ {
+ mGl.DrawElements(GetTopology(topology),
+ static_cast<GLsizei>(commandBuffer->drawCommand.u.indexedDraw.indexCount),
+ GL_UNSIGNED_SHORT,
+ reinterpret_cast<void*>(commandBuffer->drawCommand.u.indexedDraw.firstIndex));
+ }
+ else
+ {
+ mGl.DrawArrays(GetTopology(topology), 0, commandBuffer->drawCommand.u.unindexedDraw.vertexCount);
+ }
+
+ // attribute clear
+ for(auto& attribute : vi.attributes)
+ {
+ mGl.DisableVertexAttribArray(attribute.location);
+ }
}
}
*/
void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
{
- std::ostringstream out;
TraceCallStack::NamedParams namedParams;
- out << std::hex << renderTarget;
- namedParams["renderTarget"] = out.str();
+ namedParams["renderTarget"] << std::hex << renderTarget;
mCallStack.PushCall("Controller::PresentRenderTarget", "", namedParams);
}
void TestGraphicsController::UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>& updateInfoList,
const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList)
{
- std::ostringstream out;
TraceCallStack::NamedParams namedParams;
- out << "[" << updateInfoList.size() << "]:";
- namedParams["updateInfoList"] = out.str();
- out.str("");
- out << "[" << sourceList.size() << "]:";
- namedParams["sourceList"] = out.str();
+ namedParams["updateInfoList"] << "[" << updateInfoList.size() << "]:";
+ namedParams["sourceList"] << "[" << sourceList.size() << "]:";
mCallStack.PushCall("Controller::UpdateTextures", "", namedParams);
bool TestGraphicsController::EnableDepthStencilBuffer(bool enableDepth, bool enableStencil)
{
TraceCallStack::NamedParams namedParams;
- namedParams["enableDepth"] = enableDepth ? "T" : "F";
- namedParams["enableStencil"] = enableStencil ? "T" : "F";
+ namedParams["enableDepth"] << (enableDepth ? "T" : "F");
+ namedParams["enableStencil"] << (enableStencil ? "T" : "F");
mCallStack.PushCall("Controller::EnableDepthStencilBuffer", "", namedParams);
return false;
}
void TestGraphicsController::RunGarbageCollector(size_t numberOfDiscardedRenderers)
{
- std::ostringstream out;
- out << numberOfDiscardedRenderers;
TraceCallStack::NamedParams namedParams;
- namedParams["numberOfDiscardedrenderers"] = out.str();
+ namedParams["numberOfDiscardedRenderers"] << numberOfDiscardedRenderers;
mCallStack.PushCall("Controller::RunGarbageCollector", "", namedParams);
}
std::ostringstream oss;
oss << "bufferCreateInfo:" << createInfo;
mCallStack.PushCall("Controller::CreateBuffer", oss.str());
- return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGlAbstraction, createInfo.size, createInfo.usage);
+ return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGl, createInfo.size, createInfo.usage);
}
Graphics::UniquePtr<Graphics::CommandBuffer> TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
std::ostringstream oss;
oss << "commandBufferCreateInfo:" << commandBufferCreateInfo;
mCallStack.PushCall("Controller::CreateCommandBuffer", oss.str());
- return Graphics::MakeUnique<TestGraphicsCommandBuffer>(mCommandBufferCallStack, mGlAbstraction);
+ return Graphics::MakeUnique<TestGraphicsCommandBuffer>(mCommandBufferCallStack, mGl);
}
Graphics::UniquePtr<Graphics::RenderPass> TestGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<Graphics::RenderPass>&& oldRenderPass)
Graphics::UniquePtr<Graphics::Texture> TestGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Graphics::Texture>&& oldTexture)
{
- std::ostringstream params, oss;
- params << "textureCreateInfo:" << textureCreateInfo;
TraceCallStack::NamedParams namedParams;
- oss << textureCreateInfo;
- namedParams["textureCreateInfo"] = oss.str();
- mCallStack.PushCall("Controller::CreateTexture", params.str(), namedParams);
+ namedParams["textureCreateInfo"] << textureCreateInfo;
+ mCallStack.PushCall("Controller::CreateTexture", namedParams.str(), namedParams);
- return Graphics::MakeUnique<TestGraphicsTexture>(mGlAbstraction, textureCreateInfo);
+ return Graphics::MakeUnique<TestGraphicsTexture>(mGl, textureCreateInfo);
}
Graphics::UniquePtr<Graphics::Framebuffer> TestGraphicsController::CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Graphics::Framebuffer>&& oldFramebuffer)
Graphics::UniquePtr<Graphics::Pipeline> TestGraphicsController::CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
{
mCallStack.PushCall("Controller::CreatePipeline", "");
- return nullptr;
+ return std::make_unique<TestGraphicsPipeline>(mGl, pipelineCreateInfo);
}
Graphics::UniquePtr<Graphics::Shader> TestGraphicsController::CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader)
Graphics::UniquePtr<Graphics::Sampler> TestGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Graphics::Sampler>&& oldSampler)
{
- std::ostringstream params, oss;
- params << "samplerCreateInfo:" << samplerCreateInfo;
TraceCallStack::NamedParams namedParams;
- oss << samplerCreateInfo;
- namedParams["samplerCreateInfo"] = oss.str();
- mCallStack.PushCall("Controller::CreateSampler", params.str(), namedParams);
+ namedParams["samplerCreateInfo"] << samplerCreateInfo;
+ mCallStack.PushCall("Controller::CreateSampler", namedParams.str(), namedParams);
- return Graphics::MakeUnique<TestGraphicsSampler>(mGlAbstraction, samplerCreateInfo);
+ return Graphics::MakeUnique<TestGraphicsSampler>(mGl, samplerCreateInfo);
}
Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)