summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-01-27 15:04:29 -0500
committerGitHub <noreply@github.com>2020-01-27 15:04:29 -0500
commita9e1beeb003644f4034b9485ad00e273ad52c9f1 (patch)
treeb93ef4d3e3c972798f6a76a4bdd0d6d4c369924c /source
parentd98a2b75c9b4a31de0ebfb1084a68b5be5ede17d (diff)
CUDA implement StructuredBuffer/ByteAddressBuffer as pointer/count as is on CPU. (#1182)
Allow bounds check to zero index. Update docs.
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-nvrtc-compiler.cpp22
-rw-r--r--source/slang/slang-emit-cuda.cpp15
-rw-r--r--source/slang/slang-type-layout.cpp20
3 files changed, 29 insertions, 28 deletions
diff --git a/source/core/slang-nvrtc-compiler.cpp b/source/core/slang-nvrtc-compiler.cpp
index bc7d1f4f6..6464592a5 100644
--- a/source/core/slang-nvrtc-compiler.cpp
+++ b/source/core/slang-nvrtc-compiler.cpp
@@ -174,6 +174,16 @@ static SlangResult _parseLocation(const UnownedStringSlice& in, DownstreamDiagno
return SLANG_OK;
}
+static bool _isDriveLetter(char c)
+{
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+}
+
+static bool _hasDriveLetter(const UnownedStringSlice& line)
+{
+ return line.size() > 2 && line[1] == ':' && _isDriveLetter(line[0]);
+}
+
static SlangResult _parseNVRTCLine(const UnownedStringSlice& line, DownstreamDiagnostic& outDiagnostic)
{
typedef DownstreamDiagnostic Diagnostic;
@@ -182,7 +192,17 @@ static SlangResult _parseNVRTCLine(const UnownedStringSlice& line, DownstreamDia
outDiagnostic.stage = Diagnostic::Stage::Compile;
List<UnownedStringSlice> split;
- StringUtil::split(line, ':', split);
+ if (_hasDriveLetter(line))
+ {
+ // The drive letter has :, which confuses things, so skip that and then fix up first entry
+ UnownedStringSlice lineWithoutDrive(line.begin() + 2, line.end());
+ StringUtil::split(lineWithoutDrive, ':', split);
+ split[0] = UnownedStringSlice(line.begin(), split[0].end());
+ }
+ else
+ {
+ StringUtil::split(line, ':', split);
+ }
if (split.getCount() == 3)
{
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp
index 26d6eada0..83ad4a0f8 100644
--- a/source/slang/slang-emit-cuda.cpp
+++ b/source/slang/slang-emit-cuda.cpp
@@ -254,21 +254,6 @@ SlangResult CUDASourceEmitter::calcTypeName(IRType* type, CodeGenTarget target,
out << prefix << vecCount;
return SLANG_OK;
}
- case kIROp_HLSLStructuredBufferType:
- {
- auto bufferType = as<IRHLSLStructuredBufferType>(type);
- out << "const ";
- calcTypeName(bufferType->getElementType(), target, out);
- out << "* ";
- return SLANG_OK;
- }
- case kIROp_HLSLRWStructuredBufferType:
- {
- auto bufferType = as<IRHLSLRWStructuredBufferType>(type);
- calcTypeName(bufferType->getElementType(), target, out);
- out << "* ";
- return SLANG_OK;
- }
#if 0
case kIROp_MatrixType:
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index cf793b52d..2eec26ee6 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -694,29 +694,29 @@ struct CPUObjectLayoutRulesImpl : ObjectLayoutRulesImpl
{
case ShaderParameterKind::ConstantBuffer:
// It's a pointer to the actual uniform data
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), sizeof(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), SLANG_ALIGN_OF(void*));
case ShaderParameterKind::MutableTexture:
case ShaderParameterKind::TextureUniformBuffer:
case ShaderParameterKind::Texture:
// It's a pointer to a texture interface
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), sizeof(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), SLANG_ALIGN_OF(void*));
case ShaderParameterKind::StructuredBuffer:
case ShaderParameterKind::MutableStructuredBuffer:
// It's a ptr and a size of the amount of elements
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, sizeof(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, SLANG_ALIGN_OF(void*));
case ShaderParameterKind::RawBuffer:
case ShaderParameterKind::Buffer:
case ShaderParameterKind::MutableRawBuffer:
case ShaderParameterKind::MutableBuffer:
// It's a pointer and a size in bytes
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, sizeof(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, SLANG_ALIGN_OF(void*));
case ShaderParameterKind::SamplerState:
// It's a pointer
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), sizeof(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), SLANG_ALIGN_OF(void*));
case ShaderParameterKind::TextureSampler:
case ShaderParameterKind::MutableTextureSampler:
@@ -756,19 +756,15 @@ struct CUDAObjectLayoutRulesImpl : CPUObjectLayoutRulesImpl
case ShaderParameterKind::StructuredBuffer:
case ShaderParameterKind::MutableStructuredBuffer:
- // TODO(JS): We are just storing as a pointer for now
- // It's a ptr and a size of the amount of elements
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), SLANG_ALIGN_OF(void*));
+ // It's a pointer and a size
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, SLANG_ALIGN_OF(void*));
case ShaderParameterKind::RawBuffer:
case ShaderParameterKind::Buffer:
case ShaderParameterKind::MutableRawBuffer:
case ShaderParameterKind::MutableBuffer:
-
- // TODO(JS): We are storing as a pointer for now
-
// It's a pointer and a size in bytes
- return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*), SLANG_ALIGN_OF(void*));
+ return SimpleLayoutInfo(LayoutResourceKind::Uniform, sizeof(void*) * 2, SLANG_ALIGN_OF(void*));
case ShaderParameterKind::SamplerState:
// In CUDA it seems that sampler states are combined into texture objects.