Hash :
9bd6785d
Author :
Date :
2025-08-12T15:19:08
Revert "Tests: Skip CapturedTestCL to unblock vulkan-deps roll" This reverts commit 2a5ad67c883a28436d7399d73a2ccdb9ef53c641. Additionally, this modifies CapturedTestCL.cpp so there is no failure coming from the vulkan-deps roll. Bug: angleproject:438220619 Bug: angleproject:438195622 Change-Id: I6cf2d11d7ff77ce4513948b22b8c59d970c7810b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6842222 Reviewed-by: Austin Annestrand <a.annestrand@samsung.com> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
//
// Copyright 2025 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "test_utils/ANGLETestCL.h"
#include <angle_cl.h>
#include "util/test_utils.h"
using namespace angle;
namespace
{
void CL_CALLBACK ContextCreated(const char *errinfo,
const void *private_info,
size_t cb,
void *user_data)
{
std::cout << "Context created";
}
class CapturedTestCL : public ANGLETestCL<>
{
protected:
CapturedTestCL() : ANGLETestCL(this->GetParam()) {}
};
class MultiFrameCL
{
public:
MultiFrameCL() {}
void testSetUp()
{
// Get platform
cl_platform_id platform;
clGetPlatformIDs(1, &platform, nullptr);
// Get device
cl_device_id device;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, nullptr);
// Create context
context = clCreateContext(nullptr, 1, &device, ContextCreated, nullptr, nullptr);
assert(context != nullptr);
// Create command queue
queue = clCreateCommandQueue(context, device, 0, nullptr);
assert(queue != nullptr);
// Create and build program
const char *kernelSource = R"(
__kernel void frame1(__global float *output)
{
int gid = get_global_id(0);
output[gid] = gid * 2.0f;
}
__kernel void frame2(__global float *output)
{
int gid = get_global_id(0);
output[gid] = gid * gid;
}
__kernel void frame3(__global float *output)
{
int gid = get_global_id(0);
output[gid] = gid + 100.0f;
}
__kernel void frame4(__global float *output)
{
int gid = get_global_id(0);
output[gid] = gid;
}
__kernel void frame5(__global float *output)
{
int gid = get_global_id(0);
output[gid] = gid/gid;
}
)";
program = clCreateProgramWithSource(context, 1, &kernelSource, nullptr, nullptr);
clBuildProgram(program, 0, nullptr, nullptr, nullptr, nullptr);
cl_build_status status;
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status),
&status, nullptr);
std::cout << "Build status: " << status << "\n";
}
void testTearDown()
{
clReleaseProgram(program);
clReleaseCommandQueue(queue);
clReleaseContext(context);
}
void frame1() { executeKernel("frame1"); }
void frame2() { executeKernel("frame2"); }
void frame3() { executeKernel("frame3"); }
void frame4() { executeKernel("frame4"); }
void frame5() { executeKernel("frame5"); }
private:
void executeKernel(const char *kernelName)
{
// Create buffer
outputBuffer =
clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * 128, nullptr, nullptr);
// Get CL_MEM_SIZE
size_t memSize;
clGetMemObjectInfo(outputBuffer, CL_MEM_SIZE, sizeof(size_t), &memSize, nullptr);
std::cout << "Buffer size: " << memSize << ":\n";
// Create kernel
cl_kernel kernel = clCreateKernel(program, kernelName, nullptr);
assert(kernel != nullptr);
// Set kernel arguments
clSetKernelArg(kernel, 0, sizeof(cl_mem), &outputBuffer);
// Execute kernel
size_t globalWorkSize = 128;
clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &globalWorkSize, nullptr, 0, nullptr,
nullptr);
// Read and verify results
std::vector<float> results(128);
clEnqueueReadBuffer(queue, outputBuffer, CL_TRUE, 0, sizeof(float) * 128, results.data(), 0,
nullptr, nullptr);
// Print the results
std::cout << "Results from " << kernelName << ":\n";
for (size_t i = 0; i < results.size(); ++i)
{
std::cout << results[i] << " ";
}
std::cout << "\n";
// Cleanup kernel
clReleaseKernel(kernel);
// Cleanup buffer
clReleaseMemObject(outputBuffer);
}
cl_context context;
cl_command_queue queue;
cl_program program;
cl_mem outputBuffer;
};
// OpenCL test captured by capture_tests.py
TEST_P(CapturedTestCL, MultiFrameCL)
{
MultiFrameCL test;
test.testSetUp();
// Execute multiple frames
test.frame1();
test.frame2();
test.frame3();
test.frame4();
test.frame5();
test.testTearDown();
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CapturedTestCL);
// Capture is only supported on the Vulkan backend
ANGLE_INSTANTIATE_TEST(CapturedTestCL, ES3_VULKAN());
} // anonymous namespace