SWDEV-1 - Merge github PRs to amd-staging
- https://github.com/ROCm/hip-tests/pull/194 - https://github.com/ROCm/hip-tests/pull/36 - https://github.com/ROCm/hip-tests/pull/44 - https://github.com/ROCm/hip-tests/pull/47 - https://github.com/ROCm/hip-tests/pull/62 - https://github.com/ROCm/hip-tests/pull/63 - https://github.com/ROCm/hip-tests/pull/64 - https://github.com/ROCm/hip-tests/pull/65 - https://github.com/ROCm/hip-tests/pull/66 - https://github.com/ROCm/hip-tests/pull/67 - https://github.com/ROCm/hip-tests/pull/68 - https://github.com/ROCm/hip-tests/pull/69 - https://github.com/ROCm/hip-tests/pull/142 - https://github.com/ROCm/hip-tests/pull/196 - https://github.com/ROCm/hip-tests/pull/238 Change-Id: I74f7fef76d7d536b1cf89dad3e527c92d1cd21b5
Dieser Commit ist enthalten in:
@@ -0,0 +1,30 @@
|
||||
set(TEST_SRC
|
||||
hipGLGetDevices.cc
|
||||
hipGraphicsGLRegisterBuffer.cc
|
||||
hipGraphicsGLRegisterImage.cc
|
||||
hipGraphicsMapResources.cc
|
||||
hipGraphicsSubResourceGetMappedArray.cc
|
||||
hipGraphicsResourceGetMappedPointer.cc
|
||||
hipGraphicsUnmapResources.cc
|
||||
hipGraphicsUnregisterResource.cc
|
||||
)
|
||||
|
||||
find_package(OpenGL COMPONENTS OpenGL EGL)
|
||||
message(STATUS "OpenGL_FOUND: ${OpenGL_FOUND}")
|
||||
if(NOT OpenGL_FOUND)
|
||||
message(STATUS "OpenGL not found, OpenGL interop tests not enabled.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(GLUT)
|
||||
message(STATUS "GLUT_FOUND: ${GLUT_FOUND}")
|
||||
if(NOT GLUT_FOUND)
|
||||
message(STATUS "GLUT not found, OpenGL interop tests not enabled.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
hip_add_exe_to_target(NAME GLInteropTest
|
||||
TEST_SRC ${TEST_SRC}
|
||||
TEST_TARGET_NAME build_tests
|
||||
COMPILE_OPTIONS -std=c++17)
|
||||
target_link_libraries(GLInteropTest OpenGL::GL OpenGL::EGL GLUT::GLUT)
|
||||
@@ -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_;
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
namespace {
|
||||
constexpr std::array<hipGLDeviceList, 3> kDeviceLists{
|
||||
hipGLDeviceListAll, hipGLDeviceListCurrentFrame, hipGLDeviceListNextFrame};
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("Unit_hipGLGetDevices_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
const auto device_list = GENERATE(from_range(begin(kDeviceLists), end(kDeviceLists)));
|
||||
|
||||
const int device_count = HipTest::getDeviceCount();
|
||||
|
||||
unsigned int gl_device_count = 0;
|
||||
std::vector<int> gl_devices(device_count, -1);
|
||||
|
||||
HIP_CHECK(hipGLGetDevices(&gl_device_count, gl_devices.data(), device_count, device_list));
|
||||
|
||||
REQUIRE(gl_device_count == 1);
|
||||
REQUIRE(gl_devices.at(0) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGLGetDevices_Positive_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
const int device_count = HipTest::getDeviceCount();
|
||||
|
||||
unsigned int gl_device_count = 0;
|
||||
std::vector<int> gl_devices(device_count, -1);
|
||||
|
||||
SECTION("pHipDeviceCount == nullptr") {
|
||||
HIP_CHECK(hipGLGetDevices(nullptr, gl_devices.data(), device_count, hipGLDeviceListAll));
|
||||
REQUIRE(gl_devices.at(0) == 0);
|
||||
}
|
||||
|
||||
SECTION("pHipDevices == nullptr") {
|
||||
HIP_CHECK(hipGLGetDevices(&gl_device_count, nullptr, device_count, hipGLDeviceListAll));
|
||||
REQUIRE(gl_device_count == 1);
|
||||
}
|
||||
|
||||
SECTION("hipDeviceCount == 0") {
|
||||
HIP_CHECK(hipGLGetDevices(&gl_device_count, gl_devices.data(), 0, hipGLDeviceListAll));
|
||||
REQUIRE(gl_device_count == 1);
|
||||
REQUIRE(gl_devices.at(0) == -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGLGetDevices_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
const int device_count = HipTest::getDeviceCount();
|
||||
|
||||
unsigned int gl_device_count = 0;
|
||||
std::vector<int> gl_devices(device_count, -1);
|
||||
|
||||
SECTION("invalid deviceList") {
|
||||
HIP_CHECK_ERROR(hipGLGetDevices(&gl_device_count, gl_devices.data(), device_count,
|
||||
static_cast<hipGLDeviceList>(-1)),
|
||||
hipErrorInvalidValue);
|
||||
REQUIRE(gl_device_count == 0);
|
||||
REQUIRE(gl_devices.at(0) == -1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
namespace {
|
||||
constexpr std::array<unsigned int, 3> kFlags{hipGraphicsRegisterFlagsNone,
|
||||
hipGraphicsRegisterFlagsReadOnly,
|
||||
hipGraphicsRegisterFlagsWriteDiscard};
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterBuffer_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
const auto flags = GENERATE(from_range(begin(kFlags), end(kFlags)));
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, flags));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterBuffer_Positive_Register_Twice") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource *vbo_resource_1, *vbo_resource_2;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource_1, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource_2, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource_1));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource_2));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterBuffer_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
SECTION("resource == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphicsGLRegisterBuffer(nullptr, vbo, hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid buffer") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterBuffer(&vbo_resource, GLuint{}, hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid flags") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, std::numeric_limits<unsigned int>::max()),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("flags == hipGraphicsRegisterFlagsSurfaceLoadStore") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsSurfaceLoadStore),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("flags == hipGraphicsRegisterFlagsTextureGather") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsTextureGather),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
namespace {
|
||||
constexpr std::array<unsigned int, 5> kFlags{
|
||||
hipGraphicsRegisterFlagsNone, hipGraphicsRegisterFlagsReadOnly,
|
||||
hipGraphicsRegisterFlagsWriteDiscard, hipGraphicsRegisterFlagsSurfaceLoadStore,
|
||||
hipGraphicsRegisterFlagsTextureGather};
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterImage_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
const auto flags = GENERATE(from_range(begin(kFlags), end(kFlags)));
|
||||
|
||||
GLImageObject tex;
|
||||
|
||||
hipGraphicsResource* tex_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&tex_resource, tex, GL_TEXTURE_2D, flags));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterImage_Positive_Register_Twice") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLImageObject tex;
|
||||
|
||||
hipGraphicsResource *tex_resource_1, *tex_resource_2;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&tex_resource_1, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&tex_resource_2, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource_1));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource_2));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsGLRegisterImage_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLImageObject tex;
|
||||
|
||||
hipGraphicsResource* tex_resource;
|
||||
|
||||
SECTION("resource == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterImage(nullptr, tex, GL_TEXTURE_2D, hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid image") {
|
||||
HIP_CHECK_ERROR(hipGraphicsGLRegisterImage(&tex_resource, GLuint{}, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid target") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsGLRegisterImage(&tex_resource, tex, GL_BUFFER, hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("target does not match the object") {
|
||||
HIP_CHECK_ERROR(hipGraphicsGLRegisterImage(&tex_resource, tex, GL_RENDERBUFFER,
|
||||
hipGraphicsRegisterFlagsNone),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid flags") {
|
||||
HIP_CHECK_ERROR(hipGraphicsGLRegisterImage(&tex_resource, tex, GL_TEXTURE_2D,
|
||||
std::numeric_limits<unsigned int>::max()),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsMapResources_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
GLImageObject tex;
|
||||
|
||||
std::array<hipGraphicsResource_t, 2> resources;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&resources.at(0), vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&resources.at(1), tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(resources.size(), resources.data(), stream));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(resources.size(), resources.data(), stream));
|
||||
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(resources.at(0)));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(resources.at(1)));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsMapResources_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
SECTION("count == 0") {
|
||||
HIP_CHECK_ERROR(hipGraphicsMapResources(0, &vbo_resource, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("resources == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphicsMapResources(1, nullptr, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("unregistered resource") {
|
||||
hipGraphicsResource* unregistered_resource;
|
||||
HIP_CHECK(
|
||||
hipGraphicsGLRegisterBuffer(&unregistered_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unregistered_resource));
|
||||
HIP_CHECK_ERROR(hipGraphicsMapResources(1, &unregistered_resource, 0), hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
SECTION("already mapped resource") {
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
HIP_CHECK_ERROR(hipGraphicsMapResources(1, &vbo_resource, 0), hipErrorAlreadyMapped);
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
}
|
||||
|
||||
SECTION("invalid stream") {
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
HIP_CHECK_ERROR(hipGraphicsMapResources(1, &vbo_resource, stream), hipErrorContextIsDestroyed);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsResourceGetMappedPointer_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
|
||||
float* buffer_devptr = nullptr;
|
||||
size_t size = 0;
|
||||
|
||||
HIP_CHECK(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr), &size,
|
||||
vbo_resource));
|
||||
|
||||
REQUIRE(buffer_devptr != nullptr);
|
||||
REQUIRE(size == vbo.kSize);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsResourceGetMappedPointer_Positive_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
|
||||
float* buffer_devptr = nullptr;
|
||||
size_t size = 0;
|
||||
|
||||
SECTION("devPtr == nullptr") {
|
||||
HIP_CHECK(hipGraphicsResourceGetMappedPointer(nullptr, &size, vbo_resource));
|
||||
REQUIRE(size == vbo.kSize);
|
||||
}
|
||||
|
||||
SECTION("size == nullptr") {
|
||||
HIP_CHECK(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr), nullptr,
|
||||
vbo_resource));
|
||||
REQUIRE(buffer_devptr != nullptr);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsResourceGetMappedPointer_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
|
||||
float* buffer_devptr = nullptr;
|
||||
size_t size = 0;
|
||||
|
||||
SECTION("non-pointer resource") {
|
||||
GLImageObject tex;
|
||||
hipGraphicsResource* tex_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&tex_resource, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &tex_resource, 0));
|
||||
|
||||
HIP_CHECK_ERROR(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr),
|
||||
&size, tex_resource),
|
||||
hipErrorNotMappedAsPointer);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &tex_resource, 0));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource));
|
||||
}
|
||||
|
||||
SECTION("unregistered resource") {
|
||||
hipGraphicsResource* unregistered_resource;
|
||||
HIP_CHECK(
|
||||
hipGraphicsGLRegisterBuffer(&unregistered_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unregistered_resource));
|
||||
HIP_CHECK_ERROR(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr),
|
||||
&size, unregistered_resource),
|
||||
hipErrorContextIsDestroyed);
|
||||
}
|
||||
|
||||
SECTION("not mapped resource") {
|
||||
hipGraphicsResource* not_mapped_resource;
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(¬_mapped_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK_ERROR(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr),
|
||||
&size, not_mapped_resource),
|
||||
hipErrorNotMapped);
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(not_mapped_resource));
|
||||
}
|
||||
|
||||
SECTION("unmapped resource") {
|
||||
hipGraphicsResource* unmapped_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&unmapped_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &unmapped_resource, 0));
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &unmapped_resource, 0));
|
||||
|
||||
HIP_CHECK_ERROR(hipGraphicsResourceGetMappedPointer(reinterpret_cast<void**>(&buffer_devptr),
|
||||
&size, unmapped_resource),
|
||||
hipErrorNotMapped);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unmapped_resource));
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsSubResourceGetMappedArray_Positive_Basic") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLImageObject tex;
|
||||
|
||||
hipGraphicsResource* tex_resource;
|
||||
|
||||
HIP_CHECK(
|
||||
hipGraphicsGLRegisterImage(&tex_resource, tex, GL_TEXTURE_2D, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &tex_resource, 0));
|
||||
|
||||
hipArray* image_devptr = nullptr;
|
||||
HIP_CHECK(hipGraphicsSubResourceGetMappedArray(&image_devptr, tex_resource, 0, 0));
|
||||
|
||||
REQUIRE(image_devptr != nullptr);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &tex_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsSubResourceGetMappedArray_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLImageObject tex;
|
||||
|
||||
hipGraphicsResource* tex_resource;
|
||||
|
||||
HIP_CHECK(
|
||||
hipGraphicsGLRegisterImage(&tex_resource, tex, GL_TEXTURE_2D, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &tex_resource, 0));
|
||||
|
||||
hipArray* image_devptr = nullptr;
|
||||
|
||||
SECTION("array == nullptr") {
|
||||
HIP_CHECK(hipGraphicsSubResourceGetMappedArray(nullptr, tex_resource, 0, 0));
|
||||
}
|
||||
|
||||
SECTION("non-texture resource") {
|
||||
GLBufferObject vbo;
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
|
||||
HIP_CHECK_ERROR(hipGraphicsSubResourceGetMappedArray(&image_devptr, vbo_resource, 0, 0),
|
||||
hipErrorNotMappedAsArray);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
|
||||
SECTION("unregistered resource") {
|
||||
hipGraphicsResource* unregistered_resource;
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&unregistered_resource, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unregistered_resource));
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphicsSubResourceGetMappedArray(&image_devptr, unregistered_resource, 0, 0),
|
||||
hipErrorContextIsDestroyed);
|
||||
}
|
||||
|
||||
SECTION("not mapped resource") {
|
||||
hipGraphicsResource* not_mapped_resource;
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(¬_mapped_resource, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK_ERROR(hipGraphicsSubResourceGetMappedArray(&image_devptr, not_mapped_resource, 0, 0),
|
||||
hipErrorNotMapped);
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(not_mapped_resource));
|
||||
}
|
||||
|
||||
SECTION("unmapped resource") {
|
||||
hipGraphicsResource* unmapped_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterImage(&unmapped_resource, tex, GL_TEXTURE_2D,
|
||||
hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &unmapped_resource, 0));
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &unmapped_resource, 0));
|
||||
|
||||
HIP_CHECK_ERROR(hipGraphicsSubResourceGetMappedArray(&image_devptr, unmapped_resource, 0, 0),
|
||||
hipErrorNotMapped);
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unmapped_resource));
|
||||
}
|
||||
|
||||
SECTION("invalid arrayIndex") {
|
||||
HIP_CHECK_ERROR(hipGraphicsSubResourceGetMappedArray(&image_devptr, tex_resource,
|
||||
std::numeric_limits<int>::max(), 0),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("invalid mipLevel") {
|
||||
HIP_CHECK_ERROR(hipGraphicsSubResourceGetMappedArray(&image_devptr, tex_resource, 0,
|
||||
std::numeric_limits<int>::max()),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &tex_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(tex_resource));
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsUnmapResources_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
hipGraphicsResource* vbo_resource;
|
||||
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&vbo_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &vbo_resource, 0));
|
||||
|
||||
SECTION("count == 0") {
|
||||
HIP_CHECK_ERROR(hipGraphicsUnmapResources(0, &vbo_resource, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("resources == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphicsUnmapResources(1, nullptr, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("not mapped resource") {
|
||||
hipGraphicsResource* not_mapped_resource;
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(¬_mapped_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK_ERROR(hipGraphicsUnmapResources(1, ¬_mapped_resource, 0), hipErrorNotMapped);
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(not_mapped_resource));
|
||||
}
|
||||
|
||||
SECTION("invalid stream") {
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
HIP_CHECK_ERROR(hipGraphicsUnmapResources(1, &vbo_resource, stream),
|
||||
hipErrorContextIsDestroyed);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphicsUnmapResources(1, &vbo_resource, 0));
|
||||
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(vbo_resource));
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_gl_interop.h>
|
||||
|
||||
#include "gl_interop_common.hh"
|
||||
|
||||
TEST_CASE("Unit_hipGraphicsUnregisterResource_Negative_Parameters") {
|
||||
GLContextScopeGuard gl_context;
|
||||
|
||||
GLBufferObject vbo;
|
||||
|
||||
SECTION("already unregistered resource") {
|
||||
hipGraphicsResource* unregistered_resource;
|
||||
HIP_CHECK(
|
||||
hipGraphicsGLRegisterBuffer(&unregistered_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsUnregisterResource(unregistered_resource));
|
||||
HIP_CHECK_ERROR(hipGraphicsUnregisterResource(unregistered_resource), hipErrorInvalidContext);
|
||||
}
|
||||
|
||||
SECTION("mapped resource") {
|
||||
hipGraphicsResource* mapped_resource;
|
||||
HIP_CHECK(hipGraphicsGLRegisterBuffer(&mapped_resource, vbo, hipGraphicsRegisterFlagsNone));
|
||||
HIP_CHECK(hipGraphicsMapResources(1, &mapped_resource, 0));
|
||||
HIP_CHECK_ERROR(hipGraphicsUnregisterResource(mapped_resource), hipErrorAlreadyMapped);
|
||||
}
|
||||
}
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren