summaryrefslogtreecommitdiffstats
path: root/source/slang/core.meta.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-02-20 18:24:00 -0500
committerGitHub <noreply@github.com>2020-02-20 15:24:00 -0800
commit1f401d04e32c6feaeb35243ea5bfc2b14520344b (patch)
tree64394bc2f9fbef3dec3237c69604a0277d019f3c /source/slang/core.meta.slang
parentf9d99fde581c7dfdeb46e87f32da1fed8ac5441c (diff)
WIP on RWTexture types on CUDA/CPU (#1234)
* CUDA support for array of resources. * * Add support for Texture2DArray on CPU * Expand texture-simple.slang to test Texture2DArray * Reorganise CUDAComputeUtil to split out createTextureResource. * Add TextureCubeArray support for CPU/CUDA targets. * Pulled out CUDAResource Renamed derived classes to reflect that change. * Creation of SurfObject type. * Functions to return read/write access for simplifying future additions. * WIP for RWTexture access on CPU/CUDA. * CUsurfObject cannot have mips. * Ability to set number of mips on test data. Preliminary support for CUsurfObj and RWTexture1D on CUDA. CUDA docs improvements. * Fix typo.
Diffstat (limited to 'source/slang/core.meta.slang')
-rw-r--r--source/slang/core.meta.slang65
1 files changed, 65 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index ec1a3ed0b..722629034 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -777,6 +777,67 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << ")$z\")\n";
}
+
+ // CUDA
+ if (isMultisample)
+ {
+ }
+ else
+ {
+ if (access == SLANG_RESOURCE_ACCESS_READ_WRITE)
+ {
+ const int coordCount = kBaseTextureTypes[tt].coordCount;
+ const int vecCount = coordCount + int(isArray);
+
+ if( baseShape != TextureFlavor::Shape::ShapeCube )
+ {
+ sb << "__target_intrinsic(cuda, \"surf" << coordCount << "D";
+ if (isArray)
+ {
+ sb << "Layered";
+ }
+ sb << "read";
+ sb << "<$T0>($0";
+ for (int i = 0; i < coordCount; ++i)
+ {
+ sb << ", ($1)";
+ if (vecCount > 1)
+ {
+ sb << '.' << char(i + 'x');
+ }
+ }
+ if (isArray)
+ {
+ sb << ", int(($1)." << char(coordCount + 'x') << ")";
+ }
+ sb << ", SLANG_CUDA_BOUNDARY_MODE)\")\n";
+ }
+ else
+ {
+ sb << "__target_intrinsic(cuda, \"surfCubemap";
+ if (isArray)
+ {
+ sb << "Layered";
+ }
+ sb << "read";
+ sb << "<$T0>($0, ($1).x, ($1).y, ($1).z";
+ if (isArray)
+ {
+ sb << ", int(($1).w)";
+ }
+ sb << ", SLANG_CUDA_BOUNDARY_MODE)\")\n";
+ }
+ }
+ else if (access == SLANG_RESOURCE_ACCESS_READ)
+ {
+ // We can allow this on Texture1D
+ if( baseShape == TextureFlavor::Shape::Shape1D && isArray == false)
+ {
+ sb << "__target_intrinsic(cuda, \"tex1Dfetch<$T0>($0, ($1).x)\")\n";
+ }
+ }
+ }
+
sb << "T Load(";
sb << "int" << loadCoordCount << " location";
if(isMultisample)
@@ -785,6 +846,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
}
sb << ");\n";
+ // GLSL
if (isMultisample)
{
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
@@ -804,6 +866,9 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
}
sb << ", $2)$z\")\n";
}
+
+
+
sb << "T Load(";
sb << "int" << loadCoordCount << " location";
if(isMultisample)