Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXSWHTEC-224 - Test cases ID clean up and documentation for GL Interop #94

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cea96af
SWDEV-355313 - Move catch tests and samples
gargrahul Oct 26, 2022
909e7e4
SWDEV-355313 - Add README
gargrahul Nov 7, 2022
094b9af
SWDEV-355313 - Update amd-staging branch
gargrahul Nov 28, 2022
070bb7c
EXSWHTEC-174 - Add Doxygen configuration and common header with group…
milos-mozetic Dec 1, 2022
9daa6d0
SWDEV-355313 - Update README
gargrahul Dec 2, 2022
2a205ed
EXSWHTEC-200 - Add support for TEMPLATE_TEST_CASE preprocessing
milos-mozetic Dec 5, 2022
c49043e
SWDEV-355313 - Update latest code
gargrahul Dec 6, 2022
e5e8077
EXSWHTEC-134 - Implement tests for hipGLGetDevices
mirza-halilcevic Dec 9, 2022
3e1eea8
EXSWHTEC-135 - Implement tests for hipGraphicsGLRegisterBuffer
mirza-halilcevic Dec 9, 2022
183d098
EXSWHTEC-136 - Implement tests for hipGraphicsGLRegisterImage
mirza-halilcevic Dec 9, 2022
93c1436
EXSWHTEC-137 - Implement tests for hipGraphicsMapResources
mirza-halilcevic Dec 9, 2022
e20720f
EXSWHTEC-138 - Implement tests for hipGraphicsSubResourceGetMappedArray
mirza-halilcevic Dec 9, 2022
844ac1d
EXSWHTEC-139 - Implement tests for hipGraphicsResourceGetMappedPointer
mirza-halilcevic Dec 9, 2022
34a2d2f
EXSWHTEC-140 - Implement tests for hipGraphicsUnmapResources
mirza-halilcevic Dec 9, 2022
daa6cc0
EXSWHTEC-141 - Implement tests for hipGraphicsUnregisterResource
mirza-halilcevic Dec 9, 2022
afcd051
Merge branch 'develop' into hipGraphicsUnregisterResource_tests
gargrahul Dec 13, 2022
2db594f
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Dec 13, 2022
1977515
EXSWHTEC-200 - Resolve conflicts in missed conflicted files
milos-mozetic Dec 13, 2022
259be27
EXSWHTEC-200 - Add newline at the end of the file
milos-mozetic Dec 14, 2022
e0daf30
EXSWHTEC-200 - Extend the PREDEFINED list to define all macro names t…
milos-mozetic Dec 14, 2022
adb35ed
Merge remote-tracking branch 'upstream/develop' into hipGLGetDevices_…
mirza-halilcevic Dec 18, 2022
86af1b2
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
ad54b12
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
b281f78
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
52c3765
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
41270ce
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
4d0ff8a
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
6a3c580
Merge remote-tracking branch 'origin/hipGLGetDevices_tests' into hipG…
mirza-halilcevic Dec 18, 2022
2247586
Merge branch 'hipGLGetDevices_tests' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 20, 2022
1604544
Merge branch 'hipGraphicsGLRegisterBuffer_tests' of github.com:mirza-…
milos-mozetic Dec 20, 2022
2142f4d
Merge branch 'hipGraphicsGLRegisterImage_tests' of github.com:mirza-h…
milos-mozetic Dec 20, 2022
9b0dfbf
Merge branch 'hipGraphicsMapResources_tests' of github.com:mirza-hali…
milos-mozetic Dec 20, 2022
a408dbf
Merge branch 'hipGraphicsSubResourceGetMappedArray_tests' of github.c…
milos-mozetic Dec 20, 2022
d61a3b0
Merge branch 'hipGraphicsResourceGetMappedPointer_tests' of github.co…
milos-mozetic Dec 20, 2022
ca9f481
Merge branch 'hipGraphicsUnmapResources_tests' of github.com:mirza-ha…
milos-mozetic Dec 20, 2022
fb33e10
Merge branch 'hipGraphicsUnregisterResource_tests' of github.com:mirz…
milos-mozetic Dec 20, 2022
cc0d5af
EXSWHTEC-224 - Test cases ID clean up and documentation for GL Interop
milos-mozetic Dec 20, 2022
dd0088c
Merge branch 'develop' into doxygen_interop_documentation
milos-mozetic Jun 22, 2023
8c60738
Merge branch 'develop' into doxygen_interop_documentation
rakesroy Jul 25, 2023
1fa6e73
Update config_amd_linux_common.json
rakesroy Jul 28, 2023
22c9d08
Merge branch 'develop' into doxygen_interop_documentation
rakesroy Jul 28, 2023
8232a8e
Merge remote-tracking branch 'upstream/develop' into doxygen_interop_…
mirza-halilcevic Feb 18, 2024
040dad1
Merge branch 'develop' into doxygen_interop_documentation
mirza-halilcevic Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,540 changes: 2,540 additions & 0 deletions catch/DoxyfileTests

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions catch/include/hip_test_defgroups.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

