/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
return texture;
}
+TextureSet CreateTextureSet(Pixel::Format format, int width, int height)
+{
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture(0u, CreateTexture(TextureType::TEXTURE_2D, format, width, height));
+ return textureSet;
+}
+
} // namespace Dali
#define DALI_TEST_ACTOR_UTILS_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
*/
Actor CreateRenderableActor2(TextureSet textures, const std::string& vertexShader, const std::string& fragmentShader);
-Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height);
+Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height);
+TextureSet CreateTextureSet(Pixel::Format format, int width, int height);
} // namespace Dali
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
mProgramUniforms3f.clear();
mProgramUniforms4f.clear();
- mAttribLocs.clear();
- mAttribLocs.push_back("aPosition");
- mAttribLocs.push_back("aTexCoord");
+ mAttribLocs = {"aPosition", "aTexCoord"};
+ mAttribTypes = {GL_FLOAT, GL_FLOAT};
+
mCullFaceTrace.Reset();
mDepthFunctionTrace.Reset();
mEnableDisableTrace.Reset();
inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
{
+ strncpy(name, mAttribLocs[index].c_str(), 99);
+ *type = mAttribTypes[index];
}
inline void SetActiveUniforms(const std::vector<ActiveUniform>& uniforms)
mBufferTrace.PushCall("VertexAttribPointer", namedParams.str(), namedParams);
}
+ inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
+ {
+ TraceCallStack::NamedParams namedParams;
+ namedParams["index"] << index;
+ namedParams["size"] << size;
+ namedParams["type"] << std::hex << type;
+ namedParams["stride"] << stride;
+ namedParams["offset"] << std::to_string(reinterpret_cast<unsigned long>(pointer));
+
+ mBufferTrace.PushCall("VertexAttribIPointer", namedParams.str(), namedParams);
+ }
+
inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
{
std::string commaString(", ");
{
}
- inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
- {
- }
-
inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
{
}
{
mLinkStatus = value;
}
- inline void SetAttribLocations(std::vector<std::string> locs)
+ inline void SetAttribLocations(std::vector<std::string>& locs)
{
mAttribLocs = locs;
}
+ inline void SetAttribTypes(std::vector<GLenum>& types)
+ {
+ mAttribTypes = types;
+ }
inline void SetGetErrorResult(GLenum result)
{
mGetErrorResult = result;
bool mGetProgramBinaryCalled;
typedef std::map<GLuint, std::string> ShaderSourceMap;
ShaderSourceMap mShaderSources;
- std::vector<std::string> mAttribLocs; // should be bound to shader
+ std::vector<std::string> mAttribLocs; // should be bound to shader
+ std::vector<GLenum> mAttribTypes; // should be bound to shader
GLuint mLastShaderCompiled;
GLbitfield mLastClearBitMask;
Vector4 mLastClearColor;
utc-Dali-GlImplementation.cpp
utc-Dali-GlesImplementation.cpp
utc-Dali-GraphicsBuffer.cpp
+ utc-Dali-GraphicsDraw.cpp
utc-Dali-GraphicsFramebuffer.cpp
utc-Dali-GraphicsGeometry.cpp
utc-Dali-GraphicsNativeImage.cpp
--- /dev/null
+/*
+ * Copyright (c) 2023 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-test-suite-utils.h>
+#include <dali/dali.h>
+
+#include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
+#include <test-actor-utils.h>
+#include <test-graphics-application.h>
+#include <test-graphics-framebuffer.h>
+
+using namespace Dali;
+
+namespace
+{
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ INPUT mediump vec2 aPos;\n
+ INPUT mediump int aCount;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ OUTPUT flat int vCount;\n void main()\n {
+ \n
+ mediump vec4 vertexPosition(aPos, 0.0, 1.0);
+ \n
+ gl_Position = uMvpMatrix * vertexPosition;
+ \n
+ }\n);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ uniform lowp vec4 uColor;\n
+ INPUT flat int vCount;\n void main()\n {
+ \n
+ mediump float g = (128.0 + vCount * 16) / 255.0;
+ \n
+ gl_FragColor = uColor * g;
+ \n
+ }\n);
+
+} // namespace
+
+void utc_dali_texture_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_texture_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliGraphicsDrawIntegerVertexAttribs(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsDrawIntegerVertexAttribs - Test that integer vertex attribs use correct GL call");
+
+ auto& gl = app.GetGlAbstraction();
+ auto& bufferTrace = gl.GetBufferTrace();
+ bufferTrace.EnableLogging(true);
+ bufferTrace.Enable(true);
+
+ // Initalize GL shader reflection
+ std::vector<std::string> aLocs = {"aPos", "aCount"};
+ std::vector<GLenum> aTypes = {GL_FLOAT, GL_INT};
+ gl.SetAttribLocations(aLocs);
+ gl.SetAttribTypes(aTypes);
+
+ TextureSet textureSet = CreateTextureSet(Pixel::RGBA8888, 200, 200);
+ Property::Map vertexFormat{{"aPos", Property::VECTOR2}, {"aCount", Property::INTEGER}};
+ VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
+
+ struct VertexFormat
+ {
+ Vector2 aPos;
+ int aCount;
+ };
+ std::vector<VertexFormat> vertexData = {{Vector2{10, 20}, 1}, {Vector2{10, 20}, 2}, {Vector2{10, 20}, 3}, {Vector2{10, 20}, 4}};
+ vertexBuffer.SetData(&vertexData[0], sizeof(vertexData) / sizeof(VertexFormat));
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer(vertexBuffer);
+ Shader shader = Shader::New(VERTEX_SHADER, FRAGMENT_SHADER);
+ Renderer renderer = Renderer::New(geometry, shader);
+ renderer.SetTextures(textureSet);
+ Actor dummyActor = Actor::New();
+ dummyActor[Actor::Property::SIZE] = Vector2(200, 200);
+ dummyActor.AddRenderer(renderer);
+ app.GetScene().Add(dummyActor);
+
+ app.SendNotification();
+ app.Render(16);
+
+ tet_infoline("Test that we have both VertexAttribPointer and VertexAttribIPointer called");
+ DALI_TEST_CHECK(bufferTrace.FindMethod("VertexAttribPointer"));
+ DALI_TEST_CHECK(bufferTrace.FindMethod("VertexAttribIPointer"));
+
+ END_TEST;
+}
{
} // namespace
-void utc_dali_texture_startup(void)
+void utc_dali_graphics_draw_startup(void)
{
test_return_value = TET_UNDEF;
}
-void utc_dali_texture_cleanup(void)
+void utc_dali_graphics_draw_cleanup(void)
{
test_return_value = TET_PASS;
}
}
// for each attribute bind vertices
-
const auto& pipelineState = mImpl->mNewPipeline ? mImpl->mNewPipeline->GetCreateInfo() : mImpl->mCurrentPipeline->GetCreateInfo();
const auto& vertexInputState = pipelineState.vertexInputState;
// Bind buffer
BindBuffer(GL_ARRAY_BUFFER, glesBuffer);
- gl.VertexAttribPointer(attr.location,
- GLVertexFormat(attr.format).size,
- GLVertexFormat(attr.format).format,
- GL_FALSE,
- bufferBinding.stride,
- reinterpret_cast<void*>(attr.offset));
+ if(attr.format == VertexInputFormat::FLOAT ||
+ attr.format == VertexInputFormat::FVECTOR2 ||
+ attr.format == VertexInputFormat::FVECTOR3 ||
+ attr.format == VertexInputFormat::FVECTOR4)
+ {
+ gl.VertexAttribPointer(attr.location,
+ GLVertexFormat(attr.format).size,
+ GLVertexFormat(attr.format).format,
+ GL_FALSE,
+ bufferBinding.stride,
+ reinterpret_cast<void*>(attr.offset));
+ }
+ else
+ {
+ gl.VertexAttribIPointer(attr.location,
+ GLVertexFormat(attr.format).size,
+ GLVertexFormat(attr.format).format,
+ bufferBinding.stride,
+ reinterpret_cast<void*>(attr.offset));
+ }
switch(bufferBinding.inputRate)
{