From 8ee39e08c48a315163fe1850dbb12ca292020d4d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 18 Feb 2020 14:14:16 -0500 Subject: 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. --- source/slang/core.meta.slang | 79 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 17 deletions(-) (limited to 'source/slang/core.meta.slang') 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"; } } -- cgit v1.2.3