// Test groups are named based on the group names from hip_api_runtime.h, with adding "Test" suffix

/**
* @defgroup CallbackTest Callback Activity APIs
* @{
* This section describes tests for the callback/Activity of HIP runtime API.
* @}
*/

/**
* @defgroup GraphTest Graph Management
* @{
* This section describes the graph management types & functions of HIP runtime API.
* @}
*/

/**
* @defgroup GLTest Interop
* @{
* This section describes tests for the GL interop functions of HIP runtime API.
* @}
*/
5 changes: 3 additions & 2 deletions catch/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ add_subdirectory(multiThread)
add_subdirectory(compiler)
add_subdirectory(errorHandling)
add_subdirectory(cooperativeGrps)
#if(HIP_PLATFORM STREQUAL "amd")
if(HIP_PLATFORM STREQUAL "amd")
#add_subdirectory(clock)
#endif()
add_subdirectory(gl_interop) # Disabled on NVIDIA due to defect - EXSWHTEC-246
endif()
19 changes: 19 additions & 0 deletions catch/unit/gl_interop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(TEST_SRC
hipGLGetDevices.cc
hipGraphicsGLRegisterBuffer.cc
hipGraphicsGLRegisterImage.cc
hipGraphicsMapResources.cc
hipGraphicsSubResourceGetMappedArray.cc
hipGraphicsResourceGetMappedPointer.cc
hipGraphicsUnmapResources.cc
hipGraphicsUnregisterResource.cc
)

hip_add_exe_to_target(NAME GLInteropTest
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests
COMPILE_OPTIONS -std=c++17)

find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL)
find_package(GLUT REQUIRED)
target_link_libraries(GLInteropTest OpenGL::GL OpenGL::EGL GLUT::GLUT)
219 changes: 219 additions & 0 deletions catch/unit/gl_interop/gl_interop_common.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#pragma once

#include <variant>

#define GL_GLEXT_PROTOTYPES
#include <GL/freeglut.h>
#include <GL/freeglut_ext.h>

#include <EGL/egl.h>
#include <EGL/eglext.h>

#include <hip_test_common.hh>

class GLBufferObject {
public:
static constexpr size_t kSize = 512 * 512 * 4 * sizeof(float);

GLBufferObject() {
glGenBuffers(1, &vbo_);
glBindBuffer(GL_ARRAY_BUFFER, vbo_);
glBufferData(GL_ARRAY_BUFFER, kSize, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
REQUIRE(glGetError() == GL_NO_ERROR);
}

~GLBufferObject() { glDeleteBuffers(1, &vbo_); }

operator GLuint() const { return vbo_; }

private:
GLuint vbo_;
};

class GLImageObject {
public:
static constexpr size_t kWidth = 512, kHeight = 512;

GLImageObject() {
glGenTextures(1, &tex_);
glBindTexture(GL_TEXTURE_2D, tex_);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI_EXT, kWidth, kHeight, 0, GL_RGBA_INTEGER_EXT,
GL_UNSIGNED_BYTE, NULL);
REQUIRE(glGetError() == GL_NO_ERROR);
}

~GLImageObject() { glDeleteTextures(1, &tex_); }

operator GLuint() const { return tex_; }

private:
GLuint tex_;
};

static std::once_flag glut_init_flag;

