Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyopencl@2025.2.x
tile.json

tessl/pypi-pyopencl

tessl install tessl/pypi-pyopencl@2025.2.0

Python wrapper for OpenCL enabling GPU and parallel computing with comprehensive array operations and mathematical functions

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.28x

Baseline

Agent success rate without this tile

67%

task.mdevals/scenario-10/

Image Post-Processing Pipeline

Build a simple image post-processing system that processes OpenGL textures using GPU compute operations. The system should apply brightness adjustments to texture data through GPU-OpenGL interoperability.

Requirements

Create a Python program that:

  1. Sets up an OpenGL context and creates a shared compute context that can access OpenGL resources
  2. Creates a 2D RGBA texture in OpenGL (256x256 pixels) and fills it with test data
  3. Shares the OpenGL texture with the compute context for processing
  4. Implements a compute operation that reads the texture and applies a brightness adjustment (multiply RGB values by a configurable factor, leave alpha unchanged)
  5. Properly synchronizes access between OpenGL and compute when acquiring and releasing the shared texture
  6. Returns the processed texture data as a NumPy array for verification

Technical Details

  • The texture should use 8-bit per channel RGBA format (32 bits per pixel total)
  • The brightness adjustment factor should be configurable (e.g., 1.2 for 20% brighter, 0.5 for 50% darker)
  • RGB values should be clamped to the [0, 255] range after adjustment
  • Properly acquire the OpenGL texture before compute processing and release it when done
  • Ensure proper resource cleanup

Dependencies { .dependencies }

pyopencl { .dependency }

Provides GPU compute capabilities with OpenGL interoperability.

numpy { .dependency }

Provides array operations for image data handling.

PyOpenGL { .dependency }

Provides OpenGL rendering context and texture management.

Test Cases

Test 1: Context Creation { @test }

File: test_gl_interop.py

Test: Verify that a shared OpenGL/compute context can be created successfully without errors.

Expected: Context creation succeeds and can be queried for basic properties.

Test 2: Texture Sharing { @test }

File: test_gl_interop.py

Test: Create an OpenGL texture with a solid color (128, 64, 32, 255), share it with compute context, read it back. Verify the values match.

Expected: The compute context should read the exact same RGBA values from the shared texture.

Test 3: Brightness Adjustment { @test }

File: test_gl_interop.py

Test: Create texture with RGB=(100, 100, 100, 255), apply brightness factor of 1.5, read result.

Expected: Output should be RGB=(150, 150, 150, 255). Values should be properly clamped to [0, 255] range if they exceed it.

Test 4: Darkening { @test }

File: test_gl_interop.py

Test: Create texture with RGB=(200, 100, 50, 255), apply brightness factor of 0.5, read result.

Expected: Output should be RGB=(100, 50, 25, 255) showing proper darkening while preserving alpha channel.

Implementation Notes

  • You may use any OpenGL context creation library compatible with your platform (e.g., GLFW, GLUT, PyQt, etc.)
  • The compute kernels can be written in OpenCL C
  • Focus on correctness of the interoperability setup rather than performance optimization
  • Handle platform-specific differences in OpenGL context sharing appropriately