summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-11-13 13:35:56 -0500
committerGitHub <noreply@github.com>2019-11-13 13:35:56 -0500
commit9604118401f185c0e1a213b8e99dad060c6263bc (patch)
treeb2a651f72f8f6f10afad74ba7cdc91376aa0f2d5 /source
parent166a7387cb3a83b24dd4b9279877338c758eb8b6 (diff)
* Added getCStr(Name*) (#1121)
* Added the name to the EntryPointLayout so is always available * Made spReflectionEntryPoint_getName use name * Improved checking for entry point name in render-test * Improved COMPILE test type to allow failure and output of failure.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-name.cpp5
-rw-r--r--source/slang/slang-name.h3
-rw-r--r--source/slang/slang-parameter-binding.cpp1
-rw-r--r--source/slang/slang-reflection.cpp4
-rw-r--r--source/slang/slang-type-layout.h3
5 files changed, 13 insertions, 3 deletions
diff --git a/source/slang/slang-name.cpp b/source/slang/slang-name.cpp
index 8934b17bd..b6035982b 100644
--- a/source/slang/slang-name.cpp
+++ b/source/slang/slang-name.cpp
@@ -14,6 +14,11 @@ UnownedStringSlice getUnownedStringSliceText(Name* name)
return name ? name->text.getUnownedSlice() : UnownedStringSlice();
}
+const char* getCstr(Name* name)
+{
+ return name ? name->text.getBuffer() : nullptr;
+}
+
Name* NamePool::getName(String const& text)
{
RefPtr<Name> name;
diff --git a/source/slang/slang-name.h b/source/slang/slang-name.h
index de04d5fdf..cf702686b 100644
--- a/source/slang/slang-name.h
+++ b/source/slang/slang-name.h
@@ -39,6 +39,9 @@ String getText(Name* name);
/// Get the text as unowned string slice
UnownedStringSlice getUnownedStringSliceText(Name* name);
+// Get a name as a C style string, or nullptr if name is nullptr
+const char* getCstr(Name* name);
+
// A `RootNamePool` is used to store and look up names.
// If two systems need to work together with names, and be sure that they
// get equivalent names for a string like `"Foo"`, then they need to use
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index 33ad32918..5ea81c809 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -2166,6 +2166,7 @@ static RefPtr<EntryPointLayout> collectEntryPointParameters(
//
RefPtr<EntryPointLayout> entryPointLayout = new EntryPointLayout();
entryPointLayout->profile = entryPoint->getProfile();
+ entryPointLayout->name = entryPoint->getName();
// The entry point layout must be added to the output
// program layout so that it can be accessed by reflection.
diff --git a/source/slang/slang-reflection.cpp b/source/slang/slang-reflection.cpp
index f2c4973ed..59130b0fc 100644
--- a/source/slang/slang-reflection.cpp
+++ b/source/slang/slang-reflection.cpp
@@ -1210,9 +1210,7 @@ SLANG_API char const* spReflectionEntryPoint_getName(
SlangReflectionEntryPoint* inEntryPoint)
{
auto entryPointLayout = convert(inEntryPoint);
- if(!entryPointLayout) return 0;
-
- return getText(entryPointLayout->entryPoint.GetName()).begin();
+ return entryPointLayout ? getCstr(entryPointLayout->name) : nullptr;
}
SLANG_API unsigned spReflectionEntryPoint_getParameterCount(
diff --git a/source/slang/slang-type-layout.h b/source/slang/slang-type-layout.h
index ac0ef3bd7..fc638c3dd 100644
--- a/source/slang/slang-type-layout.h
+++ b/source/slang/slang-type-layout.h
@@ -658,6 +658,9 @@ public:
// The shader profile that was used to compile the entry point
Profile profile;
+ // The name of the entry point. Always available even if entryPoint is nullptr (for example when it came from a library)
+ Name* name = nullptr;
+
// Layout for any results of the entry point
RefPtr<VarLayout> resultLayout;