diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-02-18 14:14:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-18 14:14:16 -0500 |
| commit | 8ee39e08c48a315163fe1850dbb12ca292020d4d (patch) | |
| tree | 5041064a194849399aa587ac13b46db2088bdb05 /source/slang/core.meta.slang | |
| parent | e109985375712b449d365450b3d3e39416a171ce (diff) | |
First pass Texture Array support on CUDA/CPU (#1225)
* Add cubemap support.
* Add CUDA fence instrinsics.
* Added Gather for CUDA.
* Use the CUDA driver API as much as possible.
* * Support 1D texture on CPU
* WIP on 1D texture on CUDA
* Added simplified texture test
* Fix test.
* Improve texture-simple tests.
* * Add CPU support for 3d textures
* Add support for mip maps to CUDA
* Disable warnings in nvrtc
* Update CUDA docs
* WIP on 3d texture support.
* Add support for 3d textures for CPU and CUDA.
* CPU and CUDA support for cube maps.
* Add CPU support for Texture1DArray.
* Support CUDA Layered/Array type in meta library.
Diffstat (limited to 'source/slang/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 79 |
1 files changed, 62 insertions, 17 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 450cc4512..ec1a3ed0b 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -894,22 +894,47 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "__target_intrinsic(glsl, \"$ctexture($p, $2)$z\")\n"; - if( baseShape != TextureFlavor::Shape::ShapeCube ) + // CUDA { - sb << "__target_intrinsic(cuda, \"tex" << kBaseTextureTypes[tt].coordCount << "D<$T0>($0"; - for (int i = 0; i < kBaseTextureTypes[tt].coordCount; ++i) + const int coordCount = kBaseTextureTypes[tt].coordCount; + const int vecCount = coordCount + int(isArray); + + if( baseShape != TextureFlavor::Shape::ShapeCube ) { - sb << ", ($2)"; - if (kBaseTextureTypes[tt].coordCount > 1) + sb << "__target_intrinsic(cuda, \"tex" << coordCount << "D"; + if (isArray) { - sb << '.' << char(i + 'x'); + sb << "Layered"; } + sb << "<$T0>($0"; + for (int i = 0; i < coordCount; ++i) + { + sb << ", ($2)"; + if (vecCount > 1) + { + sb << '.' << char(i + 'x'); + } + } + if (isArray) + { + sb << ", int(($2)." << char(coordCount + 'x') << ")"; + } + sb << ")\")\n"; + } + else + { + sb << "__target_intrinsic(cuda, \"texCubemap"; + if (isArray) + { + sb << "Layered"; + } + sb << "<$T0>($0, ($2).x, ($2).y, ($2).z"; + if (isArray) + { + sb << ", int(($2).w)"; + } + sb << ")\")\n"; } - sb << ")\")\n"; - } - else - { - sb << "__target_intrinsic(cuda, \"texCubemap<$T0>($0, ($2).x, ($2).y, ($2).z)\")\n"; } sb << "T Sample(SamplerState s, "; @@ -939,7 +964,6 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) } sb << "float clamp, out uint status);\n"; - // `SampleBias()` sb << "__target_intrinsic(glsl, \"$ctexture($p, $2, $3)$z\")\n"; sb << "T SampleBias(SamplerState s, "; @@ -1054,24 +1078,45 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "__target_intrinsic(glsl, \"$ctextureLod($p, $2, $3)$z\")\n"; // CUDA - if (!isArray) { + const int coordCount = kBaseTextureTypes[tt].coordCount; + const int vecCount = coordCount + int(isArray); + if( baseShape != TextureFlavor::Shape::ShapeCube ) { - sb << "__target_intrinsic(cuda, \"tex" << kBaseTextureTypes[tt].coordCount << "DLod<$T0>($0"; - for (int i = 0; i < kBaseTextureTypes[tt].coordCount; ++i) + sb << "__target_intrinsic(cuda, \"tex" << coordCount << "D"; + if (isArray) + { + sb << "Layered"; + } + sb << "Lod<$T0>($0"; + for (int i = 0; i < coordCount; ++i) { sb << ", ($2)"; - if (kBaseTextureTypes[tt].coordCount > 1) + if (vecCount > 1) { sb << '.' << char(i + 'x'); } } + if (isArray) + { + sb << ", int(($2)." << char(coordCount + 'x') << ")"; + } sb << ", $3)\")\n"; } else { - sb << "__target_intrinsic(cuda, \"texCubemap<$T0>($0, ($2).x, ($2).y, ($2).z)\")\n"; + sb << "__target_intrinsic(cuda, \"texCubemap"; + if (isArray) + { + sb << "Layered"; + } + sb << "Lod<$T0>($0, ($2).x, ($2).y, ($2).z"; + if (isArray) + { + sb << ", int(($2).w)"; + } + sb << ", $3)\")\n"; } } |
