{"id":28564931,"url":"https://github.com/aelstraz/unity-gpu-compute","last_synced_at":"2026-04-30T19:31:10.381Z","repository":{"id":293799572,"uuid":"985163619","full_name":"Aelstraz/Unity-GPU-Compute","owner":"Aelstraz","description":"GPU Compute provides an easy way to setup \u0026 execute GPU compute shaders in Unity. Create and manage buffers, track GPU memory usage \u0026 execution time, automatically calculate thread group sizes \u0026 buffer strides- all in one class. ","archived":false,"fork":false,"pushed_at":"2025-05-29T11:41:33.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-29T12:59:00.929Z","etag":null,"topics":["compute-shader","compute-shaders","computeshader","computeshaders","gpu","gpu-computing","gpu-programming","shader","shaders","unity","unity-package","unity-scripts","unity3d","unity3d-plugin"],"latest_commit_sha":null,"homepage":"https://x.com/Aelstraz","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aelstraz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-17T07:32:20.000Z","updated_at":"2025-05-29T11:41:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"105ccc96-1827-44d7-9aff-915d7eebd08d","html_url":"https://github.com/Aelstraz/Unity-GPU-Compute","commit_stats":null,"previous_names":["aelstraz/gpu-compute","aelstraz/unity-gpu-compute"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aelstraz%2FUnity-GPU-Compute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aelstraz%2FUnity-GPU-Compute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aelstraz%2FUnity-GPU-Compute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aelstraz%2FUnity-GPU-Compute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aelstraz","download_url":"https://codeload.github.com/Aelstraz/Unity-GPU-Compute/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aelstraz%2FUnity-GPU-Compute/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259088487,"owners_count":22803643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compute-shader","compute-shaders","computeshader","computeshaders","gpu","gpu-computing","gpu-programming","shader","shaders","unity","unity-package","unity-scripts","unity3d","unity3d-plugin"],"created_at":"2025-06-10T14:01:11.632Z","updated_at":"2026-04-30T19:31:10.374Z","avatar_url":"https://github.com/Aelstraz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPU Compute (Unity)\nGPU Compute provides the ultimate \u0026 easiest way to setup, manage \u0026 execute GPU compute shaders in Unity. Reduces complexity and boilerplate code while providing powerful features for standard/async execution, global \u0026 local buffer/render texture creation, management, reading (standard/async), tracking \u0026 disposal, global and local variable management, GPU memory tracking, performance tracking, shader execution control \u0026 much more! \n\n## Features\n\n- **Simplified Shader Execution** - Easy setup and execution of compute shaders (synchronous \u0026 asynchronous)\n- **Automatic Buffer Management** - Create, edit, and read buffers with automatically calculated strides and lengths\n- **Flexible Thread Group Sizing** - Automatically calculate optimal GPU thread group sizes for 1D, 2D, and 3D workloads\n- **GPU Memory Tracking** - Track local and global GPU memory usage in real-time with formatted output\n- **Performance Monitoring** - Measure compute shader execution time\n- **Async GPU Readback** - Efficiently retrieve data from GPU using AsyncGPUReadbackRequest\n- **Render Texture Support** - Full support for creating and managing render textures\n- **Global Resources** - Centralized management of global buffers and textures accessible across multiple compute shader instances\n- **Buffer Resizing** - Dynamically resize buffers without recreating instances\n- **Shader Keywords** - Enable/disable local shader keywords programmatically\n- **Buffer Debugging** - Retrieve and inspect buffer contents for debugging purposes\n- **Centralized in a Single Class** - All GPU compute operations managed through one easy-to-use class\n\n```csharp\nusing (GPUCompute gpuCompute = new GPUCompute(computeShader))\n{\n    gpuCompute.SetBuffer(\"myBuffer\", ref myBuffer);\n    gpuCompute.SetFloat(\"myFloatVar\", 2f);\n    Debug.Log(\"GPU Compute Memory Allocated: \" + gpuCompute.GetGPUMemoryUsedFormatted());\n    gpuCompute.Execute();\n    gpuCompute.GetBufferData(\"myBuffer\", ref myBuffer);\n    Debug.Log(\"Compute Time: \" + gpuCompute.GetLastComputeTime());\n}\n```\n\n## Table of Contents\n1. [Installation](#installation)\n2. [Quick Start](#quick-start)\n3. [Buffers \u0026 Textures](#buffers--textures)\n4. [Shader Variables](#shader-variables)\n5. [Thread Group Sizes](#thread-group-sizes)\n6. [Execution](#execution)\n7. [Memory \u0026 Performance](#memory--performance)\n8. [Async Operations](#async-operations)\n9. [Global Resources](#global-resources)\n10. [Buffer Debugging](#buffer-debugging)\n11. [Advanced Features](#advanced-features)\n12. [Example Usage](#example-usage)\n\n## Installation\n\nSimply add the entire folder into your project's Assets folder.\n\n---\n\n## Quick Start\n\n### Instantiate\n\nCreate a new instance of GPUCompute by providing your compute shader:\n\n```csharp\nGPUCompute gpuCompute = new GPUCompute(myComputeShader);\n```\n\nYou can also specify a compute queue type for async execution:\n\n```csharp\nGPUCompute gpuCompute = new GPUCompute(myComputeShader, ComputeQueueType.Default);\n```\n\n### Dispose\n\nAlways dispose of your GPUCompute instances when finished to prevent GPU memory leaks:\n\n```csharp\ngpuCompute.Dispose();              // Disposes both local and global resources\ngpuCompute.DisposeLocal();         // Disposes only local buffers/textures\nGPUCompute.DisposeGlobal();        // Disposes only global buffers/textures\n```\n\n---\n\n## Buffers \u0026 Textures\n\n### Creating \u0026 Setting Buffers\n\nCreate buffers from existing data (stride and length are calculated automatically):\n\n```csharp\nVector3[] vertices = new Vector3[1000];\ngpuCompute.SetBuffer(\"vertices\", ref vertices);\n\nfloat[] uvs = new float[2000];\ngpuCompute.SetBuffer(\"uvs\", ref uvs);\n```\n\nCreate empty buffers by specifying the struct type and length:\n\n```csharp\ngpuCompute.CreateEmptyBuffer\u003cint\u003e(\"myEmptyBuffer\", 500);\ngpuCompute.CreateEmptyBuffer\u003cVector3\u003e(\"positions\", 1000, kernelIndex: 0);\n```\n\nSet buffers with multiple kernel indices:\n\n```csharp\nint[] kernelIndices = { 0, 1, 2 };\ngpuCompute.SetBuffer(\"sharedData\", ref data, kernelIndices);\n```\n\nSpecify buffer type and mode:\n\n```csharp\ngpuCompute.CreateEmptyBuffer\u003cfloat\u003e(\n    \"counterBuffer\", \n    100, \n    ComputeBufferType.Counter, \n    ComputeBufferMode.Dynamic\n);\n```\n\n### Reading Buffer Data\n\nRetrieve buffer data from GPU to CPU:\n\n```csharp\nVector3[] resultBuffer = new Vector3[100];\ngpuCompute.GetBufferData(\"vertices\", ref resultBuffer);\n\nList\u003cVector3\u003e resultList = new List\u003cVector3\u003e(100);\ngpuCompute.GetBufferData(\"vertices\", ref resultList);\n\nNativeArray\u003cVector3\u003e resultNative = new NativeArray\u003cVector3\u003e(100, Allocator.Persistent);\ngpuCompute.GetBufferData(\"vertices\", ref resultNative);\n```\n\n### Resizing Buffers\n\nDynamically resize buffers (data will be lost):\n\n```csharp\ngpuCompute.ResizeBuffer(\"myBuffer\", 2000);\n```\n\n### Render Textures\n\nCreate render textures for compute shader output:\n\n```csharp\nRenderTextureDescriptor descriptor = new RenderTextureDescriptor(1024, 1024, RenderTextureFormat.ARGBFloat);\ngpuCompute.CreateEmptyRenderTexture(\"outputTexture\", descriptor);\n\n// With mip levels and custom settings\ngpuCompute.CreateEmptyRenderTexture(\n    \"outputTexture\",\n    descriptor,\n    kernelIndex: 0,\n    mipLevel: 0,\n    wrapMode: TextureWrapMode.Clamp,\n    filterMode: FilterMode.Point,\n    anisoLevel: 1\n);\n```\n\nSet render textures:\n\n```csharp\nRenderTexture myTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGBFloat);\ngpuCompute.SetRenderTexture(\"myRenderTexture\", ref myTexture);\n```\n\nRetrieve render texture data:\n\n```csharp\nTexture2D outputTexture = new Texture2D(1024, 1024, TextureFormat.RGBAFloat, false);\ngpuCompute.GetRenderTextureData(\"outputTexture\", ref outputTexture);\n```\n\n### Texture Support\n\nSet various texture types:\n\n```csharp\nTexture2D texture2D = Resources.Load\u003cTexture2D\u003e(\"myTexture\");\ngpuCompute.SetTexture(\"inputTexture\", ref texture2D);\n\nTexture3D texture3D = Resources.Load\u003cTexture3D\u003e(\"myVolume\");\ngpuCompute.SetTexture(\"volumeTexture\", ref texture3D);\n\nTexture2DArray textureArray = Resources.Load\u003cTexture2DArray\u003e(\"myTextureArray\");\ngpuCompute.SetTextureArray(\"textureArrayInput\", ref textureArray);\n```\n\n---\n\n## Shader Variables\n\n### Scalar Values\n\n```csharp\ngpuCompute.SetInt(\"count\", 100);\ngpuCompute.SetFloat(\"deltaTime\", Time.deltaTime);\ngpuCompute.SetBool(\"useOptimization\", true);\n```\n\n### Vectors\n\n```csharp\ngpuCompute.SetVector(\"position\", new Vector3(1, 2, 3));\ngpuCompute.SetVector(\"colorData\", new Vector4(1, 0, 0, 1));\ngpuCompute.SetVector(\"uv\", new Vector2(0.5f, 0.5f));\ngpuCompute.SetVector(\"gridSize\", new Vector3Int(10, 10, 10));\n```\n\n### Arrays\n\n```csharp\nfloat[] floatArray = new float[100];\ngpuCompute.SetFloatArray(\"floatData\", floatArray);\n\nVector4[] vectorArray = new Vector4[50];\ngpuCompute.SetVectorArray(\"vectorData\", vectorArray);\n```\n\n### Matrices\n\n```csharp\nMatrix4x4 transformMatrix = Matrix4x4.identity;\ngpuCompute.SetMatrix(\"transform\", transformMatrix);\n\nMatrix4x4[] matrixArray = new Matrix4x4[10];\ngpuCompute.SetMatrixArray(\"transforms\", matrixArray);\n```\n\n### Retrieving Variable Values\n\n```csharp\nint value = gpuCompute.GetInt(\"myInt\");\nfloat value = gpuCompute.GetFloat(\"myFloat\");\nVector4 vector = gpuCompute.GetVector(\"myVector\");\nMatrix4x4 matrix = gpuCompute.GetMatrix(\"myMatrix\");\n```\n\n---\n\n## Thread Group Sizes\n\n### Manual Thread Group Setting\n\n```csharp\ngpuCompute.SetThreadGroupSize(new Vector3Int(8, 8, 1));\nVector3Int currentSize = gpuCompute.GetThreadGroupSize();\n```\n\n### Automatic 1D Thread Group Calculation\n\nFor array-based workloads:\n\n```csharp\nint jobLength = vertices.Length;\nint threadLength = gpuCompute.SetCalculatedThreadGroupSize(jobLength, kernelIndex: 0);\n```\n\n### Automatic 2D Thread Group Calculation\n\nFor texture-based workloads:\n\n```csharp\nint width = 1024;\nint height = 1024;\ngpuCompute.SetCalculatedThreadGroupSize(width, height, kernelIndex: 0);\n```\n\n### Automatic 3D Thread Group Calculation\n\nFor volume-based workloads:\n\n```csharp\nint width = 64;\nint height = 64;\nint depth = 64;\ngpuCompute.SetCalculatedThreadGroupSize(width, height, depth, kernelIndex: 0);\n```\n\n### Getting Kernel Thread Group Sizes\n\nRetrieve the thread group sizes defined in your compute shader kernel:\n\n```csharp\nVector3Int kernelGroupSizes = gpuCompute.GetKernelThreadGroupSizes(kernelIndex: 0);\nDebug.Log($\"Kernel thread group size: {kernelGroupSizes}\");\n```\n\n---\n\n## Execution\n\n### Synchronous Execution\n\nExecute the compute shader and wait for completion:\n\n```csharp\ngpuCompute.Execute(kernelIndex: 0);\n```\n\n### Asynchronous Execution\n\nExecute the compute shader asynchronously (DX12 only):\n\n```csharp\nStartCoroutine(gpuCompute.ExecuteAsync(kernelIndex: 0));\n```\n\nSubscribe to completion events:\n\n```csharp\ngpuCompute.OnExecuteComplete += OnComputeComplete;\n\nprivate void OnComputeComplete(int kernelIndex)\n{\n    Debug.Log($\"Kernel {kernelIndex} execution completed\");\n}\n```\n\n### Check Execution Status\n\n```csharp\nif (gpuCompute.IsExecuting())\n{\n    Debug.Log(\"Compute shader is currently executing\");\n}\n```\n\n---\n\n## Memory \u0026 Performance\n\n### Track GPU Memory Usage\n\nGet local GPU memory used by the current instance:\n\n```csharp\nlong localMemoryBytes = gpuCompute.GetLocalGPUMemoryUsed();\nstring localMemoryFormatted = gpuCompute.GetLocalGPUMemoryUsedFormatted();\n// Output: \"1.25 MB\"\n```\n\nGet global GPU memory used across all instances:\n\n```csharp\nlong globalMemoryBytes = GPUCompute.GetGlobalGPUMemoryUsed();\nstring globalMemoryFormatted = GPUCompute.GetGlobalGPUMemoryUsedFormatted();\n```\n\n### Track Execution Time\n\nMeasure the duration of the last compute shader execution:\n\n```csharp\nTimeSpan lastExecutionTime = gpuCompute.GetLastComputeTime();\nDebug.Log($\"Last execution took: {lastExecutionTime.TotalMilliseconds} ms\");\n```\n\n### Format Byte Counts\n\nConvert byte counts to human-readable strings:\n\n```csharp\nstring formatted = GPUCompute.ByteCountToFormattedString(1024000);\n// Output: \"1.02 MB\"\n```\n\n---\n\n## Async Operations\n\n### Async Buffer Readback\n\nAsynchronously retrieve buffer data using AsyncGPUReadbackRequest for better performance:\n\n```csharp\nStartCoroutine(gpuCompute.GetBufferDataAsync(\"myBuffer\"));\n\n// Subscribe to readback completion\ngpuCompute.OnReadbackComplete += OnBufferReadbackComplete;\n\nprivate void OnBufferReadbackComplete(AsyncGPUReadbackRequest request, string bufferName)\n{\n    Vector3[] data = new Vector3[100]; \n    GPUCompute.ReadbackRequestToArray(ref request, ref data);\n    // Process data...\n}\n```\n\nRead buffer data with offset and length:\n\n```csharp\nStartCoroutine(gpuCompute.GetBufferDataAsync(\"myBuffer\", length: 100, startIndex: 50));\n```\n\n### Async Render Texture Readback\n\nAsynchronously retrieve render texture data:\n\n```csharp\nStartCoroutine(gpuCompute.GetRenderTextureDataAsync(\"outputTexture\"));\n\ngpuCompute.OnReadbackComplete += OnReadbackComplete;\n\nprivate void OnReadbackComplete(AsyncGPUReadbackRequest request, string textureName)\n{\n    Texture2D output = new Texture2D(request.width, request.height, TextureFormat.RGBAFloat, false);\n    GPUCompute.ReadbackRequestToTexture2D(ref request, ref output);\n}\n```\n\nAsynchronously retrieve global render texture data:\n\nOptional parameters can also be passed through for your own use.\n\n```csharp\nint myDataToPassThrough = 0;\nStartCoroutine(gpuCompute.GetGlobalRenderTextureDataAsync(\"outputTexture\"), myDataToPassThrough);\n\ngpuCompute.OnGlobalReadbackComplete += OnGlobalReadbackComplete;\n\nprivate void OnGlobalReadbackComplete(AsyncGPUReadbackRequest request, string textureName, params object[] parameters)\n{\n    int myDataToPassThrough = (int)parameters[0];\n    Texture2D output = new Texture2D(request.width, request.height, TextureFormat.RGBAFloat, false);\n    GPUCompute.ReadbackRequestToTexture2D(ref request, ref output);\n}\n```\n\nRetrieve specific regions:\n\n```csharp\nStartCoroutine(gpuCompute.GetRenderTextureDataAsync(\n    \"outputTexture\",\n    width: 256,\n    height: 256,\n    depth: 1,\n    mipIndex: 0,\n    x: 100,\n    y: 100,\n    z: 0\n));\n```\n\n### Readback Data Conversion\n\nConvert async readback requests to different formats:\n\n```csharp\n// To NativeArray\nNativeArray\u003cVector3\u003e nativeData = new NativeArray\u003cVector3\u003e(100, Allocator.Persistent);\nGPUCompute.ReadbackRequestToNativeArray(ref request, ref nativeData);\n\n// To List\nList\u003cVector3\u003e listData = new List\u003cVector3\u003e(100);\nGPUCompute.ReadbackRequestToList(ref request, ref listData);\n\n// To Texture3D\nTexture3D volume = new Texture3D(64, 64, 64, TextureFormat.RGBAFloat, false);\nGPUCompute.ReadbackRequestToTexture3D(ref request, ref volume);\n```\n\n---\n\n## Global Resources\n\nGlobal buffers and textures are accessible across all GPUCompute instances and persist for the lifetime of the application.\n\n### Global Buffers\n\nCreate and set global buffers:\n\n```csharp\nVector3[] globalVertices = new Vector3[1000];\nGPUCompute.SetGlobalBuffer(\"globalVertices\", ref globalVertices);\n\nGPUCompute.CreateEmptyGlobalBuffer\u003cfloat\u003e(\"globalData\", 5000);\n```\n\nRetrieve global buffer data:\n\n```csharp\nVector3[] outputBuffer = new Vector3[1000];\nGPUCompute.GetGlobalBufferData(\"globalVertices\", ref outputBuffer);\n```\n\nResize global buffers:\n\n```csharp\nGPUCompute.ResizeGlobalBuffer(\"globalData\", 10000);\n```\n\n### Global Textures\n\nSet global textures:\n\n```csharp\nTexture2D globalTexture = Resources.Load\u003cTexture2D\u003e(\"myGlobalTexture\");\nGPUCompute.SetGlobalTexture(\"globalTextureName\", ref globalTexture);\n\nTexture3D globalVolume = Resources.Load\u003cTexture3D\u003e(\"myVolume\");\nGPUCompute.SetGlobalTexture(\"globalVolume\", ref globalVolume);\n\nTexture2DArray globalArray = Resources.Load\u003cTexture2DArray\u003e(\"myArray\");\nGPUCompute.SetGlobalTextureArray(\"globalTextureArray\", ref globalArray);\n```\n\nCreate global render textures:\n\n```csharp\nRenderTextureDescriptor descriptor = new RenderTextureDescriptor(2048, 2048, RenderTextureFormat.ARGBFloat);\nGPUCompute.CreateEmptyGlobalRenderTexture(\"globalOutput\", descriptor);\n```\n\nRetrieve global texture data:\n\n```csharp\nTexture2D output = new Texture2D(2048, 2048, TextureFormat.RGBAFloat, false);\nGPUCompute.GetGlobalRenderTextureData(\"globalOutput\", ref output);\n```\n\n### Linking Global Resources\n\nLink global resources to compute shader instances:\n\n```csharp\ngpuCompute.LinkGlobalBuffer(\"globalBufferName\", \"globalBufferName\", kernelIndex: 0);\ngpuCompute.LinkGlobalTexture(\"globalTextureName\", \"globalTextureName\", kernelIndex: 0);\ngpuCompute.LinkGlobalRenderTexture(\"globalOutputName\", \"globalOutputName\", kernelIndex: 0);\n```\n\nLink to multiple kernels:\n\n```csharp\nint[] kernelIndices = { 0, 1, 2 };\ngpuCompute.LinkGlobalBuffer(\"buffer\", \"buffer\", kernelIndices);\n```\n\n### Dispose Global Resources\n\n```csharp\nGPUCompute.DisposeGlobalBuffer(\"globalBufferName\");\nGPUCompute.DisposeGlobalRenderTexture(\"globalTextureName\");\nGPUCompute.DisposeGlobal(); // Dispose all global resources\n```\n\n---\n\n## Shader Keywords\n\n### Enable/Disable Keywords\n\nEnable shader keywords:\n\n```csharp\ngpuCompute.EnableKeyword(\"MY_KEYWORD\");\n```\n\nDisable shader keywords:\n\n```csharp\ngpuCompute.DisableKeyword(\"MY_KEYWORD\");\n```\n\nSet keyword state by boolean:\n\n```csharp\nLocalKeyword keyword = gpuCompute.GetKeywordSpace().FindKeyword(\"MY_KEYWORD\");\ngpuCompute.SetKeyword(keyword, true);\n```\n\n### Query Keyword State\n\nCheck if keyword is enabled:\n\n```csharp\nif (gpuCompute.IsKeywordEnabled(\"MY_KEYWORD\"))\n{\n    Debug.Log(\"MY_KEYWORD is enabled\");\n}\n```\n\nGet all enabled keywords:\n\n```csharp\nLocalKeyword[] enabledKeywords = gpuCompute.GetEnabledKeywords();\nforeach (var keyword in enabledKeywords)\n{\n    Debug.Log($\"Enabled: {keyword.name}\");\n}\n```\n\n---\n\n## Buffer Debugging\n\nDebug buffers to inspect their contents (CPU-side only, for debugging):\n\n```csharp\nstring debugInfo = gpuCompute.DebugBuffer\u003cVector3\u003e(\"myBuffer\");\nDebug.Log(debugInfo);\n// Output:\n// Buffer Name: [myBuffer], Data Type: [System.Numerics.Vector3], \n// Length: [100], Stride: [12], VRAM Usage: [1.17 KB], ...\n// Values:\n// Index 0: (1.00, 2.00, 3.00)\n// Index 1: (4.00, 5.00, 6.00)\n// ...\n```\n\nDebug global buffers:\n\n```csharp\nstring debugInfo = GPUCompute.DebugGlobalBuffer\u003cfloat\u003e(\"globalBuffer\");\nDebug.Log(debugInfo);\n```\n\n---\n\n## Advanced Features\n\n### Kernel Management\n\nFind kernel indices:\n\n```csharp\nint kernelIndex = gpuCompute.FindKernel(\"CSMain\");\n```\n\nCheck if kernel exists:\n\n```csharp\nif (gpuCompute.HasKernel(\"CSMain\"))\n{\n    Debug.Log(\"CSMain kernel found\");\n}\n```\n\nCheck device support:\n\n```csharp\nif (gpuCompute.IsSupported(kernelIndex: 0))\n{\n    Debug.Log(\"Kernel is supported on this device\");\n}\n```\n\n### Compute Queue Configuration\n\nSet compute queue type (for async execution):\n\n```csharp\ngpuCompute.SetComputeQueueType(ComputeQueueType.Default);\nComputeQueueType currentType = gpuCompute.GetComputeQueueType();\n```\n\nSet synchronization stage flags:\n\n```csharp\ngpuCompute.SetSynchronisationStageFlags(SynchronisationStageFlags.ComputeProcessing);\nSynchronisationStageFlags flags = gpuCompute.GetSynchronisationStageFlags();\n```\n\n### Accessing Compute Shader\n\n```csharp\nComputeShader shader = gpuCompute.GetComputeShader();\n```\n\n### Get Keyword Space\n\n```csharp\nLocalKeywordSpace keywordSpace = gpuCompute.GetKeywordSpace();\n```\n\n---\n\n## Example Usage\n\nComplete example demonstrating common workflow:\n\n```csharp\nusing UnityEngine;\nusing GPUComputeModule;\n\npublic class ComputeExample : MonoBehaviour\n{\n    private GPUCompute gpuCompute;\n    private ComputeShader computeShader;\n    \n    void Start()\n    {\n        // Initialize\n        computeShader = Resources.Load\u003cComputeShader\u003e(\"MyComputeShader\");\n        gpuCompute = new GPUCompute(computeShader);\n        \n        // Setup data\n        Vector3[] vertices = new Vector3[1000];\n        for (int i = 0; i \u003c vertices.Length; i++)\n            vertices[i] = new Vector3(i, 0, 0);\n        \n        // Create buffer and set data\n        gpuCompute.SetBuffer(\"vertices\", ref vertices);\n        \n        // Set shader variables\n        gpuCompute.SetFloat(\"time\", Time.deltaTime);\n        gpuCompute.SetInt(\"vertexCount\", vertices.Length);\n        \n        // Calculate thread groups for 1D workload\n        gpuCompute.SetCalculatedThreadGroupSize(vertices.Length, kernelIndex: 0);\n        \n        // Execute synchronously\n        gpuCompute.Execute();\n        \n        // Read results\n        Vector3[] results = new Vector3[1000];\n        gpuCompute.GetBufferData(\"vertices\", ref results);\n        \n        // Check memory usage\n        Debug.Log($\"GPU Memory Used: {gpuCompute.GetLocalGPUMemoryUsedFormatted()}\");\n        Debug.Log($\"Execution Time: {gpuCompute.GetLastComputeTime().TotalMilliseconds} ms\");\n        \n        // Cleanup\n        gpuCompute.Dispose();\n    }\n}\n```\n\n---\n\n## Twitter: [@aelstraz](https://x.com/Aelstraz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faelstraz%2Funity-gpu-compute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faelstraz%2Funity-gpu-compute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faelstraz%2Funity-gpu-compute/lists"}