Skip to content

Commit

Permalink
move texture fetching docs to conceptual
Browse files Browse the repository at this point in the history
  • Loading branch information
parbenc committed Jul 29, 2024
1 parent c92f266 commit fbc9c1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ On non-AMD platforms, like NVIDIA, HIP provides header files required to support
* {doc}`./understand/programming_model_reference`
* {doc}`./understand/hardware_implementation`
* {doc}`./understand/amd_clr`
* [Texture Fetching](./understand/texture_fetching)

:::

Expand All @@ -46,7 +47,6 @@ On non-AMD platforms, like NVIDIA, HIP provides header files required to support
* [Debugging with HIP](./how-to/debugging)
* {doc}`./how-to/logging`
* [Unified Memory](./how-to/unified_memory)
* [Texture Fetching](./how-to/texture_fetching)
* {doc}`./how-to/faq`

:::
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/_toc.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ subtrees:
- file: understand/programming_model_reference
- file: understand/hardware_implementation
- file: understand/amd_clr
- file: understand/texture_fetching
title: Texture Fetching

- caption: How to
entries:
Expand All @@ -31,8 +33,6 @@ subtrees:
- file: how-to/logging
- file: how-to/unified_memory
title: Unified Memory
- file: how-to/texture_fetching
title: Texture Fetching
- file: how-to/faq

- caption: Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@
Texture Fetching
*******************************************************************************

Textures are more than just a buffer, that is interpreted as 1D, 2D or 3D array. Because
of its legacy as a graphics functionality, textures are indexed with floats. This can
happen two different ways, either the index will be in the range of [0..size-1] or in
[0..1]. The difference is mathematically just a division, so for the explanations on this
page, we'll use the [0..size-1] indices.
Textures are more than just a buffer, that is interpreted as 1D, 2D or 3D array. Because of its legacy as a graphics functionality, textures are indexed with floats. This can happen two different ways, either the index will be in the range of [0..size-1] or in [0..1]. The difference is mathematically just a division, so for the explanations on this page, we'll use the [0..size-1] indices.

Using float indices isn't trivial. You as a developer, have to decide what happens, when
the index is a fraction. There is no rule for how to choose between filtering methods, as
it is very dependent of the application.
Using float indices isn't trivial. You as a developer, have to decide what happens, when the index is a fraction. There is no rule for how to choose between filtering methods, as it is very dependent of the application.

.. _texture_fetching_nearest:
Nearest point sampling
===============================================================================

In this mode the ``tex(x) = T[floor(x)]`` and similarly for 2D and 3D variants. In
practice this will not interpolate between neighboring values, which results in a
pixelated look.
In this mode the ``tex(x) = T[floor(x)]`` and similarly for 2D and 3D variants. In practice this will not interpolate between neighboring values, which results in a pixelated look.

.. _texture_fetching_linear:
Linear filtering
Expand All @@ -35,6 +27,4 @@ Linear filtering method simply does a linear interpolation between values.
* For two dimensional textures it is ``tex(x,y) = (1-α)(1-β)T[i,j] + α(1-β)T[i+1,j] + (1-α)βT[i,j+1] + αβT[i+1,j+1]``
* For three dimensional textures it is ``tex(x,y,z) = (1-α)(1-β)(1-γ)T[i,j,k] + α(1-β)(1-γ)T[i+1,j,k] + (1-α)β(1-γ)T[i,j+1,k] + αβ(1-γ)T[i+1,j+1,k] + (1-α)(1-β)γT[i,j,k+1] + α(1-β)γT[i+1,j,k+1] + (1-α)βγT[i,j+1,k+1] + αβγT[i+1,j+1,k+1]``

Where ``i = round(x')``, ``α = frac(x')``, ``x' = x - 0.5``, ``j = round(y')``,
``β = frac(y')``, ``y' = y - 0.5``, ``k = round(z')``, ``γ = frac(z')`` and
``z' = z - 0.5``
Where ``i = round(x')``, ``α = frac(x')``, ``x' = x - 0.5``, ``j = round(y')``, ``β = frac(y')``, ``y' = y - 0.5``, ``k = round(z')``, ``γ = frac(z')`` and ``z' = z - 0.5``

0 comments on commit fbc9c1e

Please sign in to comment.