Repository: pixijs/pixijs
File: src/rendering/renderers/gpu/pipeline/PipelineSystem.ts (TypeScript)

Code before:
        if (this._bufferLayoutsCache[geometry._layoutKey])
        {
            return this._bufferLayoutsCache[geometry._layoutKey];
        }

        const vertexBuffersLayout: GPUVertexBufferLayout[] = [];

        geometry.buffers.forEach((buffer) =>
        {
            const bufferEntry: GPUVertexBufferLayout = {
                arrayStride: 0,
                stepMode: 'vertex',
                attributes: [],
            };

            const bufferEntryAttributes = bufferEntry.attributes as GPUVertexAttribute[];

            for (const i in geometry.attributes)
            {
                const attribute = geometry.attributes[i];

                if ('divisor' in attribute)
                {
                    // TODO: Maybe emulate divisor with storage_buffers/float_textures?
                    // For now just issue a warning
                    warn(`Attribute ${i} has 'divisor' field set, which is currently unsupported in WebGPURenderer.`);
                }

                if (attribute.buffer === buffer)
                {
                    bufferEntry.arrayStride = attribute.stride;
                    bufferEntry.stepMode = attribute.instance ? 'instance' : 'vertex';

                    bufferEntryAttributes.push({
                        shaderLocation: attribute.location,
                        offset: attribute.offset,
                        format: attribute.format,
                    });
                }
            }

            if (bufferEntryAttributes.length)
            {
                vertexBuffersLayout.push(bufferEntry);
            }
        });

        this._bufferLayoutsCache[geometry._layoutKey] = vertexBuffersLayout;

        return vertexBuffersLayout;
    }

Review comment (suggestion):
this is great! i think we should trow this warning only if the divoser is not 1.

`Attribute ${i} has an invalid 'divisor' value of 'X'. WebGPU only supports a divisor value of 1.`

Code after:
        if (this._bufferLayoutsCache[geometry._layoutKey])
        {
            return this._bufferLayoutsCache[geometry._layoutKey];
        }

        const vertexBuffersLayout: GPUVertexBufferLayout[] = [];

        geometry.buffers.forEach((buffer) =>
        {
            const bufferEntry: GPUVertexBufferLayout = {
                arrayStride: 0,
                stepMode: 'vertex',
                attributes: [],
            };

            const bufferEntryAttributes = bufferEntry.attributes as GPUVertexAttribute[];

            for (const i in geometry.attributes)
            {
                const attribute = geometry.attributes[i];

                if ((attribute.divisor ?? 1) !== 1)
                {
                    // TODO: Maybe emulate divisor with storage_buffers/float_textures?
                    // For now just issue a warning
                    warn(`Attribute ${i} has an invalid divisor value of '${attribute.divisor}'. `
                        + 'WebGPU only supports a divisor value of 1');
                }

                if (attribute.buffer === buffer)
                {
                    bufferEntry.arrayStride = attribute.stride;
                    bufferEntry.stepMode = attribute.instance ? 'instance' : 'vertex';

                    bufferEntryAttributes.push({
                        shaderLocation: attribute.location,
                        offset: attribute.offset,
                        format: attribute.format,
                    });
                }
            }

            if (bufferEntryAttributes.length)
            {
                vertexBuffersLayout.push(bufferEntry);
            }
        });

        this._bufferLayoutsCache[geometry._layoutKey] = vertexBuffersLayout;

        return vertexBuffersLayout;