// Copyright (c) 2021 Qualcomm Technologies, Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

include::{generated}/meta/{refprefix}VK_QCOM_image_processing.adoc[]

=== Other Extension Metadata

*Last Modified Date*::
    2022-07-08
*Interactions and External Dependencies*::
  - This extension provides API support for
    {GLSLregistry}/qcom/GLSL_QCOM_image_processing.txt[`GL_QCOM_image_processing`]

*Contributors*::
  - Jeff Leger, Qualcomm Technologies, Inc.
  - Ruihao Zhang, Qualcomm Technologies, Inc.

=== Description

GPUs are commonly used to process images for various applications from 3D
graphics to UI and from composition to compute applications.
Simple scaling and filtering can be done with bilinear filtering, which
comes for free during texture sampling.
However, as screen sizes get larger and more use cases rely on GPU such as
camera and video post-processing needs, there is increasing demand for GPU
to support higher order filtering and other advanced image processing.

This extension introduces a new set of SPIR-V built-in functions for image
processing.
It exposes the following new imaging operations

  * The `OpImageSampleWeightedQCOM` instruction takes 3 operands: _sampled
    image_, _weight image_, and texture coordinates.
    The instruction computes a weighted average of an MxN region of texels
  in the _sampled image_, using a set of MxN weights in the _weight image_.
  * The `OpImageBoxFilterQCOM` instruction takes 3 operands: _sampled
    image_, _box size_, and texture coordinates.
    Note that _box size_ specifies a floating point width and height in
    texels.
    The instruction computes a weighted average of all texels in the
    _sampled image_ that are covered (either partially or fully) by a box
    with the specified size and centered at the specified texture
    coordinates.
  * The `OpImageBlockMatchSADQCOM` and `OpImageBlockMatchSSDQCOM`
    instructions each takes 5 operands: _target image_, _target
    coordinates_, _reference image_, _reference coordinates_, and _block
    size_.
    Each instruction computes an error metric, that describes whether a
    block of texels in the _target image_ matches a corresponding block of
    texels in the _reference image_.
    The error metric is computed per-component.
    `OpImageBlockMatchSADQCOM` computes "Sum Of Absolute Difference" and
    `OpImageBlockMatchSSDQCOM` computes "Sum of Squared Difference".

Each of the image processing instructions operate only on 2D images.
The instructions do not-support sampling of mipmap, multi-plane,
multi-layer, multi-sampled, or depth/stencil images.
The instructions can be used in any shader stage.

Implementations of this this extension should support these operations
natively at the HW instruction level, offering potential performance gains
as well as ease of development.

include::{generated}/interfaces/VK_QCOM_image_processing.adoc[]

=== Version History

  * Revision 1, 2022-07-08 (Jeff Leger)
