{"record":{"id":"f61b49ff1ff26051","repo":"pixijs/pixijs","slug":"gpurendertargetadaptor-cannot-get-gpu-color-text","errorCode":null,"errorMessage":"[GpuRenderTargetAdaptor] cannot get gpu color texture from a depth-only render target","messagePattern":"\\[GpuRenderTargetAdaptor\\] cannot get gpu color texture from a depth-only render target","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/rendering/renderers/gpu/renderTarget/GpuRenderTargetAdaptor.ts","lineNumber":231,"sourceCode":"    {\n        this._renderer.encoder.endRenderPass();\n\n        // The pass is now closed; a subsequent bind to the same target must genuinely reopen it\n        // (e.g. the copyToTexture / copyColor case, which reads the resolved contents).\n        this._activePass = null;\n    }\n\n    /**\n     * returns the gpu texture for the first color texture in the render target\n     * mainly used by the filter manager to get copy the texture for blending\n     * @param renderTarget\n     * @returns a gpu texture\n     */\n    private _getGpuColorTexture(renderTarget: RenderTarget): GPUTexture\n    {\n        if (renderTarget.colorAttachments.length === 0)\n        {\n            throw new Error('[GpuRenderTargetAdaptor] cannot get gpu color texture from a depth-only render target');\n        }\n\n        const colorTexture = renderTarget.colorAttachments[0].texture;\n\n        if (colorTexture instanceof CanvasSource && colorTexture._gpuContext)\n        {\n            return colorTexture._gpuContext.getCurrentTexture();\n        }\n\n        return this._renderer.texture.getGpuSource(colorTexture);\n    }\n\n    public getDescriptor(\n        renderTarget: RenderTarget,\n        clear: CLEAR_OR_BOOL,\n        clearValue: RgbaArray,\n        mipLevel = 0,\n        layer = 0","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/pixijs/pixijs/blob/4b141e3ced7255b39c2114b6bca03421a37b2363/src/rendering/renderers/gpu/renderTarget/GpuRenderTargetAdaptor.ts#L213-L249","documentation":"Thrown by GpuRenderTargetAdaptor._getGpuColorTexture() when asked for the GPU color texture of a render target that has zero color attachments (a depth-only target). There is no color texture to return, so the filter/blending copy that called this helper cannot proceed. The check is renderTarget.colorAttachments.length === 0.","triggerScenarios":"The filter manager (or any caller of _getGpuColorTexture) operating on a depth-only render target — e.g. applying a filter that needs to copy the color buffer for blending onto a target that has only a depth/stencil attachment.","commonSituations":"Applying a filter to a depth-only render target. Shadow-map targets accidentally routed through a filter/copy path. Misconfigured render target with colorAttachments omitted but depth/stencil present, used where a color texture is expected.","solutions":["Ensure any render target passed to filter/copy operations has at least one color attachment.","Avoid applying color-space filters to depth-only targets.","If you only need depth, use a depth-specific copy/read path rather than the color-texture helper."],"exampleFix":"// before\nconst depthOnly = new RenderTarget({ colorAttachments: [], depth: true, width: 1024, height: 1024 });\nfilterManager.applyFilter(depthOnly, someFilter); // internally calls _getGpuColorTexture -> throws\n\n// after\nconst withColor = new RenderTarget({ colorAttachments: [colorTex], depth: true, width: 1024, height: 1024 });\nfilterManager.applyFilter(withColor, someFilter);","handlingStrategy":"validation","validationCode":"function assertHasColorAttachment(rt: RenderTarget): void {\n  if (rt.colorAttachments.length === 0) {\n    throw new Error('Render target has no color attachment; cannot read color texture for filtering/blending.');\n  }\n}\nassertHasColorAttachment(rt);","typeGuard":"function hasColorAttachment(rt: RenderTarget): boolean {\n  return rt.colorAttachments.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Never route depth-only targets through filter/copy paths that read color.","Always include a color attachment on targets used with the filter manager.","Use a depth-specific copy path when only depth data is needed."],"tags":["webgpu","render-target","depth-only","filter","color-attachment"],"backgroundTag":null,"analyzedSha":"4b141e3ced7255b39c2114b6bca03421a37b2363","analyzedAt":"2026-08-12T17:27:29.507Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}