class GLUTContextScopeGuard {
public:
GLUTContextScopeGuard() {
std::call_once(glut_init_flag, &GLUTContextScopeGuard::init);
glut_window_ = glutCreateWindow("");
}

~GLUTContextScopeGuard() { glutDestroyWindow(glut_window_); }

GLUTContextScopeGuard(const GLUTContextScopeGuard&) = delete;
GLUTContextScopeGuard& operator=(const GLUTContextScopeGuard&) = delete;

GLUTContextScopeGuard(GLUTContextScopeGuard&&) = delete;
GLUTContextScopeGuard& operator=(GLUTContextScopeGuard&&) = delete;

private:
int glut_window_;

static void init() {
static char proc_name[] = "";
static std::array<char*, 2> glut_argv = {proc_name, nullptr};
static int glut_argc = 1;

glutInit(&glut_argc, glut_argv.data());
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(512, 512);
}
};

class EGLContextScopeGuard {
public:
EGLContextScopeGuard() {
// 1. Initialize EGL
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");

eglQueryDevicesEXT(egl_devices_.max_size(), egl_devices_.data(), &num_devices_);

INFO("Detected " << num_devices_ << " devices");

PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");

egl_display_ = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, egl_devices_.at(0), 0);

REQUIRE(eglInitialize(egl_display_, &major_, &minor_));

// 2. Select an appropriate configuration
REQUIRE(eglChooseConfig(egl_display_, kConfigAttribs, &egl_config_, 1, &num_configs_));

// 3. Create a surface
egl_surface_ = eglCreatePbufferSurface(egl_display_, egl_config_, kPbufferAttribs);

// 4. Bind the API
REQUIRE(eglBindAPI(EGL_OPENGL_API));

// 5. Create a context and make it current
egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, NULL);

REQUIRE(eglMakeCurrent(egl_display_, egl_surface_, egl_surface_, egl_context_));
}

~EGLContextScopeGuard() {
// 6. Terminate EGL when finished
eglTerminate(egl_display_);
}

EGLContextScopeGuard(const EGLContextScopeGuard&) = delete;
EGLContextScopeGuard& operator=(const EGLContextScopeGuard&) = delete;

EGLContextScopeGuard(EGLContextScopeGuard&&) = delete;
EGLContextScopeGuard& operator=(EGLContextScopeGuard&&) = delete;

private:
// clang-format off
static constexpr EGLint kConfigAttribs[] = {
EGL_SURFACE_TYPE,
EGL_PBUFFER_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_DEPTH_SIZE, 8,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_BIT,
EGL_NONE
};
// clang-format on

static constexpr int kPbufferWidth = 9;
static constexpr int kPbufferHeight = 9;

static constexpr EGLint kPbufferAttribs[] = {
EGL_WIDTH, kPbufferWidth, EGL_HEIGHT, kPbufferHeight, EGL_NONE,
};

std::array<EGLDeviceEXT, 8> egl_devices_;
EGLint num_devices_;
EGLDisplay egl_display_;
EGLint major_, minor_;
EGLint num_configs_;
EGLConfig egl_config_;
EGLSurface egl_surface_;
EGLContext egl_context_;
};

class GLContextScopeGuard {
public:
using GLUTContextScopeGuardPtr = std::unique_ptr<GLUTContextScopeGuard>;
using EGLContextScopeGuardPtr = std::unique_ptr<EGLContextScopeGuard>;
using GLContextScopeGuardVariant =
std::variant<GLUTContextScopeGuardPtr, EGLContextScopeGuardPtr>;

static constexpr char kEnvarName[] = "GL_CONTEXT_TYPE";

GLContextScopeGuard() {
char* val = std::getenv(kEnvarName);
std::string val_str = val == NULL ? "" : val;

if (val_str.empty() || val_str == "GLUT") {
gl_context_ = std::make_unique<GLUTContextScopeGuard>();
} else if (val_str == "EGL") {
gl_context_ = std::make_unique<EGLContextScopeGuard>();
} else {
INFO("Unsupported " << kEnvarName << " value '" << val_str << "'");
INFO("Supported values are ['GLUT', 'EGL']");
REQUIRE(false);
}
}

GLContextScopeGuard(const GLContextScopeGuard&) = delete;
GLContextScopeGuard& operator=(const GLContextScopeGuard&) = delete;

GLContextScopeGuard(GLContextScopeGuard&&) = delete;
GLContextScopeGuard& operator=(GLContextScopeGuard&&) = delete;

private:
GLContextScopeGuardVariant gl_context_;
};
Loading