INCLUDE(FindPkgConfig)
SET(BIN_DIR "/opt/usr/bin")
+OPTION(ENABLE_VULKAN "Whether to build tests for vulkan or gl" ON)
+
INCLUDE_DIRECTORIES(
src/common
)
--- /dev/null
+include(CheckIncludeFileCXX)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 3.8.2)
+SET(CMAKE_CXX_STANDARD 17)
+
+PROJECT(tct_coreapi_utc)
+
+INCLUDE(FindPkgConfig)
+SET(BIN_DIR "/opt/usr/bin")
+
+OPTION(ENABLE_VULKAN "Whether to build tests for vulkan or gl" @ENABLE_VULKAN@)
+
+INCLUDE_DIRECTORIES(
+ src/common
+)
+
+ADD_SUBDIRECTORY(src)
function build
{
- if [ $opt_generate == true -o $opt_rebuild == false ] ; then
- (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
- if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
- fi
+ echo Building $1
+
BUILDSYSTEM="Unix Makefiles"
BUILDCMD=make
if [ -e ../build/tizen/build.ninja ] ; then
BUILDSYSTEM="Ninja"
BUILDCMD=ninja
fi
+
+ if [ $opt_generate == true -o $opt_rebuild == false ] ; then
+ (cd build ; rm CMakeCache.txt ; cmake .. -C /dev/null -G "$BUILDSYSTEM" -DMODULE=$1)
+ (cd src/$1; ../../scripts/retriever.sh -l)
+ (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ fi
+
(cd build ; cmake .. -DMODULE=$1 -G "$BUILDSYSTEM" ; $BUILDCMD -j7 )
}
+# Query main build to determine if we are using vulkan or egl
+ENABLE_VULKAN=0
+(cd ../build/tizen ; cmake -LA -N 2>/dev/null | grep ENABLE_VULKAN | grep "\=ON")
+if [ $? -eq 0 ] ; then
+ ENABLE_VULKAN=1
+fi
if [ -n "$1" ] ; then
echo BUILDING ONLY $1
build $1
else
for mod in `ls -1 src/ | grep -v CMakeList `
do
- if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
- echo BUILDING $mod
- build $mod
- if [ $? -ne 0 ]; then echo "Build failed" ; exit 1; fi
- fi
+ build=0
+ # Don't build dali-egl-graphics if we are using Vulkan...
+ if [ $mod == 'dali-egl-graphics' ] ; then
+ if [ $ENABLE_VULKAN == 0 ] ; then
+ build=1
+ fi
+ elif [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+ build=1
+ fi
+
+ if [ $build == 1 ] ; then
+ echo BUILDING $mod
+ build $mod
+ if [ $? -ne 0 ]; then echo "Build failed" ; exit 1; fi
+ fi
done
fi
EOF
}
+modules=`ls -1 build/src | grep -v CMakeFiles | grep -v cmake_install.cmake`
if [ $opt_modules == 1 ] ; then
- modules= get_modules
echo $modules
exit 0
fi
ASCII_BOLD="\e[1m"
ASCII_RESET="\e[0m"
-modules=`ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
if [ -f summary.xml ] ; then unlink summary.xml ; fi
if [ $opt_tct == 1 ] ; then
EOF
)
-function get_tc_files {
+function get_tc_files_old {
CMAKE_FILE="$DIR/CMakeLists.txt"
if [ ! -e $CMAKE_FILE ]; then
echo "File $CMAKE_FILE not found. Aborting..."
}')
}
+function get_tc_files {
+ TC_FILES=$(cd ../../build; cmake -LA -N 2>/dev/null | grep TC_SOURCE_LIST | perl -n -e 'my ($blah, $vars)=split(/=/,$_);my @files=split(/;/, $vars); print join("\n", @files) ;' )
+}
+
function tc_names {
if [[ -z "$1" ]]; then
exit
# usage note and exit:
# - argument begin with '-' but is not recognised or number of arguments is > 3,
# - argument doesn't begin with '-' and number of arguments is > 2
-if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f)$ || $# > 3 ) ) || ( "$1" != -* && $# > 2 ) ]]; then
+if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f|l)$ || $# > 3 ) ) || ( "$1" != -* && $# > 2 ) ]]; then
echo -e "$USAGE"
exit 1
fi
# get directory from last argument (or assume current one)
-if [[ ! "$1" =~ ^-(anum|mnum|f)$ ]]; then
+if [[ ! "$1" =~ ^-(anum|mnum|f|l)$ ]]; then
DIR=${1:-.}
else
DIR=${2:-.}
tc_mnum $TC_FILES ;;
-f)
tc_fullinfo $TC_FILES ;;
+ -l)
+ echo $TC_FILES ;;
*)
tc_names $TC_FILES ;;
esac
SET(EXEC_NAME "tct-${PKG_NAME}-core")
SET(RPM_NAME "core-${PKG_NAME}-tests")
+MESSAGE(STATUS "ENABLE_VULKAN: ${ENABLE_VULKAN}")
+
SET(CAPI_LIB "dali-adaptor-internal")
SET(TC_SOURCES
utc-Dali-LRUCacheContainer.cpp
utc-Dali-TiltSensor.cpp
utc-Dali-WbmpLoader.cpp
+)
+
+IF(ENABLE_VULKAN)
+ELSE()
+ LIST(APPEND TC_SOURCES
utc-Dali-GlImplementation.cpp
utc-Dali-GlesImplementation.cpp
-)
+ )
+ENDIF()
+
+SET(TC_SOURCE_LIST ${TC_SOURCES} CACHE STRING "List of test sources")
LIST(APPEND TC_SOURCES
image-loaders.cpp
SET(EXEC_NAME "tct-${PKG_NAME}-core")
SET(RPM_NAME "core-${PKG_NAME}-tests")
+MESSAGE(STATUS "ENABLE_VULKAN: ${ENABLE_VULKAN}")
+
SET(CAPI_LIB "dali-adaptor")
+
SET(TC_SOURCES
utc-Dali-Application.cpp
utc-Dali-EncodedImageBuffer.cpp
- utc-Dali-Capture.cpp
utc-Dali-WindowData.cpp
utc-Dali-FileLoader.cpp
utc-Dali-GifLoading.cpp
- utc-Dali-Gl-Window.cpp
utc-Dali-ImageLoading.cpp
utc-Dali-Key.cpp
utc-Dali-NativeImageSource.cpp
utc-Dali-WindowSystem.cpp
)
+IF(ENABLE_VULKAN)
+ELSE()
+ LIST(APPEND TC_SOURCES
+ utc-Dali-Gl-Window.cpp
+ utc-Dali-Capture.cpp
+)
+ENDIF()
+
+SET(TC_SOURCE_LIST ${TC_SOURCES} CACHE STRING "List of test sources")
+
LIST(APPEND TC_SOURCES
dali-test-suite-utils/mesh-builder.cpp
dali-test-suite-utils/dali-test-suite-utils.cpp
--- /dev/null
+SET(PKG_NAME "dali-egl-graphics")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+MESSAGE(STATUS "ENABLE_VULKAN: ${ENABLE_VULKAN}")
+
+SET(CAPI_LIB "dali-egl-graphics")
+
+SET(TC_SOURCES
+ utc-Dali-GraphicsBuffer.cpp
+ utc-Dali-GraphicsDraw.cpp
+ utc-Dali-GraphicsFramebuffer.cpp
+ utc-Dali-GraphicsGeometry.cpp
+ utc-Dali-GraphicsNativeImage.cpp
+ utc-Dali-GraphicsProgram.cpp
+ utc-Dali-GraphicsSampler.cpp
+ utc-Dali-GraphicsShader.cpp
+ utc-Dali-GraphicsShaderParser.cpp
+ utc-Dali-GraphicsTexture.cpp
+)
+
+SET(TC_SOURCE_LIST ${TC_SOURCES} CACHE STRING "List of test sources")
+
+LIST(APPEND TC_SOURCES
+ ../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp
+ ../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-harness.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp
+
+ ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-impl.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-object.cpp
+
+ ../dali-adaptor/dali-test-suite-utils/test-native-image.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
+ ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+ tct-dali-egl-graphics-core.cpp
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+ dali2-core
+ dali2-adaptor
+ glesv2
+)
+
+ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror )
+ADD_COMPILE_OPTIONS( ${${CAPI_LIB}_CFLAGS_OTHER} )
+
+ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+ SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+ ../../../
+ ${${CAPI_LIB}_INCLUDE_DIRS}
+ ../dali-adaptor/dali-test-suite-utils
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+ ${${CAPI_LIB}_LIBRARIES}
+ --coverage
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+ DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
--- /dev/null
+#include <test-harness.h>
+
+#include "tct-dali-egl-graphics-core.h"
+
+int main(int argc, char* const argv[])
+{
+ return TestHarness::RunTests(argc, argv, tc_array);
+}
--- /dev/null
+/*
+ * 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.
+ * 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
+{
+} // namespace
+
+int UtcDaliBufferReuseTest(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliBufferReuseTest: Tests whether GLES buffer can be reused (orphaning content)");
+
+ auto& controller = app.GetGraphicsController();
+
+ Graphics::BufferCreateInfo info;
+ info.size = 1024;
+ info.usage = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
+ info.propertiesFlags = 0u;
+
+ auto buffer = controller.CreateBuffer(info, nullptr);
+ controller.WaitIdle();
+
+ DALI_TEST_NOT_EQUALS((void*)buffer.get(), (void*)nullptr, 0, TEST_LOCATION);
+
+ // New buffer with different spec, should create new object
+ Graphics::BufferCreateInfo info2;
+ info.size = 2024;
+ info.usage = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
+ info.propertiesFlags = 0u;
+
+ auto buffer2 = controller.CreateBuffer(info2, std::move(buffer));
+ controller.WaitIdle();
+
+ DALI_TEST_NOT_EQUALS(buffer.get(), buffer2.get(), 0, TEST_LOCATION);
+
+ auto ptr = buffer2.get(); // store pointer for testing, the uptr will be emptied
+ // Create new buffer using the same spec
+ auto buffer3 = controller.CreateBuffer(info2, std::move(buffer2));
+ controller.WaitIdle();
+
+ DALI_TEST_EQUALS(ptr, buffer3.get(), TEST_LOCATION);
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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;
+}
--- /dev/null
+/*
+ * 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.
+ * 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
+{
+RenderTask CreateRenderTask(TestGraphicsApplication& application,
+ FrameBuffer framebuffer)
+{
+ Actor rootActor = Actor::New();
+ application.GetScene().Add(rootActor);
+ Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
+ Actor sourceActor = CreateRenderableActor(img);
+ application.GetScene().Add(sourceActor);
+
+ CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT));
+ application.GetScene().Add(offscreenCameraActor);
+
+ // Change main render task to use a different root
+ RenderTaskList taskList = application.GetScene().GetRenderTaskList();
+ taskList.GetTask(0u).SetSourceActor(rootActor);
+
+ RenderTask newTask = taskList.CreateTask();
+ newTask.SetCameraActor(offscreenCameraActor);
+ newTask.SetSourceActor(sourceActor);
+ newTask.SetInputEnabled(false);
+ newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
+ newTask.SetClearEnabled(true);
+ newTask.SetExclusive(true);
+ newTask.SetFrameBuffer(framebuffer);
+
+ return newTask;
+}
+} // namespace
+
+void utc_dali_graphics_framebuffer_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_graphics_framebuffer_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliGraphicsFramebufferAttachDepth(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachDepth - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsFramebufferAttachStencil(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachStencil - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsFramebufferAttachDepthStencil(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachDepthStencil - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsFramebufferAttachDepthTexture(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachDepthTexture - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ Texture dummyDepthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+ DevelFrameBuffer::AttachDepthTexture(framebuffer, dummyDepthTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsFramebufferAttachDepthStencilTexture(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachDepthStencilTexture - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ {
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ Texture dummyDepthStencilTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+ DevelFrameBuffer::AttachDepthStencilTexture(framebuffer, dummyDepthStencilTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ UnparentAndReset(dummyActor);
+ }
+ // Ensure some cleanup happens!
+ app.SendNotification();
+ app.Render(16);
+ app.SendNotification();
+ app.Render(16);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsFramebufferAttachStencilAndDepthTexture(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsFramebufferAttachStencilAndDepthTexture - Test for GLES specific behavior");
+
+ auto& gl = app.GetGlAbstraction();
+
+ uint32_t width = 16u;
+ uint32_t height = 24u;
+
+ FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
+
+ DALI_TEST_CHECK(framebuffer);
+
+ Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ // Note : Current GLES cannot seperate destination of depth result and stencil result. We need to make the texture as DEPTH_STENCIL
+ Texture dummyDepthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
+ Actor dummyActor = CreateRenderableActor(dummyColorTexture);
+ framebuffer.AttachColorTexture(dummyColorTexture);
+ DevelFrameBuffer::AttachDepthTexture(framebuffer, dummyDepthTexture);
+
+ app.GetScene().Add(dummyActor);
+
+ auto renderTask = CreateRenderTask(app, framebuffer);
+
+ DALI_TEST_CHECK(renderTask);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
+
+ END_TEST;
+}
--- /dev/null
+#include <dali-test-suite-utils.h>
+
+#include <dali/graphics-api/graphics-controller.h>
+#include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
+#include <test-graphics-application.h>
+//#include <dali/graphics-api/graphics-api-buffer.h>
+
+int UtcDaliGraphicsCreateGeometry(void)
+{
+ // Initialize actual egl graphics controller (without initializing egl!)
+ TestGraphicsApplication app;
+
+ struct Vertex
+ {
+ float x;
+ float y;
+ };
+
+ std::vector<Vertex> someData(100);
+ Graphics::Controller& graphicsController = app.GetGraphicsController();
+
+ Graphics::BufferCreateInfo createInfo;
+ createInfo
+ .SetUsage(0 | Graphics::BufferUsage::VERTEX_BUFFER)
+ .SetSize(someData.size());
+
+ auto buffer = graphicsController.CreateBuffer(createInfo, nullptr);
+ Graphics::MapBufferInfo info;
+ info.buffer = buffer.get();
+ info.usage = 0 | Graphics::MemoryUsageFlagBits::WRITE;
+ info.offset = 0;
+ info.size = someData.size();
+
+ auto memory = graphicsController.MapBufferRange(info);
+ void* ptr = memory->LockRegion(0, someData.size());
+ DALI_TEST_CHECK(ptr != nullptr);
+ memory->Unlock(true);
+ graphicsController.UnmapMemory(std::move(memory));
+
+ // Test that data has been uploaded to GL, e.g. test that GPU buffer has been created
+ auto& gl = app.GetGlAbstraction();
+ auto& bufferDataCalls = gl.GetBufferDataCalls();
+ DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(bufferDataCalls[0], someData.size(), TEST_LOCATION);
+ DALI_TEST_CHECK(1);
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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-native-image.h>
+
+using namespace Dali;
+
+void utc_dali_native_image_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_native_image_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliGraphicsNativeImage(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliNativeImageTexture01");
+
+ TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
+ TraceCallStack& callStack = imageInterface->mCallStack;
+ callStack.EnableLogging(true);
+ callStack.Enable(true);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& textureCallStack = gl.GetTextureTrace();
+ textureCallStack.EnableLogging(true);
+ textureCallStack.Enable(true);
+
+ {
+ Texture texture = Texture::New(*(imageInterface.Get()));
+ Actor actor = CreateRenderableActor(texture, "", "");
+ app.GetScene().Add(actor);
+
+ app.SendNotification();
+ app.Render(16);
+
+ DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(callStack.FindMethod("PrepareTexture"), true, TEST_LOCATION);
+ TraceCallStack::NamedParams params;
+ params["target"] << std::hex << GL_TEXTURE_EXTERNAL_OES;
+ DALI_TEST_EQUALS(textureCallStack.FindMethodAndParams("BindTexture", params), 1u, TEST_LOCATION);
+ Dali::UnparentAndReset(actor);
+ }
+
+ app.SendNotification();
+ app.Render(16); // Puts texture on discard queue.
+
+ app.SendNotification();
+ app.Render(16);
+
+ // Flush the queues
+ Graphics::SubmitInfo submitInfo{{}, 0 | Graphics::SubmitFlagBits::FLUSH};
+ app.GetGraphicsController().SubmitCommandBuffers(submitInfo);
+
+ DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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-sampler.h>
+
+using namespace Dali;
+
+void utc_dali_program_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_program_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+const std::string VERT_SHADER_SOURCE = "myVertShaderSource";
+
+const std::string VERT_SHADER_SOURCE2 =
+ "\n"
+ "in vec3 aPosition;\n"
+ "in vec3 aTexCoord;\n"
+ "out vec2 vTexCoord;\n"
+ "main()\n"
+ "{\n"
+ " gl_Position=aPosition;\n"
+ " vTexCoord = aTexCoord;\n"
+ "}\n";
+
+const std::string FRAG_SHADER_SOURCE =
+ "\n"
+ "uniform sampler2D sAlbedo;\n"
+ "uniform sampler2D sMetalRoughness;\n"
+ "uniform sampler2D sNormals;\n"
+ "uniform sampler2D sAmbientOcclusion;\n"
+ "uniform mediump vec3 lightDirection;\n"
+ "in mediump vec2 vTexCoord;\n"
+ "main()\n"
+ "{\n"
+ " gl_fragColor = texture2d(sAlbedo, vTexCoord) + lightDirection*texture2d(sNormals, vTexCoord);\n"
+ "}\n";
+
+const std::string FRAG_SHADER_SOURCE2 =
+ "\n"
+ "uniform sampler2D sTextures[4];\n"
+ "uniform mediump vec3 lightDirection;\n"
+ "in mediump vec2 vTexCoord;\n"
+ "main()\n"
+ "{\n"
+ " gl_fragColor = texture2d(sTextures[0], vTexCoord) + lightDirection*texture2d(sTextures[2], vTexCoord);\n"
+ "}\n";
+
+} // anonymous namespace
+
+int UtcDaliGraphicsProgram01(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliProgram - check that right sampler uniforms are bound for textures");
+
+ Texture normals = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture metalroughness = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture ao = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture albedo = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture(0, albedo);
+ textureSet.SetTexture(1, metalroughness);
+ textureSet.SetTexture(2, normals);
+ textureSet.SetTexture(3, ao);
+
+ Actor actor = CreateRenderableActor2(textureSet, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+ app.GetScene().Add(actor);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glUniformTrace = gl.GetSetUniformTrace();
+ glUniformTrace.Enable(true);
+ glUniformTrace.EnableLogging(true);
+
+ std::vector<ActiveUniform> activeUniforms{
+ {"sAlbedo", GL_SAMPLER_2D, 1},
+ {"sAmbientOcclusion", GL_SAMPLER_2D, 1},
+ {"sNormals", GL_SAMPLER_2D, 1},
+ {"sMetalRoughness", GL_SAMPLER_2D, 1}};
+ gl.SetActiveUniforms(activeUniforms);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ // Check what uniform values were set:
+ int value;
+ DALI_TEST_CHECK(gl.GetUniformValue("sAlbedo", value)); // First in frag shader
+ DALI_TEST_EQUALS(value, 0, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sAmbientOcclusion", value)); // 4th
+ DALI_TEST_EQUALS(value, 3, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sNormals", value)); // 3rd
+ DALI_TEST_EQUALS(value, 2, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sMetalRoughness", value)); // 2nd
+ DALI_TEST_EQUALS(value, 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsProgram02(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliProgram - check that sampler arrays are handled and bound to textures");
+
+ Texture normals = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture metalroughness = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture ao = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Texture albedo = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture(0, albedo);
+ textureSet.SetTexture(1, metalroughness);
+ textureSet.SetTexture(2, normals);
+ textureSet.SetTexture(3, ao);
+
+ Actor actor = CreateRenderableActor2(textureSet, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
+ app.GetScene().Add(actor);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glUniformTrace = gl.GetSetUniformTrace();
+ glUniformTrace.Enable(true);
+ glUniformTrace.EnableLogging(true);
+ gl.GetShaderTrace().Enable(true);
+ gl.GetShaderTrace().EnableLogging(true);
+
+ std::vector<ActiveUniform> activeUniforms{
+ {"uLightDir", GL_FLOAT_VEC4, 1},
+ {"sTextures[0]", GL_SAMPLER_2D, 4}}; // Array of 4 samplers
+ gl.SetActiveUniforms(activeUniforms);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ // Check what uniform values were set:
+ int value;
+ DALI_TEST_CHECK(gl.GetUniformValue("sTextures[0]", value)); // First in frag shader
+ DALI_TEST_EQUALS(value, 0, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sTextures[3]", value)); // 4th
+ DALI_TEST_EQUALS(value, 3, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sTextures[2]", value)); // 3rd
+ DALI_TEST_EQUALS(value, 2, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue("sTextures[1]", value)); // 2nd
+ DALI_TEST_EQUALS(value, 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsShaderNew(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliProgram - check that multiple shaders from same source only create 1 program");
+
+ Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+
+ // Creates 3 Dali::Shaders
+ Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+ Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+ Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+
+ app.GetScene().Add(actor1);
+ app.GetScene().Add(actor2);
+ app.GetScene().Add(actor3);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glShaderTrace = gl.GetShaderTrace();
+ glShaderTrace.Enable(true);
+ glShaderTrace.EnableLogging(true);
+
+ app.SendNotification();
+ app.Render(16); // The above actors will get rendered and drawn once, only 1 program and 2 shaders should be created
+
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 2, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsShaderNew02(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliProgram - check that mixed up multiple shaders from same source don't create dups");
+
+ Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+
+ // Creates 3 Dali::Shaders
+ Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+ Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE2);
+ Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
+ Actor actor4 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE);
+
+ app.GetScene().Add(actor1);
+ app.GetScene().Add(actor2);
+ app.GetScene().Add(actor3);
+ app.GetScene().Add(actor4);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glShaderTrace = gl.GetShaderTrace();
+ glShaderTrace.Enable(true);
+ glShaderTrace.EnableLogging(true);
+
+ app.SendNotification();
+ app.Render(16); // The above actors will get rendered and drawn once, only 4 programs and 4 shaders should be created
+
+ // Should only be 4 shaders, not 8.
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 4, TEST_LOCATION);
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 4, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsShaderFlush(void)
+{
+ // Note : This UTC will not works well since now GLES::ProgramImpl hold the reference of shader,
+ // and we don't have any way to remove GLES::ProgramImpl by normal way.
+ // Just block this UTC until the policy was fixed up.
+#if 0
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliProgram - check that unused shaders are flushed");
+
+ Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ auto& gl = app.GetGlAbstraction();
+ auto& glShaderTrace = gl.GetShaderTrace();
+ glShaderTrace.Enable(true);
+ glShaderTrace.EnableLogging(true);
+
+ {
+ // Creates 4 Dali::Shaders
+ Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
+ Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE2);
+ Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
+ Actor actor4 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE);
+
+ app.GetScene().Add(actor1);
+ app.GetScene().Add(actor2);
+ app.GetScene().Add(actor3);
+ app.GetScene().Add(actor4);
+
+ app.SendNotification();
+ app.Render(16); // The above actors will get rendered and drawn once
+
+ // Should only be 4 shaders, not 8.
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 4, TEST_LOCATION);
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 4, TEST_LOCATION);
+
+ UnparentAndReset(actor1);
+ UnparentAndReset(actor2);
+ UnparentAndReset(actor3);
+ UnparentAndReset(actor4);
+ }
+
+ for(int i = 0; i < 1199; ++i) // 3 flushes per frame
+ {
+ app.SendNotification();
+ app.Render(16);
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("DeleteShader"), 0, TEST_LOCATION);
+ }
+
+ app.SendNotification();
+ app.Render(16);
+ DALI_TEST_EQUALS(glShaderTrace.CountMethod("DeleteShader"), 4, TEST_LOCATION);
+#else
+ DALI_TEST_CHECK(true);
+#endif
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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-sampler.h>
+
+using namespace Dali;
+
+void utc_dali_sampler_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_sampler_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliGraphicsSamplerDefault(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliSampler01 - check defaults");
+
+ Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Actor actor = CreateRenderableActor(texture, "myVertShaderSource", "myFragShaderSource");
+ app.GetScene().Add(actor);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glParamTrace = gl.GetTexParameterTrace();
+ glParamTrace.Enable(true);
+ glParamTrace.EnableLogging(true);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ TraceCallStack::NamedParams minFilter;
+ minFilter["pname"] << std::hex << GL_TEXTURE_MIN_FILTER;
+ std::ostringstream LINEAR;
+ LINEAR << GL_LINEAR;
+ std::ostringstream CLAMP_TO_EDGE;
+ CLAMP_TO_EDGE << GL_CLAMP_TO_EDGE;
+
+ auto params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
+ DALI_TEST_CHECK(params != nullptr);
+ auto iter = params->find("param");
+ DALI_TEST_EQUALS(iter->value.str(), LINEAR.str(), TEST_LOCATION);
+
+ TraceCallStack::NamedParams magFilter;
+ magFilter["pname"] << std::hex << GL_TEXTURE_MAG_FILTER;
+ params = glParamTrace.FindLastMatch("TexParameteri", magFilter);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_EQUALS(iter->value.str(), LINEAR.str(), TEST_LOCATION);
+
+ TraceCallStack::NamedParams wrapS;
+ wrapS["pname"] << std::hex << GL_TEXTURE_WRAP_S;
+ params = glParamTrace.FindLastMatch("TexParameteri", wrapS);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_EQUALS(iter->value.str(), CLAMP_TO_EDGE.str(), TEST_LOCATION);
+
+ TraceCallStack::NamedParams wrapT;
+ wrapT["pname"] << std::hex << GL_TEXTURE_WRAP_T;
+ params = glParamTrace.FindLastMatch("TexParameteri", wrapT);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_EQUALS(iter->value.str(), CLAMP_TO_EDGE.str(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliGraphicsSamplerAllSet(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliSampler01 - check defaults");
+
+ Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
+ Actor actor = CreateRenderableActor(texture, "myVertShaderSource", "myFragShaderSource");
+ TextureSet textureSet = actor.GetRendererAt(0u).GetTextures();
+
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode(FilterMode::LINEAR_MIPMAP_NEAREST, FilterMode::NEAREST);
+ sampler.SetWrapMode(WrapMode::REPEAT, WrapMode::MIRRORED_REPEAT);
+ textureSet.SetSampler(0, sampler);
+
+ app.GetScene().Add(actor);
+
+ auto& gl = app.GetGlAbstraction();
+ auto& glParamTrace = gl.GetTexParameterTrace();
+ glParamTrace.Enable(true);
+ glParamTrace.EnableLogging(true);
+
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ TraceCallStack::NamedParams minFilter;
+ minFilter["pname"] << std::hex << GL_TEXTURE_MIN_FILTER;
+
+ auto params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
+ DALI_TEST_CHECK(params != nullptr);
+ auto iter = params->find("param");
+
+ DALI_TEST_CHECK(*iter == GL_LINEAR_MIPMAP_NEAREST);
+
+ TraceCallStack::NamedParams magFilter;
+ magFilter["pname"] << std::hex << GL_TEXTURE_MAG_FILTER;
+ params = glParamTrace.FindLastMatch("TexParameteri", magFilter);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_CHECK(*iter == GL_NEAREST);
+
+ TraceCallStack::NamedParams wrapS;
+ wrapS["pname"] << std::hex << GL_TEXTURE_WRAP_S;
+ params = glParamTrace.FindLastMatch("TexParameteri", wrapS);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_CHECK(*iter == GL_REPEAT);
+
+ TraceCallStack::NamedParams wrapT;
+ wrapT["pname"] << std::hex << GL_TEXTURE_WRAP_T;
+ params = glParamTrace.FindLastMatch("TexParameteri", wrapT);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_CHECK(*iter == GL_MIRRORED_REPEAT);
+
+ sampler.SetFilterMode(FilterMode::NEAREST_MIPMAP_LINEAR, FilterMode::LINEAR);
+ sampler.SetWrapMode(WrapMode::CLAMP_TO_EDGE, WrapMode::DEFAULT);
+
+ glParamTrace.Reset();
+ app.SendNotification();
+ app.Render(16); // The above actor will get rendered and drawn once.
+
+ params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
+ DALI_TEST_CHECK(params != nullptr);
+ iter = params->find("param");
+ DALI_TEST_CHECK(*iter == GL_NEAREST_MIPMAP_LINEAR);
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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/integration-api/testing.h>
+#include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
+#include <test-graphics-application.h>
+
+int UtcDaliGlesStripLegacyCodeIfNeededTest1(void)
+{
+ TestGraphicsApplication application;
+
+ {
+ Dali::Graphics::ShaderCreateInfo info;
+ info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
+ std::string vertexShader =
+ "//@version 100\n"
+ "some code\n";
+
+ info.SetShaderVersion(100);
+ info.SetSourceData(vertexShader.data());
+ info.SetSourceSize(vertexShader.size());
+ info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
+
+ size_t dataSize = 0;
+ size_t dataIndex = 0;
+ uint32_t version;
+ Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
+
+ DALI_TEST_EQUALS(dataIndex, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliGlesStripLegacyCodeTestDifferentPrefix(void)
+{
+ TestGraphicsApplication application;
+
+ std::string vertexShader =
+ "//@version 100\n"
+ "some code\n";
+
+ std::string somePrefix =
+ "This is some prefix\n";
+
+ auto newVertexPrefix = Dali::Integration::Test::GenerateTaggedShaderPrefix(somePrefix);
+ {
+ Dali::Graphics::ShaderCreateInfo info;
+ info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
+
+ std::string prefixedVertexShader = newVertexPrefix + vertexShader;
+
+ info.SetShaderVersion(100);
+ info.SetSourceData(prefixedVertexShader.data());
+ info.SetSourceSize(prefixedVertexShader.size());
+ info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
+
+ size_t dataSize = 0;
+ size_t dataIndex = 0;
+ uint32_t version;
+ Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
+
+ auto index = prefixedVertexShader.find("//@version");
+
+ DALI_TEST_EQUALS(dataIndex, index, TEST_LOCATION);
+
+ // should match original shader size
+ DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliGlesStripLegacyCodeIfNeededTest2(void)
+{
+ TestGraphicsApplication application;
+
+ std::string vertexShader =
+ "//@version 100\n"
+ "some code\n";
+
+ auto vertexPrefix = Dali::Shader::GetVertexShaderPrefix();
+
+ {
+ Dali::Graphics::ShaderCreateInfo info;
+ info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
+
+ std::string prefixedVertexShader = Dali::Shader::GetVertexShaderPrefix() + vertexShader;
+
+ info.SetShaderVersion(100);
+ info.SetSourceData(prefixedVertexShader.data());
+ info.SetSourceSize(prefixedVertexShader.size());
+ info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
+
+ size_t dataSize = 0;
+ size_t dataIndex = 0;
+ uint32_t version;
+ Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
+
+ DALI_TEST_EQUALS(dataIndex, vertexPrefix.length(), TEST_LOCATION);
+
+ // should match original shader size
+ DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliGlesLegacyCodeTest(void)
+{
+ TestGraphicsApplication application;
+
+ std::string vertexShader =
+ "#version 320 es\n"
+ "some code\n";
+
+ std::string somePrefix =
+ "This is some prefix\n";
+
+ auto newVertexPrefix = Dali::Integration::Test::GenerateTaggedShaderPrefix(somePrefix);
+ {
+ Dali::Graphics::ShaderCreateInfo info;
+ info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
+
+ std::string prefixedVertexShader = newVertexPrefix + vertexShader;
+
+ info.SetShaderVersion(0);
+ info.SetSourceData(prefixedVertexShader.data());
+ info.SetSourceSize(prefixedVertexShader.size());
+ info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
+
+ size_t dataSize = 0;
+ size_t dataIndex = 0;
+ uint32_t version;
+ Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
+
+ auto index = prefixedVertexShader.find("#version");
+
+ DALI_TEST_EQUALS(dataIndex, index, TEST_LOCATION);
+
+ // should match original shader size
+ DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
+ }
+
+ END_TEST;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ * 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/dali.h>
+
+#include <dali-test-suite-utils.h>
+#include <dali/internal/graphics/common/shader-parser.h>
+#include <fstream>
+
+#ifndef TEST_RESOURCE_DIR
+#define TEST_RESOURCE_DIR ""
+#endif
+
+using namespace Dali::Internal::ShaderParser;
+
+static std::string LoadTextFile(std::string filename)
+{
+ std::ifstream t(filename);
+ std::string str((std::istreambuf_iterator<char>(t)),
+ std::istreambuf_iterator<char>());
+ return str;
+}
+
+static bool CompareFileWithString(std::string file1, std::string stringToCompare)
+{
+ std::ifstream infile1(file1);
+
+ std::ostringstream sstr;
+ sstr << infile1.rdbuf();
+ auto s = sstr.str();
+
+ auto result = (s == stringToCompare);
+ if(!result)
+ {
+ tet_printf("%s\n", s.c_str());
+ tet_printf("---\n%s\n", stringToCompare.c_str());
+ }
+ return result;
+}
+
+int UtcParseGLES2Shader(void)
+{
+ tet_infoline("UtcParseGLES2Shader - Tests parser output for generating GLES2");
+
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL2; // We default to GLSL3
+ parseInfo.outputVersion = 0;
+
+ Parse(parseInfo, outStrings);
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles2", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.gles2", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcParseGLES2ShaderWithOutput(void)
+{
+ tet_infoline("UtcParseGLES2ShaderWithOutput - Tests parser output for generating GLES2");
+
+ // Load fragment shader with gl_FragColor
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL2; // We default to GLSL3
+ parseInfo.outputVersion = 0;
+ Parse(parseInfo, outStrings);
+
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles2", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles2", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcParseGLES3Shader(void)
+{
+ tet_infoline("UtcParseGLES3Shader - Tests parser output for generating GLES3");
+
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL3;
+ parseInfo.outputVersion = 0;
+ Parse(parseInfo, outStrings);
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.gles3", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcParseGLES3ShaderWithOutput(void)
+{
+ tet_infoline("UtcParseGLES3ShaderWithOutput - Tests parser output for generating GLES3 with OUTPUT in fragment shader");
+
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL3;
+ parseInfo.outputVersion = 0;
+ Parse(parseInfo, outStrings);
+
+ // save to compare
+
+ {
+ //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3");
+ //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles3");
+ //outv << outVertexShader;
+ //outf << outFragmentShader;
+ }
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles3", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcParseSPIRVShader(void)
+{
+ tet_infoline("UtcParseSPIRVShader - Tests parser output for generating GLES3");
+
+ // TODO: this test should fail in future after modifying sampler keywords!
+
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::SPIRV_GLSL;
+ parseInfo.outputVersion = 0;
+ Parse(parseInfo, outStrings);
+
+ // save to compare
+
+ {
+ //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv");
+ //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.glsl-spirv");
+ //outv << outVertexShader;
+ //outf << outFragmentShader;
+ }
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.glsl-spirv", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcParseSPIRVShaderWithOutput(void)
+{
+ tet_infoline("UtcParseSPIRVShaderWithOutput - Tests parser output for generating GLES3");
+
+ // TODO: this test should fail in future after modifying sampler keywords!
+
+ auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
+ auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
+
+ std::vector<std::string> outStrings;
+
+ Internal::ShaderParser::ShaderParserInfo parseInfo{};
+ parseInfo.vertexShaderCode = &vertexShader;
+ parseInfo.fragmentShaderCode = &fragmentShader;
+ parseInfo.vertexShaderLegacyVersion = 0;
+ parseInfo.fragmentShaderLegacyVersion = 0;
+ parseInfo.language = Internal::ShaderParser::OutputLanguage::SPIRV_GLSL;
+ parseInfo.outputVersion = 0;
+ Parse(parseInfo, outStrings);
+
+ // save to compare
+
+ {
+ //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv");
+ //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.glsl-spirv");
+ //outv << outVertexShader;
+ //outf << outFragmentShader;
+ }
+ auto& outVertexShader = outStrings[0];
+ auto& outFragmentShader = outStrings[1];
+
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv", outVertexShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ {
+ bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.glsl-spirv", outFragmentShader);
+ DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
+ }
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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
+{
+} // namespace
+
+void utc_dali_graphics_draw_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+void utc_dali_graphics_draw_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliTextureConvertUpload(void)
+{
+ TestGraphicsApplication app;
+ tet_infoline("UtcDaliGraphicsConvertUpload - Test that an RGB image is converted to RGBA after upload");
+
+ auto& gl = app.GetGlAbstraction();
+ gl.EnableTextureCallTrace(true);
+ gl.EnableTexParameterCallTrace(true);
+
+ int size = 200;
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, size, size);
+
+ int bufferSize = size * size * 3;
+ uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
+ PixelData pixelData = PixelData::New(buffer, bufferSize, size, size, Pixel::RGB888, PixelData::FREE);
+ texture.Upload(pixelData, 0u, 0u, 0u, 0u, size, size);
+
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode(FilterMode::LINEAR, FilterMode::LINEAR);
+
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture(0u, texture);
+ textureSet.SetSampler(0u, sampler);
+
+ Actor dummyActor = CreateRenderableActor2(textureSet, "", "");
+ app.GetScene().Add(dummyActor);
+
+ app.SendNotification();
+ app.Render(16);
+
+ // Check that TexImage2D was called with right format
+ auto& textureTrace = gl.GetTextureTrace();
+ auto& texParameterTrace = gl.GetTexParameterTrace();
+ TraceCallStack::NamedParams namedParams;
+ DALI_TEST_CHECK(textureTrace.FindMethodAndGetParameters("TexImage2D", namedParams));
+ std::stringstream s;
+ s << std::hex << GL_RGBA;
+
+ DALI_TEST_EQUALS(texParameterTrace.CountMethod("TexParameteri"), 4, TEST_LOCATION);
+ std::stringstream out;
+ out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
+ DALI_TEST_EQUALS(texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(namedParams["format"].str(), s.str(), TEST_LOCATION);
+ END_TEST;
+}
+++ /dev/null
-SET(PKG_NAME "dali-graphics")
-
-SET(EXEC_NAME "tct-${PKG_NAME}-core")
-SET(RPM_NAME "core-${PKG_NAME}-tests")
-
-SET(CAPI_LIB "dali-graphics")
-SET(TC_SOURCES
- utc-Dali-GraphicsBuffer.cpp
- utc-Dali-GraphicsDraw.cpp
- utc-Dali-GraphicsFramebuffer.cpp
- utc-Dali-GraphicsGeometry.cpp
- utc-Dali-GraphicsNativeImage.cpp
- utc-Dali-GraphicsProgram.cpp
- utc-Dali-GraphicsSampler.cpp
- utc-Dali-GraphicsShader.cpp
- utc-Dali-GraphicsShaderParser.cpp
- utc-Dali-GraphicsTexture.cpp
-)
-
-LIST(APPEND TC_SOURCES
- ../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp
- ../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp
- ../dali-adaptor/dali-test-suite-utils/test-harness.cpp
- ../dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
- ../dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp
- ../dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp
-
- ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-impl.cpp
- ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-object.cpp
-
- ../dali-adaptor/dali-test-suite-utils/test-native-image.cpp
- ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
- ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
- ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
- ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
- ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
- tct-dali-graphics-core.cpp
-)
-
-PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
- dali2-core
- dali2-adaptor
- glesv2
-)
-
-ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror )
-ADD_COMPILE_OPTIONS( ${${CAPI_LIB}_CFLAGS_OTHER} )
-
-ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
-
-FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
- SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
-ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
-
-INCLUDE_DIRECTORIES(
- ../../../
- ${${CAPI_LIB}_INCLUDE_DIRS}
- ../dali-adaptor/dali-test-suite-utils
-)
-
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
-TARGET_LINK_LIBRARIES(${EXEC_NAME}
- ${${CAPI_LIB}_LIBRARIES}
- --coverage
-)
-
-INSTALL(PROGRAMS ${EXEC_NAME}
- DESTINATION ${BIN_DIR}/${EXEC_NAME}
-)
+++ /dev/null
-#include <test-harness.h>
-
-#include "tct-dali-graphics-core.h"
-
-int main(int argc, char* const argv[])
-{
- return TestHarness::RunTests(argc, argv, tc_array);
-}
+++ /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
-{
-} // namespace
-
-int UtcDaliBufferReuseTest(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliBufferReuseTest: Tests whether GLES buffer can be reused (orphaning content)");
-
- auto& controller = app.GetGraphicsController();
-
- Graphics::BufferCreateInfo info;
- info.size = 1024;
- info.usage = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
- info.propertiesFlags = 0u;
-
- auto buffer = controller.CreateBuffer(info, nullptr);
- controller.WaitIdle();
-
- DALI_TEST_NOT_EQUALS((void*)buffer.get(), (void*)nullptr, 0, TEST_LOCATION);
-
- // New buffer with different spec, should create new object
- Graphics::BufferCreateInfo info2;
- info.size = 2024;
- info.usage = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
- info.propertiesFlags = 0u;
-
- auto buffer2 = controller.CreateBuffer(info2, std::move(buffer));
- controller.WaitIdle();
-
- DALI_TEST_NOT_EQUALS(buffer.get(), buffer2.get(), 0, TEST_LOCATION);
-
- auto ptr = buffer2.get(); // store pointer for testing, the uptr will be emptied
- // Create new buffer using the same spec
- auto buffer3 = controller.CreateBuffer(info2, std::move(buffer2));
- controller.WaitIdle();
-
- DALI_TEST_EQUALS(ptr, buffer3.get(), TEST_LOCATION);
-
- END_TEST;
-}
+++ /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;
-}
+++ /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
-{
-RenderTask CreateRenderTask(TestGraphicsApplication& application,
- FrameBuffer framebuffer)
-{
- Actor rootActor = Actor::New();
- application.GetScene().Add(rootActor);
- Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
- Actor sourceActor = CreateRenderableActor(img);
- application.GetScene().Add(sourceActor);
-
- CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT));
- application.GetScene().Add(offscreenCameraActor);
-
- // Change main render task to use a different root
- RenderTaskList taskList = application.GetScene().GetRenderTaskList();
- taskList.GetTask(0u).SetSourceActor(rootActor);
-
- RenderTask newTask = taskList.CreateTask();
- newTask.SetCameraActor(offscreenCameraActor);
- newTask.SetSourceActor(sourceActor);
- newTask.SetInputEnabled(false);
- newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
- newTask.SetClearEnabled(true);
- newTask.SetExclusive(true);
- newTask.SetFrameBuffer(framebuffer);
-
- return newTask;
-}
-} // namespace
-
-void utc_dali_graphics_framebuffer_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-void utc_dali_graphics_framebuffer_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliGraphicsFramebufferAttachDepth(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachDepth - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- END_TEST;
-}
-
-int UtcDaliGraphicsFramebufferAttachStencil(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachStencil - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- END_TEST;
-}
-
-int UtcDaliGraphicsFramebufferAttachDepthStencil(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachDepthStencil - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- END_TEST;
-}
-
-int UtcDaliGraphicsFramebufferAttachDepthTexture(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachDepthTexture - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- Texture dummyDepthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
- DevelFrameBuffer::AttachDepthTexture(framebuffer, dummyDepthTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- END_TEST;
-}
-
-int UtcDaliGraphicsFramebufferAttachDepthStencilTexture(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachDepthStencilTexture - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- {
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- Texture dummyDepthStencilTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
- DevelFrameBuffer::AttachDepthStencilTexture(framebuffer, dummyDepthStencilTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- UnparentAndReset(dummyActor);
- }
- // Ensure some cleanup happens!
- app.SendNotification();
- app.Render(16);
- app.SendNotification();
- app.Render(16);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsFramebufferAttachStencilAndDepthTexture(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsFramebufferAttachStencilAndDepthTexture - Test for GLES specific behavior");
-
- auto& gl = app.GetGlAbstraction();
-
- uint32_t width = 16u;
- uint32_t height = 24u;
-
- FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
-
- DALI_TEST_CHECK(framebuffer);
-
- Texture dummyColorTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
- // Note : Current GLES cannot seperate destination of depth result and stencil result. We need to make the texture as DEPTH_STENCIL
- Texture dummyDepthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
- Actor dummyActor = CreateRenderableActor(dummyColorTexture);
- framebuffer.AttachColorTexture(dummyColorTexture);
- DevelFrameBuffer::AttachDepthTexture(framebuffer, dummyDepthTexture);
-
- app.GetScene().Add(dummyActor);
-
- auto renderTask = CreateRenderTask(app, framebuffer);
-
- DALI_TEST_CHECK(renderTask);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- DALI_TEST_EQUALS(gl.CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachmentCount(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
- DALI_TEST_EQUALS(gl.CheckFramebufferDepthStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION); // Check whether renderbuffer attached by DEPTH_STENCIL.
-
- END_TEST;
-}
+++ /dev/null
-#include <dali-test-suite-utils.h>
-
-#include <dali/graphics-api/graphics-controller.h>
-#include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
-#include <test-graphics-application.h>
-//#include <dali/graphics-api/graphics-api-buffer.h>
-
-int UtcDaliGraphicsCreateGeometry(void)
-{
- // Initialize actual egl graphics controller (without initializing egl!)
- TestGraphicsApplication app;
-
- struct Vertex
- {
- float x;
- float y;
- };
-
- std::vector<Vertex> someData(100);
- Graphics::Controller& graphicsController = app.GetGraphicsController();
-
- Graphics::BufferCreateInfo createInfo;
- createInfo
- .SetUsage(0 | Graphics::BufferUsage::VERTEX_BUFFER)
- .SetSize(someData.size());
-
- auto buffer = graphicsController.CreateBuffer(createInfo, nullptr);
- Graphics::MapBufferInfo info;
- info.buffer = buffer.get();
- info.usage = 0 | Graphics::MemoryUsageFlagBits::WRITE;
- info.offset = 0;
- info.size = someData.size();
-
- auto memory = graphicsController.MapBufferRange(info);
- void* ptr = memory->LockRegion(0, someData.size());
- DALI_TEST_CHECK(ptr != nullptr);
- memory->Unlock(true);
- graphicsController.UnmapMemory(std::move(memory));
-
- // Test that data has been uploaded to GL, e.g. test that GPU buffer has been created
- auto& gl = app.GetGlAbstraction();
- auto& bufferDataCalls = gl.GetBufferDataCalls();
- DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
- DALI_TEST_EQUALS(bufferDataCalls[0], someData.size(), TEST_LOCATION);
- DALI_TEST_CHECK(1);
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2021 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-native-image.h>
-
-using namespace Dali;
-
-void utc_dali_native_image_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-void utc_dali_native_image_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliGraphicsNativeImage(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliNativeImageTexture01");
-
- TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
- TraceCallStack& callStack = imageInterface->mCallStack;
- callStack.EnableLogging(true);
- callStack.Enable(true);
-
- auto& gl = app.GetGlAbstraction();
- auto& textureCallStack = gl.GetTextureTrace();
- textureCallStack.EnableLogging(true);
- textureCallStack.Enable(true);
-
- {
- Texture texture = Texture::New(*(imageInterface.Get()));
- Actor actor = CreateRenderableActor(texture, "", "");
- app.GetScene().Add(actor);
-
- app.SendNotification();
- app.Render(16);
-
- DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
- DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION);
-
- DALI_TEST_EQUALS(callStack.FindMethod("PrepareTexture"), true, TEST_LOCATION);
- TraceCallStack::NamedParams params;
- params["target"] << std::hex << GL_TEXTURE_EXTERNAL_OES;
- DALI_TEST_EQUALS(textureCallStack.FindMethodAndParams("BindTexture", params), 1u, TEST_LOCATION);
- Dali::UnparentAndReset(actor);
- }
-
- app.SendNotification();
- app.Render(16); // Puts texture on discard queue.
-
- app.SendNotification();
- app.Render(16);
-
- // Flush the queues
- Graphics::SubmitInfo submitInfo{{}, 0 | Graphics::SubmitFlagBits::FLUSH};
- app.GetGraphicsController().SubmitCommandBuffers(submitInfo);
-
- DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
-
- END_TEST;
-}
+++ /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-sampler.h>
-
-using namespace Dali;
-
-void utc_dali_program_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-void utc_dali_program_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-const std::string VERT_SHADER_SOURCE = "myVertShaderSource";
-
-const std::string VERT_SHADER_SOURCE2 =
- "\n"
- "in vec3 aPosition;\n"
- "in vec3 aTexCoord;\n"
- "out vec2 vTexCoord;\n"
- "main()\n"
- "{\n"
- " gl_Position=aPosition;\n"
- " vTexCoord = aTexCoord;\n"
- "}\n";
-
-const std::string FRAG_SHADER_SOURCE =
- "\n"
- "uniform sampler2D sAlbedo;\n"
- "uniform sampler2D sMetalRoughness;\n"
- "uniform sampler2D sNormals;\n"
- "uniform sampler2D sAmbientOcclusion;\n"
- "uniform mediump vec3 lightDirection;\n"
- "in mediump vec2 vTexCoord;\n"
- "main()\n"
- "{\n"
- " gl_fragColor = texture2d(sAlbedo, vTexCoord) + lightDirection*texture2d(sNormals, vTexCoord);\n"
- "}\n";
-
-const std::string FRAG_SHADER_SOURCE2 =
- "\n"
- "uniform sampler2D sTextures[4];\n"
- "uniform mediump vec3 lightDirection;\n"
- "in mediump vec2 vTexCoord;\n"
- "main()\n"
- "{\n"
- " gl_fragColor = texture2d(sTextures[0], vTexCoord) + lightDirection*texture2d(sTextures[2], vTexCoord);\n"
- "}\n";
-
-} //anonymous namespace
-
-int UtcDaliGraphicsProgram01(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliProgram - check that right sampler uniforms are bound for textures");
-
- Texture normals = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture metalroughness = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture ao = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture albedo = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
-
- TextureSet textureSet = TextureSet::New();
- textureSet.SetTexture(0, albedo);
- textureSet.SetTexture(1, metalroughness);
- textureSet.SetTexture(2, normals);
- textureSet.SetTexture(3, ao);
-
- Actor actor = CreateRenderableActor2(textureSet, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
- app.GetScene().Add(actor);
-
- auto& gl = app.GetGlAbstraction();
- auto& glUniformTrace = gl.GetSetUniformTrace();
- glUniformTrace.Enable(true);
- glUniformTrace.EnableLogging(true);
-
- std::vector<ActiveUniform> activeUniforms{
- {"sAlbedo", GL_SAMPLER_2D, 1},
- {"sAmbientOcclusion", GL_SAMPLER_2D, 1},
- {"sNormals", GL_SAMPLER_2D, 1},
- {"sMetalRoughness", GL_SAMPLER_2D, 1}};
- gl.SetActiveUniforms(activeUniforms);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- // Check what uniform values were set:
- int value;
- DALI_TEST_CHECK(gl.GetUniformValue("sAlbedo", value)); // First in frag shader
- DALI_TEST_EQUALS(value, 0, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sAmbientOcclusion", value)); // 4th
- DALI_TEST_EQUALS(value, 3, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sNormals", value)); // 3rd
- DALI_TEST_EQUALS(value, 2, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sMetalRoughness", value)); // 2nd
- DALI_TEST_EQUALS(value, 1, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsProgram02(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliProgram - check that sampler arrays are handled and bound to textures");
-
- Texture normals = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture metalroughness = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture ao = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Texture albedo = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
-
- TextureSet textureSet = TextureSet::New();
- textureSet.SetTexture(0, albedo);
- textureSet.SetTexture(1, metalroughness);
- textureSet.SetTexture(2, normals);
- textureSet.SetTexture(3, ao);
-
- Actor actor = CreateRenderableActor2(textureSet, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
- app.GetScene().Add(actor);
-
- auto& gl = app.GetGlAbstraction();
- auto& glUniformTrace = gl.GetSetUniformTrace();
- glUniformTrace.Enable(true);
- glUniformTrace.EnableLogging(true);
- gl.GetShaderTrace().Enable(true);
- gl.GetShaderTrace().EnableLogging(true);
-
- std::vector<ActiveUniform> activeUniforms{
- {"uLightDir", GL_FLOAT_VEC4, 1},
- {"sTextures[0]", GL_SAMPLER_2D, 4}}; // Array of 4 samplers
- gl.SetActiveUniforms(activeUniforms);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- // Check what uniform values were set:
- int value;
- DALI_TEST_CHECK(gl.GetUniformValue("sTextures[0]", value)); // First in frag shader
- DALI_TEST_EQUALS(value, 0, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sTextures[3]", value)); // 4th
- DALI_TEST_EQUALS(value, 3, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sTextures[2]", value)); // 3rd
- DALI_TEST_EQUALS(value, 2, TEST_LOCATION);
- DALI_TEST_CHECK(gl.GetUniformValue("sTextures[1]", value)); // 2nd
- DALI_TEST_EQUALS(value, 1, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsShaderNew(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliProgram - check that multiple shaders from same source only create 1 program");
-
- Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
-
- // Creates 3 Dali::Shaders
- Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
- Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
- Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
-
- app.GetScene().Add(actor1);
- app.GetScene().Add(actor2);
- app.GetScene().Add(actor3);
-
- auto& gl = app.GetGlAbstraction();
- auto& glShaderTrace = gl.GetShaderTrace();
- glShaderTrace.Enable(true);
- glShaderTrace.EnableLogging(true);
-
- app.SendNotification();
- app.Render(16); // The above actors will get rendered and drawn once, only 1 program and 2 shaders should be created
-
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 1, TEST_LOCATION);
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 2, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsShaderNew02(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliProgram - check that mixed up multiple shaders from same source don't create dups");
-
- Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
-
- // Creates 3 Dali::Shaders
- Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
- Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE2);
- Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
- Actor actor4 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE);
-
- app.GetScene().Add(actor1);
- app.GetScene().Add(actor2);
- app.GetScene().Add(actor3);
- app.GetScene().Add(actor4);
-
- auto& gl = app.GetGlAbstraction();
- auto& glShaderTrace = gl.GetShaderTrace();
- glShaderTrace.Enable(true);
- glShaderTrace.EnableLogging(true);
-
- app.SendNotification();
- app.Render(16); // The above actors will get rendered and drawn once, only 4 programs and 4 shaders should be created
-
- // Should only be 4 shaders, not 8.
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 4, TEST_LOCATION);
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 4, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsShaderFlush(void)
-{
- // Note : This UTC will not works well since now GLES::ProgramImpl hold the reference of shader,
- // and we don't have any way to remove GLES::ProgramImpl by normal way.
- // Just block this UTC until the policy was fixed up.
-#if 0
- TestGraphicsApplication app;
- tet_infoline("UtcDaliProgram - check that unused shaders are flushed");
-
- Texture diffuse = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- auto& gl = app.GetGlAbstraction();
- auto& glShaderTrace = gl.GetShaderTrace();
- glShaderTrace.Enable(true);
- glShaderTrace.EnableLogging(true);
-
- {
- // Creates 4 Dali::Shaders
- Actor actor1 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE);
- Actor actor2 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE2);
- Actor actor3 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE, FRAG_SHADER_SOURCE2);
- Actor actor4 = CreateRenderableActor(diffuse, VERT_SHADER_SOURCE2, FRAG_SHADER_SOURCE);
-
- app.GetScene().Add(actor1);
- app.GetScene().Add(actor2);
- app.GetScene().Add(actor3);
- app.GetScene().Add(actor4);
-
- app.SendNotification();
- app.Render(16); // The above actors will get rendered and drawn once
-
- // Should only be 4 shaders, not 8.
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateProgram"), 4, TEST_LOCATION);
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("CreateShader"), 4, TEST_LOCATION);
-
- UnparentAndReset(actor1);
- UnparentAndReset(actor2);
- UnparentAndReset(actor3);
- UnparentAndReset(actor4);
- }
-
- for(int i = 0; i < 1199; ++i) // 3 flushes per frame
- {
- app.SendNotification();
- app.Render(16);
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("DeleteShader"), 0, TEST_LOCATION);
- }
-
- app.SendNotification();
- app.Render(16);
- DALI_TEST_EQUALS(glShaderTrace.CountMethod("DeleteShader"), 4, TEST_LOCATION);
-#else
- DALI_TEST_CHECK(true);
-#endif
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2021 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-sampler.h>
-
-using namespace Dali;
-
-void utc_dali_sampler_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-void utc_dali_sampler_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliGraphicsSamplerDefault(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliSampler01 - check defaults");
-
- Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Actor actor = CreateRenderableActor(texture, "myVertShaderSource", "myFragShaderSource");
- app.GetScene().Add(actor);
-
- auto& gl = app.GetGlAbstraction();
- auto& glParamTrace = gl.GetTexParameterTrace();
- glParamTrace.Enable(true);
- glParamTrace.EnableLogging(true);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- TraceCallStack::NamedParams minFilter;
- minFilter["pname"] << std::hex << GL_TEXTURE_MIN_FILTER;
- std::ostringstream LINEAR;
- LINEAR << GL_LINEAR;
- std::ostringstream CLAMP_TO_EDGE;
- CLAMP_TO_EDGE << GL_CLAMP_TO_EDGE;
-
- auto params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
- DALI_TEST_CHECK(params != nullptr);
- auto iter = params->find("param");
- DALI_TEST_EQUALS(iter->value.str(), LINEAR.str(), TEST_LOCATION);
-
- TraceCallStack::NamedParams magFilter;
- magFilter["pname"] << std::hex << GL_TEXTURE_MAG_FILTER;
- params = glParamTrace.FindLastMatch("TexParameteri", magFilter);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_EQUALS(iter->value.str(), LINEAR.str(), TEST_LOCATION);
-
- TraceCallStack::NamedParams wrapS;
- wrapS["pname"] << std::hex << GL_TEXTURE_WRAP_S;
- params = glParamTrace.FindLastMatch("TexParameteri", wrapS);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_EQUALS(iter->value.str(), CLAMP_TO_EDGE.str(), TEST_LOCATION);
-
- TraceCallStack::NamedParams wrapT;
- wrapT["pname"] << std::hex << GL_TEXTURE_WRAP_T;
- params = glParamTrace.FindLastMatch("TexParameteri", wrapT);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_EQUALS(iter->value.str(), CLAMP_TO_EDGE.str(), TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliGraphicsSamplerAllSet(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliSampler01 - check defaults");
-
- Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
- Actor actor = CreateRenderableActor(texture, "myVertShaderSource", "myFragShaderSource");
- TextureSet textureSet = actor.GetRendererAt(0u).GetTextures();
-
- Sampler sampler = Sampler::New();
- sampler.SetFilterMode(FilterMode::LINEAR_MIPMAP_NEAREST, FilterMode::NEAREST);
- sampler.SetWrapMode(WrapMode::REPEAT, WrapMode::MIRRORED_REPEAT);
- textureSet.SetSampler(0, sampler);
-
- app.GetScene().Add(actor);
-
- auto& gl = app.GetGlAbstraction();
- auto& glParamTrace = gl.GetTexParameterTrace();
- glParamTrace.Enable(true);
- glParamTrace.EnableLogging(true);
-
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- TraceCallStack::NamedParams minFilter;
- minFilter["pname"] << std::hex << GL_TEXTURE_MIN_FILTER;
-
- auto params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
- DALI_TEST_CHECK(params != nullptr);
- auto iter = params->find("param");
-
- DALI_TEST_CHECK(*iter == GL_LINEAR_MIPMAP_NEAREST);
-
- TraceCallStack::NamedParams magFilter;
- magFilter["pname"] << std::hex << GL_TEXTURE_MAG_FILTER;
- params = glParamTrace.FindLastMatch("TexParameteri", magFilter);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_CHECK(*iter == GL_NEAREST);
-
- TraceCallStack::NamedParams wrapS;
- wrapS["pname"] << std::hex << GL_TEXTURE_WRAP_S;
- params = glParamTrace.FindLastMatch("TexParameteri", wrapS);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_CHECK(*iter == GL_REPEAT);
-
- TraceCallStack::NamedParams wrapT;
- wrapT["pname"] << std::hex << GL_TEXTURE_WRAP_T;
- params = glParamTrace.FindLastMatch("TexParameteri", wrapT);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_CHECK(*iter == GL_MIRRORED_REPEAT);
-
- sampler.SetFilterMode(FilterMode::NEAREST_MIPMAP_LINEAR, FilterMode::LINEAR);
- sampler.SetWrapMode(WrapMode::CLAMP_TO_EDGE, WrapMode::DEFAULT);
-
- glParamTrace.Reset();
- app.SendNotification();
- app.Render(16); // The above actor will get rendered and drawn once.
-
- params = glParamTrace.FindLastMatch("TexParameteri", minFilter);
- DALI_TEST_CHECK(params != nullptr);
- iter = params->find("param");
- DALI_TEST_CHECK(*iter == GL_NEAREST_MIPMAP_LINEAR);
-
- END_TEST;
-}
+++ /dev/null
-/*
-* 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.
-* 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/integration-api/testing.h>
-#include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
-#include <test-graphics-application.h>
-
-int UtcDaliGlesStripLegacyCodeIfNeededTest1(void)
-{
- TestGraphicsApplication application;
-
- {
- Dali::Graphics::ShaderCreateInfo info;
- info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
- std::string vertexShader =
- "//@version 100\n"
- "some code\n";
-
- info.SetShaderVersion(100);
- info.SetSourceData(vertexShader.data());
- info.SetSourceSize(vertexShader.size());
- info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
-
- size_t dataSize = 0;
- size_t dataIndex = 0;
- uint32_t version;
- Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
-
- DALI_TEST_EQUALS(dataIndex, 0, TEST_LOCATION);
- DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
- }
-
- END_TEST;
-}
-
-int UtcDaliGlesStripLegacyCodeTestDifferentPrefix(void)
-{
- TestGraphicsApplication application;
-
- std::string vertexShader =
- "//@version 100\n"
- "some code\n";
-
- std::string somePrefix =
- "This is some prefix\n";
-
- auto newVertexPrefix = Dali::Integration::Test::GenerateTaggedShaderPrefix(somePrefix);
- {
- Dali::Graphics::ShaderCreateInfo info;
- info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
-
- std::string prefixedVertexShader = newVertexPrefix + vertexShader;
-
- info.SetShaderVersion(100);
- info.SetSourceData(prefixedVertexShader.data());
- info.SetSourceSize(prefixedVertexShader.size());
- info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
-
- size_t dataSize = 0;
- size_t dataIndex = 0;
- uint32_t version;
- Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
-
- auto index = prefixedVertexShader.find("//@version");
-
- DALI_TEST_EQUALS(dataIndex, index, TEST_LOCATION);
-
- // should match original shader size
- DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
- }
-
- END_TEST;
-}
-
-int UtcDaliGlesStripLegacyCodeIfNeededTest2(void)
-{
- TestGraphicsApplication application;
-
- std::string vertexShader =
- "//@version 100\n"
- "some code\n";
-
- auto vertexPrefix = Dali::Shader::GetVertexShaderPrefix();
-
- {
- Dali::Graphics::ShaderCreateInfo info;
- info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
-
- std::string prefixedVertexShader = Dali::Shader::GetVertexShaderPrefix() + vertexShader;
-
- info.SetShaderVersion(100);
- info.SetSourceData(prefixedVertexShader.data());
- info.SetSourceSize(prefixedVertexShader.size());
- info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
-
- size_t dataSize = 0;
- size_t dataIndex = 0;
- uint32_t version;
- Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
-
- DALI_TEST_EQUALS(dataIndex, vertexPrefix.length(), TEST_LOCATION);
-
- // should match original shader size
- DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
- }
-
- END_TEST;
-}
-
-int UtcDaliGlesLegacyCodeTest(void)
-{
- TestGraphicsApplication application;
-
- std::string vertexShader =
- "#version 320 es\n"
- "some code\n";
-
- std::string somePrefix =
- "This is some prefix\n";
-
- auto newVertexPrefix = Dali::Integration::Test::GenerateTaggedShaderPrefix(somePrefix);
- {
- Dali::Graphics::ShaderCreateInfo info;
- info.SetPipelineStage(Dali::Graphics::PipelineStage::VERTEX_SHADER);
-
- std::string prefixedVertexShader = newVertexPrefix + vertexShader;
-
- info.SetShaderVersion(0);
- info.SetSourceData(prefixedVertexShader.data());
- info.SetSourceSize(prefixedVertexShader.size());
- info.SetSourceMode(Dali::Graphics::ShaderSourceMode::TEXT);
-
- size_t dataSize = 0;
- size_t dataIndex = 0;
- uint32_t version;
- Graphics::GLES::ShaderImpl::StripLegacyCodeIfNeeded(info, dataIndex, version, dataSize);
-
- auto index = prefixedVertexShader.find("#version");
-
- DALI_TEST_EQUALS(dataIndex, index, TEST_LOCATION);
-
- // should match original shader size
- DALI_TEST_EQUALS(dataSize, vertexShader.size(), TEST_LOCATION);
- }
-
- END_TEST;
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.
- * 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/dali.h>
-
-#include <dali-test-suite-utils.h>
-#include <dali/internal/graphics/common/shader-parser.h>
-#include <fstream>
-
-#ifndef TEST_RESOURCE_DIR
-#define TEST_RESOURCE_DIR ""
-#endif
-
-using namespace Dali::Internal::ShaderParser;
-
-static std::string LoadTextFile(std::string filename)
-{
- std::ifstream t(filename);
- std::string str((std::istreambuf_iterator<char>(t)),
- std::istreambuf_iterator<char>());
- return str;
-}
-
-static bool CompareFileWithString(std::string file1, std::string stringToCompare)
-{
- std::ifstream infile1(file1);
-
- std::ostringstream sstr;
- sstr << infile1.rdbuf();
- auto s = sstr.str();
-
- auto result = (s == stringToCompare);
- if(!result)
- {
- tet_printf("%s\n", s.c_str());
- tet_printf("---\n%s\n", stringToCompare.c_str());
- }
- return result;
-}
-
-int UtcParseGLES2Shader(void)
-{
- tet_infoline("UtcParseGLES2Shader - Tests parser output for generating GLES2");
-
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL2; // We default to GLSL3
- parseInfo.outputVersion = 0;
-
- Parse(parseInfo, outStrings);
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles2", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.gles2", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcParseGLES2ShaderWithOutput(void)
-{
- tet_infoline("UtcParseGLES2ShaderWithOutput - Tests parser output for generating GLES2");
-
- // Load fragment shader with gl_FragColor
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL2; // We default to GLSL3
- parseInfo.outputVersion = 0;
- Parse(parseInfo, outStrings);
-
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
-
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles2", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles2", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcParseGLES3Shader(void)
-{
- tet_infoline("UtcParseGLES3Shader - Tests parser output for generating GLES3");
-
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL3;
- parseInfo.outputVersion = 0;
- Parse(parseInfo, outStrings);
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
-
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.gles3", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcParseGLES3ShaderWithOutput(void)
-{
- tet_infoline("UtcParseGLES3ShaderWithOutput - Tests parser output for generating GLES3 with OUTPUT in fragment shader");
-
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::GLSL3;
- parseInfo.outputVersion = 0;
- Parse(parseInfo, outStrings);
-
- // save to compare
-
- {
- //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3");
- //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles3");
- //outv << outVertexShader;
- //outf << outFragmentShader;
- }
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
-
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.gles3", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.gles3", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcParseSPIRVShader(void)
-{
- tet_infoline("UtcParseSPIRVShader - Tests parser output for generating GLES3");
-
- // TODO: this test should fail in future after modifying sampler keywords!
-
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::SPIRV_GLSL;
- parseInfo.outputVersion = 0;
- Parse(parseInfo, outStrings);
-
- // save to compare
-
- {
- //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv");
- //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.glsl-spirv");
- //outv << outVertexShader;
- //outf << outFragmentShader;
- }
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
-
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.frag.glsl-spirv", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcParseSPIRVShaderWithOutput(void)
-{
- tet_infoline("UtcParseSPIRVShaderWithOutput - Tests parser output for generating GLES3");
-
- // TODO: this test should fail in future after modifying sampler keywords!
-
- auto vertexShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view.vert");
- auto fragmentShader = LoadTextFile(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag");
-
- std::vector<std::string> outStrings;
-
- Internal::ShaderParser::ShaderParserInfo parseInfo{};
- parseInfo.vertexShaderCode = &vertexShader;
- parseInfo.fragmentShaderCode = &fragmentShader;
- parseInfo.vertexShaderLegacyVersion = 0;
- parseInfo.fragmentShaderLegacyVersion = 0;
- parseInfo.language = Internal::ShaderParser::OutputLanguage::SPIRV_GLSL;
- parseInfo.outputVersion = 0;
- Parse(parseInfo, outStrings);
-
- // save to compare
-
- {
- //std::ofstream outv(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv");
- //std::ofstream outf(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.glsl-spirv");
- //outv << outVertexShader;
- //outf << outFragmentShader;
- }
- auto& outVertexShader = outStrings[0];
- auto& outFragmentShader = outStrings[1];
-
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view.vert.glsl-spirv", outVertexShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- {
- bool cmp = CompareFileWithString(TEST_RESOURCE_DIR "/shaders/canvas-view-with-output.frag.glsl-spirv", outFragmentShader);
- DALI_TEST_EQUALS(cmp, true, TEST_LOCATION);
- }
- END_TEST;
-}
+++ /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
-{
-} // namespace
-
-void utc_dali_graphics_draw_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-void utc_dali_graphics_draw_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliTextureConvertUpload(void)
-{
- TestGraphicsApplication app;
- tet_infoline("UtcDaliGraphicsConvertUpload - Test that an RGB image is converted to RGBA after upload");
-
- auto& gl = app.GetGlAbstraction();
- gl.EnableTextureCallTrace(true);
- gl.EnableTexParameterCallTrace(true);
-
- int size = 200;
- Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, size, size);
-
- int bufferSize = size * size * 3;
- uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
- PixelData pixelData = PixelData::New(buffer, bufferSize, size, size, Pixel::RGB888, PixelData::FREE);
- texture.Upload(pixelData, 0u, 0u, 0u, 0u, size, size);
-
- Sampler sampler = Sampler::New();
- sampler.SetFilterMode(FilterMode::LINEAR, FilterMode::LINEAR);
-
- TextureSet textureSet = TextureSet::New();
- textureSet.SetTexture(0u, texture);
- textureSet.SetSampler(0u, sampler);
-
- Actor dummyActor = CreateRenderableActor2(textureSet, "", "");
- app.GetScene().Add(dummyActor);
-
- app.SendNotification();
- app.Render(16);
-
- // Check that TexImage2D was called with right format
- auto& textureTrace = gl.GetTextureTrace();
- auto& texParameterTrace = gl.GetTexParameterTrace();
- TraceCallStack::NamedParams namedParams;
- DALI_TEST_CHECK(textureTrace.FindMethodAndGetParameters("TexImage2D", namedParams));
- std::stringstream s;
- s << std::hex << GL_RGBA;
-
- DALI_TEST_EQUALS(texParameterTrace.CountMethod("TexParameteri"), 4, TEST_LOCATION);
- std::stringstream out;
- out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
- DALI_TEST_EQUALS(texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
-
- DALI_TEST_EQUALS(namedParams["format"].str(), s.str(), TEST_LOCATION);
- END_TEST;
-}
utc-image-fitting-modes.cpp
)
+SET(TC_SOURCE_LIST ${TC_SOURCES} CACHE STRING "List of test sources")
+
LIST(APPEND TC_SOURCES
../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp
../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp
OPTION(ENABLE_APPMODEL "Enable AppModel" OFF)
OPTION(ENABLE_TRACE "Enable Trace" OFF)
OPTION(ENABLE_TRACE_STREAMLINE "Enable Trace (Streamline)" OFF)
+OPTION(CONFIGURE_AUTOMATED_TESTS "Configure automated tests" ON)
# Include additional macros
INCLUDE( common.cmake )
ADD_SUBDIRECTORY( application-model )
ENDIF()
-CLEAN_ARG_CACHE()
+#CLEAN_ARG_CACHE()
ARG_ENABLE( ENABLE_ECORE_WAYLAND2 enable_ecore_wayland2 "${ENABLE_VAL}" "Build on Ecore Wayland2" )
ARG_ENABLE( ENABLE_RENAME_SO enable_rename_so "${ENABLE_VAL};1" "Specify whether so file is renamed or not" )
ARG_ENABLE( ENABLE_COVERAGE enable_coverage "${ENABLE_VAL}" "Enables coverage" )
-ARG_ENABLE( ENABLE_VULKAN enable_vulkan 1 "Enables Vulkan build")
+
+ARG_ENABLE( ENABLE_VULKAN enable_vulkan "${ENABLE_VAL}" "Enables Vulkan build")
# help option
ARG_ENABLE( PRINT_HELP print_help "${ENABLE_VAL}" "Prints help" )
EXIT()
ENDIF()
+IF( CONFIGURE_AUTOMATED_TESTS )
+ # Configure automated tests
+ CONFIGURE_FILE( ${ROOT_SRC_DIR}/automated-tests/CMakeLists.txt.in
+ ${ROOT_SRC_DIR}/automated-tests/CMakeLists.txt @ONLY )
+ENDIF()
+
+
IF( NOT enable_profile )
IF( ANDROID )
SET( enable_profile ANDROID )